use of org.eclipse.jface.viewers.DoubleClickEvent in project knime-core by knime.
the class TreeSelectionControl method createTreeControl.
public Control createTreeControl(final Composite parent) {
Composite overall = new Composite(parent, SWT.NONE);
GridData fillBoth = new GridData(GridData.FILL_BOTH);
overall.setLayoutData(fillBoth);
overall.setLayout(new GridLayout(1, true));
if (m_message != null && !m_message.isEmpty()) {
createMessagePanel(overall);
}
m_treeViewer = new TreeViewer(overall, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FILL);
m_treeViewer.getTree().setLayoutData(fillBoth);
createErrorPanel(overall);
if (m_contentProvider != null) {
m_treeViewer.setContentProvider(m_contentProvider);
}
if (m_labelProvider != null) {
m_treeViewer.setLabelProvider(m_labelProvider);
}
if (m_comparator != null) {
m_treeViewer.setComparator(m_comparator);
}
m_treeViewer.setInput(m_root);
if (m_initialSelection != null) {
m_treeViewer.setSelection(m_initialSelection, true);
if (m_initialSelection instanceof StructuredSelection) {
if (((StructuredSelection) m_initialSelection).size() == 1) {
m_treeViewer.expandToLevel(((StructuredSelection) m_initialSelection).getFirstElement(), 1);
}
}
treeSelectionChanged(getSelectedTreeObject());
}
m_treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
Object sel = getSelectedTreeObject();
boolean v = treeSelectionChanged(sel);
if (m_changeListener != null) {
m_changeListener.treeSelectionChanged(sel, v);
}
}
});
m_treeViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(final DoubleClickEvent event) {
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1) {
Object selectionObj = ((IStructuredSelection) selection).getFirstElement();
m_treeViewer.setExpandedState(selectionObj, !m_treeViewer.getExpandedState(selectionObj));
}
}
});
return overall;
}
use of org.eclipse.jface.viewers.DoubleClickEvent in project yamcs-studio by yamcs.
the class AddParameterPage method createControl.
@Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
setControl(composite);
GridLayout gl = new GridLayout();
gl.marginHeight = 0;
gl.marginWidth = 0;
gl.numColumns = 2;
gl.makeColumnsEqualWidth = false;
composite.setLayout(gl);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite tableWrapper1 = new Composite(composite, SWT.NONE);
contentProvider = new ParameterContentProvider();
trcl = new TreeColumnLayout();
tableWrapper1.setLayoutData(new GridData(GridData.FILL_BOTH));
tableWrapper1.setLayout(trcl);
namespaceTable = new TreeViewer(tableWrapper1, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
namespaceTable.getTree().setHeaderVisible(true);
namespaceTable.getTree().setLinesVisible(true);
// column container
TreeViewerColumn pathColumn = new TreeViewerColumn(namespaceTable, SWT.NONE);
pathColumn.getColumn().setText(COL_NAMESPACE);
pathColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
String namespace = (String) element;
return namespace;
}
});
trcl.setColumnData(pathColumn.getColumn(), new ColumnPixelData(COLUMN_WIDTH));
namespaceTable.addSelectionChangedListener(evt -> {
IStructuredSelection sel = (IStructuredSelection) evt.getSelection();
if (sel.isEmpty()) {
contentProvider.setNamespace(null);
return;
}
contentProvider.setNamespace((String) sel.getFirstElement());
});
namespaceTable.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection sel = new IStructuredSelection() {
@Override
public boolean isEmpty() {
return false;
}
@Override
public List toList() {
return Arrays.asList(contentProvider.getElements(event));
}
@Override
public Object[] toArray() {
return contentProvider.getElements(event);
}
@Override
public int size() {
return contentProvider.getElements(event).length;
}
@Override
public Iterator iterator() {
return Arrays.asList(contentProvider.getElements(event)).iterator();
}
@Override
public Object getFirstElement() {
return null;
}
};
parameterTable.setSelection(sel);
}
});
namespaceTable.setContentProvider(new NamespaceContentProvider());
namespaceTable.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
String n1 = (String) o1;
String n2 = (String) o2;
return n1.compareTo(n2);
}
});
Composite tableWrapper2 = new Composite(composite, SWT.NONE);
tcl = new TableColumnLayout();
tableWrapper2.setLayoutData(new GridData(GridData.FILL_BOTH));
tableWrapper2.setLayout(tcl);
parameterTable = new TableViewer(tableWrapper2, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
parameterTable.getTable().setHeaderVisible(true);
parameterTable.getTable().setLinesVisible(true);
TableViewerColumn nameColumn = new TableViewerColumn(parameterTable, SWT.NONE);
nameColumn.getColumn().setText(COL_NAME);
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterInfo obj = (ParameterInfo) element;
return obj.getQualifiedName();
}
});
tcl.setColumnData(nameColumn.getColumn(), new ColumnPixelData(COLUMN_WIDTH));
parameterTable.addSelectionChangedListener(evt -> {
IStructuredSelection sel = (IStructuredSelection) evt.getSelection();
if (sel.isEmpty()) {
setParameter(new ArrayList<>());
return;
}
List<ParameterInfo> parameters = new ArrayList<>();
for (Object obj : sel.toArray()) {
parameters.add((ParameterInfo) obj);
}
setParameter(parameters);
setPageComplete(true);
});
parameterTable.setContentProvider(contentProvider);
parameterTable.setInput(contentProvider);
ParameterCatalogue.getInstance().getMetaParameters().forEach(pmtr -> {
for (NamedObjectId alias : pmtr.getAliasList()) {
String namespace = alias.getNamespace();
if (!namespace.startsWith("/"))
return;
if (!parameterInfos.containsKey(namespace)) {
parameterInfos.put(namespace, new ArrayList<>());
}
parameterInfos.get(namespace).add(pmtr);
String parentns = namespace.substring(0, namespace.lastIndexOf("/"));
while (!parentns.isEmpty()) {
if (!parameterInfos.containsKey(parentns)) {
parameterInfos.put(parentns, new ArrayList<>());
}
parentns = parentns.substring(0, parentns.lastIndexOf("/"));
}
}
});
namespaceTable.setInput(parameterInfos.keySet());
parameterTable.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
ParameterInfo n1 = (ParameterInfo) o1;
ParameterInfo n2 = (ParameterInfo) o2;
return n1.getQualifiedName().compareTo(n2.getQualifiedName());
}
});
}
use of org.eclipse.jface.viewers.DoubleClickEvent in project yamcs-studio by yamcs.
the class ResourceSelectionGroup method createTreeViewer.
/**
* Returns a new drill down viewer for this dialog.
*
* @param filters
* @param heightHint
* height hint for the drill down composite
*/
protected void createTreeViewer(final String[] filters, final int heightHint) {
// Create drill down.
DrillDownComposite drillDown = new DrillDownComposite(this, SWT.BORDER);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.widthHint = SIZING_SELECTION_PANE_WIDTH;
gridData.heightHint = heightHint;
drillDown.setLayoutData(gridData);
// Create tree viewer inside drill down.
_treeViewer = new TreeViewer(drillDown, SWT.NONE);
drillDown.setChildTree(_treeViewer);
WorkspaceResourceContentProvider contentProvider = new WorkspaceResourceContentProvider(filters);
contentProvider.showClosedProjects(_showClosedProjects);
_treeViewer.setContentProvider(contentProvider);
_treeViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
_treeViewer.setSorter(new ViewerSorter());
_treeViewer.setUseHashlookup(true);
_treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection == null) {
containerSelectionChanged(null);
} else {
containerSelectionChanged((IResource) selection.getFirstElement());
}
if (_newFolderAction != null) {
_newFolderAction.setEnabled(selection != null);
}
}
});
_treeViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(final DoubleClickEvent event) {
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection) {
Object item = ((IStructuredSelection) selection).getFirstElement();
if (item == null) {
return;
}
if (_treeViewer.getExpandedState(item)) {
_treeViewer.collapseToLevel(item, 1);
} else {
_treeViewer.expandToLevel(item, 1);
}
}
}
});
// This has to be done after the viewer has been laid out
_treeViewer.setInput(ResourcesPlugin.getWorkspace());
this.addNewContainerActions(drillDown.getToolBarManager());
this.addPopupMenu(_treeViewer);
this.setDefaultSelection(_treeViewer);
}
use of org.eclipse.jface.viewers.DoubleClickEvent in project yamcs-studio by yamcs.
the class RulesInputDialog method createRulsListViewer.
/**
* Creates and configures a {@link TableViewer}.
*
* @param parent
* The parent for the table
* @return The {@link TableViewer}
*/
private ListViewer createRulsListViewer(final Composite parent) {
final ListViewer viewer = new ListViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.SINGLE);
viewer.setContentProvider(new BaseWorkbenchContentProvider() {
@SuppressWarnings("unchecked")
@Override
public Object[] getElements(final Object element) {
return (((List<RuleData>) element).toArray());
}
});
viewer.setLabelProvider(new WorkbenchLabelProvider());
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
invokeRuleDataDialog();
}
});
viewer.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
return viewer;
}
use of org.eclipse.jface.viewers.DoubleClickEvent in project cubrid-manager by CUBRID.
the class TableEditorPart method createFkIndexTabItem.
/**
* Create foreign key/Index tab item.
*
* @param tabFolder the object of TabFolder
*/
private void createFkIndexTabItem(final TabFolder tabFolder) {
final TabItem foreignKeyTabItem = new TabItem(tabFolder, SWT.NONE);
foreignKeyTabItem.setText(Messages.infoIndexesTab);
final Composite composite = new Composite(tabFolder, SWT.NONE);
GridLayout gridLayout = new GridLayout();
composite.setLayout(gridLayout);
foreignKeyTabItem.setControl(composite);
// create the fk table viewer
final Label fkLabel = new Label(composite, SWT.NONE);
fkLabel.setText(Messages.lblFK);
fkTableView = new TableViewer(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
fkTable = fkTableView.getTable();
final GridData gdFkTable = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1);
fkTable.setLayoutData(gdFkTable);
fkTable.setLinesVisible(true);
fkTable.setHeaderVisible(true);
TableColumn tblCol = new TableColumn(fkTable, SWT.NONE);
tblCol.setWidth(100);
tblCol.setText(Messages.tblColumnFK);
tblCol = new TableColumn(fkTable, SWT.NONE);
tblCol.setWidth(119);
tblCol.setText(Messages.tblColumnColumnName);
tblCol = new TableColumn(fkTable, SWT.NONE);
tblCol.setWidth(93);
tblCol.setText(Messages.tblColumnForeignTable);
tblCol = new TableColumn(fkTable, SWT.NONE);
tblCol.setWidth(143);
tblCol.setText(Messages.tblColumnForeignColumnName);
tblCol = new TableColumn(fkTable, SWT.NONE);
tblCol.setWidth(84);
tblCol.setText(Messages.tblColumnUpdateRule);
tblCol = new TableColumn(fkTable, SWT.NONE);
tblCol.setWidth(86);
tblCol.setText(Messages.tblColumnDeleteRule);
tblCol = new TableColumn(fkTable, SWT.NONE);
tblCol.setWidth(100);
tblCol.setText(Messages.tblColumnCacheColumn);
FKTableViewerContentProvider fkContentProvider = new FKTableViewerContentProvider();
FKTableViewerLabelProvider fkLabelProvider = new FKTableViewerLabelProvider(database.getDatabaseInfo());
fkTableView.setContentProvider(fkContentProvider);
fkTableView.setLabelProvider(fkLabelProvider);
fkTableView.setInput(newSchemaInfo);
CommonUITool.hackForYosemite(fkTableView.getTable());
final Composite fkBtnComposite = new Composite(composite, SWT.NONE);
final GridData gdBtnComposite = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
fkBtnComposite.setLayoutData(gdBtnComposite);
gridLayout = new GridLayout();
gridLayout.numColumns = 3;
fkBtnComposite.setLayout(gridLayout);
final GridData gdFKBTN = new GridData(SWT.LEFT, SWT.CENTER, false, false);
final Button addFKBTN = new Button(fkBtnComposite, SWT.NONE);
addFKBTN.setLayoutData(gdFKBTN);
addFKBTN.setText(Messages.btnAddFk);
addFKBTN.addSelectionListener(new AddFkBtnListenerOnFkIndexTab());
final Button editFKBTN = new Button(fkBtnComposite, SWT.NONE);
editFKBTN.setLayoutData(gdFKBTN);
editFKBTN.setEnabled(false);
editFKBTN.setText(Messages.btnEditFk);
editFKBTN.addSelectionListener(new EditFkBtnListenerOnFkIndexTab());
final Button deleteFKBTN = new Button(fkBtnComposite, SWT.NONE);
deleteFKBTN.setLayoutData(gdFKBTN);
deleteFKBTN.setEnabled(false);
deleteFKBTN.setText(Messages.btnDelFk);
deleteFKBTN.addSelectionListener(new DelFkBtnListenerOnFkIndexTab());
fkTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (database == null || database.getDatabaseInfo() == null || newSchemaInfo == null) {
return;
}
TableItem[] items = fkTable.getSelection();
if (items == null || items.length == 0) {
deleteFKBTN.setEnabled(false);
editFKBTN.setEnabled(false);
} else {
deleteFKBTN.setEnabled(true);
editFKBTN.setEnabled(items.length == 1);
for (TableItem item : items) {
String fkName = item.getText(0);
List<SchemaInfo> superList = SuperClassUtil.getSuperClasses(database.getDatabaseInfo(), newSchemaInfo.getSuperClasses());
if (newSchemaInfo.isInSuperClasses(superList, fkName)) {
deleteFKBTN.setEnabled(false);
editFKBTN.setEnabled(false);
}
}
}
}
});
// create index table view
final Label indexLabel = new Label(composite, SWT.NONE);
indexLabel.setText(Messages.lblIndexes);
indexTableView = new TableViewer(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
indexTable = indexTableView.getTable();
indexTable.setLinesVisible(true);
indexTable.setHeaderVisible(true);
final GridData gdIndexTable = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1);
indexTable.setLayoutData(gdIndexTable);
CommonUITool.hackForYosemite(indexTable);
tblCol = new TableColumn(indexTable, SWT.NONE);
tblCol.setWidth(150);
tblCol.setText(Messages.tblColumnIndexName);
tblCol = new TableColumn(indexTable, SWT.NONE);
tblCol.setWidth(78);
tblCol.setText(Messages.tblColumnIndexType);
tblCol = new TableColumn(indexTable, SWT.NONE);
tblCol.setWidth(218);
tblCol.setText(Messages.tblColumnOnColumns);
tblCol = new TableColumn(indexTable, SWT.NONE);
tblCol.setWidth(282);
tblCol.setText(Messages.tblColumnIndexRule);
if (CompatibleUtil.isCommentSupports(database.getDatabaseInfo())) {
tblCol = new TableColumn(indexTable, SWT.NONE);
tblCol.setWidth(250);
tblCol.setText(Messages.tblColumnIndexMemo);
}
IndexTableViewerContentProvider indexContentProvider = new IndexTableViewerContentProvider();
IndexTableViewerLabelProvider indexLabelProvider = new IndexTableViewerLabelProvider();
indexTableView.setContentProvider(indexContentProvider);
indexTableView.setLabelProvider(indexLabelProvider);
indexTableView.setInput(newSchemaInfo);
indexTableView.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
StructuredSelection selected = (StructuredSelection) event.getSelection();
if (selected == null) {
return;
}
Constraint constraint = (Constraint) selected.getFirstElement();
openEditIndexDialog(constraint);
}
});
final Composite indexBtnComposite = new Composite(composite, SWT.NONE);
final GridData gdIndexBtnComposite = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
indexBtnComposite.setLayoutData(gdIndexBtnComposite);
gridLayout = new GridLayout();
gridLayout.numColumns = 3;
indexBtnComposite.setLayout(gridLayout);
final GridData gdIndexBTN = new GridData(SWT.LEFT, SWT.CENTER, false, false);
final Button addIndexBTN = new Button(indexBtnComposite, SWT.NONE);
addIndexBTN.setLayoutData(gdIndexBTN);
addIndexBTN.setText(Messages.btnAddIndex);
addIndexBTN.addSelectionListener(new AddIndexBtnListenerOnFkIndexTab());
final Button editIndexBTN = new Button(indexBtnComposite, SWT.NONE);
editIndexBTN.setLayoutData(gdIndexBTN);
editIndexBTN.setEnabled(false);
editIndexBTN.setText(Messages.btnEditIndex);
editIndexBTN.addSelectionListener(new EditIndexBtnListenerOnFkIndexTab());
final Button deleteIndexBTN = new Button(indexBtnComposite, SWT.NONE);
deleteIndexBTN.setLayoutData(gdIndexBTN);
deleteIndexBTN.setEnabled(false);
deleteIndexBTN.setText(Messages.btnDelIndex);
deleteIndexBTN.addSelectionListener(new DelIndexBtnListenerOnFkIndexTab());
indexTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
TableItem[] items = indexTable.getSelection();
if (items == null || items.length == 0) {
deleteIndexBTN.setEnabled(false);
editIndexBTN.setEnabled(false);
} else {
deleteIndexBTN.setEnabled(true);
editIndexBTN.setEnabled(items.length == 1);
}
}
});
}
Aggregations