Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-02-03 15:41:13 +0000
committerMichael Valenta2003-02-03 15:41:13 +0000
commit8e6840762670f6486f469133305cc14ab8ad9125 (patch)
tree9794334de5503065c4ff6feaa8b12b33afe0e24f
parentcc8633cb5d86ea617d55a2451745f5a689d859b0 (diff)
downloadeclipse.platform.team-8e6840762670f6486f469133305cc14ab8ad9125.tar.gz
eclipse.platform.team-8e6840762670f6486f469133305cc14ab8ad9125.tar.xz
eclipse.platform.team-8e6840762670f6486f469133305cc14ab8ad9125.zip
Added ability to create working sets on project set import
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ImportProjectSetMainPage.java93
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ProjectSetImportWizard.java38
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties8
3 files changed, 130 insertions, 9 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ImportProjectSetMainPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ImportProjectSetMainPage.java
index 803194dc3..65df4f04a 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ImportProjectSetMainPage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ImportProjectSetMainPage.java
@@ -15,21 +15,35 @@ import java.io.File;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.help.WorkbenchHelp;
public class ImportProjectSetMainPage extends TeamWizardPage {
Text fileText;
String file = ""; //$NON-NLS-1$
Button browseButton;
+ Button createWorkingSetButton;
+ Text workingSetNameField;
+ private boolean createWorkingSet = false;
+ private String workingSetName = ""; //$NON-NLS-1$
+
+ // constants
+ private static final int SIZING_TEXT_FIELD_WIDTH = 80;
+
public ImportProjectSetMainPage(String pageName, String title, ImageDescriptor titleImage) {
super(pageName, title, titleImage);
}
@@ -84,15 +98,76 @@ public class ImportProjectSetMainPage extends TeamWizardPage {
}
});
+ createWorkinSetCreationArea(inner, 3);
setControl(composite);
updateEnablement();
}
+ /**
+ * Method createWorkinSetCreationArea.
+ * @param inner
+ */
+ private void createWorkinSetCreationArea(Composite composite, int numColumns) {
+
+ createWorkingSetButton = new Button(composite, SWT.CHECK | SWT.RIGHT);
+ createWorkingSetButton.setText(Policy.bind("ImportProjectSetMainPage.createWorkingSetLabel")); //$NON-NLS-1$
+ createWorkingSetButton.setSelection(createWorkingSet);
+ GridData data = new GridData();
+ data.horizontalSpan = numColumns;
+ createWorkingSetButton.setLayoutData(data);
+
+ final Label label = new Label(composite, SWT.NONE);
+ label.setText(Policy.bind("ImportProjectSetMainPage.workingSetLabel")); //$NON-NLS-1$
+ data = new GridData();
+ data.horizontalSpan = 1;
+ label.setLayoutData(data);
+ label.setEnabled(createWorkingSet);
+
+ workingSetNameField = new Text(composite, SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = SIZING_TEXT_FIELD_WIDTH;
+ data.horizontalSpan = 1;
+ workingSetNameField.setLayoutData(data);
+ workingSetNameField.setEnabled(createWorkingSet);
+
+ createWorkingSetButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ createWorkingSet = createWorkingSetButton.getSelection();
+ label.setEnabled(createWorkingSet);
+ workingSetNameField.setEnabled(createWorkingSet);
+ updateEnablement();
+ }
+ });
+ workingSetNameField.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateEnablement();
+ }
+ });
+ }
+
+ private boolean validateWorkingSetName() {
+ if (createWorkingSet) {
+ workingSetName = workingSetNameField.getText();
+ if (workingSetName.length() == 0) {
+ setMessage(Policy.bind("ImportProjectSetMainPage.workingSetNameEmpty"), ERROR); //$NON-NLS-1$
+ return false;
+ } else {
+ // todo: verify name doesn't already exist
+ IWorkingSet existingSet = TeamUIPlugin.getPlugin().getWorkbench().getWorkingSetManager().getWorkingSet(workingSetName);
+ if (existingSet != null) {
+ setMessage(Policy.bind("ImportProjectSetMainPage.workingSetNameExists"), WARNING); //$NON-NLS-1$
+ return true;
+ }
+ }
+ }
+ setMessage(null);
+ return true;
+ }
+
private void updateEnablement() {
boolean complete;
-
+ setMessage(null);
if (file.length() == 0) {
- setMessage(null);
complete = false;
} else {
// See if the file exists
@@ -104,12 +179,9 @@ public class ImportProjectSetMainPage extends TeamWizardPage {
setMessage(Policy.bind("ImportProjectSetMainPage.You_have_specified_a_folder_5"), ERROR); //$NON-NLS-1$
complete = false;
} else {
- complete = true;
+ complete = validateWorkingSetName();
}
}
- if (complete) {
- setMessage(null);
- }
setPageComplete(complete);
}
@@ -127,4 +199,13 @@ public class ImportProjectSetMainPage extends TeamWizardPage {
fileText.setFocus();
}
}
+
+ /**
+ * @return String
+ */
+ public String getWorkingSetName() {
+ if (!createWorkingSet) return null;
+ return workingSetName;
+ }
+
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ProjectSetImportWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ProjectSetImportWizard.java
index a24545ab4..ceb4fbd00 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ProjectSetImportWizard.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ProjectSetImportWizard.java
@@ -14,13 +14,17 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.xerces.parsers.SAXParser;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.team.core.IProjectSetSerializer;
@@ -29,6 +33,8 @@ import org.eclipse.team.core.TeamException;
import org.eclipse.team.ui.TeamImages;
import org.eclipse.ui.IImportWizard;
import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -48,6 +54,16 @@ public class ProjectSetImportWizard extends Wizard implements IImportWizard {
addPage(mainPage);
}
public boolean performFinish() {
+
+ // check if the desired working set exists
+ final String workingSetName = mainPage.getWorkingSetName();
+ if (workingSetName != null) {
+ IWorkingSet existingSet = TeamUIPlugin.getPlugin().getWorkbench().getWorkingSetManager().getWorkingSet(workingSetName);
+ if (existingSet != null &&
+ !MessageDialog.openConfirm(getShell(), Policy.bind("ProjectSetImportWizard.workingSetExistsTitle"), Policy.bind("ProjectSetImportWizard.workingSetExistsMessage", workingSetName))) //$NON-NLS-1$ //$NON-NLS-2$
+ return false;
+ }
+
final boolean[] result = new boolean[] {false};
try {
getContainer().run(true, true, new WorkspaceModifyOperation() {
@@ -65,10 +81,13 @@ public class ProjectSetImportWizard extends Wizard implements IImportWizard {
parser.parse(source);
Map map = handler.getReferences();
+ List newProjects = new ArrayList();
if (map.size() == 0 && handler.isVersionOne) {
IProjectSetSerializer serializer = Team.getProjectSetSerializer("versionOneSerializer"); //$NON-NLS-1$
if (serializer != null) {
- serializer.addToWorkspace(new String[0], filename, getShell(), monitor);
+ IProject[] projects = serializer.addToWorkspace(new String[0], filename, getShell(), monitor);
+ if (projects != null)
+ newProjects.addAll(Arrays.asList(projects));
}
} else {
Iterator it = map.keySet().iterator();
@@ -77,10 +96,14 @@ public class ProjectSetImportWizard extends Wizard implements IImportWizard {
List references = (List)map.get(id);
IProjectSetSerializer serializer = Team.getProjectSetSerializer(id);
if (serializer != null) {
- serializer.addToWorkspace((String[])references.toArray(new String[references.size()]), filename, getShell(), monitor);
+ IProject[] projects = serializer.addToWorkspace((String[])references.toArray(new String[references.size()]), filename, getShell(), monitor);
+ if (projects != null)
+ newProjects.addAll(Arrays.asList(projects));
}
}
}
+ if (workingSetName != null)
+ createWorkingSet(workingSetName, (IProject[]) newProjects.toArray(new IProject[newProjects.size()]));
result[0] = true;
} catch (IOException e) {
throw new InvocationTargetException(e);
@@ -117,6 +140,17 @@ public class ProjectSetImportWizard extends Wizard implements IImportWizard {
return result[0];
}
+ private void createWorkingSet(String workingSetName, IProject[] projects) {
+ IWorkingSetManager manager = TeamUIPlugin.getPlugin().getWorkbench().getWorkingSetManager();
+ IWorkingSet oldSet = manager.getWorkingSet(workingSetName);
+ if (oldSet == null) {
+ IWorkingSet newSet = manager.createWorkingSet(workingSetName, projects);
+ manager.addWorkingSet(newSet);
+ }else {
+ oldSet.setElements(projects);
+ }
+ }
+
public void init(IWorkbench workbench, IStructuredSelection selection) {
}
}
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 bb1e461d5..a1e2333cb 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
@@ -108,10 +108,14 @@ ExportProjectSetMainPage.Project_Set_File_Name__3=Select the export destination:
ExportProjectSetMainPage.Browse_4=B&rowse...
ExportProjectSetMainPage.You_have_specified_a_folder_5=You have specified a folder
-ImportProjectSetMainPage.Project_Set_File_Name__2=&File name:
+ImportProjectSetMainPage.Project_Set_File_Name__2=F&ile name:
ImportProjectSetMainPage.Browse_3=B&rowse...
ImportProjectSetMainPage.The_specified_file_does_not_exist_4=The specified file does not exist
ImportProjectSetMainPage.You_have_specified_a_folder_5=You have specified a folder
+ImportProjectSetMainPage.workingSetNameEmpty=The working set name must not be empty
+ImportProjectSetMainPage.workingSetNameExists=The specified working set already exists
+ImportProjectSetMainPage.createWorkingSetLabel=&Create a working set containing the imported projects
+ImportProjectSetMainPage.workingSetLabel=&Working Set Name:
ProjectSetContentHandler.Element_provider_must_be_contained_in_element_psf_4=Element provider must be contained in element psf
ProjectSetContentHandler.Element_project_must_be_contained_in_element_provider_7=Element project must be contained in element provider
@@ -126,6 +130,8 @@ ProjectSetExportWizard.Question_8=Question
ProjectSetExportWizard.Target_already_exists._Would_you_like_to_overwrite_it__9=Target already exists. Would you like to overwrite it?
ProjectSetImportWizard.Project_Set_1=Team Project Set
ProjectSetImportWizard.Import_a_Project_Set_3=Import a Team Project Set
+ProjectSetImportWizard.workingSetExistsTitle=Working Set Exists
+ProjectSetImportWizard.workingSetExistsMessage=Working set ''{0}'' already exists. Overwrite?
ExportProjectSetMainPage.Project_Set_Files_3=Team Project Set Files (*.psf)
ExportProjectSetMainPage.default=projectSet.psf

Back to the top