Search in sources :

Example 1 with SourcePickerView

use of com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView in project convertigo by convertigo.

the class ConvertigoPlugin method getSourcePickerView.

/**
 * Gets the source picker view.
 * !!MUST BE CALLED IN A UI-THREAD!!
 * @return SourcePickerView : the source picker view of Convertigo Plugin
 */
public SourcePickerView getSourcePickerView() {
    SourcePickerView sourcePickerView = null;
    IWorkbenchPage activePage = getActivePage();
    if (activePage != null) {
        IViewPart viewPart = activePage.findView("com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView");
        if (viewPart != null)
            sourcePickerView = (SourcePickerView) viewPart;
    }
    return sourcePickerView;
}
Also used : SourcePickerView(com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView) IViewPart(org.eclipse.ui.IViewPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 2 with SourcePickerView

use of com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView in project convertigo by convertigo.

the class ShowStepInPickerAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            if (treeObject != null) {
                if (treeObject instanceof DatabaseObjectTreeObject) {
                    DatabaseObject selectedDbo = ((DatabaseObjectTreeObject) treeObject).getObject();
                    if (selectedDbo != null) {
                        StepSourceEvent event = null;
                        if (showSource) {
                            if (selectedDbo instanceof Step) {
                                Step step = (Step) selectedDbo;
                                Set<StepSource> sources = step.getSources();
                                if (!sources.isEmpty()) {
                                    event = new StepSourceEvent(sources.iterator().next());
                                } else {
                                    throw new Exception("No Source defined");
                                }
                            }
                        } else {
                            event = new StepSourceEvent(selectedDbo);
                        }
                        if (event != null) {
                            SourcePickerView spv = ConvertigoPlugin.getDefault().getSourcePickerView();
                            if (spv == null) {
                                spv = (SourcePickerView) getActivePage().showView("com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView");
                            }
                            if (spv != null) {
                                spv.sourceSelected(event);
                            }
                        }
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to show object in Picker!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : SourcePickerView(com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) Step(com.twinsoft.convertigo.beans.core.Step) Cursor(org.eclipse.swt.graphics.Cursor) StepSourceEvent(com.twinsoft.convertigo.eclipse.views.projectexplorer.StepSourceEvent) StepSource(com.twinsoft.convertigo.beans.core.StepSource) Shell(org.eclipse.swt.widgets.Shell) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) Display(org.eclipse.swt.widgets.Display)

Example 3 with SourcePickerView

use of com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView in project convertigo by convertigo.

the class ProjectTreeObject method clearSourcePickerView.

private void clearSourcePickerView() {
    try {
        IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        if (activePage != null) {
            IViewPart viewPart = activePage.findView("com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView");
            if (viewPart != null) {
                SourcePickerView spv = (SourcePickerView) viewPart;
                DatabaseObject dbo = (DatabaseObject) spv.getObject();
                boolean bClose = true;
                try {
                    bClose = dbo.getProject().equals(getObject());
                } catch (Exception e) {
                }
                if (bClose) {
                    spv.close();
                }
            }
        }
    } catch (Exception e) {
    }
}
Also used : SourcePickerView(com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView) IViewPart(org.eclipse.ui.IViewPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) EngineException(com.twinsoft.convertigo.engine.EngineException) ConvertigoException(com.twinsoft.convertigo.engine.ConvertigoException)

Example 4 with SourcePickerView

use of com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView in project convertigo by convertigo.

the class ConvertigoPartListener method partClosed.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart)
	 */
public void partClosed(IWorkbenchPart part) {
    if (part instanceof ConnectorEditor) {
        // close editor properly
        ((ConnectorEditor) part).close();
    }
    if (part instanceof SequenceEditor) {
        // close editor properly
        ((SequenceEditor) part).close();
    }
    if (part instanceof ProjectExplorerView) {
        // close view properly
        ((ProjectExplorerView) part).close();
    }
    if (part instanceof SourcePickerView) {
        // close view properly
        ((SourcePickerView) part).close();
    }
    if (part instanceof ConsoleView) {
        ConvertigoPlugin convertigoPlugin = ConvertigoPlugin.getDefault();
        boolean shuttingDown = convertigoPlugin.isShuttingDown();
        if (shuttingDown) {
            IConsole[] tabConsoles = ConsolePlugin.getDefault().getConsoleManager().getConsoles();
            String openedConsoles = "";
            for (IConsole console : tabConsoles) {
                if (console instanceof MessageConsole) {
                    if ((console.equals(convertigoPlugin.engineConsole)) && (openedConsoles.indexOf("engine") == -1))
                        openedConsoles += (openedConsoles.equals("") ? "" : ",") + "engine";
                    else if ((console.equals(convertigoPlugin.stdoutConsole)) && (openedConsoles.indexOf("stdout") == -1))
                        openedConsoles += (openedConsoles.equals("") ? "" : ",") + "stdout";
                }
            }
            ConvertigoPlugin.setProperty(ConvertigoPlugin.PREFERENCE_OPENED_CONSOLES, openedConsoles);
        }
    }
    if (part instanceof EditorPart) {
        IEditorInput input = ((EditorPart) part).getEditorInput();
        if (input instanceof com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput) {
            try {
                com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput acei = GenericUtils.cast(input);
                MobileBuilder mb = acei.getApplication().getProject().getMobileBuilder();
                mb.removeMobileEventListener((com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditor) part);
                mb.setAutoBuild(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (input instanceof com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput) {
            try {
                com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput acei = GenericUtils.cast(input);
                MobileBuilder mb = acei.getApplication().getProject().getMobileBuilder();
                mb.removeMobileEventListener((com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditor) part);
                mb.setAutoBuild(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (input instanceof JScriptEditorInput) {
            try {
                ((JScriptEditorInput) input).getFile().getParent().delete(true, null);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (input instanceof com.twinsoft.convertigo.eclipse.editors.mobile.ComponentFileEditorInput) {
            try {
                ((com.twinsoft.convertigo.eclipse.editors.mobile.ComponentFileEditorInput) input).getFile().delete(true, null);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (input instanceof com.twinsoft.convertigo.eclipse.editors.ngx.ComponentFileEditorInput) {
            try {
                ((com.twinsoft.convertigo.eclipse.editors.ngx.ComponentFileEditorInput) input).getFile().delete(true, null);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : SourcePickerView(com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView) JScriptEditorInput(com.twinsoft.convertigo.eclipse.editors.jscript.JScriptEditorInput) ConnectorEditor(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) MessageConsole(org.eclipse.ui.console.MessageConsole) ConsoleView(org.eclipse.ui.internal.console.ConsoleView) SequenceEditor(com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditor) IConsole(org.eclipse.ui.console.IConsole) EditorPart(org.eclipse.ui.part.EditorPart) MobileBuilder(com.twinsoft.convertigo.engine.mobile.MobileBuilder) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

SourcePickerView (com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView)4 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)2 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)2 IViewPart (org.eclipse.ui.IViewPart)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 Step (com.twinsoft.convertigo.beans.core.Step)1 StepSource (com.twinsoft.convertigo.beans.core.StepSource)1 ConnectorEditor (com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor)1 JScriptEditorInput (com.twinsoft.convertigo.eclipse.editors.jscript.JScriptEditorInput)1 SequenceEditor (com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditor)1 StepSourceEvent (com.twinsoft.convertigo.eclipse.views.projectexplorer.StepSourceEvent)1 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)1 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)1 ConvertigoException (com.twinsoft.convertigo.engine.ConvertigoException)1 EngineException (com.twinsoft.convertigo.engine.EngineException)1 MobileBuilder (com.twinsoft.convertigo.engine.mobile.MobileBuilder)1 CoreException (org.eclipse.core.runtime.CoreException)1 Cursor (org.eclipse.swt.graphics.Cursor)1 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1