Search in sources :

Example 16 with ISelectionChangedListener

use of org.eclipse.jface.viewers.ISelectionChangedListener 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 17 with ISelectionChangedListener

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

the class AbstractFilteredTree method addListeners.

/**
     * Adds the listeners.
     */
private void addListeners() {
    TreeViewer viewer = getViewer();
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            openAction.selectionChanged(event);
            copyAction.selectionChanged(event);
        }
    });
    viewer.addSelectionChangedListener(showCallersCalleesAction);
    viewer.addOpenListener(new IOpenListener() {

        @Override
        public void open(OpenEvent event) {
            openAction.run();
        }
    });
    Activator.getDefault().getPreferenceStore().addPropertyChangeListener(this);
}
Also used : IOpenListener(org.eclipse.jface.viewers.IOpenListener) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Example 18 with ISelectionChangedListener

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

the class MBeanSashForm method createSashFormControls.

/*
     * @see AbstractSashForm#createSashFormControls(SashForm, IActionBars)
     */
@Override
protected void createSashFormControls(SashForm sashForm, final IActionBars actionBars) {
    mBeanViewer = new MBeanFilteredTree(sashForm, section).getViewer();
    mBeanContentProvider = new MBeanContentProvider();
    mBeanViewer.setContentProvider(mBeanContentProvider);
    mBeanViewer.setLabelProvider(new MyDecoratingStyledCellLabelProvider());
    selectionChangedListener = new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection instanceof StructuredSelection) {
                mBeanTabFolder.selectionChanged((StructuredSelection) selection);
            }
        }
    };
    mBeanViewer.addSelectionChangedListener(selectionChangedListener);
    mBeanViewer.setInput(new Object());
    mBeanTabFolder = new MBeanTabFolder(sashForm, section);
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 19 with ISelectionChangedListener

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

the class LoginProjectPage method addListeners.

