Search in sources :

Example 31 with ISelection

use of org.eclipse.jface.viewers.ISelection in project flux by eclipse.

the class SyncDisconnectHandler method setEnabled.

@Override
public void setEnabled(Object evaluationContext) {
    Repository repository = org.eclipse.flux.core.Activator.getDefault().getRepository();
    if (repository != null && evaluationContext instanceof IEvaluationContext) {
        IEvaluationContext evalContext = (IEvaluationContext) evaluationContext;
        Object selection = evalContext.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
        if (selection instanceof ISelection) {
            IProject[] selectedProjects = getSelectedProjects((ISelection) selection);
            for (IProject project : selectedProjects) {
                if (repository.isConnected(project)) {
                    setBaseEnabled(true);
                    return;
                }
            }
        }
    }
    setBaseEnabled(false);
}
Also used : Repository(org.eclipse.flux.core.Repository) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) ISelection(org.eclipse.jface.viewers.ISelection) IProject(org.eclipse.core.resources.IProject)

Example 32 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 33 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 34 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 35 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)

Aggregations

ISelection (org.eclipse.jface.viewers.ISelection)306 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)183 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)44 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)41 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)40 GridData (org.eclipse.swt.layout.GridData)40 SelectionEvent (org.eclipse.swt.events.SelectionEvent)34 ArrayList (java.util.ArrayList)33 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)30 IEditorPart (org.eclipse.ui.IEditorPart)30 Composite (org.eclipse.swt.widgets.Composite)29 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)29 WizardDialog (org.eclipse.jface.wizard.WizardDialog)26 IResource (org.eclipse.core.resources.IResource)24 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)24 TableViewer (org.eclipse.jface.viewers.TableViewer)24 IFile (org.eclipse.core.resources.IFile)23 GridLayout (org.eclipse.swt.layout.GridLayout)23 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)23 TreeViewer (org.eclipse.jface.viewers.TreeViewer)22