Search in sources :

Example 66 with IEditorInput

use of org.eclipse.ui.IEditorInput in project tesb-studio-se by Talend.

the class OpenAnotherVersionResourceAction method getCorrespondingEditor.

protected IEditorPart getCorrespondingEditor(RepositoryNode node) {
    for (IEditorReference ref : getActivePage().getEditorReferences()) {
        try {
            IEditorInput input = ref.getEditorInput();
            if (!(input instanceof RouteResourceInput)) {
                continue;
            }
            RouteResourceInput repositoryInput = (RouteResourceInput) input;
            if (repositoryInput.getItem().equals(node.getObject().getProperty().getItem())) {
                return ref.getEditor(false);
            }
        } catch (PartInitException e) {
            continue;
        }
    }
    return null;
}
Also used : RouteResourceInput(org.talend.designer.camel.resource.editors.input.RouteResourceInput) IEditorReference(org.eclipse.ui.IEditorReference) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 67 with IEditorInput

use of org.eclipse.ui.IEditorInput in project tesb-studio-se by Talend.

the class CamelEditorDropTargetListener method createContext.

private void createContext() {
    if (selectSourceList.size() == 0) {
        return;
    }
    boolean created = false;
    for (Object source : selectSourceList) {
        if (source instanceof RepositoryNode) {
            RepositoryNode sourceNode = (RepositoryNode) source;
            Item item = sourceNode.getObject().getProperty().getItem();
            if (item instanceof ContextItem) {
                ContextItem contextItem = (ContextItem) item;
                EList context = contextItem.getContext();
                Set<String> contextSet = new HashSet<String>();
                Iterator iterator = context.iterator();
                while (iterator.hasNext()) {
                    Object obj = iterator.next();
                    if (obj instanceof ContextTypeImpl) {
                        EList contextParameters = ((ContextTypeImpl) obj).getContextParameter();
                        Iterator contextParas = contextParameters.iterator();
                        while (contextParas.hasNext()) {
                            ContextParameterTypeImpl contextParameterType = (ContextParameterTypeImpl) contextParas.next();
                            String name = contextParameterType.getName();
                            contextSet.add(name);
                        }
                    }
                }
                IEditorInput editorInput = editor.getEditorInput();
                if (editorInput instanceof JobEditorInput) {
                    JobEditorInput jobInput = (JobEditorInput) editorInput;
                    IProcess2 process = jobInput.getLoadedProcess();
                    IContextManager contextManager = process.getContextManager();
                    List<IContext> listContext = contextManager.getListContext();
                    Set<String> addedVars = ConnectionContextHelper.checkAndAddContextVariables(contextItem, contextSet, process.getContextManager(), false);
                    if (addedVars != null && !addedVars.isEmpty() && !ConnectionContextHelper.isAddContextVar(contextItem, contextManager, contextSet)) {
                        // show
                        Map<String, Set<String>> addedVarsMap = new HashMap<String, Set<String>>();
                        addedVarsMap.put(item.getProperty().getLabel(), contextSet);
                        if (ConnectionContextHelper.showContextdialog(process, contextItem, process.getContextManager(), addedVarsMap, contextSet)) {
                            created = true;
                        }
                    } else {
                        //$NON-NLS-1$
                        MessageDialog.openInformation(//$NON-NLS-1$
                        editor.getEditorSite().getShell(), //$NON-NLS-1$
                        "Adding Context", //$NON-NLS-1$
                        "Context \"" + contextItem.getProperty().getDisplayName() + "\" already exist.");
                    }
                }
            }
        }
    }
    if (created) {
        RepositoryPlugin.getDefault().getDesignerCoreService().switchToCurContextsView();
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) IContext(org.talend.core.model.process.IContext) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ContextParameterTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl) RepositoryNode(org.talend.repository.model.RepositoryNode) JobEditorInput(org.talend.core.ui.editor.JobEditorInput) ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) EList(org.eclipse.emf.common.util.EList) Iterator(java.util.Iterator) IProcess2(org.talend.core.model.process.IProcess2) ContextTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ContextTypeImpl) IContextManager(org.talend.core.model.process.IContextManager) IEditorInput(org.eclipse.ui.IEditorInput) HashSet(java.util.HashSet)

Example 68 with IEditorInput

use of org.eclipse.ui.IEditorInput in project tesb-studio-se by Talend.

the class LocalWSDLEditor method dispose.

