Java Code Examples for org.eclipse.ui.forms.widgets.FormToolkit#createComposite()

The following examples show how to use org.eclipse.ui.forms.widgets.FormToolkit#createComposite() . 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
protected CCombo createCombo(Composite parent, String label, IJSONPath path, String[] values, String defaultValue) {
	FormToolkit toolkit = getToolkit();
	Composite composite = toolkit.createComposite(parent, SWT.NONE);
	composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	GridLayout layout = new GridLayout(2, false);
	layout.marginWidth = 0;
	layout.marginBottom = 0;
	layout.marginTop = 0;
	layout.marginHeight = 0;
	layout.verticalSpacing = 0;
	composite.setLayout(layout);

	toolkit.createLabel(composite, label);

	CCombo combo = new CCombo(composite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
	combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	combo.setItems(values);
	toolkit.adapt(combo, true, false);

	bind(combo, path, defaultValue);
	return combo;
}
 
Example 2
Source File: InfoPage.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void createButtons(Composite comp, FormToolkit tk) {
	UI.filler(comp, tk);
	Composite inner = tk.createComposite(comp);
	UI.gridLayout(inner, 3, 5, 0);

	// create product system
	Button b = tk.createButton(inner, M.CreateProductSystem, SWT.NONE);
	b.setImage(Images.get(ModelType.PRODUCT_SYSTEM, Overlay.NEW));
	Controls.onSelect(b, e -> ProcessToolbar.createSystem(getModel()));

	// direct calculation
	b = tk.createButton(inner, "Direct calculation", SWT.NONE);
	b.setImage(Icon.RUN.get());
	Controls.onSelect(b, e -> ProcessToolbar.directCalculation(getModel()));

	// export to Excel
	b = tk.createButton(inner, M.ExportToExcel, SWT.NONE);
	b.setImage(Images.get(FileType.EXCEL));
	Controls.onSelect(b, e -> ProcessToolbar.exportToExcel(getModel()));
}
 
Example 3
Source File: InfoSection.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private static void buttons(Composite comp, FormToolkit tk) {
	tk.createLabel(comp, "");
	Composite inner = tk.createComposite(comp);
	UI.gridLayout(inner, 2, 5, 0);
	Button excel = tk.createButton(inner,
			M.ExportToExcel, SWT.NONE);
	excel.setImage(Images.get(FileType.EXCEL));
	Controls.onSelect(excel,
			e -> new ExcelExportAction().run());
	Button lci = tk.createButton(inner,
			M.SaveAsLCIResult, SWT.NONE);
	lci.setImage(Images.get(ProcessType.LCI_RESULT));
	Controls.onSelect(lci, e -> {
		ResultEditor<?> editor = Editors.getActive();
		if (editor == null)
			return;
		SaveProcessDialog.open(editor);
	});

}
 
Example 4
Source File: OutputPage.java    From typescript.java with MIT License 5 votes vote down vote up
private void createLeftContent(Composite parent) {
	FormToolkit toolkit = super.getToolkit();
	Composite left = toolkit.createComposite(parent);
	left.setLayout(FormLayoutFactory.createFormPaneTableWrapLayout(false, 1));
	left.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
	createOutputSection(left);
}
 
Example 5
Source File: ServiceInvocationPropertiesEditionPartForm.java    From eip-designer with Apache License 2.0 5 votes vote down vote up
/**
 * 
 */
protected Composite createPropertiesGroup(FormToolkit widgetFactory, final Composite parent) {
	Section propertiesSection = widgetFactory.createSection(parent, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
	propertiesSection.setText(EipMessages.ServiceInvocationPropertiesEditionPart_PropertiesGroupLabel);
	GridData propertiesSectionData = new GridData(GridData.FILL_HORIZONTAL);
	propertiesSectionData.horizontalSpan = 3;
	propertiesSection.setLayoutData(propertiesSectionData);
	Composite propertiesGroup = widgetFactory.createComposite(propertiesSection);
	GridLayout propertiesGroupLayout = new GridLayout();
	propertiesGroupLayout.numColumns = 3;
	propertiesGroup.setLayout(propertiesGroupLayout);
	propertiesSection.setClient(propertiesGroup);
	return propertiesGroup;
}
 
Example 6
Source File: GroupResultSection.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createCombos(FormToolkit toolkit, Composite client) {
	Composite composite = toolkit.createComposite(client);
	UI.gridData(composite, true, false);
	UI.gridLayout(composite, 2);
	createFlowViewer(toolkit, composite);
	if (result.hasImpactResults())
		createImpact(toolkit, composite);
}
 
Example 7
Source File: AggregatorPropertiesEditionPartForm.java    From eip-designer with Apache License 2.0 5 votes vote down vote up
/**
 * 
 */
protected Composite createPropertiesGroup(FormToolkit widgetFactory, final Composite parent) {
	Section propertiesSection = widgetFactory.createSection(parent, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
	propertiesSection.setText(EipMessages.AggregatorPropertiesEditionPart_PropertiesGroupLabel);
	GridData propertiesSectionData = new GridData(GridData.FILL_HORIZONTAL);
	propertiesSectionData.horizontalSpan = 3;
	propertiesSection.setLayoutData(propertiesSectionData);
	Composite propertiesGroup = widgetFactory.createComposite(propertiesSection);
	GridLayout propertiesGroupLayout = new GridLayout();
	propertiesGroupLayout.numColumns = 3;
	propertiesGroup.setLayout(propertiesGroupLayout);
	propertiesSection.setClient(propertiesGroup);
	return propertiesGroup;
}
 
Example 8
Source File: ConditionalRoutePropertiesEditionPartForm.java    From eip-designer with Apache License 2.0 5 votes vote down vote up
/**
 * 
 */
protected Composite createPropertiesGroup(FormToolkit widgetFactory, final Composite parent) {
	Section propertiesSection = widgetFactory.createSection(parent, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
	propertiesSection.setText(EipMessages.ConditionalRoutePropertiesEditionPart_PropertiesGroupLabel);
	GridData propertiesSectionData = new GridData(GridData.FILL_HORIZONTAL);
	propertiesSectionData.horizontalSpan = 3;
	propertiesSection.setLayoutData(propertiesSectionData);
	Composite propertiesGroup = widgetFactory.createComposite(propertiesSection);
	GridLayout propertiesGroupLayout = new GridLayout();
	propertiesGroupLayout.numColumns = 3;
	propertiesGroup.setLayout(propertiesGroupLayout);
	propertiesSection.setClient(propertiesGroup);
	return propertiesGroup;
}
 
Example 9
Source File: OutputPage.java    From typescript.java with MIT License 5 votes vote down vote up
private Composite createBody(Section section) {
	FormToolkit toolkit = super.getToolkit();
	Composite body = toolkit.createComposite(section);
	section.setClient(body);

	GridLayout glayout = new GridLayout();
	glayout.numColumns = 1;
	body.setLayout(glayout);
	return body;
}
 
Example 10
Source File: OutputPage.java    From typescript.java with MIT License 5 votes vote down vote up
private void createRightContent(Composite parent) {
	FormToolkit toolkit = super.getToolkit();
	Composite right = toolkit.createComposite(parent);
	right.setLayout(FormLayoutFactory.createFormPaneTableWrapLayout(false, 1));
	right.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
	createDebuggingSection(right);
	createReportingSection(right);
	createJSXSection(right);
}
 
Example 11
Source File: ContributionChartSection.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
public void render(Composite parent, FormToolkit tk) {
	Section section = UI.section(parent, tk, sectionTitle);
	Composite comp = UI.sectionClient(section, tk);
	UI.gridLayout(comp, 1);
	Composite header = tk.createComposite(comp);
	UI.gridLayout(header, 2);
	createCombo(tk, header);
	chart = ContributionChart.create(comp, tk);
	Actions.bind(section, new ImageExportAction(comp));
	refresh();
}
 
Example 12
Source File: PluginsPage.java    From typescript.java with MIT License 5 votes vote down vote up
private void createLeftContent(Composite parent) {
	FormToolkit toolkit = super.getToolkit();
	Composite left = toolkit.createComposite(parent);
	left.setLayout(FormLayoutFactory.createFormPaneGridLayout(false, 1));
	left.setLayoutData(new GridData(GridData.FILL_BOTH));
	createPluginsSection(left);
}
 
Example 13
Source File: OverviewPage.java    From typescript.java with MIT License 5 votes vote down vote up
private void createRightContent(Composite parent) {
	FormToolkit toolkit = super.getToolkit();
	Composite right = toolkit.createComposite(parent);
	right.setLayout(FormLayoutFactory.createFormPaneTableWrapLayout(false, 1));
	right.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
	createValidatingSection(right);
}
 
Example 14
Source File: QualityCell.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
void create(Composite parent, FormToolkit tk) {
	String text = score.description;
	composite = tk.createComposite(parent, SWT.BORDER);
	UI.gridData(composite, true, true);
	FillLayout layout = new FillLayout(SWT.HORIZONTAL);
	layout.marginHeight = 2;
	layout.marginWidth = 2;
	composite.setLayout(layout);
	label = tk.createLabel(composite, "", SWT.WRAP);
	label.setToolTipText(text);
	composite.setToolTipText(text);
	label.addMouseTrackListener(new MouseOver());
	label.addMouseListener(new MouseClick());
}
 
Example 15
Source File: CommitDialog.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createModelViewer(Composite parent, FormToolkit toolkit) {
	Section section = UI.section(parent, toolkit, M.Files);
	UI.gridData(section, true, true);
	Composite comp = toolkit.createComposite(section);
	UI.gridData(comp, true, true);
	UI.gridLayout(comp, 1);
	section.setClient(comp);
	JsonLoader loader = CloudUtil.getJsonLoader(client);
	viewer = new CommitDiffViewer(comp, loader, false);
	viewer.getViewer().addCheckStateListener((e) -> updateButton());
}
 
Example 16
Source File: DataQualityCell.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
void createComponents(Composite parent, FormToolkit toolkit) {
	String text = score.description;
	composite = toolkit.createComposite(parent, SWT.BORDER);
	GridData gridData = UI.gridData(composite, true, true);
	gridData.minimumWidth = 120;
	gridData.widthHint = 120;
	FillLayout layout = new FillLayout(SWT.HORIZONTAL);
	layout.marginHeight = 2;
	layout.marginWidth = 2;
	composite.setLayout(layout);
	label = toolkit.createLabel(composite, text, SWT.WRAP);
	label.addMouseTrackListener(new MouseOver());
	label.addMouseListener(new MouseClick());
}
 
Example 17
Source File: OpenMiniatureViewAction.java    From olca-app with Mozilla Public License 2.0 4 votes vote down vote up
@Override
protected Control createContents(final Composite parent) {
	FormToolkit toolkit = new FormToolkit(Display.getCurrent());
	ScrolledForm scrolledForm = toolkit.createScrolledForm(parent);
	Composite body = scrolledForm.getBody();
	body.setLayout(new FillLayout());
	toolkit.paintBordersFor(body);

	SashForm sashForm = new SashForm(body, SWT.VERTICAL);
	toolkit.adapt(sashForm, true, true);

	Section categorySection = toolkit
			.createSection(sashForm, ExpandableComposite.NO_TITLE
					| ExpandableComposite.EXPANDED);
	categorySection.setText("");
	Composite composite = toolkit.createComposite(categorySection,
			SWT.NONE);
	composite.setLayout(new GridLayout());
	categorySection.setClient(composite);
	toolkit.paintBordersFor(composite);
	final Scale scale = new Scale(composite, SWT.NONE);
	scale.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
	final double[] values = GraphConfig.ZOOM_LEVELS;
	final int increment = 100 / (values.length - 1);
	scale.setIncrement(increment);
	scale.setMinimum(0);
	scale.setMaximum(100);
	Controls.onSelect(scale, (e) -> {
		zoomManager.setZoom(values[scale.getSelection() / increment]);
	});
	scale.setSelection(increment * (values.length - 1) / 2);
	Canvas canvas = new Canvas(composite, SWT.BORDER);
	canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	lws = new LightweightSystem(canvas);
	thumbnail = new ScrollableThumbnail(port);
	thumbnail.setSource(figure);
	lws.setContents(thumbnail);
	disposeListener = new DisposeListener() {

		@Override
		public void widgetDisposed(final DisposeEvent e) {
			if (thumbnail != null) {
				thumbnail.deactivate();
				thumbnail = null;
			}
			if (control != null && !control.isDisposed())
				control.removeDisposeListener(disposeListener);
			close();
		}
	};
	control.addDisposeListener(disposeListener);
	return super.createContents(parent);
}
 
Example 18
Source File: ApplicationOverviewEditorPart.java    From codewind-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public ProjectLinkSection(Composite parent, FormToolkit toolkit, int hSpan, int vSpan) {
	Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
       section.setText(Messages.AppOverviewEditorProjectLinksSection);
       section.setLayoutData(new GridData(SWT.FILL,SWT.FILL, true, false, hSpan, vSpan));
       section.setExpanded(true);

       Composite composite = toolkit.createComposite(section);
       GridLayout layout = new GridLayout();
       layout.numColumns = 2;
       layout.marginHeight = 5;
       layout.marginWidth = 10;
       layout.verticalSpacing = 10;
       layout.horizontalSpacing = 10;
       composite.setLayout(layout);
       composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
       toolkit.paintBordersFor(composite);
       section.setClient(composite);
       
	// Link description and manage link
	toLinkDescriptionText = new Text(composite, SWT.WRAP | SWT.MULTI | SWT.READ_ONLY);
	toLinkDescriptionText.setText(Messages.AppOverviewEditorProjectLinksNoLinks);
	toLinkDescriptionText.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
	toLinkDescriptionText.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false));
	IDEUtil.paintBackgroundToMatch(toLinkDescriptionText, composite);

	Hyperlink manageLink = toolkit.createHyperlink(composite, Messages.AppOverviewEditorProjectLinksManageLinks, SWT.WRAP);
	GridData data = new GridData(GridData.END, GridData.BEGINNING, false, false);
	manageLink.setLayoutData(data);

	manageLink.addHyperlinkListener(new HyperlinkAdapter() {
		@Override
		public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) {
			final CodewindConnection conn = getConn();
			final CodewindApplication app = getApp(conn);
			ManageLinksAction.openManageLinksDialog(app);
		}
	});

	// Link table
	toLinkTable = new LinkTable(composite, toolkit, Messages.LinkMgmtProjectColumn);

	// From link description
	fromLinkDescriptionText = new Text(composite, SWT.WRAP | SWT.MULTI | SWT.READ_ONLY);
	fromLinkDescriptionText.setText(Messages.AppOverviewEditorProjectLinksNoFromLinks);
	fromLinkDescriptionText.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
	fromLinkDescriptionText.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false, 2, 1));
	IDEUtil.paintBackgroundToMatch(fromLinkDescriptionText, composite);

	// From link table
	fromLinkTable = new LinkTable(composite, toolkit, Messages.AppOverviewEditorProjectLinksSourceProject);

	// Initialize
	toLinkTable.tableComp.setVisible(false);
	((GridData) toLinkTable.tableComp.getLayoutData()).exclude = true;

	fromLinkTable.tableComp.setVisible(false);
	((GridData) fromLinkTable.tableComp.getLayoutData()).exclude = true;
}
 
