Search in sources :

Example 1 with ApplicationComponentEditorInput

use of com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput in project convertigo by convertigo.

the class MobileApplicationComponentTreeObject method activeEditor.

public ApplicationComponentEditor activeEditor(boolean autoLaunch) {
    ApplicationComponentEditor editorPart = null;
    ApplicationComponent application = (ApplicationComponent) getObject();
    synchronized (application) {
        String tpl = application.getTplProjectName();
        try {
            if (StringUtils.isBlank(tpl) || Engine.theApp.databaseObjectsManager.getOriginalProjectByName(tpl, false) == null) {
                throw new InvalidParameterException("The value '" + tpl + "' of the property 'Template project' from '" + application.getQName() + "' is incorrect.");
            }
            IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
            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) && (editorInput instanceof ApplicationComponentEditorInput)) {
                            if (((ApplicationComponentEditorInput) editorInput).is(application)) {
                                editorPart = (ApplicationComponentEditor) editorRef.getEditor(false);
                            }
                        }
                    } catch (PartInitException e) {
                    }
                }
                if (editorPart != null) {
                    activePage.activate(editorPart);
                } else {
                    IEditorPart editor = activePage.openEditor(new ApplicationComponentEditorInput(application, autoLaunch), "com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditor");
                    if (editor instanceof ApplicationComponentEditor) {
                        editorPart = (ApplicationComponentEditor) editor;
                    } else {
                        ConvertigoPlugin.logWarning("The Application Component Editor won't open, please see the error log.");
                    }
                }
            }
        } catch (Exception e) {
            ConvertigoPlugin.logException(e, "Error while loading the page editor '" + application.getName() + "'");
        }
    }
    return editorPart;
}
Also used : ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) ApplicationComponentEditor(com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditor) IEditorPart(org.eclipse.ui.IEditorPart) InvalidParameterException(java.security.InvalidParameterException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EngineException(com.twinsoft.convertigo.engine.EngineException) InvalidParameterException(java.security.InvalidParameterException) IEditorReference(org.eclipse.ui.IEditorReference) ApplicationComponentEditorInput(com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 2 with ApplicationComponentEditorInput

use of com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput in project convertigo by convertigo.

the class MobileApplicationComponentTreeObject method closeAllEditors.

@Override
public void closeAllEditors(boolean save) {
    // will close any child component editor
    super.closeAllEditors(save);
    ApplicationComponent application = (ApplicationComponent) getObject();
    synchronized (application) {
        IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        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 && editorInput instanceof ApplicationComponentEditorInput) {
                        if (((ApplicationComponentEditorInput) editorInput).is(application)) {
                            activePage.closeEditor(editorRef.getEditor(false), false);
                        }
                    }
                } catch (Exception e) {
                }
            }
        }
    }
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) ApplicationComponentEditorInput(com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput) ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorInput(org.eclipse.ui.IEditorInput) InvalidParameterException(java.security.InvalidParameterException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Aggregations

ApplicationComponent (com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent)2 ApplicationComponentEditorInput (com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput)2 EngineException (com.twinsoft.convertigo.engine.EngineException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 InvalidParameterException (java.security.InvalidParameterException)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 ApplicationComponentEditor (com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditor)1 IEditorPart (org.eclipse.ui.IEditorPart)1