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

The following examples show how to use org.eclipse.ui.forms.widgets.FormToolkit#createButton() . 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: ResultTypeCombo.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void initImpactCombo(FormToolkit tk, Composite comp) {
	boolean enabled = getType(initialSelection) == ModelType.IMPACT_CATEGORY;
	Button check = tk.createButton(comp, M.ImpactCategory, SWT.RADIO);
	check.setSelection(enabled);
	Controls.onSelect(check, _e -> {
		if (check.getSelection()) {
			impactCombo.setEnabled(true);
			selectedType = ModelType.IMPACT_CATEGORY;
			fireSelection();
		} else {
			impactCombo.setEnabled(false);
		}
	});

	impactCombo = new ImpactCategoryViewer(comp);
	impactCombo.setEnabled(enabled);
	impactCombo.setInput(impacts);
	impactCombo.selectFirst();
	impactCombo.addSelectionChangedListener((val) -> fireSelection());
	if (enabled) {
		impactCombo.select((ImpactCategoryDescriptor) initialSelection);
	}
}
 
Example 2
Source File: Combo.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void initFlowCombo(FormToolkit tk, Composite comp) {
	boolean enabled = getType(initialSelection) == ModelType.FLOW;
	Button check = tk.createButton(comp, M.Flow, SWT.RADIO);
	check.setSelection(enabled);
	Controls.onSelect(check, _e -> {
		if (check.getSelection()) {
			flowCombo.setEnabled(true);
			selectedType = ModelType.FLOW;
			fire(flowCombo.getSelected());
		} else {
			flowCombo.setEnabled(false);
		}
	});

	flowCombo = new FlowViewer(comp);
	flowCombo.setEnabled(enabled);
	flowCombo.setInput(flows);
	flowCombo.selectFirst();
	flowCombo.addSelectionChangedListener(f -> {
		fire(f);
		check.setSelection(true);
	});
	if (enabled) {
		flowCombo.select((FlowDescriptor) initialSelection);
	}
}
 
Example 3
Source File: MultiResourceSelectionDialogWithFlowOption.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
  Composite composite = (Composite) super.createDialogArea(parent);

  new Label(composite, SWT.WRAP).setText(""); //$NON-NLS-1$

  String sAddToFlowPrompt = Messages
          .getString("MultiResourceSelectionDialogWithFlowOption.addSelectedAEsToEndOfFlow"); //$NON-NLS-1$
  FormToolkit factory = new FormToolkit(TAEConfiguratorPlugin.getDefault().getFormColors(
          parent.getDisplay()));

  autoAddToFlowButton = factory.createButton(composite, sAddToFlowPrompt, SWT.CHECK);
  m_bAutoAddToFlow = "false".equals(CDEpropertyPage.getAddToFlow(editor.getProject())) ? false : true;
  autoAddToFlowButton.setSelection(m_bAutoAddToFlow);
  autoAddToFlowButton.setBackground(null);

  return composite;
}
 
Example 4
Source File: ReplacerDialog.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
@Override
protected void createFormContent(IManagedForm mform) {
	FormToolkit tk = mform.getToolkit();
	Composite comp = UI.formBody(mform.getForm(), tk);
	UI.gridLayout(comp, 1, 10, 10);
	UI.formLabel(comp, tk, "This will replace the flows in the database " +
			"(the source system) with the flows in the target system.");
	tree = new ModelCheckBoxTree(
			ModelType.PROCESS,
			ModelType.IMPACT_METHOD);
	tree.drawOn(comp, tk);
	Button delete = tk.createButton(comp,
			"Delete replaced and unused flows", SWT.CHECK);
	Controls.onSelect(delete, _e -> {
		conf.deleteMapped = delete.getSelection();
	});
}
 
Example 5
Source File: ResultTypeCombo.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void initFlowCombo(FormToolkit tk, Composite comp) {
	boolean enabled = getType(initialSelection) == ModelType.FLOW;
	Button check = tk.createButton(comp, M.Flow, SWT.RADIO);
	check.setSelection(enabled);
	Controls.onSelect(check, _e -> {
		if (check.getSelection()) {
			flowCombo.setEnabled(true);
			selectedType = ModelType.FLOW;
			fireSelection();
		} else {
			flowCombo.setEnabled(false);
		}
	});

	flowCombo = new ResultFlowCombo(comp);
	flowCombo.setEnabled(enabled);
	flowCombo.setInput(flows);
	flowCombo.selectFirst();
	flowCombo.addSelectionChangedListener(_e -> fireSelection());
	if (enabled) {
		flowCombo.select((IndexFlow) initialSelection);
	}
}
 
