Search in sources :

Example 1 with SequenceEditorInput

use of com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditorInput in project convertigo by convertigo.

the class ProjectTreeObject method getSequenceEditor.

public SequenceEditor getSequenceEditor(Sequence sequence) {
    SequenceEditor sequenceEditor = null;
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (activePage != null) {
        if (sequence != null) {
            IEditorReference[] editorRefs = activePage.getEditorReferences();
            for (int i = 0; i < editorRefs.length; i++) {
                IEditorReference editorRef = (IEditorReference) editorRefs[i];
                try {
                    IEditorInput editorInput = editorRef.getEditorInput();
                    if ((editorInput != null) && (editorInput instanceof SequenceEditorInput)) {
                        if (((SequenceEditorInput) editorInput).is(sequence)) {
                            sequenceEditor = (SequenceEditor) editorRef.getEditor(true);
                            break;
                        }
                    }
                } catch (PartInitException e) {
                    ConvertigoPlugin.logException(e, "Error while retrieving the sequence editor '" + editorRef.getName() + "'");
                }
            }
        }
    }
    return sequenceEditor;
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) SequenceEditor(com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditor) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput) SequenceEditorInput(com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditorInput)

Example 2 with SequenceEditorInput

use of com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditorInput in project convertigo by convertigo.

the class ProjectTreeObject method closeAllEditors.

public void closeAllEditors() {
    Project project = getObject();
    IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage activePage = workbenchWindow != null ? workbenchWindow.getActivePage() : null;
    if (activePage != null) {
        IEditorReference[] editorRefs = activePage.getEditorReferences();
        for (int i = 0; i < editorRefs.length; i++) {
            IEditorReference editorRef = (IEditorReference) editorRefs[i];
            try {
                IEditorInput editorInput = editorRef.getEditorInput();
                if (editorInput != null) {
                    // close connector editor
                    if (editorInput instanceof ConnectorEditorInput) {
                        if (((ConnectorEditorInput) editorInput).is(project)) {
                            closeEditor(activePage, editorRef);
                        }
                    } else // close sequence editors
                    if (editorInput instanceof SequenceEditorInput) {
                        if (((SequenceEditorInput) editorInput).is(project)) {
                            closeEditor(activePage, editorRef);
                        }
                    } else // close js editors
                    if (editorInput instanceof JScriptEditorInput) {
                        DatabaseObject dbo = ((JScriptEditorInput) editorInput).getJScriptContainer().getDatabaseObject();
                        if (dbo != null && project.equals(dbo.getProject())) {
                            closeEditor(activePage, editorRef);
                        }
                    } else // close trace editors
                    if (editorInput instanceof TraceFileEditorInput) {
                        if (((TraceFileEditorInput) editorInput).getConnector().getProject().equals(project)) {
                            closeEditor(activePage, editorRef);
                        }
                    } else // close other file editors
                    if (editorInput instanceof FileEditorInput) {
                        IPath fullpath = ((FileEditorInput) editorInput).getFile().getFullPath();
                        if (fullpath.toString().replaceFirst("/(.*?)/.*", "$1").equals(project.getName())) {
                            closeEditor(activePage, editorRef);
                        }
                    } else if (editorInput instanceof com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput) {
                        com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput acei = GenericUtils.cast(editorInput);
                        if (acei.getApplication().getProject().equals(project)) {
                            closeEditor(activePage, editorRef);
                        }
                    } else if (editorInput instanceof com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput) {
                        com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput acei = GenericUtils.cast(editorInput);
                        if (acei.getApplication().getProject().equals(project)) {
                            closeEditor(activePage, editorRef);
                        }
                    }
                }
            } catch (PartInitException e) {
                ConvertigoPlugin.logException(e, "Error while retrieving the editor '" + editorRef.getName() + "'");
            }
        }
    }
}
Also used : JScriptEditorInput(com.twinsoft.convertigo.eclipse.editors.jscript.JScriptEditorInput) TraceFileEditorInput(com.twinsoft.convertigo.eclipse.editors.text.TraceFileEditorInput) ConnectorEditorInput(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditorInput) IEditorReference(org.eclipse.ui.IEditorReference) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) PartInitException(org.eclipse.ui.PartInitException) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IPath(org.eclipse.core.runtime.IPath) SequenceEditorInput(com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditorInput) IProject(org.eclipse.core.resources.IProject) Project(com.twinsoft.convertigo.beans.core.Project) TraceFileEditorInput(com.twinsoft.convertigo.eclipse.editors.text.TraceFileEditorInput) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

SequenceEditorInput (com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditorInput)2 IEditorInput (org.eclipse.ui.IEditorInput)2 IEditorReference (org.eclipse.ui.IEditorReference)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 PartInitException (org.eclipse.ui.PartInitException)2 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)1 Project (com.twinsoft.convertigo.beans.core.Project)1 ConnectorEditorInput (com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditorInput)1 JScriptEditorInput (com.twinsoft.convertigo.eclipse.editors.jscript.JScriptEditorInput)1 SequenceEditor (com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditor)1 TraceFileEditorInput (com.twinsoft.convertigo.eclipse.editors.text.TraceFileEditorInput)1 IProject (org.eclipse.core.resources.IProject)1 IPath (org.eclipse.core.runtime.IPath)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 FileEditorInput (org.eclipse.ui.part.FileEditorInput)1