Java Code Examples for org.eclipse.ui.forms.IManagedForm#getForm()

The following examples show how to use org.eclipse.ui.forms.IManagedForm#getForm() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractFormPage.java    From typescript.java with MIT License 6 votes vote down vote up
@Override
protected void createFormContent(IManagedForm managedForm) {
	final ScrolledForm form = managedForm.getForm();
	FormToolkit toolkit = managedForm.getToolkit();
	toolkit.decorateFormHeading(form.getForm());

	IToolBarManager manager = form.getToolBarManager();
	if (contributeToToolbar(manager)) {
		form.updateToolBar();
	}
	String titleText = getFormTitleText();
	if (titleText != null) {
		form.setText(titleText);
	}
	Image titleImage = getFormTitleImage();
	if (titleImage != null) {
		form.setImage(titleImage);
	}
	toolkit.decorateFormHeading(form.getForm());
	createUI(managedForm);
}
 
Example 2
Source File: SimulationPage.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
@Override
protected void createFormContent(IManagedForm mform) {
	form = mform.getForm();
	FormToolkit tk = mform.getToolkit();
	form.setText(M.MonteCarloSimulation);
	tk.decorateFormHeading(form.getForm());
	Composite body = UI.formBody(form, tk);
	createSettingsSection(tk, body);

	PinBoard pinBoard = new PinBoard(simulator);
	pinBoard.create(tk, body);
	pinBoard.onResultPinChange = (pp) -> {
		this.resultPin = pp;
		updateSelection();
	};

	createProgressSection(tk, body);
	createResultSection(tk, body);
	form.reflow(true);
}
 
Example 3
Source File: ReportViewer.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
@Override
protected void createFormContent(IManagedForm mform) {
	ScrolledForm form = mform.getForm();
	Composite comp = form.getBody();
	comp.setLayout(new FillLayout());
	try {
		Browser b = new Browser(comp, SWT.NONE);
		b.setJavascriptEnabled(true);
		UI.onLoaded(b, HtmlFolder.getUrl("report.html"), () -> {
			Gson gson = new Gson();
			String json = gson.toJson(report);
			String command = "setData(" + json + ")";
			b.execute(command);
		});
	} catch (Exception e) {
		Logger log = LoggerFactory.getLogger(getClass());
		log.error("failed to load report in browser", e);
	}
}
 
