Search in sources :

Example 6 with DoubleClickEvent

use of org.eclipse.jface.viewers.DoubleClickEvent in project azure-tools-for-java by Microsoft.

the class BlobExplorerFileEditor method createTable.

private Table createTable(Composite parent) {
    blobListTable = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION);
    blobListTable.setHeaderVisible(true);
    blobListTable.setLinesVisible(true);
    GridData gridData = new GridData();
    //        gridData.heightHint = 75;
    gridData.horizontalAlignment = SWT.FILL;
    gridData.verticalAlignment = SWT.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.grabExcessHorizontalSpace = true;
    GridLayout gridLayoutTable = new GridLayout();
    gridLayoutTable.numColumns = 6;
    gridLayoutTable.marginRight = 0;
    blobListTable.setLayout(gridLayoutTable);
    blobListTable.setLayoutData(gridData);
    for (int i = 0; i < 6; i++) {
        new TableColumn(blobListTable, SWT.FILL);
    }
    blobListTable.getColumn(0).setText("");
    blobListTable.getColumn(1).setText("Name");
    blobListTable.getColumn(2).setText("Size");
    blobListTable.getColumn(3).setText("Last Modified (UTC)");
    blobListTable.getColumn(4).setText("Content Type");
    blobListTable.getColumn(5).setText("URL");
    blobListTable.getColumn(0).setWidth(25);
    blobListTable.getColumn(1).setWidth(280);
    blobListTable.getColumn(2).setWidth(60);
    blobListTable.getColumn(3).setWidth(110);
    blobListTable.getColumn(4).setWidth(140);
    blobListTable.getColumn(5).setWidth(250);
    tableViewer = new TableViewer(blobListTable);
    tableViewer.setUseHashlookup(true);
    tableViewer.setContentProvider(new BlobListContentProvider());
    tableViewer.setLabelProvider(new BlobListLabelProvider());
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
            boolean directorySelected = tableViewer.getTable().getSelectionIndex() > -1 && isDirectorySelected();
            deleteButton.setEnabled(!directorySelected);
            //                openButton.setEnabled(!directorySelected);
            saveAsButton.setEnabled(!directorySelected);
        }
    });
    tableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            tableSelection();
        }
    });
    fillGrid();
    return blobListTable;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableColumn(org.eclipse.swt.widgets.TableColumn) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 7 with DoubleClickEvent

use of org.eclipse.jface.viewers.DoubleClickEvent in project tdi-studio-se by Talend.

the class DatabaseTypeFilter method createDialogArea.

protected Control createDialogArea(Composite parent, String specifiedPId) {
    Composite container = (Composite) super.createDialogArea(parent);
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "before createDialogArea...");
    GridData data = (GridData) container.getLayoutData();
    data.minimumHeight = 400;
    data.heightHint = 400;
    data.minimumWidth = 500;
    data.widthHint = 500;
    container.setLayoutData(data);
    createFilterField(container);
    Composite viewContainer = new Composite(container, SWT.BORDER);
    viewContainer.setLayout(new GridLayout());
    viewContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
    repositoryTreeViewer = RepoCommonViewerProvider.NORMAL.createViewer(viewContainer, specifiedPId);
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "finshed createViewer");
    repositoryTreeViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
    addFilter(textFilter);
    if (dbSupportFilter != null) {
        addFilter(dbSupportFilter);
    }
    if (additionalFilters != null) {
        addFilter(additionalFilters);
    }
    ViewerFilter filter = typeProcessor.makeFilter();
    addFilter(filter);
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "finshed add Filters");
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "set input");
    repositoryTreeViewer.expandToLevel(2);
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "expandAll");
    final Label label = new Label(container, SWT.NONE);
    //$NON-NLS-1$
    label.setText(Messages.getString("RepositoryReviewDialog.label"));
    label.setForeground(new Color(null, 250, 0, 0));
    label.setVisible(false);
    // see feature 0003664: tRunJob: When opening the tree dialog to select the job target, it could be useful to
    // open it on previous selected job if exists
    selectNode();
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "selectNode");
    repositoryTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            boolean highlightOKButton = isSelectionValid(event);
            getButton(IDialogConstants.OK_ID).setEnabled(highlightOKButton);
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection != null && !selection.isEmpty()) {
                RepositoryNode node = (RepositoryNode) selection.getFirstElement();
                if (!highlightOKButton && node.getType() == ENodeType.REPOSITORY_ELEMENT && node.getObjectType().equals(ERepositoryObjectType.METADATA_VALIDATION_RULES)) {
                    label.setVisible(true);
                } else {
                    label.setVisible(false);
                }
            }
        }
    });
    repositoryTreeViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            if (getButton(IDialogConstants.OK_ID).isEnabled()) {
                okPressed();
            }
        }
    });
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "finished createDialogArea...");
    TimeMeasure.end(RepositoryReviewDialog.class.getSimpleName());
    TimeMeasure.display = false;
    TimeMeasure.displaySteps = false;
    TimeMeasure.measureActive = false;
    return container;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Color(org.eclipse.swt.graphics.Color) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) GridLayout(org.eclipse.swt.layout.GridLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData)

Example 8 with DoubleClickEvent

use of org.eclipse.jface.viewers.DoubleClickEvent in project tdi-studio-se by Talend.

the class JobVMArgumentsComposite method getTableControl.

/**
     * Returns this field editor's list control.
     * 
     * @param parent the parent control
     * @return the list control
     */