Example 6
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 7
Source File: Combo.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void initCostCombo(FormToolkit tk, Composite comp) {
	boolean enabled = getType(initialSelection) == ModelType.CURRENCY;
	Button check = tk.createButton(comp, M.CostCategory, SWT.RADIO);
	check.setSelection(enabled);
	Controls.onSelect(check, _e -> {
		if (check.getSelection()) {
			costCombo.setEnabled(true);
			selectedType = ModelType.CURRENCY;
			fire(costCombo.getSelected());
		} else {
			costCombo.setEnabled(false);
		}
	});

	costCombo = new CostResultViewer(comp);
	costCombo.setEnabled(enabled);
	costCombo.setInput(costs);
	costCombo.selectFirst();
	costCombo.addSelectionChangedListener(c -> {
		fire(c);
		check.setSelection(true);
	});
	if (enabled) {
		costCombo.select((CostResultDescriptor) initialSelection);
	}
}
 
Example 8
Source File: Combo.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void initImpactCombo(FormToolkit tk, Composite comp) {
	boolean enabled = getType(initialSelection) == ModelType.IMPACT_CATEGORY;
	Button check = tk.createButton(comp, M.ImpactCategory, SWT.RADIO);
	check.setSelection(enabled);
	Controls.onSelect(check, _e -> {
		if (check.getSelection()) {
			impactCombo.setEnabled(true);
			selectedType = ModelType.IMPACT_CATEGORY;
			fire(impactCombo.getSelected());
		} else {
			impactCombo.setEnabled(false);
		}
	});

	impactCombo = new ImpactCategoryViewer(comp);
	impactCombo.setEnabled(enabled);
	impactCombo.setInput(impacts);
	impactCombo.selectFirst();
	impactCombo.addSelectionChangedListener(imp -> {
		fire(imp);
		check.setSelection(true);
	});
	if (enabled) {
		impactCombo.select((ImpactCategoryDescriptor) initialSelection);
	}
}
 
Example 9
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 10
Source File: StatisticsPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void generalSection(FormToolkit tk, Composite body) {
	Composite comp = UI.formSection(body, tk, "General statistics");
	UI.gridLayout(comp, 2, 15, 10);

	UI.formLabel(comp, "Number of processes");
	bind(UI.formLabel(comp, ""), label -> {
		label.setText(Integer.toString(stats.processCount));
	});

	UI.formLabel(comp, "Number of process links");
	bind(UI.formLabel(comp, ""), label -> {
		label.setText(Integer.toString(stats.linkCount));
	});

	UI.formLabel(comp, "Connected graph / can calculate?");
	bind(UI.formLabel(comp, ""), label -> {
		String text = stats.connectedGraph
				? "yes"
				: "no";
		label.setText(text);
	});

	UI.formLabel(comp, "Reference process");
	ImageHyperlink link = new ImageHyperlink(comp, SWT.TOP);
	link.setForeground(Colors.linkBlue());
	link.setImage(Images.get(ModelType.PROCESS));
	Controls.onClick(link, e -> {
		if (stats != null) {
			App.openEditor(stats.refProcess);
		}
	});
	bind(link, l -> {
		l.setText(Labels.name(stats.refProcess));
	});

	UI.formLabel(comp, "");
	Button btn = tk.createButton(comp, M.Update, SWT.NONE);
	Controls.onSelect(btn, e -> calculate());
}
 
Example 11
Source File: GroupResultSection.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createImpact(FormToolkit toolkit, Composite parent) {
	Button impactCheck = toolkit.createButton(parent, M.ImpactCategories, SWT.RADIO);
	impactViewer = new ImpactCategoryViewer(parent);
	impactViewer.setEnabled(false);
	List<ImpactCategoryDescriptor> impacts = result.getImpacts();
	impactViewer.setInput(impacts);
	impactViewer.addSelectionChangedListener((e) -> update());
	if (impacts.size() > 0) {
		impactViewer.select(impacts.get(0));
	}
	new ResultTypeCheck(impactViewer, impactCheck, IMPACT);
}
 
Example 12
Source File: SimulationPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void initFlowCheckViewer(FormToolkit tk, Composite section) {
	Button flowsCheck = tk.createButton(section, M.Flows, SWT.RADIO);
	flowsCheck.setSelection(true);
	flowViewer = new ResultFlowCombo(section);
	flowViewer.setInput(result.getFlows());
	flowViewer.selectFirst();
	flowViewer.addSelectionChangedListener((e) -> updateSelection());
	new ResultTypeCheck<>(flowViewer, flowsCheck, FLOW);
}
 
