use of org.eclipse.jface.dialogs.IPageChangedListener 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.jface.dialogs.IPageChangedListener in project reddeer by eclipse.
the class CodeGenHandler method openCodeGen.
/**
* Method for open RedDeer CodeGen wizard and runs all necessary listeners
*
* @param window
*/
private void openCodeGen(IWorkbenchWindow window) {
log.info("Trying to open CodeGen wizard.");
Shell[] shell = ShellLookup.getInstance().getShells();
for (Shell sh : shell) {
if (sh.getText() == CodeGenWizard.WIZZARD_NAME)
return;
}
INewWizard wizard = new CodeGenWizard();
WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
dialog.setMinimumPageSize(150, 350);
dialog.addPageChangedListener(new IPageChangedListener() {
@Override
public void pageChanged(PageChangedEvent event) {
log.info("Page changed listener was started.");
Object selected = event.getSelectedPage();
if (selected instanceof PreviewPage) {
PreviewPage prev = ((PreviewPage) selected);
log.debug("Active page -> 'PreviewPage'.");
dialog.updateButtons();
} else if (selected instanceof MethodsPage) {
log.debug("Active page -> 'MethodsPage'.");
} else if (selected instanceof FirstPage) {
log.debug("Active page -> 'FirstPage'.");
((FirstPage) selected).dialogChanged();
dialog.updateButtons();
}
}
});
dialog.addPageChangingListener(new IPageChangingListener() {
@Override
public void handlePageChanging(PageChangingEvent event) {
log.info("Page changing listener was started.");
Object current = event.getCurrentPage();
Object target = event.getTargetPage();
if (current instanceof MethodsPage && target instanceof PreviewPage) {
log.debug("Switching between 'MethodsPage' -> 'PreviewPage'.");
MethodsPage meth = ((MethodsPage) current);
PreviewPage prev = ((PreviewPage) target);
log.info("Trying to generate code.");
CodeGenerator g = new CodeGenerator(meth.getClassBuilder().getClassName(), meth.getClassBuilder().getPackageName(), meth.getSelectedOptional());
log.info("Trying to update text area in 'PreviewPage'.");
g.setLastActiveShell(lastActiveShell);
prev.updateAreaContent(g.generateCode());
}
}
});
log.info("Opening WizardDialog -> " + wizard.getWindowTitle() + "...");
dialog.open();
}
use of org.eclipse.jface.dialogs.IPageChangedListener in project org.eclipse.rap by eclipse-rap.
the class PreferenceDialog method firePageChanged.
/**
* Notifies any selection changed listeners that the selected page
* has changed.
* Only listeners registered at the time this method is called are notified.
*
* @param event a selection changed event
*
* @see IPageChangedListener#pageChanged
*
* @since 1.0
*/
protected void firePageChanged(final PageChangedEvent event) {
Object[] listeners = pageChangedListeners.getListeners();
for (int i = 0; i < listeners.length; i++) {
final IPageChangedListener l = (IPageChangedListener) listeners[i];
SafeRunnable.run(new SafeRunnable() {
public void run() {
l.pageChanged(event);
}
});
}
}
use of org.eclipse.jface.dialogs.IPageChangedListener in project org.eclipse.rap by eclipse-rap.
the class PartListenerList2 method firePageChanged.
public void firePageChanged(final PageChangedEvent event) {
Object[] array = getListeners();
for (int i = 0; i < array.length; i++) {
final IPageChangedListener l;
if (array[i] instanceof IPageChangedListener) {
l = (IPageChangedListener) array[i];
} else {
continue;
}
SafeRunnable.run(new SafeRunnable() {
public void run() {
l.pageChanged(event);
}
});
}
}
use of org.eclipse.jface.dialogs.IPageChangedListener in project org.eclipse.rap by eclipse-rap.
the class FormEditor method firePageChanged.
private void firePageChanged(final PageChangedEvent event) {
Object[] listeners = pageListeners.getListeners();
for (int i = 0; i < listeners.length; ++i) {
final IPageChangedListener l = (IPageChangedListener) listeners[i];
SafeRunnable.run(new SafeRunnable() {
public void run() {
l.pageChanged(event);
}
});
}
}
Aggregations