use of org.eclipse.jface.viewers.ArrayContentProvider in project linuxtools by eclipse.
the class MassifViewPart method createPartControl.
@Override
public void createPartControl(Composite parent) {
chartInputs = new ArrayList<>();
top = new Composite(parent, SWT.NONE);
stackLayout = new StackLayout();
top.setLayout(stackLayout);
top.setLayoutData(new GridData(GridData.FILL_BOTH));
viewer = new TableViewer(top, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
Table table = viewer.getTable();
table.setLayoutData(new GridData(GridData.FILL_BOTH));
String[] columnTitles = { TITLE_NUMBER, TITLE_TIME, TITLE_TOTAL, TITLE_USEFUL, TITLE_EXTRA, TITLE_STACKS };
for (int i = 0; i < columnTitles.length; i++) {
TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
column.getColumn().setText(columnTitles[i]);
column.getColumn().setWidth(COLUMN_SIZE);
column.getColumn().setResizable(true);
column.getColumn().addSelectionListener(getHeaderListener());
}
table.setHeaderVisible(true);
table.setLinesVisible(true);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new MassifLabelProvider());
treeViewer = new MassifTreeViewer(top);
treeViewer.getViewer().getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
viewer.addDoubleClickListener(event -> {
MassifSnapshot snapshot = (MassifSnapshot) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (snapshot.getType() != SnapshotType.EMPTY) {
treeAction.setChecked(true);
setTopControl(treeViewer.getViewer().getControl());
treeViewer.getViewer().setSelection(new StructuredSelection(snapshot.getRoot()), true);
treeViewer.getViewer().expandToLevel(snapshot.getRoot(), AbstractTreeViewer.ALL_LEVELS);
}
});
stackLayout.topControl = viewer.getControl();
top.layout();
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project linuxtools by eclipse.
the class ContainerDataVolumeDialog method createDialogArea.
@Override
protected Control createDialogArea(final Composite parent) {
final Composite container = new Composite(parent, SWT.NONE);
final int COLUMNS = 3;
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(1, 1).grab(true, true).applyTo(container);
GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(COLUMNS).applyTo(container);
// Container path
final Label containerPathLabel = new Label(container, SWT.NONE);
containerPathLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.containerPathLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(containerPathLabel);
final Text containerPathText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(containerPathText);
final IObservableValue containerPathObservable = BeanProperties.value(DataVolumeModel.class, DataVolumeModel.CONTAINER_PATH).observe(model);
dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(containerPathText), containerPathObservable);
// mount type
final Label explanationLabel = new Label(container, SWT.NONE);
explanationLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.explanationLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(true, false).applyTo(explanationLabel);
final int INDENT = 20;
// No mount
final Button noMountButton = new Button(container, SWT.RADIO);
noMountButton.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.noMountButton"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(INDENT, 0).span(COLUMNS, 1).grab(true, false).applyTo(noMountButton);
bindButton(noMountButton, MountType.NONE);
// File System mount
final Button fileSystemMountButton = new Button(container, SWT.RADIO);
fileSystemMountButton.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.fileSystemMountButton"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(INDENT, 0).span(COLUMNS, 1).grab(true, false).applyTo(fileSystemMountButton);
final Label hostPathLabel = new Label(container, SWT.NONE);
hostPathLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.hostPathLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(2 * INDENT, SWT.DEFAULT).grab(false, false).applyTo(hostPathLabel);
final Text hostPathText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(hostPathText);
final IObservableValue hostPathObservable = BeanProperties.value(DataVolumeModel.class, DataVolumeModel.HOST_PATH_MOUNT).observe(model);
dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(hostPathText), hostPathObservable);
// browse for directory
final Button hostPathDirectoryButton = new Button(container, SWT.NONE);
hostPathDirectoryButton.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.directoryButton"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(hostPathDirectoryButton);
hostPathDirectoryButton.addSelectionListener(onHostDirectoryPath());
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(new Label(container, SWT.NONE));
// optional read-only access
final Button readOnlyButton = new Button(container, SWT.CHECK);
readOnlyButton.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.readOnlyButton"));
readOnlyButton.setToolTipText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.readOnlyButtonTooltip"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS - 2, 1).grab(true, false).applyTo(readOnlyButton);
final ISWTObservableValue readOnlyButtonObservable = WidgetProperties.selection().observe(readOnlyButton);
dbc.bindValue(readOnlyButtonObservable, BeanProperties.value(DataVolumeModel.class, DataVolumeModel.READ_ONLY_VOLUME).observe(model));
// browse for file
final Button hostPathFileButton = new Button(container, SWT.NONE);
hostPathFileButton.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.fileButton"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(hostPathFileButton);
hostPathFileButton.addSelectionListener(onHostFilePath());
bindButton(fileSystemMountButton, MountType.HOST_FILE_SYSTEM, hostPathText, hostPathDirectoryButton, hostPathFileButton, readOnlyButton);
// Container mount
final Button containerMountButton = new Button(container, SWT.RADIO);
containerMountButton.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.containerMountButton"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(INDENT, 0).span(COLUMNS, 1).grab(true, false).applyTo(containerMountButton);
final Label containerSelectionLabel = new Label(container, SWT.NONE);
containerSelectionLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.containerSelectionLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(2 * INDENT, SWT.DEFAULT).applyTo(containerSelectionLabel);
final Combo containerSelectionCombo = new Combo(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(1, 1).applyTo(containerSelectionCombo);
new ControlDecoration(containerSelectionCombo, SWT.TOP | SWT.LEFT);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(new Label(container, SWT.NONE));
bindButton(containerMountButton, MountType.CONTAINER, containerSelectionCombo);
final ComboViewer containerSelectionComboViewer = new ComboViewer(containerSelectionCombo);
containerSelectionComboViewer.setContentProvider(new ArrayContentProvider());
containerSelectionComboViewer.setInput(this.containerNames);
final IObservableValue selectedContainerObservable = BeanProperties.value(DataVolumeModel.class, DataVolumeModel.CONTAINER_MOUNT).observe(model);
dbc.bindValue(WidgetProperties.selection().observe(containerSelectionCombo), selectedContainerObservable);
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);
// 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);
setupValidationSupport(errorMessageIcon, errorMessageLabel);
return container;
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project linuxtools by eclipse.
the class DockerComposeUpDialog method createDialogArea.
@SuppressWarnings("unchecked")
@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$
"DockerComposeUpDialog.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(WizardMessages.getString(// $NON-NLS-1$
"DockerComposeUpDialog.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 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(DockerComposeUpModel.class, DockerComposeUpModel.CONNECTION_NAME).observe(model));
// must be called after bindings were set
setupValidationSupport(errorMessageIcon, errorMessageLabel);
return container;
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project linuxtools by eclipse.
the class ImagePushPage method createImageSelectionControls.
@SuppressWarnings("unchecked")
private IObservableValue<String> createImageSelectionControls(final Composite container) {
final Label nameLabel = new Label(container, SWT.NULL);
nameLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ImagePullPushPage.name.label"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(nameLabel);
final Combo imageNameCombo = new Combo(container, SWT.DROP_DOWN);
imageNameCombo.setToolTipText(// $NON-NLS-1$
WizardMessages.getString("ImagePushName.toolTip"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(imageNameCombo);
final ComboViewer imageNameComboViewer = new ComboViewer(imageNameCombo);
imageNameComboViewer.setContentProvider(new ArrayContentProvider());
imageNameComboViewer.setInput(getModel().getImage().repoTags());
// binding must take place after the input is set, so that default
// repo/name can be selected.
final IObservableValue<String> imageNameObservable = BeanProperties.value(ImagePushPageModel.class, ImagePullPushPageModel.SELECTED_IMAGE_NAME).observe(getModel());
dbc.bindValue(WidgetProperties.selection().observe(imageNameCombo), imageNameObservable);
// filler for the last column
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(new Label(container, SWT.NONE));
return imageNameObservable;
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project yamcs-studio by yamcs.
the class RuleDataEditDialog method createExpressionsTableViewer.
/**
* Creates and configures a {@link TableViewer}.
*
* @param parent
* The parent for the table
* @return The {@link TableViewer}
*/
private TableViewer createExpressionsTableViewer(final Composite parent) {
final TableViewer viewer = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
viewer.getTable().setLinesVisible(true);
viewer.getTable().setHeaderVisible(true);
TableViewerColumn expressionColumn = new TableViewerColumn(viewer, SWT.NONE);
expressionColumn.getColumn().setText("Boolean Expression");
expressionColumn.getColumn().setMoveable(false);
expressionColumn.getColumn().setWidth(200);
expressionColumn.setEditingSupport(new EditingSupport(viewer) {
@Override
protected void setValue(Object element, Object value) {
if (element instanceof Expression)
((Expression) element).setBooleanExpression(value.toString());
viewer.refresh();
}
@Override
protected Object getValue(Object element) {
if (element instanceof Expression)
return ((Expression) element).getBooleanExpression();
return null;
}
@Override
protected CellEditor getCellEditor(Object element) {
return new TextCellEditor(viewer.getTable());
}
@Override
protected boolean canEdit(Object element) {
return true;
}
});
valueColumn = new TableViewerColumn(viewer, SWT.NONE);
valueColumn.getColumn().setText(ruleData.isOutputExpValue() ? "Output Expression" : "Output Value");
valueColumn.getColumn().setMoveable(false);
valueColumn.getColumn().setWidth(200);
EditingSupport editingSupport = new EditingSupport(viewer) {
@Override
protected void setValue(Object element, Object value) {
if (element instanceof Expression) {
((Expression) element).setValue(value);
}
viewer.refresh();
}
@Override
protected Object getValue(Object element) {
if (element instanceof Expression) {
if (((Expression) element).getValue() == null)
// $NON-NLS-1$
return "";
return ((Expression) element).getValue();
}
return null;
}
@Override
protected CellEditor getCellEditor(Object element) {
if (element instanceof Expression) {
if (ruleData.isOutputExpValue() || ruleData.getProperty().getPropertyDescriptor() == null)
return new TextCellEditor(viewer.getTable());
else
return ruleData.getProperty().getPropertyDescriptor().createPropertyEditor(viewer.getTable());
}
return null;
}
@Override
protected boolean canEdit(Object element) {
return true;
}
};
valueColumn.setEditingSupport(editingSupport);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new ExpressionLabelProvider());
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
viewer.getTable().setLayoutData(gd);
return viewer;
}
Aggregations