Author: snjeza
Date: 2010-12-06 04:55:37 -0500 (Mon, 06 Dec 2010)
New Revision: 27182
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/fixes/WTPRuntimeFix.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java
Log:
JBIDE-7816 NewProjectExamplesWizard blocks UI for a long time!
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java 2010-12-06
07:57:39 UTC (rev 27181)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java 2010-12-06
09:55:37 UTC (rev 27182)
@@ -77,6 +77,7 @@
public static String ProjectUtil_Invalid_property;
public static String ProjectUtil_Invalid_URL;
public static String ProjectUtil_Invalid_welcome_element;
+ public static String ProjectUtil_Parsing_project_description_files;
public static String ProjectUtil_Test;
public static String SeamRuntimeFix_Invalid_seam_runtime_fix;
public static String SiteDialog_Add_Project_Example_Site;
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/fixes/WTPRuntimeFix.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/fixes/WTPRuntimeFix.java 2010-12-06
07:57:39 UTC (rev 27181)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/fixes/WTPRuntimeFix.java 2010-12-06
09:55:37 UTC (rev 27182)
@@ -45,7 +45,7 @@
private static final String ESB = "esb"; //$NON-NLS-1$
private static final String PORTLET = "portlet"; //$NON-NLS-1$
private static final String REQUIRED_COMPONENTS = "required-components";
//$NON-NLS-1$
- private static final IPath ESB_SERVER_SUPPLIED_CONTAINER_PATH = new
Path("org.jboss.esb.runtime.classpath/server.supplied");
+ private static final IPath ESB_SERVER_SUPPLIED_CONTAINER_PATH = new
Path("org.jboss.esb.runtime.classpath/server.supplied"); //$NON-NLS-1$
public boolean canFix(Project project, ProjectFix fix) {
if (!ProjectFix.WTP_RUNTIME.equals(fix.getType())) {
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties 2010-12-06
07:57:39 UTC (rev 27181)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties 2010-12-06
09:55:37 UTC (rev 27182)
@@ -64,6 +64,7 @@
ProjectUtil_Invalid_property=Invalid property.
ProjectUtil_Invalid_URL=Invalid URL\: {0}
ProjectUtil_Invalid_welcome_element=The welcome element has invalid the url attribute
+ProjectUtil_Parsing_project_description_files=Parsing project description files...
ProjectUtil_Test=Test
NewProjectExamplesWizardPage_Site=Site\:
SeamRuntimeFix_Invalid_seam_runtime_fix=Invalid Seam runtime fix in {0}.
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2010-12-06
07:57:39 UTC (rev 27181)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2010-12-06
09:55:37 UTC (rev 27182)
@@ -23,7 +23,6 @@
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -209,7 +208,8 @@
return null;
}
- public static List<Category> getProjects() {
+ public static List<Category> getProjects(IProgressMonitor monitor) {
+ monitor.setTaskName(Messages.ProjectUtil_Parsing_project_description_files);
Set<ProjectExampleSite> sites = getSites();
List<Category> list = new ArrayList<Category>();
invalidSites.clear();
@@ -220,13 +220,22 @@
if (!showExperimentalSites && site.isExperimental()) {
continue;
}
+ if (monitor.isCanceled()) {
+ invalidSites.add(site);
+ continue;
+ }
File file = getProjectExamplesFile(site.getUrl(),
- "projectExamples", ".xml", null); //$NON-NLS-1$ //$NON-NLS-2$
+ "projectExamples", ".xml", monitor); //$NON-NLS-1$
//$NON-NLS-2$
+ if (monitor.isCanceled()) {
+ invalidSites.add(site);
+ continue;
+ }
if (file == null || !file.exists() || !file.isFile()) {
ProjectExamplesActivator.log(NLS.bind(Messages.ProjectUtil_Invalid_URL,site.getUrl().toString()));
invalidSites.add(site);
continue;
}
+
DocumentBuilderFactory dbf = DocumentBuilderFactory
.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
@@ -419,10 +428,19 @@
return null;
} else {
try {
+ if (monitor.isCanceled()) {
+ return null;
+ }
file = File.createTempFile(prefix, suffix);
file.deleteOnExit();
+ if (monitor.isCanceled()) {
+ return null;
+ }
BufferedOutputStream destination = new BufferedOutputStream(
new FileOutputStream(file));
+ if (monitor.isCanceled()) {
+ return null;
+ }
IStatus result = getTransport().download(prefix,
url.toExternalForm(), destination, monitor);
if (!result.isOK()) {
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java 2010-12-06
07:57:39 UTC (rev 27181)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java 2010-12-06
09:55:37 UTC (rev 27182)
@@ -11,6 +11,7 @@
package org.jboss.tools.project.examples.wizard;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
@@ -18,8 +19,11 @@
import java.util.Set;
import java.util.TreeSet;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.util.Geometry;
@@ -80,6 +84,7 @@
private PageBook notesPageBook;
private Composite noteEmptyComposite;
private Composite noteComposite;
+ private List<Category> categories;
public NewProjectExamplesWizardPage() {
super("org.jboss.tools.project.examples"); //$NON-NLS-1$
@@ -116,8 +121,7 @@
new Label(siteComposite,SWT.NONE).setText(Messages.NewProjectExamplesWizardPage_Site);
siteCombo = new Combo(siteComposite,SWT.READ_ONLY);
siteCombo.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
- String[] items = getItems();
- siteCombo.setItems(items);
+
siteCombo.setText(ProjectExamplesActivator.ALL_SITES);
new Label(composite,SWT.NONE).setText(Messages.NewProjectExamplesWizardPage_Projects);
@@ -141,7 +145,6 @@
viewer.setLabelProvider(new ProjectLabelProvider());
viewer.setContentProvider(new ProjectContentProvider());
- refresh(viewer, false);
final SiteFilter siteFilter = new SiteFilter();
viewer.addFilter(siteFilter);
@@ -303,6 +306,7 @@
setControl(composite);
configureSizeAndLocation();
+ refresh(viewer, false);
}
private void configureSizeAndLocation() {
@@ -409,10 +413,22 @@
AdaptableList input = new AdaptableList(getCategories(show));
viewer.setInput(input);
viewer.refresh();
+ String[] items = getItems();
+ siteCombo.setItems(items);
}
private List<Category> getCategories(boolean show) {
- List<Category> categories = ProjectUtil.getProjects();
+ IRunnableWithProgress op = new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor) {
+ categories = ProjectUtil.getProjects(monitor);
+ }
+ };
+ try {
+ new ProgressMonitorDialog(getShell()).run(true, true, op);
+ } catch (Exception e) {
+ ProjectExamplesActivator.log(e);
+ }
HashSet<ProjectExampleSite> invalidSites = ProjectUtil.getInvalidSites();
boolean showInvalidSites =
ProjectExamplesActivator.getDefault().getPreferenceStore().getBoolean(ProjectExamplesActivator.SHOW_INVALID_SITES);
if (invalidSites.size() > 0 && showInvalidSites && show) {
@@ -428,7 +444,7 @@
}
private String[] getItems() {
- List<Category> categories = getCategories(true);
+ //List<Category> categories = getCategories(true);
Set<String> sites = new TreeSet<String>();
sites.add(ProjectExamplesActivator.ALL_SITES);
for (Category category:categories) {