Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-05-16 13:40:50 -0400
committerJean Michel-Lemieux2002-05-16 13:40:50 -0400
commit5356bd63566d70895c8cc35bab27bb00a8abd1a9 (patch)
tree0ae31344f79ab6374dbd9bddf791261e8f79cc35
parentf85e1bc9ccb1154b23480afb172f6f1e804f1e3d (diff)
downloadeclipse.platform.team-5356bd63566d70895c8cc35bab27bb00a8abd1a9.tar.gz
eclipse.platform.team-5356bd63566d70895c8cc35bab27bb00a8abd1a9.tar.xz
eclipse.platform.team-5356bd63566d70895c8cc35bab27bb00a8abd1a9.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties4
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ConfigureTargetWizard.java125
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/MappingSelectionPage.java49
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteResourceElement.java10
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteElement.java10
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteRootsElement.java29
6 files changed, 161 insertions, 66 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
index 0fe94abd4..c20d6ab41 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
@@ -150,5 +150,5 @@ PutAction.working=Storing...
SiteExplorerViewaddSiteAction=Add a Site
SiteExplorerViewaddSiteActionTooltip=Add a Site
-MappingSelectionPage.description=Specify the location on the site where you want to deploy our resources.
-MappingSelectionPage.label=Enter the path:
+MappingSelectionPage.description=Specify the location on the site where you want to deploy your resources.
+MappingSelectionPage.label=Select the site or a folder:
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ConfigureTargetWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ConfigureTargetWizard.java
index 0d1dab321..319c14908 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ConfigureTargetWizard.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ConfigureTargetWizard.java
@@ -1,10 +1,16 @@
package org.eclipse.team.internal.ui.target;
+import java.lang.reflect.InvocationTargetException;
+
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.target.IRemoteTargetResource;
import org.eclipse.team.core.target.Site;
import org.eclipse.team.core.target.TargetManager;
import org.eclipse.team.internal.ui.ConfigurationWizardElement;
@@ -19,8 +25,9 @@ import org.eclipse.ui.internal.model.AdaptableList;
public class ConfigureTargetWizard extends ConfigureProjectWizard {
+ public static final String MAPPING_PAGE_NAME = "mapping-page";
+
protected SiteSelectionPage siteSelectionPage = null;
- protected MappingSelectionPage mappingSelectionPage = null;
protected IWizardPage firstTargetPage = null;
public ConfigureTargetWizard() {
@@ -67,9 +74,8 @@ public class ConfigureTargetWizard extends ConfigureProjectWizard {
AdaptableList wizards = getAvailableWizards();
setWindowTitle(getWizardWindowTitle());
- mappingSelectionPage = new MappingSelectionPage("mapping1", Policy.bind("TargetSiteCreationWizard.mappingPageTitle"), TeamImages.getImageDescriptor(UIConstants.IMG_WIZBAN_SHARE)); //$NON-NLS-1$ //$NON-NLS-2$
if(sites.length > 0 && project != null) {
- siteSelectionPage = new SiteSelectionPage("mapping2", Policy.bind("TargetSiteCreationWizard.siteSelectionPage"), TeamImages.getImageDescriptor(UIConstants.IMG_WIZBAN_SHARE)); //$NON-NLS-1$ //$NON-NLS-2$
+ siteSelectionPage = new SiteSelectionPage("site-selection-page", Policy.bind("TargetSiteCreationWizard.siteSelectionPage"), TeamImages.getImageDescriptor(UIConstants.IMG_WIZBAN_SHARE)); //$NON-NLS-1$ //$NON-NLS-2$
addPage(siteSelectionPage);
}
@@ -84,13 +90,10 @@ public class ConfigureTargetWizard extends ConfigureProjectWizard {
IWizardPage[] pages = wizard.getPages();
for (int i = 0; i < pages.length; i++) {
addPage(pages[i]);
- if(i == 0) {
- firstTargetPage = pages[i];
- }
}
}
} else {
- mainPage = new ConfigureProjectWizardMainPage("configurePage1", getWizardLabel(), TeamImages.getImageDescriptor(UIConstants.IMG_WIZBAN_SHARE), wizards); //$NON-NLS-1$
+ mainPage = new ConfigureProjectWizardMainPage("target-selection-page", getWizardLabel(), TeamImages.getImageDescriptor(UIConstants.IMG_WIZBAN_SHARE), wizards); //$NON-NLS-1$
mainPage.setDescription(getWizardDescription());
mainPage.setProject(project);
mainPage.setWorkbench(workbench);
@@ -103,20 +106,47 @@ public class ConfigureTargetWizard extends ConfigureProjectWizard {
}
public IWizardPage getNextPage(IWizardPage page) {
+ // This is what we really want to do, but will have to rework the
+ // target wizards first.
+ // if(getPage(page.getName()) != null) {
+ // // this is one of our pages
+ // // 1. site selection
+ // // 2. target selection
+ // // 3. mapping
+ // } else {
+ // // not one of our pages, is a target specific page
+ // IWizardPage nextPage;
+ // if(wizard != null) {
+ // nextPage = wizard.getNextPage(page);
+ // } else {
+ // nextPage = mainPage.getSelectedWizard().getNextPage(page);
+ // }
+ // if(nextPage != null) {
+ // return nextPage;
+ // } else {
+ // MappingSelectionPage mappingPage = getMappingPage();
+ // mappingPage.setPreviousPage(page);
+ // }
+ // }
if(page == siteSelectionPage) {
if(siteSelectionPage.getSite() != null) {
- mappingSelectionPage.setSite(siteSelectionPage.getSite());
- addPage(mappingSelectionPage);
- return mappingSelectionPage;
+ MappingSelectionPage mappingPage = getMappingPage();
+ mappingPage.setSite(siteSelectionPage.getSite());
+ mappingPage.setPreviousPage(page);
+ return mappingPage;
} else if(mainPage != null) {
return mainPage;
- } else if(firstTargetPage != null) {
- return firstTargetPage;
+ } else if(wizard != null) {
+ return wizard.getStartingPage();
}
}
return super.getNextPage(page);
}
+ private MappingSelectionPage getMappingPage() {
+ return (MappingSelectionPage)getPage(MAPPING_PAGE_NAME);
+ }
+
public boolean canFinish() {
// If we are on the first page, never allow finish unless the selected wizard has no pages.
IWizardPage currentPage = getContainer().getCurrentPage();
@@ -127,8 +157,11 @@ public class ConfigureTargetWizard extends ConfigureProjectWizard {
return false;
} else if(currentPage == siteSelectionPage) {
return false;
- } else if(currentPage == mappingSelectionPage) {
- return mappingSelectionPage.isPageComplete();
+ }
+
+ MappingSelectionPage mappingPage = getMappingPage();
+ if(mappingPage != null && currentPage == mappingPage) {
+ return mappingPage.isPageComplete();
}
if (wizard != null) {
@@ -142,19 +175,27 @@ public class ConfigureTargetWizard extends ConfigureProjectWizard {
*/
public boolean performFinish() {
IWizardPage currentPage = getContainer().getCurrentPage();
- if(currentPage == mappingSelectionPage) {
- IPath path = mappingSelectionPage.getMapping();
- Site site = siteSelectionPage.getSite();
- try {
- if(TargetManager.getProvider(project) != null) {
- TargetManager.unmap(project);
+ MappingSelectionPage mappingPage = getMappingPage();
+ // set mapping
+ if(mappingPage != null && currentPage == mappingPage) {
+ Site currentSite = mappingPage.getSite();
+ if(validateSite(currentSite, getContainer())) {
+ if(TargetManager.getSite(currentSite.getType(), currentSite.getURL()) ==null) {
+ TargetManager.addSite(currentSite);
+ }
+ try {
+ TargetManager.map(project, currentSite, mappingPage.getMapping());
+ return true;
+ } catch (TeamException e) {
+ ErrorDialog.openError(getShell(), "Error", "Error mapping the project with this site", e.getStatus());
+ return false;
}
- TargetManager.map(project, site, path);
- } catch (TeamException e) {
- ErrorDialog.openError(getContainer().getShell(), "Error", "Error associating project with target location", e.getStatus());
+ } else {
return false;
}
- } else if (wizard != null) {
+ }
+ // allow target wizard to finish
+ if (wizard != null) {
return wizard.performFinish();
}
return true;
@@ -166,4 +207,38 @@ public class ConfigureTargetWizard extends ConfigureProjectWizard {
public IWizardPage getPreviousPage(IWizardPage page) {
return super.getPreviousPage(page);
}
+
+ public static boolean validateSite(final Site site, final IWizardContainer container) {
+ final boolean[] valid = new boolean[] {true};
+ final String[] message = new String[] {"ok"};
+ final int[] code = new int[] {-1};
+ try {
+ container.run(true, false, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ try {
+ monitor.beginTask("Validating connection to Site...", monitor.UNKNOWN);
+ IRemoteTargetResource remote = site.getRemoteResource();
+ } catch(TeamException e) {
+ message[0] = e.getStatus().getMessage();
+ code[0] = e.getStatus().getCode();
+ valid[0] = false;
+ }
+ }
+ });
+ } catch (InvocationTargetException e) {
+ valid[0] = false;
+ message[0] = e.getTargetException().getMessage();
+ } catch (InterruptedException e) {
+ return false;
+ }
+ if(! valid[0]) {
+ if(! MessageDialog.openQuestion(container.getShell(),
+ "Error connecting to Site",
+ "An error occured connecting to '" + site.getURL().toExternalForm() + "'.\n\nCode: " + code[0] + "\nMessage: " + message[0] + "\n\nDo you still want to keep this connection?")) {
+ return false;
+ }
+ }
+ return true;
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/MappingSelectionPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/MappingSelectionPage.java
index 64881f039..5869f8f0e 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/MappingSelectionPage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/MappingSelectionPage.java
@@ -11,6 +11,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.swt.SWT;
@@ -41,14 +42,19 @@ public class MappingSelectionPage extends TargetWizardPage {
this.site = site;
}
+ public Site getSite() {
+ return site;
+ }
+
public void createControl(Composite p) {
Composite composite = createComposite(p, 1);
- viewer = new TreeViewer(composite, SWT.BORDER | SWT.MULTI);
+
+ createLabel(composite, Policy.bind("MappingSelectionPage.label")); //$NON-NLS-1$
+
+ viewer = new TreeViewer(composite, SWT.BORDER | SWT.SINGLE);
GridData data = new GridData (GridData.FILL_BOTH);
viewer.getTree().setLayoutData(data);
-
-
viewer.setContentProvider(new SiteLazyContentProvider());
viewer.setLabelProvider(new WorkbenchLabelProvider());
viewer.setSorter(new SiteViewSorter());
@@ -58,15 +64,6 @@ public class MappingSelectionPage extends TargetWizardPage {
}
});
setViewerInput();
-
- textPath = createTextField(composite);
-
- textPath.addListener(SWT.Modify, new Listener() {
- public void handleEvent(Event e) {
- MappingSelectionPage.this.path = new Path(textPath.getText());
- }
- });
-
setControl(composite);
setPageComplete(true);
}
@@ -90,11 +87,9 @@ public class MappingSelectionPage extends TargetWizardPage {
TeamUIPlugin.handle(e);
return;
}
-
this.path = UrlUtil.getTrailingPath(
remoteResourceURL,
this.site.getURL());
- textPath.setText(this.path.toString());
return;
}
}
@@ -104,14 +99,6 @@ public class MappingSelectionPage extends TargetWizardPage {
public IPath getMapping() {
return this.path;
}
- /**
- * @see IWizardPage#setPreviousPage(IWizardPage)
- */
- public void setPreviousPage(IWizardPage page) {
- if(viewer!=null) {
- setViewerInput();
- }
- }
/*
* Attempt to set the viewer input.
@@ -119,13 +106,19 @@ public class MappingSelectionPage extends TargetWizardPage {
*/
private void setViewerInput() {
- if(this.site == null)
+ if(this.site == null || viewer == null)
return;
- try {
- viewer.setInput(new RemoteResourceElement(this.site.getRemoteResource(), false));
- } catch (TeamException e) {
- TeamUIPlugin.log(e.getStatus());
- }
+ viewer.setInput(new SiteRootsElement(new Site[] {site}, false /* show only folders */));
}
+ /**
+ * @see IDialogPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ if(visible) {
+ setViewerInput();
+ viewer.setSelection(new StructuredSelection(new SiteElement(site)));
+ }
+ super.setVisible(visible);
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteResourceElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteResourceElement.java
index 6e8f4d443..1882acd0b 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteResourceElement.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteResourceElement.java
@@ -18,15 +18,15 @@ import org.eclipse.ui.model.IWorkbenchAdapter;
public class RemoteResourceElement implements IWorkbenchAdapter, IAdaptable {
IRemoteTargetResource remote;
- boolean showOnlyFolder = false;
+ boolean showFiles = true;
public RemoteResourceElement(IRemoteTargetResource remote) {
this.remote = remote;
}
- public RemoteResourceElement(IRemoteTargetResource remote, boolean showOnlyFolders) {
+ public RemoteResourceElement(IRemoteTargetResource remote, boolean showFiles) {
this.remote = remote;
- this.showOnlyFolder = showOnlyFolders;
+ this.showFiles = showFiles;
}
public IRemoteTargetResource getRemoteResource() {
@@ -49,8 +49,8 @@ public class RemoteResourceElement implements IWorkbenchAdapter, IAdaptable {
int n = 0;
for (int i = 0; i < children.length; i++) {
IRemoteTargetResource child = (IRemoteTargetResource)children[i];
- if(!child.isContainer() || !showOnlyFolder) {
- remoteElements.add(new RemoteResourceElement(child, showOnlyFolder));
+ if(child.isContainer() || showFiles) {
+ remoteElements.add(new RemoteResourceElement(child, showFiles));
}
}
result[0] = (RemoteResourceElement[])remoteElements.toArray(new RemoteResourceElement[remoteElements.size()]);
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteElement.java
index ac6701ed1..874bae2f5 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteElement.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteElement.java
@@ -16,12 +16,18 @@ import org.eclipse.team.ui.TeamImages;
import org.eclipse.ui.model.IWorkbenchAdapter;
public class SiteElement implements IWorkbenchAdapter, IAdaptable {
- Site site;
+ private Site site;
+ private boolean showFiles = true;
public SiteElement(Site site) {
this.site = site;
}
+ public SiteElement(Site site, boolean showFiles) {
+ this.site = site;
+ this.showFiles = showFiles;
+ }
+
public Site getSite() {
return site;
}
@@ -37,7 +43,7 @@ public class SiteElement implements IWorkbenchAdapter, IAdaptable {
public Object[] getChildren(Object o) {
try {
- return new RemoteResourceElement(site.getRemoteResource()).getChildren(this);
+ return new RemoteResourceElement(site.getRemoteResource(), showFiles).getChildren(this);
} catch (TeamException e) {
TeamUIPlugin.handle(e);
return new Object[0];
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteRootsElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteRootsElement.java
index 337163f27..142f7afdc 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteRootsElement.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteRootsElement.java
@@ -7,24 +7,45 @@ import org.eclipse.team.core.target.TargetManager;
import org.eclipse.ui.model.IWorkbenchAdapter;
public class SiteRootsElement implements IWorkbenchAdapter, IAdaptable {
+ private Site[] sites = null;
+ private boolean showFiles = true;
+
+ public SiteRootsElement(Site[] sites, boolean showFiles) {
+ this.sites = sites;
+ this.showFiles = showFiles;
+ }
+
+ public SiteRootsElement() {
+ this.sites = null;
+ }
+
public ImageDescriptor getImageDescriptor(Object object) {
return null;
}
+
public Object[] getChildren(Object o) {
- Site[] sites = TargetManager.getSites();
- SiteElement[] siteElements = new SiteElement[sites.length];
- for (int i = 0; i < sites.length; i++) {
- siteElements[i] = new SiteElement(sites[i]);
+ Site[] childSites;
+ if(sites == null) {
+ childSites = TargetManager.getSites();
+ } else {
+ childSites = sites;
+ }
+ SiteElement[] siteElements = new SiteElement[childSites.length];
+ for (int i = 0; i < childSites.length; i++) {
+ siteElements[i] = new SiteElement(childSites[i], showFiles);
}
return siteElements;
}
+
public String getLabel(Object o) {
return null;
}
+
public Object getAdapter(Class adapter) {
if (adapter == IWorkbenchAdapter.class) return this;
return null;
}
+
public Object getParent(Object o) {
return null;
}

Back to the top