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);
}
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
}
});
}
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) {
}
});
}
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) {
}
});
}
Aggregations