Author: snjeza
Date: 2008-10-13 17:23:21 -0400 (Mon, 13 Oct 2008)
New Revision: 10814
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/wizard/NewProjectExamplesWizard.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java
Log:
JBIDE-2744 Creating Seam Web projects based on the Seam example applications
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 2008-10-13
21:09:51 UTC (rev 10813)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2008-10-13
21:23:21 UTC (rev 10814)
@@ -223,8 +223,10 @@
file.deleteOnExit();
BufferedOutputStream destination = new BufferedOutputStream(new
FileOutputStream(file));
IStatus result = getTransport().download(prefix,url.toExternalForm(), destination,
monitor);
- if (!result.isOK())
+ if (!result.isOK()) {
+ ProjectExamplesActivator.getDefault().getLog().log(result);
return null;
+ }
} catch (FileNotFoundException e) {
ProjectExamplesActivator.log(e);
return null;
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2008-10-13
21:09:51 UTC (rev 10813)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2008-10-13
21:23:21 UTC (rev 10814)
@@ -15,6 +15,9 @@
*
*/
import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import java.util.zip.ZipFile;
import org.eclipse.core.resources.IProject;
@@ -74,8 +77,8 @@
@Override
public boolean performFinish() {
- final Project project = page.getSelectedProject();
- if (project == null) {
+
+ if (page.getSelection() == null || page.getSelection().size() <= 0) {
return false;
}
WorkspaceJob job = new WorkspaceJob("Downloading...") {
@@ -83,15 +86,30 @@
@Override
public IStatus runInWorkspace(IProgressMonitor monitor)
throws CoreException {
- String url = project.getUrl();
- String name = project.getName();
- final File file = ProjectUtil.getProjectExamplesFile(url, name,
- ".zip",monitor);
- if (file == null) {
- return Status.CANCEL_STATUS;
+ IStructuredSelection selection= page.getSelection();
+ Iterator iterator = selection.iterator();
+ List<Project> projects = new ArrayList<Project>();
+ List<File> files = new ArrayList<File>();
+ while (iterator.hasNext()) {
+ Object object = iterator.next();
+ if (object instanceof Project) {
+ Project project = (Project) object;
+ String url = project.getUrl();
+ String name = project.getName();
+ final File file = ProjectUtil.getProjectExamplesFile(
+ url, name, ".zip", monitor);
+ if (file == null) {
+ return Status.CANCEL_STATUS;
+ }
+ projects.add(project);
+ files.add(file);
+ }
}
try {
- importProject(project, file, monitor);
+ int i = 0;
+ for (Project project:projects) {
+ importProject(project, files.get(i++), monitor);
+ }
} catch (final Exception e) {
Display.getDefault().syncExec(new Runnable() {
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 2008-10-13
21:09:51 UTC (rev 10813)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java 2008-10-13
21:23:21 UTC (rev 10814)
@@ -11,6 +11,7 @@
package org.jboss.tools.project.examples.wizard;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -40,7 +41,7 @@
*/
public class NewProjectExamplesWizardPage extends WizardPage {
- private Project selectedProject;
+ private IStructuredSelection selection;
public NewProjectExamplesWizardPage() {
super("org.jboss.tools.project.examples");
@@ -58,7 +59,7 @@
gd.widthHint= 225;
composite.setLayoutData(gd);
- TreeViewer viewer = new TreeViewer(composite,SWT.SINGLE);
+ TreeViewer viewer = new TreeViewer(composite,SWT.MULTI);
Tree tree = viewer.getTree();
tree.setLayoutData(new GridData(GridData.FILL_BOTH));
tree.setFont(parent.getFont());
@@ -97,23 +98,33 @@
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ selection = (IStructuredSelection) event.getSelection();
Object selected = selection.getFirstElement();
- if (selected instanceof Project) {
- selectedProject = (Project) selected;
+ if (selected instanceof Project && selection.size() == 1) {
+ Project selectedProject = (Project) selected;
text.setText(selectedProject.getDescription());
- setPageComplete(true);
projectName.setText(selectedProject.getName());
projectURL.setText(selectedProject.getUrl());
projectSize.setText(selectedProject.getSizeAsText());
} else {
- selectedProject=null;
+ Project selectedProject=null;
text.setText("");
projectName.setText("");
projectURL.setText("");
projectSize.setText("");
- setPageComplete(false);
}
+ boolean canFinish = false;
+ Iterator iterator = selection.iterator();
+ while (iterator.hasNext()) {
+ Object object = iterator.next();
+ if (object instanceof Project) {
+ canFinish=true;
+ } else {
+ canFinish=false;
+ break;
+ }
+ }
+ setPageComplete(canFinish);
}
});
@@ -180,7 +191,7 @@
}
- public Project getSelectedProject() {
- return selectedProject;
+ public IStructuredSelection getSelection() {
+ return selection;
}
}
Show replies by date