protected TableViewer getTableControl(Composite parent) {
    if (viewer == null) {
        Table table = createTable(parent);
        viewer = new TableViewer(table);
        viewer.setContentProvider(createContentProvider());
        viewer.setLabelProvider(createLabelProvider());
        table.setFont(parent.getFont());
        viewer.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                JobVMArgumentsComposite.this.selectionChanged();
            }
        });
        viewer.addDoubleClickListener(new IDoubleClickListener() {

            @Override
            public void doubleClick(DoubleClickEvent event) {
                editItem(event.getSelection());
            }
        });
    }
    // doLoadDefault();
    return viewer;
}
Also used : Table(org.eclipse.swt.widgets.Table) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 9 with DoubleClickEvent

use of org.eclipse.jface.viewers.DoubleClickEvent in project tdi-studio-se by Talend.

the class TnsEditorDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    TnsParser tnsparser = new TnsParser(tnsFile);
    treeViewer = new TreeViewer(parent);
    Tree tree = treeViewer.getTree();
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);
    GridData layoutData = new GridData(GridData.FILL_BOTH);
    layoutData.heightHint = 400;
    layoutData.widthHint = 300;
    tree.setLayoutData(layoutData);
    TreeColumn column1st = new TreeColumn(tree, SWT.NONE);
    //$NON-NLS-1$
    column1st.setText(Messages.getString("TnsEditorDialog.Service"));
    column1st.setWidth(200);
    TreeColumn column2nd = new TreeColumn(tree, SWT.NONE);
    //$NON-NLS-1$
    column2nd.setText(Messages.getString("TnsEditorDialog.Value"));
    column2nd.setWidth(200);
    treeViewer.setContentProvider(new TnsContentProvider());
    treeViewer.setLabelProvider(new TnsTableProvider());
    treeViewer.setInput(tnsparser.getTree());
    treeViewer.expandAll();
    treeViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            okPressed();
        }
    });
    return tree;
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) TreeColumn(org.eclipse.swt.widgets.TreeColumn) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) Tree(org.eclipse.swt.widgets.Tree) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent)

Example 10 with DoubleClickEvent

use of org.eclipse.jface.viewers.DoubleClickEvent in project tdi-studio-se by Talend.

the class ProcessVersionComposite method addSortListener.

/**
     * DOC Administrator Comment method "addSortListener".
     * 
     * @param table
     * @param column1
     * @param column2
     * @param column3
     */
private void addSortListener(final Table table, final TableColumn column1, final TableColumn column2, final TableColumn column3, final TableColumn column4) {
    Listener sortListener = new Listener() {

        private int direction = 1;

        @Override
        public void handleEvent(Event e) {
            final TableColumn column = (TableColumn) e.widget;
            if (column == table.getSortColumn()) {
                direction = -direction;
            }
            if (direction == 1) {
                table.setSortDirection(SWT.DOWN);
            } else {
                table.setSortDirection(SWT.UP);
            }
            table.setSortColumn(column);
            tableViewer.setSorter(new ViewerSorter() {

                int index = 0;

                @Override
                public void sort(Viewer viewer, Object[] elements) {
                    while (index < table.getColumns().length && table.getColumn(index) != column) {
                        index++;
                    }
                    super.sort(viewer, elements);
                }

                @Override
                public int compare(Viewer viewer, Object e1, Object e2) {
                    ITableLabelProvider labelProvider = (ITableLabelProvider) tableViewer.getLabelProvider();
                    String columnText = labelProvider.getColumnText(e1, index) != null ? labelProvider.getColumnText(e1, index) : //$NON-NLS-1$
                    "";
                    String columnText2 = labelProvider.getColumnText(e2, index) != null ? labelProvider.getColumnText(e2, index) : //$NON-NLS-1$
                    "";
                    return getComparator().compare(columnText, columnText2) * direction;
                }
            });
        }
    };
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        /*
             * (non-Javadoc)
             * 
             * @seeorg.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.
             * SelectionChangedEvent)
             */
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ProcessVersionComposite.this.selection = event.getSelection();
            if (getParentWizard() != null) {
                ((WizardPage) getParentWizard()).setPageComplete(true);
            }
        }
    });
    column1.addListener(SWT.Selection, sortListener);
    column2.addListener(SWT.Selection, sortListener);
    column3.addListener(SWT.Selection, sortListener);
    column4.addListener(SWT.Selection, sortListener);
    table.setSortColumn(column1);
    table.setSortDirection(SWT.DOWN);
    tableViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            if (getParentWizard() == null) {
                ITreeContextualAction editPropertiesAction = getEditPropertiesAction(EditPropertiesAction.class);
                if (editPropertiesAction != null) {
                    editPropertiesAction.run();
                }
            }
        }
    });
}
Also used : IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) IMenuListener(org.eclipse.jface.action.IMenuListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Listener(org.eclipse.swt.widgets.Listener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) ITreeContextualAction(org.talend.commons.ui.swt.actions.ITreeContextualAction) TableColumn(org.eclipse.swt.widgets.TableColumn) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) EditPropertiesAction(org.talend.repository.ui.actions.EditPropertiesAction) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryObject(org.talend.core.model.repository.IRepositoryObject)

Aggregations

DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)49 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)49 TableViewer (org.eclipse.jface.viewers.TableViewer)33 SelectionEvent (org.eclipse.swt.events.SelectionEvent)29 GridData (org.eclipse.swt.layout.GridData)28 Composite (org.eclipse.swt.widgets.Composite)28 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)23 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)16 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)16 GridLayout (org.eclipse.swt.layout.GridLayout)16 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)14 Table (org.eclipse.swt.widgets.Table)13 TableColumn (org.eclipse.swt.widgets.TableColumn)12 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)11 Label (org.eclipse.swt.widgets.Label)11 Button (org.eclipse.swt.widgets.Button)10 ISelection (org.eclipse.jface.viewers.ISelection)8 FillLayout (org.eclipse.swt.layout.FillLayout)8 Event (org.eclipse.swt.widgets.Event)8