Author: scabanovich
Date: 2007-10-12 06:03:37 -0400 (Fri, 12 Oct 2007)
New Revision: 4143
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/appregister/AppRegisterWizard.java
Log:
JBIDE-535
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/appregister/AppRegisterWizard.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/appregister/AppRegisterWizard.java 2007-10-12
09:48:06 UTC (rev 4142)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/appregister/AppRegisterWizard.java 2007-10-12
10:03:37 UTC (rev 4143)
@@ -15,11 +15,18 @@
import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.wizard.*;
import org.jboss.tools.common.meta.action.SpecialWizard;
import org.jboss.tools.common.meta.key.WizardKeys;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.impl.FileSystemImpl;
+import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.reporting.ProblemReportingHelper;
import org.jboss.tools.common.model.ui.*;
@@ -38,24 +45,65 @@
}
public boolean performFinish() {
- try {
- IProject p = EclipseResourceUtil.getProject(object);
- String contextRoot = registry.getApplicationName();
- if(!contextRoot.equals(ComponentUtilities.getServerContextRoot(p))) {
- ComponentUtilities.setServerContextRoot(p, contextRoot);
+ Job job = new RegisterServerJob();
+ job.schedule(100);
+ return true;
+ }
+
+ class RegisterServerJob extends Job {
+
+ public RegisterServerJob() {
+ super("Register in Server");
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ ModelPlugin.getWorkspace().run(new WR(), monitor);
+ } catch (Exception e) {
+ WebUiPlugin.getPluginLog().logError(e);
}
- IServer[] is = registry.getTargetServers();
- for (int i = 0; i < is.length; i++) {
- RegistrationHelper.register(p, is[i]);
+ return Status.OK_STATUS;
+ }
+ }
+
+ class WR implements IWorkspaceRunnable {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ try {
+ register(monitor);
+ } catch (Exception e) {
+ WebUiPlugin.getPluginLog().logError(e);
}
- object.getModel().changeObjectAttribute(object, "application name",
registry.getApplicationName());
- } catch (Exception ex) {
- ProblemReportingHelper.reportProblem(WebUiPlugin.PLUGIN_ID, "Exception caught in
AppRegisterWizard.performFinish(): " + ex.getMessage(), ex);
- return false;
- }
- return true;
+ }
+
}
+ private void register(IProgressMonitor monitor) throws Exception {
+ if(monitor != null) monitor.beginTask("", 100);
+ if(monitor != null) monitor.worked(5);
+
+ IServer[] servers = registry.getTargetServers();
+ int step = 70;
+ if(monitor != null) {
+ monitor.worked(5);
+ step = step / (2 * servers.length + 1);
+ }
+ IProject p = EclipseResourceUtil.getProject(object);
+ String contextRoot = registry.getApplicationName();
+ if(!contextRoot.equals(ComponentUtilities.getServerContextRoot(p))) {
+ ComponentUtilities.setServerContextRoot(p, contextRoot);
+ }
+ for (int i = 0; i < servers.length; i++) {
+ if(monitor != null) {
+ monitor.worked(step);
+ monitor.subTask(servers[i].getName());
+ }
+ RegistrationHelper.register(p, servers[i]);
+ if(monitor != null) monitor.worked(step);
+ }
+ object.getModel().changeObjectAttribute(object, "application name",
registry.getApplicationName());
+ if(monitor != null) monitor.worked(20);
+ }
+
public String getWebRootLocation() {
XModelObject fs = object.getModel().getByPath("FileSystems/WEB-ROOT");
///if(fs == null) fs = getRootFileSystemForModule(model, "");
Show replies by date