use of org.eclipse.jface.viewers.IStructuredContentProvider in project tbd-studio-se by Talend.
the class RelationshipTableView method createComboBoxCellEditor.
private ComboBoxViewerCellEditor createComboBoxCellEditor(Table table) {
ComboBoxViewerCellEditor cellEditor = new ComboBoxViewerCellEditor(table);
cellEditor.setContenProvider(new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
}
@Override
public void dispose() {
}
@Override
public Object[] getElements(Object arg0) {
return (String[]) arg0;
}
});
cellEditor.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return (String) element;
}
});
cellEditor.setInput(Relationship.Direction.getNames());
cellEditor.setValue(Relationship.Direction.OUTGOING.getName());
return cellEditor;
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project archi by archimatetool.
the class RelationshipsMatrixDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
setTitle(Messages.RelationshipsMatrixDialog_0);
setMessage(Messages.RelationshipsMatrixDialog_1);
Composite composite = (Composite) super.createDialogArea(parent);
Composite client = new Composite(composite, SWT.NULL);
GridLayout layout = new GridLayout(2, false);
client.setLayout(layout);
client.setLayoutData(new GridData(GridData.FILL_BOTH));
GridData gd;
GridTableViewer viewer = new GridTableViewer(client);
gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 800;
gd.heightHint = 500;
viewer.getControl().setLayoutData(gd);
viewer.getGrid().setHeaderVisible(true);
viewer.getGrid().setRowHeaderVisible(true);
viewer.getGrid().setRowsResizeable(true);
viewer.getGrid().setCellSelectionEnabled(true);
// viewer.setColumnProperties(new String[] {"1", "2", "3"});
viewer.setRowHeaderLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
cell.setText(ArchiLabelProvider.INSTANCE.getDefaultName((EClass) cell.getElement()));
cell.setImage(ArchiLabelProvider.INSTANCE.getImage(cell.getElement()));
}
});
GC gc = new GC(viewer.getGrid());
// $NON-NLS-1$
int columnWidth = gc.textExtent("acfginorstv").x + 8;
gc.dispose();
for (EClass eClass : getData()) {
GridColumn column = new GridColumn(viewer.getGrid(), SWT.NONE);
column.setWidth(columnWidth);
column.setImage(ArchiLabelProvider.INSTANCE.getImage(eClass));
column.setHeaderTooltip(ArchiLabelProvider.INSTANCE.getDefaultName(eClass));
}
viewer.setContentProvider(new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@Override
public void dispose() {
}
@Override
public Object[] getElements(Object inputElement) {
return getData().toArray();
}
});
viewer.setLabelProvider(new MyLabelProvider());
// hookContextMenu(viewer);
viewer.setInput(getData());
// $NON-NLS-1$
String text = "";
for (Entry<EClass, Character> entry : RelationshipsMatrix.INSTANCE.getRelationshipsValueMap().entrySet()) {
// $NON-NLS-1$ //$NON-NLS-2$
text += entry.getValue() + ": " + ArchiLabelProvider.INSTANCE.getDefaultName(entry.getKey()) + "\n";
}
Label label = new Label(client, SWT.NULL);
label.setText(text);
label.setLayoutData(new GridData(SWT.TOP, SWT.TOP, false, true));
return composite;
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project archi by archimatetool.
the class ConnectionsARMPreferencePage method createRelationsTable.
private CheckboxTableViewer createRelationsTable(Composite parent) {
final CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
GridDataFactory.create(GridData.FILL_HORIZONTAL).hint(SWT.DEFAULT, 100).applyTo(viewer.getTable());
viewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ArchiLabelProvider.INSTANCE.getDefaultName((EClass) element);
}
@Override
public Image getImage(Object element) {
return ArchiLabelProvider.INSTANCE.getImage(element);
}
});
viewer.setContentProvider(new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@Override
public void dispose() {
}
@Override
public Object[] getElements(Object inputElement) {
return ConnectionPreferences.RELATION_KEYMAP.keySet().toArray();
}
});
viewer.setCheckStateProvider(new ICheckStateProvider() {
@Override
public boolean isGrayed(Object element) {
return false;
}
@Override
public boolean isChecked(Object element) {
int value = (Integer) viewer.getInput();
return (value & ConnectionPreferences.RELATION_KEYMAP.get(element)) != 0;
}
});
return viewer;
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project archi by archimatetool.
the class DropinsPluginDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
setTitle(Messages.DropinsPluginDialog_1);
setMessage(Messages.DropinsPluginDialog_2);
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayoutData(new GridData(GridData.FILL_BOTH));
container.setLayout(new GridLayout(1, false));
Composite tableComp = new Composite(container, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
tableComp.setLayout(layout);
GridData gd = new GridData(GridData.FILL_BOTH);
tableComp.setLayoutData(gd);
viewer = new TableViewer(tableComp, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(viewer.getTable());
viewer.getTable().setHeaderVisible(true);
TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
layout.setColumnData(column.getColumn(), new ColumnWeightData(10, false));
column.getColumn().setText(Messages.DropinsPluginDialog_3);
column = new TableViewerColumn(viewer, SWT.NONE);
layout.setColumnData(column.getColumn(), new ColumnWeightData(8, false));
column.getColumn().setText(Messages.DropinsPluginDialog_4);
column = new TableViewerColumn(viewer, SWT.NONE);
layout.setColumnData(column.getColumn(), new ColumnWeightData(10, false));
column.getColumn().setText(Messages.DropinsPluginDialog_5);
column = new TableViewerColumn(viewer, SWT.NONE);
layout.setColumnData(column.getColumn(), new ColumnWeightData(10, false));
column.getColumn().setText(Messages.DropinsPluginDialog_6);
column = new TableViewerColumn(viewer, SWT.NONE);
layout.setColumnData(column.getColumn(), new ColumnWeightData(10, false));
column.getColumn().setText(Messages.DropinsPluginDialog_14);
DropinsPluginHandler handler = new DropinsPluginHandler();
viewer.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
try {
return handler.getInstalledPlugins().toArray();
} catch (IOException ex) {
// $NON-NLS-1$
Logger.logError("Error getting installed plug-in", ex);
}
return new Object[0];
}
});
class LabelCellProvider extends LabelProvider implements ITableLabelProvider {
@Override
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
@Override
public String getColumnText(Object element, int columnIndex) {
if (element instanceof Bundle) {
Bundle bundle = (Bundle) element;
switch(columnIndex) {
case 0:
// $NON-NLS-1$
return bundle.getHeaders().get("Bundle-Name");
case 1:
return bundle.getVersion().toString();
case 2:
return bundle.getSymbolicName();
case 3:
// $NON-NLS-1$
return bundle.getHeaders().get("Bundle-Vendor");
case 4:
try {
File file = handler.getDropinsBundleFile(bundle);
return file == null ? Messages.DropinsPluginDialog_13 : file.getParentFile().getPath();
} catch (IOException ex) {
return Messages.DropinsPluginDialog_13;
}
default:
break;
}
}
return element.toString();
}
}
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
Bundle b1 = (Bundle) e1;
Bundle b2 = (Bundle) e2;
// $NON-NLS-1$ //$NON-NLS-2$
return b1.getHeaders().get("Bundle-Name").compareToIgnoreCase(b2.getHeaders().get("Bundle-Name"));
}
});
viewer.setLabelProvider(new LabelCellProvider());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
getButton(UNINSTALL).setEnabled(!event.getSelection().isEmpty());
}
});
// anything will do //$NON-NLS-1$
viewer.setInput("");
return area;
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project archi by archimatetool.
the class AppearancePreferencePage method createContents.
@Override
protected Control createContents(Composite parent) {
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
Composite client = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout(2, false);
layout.marginWidth = layout.marginHeight = 0;
client.setLayout(layout);
// Enable Theming
fUseThemes = new Button(client, SWT.CHECK);
fUseThemes.setText(Messages.AppearancePreferencePage_4);
fUseThemes.setLayoutData(createHorizontalGridData(2));
// Themes, if enabled
if (themeEngine != null) {
Label label = new Label(client, SWT.NULL);
label.setText(Messages.AppearancePreferencePage_1);
fThemeComboViewer = new ComboViewer(client, SWT.READ_ONLY);
fThemeComboViewer.getCombo().setLayoutData(createHorizontalGridData(1));
fThemeComboViewer.setContentProvider(new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@Override
public void dispose() {
}
@Override
public Object[] getElements(Object inputElement) {
return (Object[]) inputElement;
}
});
fThemeComboViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((ITheme) element).getLabel();
}
});
fThemeComboViewer.setComparator(new ViewerComparator());
}
// Use Round Tabs
fUseRoundTabsButton = new Button(client, SWT.CHECK);
fUseRoundTabsButton.setText(Messages.AppearancePreferencePage_3);
fUseRoundTabsButton.setLayoutData(createHorizontalGridData(2));
// Show Status Line
fShowStatusLineButton = new Button(client, SWT.CHECK);
fShowStatusLineButton.setText(Messages.AppearancePreferencePage_2);
fShowStatusLineButton.setLayoutData(createHorizontalGridData(2));
setValues();
if (themeEngine != null) {
fThemeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ITheme theme = (ITheme) ((IStructuredSelection) fThemeComboViewer.getSelection()).getFirstElement();
setTheme(theme, false);
}
});
}
return client;
}
Aggregations