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

The following examples show how to use org.eclipse.ui.forms.widgets.FormToolkit#createLabel() . 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: SankeySelectionDialog.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void createCutoffSpinner(FormToolkit tk, Composite comp) {
	tk.createLabel(comp, M.DontShowSmallerThen);
	Composite inner = tk.createComposite(comp);
	UI.gridLayout(inner, 2, 10, 0);
	Spinner spinner = new Spinner(inner, SWT.BORDER);
	spinner.setIncrement(100);
	spinner.setMinimum(0);
	spinner.setMaximum(100000);
	spinner.setDigits(3);
	spinner.setSelection((int) (cutoff * 100000));
	spinner.addModifyListener(e -> {
		cutoff = spinner.getSelection() / 100000d;
	});
	tk.adapt(spinner);
	tk.createLabel(inner, "%");
}
 
Example 2
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 3
Source File: TotalRequirementsSection.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void createCostSum(Composite comp, FormToolkit tk) {
	if (costs == Costs.NONE)
		return;
	double v = result.totalCosts;
	String s;
	String c;
	if (costs == Costs.NET_COSTS) {
		s = M.TotalNetcosts;
		c = asCosts(v);
	} else {
		s = M.TotalAddedValue;
		c = asCosts(v == 0 ? 0 : -v);
	}

	Control label = tk.createLabel(comp, s + ": " + c);
	label.setFont(UI.boldFont());
}
 
Example 4
Source File: AbstractFormPage.java    From typescript.java with MIT License 6 votes vote down vote up
protected Text createText(Composite parent, String label, JSONPath path, String defaultValue, String message) {
	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);

	Text text = toolkit.createText(composite, "");
	if (message != null) {
		text.setMessage(message);
	}
	text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

	bind(text, path, defaultValue);
	return text;
}
 
Example 5
Source File: FormsPart.java    From codeexamples-eclipse with Eclipse Public License 1.0 6 votes vote down vote up
private void createSecondSection( ScrolledForm form, FormToolkit toolkit) {
	ExpandableComposite ec = toolkit.createExpandableComposite(form.getBody(), 
		     ExpandableComposite.TREE_NODE|
		     ExpandableComposite.CLIENT_INDENT);
		 ec.setText("Expandable Composite title");
		 String ctext = "We will now create a somewhat long text so that "+
		 "we can use it as content for the expandable composite. "+
		 "Expandable composite is used to hide or show the text using the " +
		 "toggle control";
		 Label client = toolkit.createLabel(ec, ctext, SWT.WRAP);
		 ec.setClient(client);
		 TableWrapData  td = new TableWrapData();
		 td.colspan = 2;
		 ec.setLayoutData(td);
		 ec.addExpansionListener(new ExpansionAdapter() {
		  @Override
		public void expansionStateChanged(ExpansionEvent e) {
		   form.reflow(true);
		  }
		 });

	
}
 
Example 6
Source File: ProductSystemInfoPage.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void createReferenceSection(Composite body, FormToolkit tk) {
	Composite composite = UI.formSection(body, tk, M.Reference, 3);
	link(composite, M.Process, "referenceProcess");
	tk.createLabel(composite, M.Product);
	productViewer = new ExchangeViewer(composite);
	productViewer.addSelectionChangedListener(e -> {
		Flow flow = e.flow;
		propertyViewer.setInput(flow);
		propertyViewer.select(flow.getReferenceFactor());
	});
	productViewer.setInput(getRefCandidates(getModel().referenceProcess));
	new CommentControl(composite, getToolkit(), "referenceExchange", getComments());
	tk.createLabel(composite, M.FlowProperty);
	propertyViewer = new FlowPropertyFactorViewer(composite);
	propertyViewer.addSelectionChangedListener(this::propertyChanged);
	new CommentControl(composite, getToolkit(), "targetFlowPropertyFactor", getComments());
	tk.createLabel(composite, M.Unit);
	unitViewer = new UnitViewer(composite);
	new CommentControl(composite, getToolkit(), "targetUnit", getComments());
	targetAmountText = UI.formText(composite, getManagedForm().getToolkit(), M.TargetAmount);
	new CommentControl(composite, getToolkit(), "targetAmount", getComments());
	createBindings();
}
 