Example 4
Source File: ErrorMessageFormPage.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void createFormContent(IManagedForm managedForm) {
	// Local Declarations
	final ScrolledForm form = managedForm.getForm();
	GridLayout layout = new GridLayout();

	// Setup the layout and layout data
	layout.numColumns = 1;
	form.getBody().setLayoutData(
			new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	form.getBody().setLayout(new FillLayout());

	String errorMsg = "There is no data to show in your Form or in this "
			+ "particular component. Please file a bug or email "
			+ "[email protected].";
	managedForm.getToolkit().createText(form.getBody(), errorMsg);

	return;
}
 
Example 5
Source File: ConfigureRepositoriesDialog.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void createFormContent(IManagedForm mform) {
	ScrolledForm form = mform.getForm();
	FormToolkit toolkit = mform.getToolkit();
	UI.formHeader(mform, M.ConfigureRepositories);
	Composite body = UI.formBody(form, toolkit);
	viewer = new RepositoryConfigViewer(body);
	Tables.bindColumnWidths(viewer.getViewer(), 0.4, 0.3, 0.2, 0.1);
	viewer.setInput(RepositoryConfig.loadAll(Database.get()));
	Actions.bind(viewer.getViewer(), new AddAction(), new RemoveAction());
}
 
Example 6
Source File: AddRepositoryDialog.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void createFormContent(IManagedForm mform) {
	ScrolledForm form = mform.getForm();
	FormToolkit toolkit = mform.getToolkit();
	UI.formHeader(mform, M.AddNewRepository);
	Composite body = UI.formBody(form, toolkit);
	UI.gridLayout(body, 3);
	createConfigViewer(body, toolkit);
	createRepositoryViewer(body, toolkit);
	initConfigViewer();

}
 
Example 7
Source File: LogFileEditor.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void createFormContent(IManagedForm mform) {
	ScrolledForm form = mform.getForm();
	FormToolkit toolkit = mform.getToolkit();
	UI.formHeader(mform, M.OpenLCALog);
	Composite body = UI.formBody(form, toolkit);
	Browser browser = new Browser(body, SWT.NONE);
	UI.gridData(browser, true, true);
	try {
		browser.setUrl(file.toURI().toURL().toString());
	} catch (IOException e) {
		log.error("Error loading log files", e);
	}
}
 
Example 8
Source File: HeaderPageWithSash.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the tool bar actions.
 *
 * @param managedForm the managed form
 */
protected void createToolBarActions(IManagedForm managedForm) {
  final ScrolledForm form = managedForm.getForm();

  haction = new Action("hor", IAction.AS_RADIO_BUTTON) { //$NON-NLS-1$
    @Override
    public void run() {
      sashForm.setOrientation(SWT.HORIZONTAL);
      form.reflow(true);
    }
  };
  haction.setChecked(true);
  haction.setToolTipText("Horizontal Orientation");
  TAEConfiguratorPlugin instance = TAEConfiguratorPlugin.getDefault();
  haction.setImageDescriptor(instance
          .getImageDescriptor(TAEConfiguratorPlugin.IMAGE_TH_HORIZONTAL));
  haction.setDisabledImageDescriptor(instance
          .getImageDescriptor(TAEConfiguratorPlugin.IMAGE_TH_HORIZONTAL));

  vaction = new Action("ver", IAction.AS_RADIO_BUTTON) { //$NON-NLS-1$
    @Override
    public void run() {
      sashForm.setOrientation(SWT.VERTICAL);
      form.reflow(true);
    }
  };
  vaction.setChecked(false);
  vaction.setToolTipText("Vertical Orientation");
  vaction.setImageDescriptor(instance
          .getImageDescriptor(TAEConfiguratorPlugin.IMAGE_TH_VERTICAL));
  vaction.setDisabledImageDescriptor(instance
          .getImageDescriptor(TAEConfiguratorPlugin.IMAGE_TH_VERTICAL));
  form.getToolBarManager().add(haction);
  form.getToolBarManager().add(vaction);
  form.updateToolBar();
  maybeInitialize(managedForm);
}
 
Example 9
Source File: HeaderPage.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Setup 2 column layout not sash.
 *
 * @param managedForm the managed form
 * @param equalWidth the equal width
 * @return the form 2 panel
 */
public Form2Panel setup2ColumnLayoutNotSash(IManagedForm managedForm, boolean equalWidth) {
  final ScrolledForm sform = managedForm.getForm();
  final Composite form = sform.getBody();
  GridLayout layout = new GridLayout(2, equalWidth);
  form.setLayout(layout);
  form.setLayoutData(new GridData(GridData.FILL_BOTH));
  leftPanel = newComposite(form);
  rightPanel = newComposite(form);
  // strategy for setting size hints of right and left panels
  // Why set hints? Because they make the inner containing things
  // scroll horiz. if they're too wide (useful for aggregates having
  // long names).
  // What hint to set? The hint should be the smallest size you want
  // with child scrolling, before the tabbed page container itself
  // gets a scroll bar.
  // When in the life cycle to do this? Only need to do it once, but
  // after the Grid Layout has happened. This can be the first resizing
  // event (learned this by debugging)

  sform.addListener(SWT.Resize, new Listener() {
    @Override
    public void handleEvent(Event event) {
      float col1CurrentWidth = leftPanel.getSize().x;
      float col2CurrentWidth = rightPanel.getSize().x;
      final int minLeftPanelWidth = 250; // in pels
      final int minRightPanelWidth = (int) (col2CurrentWidth * minLeftPanelWidth / col1CurrentWidth);
      ((GridData) leftPanel.getLayoutData()).widthHint = minLeftPanelWidth;
      ((GridData) rightPanel.getLayoutData()).widthHint = minRightPanelWidth;
      sform.removeListener(SWT.Resize, this); // only do this one time
    }
  });
  return new Form2Panel(form, leftPanel, rightPanel);
}
 
Example 10
Source File: HeaderPage.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Setup 2 column layout.
 *
 * @param managedForm the managed form
 * @param w1 the w 1
 * @param w2 the w 2
 * @return the form 2 panel
 */
public Form2Panel setup2ColumnLayout(IManagedForm managedForm, int w1, int w2) {
  final ScrolledForm sform = managedForm.getForm();
  final Composite form = sform.getBody();
  form.setLayout(new GridLayout(1, false)); // this is required !
  Composite xtra = toolkit.createComposite(form);
  xtra.setLayout(new GridLayout(1, false));
  xtra.setLayoutData(new GridData(GridData.FILL_BOTH));
  Control c = xtra.getParent();
  while (!(c instanceof ScrolledComposite))
    c = c.getParent();
  ((GridData) xtra.getLayoutData()).widthHint = c.getSize().x;
  ((GridData) xtra.getLayoutData()).heightHint = c.getSize().y;
  sashForm = new SashForm(xtra, SWT.HORIZONTAL);

  sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); // needed

  leftPanel = newComposite(sashForm);
  ((GridLayout) leftPanel.getLayout()).marginHeight = 5;
  ((GridLayout) leftPanel.getLayout()).marginWidth = 5;
  rightPanel = newComposite(sashForm);
  ((GridLayout) rightPanel.getLayout()).marginHeight = 5;
  ((GridLayout) rightPanel.getLayout()).marginWidth = 5;
  sashForm.setWeights(new int[] { w1, w2 });
  leftPanelPercent = (float) w1 / (float) (w1 + w2);
  rightPanelPercent = (float) w2 / (float) (w1 + w2);

  rightPanel.addControlListener(new ControlAdapter() {
    @Override
    public void controlResized(ControlEvent e) {
      setSashFormWidths();
    }
  });

  return new Form2Panel(form, leftPanel, rightPanel);
}
 
