Search in sources :

Example 1 with TraceFileEditorInput

use of com.twinsoft.convertigo.eclipse.editors.text.TraceFileEditorInput in project convertigo by convertigo.

the class TraceTreeObject method openTextEditor.

public void openTextEditor(IProject project) {
    ConnectorTreeObject connectorTreeObject = (ConnectorTreeObject) this.parent.parent;
    IFile file = project.getFile("Traces/" + connectorTreeObject.getName() + "/" + this.getName());
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (activePage != null) {
        try {
            activePage.openEditor(new TraceFileEditorInput(connectorTreeObject.getObject(), file), "org.eclipse.ui.DefaultTextEditor");
        } catch (PartInitException e) {
            ConvertigoPlugin.logException(e, "Error while loading the text editor.");
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) TraceFileEditorInput(com.twinsoft.convertigo.eclipse.editors.text.TraceFileEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException)

Example 2 with TraceFileEditorInput

use of com.twinsoft.convertigo.eclipse.editors.text.TraceFileEditorInput 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

TraceFileEditorInput (com.twinsoft.convertigo.eclipse.editors.text.TraceFileEditorInput)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 SequenceEditorInput (com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditorInput)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IPath (org.eclipse.core.runtime.IPath)1 IEditorInput (org.eclipse.ui.IEditorInput)1 IEditorReference (org.eclipse.ui.IEditorReference)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 FileEditorInput (org.eclipse.ui.part.FileEditorInput)1