@Override
public void dispose() {
    // unlock item if necessary
    IEditorInput currentEditorInput = getEditorInput();
    if (currentEditorInput instanceof RepositoryEditorInput) {
        RepositoryEditorInput serviceEditorInput = (RepositoryEditorInput) currentEditorInput;
        Item currentItem = serviceEditorInput.getItem();
        if (currentItem != null) {
            // unlock item if no other editors open it.
            boolean openItemInOtherEditor = false;
            IEditorReference[] editorRefs = getEditorSite().getPage().getEditorReferences();
            for (IEditorReference editorRef : editorRefs) {
                if (editorRef.getEditor(false) == this) {
                    continue;
                }
                try {
                    IEditorInput editorInput = editorRef.getEditorInput();
                    if (editorInput instanceof RepositoryEditorInput) {
                        Item item = ((RepositoryEditorInput) editorInput).getItem();
                        if (item == currentItem) {
                            // open this item & not this one.
                            openItemInOtherEditor = true;
                        }
                    }
                } catch (PartInitException e) {
                    // ignore and compare others
                    ExceptionHandler.process(e);
                }
            }
            if (!openItemInOtherEditor) {
                try {
                    DesignerPlugin.getDefault().getProxyRepositoryFactory().unlock(currentItem);
                } catch (Exception e) {
                    ExceptionHandler.process(e);
                }
            }
        }
    }
    super.dispose();
}
Also used : Item(org.talend.core.model.properties.Item) ServiceItem(org.talend.repository.services.model.services.ServiceItem) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IEditorReference(org.eclipse.ui.IEditorReference) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) LoginException(org.talend.commons.exception.LoginException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 69 with IEditorInput

use of org.eclipse.ui.IEditorInput in project bndtools by bndtools.

the class AbstractLaunchShortcut method launch.

@Override
public void launch(IEditorPart editor, String mode) {
    IEditorInput input = editor.getEditorInput();
    IJavaElement element = (IJavaElement) input.getAdapter(IJavaElement.class);
    if (element != null) {
        IJavaProject jproject = element.getJavaProject();
        if (jproject != null) {
            launch(jproject.getProject().getFullPath(), jproject.getProject(), mode);
        }
    } else {
        IFile file = ResourceUtil.getFile(input);
        if (file != null) {
            if (file.getName().endsWith(LaunchConstants.EXT_BNDRUN)) {
                launch(file.getFullPath(), file.getProject(), mode);
            } else if (file.getName().equals(Project.BNDFILE)) {
                launch(file.getProject().getFullPath(), file.getProject(), mode);
            }
        }
    }
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) IEditorInput(org.eclipse.ui.IEditorInput)

Example 70 with IEditorInput

use of org.eclipse.ui.IEditorInput in project bndtools by bndtools.

the class RunRequirementsPart method doResolve.

private void doResolve() {
    // Make sure all the parts of this editor page have committed their
    // dirty state to the model
    IFormPart[] parts = getManagedForm().getParts();
    for (IFormPart part : parts) {
        if (part.isDirty())
            part.commit(false);
    }
    final IFormPage page = (IFormPage) getManagedForm().getContainer();
    final IEditorInput input = page.getEditorInput();
    final IEditorPart editor = page.getEditor();
    final IFile file = ResourceUtil.getFile(input);
    final Shell parentShell = page.getEditor().getSite().getShell();
    // Create the wizard and pre-validate
    final ResolveJob job = new ResolveJob(model);
    IStatus validation = job.validateBeforeRun();
    if (!validation.isOK()) {
        ErrorDialog errorDialog = new ErrorDialog(parentShell, "Validation Problem", null, validation, IStatus.ERROR | IStatus.WARNING) {

            @Override
            protected void createButtonsForButtonBar(Composite parent) {
                // create OK, Cancel and Details buttons
                createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
                createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true);
                createDetailsButton(parent);
            }
        };
        int response = errorDialog.open();
        if (Window.CANCEL == response || validation.getSeverity() >= IStatus.ERROR) {
            btnResolveNow.setEnabled(true);
            return;
        }
    }
    // Add the operation to perform at the end of the resolution job (i.e.,
    // showing the result)
    final Runnable showResult = new Runnable() {

        @Override
        public void run() {
            ResolutionWizard wizard = new ResolutionWizard(model, file, job.getResolutionResult());
            WizardDialog dialog = new WizardDialog(parentShell, wizard);
            boolean dirtyBeforeResolve = editor.isDirty();
            if (dialog.open() == Dialog.OK && !dirtyBeforeResolve) {
                // only save the editor, when no unsaved changes happened before resolution
                editor.getEditorSite().getPage().saveEditor(editor, false);
            }
            btnResolveNow.setEnabled(true);
        }
    };
    job.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(IJobChangeEvent event) {
            Outcome outcome = job.getResolutionResult().getOutcome();
            if (outcome != Outcome.Cancelled)
                parentShell.getDisplay().asyncExec(showResult);
        }
    });
    job.setUser(true);
    job.schedule();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) Composite(org.eclipse.swt.widgets.Composite) ResolutionWizard(org.bndtools.core.resolve.ui.ResolutionWizard) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) ErrorDialog(org.eclipse.jface.dialogs.ErrorDialog) IFormPage(org.eclipse.ui.forms.editor.IFormPage) IEditorPart(org.eclipse.ui.IEditorPart) ResolveJob(org.bndtools.core.resolve.ResolveJob) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) Shell(org.eclipse.swt.widgets.Shell) Outcome(org.bndtools.core.resolve.ResolutionResult.Outcome) IFormPart(org.eclipse.ui.forms.IFormPart) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

IEditorInput (org.eclipse.ui.IEditorInput)71 IFile (org.eclipse.core.resources.IFile)26 PartInitException (org.eclipse.ui.PartInitException)21 IEditorPart (org.eclipse.ui.IEditorPart)19 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)17 IEditorReference (org.eclipse.ui.IEditorReference)14 CoreException (org.eclipse.core.runtime.CoreException)13 ArrayList (java.util.ArrayList)11 IViewPart (org.eclipse.ui.IViewPart)11 FileEditorInput (org.eclipse.ui.part.FileEditorInput)10 Shell (org.eclipse.swt.widgets.Shell)9 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)8 IFileEditorInput (org.eclipse.ui.IFileEditorInput)8 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)8 File (java.io.File)7 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)7 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)7 Item (org.talend.core.model.properties.Item)7 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)6 IProject (org.eclipse.core.resources.IProject)6