@Override
protected void addListeners() {
    super.addListeners();
    connectionsViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            try {
                resetProjectOperationSelectionWithBusyCursor(false);
                final ConnectionBean connection = getConnection();
                if (connection == null) {
                    checkErrors();
                    return;
                }
                // }
                if (connection == loginHelper.getCurrentSelectedConnBean()) {
                    return;
                } else {
                    loginHelper.setCurrentSelectedConnBean(connection);
                }
                cancelAndClearFetchJobs();
                errorManager.clearAllMessages();
                // beforeConnBean = connection;
                updateServerFields();
                // Validate data
                if (validateFields()) {
                    fillUIProjectListWithBusyCursor();
                    validateProject();
                }
                checkErrors();
                validateUpdate();
            } catch (PersistenceException e) {
                CommonExceptionHandler.process(e);
            } catch (JSONException e) {
                CommonExceptionHandler.process(e);
            }
        }
    });
    selectExistingProject.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (selectExistingProject.getSelection()) {
                // refreshProjectListAreaEnable(true);
                finishButtonAction = FINISH_ACTION_OPEN_PROJECT;
                // changeFinishButtonAction(finishButtonAction);
                try {
                    checkErrors();
                } catch (PersistenceException e1) {
                    CommonExceptionHandler.process(e1);
                }
            } else {
                refreshProjectListAreaEnable(false);
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // nothing need to do
        }
    });
    createSandBoxProject.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (createSandBoxProject.getSelection()) {
                finishButtonAction = FINISH_ACTION_CREATE_SANDBOX;
                // changeFinishButtonAction(finishButtonAction);
                refreshUIFinishButtonEnable(false);
                executeCreateSandBoxProject.setVisible(true);
                executeCreateSandBoxProject.forceFocus();
            } else {
                executeCreateSandBoxProject.setVisible(false);
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // nothing need to do
        }
    });
    importDemoProject.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (importDemoProject.getSelection()) {
                finishButtonAction = FINISH_ACTION_IMPORT_DEMO_PROJECT;
                // changeFinishButtonAction(finishButtonAction);
                refreshUIFinishButtonEnable(false);
                executeImportDemoProject.setVisible(true);
                executeImportDemoProject.forceFocus();
            } else {
                executeImportDemoProject.setVisible(false);
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // nothing need to do
        }
    });
    importLocalProject.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (importLocalProject.getSelection()) {
                finishButtonAction = FINISH_ACTION_IMPORT_LOCAL_PROJECT;
                // changeFinishButtonAction(finishButtonAction);
                refreshUIFinishButtonEnable(false);
                executeImportLocalProject.setVisible(true);
                executeImportLocalProject.forceFocus();
            } else {
                executeImportLocalProject.setVisible(false);
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // nothing need to do
        }
    });
    createNewProject.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (createNewProject.getSelection()) {
                //$NON-NLS-1$
                createNewProject.setText(Messages.getString("LoginProjectPage.createNewProject.beginCreate"));
                createNewProject.pack();
                FormData formData = (FormData) newProjectName.getLayoutData();
                formData.left = new FormAttachment(createNewProject, createNewProject.getSize().x + TAB_HORIZONTAL_PADDING_LEVEL_2, SWT.LEFT);
                newProjectName.setVisible(true);
                newProjectName.forceFocus();
                executeCreateNewProject.setVisible(true);
                finishButtonAction = FINISH_ACTION_CREATE_NEW_PROJECT;
                // changeFinishButtonAction(finishButtonAction);
                refreshUIFinishButtonEnable(false);
                validateNewProjectName();
            } else {
                //$NON-NLS-1$
                createNewProject.setText(Messages.getString("LoginProjectPage.createNewProject"));
                newProjectName.setVisible(false);
                executeCreateNewProject.setVisible(false);
                getErrorManager().clearCreateNewProjectError();
            // refreshUIFinishButtonEnable();
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // nothing need to do
        }
    });
    projectViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            finishButton.setEnabled(false);
            Project project = getProject();
            if (project != null) {
                // last used project will be saved when click finish
                // loginHelper.getPrefManipulator().setLastProject(project.getLabel());
                fetchLicenseIfNeeded(project);
                try {
                    fillUIBranches(project, false);
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    ExceptionHandler.process(e);
                }
                setRepositoryContextInContext();
            }
            finishButton.setEnabled(true);
        }
    });
    branchesViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
        // last used branch of project will be saved when click finish
        // String branch = getBranch();
        // if (branch == null) {
        // branch = SVNConstant.EMPTY;
        // }
        // Project project = getProject();
        // try {
        // loginHelper.getPrefManipulator().setLastSVNBranch(
        // new JSONObject(project.getEmfProject().getUrl()).getString("location"), project.getTechnicalLabel(),
        // branch);
        // } catch (JSONException e) {
        // // TODO Auto-generated catch block
        // ExceptionHandler.process(e);
        // }
        }
    });
    manageButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            try {
                ConnectionsDialog connectionsDialog = new ConnectionsDialog(getShell());
                int open = connectionsDialog.open();
                if (open == Window.OK) {
                    List<ConnectionBean> storedConnections = connectionsDialog.getConnections();
                    loginHelper.setStoredConnections(storedConnections);
                    loginHelper.saveConnections();
                    fillUIContentsWithBusyCursor();
                    final ConnectionBean connection = getConnection();
                    if (connection == null) {
                        checkErrors();
                        return;
                    }
                    // beforeConnBean = connection;
                    updateServerFields();
                    // Validate data
                    if (validateFields()) {
                        fillUIProjectListWithBusyCursor();
                        validateProject();
                    }
                    checkErrors();
                    validateUpdate();
                } else if (!LoginHelper.isRemoteConnection(getConnection())) {
                    fillUIProjectListWithBusyCursor();
                    validateProject();
                    checkErrors();
                }
            // setStatusArea();
            } catch (PersistenceException e1) {
                CommonExceptionHandler.process(e1);
            } catch (JSONException e2) {
                CommonExceptionHandler.process(e2);
            }
        }
    });
    refreshProjectButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            cancelAndClearFetchJobs();
            LoginProjectPage.this.selectedProjectBeforeRefresh = getProject() == null ? null : getProject().getLabel();
            // Validate data
            if (validateFields()) {
                fillUIProjectListWithBusyCursor();
                validateProject();
            }
            try {
                checkErrors();
                validateUpdate();
            } catch (PersistenceException e1) {
                CommonExceptionHandler.process(e1);
            } catch (JSONException e1) {
                CommonExceptionHandler.process(e1);
            }
            setRepositoryContextInContext();
            LoginProjectPage.this.selectedProjectBeforeRefresh = null;
        }
    });
    newProjectName.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            validateNewProjectName();
        }
    });
    executeCreateNewProject.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            createNewProjectWithBusyCursor();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // nothing need to do
        }
    });
    executeCreateSandBoxProject.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            createSandboxProject();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // nothing need to do
        }
    });
    executeImportDemoProject.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            importDemoProject();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // nothing need to do
        }
    });
    executeImportLocalProject.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            importProjects();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // nothing need to do
        }
    });
    finishButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (FINISH_ACTION_OPEN_PROJECT.equals(finishButtonAction)) {
                setRepositoryContextInContext();
                finishPressed();
            } else if (FINISH_ACTION_RESTART.equals(finishButtonAction)) {
                restartStudio();
            } else if (FINISH_ACTION_UPDATE.equals(finishButtonAction) || FINISH_ACTION_UPDATE_DETAILS.equals(finishButtonAction)) {
                updateStudio();
            } else if (FINISH_ACTION_CREATE_SANDBOX.equals(finishButtonAction)) {
                createSandboxProject();
            } else if (FINISH_ACTION_IMPORT_DEMO_PROJECT.equals(finishButtonAction)) {
                importDemoProject();
            } else if (FINISH_ACTION_IMPORT_LOCAL_PROJECT.equals(finishButtonAction)) {
                importProjects();
            } else if (FINISH_ACTION_CREATE_NEW_PROJECT.equals(finishButtonAction)) {
                createNewProjectWithBusyCursor();
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // nothing need to do
        }
    });
}
Also used : FormData(org.eclipse.swt.layout.FormData) ModifyListener(org.eclipse.swt.events.ModifyListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) JSONException(org.talend.utils.json.JSONException) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Project(org.talend.core.model.general.Project) ModifyEvent(org.eclipse.swt.events.ModifyEvent) PersistenceException(org.talend.commons.exception.PersistenceException) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ConnectionBean(org.talend.core.model.general.ConnectionBean) ArrayList(java.util.ArrayList) List(java.util.List) ConnectionsDialog(org.talend.repository.ui.login.connections.ConnectionsDialog) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 20 with ISelectionChangedListener

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