Example 7
Source File: InfoPage.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void createGeographySection(Composite body, FormToolkit tk) {
	Composite comp = UI.formSection(body, tk, M.Geography, 3);
	tk.createLabel(comp, M.Location);
	LocationViewer combo = new LocationViewer(comp);
	combo.setNullable(true);
	combo.setInput(Database.get());
	getBinding().onModel(() -> getModel(), "location", combo);
	combo.addSelectionChangedListener(loc -> {
		String linkText = loc != null && loc.geodata != null
				? "open in map"
				: "no data";
		geoLink.setText(linkText);
		geoLink.getParent().pack();
	});
	new CommentControl(comp, getToolkit(), "location", getComments());
	createGeoLink(comp, tk);
	multiText(comp, M.Description, "documentation.geography", 40);
}
 
Example 8
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 9
Source File: ReplaceFlowsDialog.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createNote(Composite parent, FormToolkit toolkit) {
	String note = M.NoteDefaultProviders;
	Label noteLabel = toolkit.createLabel(parent, note, SWT.WRAP);
	GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
	gd.widthHint = 300;
	noteLabel.setLayoutData(gd);
}
 
Example 10
Source File: ProductSystemInfoPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void addCalculationButton(Composite comp, FormToolkit tk) {
	tk.createLabel(comp, "");
	Button button = tk.createButton(comp, M.Calculate, SWT.NONE);
	button.setImage(Icon.RUN.get());
	Controls.onSelect(button, e -> {
		CalculationWizard.open(getModel());
		inventoryInfo.setVisible(!getModel().inventory.isEmpty());
	});
	tk.createLabel(comp, "");
}
 
Example 11
Source File: Widgets.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
public static TextDropComponent dropComponent(Composite parent, String label, String property,
		ModelEditor<?> editor, FormToolkit toolkit) {
	ModelType modelType = getModelType(editor.getModel(), property);
	toolkit.createLabel(parent, label, SWT.NONE);
	TextDropComponent text = new TextDropComponent(
			parent, toolkit, modelType);
	UI.gridData(text, true, false);
	editor.getBinding().onModel(() -> editor.getModel(), property, text);
	new CommentControl(parent, toolkit, property, editor.getComments());
	return text;
}
 
Example 12
Source File: Widgets.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
public static DateTime date(Composite parent, String label, String property, ModelEditor<?> editor,
		FormToolkit toolkit) {
	toolkit.createLabel(parent, label, SWT.NONE);
	DateTime dateTime = new DateTime(parent, SWT.DATE | SWT.DROP_DOWN);
	GridData data = new GridData();
	data.widthHint = 150;
	dateTime.setLayoutData(data);
	editor.getBinding().onDate(() -> editor.getModel(), property, dateTime);
	new CommentControl(parent, toolkit, property, editor.getComments());
	return dateTime;
}
 
Example 13
Source File: MemoryError.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void createFormContent(IManagedForm mform) {
	String message = M.CouldNotAllocateMemoryError;
	FormToolkit toolkit = mform.getToolkit();
	mform.getForm().setText(M.OutOfMemory);
	Composite comp = UI.formBody(mform.getForm(), mform.getToolkit());
	UI.gridLayout(comp, 1);
	Label label = toolkit.createLabel(comp, message, SWT.WRAP);
	UI.gridData(label, true, false);
	Hyperlink link = UI.formLink(comp, toolkit, "Open preference dialog");
	Controls.onClick(link, e -> openPreferences());
}
 
Example 14
Source File: LinkingMatrix.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void headerCell(Composite body, FormToolkit tk, String text) {
	Composite c = tk.createComposite(body, SWT.BORDER);
	FillLayout layout = new FillLayout();
	layout.marginHeight = 5;
	c.setLayout(layout);
	UI.gridData(c, true, false).horizontalSpan = 3;
	Label label = tk.createLabel(c, text, SWT.CENTER);
	label.setFont(UI.boldFont());
}
 
Example 15
Source File: ResultPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void renderCategory(FormToolkit tk, Descriptor d, Composite comp) {
	if (!(d instanceof CategorizedDescriptor))
		return;
	CategorizedDescriptor cd = (CategorizedDescriptor) d;
	Long id = cd.category;
	if (id == null)
		return;
	Category cat = Cache.getEntityCache().get(Category.class, id);
	if (cat == null)
		return;
	String path = CategoryPath.getFull(cat);
	Label label = tk.createLabel(comp, path);
	label.setForeground(Colors.get(0, 128, 42));
}
 
