Search in sources :

Example 6 with IWorkbenchListener

use of org.eclipse.ui.IWorkbenchListener in project mdw-designer by CenturyLinkCloud.

the class TaskTemplateEditor method init.

@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    setSite(site);
    textEditor = new StructuredTextEditor() {

        @Override
        public boolean isEditable() {
            return false;
        }

        @Override
        public boolean isEditorInputModifiable() {
            return false;
        }

        @Override
        public boolean isEditorInputReadOnly() {
            return true;
        }

        @Override
        public boolean isDirty() {
            return false;
        }
    };
    textEditor.setEditorPart(this);
    if (input instanceof FileEditorInput) {
        setInput(input);
        IFile file = ((FileEditorInput) input).getFile();
        WorkflowProject project = WorkflowProjectManager.getInstance().getWorkflowProject(file.getProject());
        // force initialization
        project.getDesignerProxy();
        WorkflowPackage pkg = project.getPackage((IFolder) file.getParent());
        taskTemplate = (TaskTemplate) pkg.getTaskTemplate(file);
        // refresh from file system to make sure we're in sync
        try {
            Long taskId = taskTemplate.getId();
            int version = taskTemplate.getVersion();
            file.refreshLocal(IResource.DEPTH_ZERO, null);
            String content = new String(PluginUtil.readFile(file));
            TaskVO taskVO;
            if (content.trim().startsWith("{")) {
                taskVO = new TaskVO(new JSONObject(content));
            } else {
                TaskTemplateDocument doc = TaskTemplateDocument.Factory.parse(content);
                com.centurylink.mdw.task.TaskTemplate fileTemplate = doc.getTaskTemplate();
                taskVO = new TaskVO(fileTemplate);
            }
            taskTemplate.setTaskVO(taskVO);
            taskVO.setName(file.getName());
            taskVO.setTaskId(taskId);
            taskTemplate.setId(taskId);
            taskTemplate.setVersion(version);
            taskVO.setPackageName(pkg.getName());
        } catch (Exception ex) {
            throw new PartInitException(ex.getMessage(), ex);
        }
    } else {
        throw new PartInitException("Invalid input: " + input);
    }
    selectionProvider = new WorkflowSelectionProvider(taskTemplate);
    site.setSelectionProvider(selectionProvider);
    setPartName(taskTemplate.getName());
    addPageChangedListener(new IPageChangedListener() {

        public void pageChanged(PageChangedEvent event) {
            if (getSelectedPage() == pages.get("Variables")) {
                reconcileVariables();
            }
        }
    });
    partListener = new IPartListener2() {

        public void partOpened(IWorkbenchPartReference partRef) {
        // do nothing
        }

        public void partActivated(IWorkbenchPartReference partRef) {
            IWorkbenchPart part = partRef.getPart(false);
            if (part == TaskTemplateEditor.this && getSelectedPage() == pages.get("Variables"))
                reconcileVariables();
        }

        public void partBroughtToTop(IWorkbenchPartReference partRef) {
        // do nothing
        }

        public void partDeactivated(IWorkbenchPartReference partRef) {
        // do nothing
        }

        public void partClosed(IWorkbenchPartReference partRef) {
        // do nothing
        }

        public void partVisible(IWorkbenchPartReference partRef) {
        // do nothing
        }

        public void partHidden(IWorkbenchPartReference partRef) {
        // do nothing
        }

        public void partInputChanged(IWorkbenchPartReference partRef) {
        // do nothing
        }
    };
    getSite().getPage().addPartListener(partListener);
    workbenchListener = new IWorkbenchListener() {

        public boolean preShutdown(IWorkbench workbench, boolean forced) {
            return MdwPlugin.getActivePage().closeEditor(TaskTemplateEditor.this, true);
        }

        public void postShutdown(IWorkbench workbench) {
        // do nothing
        }
    };
    PlatformUI.getWorkbench().addWorkbenchListener(workbenchListener);
}
Also used : IWorkbenchListener(org.eclipse.ui.IWorkbenchListener) WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) TaskTemplateDocument(com.centurylink.mdw.task.TaskTemplateDocument) IFile(org.eclipse.core.resources.IFile) PageChangedEvent(org.eclipse.jface.dialogs.PageChangedEvent) IPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) PartInitException(org.eclipse.ui.PartInitException) IWorkbenchPartReference(org.eclipse.ui.IWorkbenchPartReference) WorkflowSelectionProvider(com.centurylink.mdw.plugin.designer.WorkflowSelectionProvider) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor) JSONException(org.json.JSONException) PartInitException(org.eclipse.ui.PartInitException) IPartListener2(org.eclipse.ui.IPartListener2) IWorkbench(org.eclipse.ui.IWorkbench) JSONObject(org.json.JSONObject) FileEditorInput(org.eclipse.ui.part.FileEditorInput) TaskVO(com.centurylink.mdw.model.value.task.TaskVO)

