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

The following examples show how to use org.eclipse.ui.forms.widgets.FormToolkit#paintBordersFor() . 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: ApplicationOverviewEditorPart.java    From codewind-eclipse with Eclipse Public License 2.0 7 votes vote down vote up
public ProjectInfoSection(Composite parent, FormToolkit toolkit, int hSpan, int vSpan) {
	Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
       section.setText(Messages.AppOverviewEditorProjectInfoSection);
       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 = 5;
       layout.horizontalSpacing = 10;
       composite.setLayout(layout);
       composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
       toolkit.paintBordersFor(composite);
       section.setClient(composite);
       
       typeEntry = new StringEntry(composite, Messages.AppOverviewEditorTypeEntry);
       languageEntry = new StringEntry(composite, Messages.AppOverviewEditorLanguageEntry);
       projectIdEntry = new StringEntry(composite, Messages.AppOverviewEditorProjectIdEntry);
       locationEntry = new StringEntry(composite, Messages.AppOverviewEditorLocationEntry);
}
 
Example 2
Source File: DiffEditorDialog.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
@Override
protected void createFormContent(IManagedForm mform) {
	String title = M.Diff;
	if (this.title != null)
		title += ": " + this.title;
	ScrolledForm form = UI.formHeader(mform, title);
	if (logo != null)
		form.setImage(logo);
	FormToolkit toolkit = mform.getToolkit();
	Composite body = form.getBody();
	UI.gridLayout(body, 1, 0, 0);
	toolkit.paintBordersFor(body);
	UI.gridData(body, true, true);
	if (editMode)
		editor = DiffEditor.forEditing(body, toolkit);
	else
		editor = DiffEditor.forViewing(body, toolkit);
	editor.initialize(root, labelProvider, dependencyResolver, action);
	UI.gridData(editor, true, true);
	form.reflow(true);
}
 
Example 3
Source File: ReplaceFlowsDialog.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void createBottom(Composite parent, FormToolkit toolkit) {
	Composite bottom = UI.formComposite(parent, toolkit);
	UI.gridLayout(bottom, 1, 0, 0);
	Composite typeContainer = UI.formComposite(bottom, toolkit);
	UI.gridLayout(typeContainer, 4, 20, 5);
	UI.formLabel(typeContainer, toolkit, M.ReplaceIn);
	replaceFlowsButton = toolkit.createButton(typeContainer, M.InputsOutputs, SWT.RADIO);
	replaceFlowsButton.setSelection(true);
	Controls.onSelect(replaceFlowsButton, this::updateSelection);
	replaceImpactsButton = toolkit.createButton(typeContainer, M.ImpactFactors, SWT.RADIO);
	Controls.onSelect(replaceImpactsButton, this::updateSelection);
	replaceBothButton = toolkit.createButton(typeContainer, M.Both, SWT.RADIO);
	Controls.onSelect(replaceBothButton, this::updateSelection);
	Composite excludeContainer = UI.formComposite(bottom, toolkit);
	UI.gridLayout(excludeContainer, 2, 20, 5);
	excludeWithProviders = UI.formCheckbox(excludeContainer, toolkit);
	UI.formLabel(excludeContainer, toolkit, M.ExcludeExchangesWithDefaultProviders);
	toolkit.paintBordersFor(bottom);
	toolkit.adapt(bottom);
	createNote(parent, toolkit);
}
 
Example 4
Source File: SankeyMiniViewAction.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private Composite createForm(Composite parent) {
	FormToolkit toolkit = new FormToolkit(Display.getCurrent());
	ScrolledForm form = toolkit.createScrolledForm(parent);
	Composite body = form.getBody();
	body.setLayout(new FillLayout());
	toolkit.paintBordersFor(body);
	SashForm sash = new SashForm(body, SWT.VERTICAL);
	toolkit.adapt(sash, true, true);
	Section section = toolkit.createSection(sash,
			ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED);
	section.setText("");
	Composite composite = toolkit.createComposite(section, SWT.NONE);
	composite.setLayout(new GridLayout());
	section.setClient(composite);
	toolkit.paintBordersFor(composite);
	return composite;
}
 