Example 13
Source File: SimulationPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void initImpactCheckViewer(FormToolkit toolkit, Composite section) {
	Button impactCheck = toolkit.createButton(section,
			M.ImpactCategories, SWT.RADIO);
	impactViewer = new ImpactCategoryViewer(section);
	impactViewer.setEnabled(false);
	impactViewer.setInput(result.getImpacts());
	impactViewer.addSelectionChangedListener((e) -> updateSelection());
	impactViewer.selectFirst();
	new ResultTypeCheck<>(impactViewer, impactCheck, IMPACT);
}
 
Example 14
Source File: SimulationPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createProgressSection(FormToolkit toolkit, Composite body) {
	progressSection = UI.section(body, toolkit, M.Progress);
	Composite composite = UI.sectionClient(progressSection, toolkit);
	progressBar = new ProgressBar(composite, SWT.SMOOTH);
	progressBar.setMaximum(editor.setup.numberOfRuns);
	UI.gridData(progressBar, false, false).widthHint = 470;
	Button progressButton = toolkit.createButton(composite,
			M.Start, SWT.NONE);
	UI.gridData(progressButton, false, false).widthHint = 70;
	new SimulationControl(progressButton, editor, this);
}
 
Example 15
Source File: CurrencyEditor.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createRefButton(Composite comp, FormToolkit tk) {
	UI.filler(comp, tk);
	Button b = tk.createButton(comp, M.SetAsReferenceCurrency, SWT.NONE);
	b.setImage(Images.get(ModelType.CURRENCY));
	Controls.onSelect(b, e -> {
		RefCurrencyUpdate.run(getModel());
	});
	UI.filler(comp, tk);
}
 
Example 16
Source File: BigParameterTable.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
static FilterCombo create(Composite comp, FormToolkit tk) {
	FilterCombo combo = new FilterCombo();
	Button button = tk.createButton(comp, "All columns", SWT.NONE);
	button.setImage(Icon.DOWN.get());
	Menu menu = new Menu(button);
	int[] types = {
			ALL,
			NAMES,
			SCOPES,
			FORMULAS,
			DESCRIPTIONS,
			ERRORS
	};
	for (int type : types) {
		MenuItem item = new MenuItem(menu, SWT.NONE);
		item.setText(label(type));
		Controls.onSelect(item, e -> {
			combo.type = type;
			button.setText(label(type));
			button.setToolTipText(label(type));
			button.pack();
			button.getParent().layout();
			if (combo.onChange != null) {
				combo.onChange.run();
			}
		});
	}
	button.setMenu(menu);
	Controls.onSelect(button, e -> menu.setVisible(true));
	return combo;
}
 
Example 17
Source File: MappingPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createInfoSection(FormToolkit tk, Composite body) {
	Composite comp = UI.formSection(body, tk, M.GeneralInformation);
	Text name = UI.formText(comp, tk, M.Name);
	Controls.set(name, this.tool.mapping.name);

	UI.formLabel(comp, tk, "Source system");
	ProviderRow sourceRow = new ProviderRow(comp, tk);
	sourceRow.onSelect = p -> tool.sourceSystem = p;

	UI.formLabel(comp, tk, "Target system");
	ProviderRow targetRow = new ProviderRow(comp, tk);
	targetRow.onSelect = p -> tool.targetSystem = p;

	UI.filler(comp);
	Button checkButton = tk.createButton(comp, "Check mappings", SWT.NONE);
	Runnable updateCheckState = () -> {
		if (tool.checked.get()) {
			checkButton.setImage(Icon.ACCEPT.get());
			checkButton.setToolTipText("Click to check the mappings.");
		} else {
			checkButton.setImage(Icon.WARNING.get());
			checkButton.setToolTipText("No check was performed yet.");
		}
	};
	updateCheckState.run();
	Controls.onSelect(checkButton, _e -> {
		if (tool.sourceSystem == null || tool.targetSystem == null) {
			MsgBox.warning("No source or target system",
					"You need to select a source and target"
							+ " system against which you want"
							+ " to check the mapping.");
			return;
		}
		App.runWithProgress("Check mappings", this::syncMappings, () -> {
			tool.checked.set(true);
			table.setInput(tool.mapping.entries);
			updateCheckState.run();
		});
	});
}
 
