use of org.eclipse.jface.viewers.IDoubleClickListener 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.IDoubleClickListener 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.IDoubleClickListener 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.IDoubleClickListener 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;
}
use of org.eclipse.jface.viewers.IDoubleClickListener in project yamcs-studio by yamcs.
the class PropertiesSelectDialog method createPropertiesViewer.
private ListViewer createPropertiesViewer(Composite parent) {
final ListViewer viewer = new ListViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.MULTI);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new PropertyListLableProvider());
viewer.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@SuppressWarnings("unchecked")
@Override
public void selectionChanged(SelectionChangedEvent event) {
selectedProps = ((StructuredSelection) viewer.getSelection()).toList();
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
okPressed();
}
});
return viewer;
}
Aggregations