Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-05-16 20:08:44 +0000
committerJean Michel-Lemieux2002-05-16 20:08:44 +0000
commit6e97ac4bfa0f79ffc55896b2396d61d7a8a511b0 (patch)
tree5f7e2af9b9d5f21e31c51a82eadfd5f18a6f3aca
parent6f559169d9da6f6154ed86545827af11e9fb8e9b (diff)
downloadeclipse.platform.team-6e97ac4bfa0f79ffc55896b2396d61d7a8a511b0.tar.gz
eclipse.platform.team-6e97ac4bfa0f79ffc55896b2396d61d7a8a511b0.tar.xz
eclipse.platform.team-6e97ac4bfa0f79ffc55896b2396d61d7a8a511b0.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ConfigureProjectWizardMainPage.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ConfigureTargetWizard.java213
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/MappingSelectionPage.java3
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteElement.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerView.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteSelectionPage.java27
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetProjectAction.java2
7 files changed, 208 insertions, 43 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ConfigureProjectWizardMainPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ConfigureProjectWizardMainPage.java
index a2634aa5b..5ead7e122 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ConfigureProjectWizardMainPage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ConfigureProjectWizardMainPage.java
@@ -64,7 +64,7 @@ public class ConfigureProjectWizardMainPage extends WizardPage {
/*
* @see WizardPage#canFlipToNextPage
*/
- public boolean canFlipToNextPage() {
+ public boolean canFlipToNextPage() {
return selectedWizard != null && selectedWizard.getPageCount() > 0;
}
/*
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 319c14908..0d096c563 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
@@ -2,38 +2,62 @@ package org.eclipse.team.internal.ui.target;
import java.lang.reflect.InvocationTargetException;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IPluginRegistry;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
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.jface.wizard.Wizard;
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.core.target.TargetProvider;
import org.eclipse.team.internal.ui.ConfigurationWizardElement;
-import org.eclipse.team.internal.ui.ConfigureProjectWizard;
import org.eclipse.team.internal.ui.ConfigureProjectWizardMainPage;
import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.UIConstants;
import org.eclipse.team.ui.IConfigurationWizard;
import org.eclipse.team.ui.TeamImages;
+import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.internal.model.AdaptableList;
-public class ConfigureTargetWizard extends ConfigureProjectWizard {
+public class ConfigureTargetWizard extends Wizard implements IConfigurationWizard {
+ protected IWorkbench workbench;
+ protected IProject project;
+ protected IConfigurationWizard wizard;
- public static final String MAPPING_PAGE_NAME = "mapping-page";
+ protected ConfigureProjectWizardMainPage mainPage;
+ private String pluginId = UIConstants.PLUGIN_ID;
- protected SiteSelectionPage siteSelectionPage = null;
- protected IWizardPage firstTargetPage = null;
+ protected final static String TAG_WIZARD = "wizard"; //$NON-NLS-1$
+ protected final static String TAG_DESCRIPTION = "description"; //$NON-NLS-1$
+ protected final static String ATT_NAME = "name"; //$NON-NLS-1$
+ protected final static String ATT_CLASS = "class"; //$NON-NLS-1$
+ protected final static String ATT_ICON = "icon"; //$NON-NLS-1$
+ protected final static String ATT_ID = "id"; //$NON-NLS-1$
public ConfigureTargetWizard() {
- super();
+ setNeedsProgressMonitor(true);
+ setWindowTitle(getWizardWindowTitle()); //$NON-NLS-1$
}
+ public static final String MAPPING_PAGE_NAME = "mapping-page";
+
+ protected SiteSelectionPage siteSelectionPage = null;
+ protected IWizardPage firstTargetPage = null;
+
/**
* @see ConfigureProjectWizard#getExtensionPoint()
*/
@@ -75,7 +99,17 @@ public class ConfigureTargetWizard extends ConfigureProjectWizard {
setWindowTitle(getWizardWindowTitle());
if(sites.length > 0 && project != null) {
- siteSelectionPage = new SiteSelectionPage("site-selection-page", Policy.bind("TargetSiteCreationWizard.siteSelectionPage"), TeamImages.getImageDescriptor(UIConstants.IMG_WIZBAN_SHARE)); //$NON-NLS-1$ //$NON-NLS-2$
+ Site site = null;
+ TargetProvider provider = null;
+ try {
+ provider = TargetManager.getProvider(project);
+ } catch (TeamException e) {
+ TeamUIPlugin.log(e.getStatus());
+ }
+ if(provider != null) {
+ site = provider.getSite();
+ }
+ siteSelectionPage = new SiteSelectionPage("site-selection-page", Policy.bind("TargetSiteCreationWizard.siteSelectionPage"), TeamImages.getImageDescriptor(UIConstants.IMG_WIZBAN_SHARE), site); //$NON-NLS-1$ //$NON-NLS-2$
addPage(siteSelectionPage);
}
@@ -140,6 +174,9 @@ public class ConfigureTargetWizard extends ConfigureProjectWizard {
return wizard.getStartingPage();
}
}
+ if(wizard != null) {
+ return wizard.getNextPage(page);
+ }
return super.getNextPage(page);
}
@@ -156,15 +193,16 @@ public class ConfigureTargetWizard extends ConfigureProjectWizard {
}
return false;
} else if(currentPage == siteSelectionPage) {
- return false;
+ if(siteSelectionPage.getSite() != null) {
+ return true;
+ }
}
MappingSelectionPage mappingPage = getMappingPage();
if(mappingPage != null && currentPage == mappingPage) {
return mappingPage.isPageComplete();
}
-
- if (wizard != null) {
+ if(wizard != null) {
return wizard.canFinish();
}
return super.canFinish();
@@ -174,26 +212,23 @@ public class ConfigureTargetWizard extends ConfigureProjectWizard {
* @see Wizard#performFinish
*/
public boolean performFinish() {
+ // handles finish on site selection page and on mapping page
IWizardPage currentPage = getContainer().getCurrentPage();
- 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;
- }
+ if(currentPage == siteSelectionPage || currentPage == getMappingPage()) {
+ Site site;
+ if(currentPage == siteSelectionPage) {
+ site = siteSelectionPage.getSite();
} else {
- return false;
+ site = getMappingPage().getSite();
+ }
+ IPath path = Path.EMPTY;
+ if(getMappingPage() != null) {
+ path = getMappingPage().getMapping();
}
+ setMapping(getContainer(), project, site, path);
+ return true;
}
+
// allow target wizard to finish
if (wizard != null) {
return wizard.performFinish();
@@ -201,11 +236,30 @@ public class ConfigureTargetWizard extends ConfigureProjectWizard {
return true;
}
- /**
- * @see IWizard#getPreviousPage(IWizardPage)
- */
- public IWizardPage getPreviousPage(IWizardPage page) {
- return super.getPreviousPage(page);
+ public static boolean setMapping(IWizardContainer container, IProject project, Site site, IPath path) {
+ if(validateSite(site, container)) {
+ if(TargetManager.getSite(site.getType(), site.getURL()) == null) {
+ TargetManager.addSite(site);
+ }
+ try {
+ TargetProvider provider = TargetManager.getProvider(project);
+ if(provider != null) {
+ if(! MessageDialog.openQuestion(container.getShell(),
+ "Question",
+ "'" + project.getName() + "' is already mapped to '" + provider.getSite().getURL().toExternalForm() +"'. Are you sure you want to change to another location?")) {
+ return false;
+ }
+ TargetManager.unmap(project);
+ }
+ TargetManager.map(project, site, path);
+ return true;
+ } catch (TeamException e) {
+ ErrorDialog.openError(container.getShell(), "Error", "Error mapping the project with this site", e.getStatus());
+ return false;
+ }
+ } else {
+ return false;
+ }
}
public static boolean validateSite(final Site site, final IWizardContainer container) {
@@ -223,6 +277,8 @@ public class ConfigureTargetWizard extends ConfigureProjectWizard {
message[0] = e.getStatus().getMessage();
code[0] = e.getStatus().getCode();
valid[0] = false;
+ } finally {
+ monitor.done();
}
}
});
@@ -234,11 +290,104 @@ public class ConfigureTargetWizard extends ConfigureProjectWizard {
}
if(! valid[0]) {
if(! MessageDialog.openQuestion(container.getShell(),
- "Error connecting to Site",
+ "Connection Error",
"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;
}
+
+ /**
+ * Returns the configuration wizards that are available for invocation.
+ *
+ * @return the available wizards
+ */
+ protected AdaptableList getAvailableWizards() {
+ AdaptableList result = new AdaptableList();
+ IPluginRegistry registry = Platform.getPluginRegistry();
+ IExtensionPoint point = registry.getExtensionPoint(pluginId, getExtensionPoint());
+ if (point != null) {
+ IExtension[] extensions = point.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ IConfigurationElement[] elements = extensions[i].getConfigurationElements();
+ for (int j = 0; j < elements.length; j++) {
+ IConfigurationElement element = elements[j];
+ if (element.getName().equals(TAG_WIZARD)) {
+ ConfigurationWizardElement wizard = createWizardElement(element);
+ if (wizard != null) {
+ result.add(wizard);
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+ /**
+ * Returns a new ConfigurationWizardElement configured according to the parameters
+ * contained in the passed Registry.
+ *
+ * May answer null if there was not enough information in the Extension to create
+ * an adequate wizard
+ *
+ * @param element the element for which to create a wizard element
+ * @return the wizard element for the given element
+ */
+ protected ConfigurationWizardElement createWizardElement(IConfigurationElement element) {
+ // WizardElements must have a name attribute
+ String nameString = element.getAttribute(ATT_NAME);
+ if (nameString == null) {
+ // Missing attribute
+ return null;
+ }
+ ConfigurationWizardElement result = new ConfigurationWizardElement(nameString);
+ if (initializeWizard(result, element)) {
+ // initialization was successful
+ return result;
+ }
+ return null;
+ }
+ /**
+ * Initialize the passed element's properties based on the contents of
+ * the passed registry. Answer a boolean indicating whether the element
+ * was able to be adequately initialized.
+ *
+ * @param element the element to initialize the properties for
+ * @param extension the registry to get properties from
+ * @return whether initialization was successful
+ */
+ protected boolean initializeWizard(ConfigurationWizardElement element, IConfigurationElement config) {
+ element.setID(config.getAttribute(ATT_ID));
+ String description = ""; //$NON-NLS-1$
+ IConfigurationElement [] children = config.getChildren(TAG_DESCRIPTION);
+ if (children.length >= 1) {
+ description = children[0].getValue();
+ }
+
+ element.setDescription(description);
+
+ // apply CLASS and ICON properties
+ element.setConfigurationElement(config);
+ String iconName = config.getAttribute(ATT_ICON);
+ if (iconName != null) {
+ IExtension extension = config.getDeclaringExtension();
+ element.setImageDescriptor(TeamImages.getImageDescriptorFromExtension(extension, iconName));
+ }
+ // ensure that a class was specified
+ if (element.getConfigurationElement() == null) {
+ // Missing attribute
+ return false;
+ }
+ setForcePreviousAndNextButtons(true);
+ return true;
+ }
+ /*
+ * Method declared on IConfigurationWizard
+ */
+ public void init(IWorkbench workbench, IProject project) {
+ this.workbench = workbench;
+ this.project = project;
+ }
} \ 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 5869f8f0e..4fe19dd44 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
@@ -100,11 +100,10 @@ public class MappingSelectionPage extends TargetWizardPage {
return this.path;
}
- /*
+ /**
* Attempt to set the viewer input.
* Do nothing if we don't have enough info yet to set it.
*/
-
private void setViewerInput() {
if(this.site == null || viewer == null)
return;
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 874bae2f5..82298b97c 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
@@ -22,7 +22,7 @@ public class SiteElement implements IWorkbenchAdapter, IAdaptable {
public SiteElement(Site site) {
this.site = site;
}
-
+
public SiteElement(Site site, boolean showFiles) {
this.site = site;
this.showFiles = showFiles;
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerView.java
index f154f7986..2a38135b5 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerView.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerView.java
@@ -62,7 +62,7 @@ public class SiteExplorerView extends ViewPart implements ISiteListener {
// Refresh (toolbar)
addSiteAction = new Action(Policy.bind("SiteExplorerViewaddSiteAction"), TeamImages.getImageDescriptor(ISharedImages.IMG_SITE_ELEMENT)) { //$NON-NLS-1$
public void run() {
- ConfigureProjectWizard wizard = new ConfigureTargetWizard();
+ ConfigureTargetWizard wizard = new ConfigureTargetWizard();
wizard.init(null, null);
WizardDialog dialog = new WizardDialog(shell, wizard);
dialog.open();
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteSelectionPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteSelectionPage.java
index 5f669f4f8..1f8bdf9fd 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteSelectionPage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteSelectionPage.java
@@ -7,13 +7,18 @@ package org.eclipse.team.internal.ui.target;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
@@ -33,10 +38,12 @@ public class SiteSelectionPage extends TargetWizardPage {
private Button useExistingRepo;
private Button useNewRepo;
private Site site;
+ private Site initialSiteSelection;
- public SiteSelectionPage(String pageName, String title, ImageDescriptor titleImage) {
+ public SiteSelectionPage(String pageName, String title, ImageDescriptor titleImage, Site site) {
super(pageName, title, titleImage);
setDescription(Policy.bind("SiteSelectionPage.description")); //$NON-NLS-1$
+ initialSiteSelection = site;
}
protected TableViewer createTable(Composite parent) {
@@ -64,7 +71,15 @@ public class SiteSelectionPage extends TargetWizardPage {
useExistingRepo = createRadioButton(composite, Policy.bind("SiteSelectionPage.useExisting"), 2); //$NON-NLS-1$
table = createTable(composite);
table.setContentProvider(new WorkbenchContentProvider());
- table.setLabelProvider(new WorkbenchLabelProvider());
+ table.setLabelProvider(new WorkbenchLabelProvider() {
+ protected String decorateText(String input, Object element) {
+ if(element.equals(new SiteElement(initialSiteSelection))) {
+ return super.decorateText(input, element) + " (current location)";
+ }
+ return super.decorateText(input, element);
+ }
+ });
+
table.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
SiteElement siteElement = (SiteElement)((IStructuredSelection)table.getSelection()).getFirstElement();
@@ -105,8 +120,12 @@ public class SiteSelectionPage extends TargetWizardPage {
if (sites.length == 0) {
useNewRepo.setSelection(true);
} else {
- useExistingRepo.setSelection(true);
- table.setSelection(new StructuredSelection(new SiteElement(sites[0])));
+ useExistingRepo.setSelection(true);
+ if(initialSiteSelection != null) {
+ table.setSelection(new StructuredSelection(new SiteElement(initialSiteSelection)));
+ } else {
+ table.setSelection(new StructuredSelection(new SiteElement(sites[0])));
+ }
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetProjectAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetProjectAction.java
index 389b7bb22..67f3092cc 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetProjectAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetProjectAction.java
@@ -50,6 +50,4 @@ public class TargetProjectAction extends TeamAction {
*/
return true;
}
-
-
}

Back to the top