use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.
the class TaskWizard method addSubWizardFragments.
private void addSubWizardFragments(WizardFragment fragment, List<WizardFragment> list) {
Iterator iterator = fragment.getChildFragments().iterator();
while (iterator.hasNext()) {
WizardFragment child = (WizardFragment) iterator.next();
list.add(child);
addSubWizardFragments(child, list);
}
}
use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.
the class TaskWizard method switchWizardFragment.
protected void switchWizardFragment(WizardFragment newFragment) {
List list = getAllWizardFragments();
int oldIndex = list.indexOf(currentFragment);
int newIndex = list.indexOf(newFragment);
if (oldIndex == newIndex)
return;
// safeExecuteTask(currentFragment, DEPARTURE);
if (currentFragment != null)
currentFragment.exit();
if (oldIndex < newIndex)
oldIndex++;
else
oldIndex--;
while (oldIndex != newIndex) {
WizardFragment fragment = (WizardFragment) list.get(oldIndex);
// safeExecuteTask(fragment, ARRIVAL);
// safeExecuteTask(fragment, DEPARTURE);
fragment.enter();
fragment.exit();
if (oldIndex < newIndex)
oldIndex++;
else
oldIndex--;
}
currentFragment = newFragment;
// safeExecuteTask(currentFragment, ARRIVAL);
currentFragment.enter();
}
use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.
the class TaskWizard method performFinish.
public boolean performFinish() {
if (currentFragment != null)
currentFragment.exit();
final WizardFragment cFragment = currentFragment;
final List list = getAllWizardFragments();
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
// enter & exit the remaining pages
int index = list.indexOf(cFragment);
while (index > 0 && index < list.size() - 1) {
final WizardFragment fragment = (WizardFragment) list.get(++index);
try {
Display.getDefault().syncExec(new Runnable() {
public void run() {
fragment.enter();
fragment.exit();
}
});
} catch (Exception e) {
if (Trace.WARNING) {
Trace.trace(Trace.STRING_WARNING, "Could not enter/exit page", e);
}
}
}
if (useJob()) {
class FinishWizardJob extends Job {
public FinishWizardJob() {
super(getJobTitle());
}
public boolean belongsTo(Object family) {
return "org.eclipse.wst.server.ui.family".equals(family);
}
public IStatus run(IProgressMonitor monitor2) {
try {
Iterator iterator = list.iterator();
while (iterator.hasNext()) executeTask((WizardFragment) iterator.next(), FINISH, monitor2);
} catch (CoreException ce) {
if (Trace.SEVERE) {
Trace.trace(Trace.STRING_SEVERE, "Error finishing wizard job", ce);
}
return new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, 0, ce.getLocalizedMessage(), null);
}
return Status.OK_STATUS;
}
}
FinishWizardJob job = new FinishWizardJob();
job.setUser(true);
job.schedule();
} else {
Iterator iterator = list.iterator();
while (iterator.hasNext()) executeTask((WizardFragment) iterator.next(), FINISH, monitor);
}
}
};
Throwable t = null;
try {
if (getContainer() != null)
getContainer().run(true, true, new WorkspaceRunnableAdapter(runnable));
else
runnable.run(new NullProgressMonitor());
return true;
} catch (InvocationTargetException te) {
if (Trace.SEVERE) {
Trace.trace(Trace.STRING_SEVERE, "Error finishing task wizard", te);
}
t = te.getCause();
} catch (InterruptedException interruptedEx) {
if (Trace.INFO) {
Trace.trace(Trace.STRING_INFO, "The task wizard was cancelled.", interruptedEx);
}
// return false since the request was canceled
return false;
} catch (Exception e) {
if (Trace.SEVERE) {
Trace.trace(Trace.STRING_SEVERE, "Error finishing task wizard 2", e);
}
t = e;
}
if (Trace.WARNING) {
Trace.trace(Trace.STRING_WARNING, "Error completing wizard", t);
}
if (t instanceof CoreException) {
EclipseUtil.openError(t.getLocalizedMessage(), ((CoreException) t).getStatus());
} else if (t instanceof NullPointerException)
EclipseUtil.openError("NullPointerException");
else
EclipseUtil.openError(t.getLocalizedMessage());
return false;
}
use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.
the class TaskWizard method getAllWizardFragments.
private List<WizardFragment> getAllWizardFragments() {
List<WizardFragment> list = new ArrayList<WizardFragment>();
list.add(rootFragment);
addSubWizardFragments(rootFragment, list);
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
WizardFragment fragment = (WizardFragment) iterator.next();
if ((!(fragment instanceof DownloadableAdapterLicenseWizardFragment)) && !taskModel.equals(fragment.getTaskModel()))
fragment.setTaskModel(taskModel);
}
return list;
}
use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.
the class TaskWizard method addPages.
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.IWizard#addPages()
*/
public void addPages() {
if (addingPages)
return;
try {
addingPages = true;
pages = new ArrayList<IWizardPage>();
Iterator<WizardFragment> iterator = getAllWizardFragments().iterator();
while (iterator.hasNext()) {
WizardFragment fragment = iterator.next();
TaskWizardPage page = getFragmentData(fragment);
if (fragment.hasComposite()) {
if (page != null)
addPage(page);
else {
TaskWizardPage page2 = new TaskWizardPage(fragment);
fragmentData.put(fragment, page2);
addPage(page2);
}
}
}
} catch (Exception e) {
if (Trace.SEVERE) {
Trace.trace(Trace.STRING_SEVERE, "Error adding fragments to wizard", e);
}
} finally {
addingPages = false;
}
}
Aggregations