Example 7 with IWorkbenchListener

use of org.eclipse.ui.IWorkbenchListener in project gfm_viewer by satyagraha.

the class LogConsole method start.

public static void start(String name) {
    instance = new LogConsole(name);
    // due to JobManager shutting down we need to stop early
    PlatformUI.getWorkbench().addWorkbenchListener(new IWorkbenchListener() {

        @Override
        public boolean preShutdown(IWorkbench workbench, boolean forced) {
            stop();
            return true;
        }

        @Override
        public void postShutdown(IWorkbench workbench) {
        // no-op
        }
    });
}
Also used : IWorkbenchListener(org.eclipse.ui.IWorkbenchListener) IWorkbench(org.eclipse.ui.IWorkbench)

Example 8 with IWorkbenchListener

use of org.eclipse.ui.IWorkbenchListener in project azure-tools-for-java by Microsoft.

the class RedisPropertyView method init.

@Override
public void init(IViewSite site) throws PartInitException {
    super.init(site);
    IWorkbench workbench = PlatformUI.getWorkbench();
    final IWorkbenchPage activePage = workbench.getActiveWorkbenchWindow().getActivePage();
    workbench.addWorkbenchListener(new IWorkbenchListener() {

        @Override
        public boolean preShutdown(IWorkbench workbench, boolean forced) {
            activePage.hideView(RedisPropertyView.this);
            return true;
        }

        @Override
        public void postShutdown(IWorkbench workbench) {
        }
    });
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchListener(org.eclipse.ui.IWorkbenchListener) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 9 with IWorkbenchListener

use of org.eclipse.ui.IWorkbenchListener in project azure-tools-for-java by Microsoft.

the class WebAppBasePropertyEditor method init.

@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    setSite(site);
    setInput(input);
    if (input instanceof WebAppPropertyEditorInput) {
        WebAppPropertyEditorInput webappInput = (WebAppPropertyEditorInput) input;
        this.setPartName(webappInput.getName());
        this.subscriptionId = webappInput.getSubscriptionId();
        this.webAppId = webappInput.getId();
        this.webAppBasePropertyViewPresenter.onLoadWebAppProperty(subscriptionId, webAppId, null);
    } else if (input instanceof DeploymentSlotPropertyEditorInput) {
        DeploymentSlotPropertyEditorInput slotInput = (DeploymentSlotPropertyEditorInput) input;
        this.setPartName(slotInput.getName());
        this.subscriptionId = slotInput.getSubscriptionId();
        this.webAppId = slotInput.getWebappId();
        this.slotName = slotInput.getName();
        this.webAppBasePropertyViewPresenter.onLoadWebAppProperty(subscriptionId, webAppId, slotName);
    }
    IWorkbench workbench = PlatformUI.getWorkbench();
    final IWorkbenchPage activePage = workbench.getActiveWorkbenchWindow().getActivePage();
    workbench.addWorkbenchListener(new IWorkbenchListener() {

        @Override
        public boolean preShutdown(IWorkbench workbench, boolean forced) {
            activePage.closeEditor(WebAppBasePropertyEditor.this, true);
            return true;
        }

        @Override
        public void postShutdown(IWorkbench workbench) {
        }
    });
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchListener(org.eclipse.ui.IWorkbenchListener) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Aggregations

IWorkbenchListener (org.eclipse.ui.IWorkbenchListener)9 IWorkbench (org.eclipse.ui.IWorkbench)8 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)4 TaskVO (com.centurylink.mdw.model.value.task.TaskVO)1 WorkflowSelectionProvider (com.centurylink.mdw.plugin.designer.WorkflowSelectionProvider)1 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)1 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)1 TaskTemplateDocument (com.centurylink.mdw.task.TaskTemplateDocument)1 IFile (org.eclipse.core.resources.IFile)1 CatalogDescriptor (org.eclipse.epp.mpc.ui.CatalogDescriptor)1 SolutionInstallationInfo (org.eclipse.epp.mpc.ui.MarketplaceUrlHandler.SolutionInstallationInfo)1 IPageChangedListener (org.eclipse.jface.dialogs.IPageChangedListener)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 PageChangedEvent (org.eclipse.jface.dialogs.PageChangedEvent)1 IWizardPage (org.eclipse.jface.wizard.IWizardPage)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 TraverseEvent (org.eclipse.swt.events.TraverseEvent)1 TraverseListener (org.eclipse.swt.events.TraverseListener)1 Shell (org.eclipse.swt.widgets.Shell)1