Example 19
Source File: ICESectionPage.java    From ice with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * <p>
 * This operation creates ICEMatrixComponentSectionParts for each
 * MatrixComponent in the list of MatrixComponents and figures out exactly
 * how they should be arranged and span across the page based on their
 * properties.
 * </p>
 *
 */
private void createMatrixComponentSections() {

	// Get the parent form and the ToolKit to create decorated Sections.
	final ScrolledForm scrolledForm = managedFormRef.getForm();
	final FormToolkit formToolkit = managedFormRef.getToolkit();

	// Each MatrixComponent will get its own Section. These Sections will be
	// spread horizontally and will take all remaining available horizontal
	// and vertical space offered by the Form.

	// Create a Composite to wrap the MatrixComponent Sections. As specified
	// above, it should have a default horizontal FillLayout.
	Composite matrixGridComposite = formToolkit
			.createComposite(scrolledForm.getBody(), SWT.NONE);
	matrixGridComposite.setLayout(new FillLayout());

	// The MatrixComponentSections should grab all remaining space.
	matrixGridComposite
			.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

	// Create the MatrixComponent Sections.
	for (int i = 0; i < matrixComponents.size(); i++) {
		// Create a new Section for the current MatrixComponent.
		MatrixComponent matrixComponent = matrixComponents.get(i);
		Section section = formToolkit.createSection(matrixGridComposite,
				ExpandableComposite.TITLE_BAR | Section.DESCRIPTION
						| ExpandableComposite.TWISTIE
						| ExpandableComposite.EXPANDED);
						// No layout data needs to be set because the
						// matrixGridComposite
						// uses a FillLayout.

		// To populate the Section, use an ICEMatrixComponentSectionPart.
		ICEMatrixComponentSectionPart sectionPart;
		sectionPart = new ICEMatrixComponentSectionPart(section, editor,
				managedFormRef);
		sectionPart.setMatrixComponent(matrixComponent);
		sectionPart.renderSection();
		// Add the part to the ManagedForm's update lifecycle
		managedFormRef.addPart(sectionPart);
	}

	return;
}
 