the class SetupProcessDependenciesRoutinesDialog method createTabFolderField.

private void createTabFolderField(Composite parent) {
    // tab
    folder = new CTabFolder(parent, SWT.NONE);
    folder.setLayoutData(new GridData(GridData.FILL_BOTH));
    folder.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateButtons();
        }
    });
    userTabItem = new CTabItem(folder, SWT.NONE);
    //$NON-NLS-1$
    userTabItem.setText(Messages.getString("SetupProcessDependenciesRoutinesDialog.userRoutineLabel"));
    systemTabItem = new CTabItem(folder, SWT.NONE);
    //$NON-NLS-1$
    systemTabItem.setText(Messages.getString("SetupProcessDependenciesRoutinesDialog.systemRoutineLabel"));
    folder.setSelection(userTabItem);
    folder.setSimple(false);
    ISelectionChangedListener listListener = new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updateButtons();
        }
    };
    // user
    Composite userComposite = new Composite(folder, SWT.NONE);
    userComposite.setLayout(new GridLayout());
    userComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    userViewer = new ListViewer(userComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    userViewer.setLabelProvider(new RoutineRecordLabelProvider());
    userViewer.setContentProvider(ArrayContentProvider.getInstance());
    userViewer.setInput(userRoutines);
    userViewer.getList().setLayoutData(new GridData(GridData.FILL_BOTH));
    userViewer.addSelectionChangedListener(listListener);
    userTabItem.setControl(userComposite);
    // system
    Composite systemComposite = new Composite(folder, SWT.NONE);
    systemComposite.setLayout(new GridLayout());
    systemComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    systemViewer = new ListViewer(systemComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    systemViewer.setLabelProvider(new RoutineRecordLabelProvider());
    systemViewer.setContentProvider(ArrayContentProvider.getInstance());
    systemViewer.setInput(systemRoutines);
    systemViewer.getList().setLayoutData(new GridData(GridData.FILL_BOTH));
    systemViewer.addSelectionChangedListener(listListener);
    systemTabItem.setControl(systemComposite);
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) GridLayout(org.eclipse.swt.layout.GridLayout) CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) CTabItem(org.eclipse.swt.custom.CTabItem)

Aggregations

ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)770 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)750 GridData (org.eclipse.swt.layout.GridData)411 Composite (org.eclipse.swt.widgets.Composite)332 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)302 GridLayout (org.eclipse.swt.layout.GridLayout)246 SelectionEvent (org.eclipse.swt.events.SelectionEvent)190 Label (org.eclipse.swt.widgets.Label)158 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)147 TableViewer (org.eclipse.jface.viewers.TableViewer)145 Button (org.eclipse.swt.widgets.Button)141 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)138 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)130 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)118 IPropertiesEditionEvent (org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)116 PropertiesEditionEvent (org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent)116 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)116 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)115 Table (org.eclipse.swt.widgets.Table)92 ISelection (org.eclipse.jface.viewers.ISelection)85