Example 16
Source File: ResultPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void renderDescription(FormToolkit tk, Descriptor d, Composite comp) {
	if (d.description == null)
		return;
	String text = Strings.cut(d.description, 400);
	if (text != null && !text.isEmpty()) {
		Label label = tk.createLabel(comp, text, SWT.WRAP);
		UI.gridData(label, false, false).widthHint = 600;
	}
}
 
Example 17
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 18
Source File: CommonGui.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds a {@link Text} input field with a {@link Label}.
 * @param toolkit This toolkit is the factory that makes the Controls.
 * @param comp The parent {@link Composite} that the new {@link Control} is to be added.
 * @param labelText The text that will be added to the {@link Label}.
 * @param def The default texdt thats displayed on the {@link Text}.
 * @return The newly created textfield.
 */
protected Text addTextField(FormToolkit toolkit, Composite comp, String labelText, String def) {
    Text ret;
    Label label = toolkit.createLabel(comp, labelText);
    label.setLayoutData(new GridData());
    ret = toolkit.createText(comp, def, SWT.MULTI | SWT.WRAP | SWT.BORDER);
    GridData gd = new GridData();
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.widthHint = TEXTWIDTH;
    ret.setLayoutData(gd);
    return ret;
}
 
Example 19
Source File: MechanicDialog.java    From workspacemechanic with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Add a form to the supplied Composite.
 */
private Control createForm(Composite parent) {

  final FormToolkit toolkit = new FormToolkit(parent.getDisplay());
  final ScrolledForm form = toolkit.createScrolledForm(parent);

  /*
   * For the life of me I can't understand why I have to supply
   * a GridData instance to the form object in order to get the form
   * to fill the dialog area.
   * 
   * BTW, I only found this out through trial and error.
   */
  form.setLayoutData(new GridData(GridData.FILL_BOTH));

  TableWrapLayout layout = new TableWrapLayout();
  layout.numColumns = 2;
  layout.horizontalSpacing = 15;
  layout.verticalSpacing = 10;

  form.getBody().setLayout(layout);
  form.getBody().setLayoutData(new TableWrapData(
      TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB, 1, 3));

  for (Task item : items) {

    // add an expandable description of the task, with a pretty title
    ExpandableComposite ec = toolkit.createExpandableComposite(form.getBody(),
        ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT);
    ec.setText(item.getTitle());
    Label label = toolkit.createLabel(ec, item.getDescription(), SWT.WRAP);
    ec.setClient(label);
    ec.addExpansionListener(new ExpansionAdapter() {
      @Override 
      public void expansionStateChanged(ExpansionEvent e) {
        form.reflow(true);
      }
    });
    ec.setExpanded(true);
    ec.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));

    // add a combo box allowing the user to select the repair action to take
    createDecisionCombo(form.getBody(), item);
  }

  return parent;
}
 
