Search in sources :

Example 1 with ISelection

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

the class UIManager method moveRecord.

public void moveRecord(TreeViewer schemaTreeViewer, boolean left) {
    if (schemaTreeViewer == null) {
        return;
    }
    ISelection selection = schemaTreeViewer.getSelection();
    if (selection instanceof IStructuredSelection) {
        Object element = ((IStructuredSelection) selection).getFirstElement();
        if (element instanceof SchemasKeyData) {
            SchemasKeyData data = (SchemasKeyData) element;
            SchemasKeyData parent = data.getParent();
            if (left) {
                SchemasKeyData grandfather = parent.getParent();
                if (grandfather != null) {
                    // not in root.
                    List<SchemasKeyData> children = grandfather.getChildren();
                    int index = -1;
                    for (int i = 0; i < children.size(); i++) {
                        if (children.get(i) == parent) {
                            index = i;
                            break;
                        }
                    }
                    if (index > -1) {
                        int index2 = index + 1;
                        if (index2 > children.size()) {
                            grandfather.addChild(data);
                        } else {
                            grandfather.addChild(index2, data);
                        }
                    }
                }
            } else {
                SchemasKeyData sibling = null;
                for (SchemasKeyData skd : parent.getChildren()) {
                    if (skd == data) {
                        break;
                    } else {
                        sibling = skd;
                    }
                }
                if (sibling != null) {
                    sibling.addChild(data);
                }
            }
            schemaTreeViewer.refresh();
        }
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData)

Example 2 with ISelection

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

the class OpenExistVersionProcessAction method doRun.

@Override
protected void doRun() {
    ISelection selection = getSelection();
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    RepositoryNode node = (RepositoryNode) obj;
    IPath path = RepositoryNodeUtilities.getPath(node);
    String originalName = node.getObject().getLabel();
    RepositoryObject repositoryObj = new RepositoryObject(node.getObject().getProperty());
    repositoryObj.setRepositoryNode(node.getObject().getRepositoryNode());
    OpenExistVersionProcessWizard wizard = new OpenExistVersionProcessWizard(repositoryObj);
    WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
    dialog.setPageSize(300, 250);
    //$NON-NLS-1$
    dialog.setTitle(Messages.getString("OpenExistVersionProcess.open.dialog"));
    if (dialog.open() == Dialog.OK) {
        refresh(node);
        // refresh the corresponding editor's name
        IEditorPart part = getCorrespondingEditor(node);
        if (part != null && part instanceof IUIRefresher) {
            ((IUIRefresher) part).refreshName();
        } else {
            processRoutineRenameOperation(originalName, node, path);
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) RepositoryObject(org.talend.core.model.repository.RepositoryObject) OpenExistVersionProcessWizard(org.talend.designer.core.ui.wizards.OpenExistVersionProcessWizard) ISelection(org.eclipse.jface.viewers.ISelection) RepositoryObject(org.talend.core.model.repository.RepositoryObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IUIRefresher(org.talend.core.services.IUIRefresher)

Example 3 with ISelection

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

the class RunProcess method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
protected void doRun() {
    ISelection selection = getSelection();
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    if (!(obj instanceof RepositoryNode)) {
        return;
    }
    // Add this job to running history list.
    JobLaunchShortcutManager.run(selection);
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 4 with ISelection

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

the class ProcessVersionComposite method addPopUpMenu.

/**
     * DOC Administrator Comment method "addPoppuMenu".
     */
private void addPopUpMenu() {
    //$NON-NLS-1$
    MenuManager menuMgr = new MenuManager("#PopUp");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager mgr) {
            if (getParentWizard() == null) {
                ISelection selection = tableViewer.getSelection();
                if (selection instanceof IStructuredSelection) {
                    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                    List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
                    for (ITreeContextualAction action : contextualsActions) {
                        if (action instanceof OpenExistVersionProcessAction) {
                            continue;
                        }
                        if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
                            action.init(null, structuredSelection);
                            Object o = structuredSelection.getFirstElement();
                            if (o instanceof RepositoryNode) {
                                ((AContextualAction) action).setAvoidUnloadResources(true);
                            }
                            if (action.isVisible()) {
                                mgr.add(action);
                            }
                        }
                    }
                }
            }
        }
    });
    Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
    tableViewer.getControl().setMenu(menu);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ISelection(org.eclipse.jface.viewers.ISelection) List(java.util.List) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryObject(org.talend.core.model.repository.IRepositoryObject) IMenuManager(org.eclipse.jface.action.IMenuManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITreeContextualAction(org.talend.commons.ui.swt.actions.ITreeContextualAction) Menu(org.eclipse.swt.widgets.Menu) RepositoryNode(org.talend.repository.model.RepositoryNode) OpenExistVersionProcessAction(org.talend.designer.core.ui.action.OpenExistVersionProcessAction) IMenuListener(org.eclipse.jface.action.IMenuListener)

Example 5 with ISelection

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

ISelection (org.eclipse.jface.viewers.ISelection)1005 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)633 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)176 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)121 ArrayList (java.util.ArrayList)116 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)114 IResource (org.eclipse.core.resources.IResource)91 IFile (org.eclipse.core.resources.IFile)86 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)86 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)83 GridData (org.eclipse.swt.layout.GridData)78 IEditorPart (org.eclipse.ui.IEditorPart)70 Composite (org.eclipse.swt.widgets.Composite)69 ITextSelection (org.eclipse.jface.text.ITextSelection)65 PartInitException (org.eclipse.ui.PartInitException)65 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)64 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)62 SelectionEvent (org.eclipse.swt.events.SelectionEvent)59 GridLayout (org.eclipse.swt.layout.GridLayout)57 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)54