Example 20
Source File: GeoPage.java    From olca-app with Mozilla Public License 2.0 4 votes vote down vote up
private void setupSection(Composite body, FormToolkit tk) {
	Composite comp = UI.formSection(body, tk, "Setup");
	UI.gridLayout(comp, 3);

	// GeoJSON file
	UI.gridLayout(comp, 3);
	UI.gridData(comp, true, false);
	UI.formLabel(comp, tk, "GeoJSON File");
	Text fileText = tk.createText(comp, "");
	fileText.setEditable(false);
	UI.gridData(fileText, false, false).widthHint = 350;
	Button fileBtn = tk.createButton(
			comp, "Open file", SWT.NONE);
	fileBtn.setImage(Icon.FOLDER_OPEN.get());
	Controls.onSelect(fileBtn, _e -> {
		File file = FileChooser.open("*.geojson");
		if (file == null)
			return;
		Setup s = App.exec("Parse GeoJSON ...",
				() -> Setup.read(file));
		if (s == null || s.file == null)
			return;

		// copy possible elementary flow bindings
		// into the new setup (note that the parameters
		// are already initialized in the new setup)
		if (setup != null) {
			s.bindings.addAll(setup.bindings);
		}
		setup = s;
		fileText.setText(s.file);
		paramSection.update();
		flowSection.update();
	});

	UI.filler(comp, tk);
	Composite btnComp = tk.createComposite(comp);
	UI.gridLayout(btnComp, 2, 10, 0);
	Button openBtn = tk.createButton(
			btnComp, "Open setup", SWT.NONE);
	openBtn.setImage(Icon.FOLDER_OPEN.get());
	Button saveBtn = tk.createButton(
			btnComp, "Save setup", SWT.NONE);
	saveBtn.setImage(Icon.SAVE.get());
}