Example 5
Source File: FormHelper.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Constructs a section and returns a section client composite
 * 
 * the section layout is TableWrapLayout
 * 
 * 
 * @param parent parent container for the section
 * @param title title of the section
 * @param description description of the section
 * @param toolkit toolkit to create the composite
 * @param sectionFlags parameters of the section
 * @param expansionListener 
 * @return a section client (the content container of the section)
 */
public static Section createSectionComposite(Composite parent, String title, String description,
        FormToolkit toolkit, int sectionFlags, IExpansionListener expansionListener)
{
    final Section section = toolkit.createSection(parent, sectionFlags);

    section.setData(SECTION_IS_NOT_SPACE_GRABBING, new Object());
    section.setText(title);
    section.setDescription(description);

    if (expansionListener != null)
    {
        section.addExpansionListener(expansionListener);
    }

    // create section client
    Composite sectionClient = toolkit.createComposite(section);
    TableWrapLayout layout = new TableWrapLayout();
    layout.numColumns = 1;
    sectionClient.setLayout(layout);
    section.setClient(sectionClient);

    // draw flat borders
    toolkit.paintBordersFor(sectionClient);
    return section;
}
 
Example 6
Source File: WSO2PluginFormBrowser.java    From developer-studio with Apache License 2.0 5 votes vote down vote up
public void createControl(Composite parent) {
	toolkit = new FormToolkit(parent.getDisplay());
	int borderStyle = toolkit.getBorderStyle() == SWT.BORDER ? SWT.NULL : SWT.BORDER;
	container = new Composite(parent, borderStyle);
	FillLayout flayout = new FillLayout();
	flayout.marginWidth = 1;
	flayout.marginHeight = 1;
	container.setLayout(flayout);
	formText = new ScrolledFormText(container, SWT.V_SCROLL | SWT.H_SCROLL, false);
	if (borderStyle == SWT.NULL) {
		formText.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
		toolkit.paintBordersFor(container);
	}
	FormText ftext = toolkit.createFormText(formText, false);
	formText.setFormText(ftext);
	formText.setExpandHorizontal(true);
	formText.setExpandVertical(true);
	formText.setBackground(toolkit.getColors().getBackground());
	formText.setForeground(toolkit.getColors().getForeground());
	ftext.marginWidth = 2;
	ftext.marginHeight = 2;
	ftext.setHyperlinkSettings(toolkit.getHyperlinkGroup());
	formText.addDisposeListener(new DisposeListener() {
		public void widgetDisposed(DisposeEvent e) {
			if (toolkit != null) {
				toolkit.dispose();
				toolkit = null;
			}
		}
	});
	if (text != null)
		formText.setText(text);
}
 
Example 7
Source File: CommitDialog.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void createFormContent(IManagedForm mform) {
	ScrolledForm form = UI.formHeader(mform, M.CommitChangesToRepository);
	FormToolkit toolkit = mform.getToolkit();
	Composite body = form.getBody();
	body.setLayout(new GridLayout());
	toolkit.paintBordersFor(body);
	UI.gridData(body, true, true);
	createCommitMessage(body, toolkit);
	createModelViewer(body, toolkit);
	form.reflow(true);
	viewer.setInput(Collections.singleton(node));
	viewer.setSelection(initialSelection);
}
 
Example 8
Source File: DiffDialog.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void createFormContent(IManagedForm mform) {
	ScrolledForm form = UI.formHeader(mform, M.Diff);
	FormToolkit toolkit = mform.getToolkit();
	Composite body = form.getBody();
	body.setLayout(new GridLayout());
	toolkit.paintBordersFor(body);
	UI.gridData(body, true, true);
	viewer = new FetchDiffViewer(body, loader);
	form.reflow(true);
	viewer.setInput(Collections.singletonList(rootNode));
	viewer.setOnMerge(() -> getButton(OK).setEnabled(!viewer.hasConflicts()));
}
 
