Search in sources :

Example 91 with IEditorInput

use of org.eclipse.ui.IEditorInput in project KaiZen-OpenAPI-Editor by RepreZen.

the class QuickOutline method handleMultiView.

protected void handleMultiView() {
    currentScope = currentScope.next();
    SwaggerFileFinder fileFinder = new SwaggerFileFinder(fileContentType);
    IEditorInput input = editor.getEditorInput();
    IFile currentFile = null;
    if (input instanceof IFileEditorInput) {
        currentFile = ((IFileEditorInput) input).getFile();
    }
    Iterable<IFile> files = fileFinder.collectFiles(currentScope, currentFile);
    setInfoText(statusMessage());
    if (currentScope == Scope.LOCAL) {
        treeViewer.setAutoExpandLevel(2);
    } else {
        treeViewer.setAutoExpandLevel(0);
    }
    setInput(Model.parseYaml(files, getSchema()));
}
Also used : SwaggerFileFinder(com.reprezen.swagedit.core.utils.SwaggerFileFinder) IFile(org.eclipse.core.resources.IFile) IFileEditorInput(org.eclipse.ui.IFileEditorInput) IEditorInput(org.eclipse.ui.IEditorInput)

Example 92 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 93 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 94 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 95 with IEditorInput

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

the class OpenDeclarationAction method run.

/*
     * @see Action#run()
     */
@Override
public void run() {
    if (className == null) {
        return;
    }
    // search source
    IType source = null;
    try {
        source = searchSource();
    } catch (InterruptedException e) {
        return;
    }
    if (source == null) {
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.errorLabel, Messages.openDeclarationFailedMsg);
        return;
    }
    // get editor input
    IDebugModelPresentation presentation = DebugUITools.newDebugModelPresentation(JDIDebugModel.getPluginIdentifier());
    if (presentation == null) {
        return;
    }
    IEditorInput editorInput = presentation.getEditorInput(source);
    if (editorInput == null) {
        return;
    }
    // open editor
    IEditorPart editorPart = null;
    try {
        editorPart = openEditor(editorInput, presentation, source);
    } catch (PartInitException e) {
        Activator.log(IStatus.ERROR, Messages.openEditorFailedMsg, e);
    }
    presentation.dispose();
    if (editorPart == null) {
        return;
    }
    // highlight method
    try {
        highlightMethod(editorInput, editorPart);
    } catch (CoreException e) {
        Activator.log(IStatus.ERROR, Messages.highlightMethodFailedMsg, e);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IDebugModelPresentation(org.eclipse.debug.ui.IDebugModelPresentation) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput) IType(org.eclipse.jdt.core.IType)

Aggregations

IEditorInput (org.eclipse.ui.IEditorInput)135 IFile (org.eclipse.core.resources.IFile)38 IEditorPart (org.eclipse.ui.IEditorPart)37 PartInitException (org.eclipse.ui.PartInitException)31 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)28 CoreException (org.eclipse.core.runtime.CoreException)25 IFileEditorInput (org.eclipse.ui.IFileEditorInput)22 IDocument (org.eclipse.jface.text.IDocument)17 IEditorReference (org.eclipse.ui.IEditorReference)17 FileEditorInput (org.eclipse.ui.part.FileEditorInput)16 File (java.io.File)14 ArrayList (java.util.ArrayList)14 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)14 IDocumentProvider (org.eclipse.ui.texteditor.IDocumentProvider)14 IResource (org.eclipse.core.resources.IResource)13 Shell (org.eclipse.swt.widgets.Shell)13 IViewPart (org.eclipse.ui.IViewPart)13 IPath (org.eclipse.core.runtime.IPath)12 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)12 FileStoreEditorInput (org.eclipse.ui.ide.FileStoreEditorInput)11