Search in sources :

Example 61 with IDoubleClickListener

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;
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Credentials(org.knime.core.node.workflow.Credentials) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 62 with IDoubleClickListener

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;
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FlowVariable(org.knime.core.node.workflow.FlowVariable) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 63 with IDoubleClickListener

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;
}
Also used : BaseWorkbenchContentProvider(org.eclipse.ui.model.BaseWorkbenchContentProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 64 with IDoubleClickListener

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;
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) BaseWorkbenchContentProvider(org.eclipse.ui.model.BaseWorkbenchContentProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 65 with IDoubleClickListener

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;
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent)

Aggregations

DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)67 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)67 GridData (org.eclipse.swt.layout.GridData)40 TableViewer (org.eclipse.jface.viewers.TableViewer)37 Composite (org.eclipse.swt.widgets.Composite)33 SelectionEvent (org.eclipse.swt.events.SelectionEvent)32 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)28 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)25 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)25 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)23 GridLayout (org.eclipse.swt.layout.GridLayout)21 Table (org.eclipse.swt.widgets.Table)16 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)15 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)13 Button (org.eclipse.swt.widgets.Button)13 Label (org.eclipse.swt.widgets.Label)13 TableColumn (org.eclipse.swt.widgets.TableColumn)13 ISelection (org.eclipse.jface.viewers.ISelection)11 TreeViewer (org.eclipse.jface.viewers.TreeViewer)11 FillLayout (org.eclipse.swt.layout.FillLayout)10