Example 9
Source File: CommitEntryDialog.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void createFormContent(IManagedForm mform) {
	ScrolledForm form = UI.formHeader(mform, M.ChangesToBeFetched);
	FormToolkit toolkit = mform.getToolkit();
	Composite body = form.getBody();
	body.setLayout(new GridLayout());
	toolkit.paintBordersFor(body);
	UI.gridData(body, true, true);
	CommitEntryViewer viewer = new CommitEntryViewer(body, client);
	form.reflow(true);
	viewer.setInput(commits);
}
 
Example 10
Source File: ReferencesResultDialog.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void createFormContent(IManagedForm mform) {
	ScrolledForm form = UI.formHeader(mform, M.CommitReferenceNotice);
	FormToolkit toolkit = mform.getToolkit();
	Composite body = form.getBody();
	body.setLayout(new GridLayout());
	toolkit.paintBordersFor(body);
	UI.gridData(body, true, true);
	createModelViewer(body, toolkit);
	form.reflow(true);
	viewer.setInput(Collections.singleton(node));
	Set<FileReference> initialSelection = getNewElements(node);
	viewer.setSelection(initialSelection);
}
 
Example 11
Source File: LibraryResultDialog.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void createFormContent(IManagedForm mform) {
	ScrolledForm form = UI.formHeader(mform, M.LibraryDataSets);
	FormToolkit toolkit = mform.getToolkit();
	Composite body = form.getBody();
	body.setLayout(new GridLayout());
	toolkit.paintBordersFor(body);
	UI.gridData(body, true, true);
	String description = M.RecognizedLibraryDatasetsDescription;
	Label label = toolkit.createLabel(body, description, SWT.WRAP);
	UI.gridData(label, true, false).widthHint = 750;
	Viewer viewer = new Viewer(body);
	form.reflow(true);
	viewer.setInput(restrictions);
}
 
Example 12
Source File: UI.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
public static Composite formBody(ScrolledForm form, FormToolkit tk) {
	Composite body = form.getBody();
	GridLayout layout = new GridLayout();
	layout.marginRight = 10;
	layout.marginLeft = 10;
	layout.horizontalSpacing = 10;
	layout.marginBottom = 10;
	layout.marginTop = 10;
	layout.verticalSpacing = 10;
	layout.numColumns = 1;
	body.setLayout(layout);
	tk.paintBordersFor(body);
	gridData(body, true, true);
	return body;
}
 
Example 13
Source File: ContributionTreePage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createTree(FormToolkit tk, Composite comp) {
	tree = Trees.createViewer(comp, HEADERS,
			new ContributionLabelProvider());
	tree.setAutoExpandLevel(2);
	tree.getTree().setLinesVisible(false);
	tree.setContentProvider(new ContributionContentProvider());
	tk.adapt(tree.getTree(), false, false);
	tk.paintBordersFor(tree.getTree());
	tree.getTree().getColumns()[2].setAlignment(SWT.RIGHT);
	Trees.bindColumnWidths(tree.getTree(),
			0.20, 0.50, 0.20, 0.10);

	// action bindings
	Action onOpen = Actions.onOpen(() -> {
		UpstreamNode n = Viewers.getFirstSelected(tree);
		if (n == null || n.provider == null)
			return;
		App.openEditor(n.provider.process);
	});

	Action onExport = Actions.create(M.ExportToExcel,
			Images.descriptor(FileType.EXCEL), () -> {
				Object input = tree.getInput();
				if (!(input instanceof UpstreamTree))
					return;
				TreeExportDialog.open((UpstreamTree) input);
			});

	Actions.bind(tree, onOpen, TreeClipboard.onCopy(tree), onExport);
	Trees.onDoubleClick(tree, e -> onOpen.run());
}
 