Example 18
Source File: ResequencerPropertiesEditionPartForm.java    From eip-designer with Apache License 2.0 5 votes vote down vote up
protected Composite createStreamSequencesCheckbox(FormToolkit widgetFactory, Composite parent) {
	streamSequences = widgetFactory.createButton(parent, getDescription(EipViewsRepository.Resequencer.Properties.streamSequences, EipMessages.ResequencerPropertiesEditionPart_StreamSequencesLabel), SWT.CHECK);
	streamSequences.addSelectionListener(new SelectionAdapter() {

		/**
		 * {@inheritDoc}
		 *
		 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
		 * 	
		 */
		public void widgetSelected(SelectionEvent e) {
			if (propertiesEditionComponent != null)
				propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ResequencerPropertiesEditionPartForm.this, EipViewsRepository.Resequencer.Properties.streamSequences, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, new Boolean(streamSequences.getSelection())));
		}

	});
	GridData streamSequencesData = new GridData(GridData.FILL_HORIZONTAL);
	streamSequencesData.horizontalSpan = 2;
	streamSequences.setLayoutData(streamSequencesData);
	EditingUtils.setID(streamSequences, EipViewsRepository.Resequencer.Properties.streamSequences);
	EditingUtils.setEEFtype(streamSequences, "eef::Checkbox"); //$NON-NLS-1$
	FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(EipViewsRepository.Resequencer.Properties.streamSequences, EipViewsRepository.FORM_KIND), null); //$NON-NLS-1$
	// Start of user code for createStreamSequencesCheckbox

	// End of user code
	return parent;
}
 
Example 19
Source File: ChannelPropertiesEditionPartForm.java    From eip-designer with Apache License 2.0 5 votes vote down vote up
protected Composite createGuaranteedCheckbox(FormToolkit widgetFactory, Composite parent) {
	guaranteed = widgetFactory.createButton(parent, getDescription(EipViewsRepository.Channel.Properties.guaranteed, EipMessages.ChannelPropertiesEditionPart_GuaranteedLabel), SWT.CHECK);
	guaranteed.addSelectionListener(new SelectionAdapter() {

		/**
		 * {@inheritDoc}
		 *
		 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
		 * 	
		 */
		public void widgetSelected(SelectionEvent e) {
			if (propertiesEditionComponent != null)
				propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ChannelPropertiesEditionPartForm.this, EipViewsRepository.Channel.Properties.guaranteed, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, new Boolean(guaranteed.getSelection())));
		}

	});
	GridData guaranteedData = new GridData(GridData.FILL_HORIZONTAL);
	guaranteedData.horizontalSpan = 2;
	guaranteed.setLayoutData(guaranteedData);
	EditingUtils.setID(guaranteed, EipViewsRepository.Channel.Properties.guaranteed);
	EditingUtils.setEEFtype(guaranteed, "eef::Checkbox"); //$NON-NLS-1$
	FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(EipViewsRepository.Channel.Properties.guaranteed, EipViewsRepository.FORM_KIND), null); //$NON-NLS-1$
	// Start of user code for createGuaranteedCheckbox

	// End of user code
	return parent;
}
 
Example 20
Source File: ImpactChecksPage.java    From olca-app with Mozilla Public License 2.0 4 votes vote down vote up
@Override
protected void createFormContent(IManagedForm mform) {
	ScrolledForm form = UI.formHeader(mform,
			"Flows that are not covered by the "
					+ "selected LCIA method",
			Images.get(result));
	FormToolkit tk = mform.getToolkit();
	Composite body = UI.formBody(form, tk);

	// the grouping check
	Button group = tk.createButton(body,
			"Group by LCIA category", SWT.CHECK);
	group.setSelection(true);
	Controls.onSelect(group, e -> {
		tree.setInput(
				group.getSelection()
						? groupedNodes()
						: flatNodes());
	});

	// create the tree
	tree = Trees.createViewer(body,
			M.Name, M.Category, M.InventoryResult);
	tree.setContentProvider(new ContentProvider());
	tree.setLabelProvider(new Label());
	tree.getTree().getColumns()[2].setAlignment(SWT.RIGHT);
	Trees.bindColumnWidths(
			tree.getTree(), 0.4, 0.4, 0.2);

	// bind `onOpen`
	Action onOpen = Actions.onOpen(() -> {
		Contribution<?> c = Viewers.getFirstSelected(tree);
		if (c == null)
			return;
		if (c.item instanceof IndexFlow) {
			IndexFlow f = (IndexFlow) c.item;
			App.openEditor(f.flow);
		} else if (c.item instanceof ImpactCategoryDescriptor) {
			App.openEditor((ImpactCategoryDescriptor) c.item);
		}
	});
	Actions.bind(tree, onOpen);
	Trees.onDoubleClick(tree, e -> onOpen.run());

	tree.setInput(group.getSelection()
			? groupedNodes()
			: flatNodes());
}