use of org.eclipse.jface.viewers.ComboViewer in project linuxtools by eclipse.
the class ContainerLinkDialog method createDialogArea.
@Override
protected Control createDialogArea(final Composite parent) {
final int COLUMNS = 2;
final Composite container = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(COLUMNS, 1).grab(true, false).applyTo(container);
GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(10, 10).applyTo(container);
final Label explanationLabel = new Label(container, SWT.NONE);
explanationLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerLinkDialog.explanationLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(false, false).applyTo(explanationLabel);
final Label containerLabel = new Label(container, SWT.NONE);
containerLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ContainerLinkDialog.containerLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(containerLabel);
final Combo containerSelectionCombo = new Combo(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(containerSelectionCombo);
final ComboViewer containerSelectionComboViewer = new ComboViewer(containerSelectionCombo);
containerSelectionComboViewer.setContentProvider(new ArrayContentProvider());
containerSelectionComboViewer.setInput(model.getContainerNames());
new ContentProposalAdapter(containerSelectionCombo, new ComboContentAdapter() {
@Override
public void insertControlContents(Control control, String text, int cursorPosition) {
final Combo combo = (Combo) control;
final Point selection = combo.getSelection();
combo.setText(text);
selection.x = text.length();
selection.y = selection.x;
combo.setSelection(selection);
}
}, getContainerNameContentProposalProvider(containerSelectionCombo), null, null);
final Label aliasLabel = new Label(container, SWT.NONE);
aliasLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ContainerLinkDialog.aliasLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(aliasLabel);
final Text containerAliasText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(containerAliasText);
// error message
final Label errorMessageLabel = new Label(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(true, false).applyTo(errorMessageLabel);
final ISWTObservableValue containerNameObservable = WidgetProperties.selection().observe(containerSelectionComboViewer.getCombo());
dbc.bindValue(containerNameObservable, BeanProperties.value(ContainerLinkDialogModel.class, ContainerLinkDialogModel.CONTAINER_NAME).observe(model));
final ISWTObservableValue containerAliasObservable = WidgetProperties.text(SWT.Modify).observe(containerAliasText);
dbc.bindValue(containerAliasObservable, BeanProperties.value(ContainerLinkDialogModel.class, ContainerLinkDialogModel.CONTAINER_ALIAS).observe(model));
containerNameObservable.addValueChangeListener(onContainerLinkSettingsChanged());
containerAliasObservable.addValueChangeListener(onContainerLinkSettingsChanged());
return container;
}
use of org.eclipse.jface.viewers.ComboViewer in project linuxtools by eclipse.
the class ImageBuildDialog method createDialogArea.
@Override
protected Control createDialogArea(final Composite parent) {
final int COLUMNS = 2;
final Composite container = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(COLUMNS, 1).grab(true, false).applyTo(container);
GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(10, 10).applyTo(container);
final Label explanationLabel = new Label(container, SWT.NONE);
explanationLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ImageBuildDialog.explanationLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(false, false).applyTo(explanationLabel);
final Label containerLabel = new Label(container, SWT.NONE);
containerLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ImageBuildDialog.connectionLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(containerLabel);
final Combo containerSelectionCombo = new Combo(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(containerSelectionCombo);
final ComboViewer connectionSelectionComboViewer = new ComboViewer(containerSelectionCombo);
connectionSelectionComboViewer.setContentProvider(new ArrayContentProvider());
final List<String> connectionNames = model.getConnectionNames();
connectionSelectionComboViewer.setInput(connectionNames);
new ContentProposalAdapter(containerSelectionCombo, new ComboContentAdapter() {
@Override
public void insertControlContents(Control control, String text, int cursorPosition) {
final Combo combo = (Combo) control;
final Point selection = combo.getSelection();
combo.setText(text);
selection.x = text.length();
selection.y = selection.x;
combo.setSelection(selection);
}
}, getConnectionNameContentProposalProvider(containerSelectionCombo), null, null);
final Label repoNameLabel = new Label(container, SWT.NONE);
repoNameLabel.setToolTipText(// $NON-NLS-1$
WizardMessages.getString("ImageBuildName.toolTip"));
// $NON-NLS-1$
repoNameLabel.setText(WizardMessages.getString("ImageBuildName.label"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(repoNameLabel);
final Text repoNameText = new Text(container, SWT.BORDER);
repoNameText.setToolTipText(// $NON-NLS-1$
WizardMessages.getString("ImageBuildName.toolTip"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(repoNameText);
final ISWTObservableValue connnectionNameObservable = WidgetProperties.selection().observe(connectionSelectionComboViewer.getCombo());
// pre-select with first connection
if (!connectionNames.isEmpty()) {
model.setConnectionName(connectionNames.get(0));
}
// error message
final Composite errorContainer = new Composite(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(COLUMNS, 1).grab(true, true).applyTo(errorContainer);
GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(2).applyTo(errorContainer);
final Label errorMessageIcon = new Label(errorContainer, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).hint(20, SWT.DEFAULT).applyTo(errorMessageIcon);
final Label errorMessageLabel = new Label(errorContainer, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(errorMessageLabel);
dbc.bindValue(connnectionNameObservable, BeanProperties.value(ImageBuildDialogModel.class, ImageBuildDialogModel.CONNECTION_NAME).observe(model));
final ISWTObservableValue repoNameObservable = WidgetProperties.text(SWT.Modify).observe(repoNameText);
dbc.bindValue(repoNameObservable, BeanProperties.value(ImageBuildDialogModel.class, ImageBuildDialogModel.REPO_NAME).observe(model));
// must be called after bindings were set
setupValidationSupport(errorMessageIcon, errorMessageLabel);
return container;
}
use of org.eclipse.jface.viewers.ComboViewer in project linuxtools by eclipse.
the class ImagePullPushPage method createRegistrySelectionControls.
@SuppressWarnings("unchecked")
IObservableValue<IRegistry> createRegistrySelectionControls(Composite parent) {
// registry selection
final Label accountLabel = new Label(parent, SWT.NULL);
accountLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ImagePullPushPage.registry.account.label"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(accountLabel);
final Combo registryAccountCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
registryAccountCombo.setToolTipText(WizardMessages.getString(// $NON-NLS-1$
"ImagePullPushPage.registry.account.desc"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(registryAccountCombo);
final ComboViewer registryAccountComboViewer = new ComboViewer(registryAccountCombo);
registryAccountComboViewer.setContentProvider(ArrayContentProvider.getInstance());
registryAccountComboViewer.setLabelProvider(new RegistryAccountLabelProvider());
final List<IRegistry> allRegistryAccounts = getRegistryAccounts();
final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
// Calculate selected registry account to be the last one used
// or else default to the first in the list
IRegistry defaultRegistry = null;
String lastRegistry = store.getString(PreferenceConstants.LAST_REGISTRY_ACCOUNT);
if (!allRegistryAccounts.isEmpty()) {
defaultRegistry = allRegistryAccounts.get(0);
}
IRegistry selectedRegistry = allRegistryAccounts.stream().filter(x -> ((RegistryInfo) x).getRegistryId().equals(lastRegistry)).findFirst().orElse(defaultRegistry);
registryAccountComboViewer.setInput(allRegistryAccounts);
if (selectedRegistry != null) {
getModel().setSelectedRegistry(selectedRegistry);
}
final IObservableValue<IRegistry> registryAccountObservable = BeanProperties.value(ImagePushPageModel.class, ImagePullPushPageModel.SELECTED_REGISTRY).observe(model);
dbc.bindValue(ViewerProperties.singleSelection().observe(registryAccountComboViewer), registryAccountObservable);
// link to add registries and accounts
final Link addRegistryLink = new Link(parent, SWT.NONE);
addRegistryLink.setText(// $NON-NLS-1$
WizardMessages.getString("ImagePullPushPage.add.link"));
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(addRegistryLink);
addRegistryLink.addSelectionListener(onAddRegistry(registryAccountComboViewer));
return registryAccountObservable;
}
use of org.eclipse.jface.viewers.ComboViewer in project linuxtools by eclipse.
the class FileSystemSelectionArea method createContents.
/**
* Create the contents of the receiver in composite.
* @param composite Parent composite for created components.
*/
public void createContents(Composite composite) {
fileSystemTitle = new Label(composite, SWT.NONE);
fileSystemTitle.setText(ResourceSelectorWidgetMessages.fileSystemSelectionText);
fileSystemTitle.setFont(composite.getFont());
fileSystems = new ComboViewer(composite, SWT.READ_ONLY);
fileSystems.getControl().setFont(composite.getFont());
fileSystems.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((FileSystemElement) element).getSchemeLabel();
}
});
fileSystems.setContentProvider(new IStructuredContentProvider() {
@Override
public void dispose() {
// Nothing to do
}
@Override
public Object[] getElements(Object inputElement) {
return getSchemes();
}
@Override
public void inputChanged(org.eclipse.jface.viewers.Viewer viewer, Object oldInput, Object newInput) {
// Nothing to do
}
});
fileSystems.setInput(this);
Iterator<FileSystemElement> fsEltItr = fsElements.iterator();
boolean foundDefault = false;
while (fsEltItr.hasNext()) {
FileSystemElement fsElt = fsEltItr.next();
if (fsElt.getIsDefault()) {
if (foundDefault) {
ProfileLaunchPlugin.log(IStatus.WARNING, ResourceSelectorWidgetMessages.FileSystemSelectionArea_found_multiple_default_extensions + fsElt.getScheme());
// use only the first one we found marked as default
continue;
}
fileSystems.setSelection(new StructuredSelection(fsElt));
foundDefault = true;
}
}
}
use of org.eclipse.jface.viewers.ComboViewer in project knime-core by knime.
the class NodeOutputView method createPartControl.
/**
* {@inheritDoc}
*/
@Override
public void createPartControl(final Composite parent) {
// Toolbar
IToolBarManager toolbarMGR = getViewSite().getActionBars().getToolBarManager();
// create button for stick with branch.
final RetargetAction lockAction = new RetargetAction("StayOnBranch", "Pin view to new node added to branch", IAction.AS_CHECK_BOX);
lockAction.setImageDescriptor(ImageDescriptor.createFromFile(this.getClass(), "icons/lock.png"));
lockAction.setChecked(m_branchLocked);
lockAction.setEnabled(m_pinned);
lockAction.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (lockAction.isChecked()) {
m_branchLocked = true;
m_selectionWhenLocked = m_lastSelection;
} else {
m_branchLocked = false;
selectionChanged(null, m_lastSelectionWhilePinned);
}
}
});
toolbarMGR.add(lockAction);
// create button which allows to "pin" selection:
m_pinButton = new RetargetAction("PinView", "Pin view to selected node", IAction.AS_CHECK_BOX);
m_pinButton.setImageDescriptor(ImageDescriptor.createFromFile(this.getClass(), "icons/pin.png"));
m_pinButton.setChecked(m_pinned);
m_pinButton.setEnabled(true);
m_pinButton.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (m_pinButton.isChecked()) {
m_pinned = true;
m_lastSelectionWhilePinned = m_lastSelection;
lockAction.setEnabled(true);
} else {
m_pinned = false;
selectionChanged(null, m_lastSelectionWhilePinned);
lockAction.setEnabled(false);
}
}
});
toolbarMGR.add(m_pinButton);
toolbarMGR.add(new Separator());
// configure drop down menu
IMenuManager dropDownMenu = getViewSite().getActionBars().getMenuManager();
// drop down menu entry for outport table:
final RetargetAction menuentrytable = new RetargetAction("OutputTable", "Show Output Table", IAction.AS_RADIO_BUTTON);
menuentrytable.setChecked(DISPLAYOPTIONS.TABLE.equals(m_choice));
menuentrytable.setEnabled(true);
menuentrytable.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (menuentrytable.isChecked()) {
m_choice = DISPLAYOPTIONS.TABLE;
updateNodeContainerInfo(m_lastNode);
}
}
});
dropDownMenu.add(menuentrytable);
// drop down menu entry for node variables:
final RetargetAction dropdownmenuvars = new RetargetAction("NodeVariables", "Show Variables", IAction.AS_RADIO_BUTTON);
dropdownmenuvars.setChecked(DISPLAYOPTIONS.VARS.equals(m_choice));
dropdownmenuvars.setEnabled(true);
dropdownmenuvars.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (dropdownmenuvars.isChecked()) {
m_choice = DISPLAYOPTIONS.VARS;
updateNodeContainerInfo(m_lastNode);
}
}
});
dropDownMenu.add(dropdownmenuvars);
// drop down menu entry for configuration/settings:
final RetargetAction menuentrysettings = new RetargetAction("NodeConf", "Show Configuration", IAction.AS_RADIO_BUTTON);
menuentrysettings.setChecked(DISPLAYOPTIONS.SETTINGS.equals(m_choice));
menuentrysettings.setEnabled(true);
menuentrysettings.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (menuentrysettings.isChecked()) {
m_choice = DISPLAYOPTIONS.SETTINGS;
updateNodeContainerInfo(m_lastNode);
}
}
});
dropDownMenu.add(menuentrysettings);
// drop down menu entry for configuration/settings:
final RetargetAction menuentryallsettings = new RetargetAction("NodeConfAll", "Show Entire Configuration", IAction.AS_RADIO_BUTTON);
menuentryallsettings.setChecked(DISPLAYOPTIONS.ALLSETTINGS.equals(m_choice));
menuentryallsettings.setEnabled(true);
menuentryallsettings.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (menuentryallsettings.isChecked()) {
m_choice = DISPLAYOPTIONS.ALLSETTINGS;
updateNodeContainerInfo(m_lastNode);
}
}
});
dropDownMenu.add(menuentryallsettings);
// drop down menu entry for node graph annotations
final RetargetAction menuentrygraphannotations = new RetargetAction("NodeGraphAnno", "Show Graph Annotations", IAction.AS_RADIO_BUTTON);
menuentrygraphannotations.setChecked(DISPLAYOPTIONS.GRAPHANNOTATIONS.equals(m_choice));
menuentrygraphannotations.setEnabled(true);
menuentrygraphannotations.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (menuentrygraphannotations.isChecked()) {
m_choice = DISPLAYOPTIONS.GRAPHANNOTATIONS;
updateNodeContainerInfo(m_lastNode);
}
}
});
dropDownMenu.add(menuentrygraphannotations);
// Content
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(parent);
// Node Title:
Label titlelabel = new Label(parent, SWT.NONE);
titlelabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
titlelabel.setText("Node: ");
m_title = new Text(parent, SWT.BORDER);
m_title.setEditable(false);
m_title.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
m_title.setText("n/a.");
// Panel for currently displayed information (some information
// providers will add more elements to this):
Composite infoPanel = new Composite(parent, SWT.NONE);
GridData infoGrid = new GridData(SWT.FILL, SWT.TOP, true, false);
infoGrid.horizontalSpan = 2;
infoPanel.setLayoutData(infoGrid);
GridLayoutFactory.swtDefaults().numColumns(3).applyTo(infoPanel);
m_info = new Label(infoPanel, SWT.NONE);
m_info.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
m_info.setText("n/a. ");
m_portIndex = new ComboViewer(infoPanel);
m_portIndex.add(new String[] { "port 0", "port 1", "port 2" });
m_portIndex.getCombo().setEnabled(false);
m_portIndex.getCombo().setSelection(new Point(m_portIndexInit, m_portIndexInit));
m_portIndex.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
ISelection sel = event.getSelection();
try {
int newIndex = Integer.parseInt(sel.toString().substring(5).replace(']', ' ').trim());
NodeContainer node;
if (m_workflow.containsNodeContainer(m_lastNode)) {
node = m_workflow.getNodeContainer(m_lastNode);
updateDataTable(node, newIndex);
}
} catch (NumberFormatException nfe) {
// ignore.
}
}
});
// Table:
// stack panel switches between KNIME data table view and SWT table for other info
m_stackPanel = new Composite(parent, SWT.NONE);
m_stackPanel.setLayout(new StackLayout());
GridData tableGrid = new GridData(SWT.FILL, SWT.FILL, true, true);
m_stackPanel.setLayoutData(tableGrid);
// DataTable view wrapped in AWT-SWT bridge
m_tableView = new TableView();
m_tableViewPanel = new Panel2CompositeWrapper(m_stackPanel, m_tableView, SWT.NONE);
m_errorLabel = new Label(m_stackPanel, SWT.NONE);
// SWT Table for the other info
m_table = new Table(m_stackPanel, SWT.MULTI | SWT.BORDER);
m_table.setLinesVisible(true);
m_table.setHeaderVisible(true);
tableGrid.horizontalSpan = 2;
m_table.setLayoutData(tableGrid);
String[] titles = { "Name", "Value" };
for (int i = 0; i < titles.length; i++) {
TableColumn column = new TableColumn(m_table, SWT.NONE);
column.setText(titles[i]);
}
for (int i = 0; i < titles.length; i++) {
m_table.getColumn(i).pack();
}
m_lastNode = null;
getViewSite().getPage().addSelectionListener(this);
if (m_choice.equals(DISPLAYOPTIONS.TABLE)) {
((StackLayout) m_stackPanel.getLayout()).topControl = m_tableViewPanel;
m_stackPanel.layout();
} else {
((StackLayout) m_stackPanel.getLayout()).topControl = m_table;
m_stackPanel.layout();
}
m_stackPanel.layout();
selectionChanged(null, m_lastSelection);
}
Aggregations