Search in sources :

Example 1 with SelectionChangedEvent

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

the class CpuDumpEditor method createHotSpotsPage.

/**
     * Creates the hot spots page.
     */
private void createHotSpotsPage() {
    Composite panel = new Composite(getContainer(), SWT.NONE);
    panel.setLayout(new FillLayout());
    final HotSpotsFilteredTree hotSpotsFilteredTree = new HotSpotsFilteredTree(panel, getEditorSite().getActionBars());
    TreeViewer hotSpotsViewer = hotSpotsFilteredTree.getViewer();
    hotSpotsViewer.setContentProvider(new AbstractContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof ICpuModel) {
                return ((ICpuModel) inputElement).getHotSpotRoots();
            }
            return new Object[0];
        }
    });
    hotSpotsViewer.setLabelProvider(new HotSpotsLabelProvider(hotSpotsFilteredTree));
    hotSpotsViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            hotSpotsFilteredTree.updateStatusLine((IStructuredSelection) event.getSelection());
        }
    });
    hotSpotsViewer.setUseHashlookup(true);
    hotSpotsViewer.setInput(cpuModel);
    hotSpotsFilteredTree.sortColumn(hotSpotsViewer.getTree().getColumn(1));
    int page = addPage(panel);
    trees.put(hotSpotsFilteredTree, page);
    setPageText(page, Messages.hotSpotsPageLabel);
    setPageImage(page, getHotSpotsImage());
}
Also used : Composite(org.eclipse.swt.widgets.Composite) HotSpotsFilteredTree(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.HotSpotsFilteredTree) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) HotSpotsLabelProvider(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.HotSpotsLabelProvider) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICpuModel(org.talend.designer.runtime.visualization.internal.core.cpu.ICpuModel) AbstractContentProvider(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.AbstractContentProvider)

Example 2 with SelectionChangedEvent

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

the class PaletteSettingPage method addTreeViewer.

/**
     * qwei Comment method "addViewer".
     * 
     * @param parent
     */
private void addTreeViewer(ThreeCompositesSashForm parent) {
    ViewerSorter sorter = new ViewerSorter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer,
             * java.lang.Object, java.lang.Object)
             */
        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            if (e1 instanceof ComponentPaletteItem && e2 instanceof ComponentPaletteItem) {
                return super.compare(viewer, ((IPaletteItem) e1).getLabel(), ((IPaletteItem) e2).getLabel());
            } else if (e1 instanceof FolderPaletteItem && e2 instanceof FolderPaletteItem) {
                return super.compare(viewer, ((IPaletteItem) e1).getLabel(), ((IPaletteItem) e2).getLabel());
            } else if (e1 instanceof ComponentPaletteItem && e2 instanceof FolderPaletteItem) {
                return 1;
            } else if (e1 instanceof FolderPaletteItem && e2 instanceof ComponentPaletteItem) {
                return -1;
            } else if (e1 instanceof RootPaletteItem && e2 instanceof RootPaletteItem) {
                if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_DI) {
                    // up
                    return -1;
                } else if (((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_DI) {
                    // down
                    return 1;
                } else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_CAMEL && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_MAPREDUCE) {
                    // up
                    return -1;
                } else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_MAPREDUCE && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_CAMEL) {
                    // down
                    return 1;
                } else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_MAPREDUCE && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_STORM) {
                    // up
                    return -1;
                } else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_STORM && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_MAPREDUCE) {
                    // down
                    return 1;
                } else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_CAMEL && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_STORM) {
                    // up
                    return -1;
                } else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_STORM && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_CAMEL) {
                    // down
                    return 1;
                }
            }
            return super.compare(viewer, e1, e2);
        }
    };
    List<IPaletteItem> input = getViewerInput();
    Composite leftComposite = parent.getLeftComposite();
    Label label = new Label(leftComposite, SWT.NONE);
    label.setText("Hide");
    hiddenViewer = new TreeViewer(leftComposite);
    hiddenViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    hiddenViewer.setContentProvider(new TalendPaletteTreeProvider());
    hiddenViewer.setLabelProvider(new TalendPaletteLabelProvider());
    hiddenViewer.addFilter(getFilterForComponent(false));
    hiddenViewer.setSorter(sorter);
    hiddenViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            displayComponentsButton.setEnabled(!event.getSelection().isEmpty());
        }
    });
    createButtons(parent.getMidComposite());
    Composite rightComposite = parent.getRightComposite();
    label = new Label(rightComposite, SWT.NONE);
    label.setText("Show");
    displayViewer = new TreeViewer(rightComposite);
    displayViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    displayViewer.setContentProvider(new TalendPaletteTreeProvider());
    displayViewer.setLabelProvider(new TalendPaletteLabelProvider());
    displayViewer.addFilter(getFilterForComponent(true));
    displayViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            hideCompnentsButton.setEnabled(!event.getSelection().isEmpty());
        }
    });
    displayViewer.setSorter(sorter);
    getComponentsFromProject(project);
    hiddenViewer.setInput(input);
    displayViewer.setInput(input);
    if (!input.isEmpty()) {
        displayViewer.expandToLevel(input.get(0), 1);
    }
    if (!input.isEmpty()) {
        hiddenViewer.expandToLevel(input.get(0), 1);
    }
}
Also used : ComponentPaletteItem(org.talend.repository.preference.palettesettings.ComponentPaletteItem) Composite(org.eclipse.swt.widgets.Composite) IPaletteItem(org.talend.core.ui.component.preference.provider.IPaletteItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) Label(org.eclipse.swt.widgets.Label) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FolderPaletteItem(org.talend.repository.preference.palettesettings.FolderPaletteItem) TalendPaletteTreeProvider(org.talend.core.ui.component.preference.provider.TalendPaletteTreeProvider) RootPaletteItem(org.talend.repository.preference.palettesettings.RootPaletteItem) GridData(org.eclipse.swt.layout.GridData) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TalendPaletteLabelProvider(org.talend.core.ui.component.preference.provider.TalendPaletteLabelProvider)

