use of org.eclipse.jface.viewers.DoubleClickEvent in project knime-core by knime.
the class AbstractRepositoryView method hookDoubleClickAction.
private void hookDoubleClickAction() {
m_viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(final DoubleClickEvent event) {
Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (o instanceof NodeTemplate) {
NodeTemplate tmplt = (NodeTemplate) o;
NodeFactory<? extends NodeModel> nodeFact;
try {
nodeFact = tmplt.createFactoryInstance();
} catch (Exception e) {
LOGGER.error("Unable to instantiate the selected node " + tmplt.getFactory().getName(), e);
return;
}
boolean added = NodeProvider.INSTANCE.addNode(nodeFact);
if (added) {
NodeUsageRegistry.addNode(tmplt);
}
} else if (o instanceof MetaNodeTemplate) {
MetaNodeTemplate mnt = (MetaNodeTemplate) o;
NodeID metaNode = mnt.getManager().getID();
NodeProvider.INSTANCE.addMetaNode(WorkflowManager.META_NODE_ROOT, metaNode);
} else if (o instanceof Category) {
m_viewer.setExpandedState(o, !m_viewer.getExpandedState(o));
}
}
});
}
use of org.eclipse.jface.viewers.DoubleClickEvent in project knime-core by knime.
the class CredentialVariablesDialog method createDialogArea.
/**
* Creates and returns the contents of this dialog with or without edit,
* add and remove buttons.
* @param parent the parent composite
* @param hideButtons true to hide the button bar, false to show it
* @return the control
* @since 2.6
*/
public Control createDialogArea(final Composite parent, final boolean hideButtons) {
parent.getShell().setText("Workflow Credentials...");
Composite composite = new Composite(parent, SWT.NONE);
if (m_workflowName != null) {
Label label = new Label(composite, SWT.NONE);
label.setText("Edit Credentials for Workflow '" + m_workflowName + "'.");
}
composite.setLayout(new GridLayout(1, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
// first row (new composite):
Composite tableAndBtnsComp = new Composite(composite, SWT.NONE);
tableAndBtnsComp.setLayoutData(new GridData(GridData.FILL_BOTH));
tableAndBtnsComp.setLayout(new GridLayout(2, false));
// first column: table
Composite tableComp = new Composite(tableAndBtnsComp, SWT.NONE);
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.grabExcessHorizontalSpace = true;
tableComp.setLayout(new FillLayout());
tableComp.setLayoutData(gridData);
m_table = new CredentialVariableTable(tableComp);
for (Credentials cred : m_credentials) {
m_table.add(cred);
}
m_table.getViewer().refresh();
m_table.getViewer().addDoubleClickListener(new IDoubleClickListener() {
/**
* {@inheritDoc}
*/
@Override
public void doubleClick(final DoubleClickEvent event) {
Table table = m_table.getViewer().getTable();
int index = table.getSelectionIndex();
// we only get a double-click event for existing items
Credentials var = m_table.get(index);
editCredentials(var, index);
}
});
if (!hideButtons) {
// second column: 3 buttons
Composite btnsComp = new Composite(tableAndBtnsComp, SWT.NONE);
btnsComp.setLayout(new GridLayout(1, false));
gridData = new GridData();
gridData.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
btnsComp.setLayoutData(gridData);
m_addVarBtn = new Button(btnsComp, SWT.PUSH);
m_addVarBtn.setText("Add");
m_addVarBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent arg0) {
widgetSelected(arg0);
}
@Override
public void widgetSelected(final SelectionEvent arg0) {
addCredential();
}
});
gridData = new GridData();
gridData.widthHint = 80;
gridData.heightHint = 20;
m_addVarBtn.setLayoutData(gridData);
m_editVarBtn = new Button(btnsComp, SWT.PUSH);
m_editVarBtn.setText("Edit");
m_editVarBtn.setLayoutData(gridData);
m_editVarBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent arg0) {
widgetSelected(arg0);
}
@Override
public void widgetSelected(final SelectionEvent arg0) {
int selectionIdx = m_table.getViewer().getTable().getSelectionIndex();
if (selectionIdx < 0) {
MessageDialog.openWarning(getShell(), "Empty selection", "Please select the credential you want to edit.");
return;
}
Credentials selectedCred = m_table.get(selectionIdx);
editCredentials(selectedCred, selectionIdx);
}
});
m_removeVarBtn = new Button(btnsComp, SWT.PUSH);
m_removeVarBtn.setText("Remove");
m_removeVarBtn.setLayoutData(gridData);
m_removeVarBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent arg0) {
widgetSelected(arg0);
}
@Override
public void widgetSelected(final SelectionEvent arg0) {
int idx = m_table.getViewer().getTable().getSelectionIndex();
if (idx < 0) {
MessageDialog.openWarning(getShell(), "Empty selection", "Please select the parameter you want to remove.");
return;
}
Credentials cred = (Credentials) ((IStructuredSelection) m_table.getViewer().getSelection()).getFirstElement();
removeCredential(cred);
}
});
}
return composite;
}
use of org.eclipse.jface.viewers.DoubleClickEvent in project knime-core by knime.
the class WorkflowVariablesDialog method createDialogArea.
/**
* Creates and returns the contents of this dialog with or without edit,
* add and remove buttons.
* @param parent the parent composite
* @param hideButtons true to hide the button bar, false to show it
* @return the control
* @since 2.6
*/
public Control createDialogArea(final Composite parent, final boolean hideButtons) {
m_buttonsHidden = hideButtons;
parent.getShell().setText("Workflow Variable Administration");
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(1, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
// composite contains:
// first row (new composite):
Composite tableAndBtnsComp = new Composite(composite, SWT.NONE);
tableAndBtnsComp.setLayoutData(new GridData(GridData.FILL_BOTH));
tableAndBtnsComp.setLayout(new GridLayout(2, false));
// first column: table
Composite tableComp = new Composite(tableAndBtnsComp, SWT.NONE);
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.grabExcessHorizontalSpace = true;
tableComp.setLayout(new FillLayout());
tableComp.setLayoutData(gridData);
m_table = new WorkflowVariableTable(tableComp);
for (FlowVariable var : m_workflow.getWorkflowVariables()) {
m_table.add(var);
}
m_table.getViewer().refresh();
m_table.getViewer().addDoubleClickListener(new IDoubleClickListener() {
/**
* {@inheritDoc}
*/
@Override
public void doubleClick(final DoubleClickEvent event) {
Table table = m_table.getViewer().getTable();
int index = table.getSelectionIndex();
// we only get a double-click event for existing items
FlowVariable var = m_table.get(index);
editWorkflowVariable(var, index);
}
});
if (!hideButtons) {
// second column: 3 buttons
Composite btnsComp = new Composite(tableAndBtnsComp, SWT.NONE);
btnsComp.setLayout(new GridLayout(1, false));
gridData = new GridData();
gridData.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
btnsComp.setLayoutData(gridData);
m_addVarBtn = new Button(btnsComp, SWT.PUSH);
m_addVarBtn.setText("Add");
m_addVarBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent arg0) {
widgetSelected(arg0);
}
@Override
public void widgetSelected(final SelectionEvent arg0) {
addWorkflowVariable();
}
});
gridData = new GridData();
gridData.widthHint = 80;
m_addVarBtn.setLayoutData(gridData);
m_editVarBtn = new Button(btnsComp, SWT.PUSH);
m_editVarBtn.setText("Edit");
m_editVarBtn.setLayoutData(gridData);
m_editVarBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent arg0) {
widgetSelected(arg0);
}
@Override
public void widgetSelected(final SelectionEvent arg0) {
int selectionIdx = m_table.getViewer().getTable().getSelectionIndex();
if (selectionIdx < 0) {
MessageDialog.openWarning(getShell(), "Empty selection", "Please select the parameter you want to edit.");
return;
}
FlowVariable selectedVar = m_table.get(selectionIdx);
editWorkflowVariable(selectedVar, selectionIdx);
}
});
m_removeVarBtn = new Button(btnsComp, SWT.PUSH);
m_removeVarBtn.setText("Remove");
m_removeVarBtn.setLayoutData(gridData);
m_removeVarBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent arg0) {
widgetSelected(arg0);
}
@Override
public void widgetSelected(final SelectionEvent arg0) {
int idx = m_table.getViewer().getTable().getSelectionIndex();
if (idx < 0) {
MessageDialog.openWarning(getShell(), "Empty selection", "Please select the parameter you want to remove.");
return;
}
FlowVariable selectedParam = (FlowVariable) ((IStructuredSelection) m_table.getViewer().getSelection()).getFirstElement();
removeWorkflowVariable(selectedParam);
}
});
}
// second row: the warning label (in case the edit buttons are disabled
// due to executing workflow...)
m_warningLabel = new Label(composite, SWT.NONE);
m_warningLabel.setText("");
m_warningLabel.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
m_warningLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
return composite;
}
use of org.eclipse.jface.viewers.DoubleClickEvent in project yamcs-studio by yamcs.
the class OPIFontDialog method createPredefinedFontsTableViewer.
/**
* Creates and configures a {@link TableViewer}.
*
* @param parent
* The parent for the table
* @return The {@link TableViewer}
*/
private TableViewer createPredefinedFontsTableViewer(final Composite parent) {
TableViewer viewer = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.SINGLE);
viewer.setContentProvider(new BaseWorkbenchContentProvider() {
@Override
public Object[] getElements(final Object element) {
return (Object[]) element;
}
});
viewer.setLabelProvider(new LabelProvider());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
refreshGUIOnSelection();
}
});
viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
MenuManager menuManager = new MenuManager();
menuManager.add(new ReloadFontFileAction());
viewer.getTable().setMenu(menuManager.createContextMenu(viewer.getTable()));
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
okPressed();
}
});
return viewer;
}
use of org.eclipse.jface.viewers.DoubleClickEvent in project yamcs-studio by yamcs.
the class OPIColorDialog method createPredefinedColorsTableViewer.
/**
* Creates and configures a {@link TableViewer}.
*
* @param parent
* The parent for the table
* @return The {@link TableViewer}
*/
private TableViewer createPredefinedColorsTableViewer(final Composite parent) {
TableViewer viewer = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.SINGLE);
viewer.setContentProvider(new BaseWorkbenchContentProvider() {
@Override
public Object[] getElements(final Object element) {
return (Object[]) element;
}
});
viewer.setLabelProvider(new WorkbenchLabelProvider());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
refreshGUIOnSelection();
}
});
viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
MenuManager menuManager = new MenuManager();
menuManager.add(new ReloadColorFileAction());
viewer.getTable().setMenu(menuManager.createContextMenu(viewer.getTable()));
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
okPressed();
}
});
return viewer;
}
Aggregations