Search in sources :

Example 1 with EditPropertiesAction

use of org.talend.repository.ui.actions.EditPropertiesAction 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

IMenuListener (org.eclipse.jface.action.IMenuListener)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ILabelProviderListener (org.eclipse.jface.viewers.ILabelProviderListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 ITableLabelProvider (org.eclipse.jface.viewers.ITableLabelProvider)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerSorter (org.eclipse.jface.viewers.ViewerSorter)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1 ITreeContextualAction (org.talend.commons.ui.swt.actions.ITreeContextualAction)1 IRepositoryObject (org.talend.core.model.repository.IRepositoryObject)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 EditPropertiesAction (org.talend.repository.ui.actions.EditPropertiesAction)1