Example 3 with SelectionChangedEvent

use of org.eclipse.jface.viewers.SelectionChangedEvent 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)

Example 4 with SelectionChangedEvent

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

the class JobSettingsView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    // tabFactory = new HorizontalTabFactory();
    this.parent = parent;
    tabFactory.initComposite(parent, false);
    tabFactory.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            TalendPropertyTabDescriptor descriptor = (TalendPropertyTabDescriptor) selection.getFirstElement();
            if (descriptor == null) {
                return;
            }
            if (currentSelectedTab != null) {
                if ((!currentSelectedTab.getData().equals(descriptor.getData()) || currentSelectedTab.getData() != descriptor.getData() || currentSelectedTab.getCategory() != descriptor.getCategory())) {
                    for (Control curControl : tabFactory.getTabComposite().getChildren()) {
                        curControl.dispose();
                    }
                }
            }
            if (element == null || !element.equals(descriptor.getData()) || currentSelectedTab == null || currentSelectedTab.getCategory() != descriptor.getCategory() || selectedPrimary) {
                Object data = descriptor.getData();
                if (data instanceof Element) {
                    element = (Element) data;
                    currentSelectedTab = descriptor;
                    IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), element, descriptor.getCategory());
                } else if (data instanceof IRepositoryViewObject) {
                    IRepositoryViewObject viewObject = (IRepositoryViewObject) data;
                    IProcess process = getProcess(viewObject);
                    if (process != null && process instanceof Element && process.getId().equals(viewObject.getId()) && process.getVersion().equals(viewObject.getVersion())) {
                        data = process;
                    }
                    currentSelectedTab = descriptor;
                    IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), data, descriptor.getCategory());
                } else if (data instanceof IEditorPart) {
                    currentSelectedTab = descriptor;
                    IRepositoryViewObject repObj = retrieveBusiness((IEditorPart) data);
                    if (repObj != null) {
                        IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), repObj, descriptor.getCategory());
                    }
                } else {
                    currentSelectedTab = descriptor;
                    IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), null, descriptor.getCategory());
                }
                selectedPrimary = false;
            }
        }
    });
}
Also used : Control(org.eclipse.swt.widgets.Control) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Element(org.talend.core.model.process.Element) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) EmptyRepositoryObject(org.talend.core.model.repository.EmptyRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TalendPropertyTabDescriptor(org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor) IEditorPart(org.eclipse.ui.IEditorPart) IProcess(org.talend.core.model.process.IProcess)

Example 5 with SelectionChangedEvent

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

the class DeploymentComposite method addListeners.

private void addListeners() {
    groupIdCheckbox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (groupIdCheckbox.getSelection()) {
                groupIdText.setEnabled(true);
                groupIdText.setText(groupId);
            } else {
                groupIdText.setEnabled(false);
                groupIdText.setText(defaultGroupId);
                // remove key, so will be default groupId
                Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_GROUP_ID, null);
                getCommandStack().execute(cmd);
            }
        }
    });
    groupIdText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            String currentGroupId = groupIdText.getText();
            if (currentGroupId != null && !currentGroupId.trim().equals("")) {
                //$NON-NLS-1$
                groupIdText.setBackground(getBackground());
                //$NON-NLS-1$
                groupIdText.setToolTipText("");
                if (!defaultGroupId.equals(currentGroupId)) {
                    groupId = currentGroupId;
                } else {
                    currentGroupId = null;
                }
                Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_GROUP_ID, currentGroupId);
                getCommandStack().execute(cmd);
            } else {
                groupIdText.setBackground(COLOR_RED);
                //$NON-NLS-1$
                groupIdText.setToolTipText(Messages.getString("DeploymentComposite.valueWarning"));
            }
        }
    });
    versionCheckbox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (versionCheckbox.getSelection()) {
                versionText.setEnabled(true);
                versionText.setText(version);
            } else {
                versionText.setEnabled(false);
                versionText.setText(defaultVersion);
                // remove key, so will be default version
                Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_USER_VERSION, null);
                getCommandStack().execute(cmd);
            }
        }
    });
    versionText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            String currentVersion = versionText.getText();
            if (//$NON-NLS-1$
            currentVersion != null && !currentVersion.trim().equals("") && !MavenVersionUtils.isValidMavenVersion(currentVersion)) {
                //$NON-NLS-1$
                versionText.setToolTipText(Messages.getString("DeploymentComposite.valueWarning"));
                versionText.setBackground(COLOR_RED);
            } else {
                //$NON-NLS-1$
                versionText.setToolTipText("");
                versionText.setBackground(getBackground());
                if (!defaultVersion.equals(currentVersion)) {
                    version = currentVersion;
                } else {
                    currentVersion = null;
                }
                // if empty, remove it from job, else will set the new value
                Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_USER_VERSION, currentVersion);
                getCommandStack().execute(cmd);
            }
        }
    });
    buildTypeCombo.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            final ISelection selection = event.getSelection();
            if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
                final Object elem = ((IStructuredSelection) selection).getFirstElement();
                if (elem instanceof BuildType) {
                    Command cmd = new MavenDeploymentValueChangeCommand(process, TalendProcessArgumentConstant.ARG_BUILD_TYPE, ((BuildType) elem).getName());
                    getCommandStack().execute(cmd);
                }
            }
        }
    });
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ModifyEvent(org.eclipse.swt.events.ModifyEvent) MavenDeploymentValueChangeCommand(org.talend.designer.core.ui.editor.cmd.MavenDeploymentValueChangeCommand) Command(org.eclipse.gef.commands.Command) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) MavenDeploymentValueChangeCommand(org.talend.designer.core.ui.editor.cmd.MavenDeploymentValueChangeCommand) BuildType(org.talend.core.runtime.repository.build.BuildType) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Aggregations

SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)802 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)754 GridData (org.eclipse.swt.layout.GridData)417 Composite (org.eclipse.swt.widgets.Composite)332 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)303 GridLayout (org.eclipse.swt.layout.GridLayout)245 SelectionEvent (org.eclipse.swt.events.SelectionEvent)187 Label (org.eclipse.swt.widgets.Label)158 TableViewer (org.eclipse.jface.viewers.TableViewer)153 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)147 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)140 Button (org.eclipse.swt.widgets.Button)140 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)126 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)121 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)120 IPropertiesEditionEvent (org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)116 PropertiesEditionEvent (org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent)116 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)116 Table (org.eclipse.swt.widgets.Table)93 ISelection (org.eclipse.jface.viewers.ISelection)84