Example 11
Source File: StartPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void createFormContent(IManagedForm mform) {
	ScrolledForm form = mform.getForm();
	Composite comp = form.getBody();
	comp.setLayout(new FillLayout());
	Browser browser = new Browser(comp, SWT.NONE);
	browser.setJavascriptEnabled(true);

	// handles link clicks and opens them in the browser
	UI.bindFunction(browser, "onOpenLink", (args) -> {
		if (args == null || args.length == 0)
			return null;
		Object s = args[0];
		if (!(s instanceof String))
			return null;
		Desktop.browse(s.toString());
		return null;
	});

	// handles click on the "native library hint"
	UI.bindFunction(browser, "onLibHintClick", (args) -> {
		LibraryDownload.open();
		return null;
	});

	// set the start page configuration
	UI.onLoaded(browser, HtmlFolder.getUrl("home.html"), () -> {
		HashMap<String, Object> config = new HashMap<>();
		config.put("version", getVersion());
		String lang = AppArg.get("nl");
		config.put("lang", Strings.nullOrEmpty(lang) ? "en" : lang);
		config.put("showLibHint", !Julia.isWithUmfpack());
		String json = new Gson().toJson(config);
		browser.execute("setData(" + json + ")");
	});
}
 
Example 12
Source File: HeaderPage.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Setup 1 column layout.
 *
 * @param managedForm the managed form
 * @return the composite
 */
public Composite setup1ColumnLayout(IManagedForm managedForm) {
  final ScrolledForm sform = managedForm.getForm();
  final Composite form = sform.getBody();
  form.setLayout(new GridLayout(1, false)); // this is required !
  Composite xtra = toolkit.createComposite(form);
  xtra.setLayout(new GridLayout(1, false));
  xtra.setLayoutData(new GridData(GridData.FILL_BOTH));

  Control c = form.getParent();
  while (!(c instanceof ScrolledComposite))
    c = c.getParent();
  ((GridData) xtra.getLayoutData()).widthHint = c.getSize().x;
  return xtra;
}
 
Example 13
Source File: AbstractFormPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void createFormContent(IManagedForm managedForm) {
    toolkit = managedForm.getToolkit();
    scrolledForm = managedForm.getForm();
    scrolledForm.setHeadClient(createHeader(scrolledForm.getForm()));
    scrolledForm.getBody().setLayout(GridLayoutFactory.swtDefaults().create());
    scrolledForm.getBody().setLayoutData(GridDataFactory.fillDefaults().create());
    createForm();
}
 
Example 14
Source File: ICEScrolledPropertiesBlock.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <p>
 * This operation creates actions in the toolbar for the block.
 * </p>
 * 
 * @param managedForm
 *            <p>
 *            The parent Form
 *            </p>
 */
@Override
protected void createToolBarActions(IManagedForm managedForm) {
	final ScrolledForm form = managedForm.getForm();
	Action haction = new Action("Horizontal Orientation",
			IAction.AS_RADIO_BUTTON) {
		@Override
		public void run() {
			sashForm.setOrientation(SWT.HORIZONTAL);
			form.reflow(true);
		}
	};
	haction.setChecked(true);
	haction.setToolTipText("Set Details to the Right of Masters");
	Action vaction = new Action("Vertical Orientation",
			IAction.AS_RADIO_BUTTON) {
		@Override
		public void run() {
			sashForm.setOrientation(SWT.VERTICAL);
			form.reflow(true);
		}
	};
	vaction.setChecked(false);
	vaction.setToolTipText("Set Details Below Masters");
	form.getToolBarManager().add(haction);
	form.getToolBarManager().add(vaction);
}
 