Example 14
Source File: ReplaceFlowsDialog.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createTop(Composite parent, FormToolkit toolkit) {
	Composite top = UI.formComposite(parent, toolkit);
	UI.gridLayout(top, 2, 20, 5);
	UI.gridData(top, true, false);
	selectionViewer = createFlowViewer(top, toolkit, M.ReplaceFlow, this::updateReplacementCandidates);
	replacementViewer = createFlowViewer(top, toolkit, M.With, selected -> updateButtons());
	replacementViewer.setEnabled(false);
	selectionViewer.setInput(getUsed());
	toolkit.paintBordersFor(top);
	toolkit.adapt(top);
}
 
Example 15
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 16
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 17
Source File: ApplicationOverviewEditorPart.java    From codewind-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public ProjectStatusSection(Composite parent, FormToolkit toolkit, int hSpan, int vSpan) {
	Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
       section.setText(Messages.AppOverviewEditorProjectStatusSection);
       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 = 5;
       layout.horizontalSpacing = 10;
       composite.setLayout(layout);
       composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
       toolkit.paintBordersFor(composite);
       section.setClient(composite);
       
       autoBuildEntry = new StringEntry(composite, Messages.AppOverviewEditorAutoBuildEntry);
       injectMetricsEntry = new StringEntry(composite, Messages.AppOverviewEditorInjectMetricsEntry);
       appStatusEntry = new StringEntry(composite, Messages.AppOverviewEditorAppStatusEntry);
       buildStatusEntry = new StringEntry(composite, Messages.AppOverviewEditorBuildStatusEntry);
       lastImageBuildEntry = new StringEntry(composite, Messages.AppOverviewEditorLastImageBuildEntry);
       lastBuildEntry = new StringEntry(composite, Messages.AppOverviewEditorLastBuildEntry);
       
	Label label = new Label(composite, SWT.NONE);
	label.setFont(boldFont);
	label.setText(Messages.AppOverviewEditorProjectLogs);
	label.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
	projectLogs = new Link(composite, SWT.NONE);
	projectLogs.setText("");
	projectLogs.setVisible(false);
	GridData data = new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false);
	data.horizontalIndent = 2;
	data.exclude = true;
	projectLogs.setLayoutData(data);
	IDEUtil.paintBackgroundToMatch(projectLogs, composite);
	projectLogs.addListener(SWT.Selection, event -> {
		CodewindEclipseApplication app = (CodewindEclipseApplication) getApp(getConn());
		if (app == null) {
			Logger.logError("A log link was selected but could not find the application for the " + connectionId //$NON-NLS-1$
					+ " connection with name: " + projectId); //$NON-NLS-1$
			return;
		}
		Optional<ProjectLogInfo> logInfo = app.getLogInfos().stream().filter(info -> info.logName.equals(event.text)).findFirst();
		if (logInfo.isPresent()) {
			try {
				SocketConsole console = app.getConsole(logInfo.get());
				if (console == null) {
					console = CodewindConsoleFactory.createLogFileConsole(app, logInfo.get());
					app.addConsole(console);
				}
				ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);
			} catch (Exception e) {
				Logger.logError("An error occurred trying to open the " + logInfo.get().logName //$NON-NLS-1$
						+ "log file for application: " + projectId, e); //$NON-NLS-1$
				MessageDialog.openError(parent.getShell(), Messages.AppOverviewEditorOpenLogErrorTitle,
						NLS.bind(Messages.AppOverviewEditorOpenLogErrorMsg, new String[] {logInfo.get().logName, app.name, e.getMessage()}));
			}
		} else {
			Logger.logError("The " + event.text + " was selected but the associated log info could not be found for the " + projectId + " project."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
		}
	});
	noProjectLogs = new Text(composite, SWT.READ_ONLY);
	noProjectLogs.setText(Messages.AppOverviewEditorNoProjectLogs);
	noProjectLogs.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
	noProjectLogs.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false));
	IDEUtil.paintBackgroundToMatch(noProjectLogs, composite);
}