Example 20
Source File: DBConnectFirstPage.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
public void createControl(Composite parent){
	FormToolkit tk = UiDesk.getToolkit();
	Form form = tk.createForm(parent);
	form.setText(Messages.DBConnectFirstPage_connectioNDetails); //$NON-NLS-1$
	Composite body = form.getBody();
	body.setLayout(new TableWrapLayout());
	FormText alt = tk.createFormText(body, false);
	StringBuilder old = new StringBuilder();
	old.append("<form>"); //$NON-NLS-1$
	String driver = "";
	String user = "";
	String typ = "";
	String connectString = "";
	Hashtable<Object, Object> hConn = null;
	String cnt = CoreHub.localCfg.get(Preferences.CFG_FOLDED_CONNECTION, null);
	if (cnt != null) {
		hConn = PersistentObject.fold(StringTool.dePrintable(cnt));
		if (hConn != null) {
			driver =
				PersistentObject.checkNull(hConn.get(Preferences.CFG_FOLDED_CONNECTION_DRIVER));
			connectString =
				PersistentObject.checkNull(hConn
					.get(Preferences.CFG_FOLDED_CONNECTION_CONNECTSTRING));
			user =
				PersistentObject.checkNull(hConn.get(Preferences.CFG_FOLDED_CONNECTION_USER));
			typ = PersistentObject.checkNull(hConn.get(Preferences.CFG_FOLDED_CONNECTION_TYPE));
		}
	}
	// Check whether we were overridden
	String dbUser = System.getProperty(ElexisSystemPropertyConstants.CONN_DB_USERNAME);
	String dbPw = System.getProperty(ElexisSystemPropertyConstants.CONN_DB_PASSWORD);
	String dbFlavor = System.getProperty(ElexisSystemPropertyConstants.CONN_DB_FLAVOR);
	String dbSpec = System.getProperty(ElexisSystemPropertyConstants.CONN_DB_SPEC);
	if (dbUser != null && dbPw != null && dbFlavor != null && dbSpec != null) {
		old.append("<br/><li><b>Aktuelle Verbindung wurde via Übergabeparameter ans Programm gesetzt!</b></li><br/>"); //$NON-NLS-1$
	}
	if (ch.rgw.tools.StringTool.isNothing(connectString)) {
		old.append("<br/>"); //$NON-NLS-1$
		old.append("Keine konfigurierte Verbindung."); //$NON-NLS-1$
	} else {
		old.append("Konfigurierte Verbindung ist:<br/>"); //$NON-NLS-1$
		old.append("<li><b>Typ:</b>       ").append(typ).append("</li>"); //$NON-NLS-1$ //$NON-NLS-2$
		old.append("<li><b>Treiber</b>    ").append(driver).append("</li>"); //$NON-NLS-1$ //$NON-NLS-2$
		old.append("<li><b>Verbinde</b>   ").append(connectString).append("</li>"); //$NON-NLS-1$ //$NON-NLS-2$
		old.append("<li><b>Username</b>   ").append(user).append("</li>"); //$NON-NLS-1$ //$NON-NLS-2$
	}
	if (PersistentObject.getConnection() != null
		&& PersistentObject.getConnection().getConnectString() != null) {
		old.append("<li><b>Effektiv</b> verwendet wird:").append( //$NON-NLS-1$
			PersistentObject.getConnection().getConnectString()).append("</li>"); //$NON-NLS-1$
	}
	old.append("</form>"); //$NON-NLS-1$
	alt.setText(old.toString(), true, false);
	// Composite form=new Composite(parent, SWT.BORDER);
	Label sep = tk.createSeparator(body, SWT.NONE);
	TableWrapData twd = new TableWrapData();
	twd.heightHint = 5;
	sep.setLayoutData(twd);
	tk.createLabel(body, Messages.DBConnectFirstPage_enterType); //$NON-NLS-1$
	dbTypes = new Combo(body, SWT.BORDER | SWT.SIMPLE);
	dbTypes.setItems(supportedDB);
	dbTypes.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e){
			int it = dbTypes.getSelectionIndex();
			switch (it) {
			case 0:
			case 1:
				server.setEnabled(true);
				dbName.setEnabled(true);
				defaultUser = "elexis"; //$NON-NLS-1$
				defaultPassword = "elexisTest"; //$NON-NLS-1$
				break;
			case 2:
				server.setEnabled(false);
				dbName.setEnabled(true);
				defaultUser = "sa"; //$NON-NLS-1$
				defaultPassword = ""; //$NON-NLS-1$
				break;
			default:
				break;
			}
			DBConnectSecondPage sec = (DBConnectSecondPage) getNextPage();
			sec.name.setText(defaultUser);
			sec.pwd.setText(defaultPassword);
			
		}
		
	});
	tk.adapt(dbTypes, true, true);
	tk.createLabel(body, Messages.DBConnectFirstPage_serevrAddress); //$NON-NLS-1$
	server = tk.createText(body, "", SWT.BORDER); //$NON-NLS-1$
	TableWrapData twr = new TableWrapData(TableWrapData.FILL_GRAB);
	server.setLayoutData(twr);
	tk.createLabel(body, Messages.DBConnectFirstPage_databaseName); //$NON-NLS-1$
	dbName = tk.createText(body, "", SWT.BORDER); //$NON-NLS-1$
	TableWrapData twr2 = new TableWrapData(TableWrapData.FILL_GRAB);
	dbName.setLayoutData(twr2);
	setControl(form);
}