Example 15
Source File: ICEMasterDetailsPage.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <p>
 * This operation overrides the default/abstract implementation of
 * FormPage.createFormContents to create the contents of the
 * ICEMasterDetailsPage.
 * </p>
 * 
 * @param managedForm
 *            <p>
 *            The Form widget on which the ICEMasterDetailsPage exists.
 *            </p>
 */
@Override
protected void createFormContent(IManagedForm managedForm) {

	// Set the Form
	final ScrolledForm scrolledForm = managedForm.getForm();

	FormToolkit toolkit = managedForm.getToolkit();
	Section section = toolkit.createSection(scrolledForm.getBody(),
			Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);

	GridData gd = new GridData(GridData.FILL_HORIZONTAL);
	section.setLayoutData(gd);

	// Set the MasterDetailsComponent's "header component" that contains
	// global data if it exists.
	ICEDataComponentSectionPart headerSectionPart = new ICEDataComponentSectionPart(
			section, ICEFormEditor, managedForm);
	DataComponent header = masterDetailsComponent.getGlobalsComponent();
	if (header != null) {
		headerSectionPart.setDataComponent(header);
		headerSectionPart.renderSection();
	}

	// Get the Provider
	ICEDetailsPageProvider pageProvider = new ICEDetailsPageProvider(
			masterDetailsComponent, ICEFormEditor);

	// Create a scrolledPropertiesBlock with given providers.
	block = new ICEScrolledPropertiesBlock(masterDetailsComponent,
			ICEFormEditor, pageProvider);
	block.createContent(managedForm);

}
 
Example 16
Source File: UI.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
public static ScrolledForm formHeader(IManagedForm mform, String title, Image image) {
	ScrolledForm form = mform.getForm();
	FormToolkit tk = mform.getToolkit();
	tk.getHyperlinkGroup().setHyperlinkUnderlineMode(
			HyperlinkSettings.UNDERLINE_HOVER);
	if (title != null)
		form.setText(title);
	if (image != null)
		form.setImage(image);
	tk.decorateFormHeading(form.getForm());
	return form;
}
 
Example 17
Source File: AbstactConfigEditorPage.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void createFormContent(IManagedForm managedForm) {
	final ScrolledForm form = managedForm.getForm();
	LaunchCordovaPluginWizardAction action = new LaunchCordovaPluginWizardAction(getConfigEditor());
	form.getToolBarManager().add(action);
	form.updateToolBar();
}
 
