Author: rob.stryker(a)jboss.com
Date: 2007-05-24 17:09:36 -0400 (Thu, 24 May 2007)
New Revision: 2071
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java
Log:
Wizards refactored for API changes
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java 2007-05-24
21:08:58 UTC (rev 2070)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java 2007-05-24
21:09:36 UTC (rev 2071)
@@ -3,6 +3,7 @@
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -23,19 +24,25 @@
public abstract class AbstractArchiveWizard extends WizardWithNotification implements
INewWizard {
private ArchiveInfoWizardPage firstPage;
private WizardPage pages[];
- protected IPath project;
+ protected IProject project;
protected Object selectedDestination;
protected IArchive existingPackage;
public AbstractArchiveWizard () {
- this.project = ProjectArchivesView.getInstance().getCurrentProject().getLocation();
+ this.project = ProjectArchivesView.getInstance().getCurrentProject();
}
public AbstractArchiveWizard (IArchive existingPackage) {
this.existingPackage = existingPackage;
- this.project = existingPackage.getProjectPath();
+ this.project = findProject(existingPackage.getProjectPath());
}
-
+ protected IProject findProject(IPath path) {
+ IProject[] list = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for( int i = 0; i < list.length; i++ )
+ if( list[i].getProject().getLocation().equals(path))
+ return list[i];
+ return null;
+ }
public void addPages() {
firstPage = new ArchiveInfoWizardPage(this, existingPackage);
addPage(firstPage);
@@ -85,13 +92,13 @@
}
parent = (IArchiveNode)destination;
} else {
- parent = ArchivesModel.instance().getRoot(project, true, monitor);
+ parent = ArchivesModel.instance().getRoot(project.getLocation(), true, monitor);
}
if( create )
ArchivesModel.instance().attach(parent, pkg, monitor);
else
- ArchivesModel.instance().saveModel(project, monitor);
+ ArchivesModel.instance().saveModel(project.getLocation(), monitor);
}
});
} catch (InvocationTargetException e) {
@@ -105,7 +112,7 @@
public void init(IWorkbench workbench, IStructuredSelection selection) {
if (selection == null) return;
- project = ProjectArchivesView.getInstance().getCurrentProject().getLocation();
+ project = ProjectArchivesView.getInstance().getCurrentProject();
Object selected;
if( selection.isEmpty() ) {
@@ -121,7 +128,7 @@
{
selectedDestination = selected;
}
- project = node.getProjectPath();
+ project = findProject(node.getProjectPath());
}
else if (selected instanceof IContainer)
{
@@ -129,7 +136,7 @@
}
else {
// find project
- String proj =
project.toOSString().substring(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString().length()+1);
+ String proj =
project.getLocation().toOSString().substring(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString().length()+1);
selectedDestination = ResourcesPlugin.getWorkspace().getRoot().getProject(proj);
}
@@ -146,7 +153,7 @@
public abstract ImageDescriptor getImageDescriptor();
public abstract String getArchiveExtension();
- public IPath getProject() {
+ public IProject getProject() {
return project;
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java 2007-05-24
21:08:58 UTC (rev 2070)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java 2007-05-24
21:09:36 UTC (rev 2071)
@@ -66,9 +66,9 @@
new Label(pkgNameComposite,
SWT.NONE).setImage(ArchivesSharedImages.getImage(ArchivesSharedImages.IMG_PACKAGE));
packageNameText = new Text(pkgNameComposite, SWT.BORDER);
- packageName = wizard.getProject().lastSegment() + "." +
wizard.getArchiveExtension();
+ packageName = wizard.getProject().getName() + "." +
wizard.getArchiveExtension();
packageNameText.setText(packageName);
- packageNameText.setSelection(0, wizard.getProject().lastSegment().length());
+ packageNameText.setSelection(0, wizard.getProject().getName().length());
expand(packageNameText);
GridData pkgNameData = new GridData(GridData.FILL_HORIZONTAL);
@@ -189,7 +189,7 @@
}
} else if (destination instanceof IContainer) {
IContainer container = (IContainer) destination;
- IArchive[] packages =
ArchivesModel.instance().getProjectArchives(wizard.getProject());
+ IArchive[] packages =
ArchivesModel.instance().getProjectArchives(wizard.getProject().getLocation());
if (packages != null) {
for( int i = 0; i < packages.length; i++ ) {
IArchive pkg = (IArchive) packages[i];
@@ -207,7 +207,7 @@
}
} else if (destination instanceof IPath) {
IPath path = (IPath) destination;
- IArchive[] packages =
ArchivesModel.instance().getProjectArchives(wizard.getProject());
+ IArchive[] packages =
ArchivesModel.instance().getProjectArchives(wizard.getProject().getLocation());
if (packages != null) {
for( int i = 0; i < packages.length; i++ ) {
IArchive pkg = (IArchive) packages[i];
Show replies by date