Example 18
Source File: ListComponentSectionPage.java    From ice with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void createFormContent(IManagedForm managedForm) {

	// Get the parent form and the toolkit
	final ScrolledForm scrolledForm = managedForm.getForm();
	final FormToolkit formToolkit = managedForm.getToolkit();

	// Set a GridLayout with a single column. Remove the default margins.
	GridLayout layout = new GridLayout(1, true);
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	scrolledForm.getBody().setLayout(layout);

	// Only create something if there is valid input.
	if (list != null) {

		// Get the parent
		Composite parent = managedForm.getForm().getBody();

		shell = parent.getShell();
		// Create the section and set its layout info
		Section listSection = formToolkit.createSection(parent,
				ExpandableComposite.TITLE_BAR | Section.DESCRIPTION
						| ExpandableComposite.TWISTIE
						| ExpandableComposite.EXPANDED
						| ExpandableComposite.COMPACT);
		listSection.setLayout(new GridLayout(1, false));
		listSection.setLayoutData(
				new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		// Create the section client, which is the client area of the
		// section that will actually render data.
		sectionClient = new Composite(listSection, SWT.FLAT);
		sectionClient.setLayout(new GridLayout(2, false));
		sectionClient.setLayoutData(
				new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		// Fixes section header bug where label color is spammed
		sectionClient.setBackground(
				Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		// Fixes background color bug for NatTable
		sectionClient.setBackgroundMode(SWT.INHERIT_FORCE);

		// Draws the table and sets that instance variable
		table = new ListComponentNattable(sectionClient, list, true);

		// Create the buttons for add, delete, up, and down
		createButtons();

		// Set the section client.
		listSection.setClient(sectionClient);
	}

	return;
}
 
Example 19
Source File: PropertiesPage.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void createFormContent(IManagedForm managedForm) {
	super.createFormContent(managedForm);
	final ScrolledForm form = managedForm.getForm();
	
	formToolkit.decorateFormHeading( form.getForm());
	managedForm.getForm().setText(getTitle());

	GridLayout formGridLayout = new GridLayout();
	formGridLayout.horizontalSpacing = FormUtils.FORM_BODY_HORIZONTAL_SPACING;
	formGridLayout.verticalSpacing = FormUtils.FORM_BODY_VERTICAL_SPACING;
	formGridLayout.marginBottom = FormUtils.FORM_BODY_MARGIN_BOTTOM;
	formGridLayout.marginTop = FormUtils.FORM_BODY_MARGIN_TOP;
	formGridLayout.marginRight = FormUtils.FORM_BODY_MARGIN_RIGHT;
	formGridLayout.marginLeft = FormUtils.FORM_BODY_MARGIN_LEFT;
	formGridLayout.marginWidth =FormUtils.FORM_BODY_MARGIN_WIDTH;
	formGridLayout.marginHeight = FormUtils.FORM_BODY_MARGIN_HEIGHT;
	formGridLayout.makeColumnsEqualWidth = true;
	formGridLayout.numColumns = 2;
	Composite body = managedForm.getForm().getBody();
	body.setLayout(formGridLayout);
	
	Composite left, right;
	left = formToolkit.createComposite(body);
	left.setLayout(FormUtils.createFormPaneGridLayout(false, 1));
	GridDataFactory.fillDefaults().grab(true, true).applyTo(left);;
	right = formToolkit.createComposite(body);
	right.setLayout(FormUtils.createFormPaneGridLayout(false, 1));
	GridDataFactory.fillDefaults().grab(true, true).applyTo(right);
	
	
	createFeaturesSection(left);
	createFeatureParamsSection(right);
	createPreferencesSection(left);
	createAccessSection(right);
	
	m_bindingContext = initDataBindings();
	
	selectFirstFeature();
	
}
 
Example 20
Source File: BasicFormPage.java    From tlaplus with MIT License 4 votes vote down vote up
/**
  * Called during FormPage life cycle and delegates the form creation
  * to three methods {@link BasicFormPage#createBodyContent(IManagedForm)}, 
  * {@link BasicFormPage#loadData()}, {@link BasicFormPage#pageInitializationComplete()}
  */
 protected void createFormContent(IManagedForm managedForm)
 {
     ScrolledForm formWidget = managedForm.getForm();
     formWidget.setText(getTitle());
     if (imagePathTemplate != null)
     {
// Show the given image left of the form page's title and beneath the tab
// bar. E.g. the main model page displays three sliders left of its "Model
// Overview" label.
         formWidget.setImage(createRegisteredImage(24));
     }

     Composite body = formWidget.getBody();

     FormToolkit toolkit = managedForm.getToolkit();
     toolkit.decorateFormHeading(formWidget.getForm());

     /*
      * The head client is the second row of the header section, below the title; if we don't create this
      * with 'NO_FOCUS' then the toolbar will always take focus on a form page that gains focus.
      */
     ToolBar headClientTB = new ToolBar(formWidget.getForm().getHead(), SWT.HORIZONTAL | SWT.NO_FOCUS);
     headClientTBM = new ToolBarManager(headClientTB);
     // run button
     headClientTBM.add(new DynamicContributionItem(new RunAction()));
     // validate button
     headClientTBM.add(new DynamicContributionItem(new GenerateAction()));
     // stop button
     headClientTBM.add(new DynamicContributionItem(new StopAction()));

     // refresh the head client toolbar
     headClientTBM.update(true);

     formWidget.getForm().setHeadClient(headClientTB);

     // setup body layout
     body.setLayout(getBodyLayout());

     // create the body of the page
     createBodyContent(managedForm);

     super.createFormContent(managedForm);
     try
     {
         // load data from the model
     	//TODO decouple from UI thread (causes I/O)
         loadData();
     } catch (CoreException e)
     {
         TLCUIActivator.getDefault().logError("Error loading data from the model into the form fields", e);
     }

     // check the model is-running state
     refresh();

     // finalizes the page construction
     // activates the change listeners
     pageInitializationComplete();
     TLCUIHelper.setHelp(getPartControl(), helpId);

     getManagedForm().getForm().getForm().addMessageHyperlinkListener(errorMessageHyperLinkListener);
 }