diff options
author | Michael Valenta | 2005-09-27 20:46:49 +0000 |
---|---|---|
committer | Michael Valenta | 2005-09-27 20:46:49 +0000 |
commit | e5fe1d77a0b2b1c78ed1368d6d1a671e5de59306 (patch) | |
tree | 1cce4801010c28fea6a517faacd6dd7b5ef39dbc | |
parent | 549f4f5e8670195bd4c8e4b27920ba2b8022b195 (diff) | |
download | eclipse.platform.team-e5fe1d77a0b2b1c78ed1368d6d1a671e5de59306.tar.gz eclipse.platform.team-e5fe1d77a0b2b1c78ed1368d6d1a671e5de59306.tar.xz eclipse.platform.team-e5fe1d77a0b2b1c78ed1368d6d1a671e5de59306.zip |
Merged HEAD
53 files changed, 1498 insertions, 686 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java index 7b51dbe81..b2a29630c 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java @@ -146,6 +146,12 @@ public final class Team { // The ignores are cached and when the preferences change the // cache is cleared. This makes it faster to lookup without having // to re-parse the preferences. + initializeIgnores(); + IIgnoreInfo[] result = getIgnoreInfo(globalIgnore); + return result; + } + + private static void initializeIgnores() { if (globalIgnore == null) { globalIgnore = new TreeMap(); pluginIgnore = new TreeMap(); @@ -157,8 +163,6 @@ public final class Team { } initializePluginIgnores(pluginIgnore, globalIgnore); } - IIgnoreInfo[] result = getIgnoreInfo(globalIgnore); - return result; } private static IIgnoreInfo[] getIgnoreInfo(Map gIgnore) { @@ -222,10 +226,11 @@ public final class Team { * Add patterns to the list of global ignores. */ public static void setAllIgnores(String[] patterns, boolean[] enabled) { + initializeIgnores(); globalIgnore = new TreeMap(); ignoreMatchers = null; for (int i = 0; i < patterns.length; i++) { - globalIgnore.put(patterns[i], new Boolean(enabled[i])); + globalIgnore.put(patterns[i], Boolean.valueOf(enabled[i])); } // Now set into preferences StringBuffer buf = new StringBuffer(); @@ -272,9 +277,9 @@ public final class Team { } boolean enabled = selected != null && selected.equalsIgnoreCase("true"); //$NON-NLS-1$ // if this ignore doesn't already exist, add it to the global list - pIgnore.put(pattern, new Boolean(enabled)); + pIgnore.put(pattern, Boolean.valueOf(enabled)); if (!gIgnore.containsKey(pattern)) { - gIgnore.put(pattern, new Boolean(enabled)); + gIgnore.put(pattern, Boolean.valueOf(enabled)); } } } @@ -308,7 +313,7 @@ public final class Team { pattern = tok.nextToken(); if (pattern.length()==0) return; enabled = tok.nextToken(); - globalIgnore.put(pattern, new Boolean(enabled)); + globalIgnore.put(pattern, Boolean.valueOf(enabled)); } } catch (NoSuchElementException e) { return; @@ -337,7 +342,7 @@ public final class Team { for (int i = 0; i < ignoreCount; i++) { String pattern = dis.readUTF(); boolean enabled = dis.readBoolean(); - globalIgnore.put(pattern, new Boolean(enabled)); + globalIgnore.put(pattern, Boolean.valueOf(enabled)); } } finally { dis.close(); diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java index be1f04e26..c163f80b9 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java @@ -239,7 +239,10 @@ public class SubscriberEventHandler extends BackgroundEventHandler { monitor); } } catch (TeamException e) { - handleException(e, resource, ITeamStatus.SYNC_INFO_SET_ERROR, NLS.bind(Messages.SubscriberEventHandler_8, new String[] { resource.getFullPath().toString(), e.getMessage() })); + // We only handle the exception if the resource's project is accessible. + // The project close delta will clean up. + if (resource.getProject().isAccessible()) + handleException(e, resource, ITeamStatus.SYNC_INFO_SET_ERROR, NLS.bind(Messages.SubscriberEventHandler_8, new String[] { resource.getFullPath().toString(), e.getMessage() })); } } @@ -331,6 +334,15 @@ public class SubscriberEventHandler extends BackgroundEventHandler { new SubscriberEvent(info.getLocal(), SubscriberEvent.CHANGE, IResource.DEPTH_ZERO, info)); } public void addError(ITeamStatus status) { + if (status instanceof TeamStatus) { + TeamStatus ts = (TeamStatus) status; + IResource resource = ts.getResource(); + if (resource != null && !resource.getProject().isAccessible()) { + // The project was closed while we were collecting sync info. + // The close delta will cause us to clean up properly + return; + } + } super.addError(status); TeamPlugin.getPlugin().getLog().log(status); syncSetInput.handleError(status); diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetFilteredSyncInfoCollector.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetFilteredSyncInfoCollector.java index 2c3ec8545..4ca87cb5b 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetFilteredSyncInfoCollector.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetFilteredSyncInfoCollector.java @@ -31,7 +31,6 @@ public final class WorkingSetFilteredSyncInfoCollector { private WorkingSetSyncSetInput workingSetInput; private SyncSetInputFromSyncSet filteredInput; private SubscriberEventHandler eventHandler; - private IResource[] roots; /** * Create a collector that collects out-of-sync resources that are children of @@ -43,7 +42,6 @@ public final class WorkingSetFilteredSyncInfoCollector { * @param roots the roots of the out-of-sync resources to be collected */ public WorkingSetFilteredSyncInfoCollector(SubscriberSyncInfoCollector collector, IResource[] roots) { - this.roots = roots; this.eventHandler = collector.getEventHandler(); // TODO: optimize and don't use working set if no roots are passed in workingSetInput = new WorkingSetSyncSetInput((SubscriberSyncInfoSet)collector.getSyncInfoSet(), getEventHandler()); diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.properties b/bundles/org.eclipse.team.cvs.ui/plugin.properties index dd9660be7..ba3f2a0d7 100644 --- a/bundles/org.eclipse.team.cvs.ui/plugin.properties +++ b/bundles/org.eclipse.team.cvs.ui/plugin.properties @@ -7,6 +7,7 @@ # # Contributors: # IBM Corporation - initial API and implementation +# Maik Schreiber - bug 102461 ############################################################################### providerName=Eclipse.org pluginName=CVS Team Provider UI @@ -228,10 +229,18 @@ newProjectCheckoutWizardDescription=Import a project from a CVS Repository. newProjectCheckoutWizardDescription2=Create a new project by checking out an existing project from a CVS repository. PasswordManagement=Password Management +OutgoingChangeForegroundColor.label=Outgoing Change (Foreground) +OutgoingChangeForegroundColor.description=This color is used for the foreground color for resources that have outgoing changes. +OutgoingChangeBackgroundColor.label=Outgoing Change (Background) +OutgoingChangeBackgroundColor.description=This color is used for the background color for resources that have outgoing changes. OutgoingChangeFont.label=Outgoing Change Font +OutgoingChangeFont.description=The font used to display outgoing changes. IgnoredResourceFont.label=Ignored Resource Font +IgnoredResourceFont.description=The font used to display resources that are ignored from CVS. IgnoredResourceForegroundColor.label=Ignored Resource (Foreground) +IgnoredResourceForegroundColor.description=This color is used for the foreground color for resources that are ignored from CVS. IgnoredResourceBackgroundColor.label=Ignored Resource (Background) +IgnoredResourceBackgroundColor.description=This color is used for the background color for resources that are ignored from CVS. PreferenceKeywords.CVS=CVS Team PreferenceKeywords.EXT=CVS Team ext connection method ssh @@ -239,3 +248,5 @@ PreferenceKeywords.Console=CVS team console colors RepoPreference.Name=CVS Repositories RepoPreference.Description=Preferences that contain the CVS repository connection information + +CommentTemplatesPreferencePage.name=Comment Templates diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.xml b/bundles/org.eclipse.team.cvs.ui/plugin.xml index af039d431..79ad27a0c 100644 --- a/bundles/org.eclipse.team.cvs.ui/plugin.xml +++ b/bundles/org.eclipse.team.cvs.ui/plugin.xml @@ -18,7 +18,7 @@ <extension point="org.eclipse.ui.console.consoleFactories"> <consoleFactory - label="CVS" + label="%CVS" icon="$nl$/icons/full/eview16/console_view.gif" class="org.eclipse.team.internal.ccvs.ui.console.CVSConsoleFactory"/> </extension> @@ -213,15 +213,6 @@ value="org.eclipse.team.core.repository=org.eclipse.team.cvs.core.cvsnature"> </filter> <action - helpContextId="org.eclipse.team.cvs.ui.team_create_patch_action_context" - label="%GenerateDiff.label" - definitionId="org.eclipse.team.cvs.ui.GenerateDiff" - class="org.eclipse.team.internal.ccvs.ui.actions.GenerateDiffFileAction" - tooltip="%GenerateDiff.tooltip" - menubarPath="team.main/group1" - id="org.eclipse.team.cvs.ui.GenerateDiff"> - </action> - <action label="%ShowEditorsAction.label" helpContextId="org.eclipse.team.cvs.ui.team_show_editors_action_context" tooltip="%ShowEditorsAction.tooltip" @@ -324,6 +315,14 @@ id="org.eclipse.team.cvs.ui.replace"> </action> <action + class="org.eclipse.team.internal.ccvs.ui.actions.GenerateDiffFileAction" + definitionId="org.eclipse.team.cvs.ui.GenerateDiff" + helpContextId="org.eclipse.team.cvs.ui.team_create_patch_action_context" + id="org.eclipse.team.cvs.ui.GenerateDiff" + label="%GenerateDiff.label" + menubarPath="team.main/group1" + tooltip="%GenerateDiff.tooltip"/> + <action label="Model Update" class="org.eclipse.team.internal.ccvs.ui.actions.UpdateModelAction" menubarPath="team.main/group1" @@ -433,7 +432,7 @@ label="%AddToBranch.label" icon="$nl$/icons/full/clcl16/newstream_wiz.gif" helpContextId="org.eclipse.team.cvs.ui.add_to_branch_context" - tooltip="%ddToBranch.tooltip" + tooltip="%AddToBranch.tooltip" class="org.eclipse.team.internal.ccvs.ui.repo.AddToBranchAction" menubarPath="miscGroup" id="org.eclipse.team.ccvs.ui.addToBranch"> @@ -687,6 +686,16 @@ <extension point="org.eclipse.ui.preferencePages"> <page + name="%CommentTemplatesPreferencePage.name" + category="org.eclipse.team.cvs.ui.CVSPreferences" + class="org.eclipse.team.internal.ccvs.ui.CommentTemplatesPreferencePage" + id="org.eclipse.team.cvs.ui.CommentTemplatesPreferences"> + <keywordReference id="org.eclipse.team.cvs.ui.cvs"/> + </page> + </extension> + <extension + point="org.eclipse.ui.preferencePages"> + <page name="%ConsolePreferencePage.name" category="org.eclipse.team.cvs.ui.CVSPreferences" class="org.eclipse.team.internal.ccvs.ui.console.ConsolePreferencesPage" @@ -1248,19 +1257,19 @@ <colorDefinition id="org.eclipse.team.cvs.ui.fontsandcolors.outgoing_change_foreground_color" categoryId="org.eclipse.team.cvs.ui.fontsandcolors" - label="Outgoing Change (Foreground)" + label="%OutgoingChangeForegroundColor.label" value="COLOR_LIST_FOREGROUND"> <description> - This color is used for the foreground color for resources that have outgoing changes. + %OutgoingChangeForegroundColor.description </description> </colorDefinition> <colorDefinition id="org.eclipse.team.cvs.ui.fontsandcolors.outgoing_change_background_color" categoryId="org.eclipse.team.cvs.ui.fontsandcolors" - label="Outgoing Change (Background)" + label="%OutgoingChangeBackgroundColor.label" value="COLOR_LIST_BACKGROUND"> <description> - This color is used for the background color for resources that have outgoing changes. + %OutgoingChangeBackgroundColor.description </description> </colorDefinition> <fontDefinition @@ -1268,7 +1277,7 @@ categoryId="org.eclipse.team.cvs.ui.fontsandcolors" label="%OutgoingChangeFont.label"> <description> - The font used to display outgoing changes. + %OutgoingChangeFont.description </description> </fontDefinition> <colorDefinition @@ -1277,7 +1286,7 @@ label="%IgnoredResourceForegroundColor.label" value="COLOR_LIST_FOREGROUND"> <description> - This color is used for the foreground color for resources that are ignored from CVS. + %IgnoredResourceForegroundColor.description </description> </colorDefinition> <colorDefinition @@ -1286,7 +1295,7 @@ label="%IgnoredResourceBackgroundColor.label" value="COLOR_LIST_BACKGROUND"> <description> - This color is used for the background color for resources that are ignored from CVS. + %IgnoredResourceBackgroundColor.description </description> </colorDefinition> <fontDefinition @@ -1294,7 +1303,7 @@ categoryId="org.eclipse.team.cvs.ui.fontsandcolors" label="%IgnoredResourceFont.label"> <description> - The font used to display resources that are ignored from CVS. + %IgnoredResourceFont.description </description> </fontDefinition> </extension> diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java index 2655499a1..e7ec3e7ef 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java @@ -235,7 +235,7 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig boolean accessible = resource.getProject().isAccessible(); if (accessible) { // We only care about the failure if the project is open - handleException(e); + handleException(resource, e); } // Return dirty if the project is open and clean otherwise return accessible; @@ -299,7 +299,8 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig if (cvsDecoration != null) cvsDecoration.apply(decoration); } catch(CoreException e) { - handleException(e); + // TODO: Need to check for closed projects properly + handleException(mapping.getProjects()[0], e); } catch (IllegalStateException e) { // This is thrown by Core if the workspace is in an illegal state // If we are not active, ignore it. Otherwise, propagate it. @@ -576,7 +577,7 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig }); getResourceChangeHandler().updateLabels((IResource[]) resources.toArray(new IResource[resources.size()])); } catch (CoreException e) { - handleException(e); + handleException(project, e); } } @@ -651,10 +652,13 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig } /** - * Handle exceptions that occur in the decorator. + * Handle exceptions that occur in the decorator. + * Exceptions are only logged for resources that + * are accessible (i.e. exist in an open project). */ - private static void handleException(CoreException e) { - exceptions.handleException(e); + private static void handleException(IResource resource, CoreException e) { + if (resource.isAccessible()) + exceptions.handleException(e); } /* (non-Javadoc) diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java index bca30081a..a01f2b924 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Philippe Ombredanne - bug 84808 *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui; @@ -375,6 +376,7 @@ public class CVSPreferencesPage extends PreferencePage implements IWorkbenchPref new Checkbox(composite, ICVSUIConstants.PREF_DEBUG_PROTOCOL, CVSUIMessages.CVSPreferencesPage_17, IHelpContextIds.PREF_DEBUG_PROTOCOL); new Checkbox(composite, ICVSUIConstants.PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG, CVSUIMessages.CVSPreferencesPage_18, IHelpContextIds.PREF_AUTOREFRESH_TAG); new Checkbox(composite, ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT, CVSUIMessages.CVSPreferencesPage_44, null); + new Checkbox(composite, ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT, CVSUIMessages.CVSPreferencesPage_45, null); final Composite textComposite= SWTUtils.createHFillComposite(composite, SWTUtils.MARGINS_NONE, 2); new TextField( diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java index 5db43b85e..49230d381 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java @@ -5,7 +5,9 @@ * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation + * Maik Schreiber - bug 102461 + * Philippe Ombredanne - bug 84808 **********************************************************************/ package org.eclipse.team.internal.ccvs.ui; @@ -147,6 +149,7 @@ public class CVSUIMessages extends NLS { public static String CVSDecoratorPreferencesPage_36; public static String CVSDecoratorPreferencesPage_37; public static String CVSDecoratorPreferencesPage_38; // repository label + public static String CVSDecoratorPreferencesPage_39; public static String CVSFilePropertiesPage_ignored; public static String CVSFilePropertiesPage_notManaged; @@ -225,6 +228,7 @@ public class CVSUIMessages extends NLS { public static String CVSPreferencesPage_42; public static String CVSPreferencesPage_43; public static String CVSPreferencesPage_44; + public static String CVSPreferencesPage_45; public static String CVSPropertiesPage_virtualModule; @@ -566,8 +570,6 @@ public class CVSUIMessages extends NLS { public static String Save_In_Workspace_7; public static String Select_a_folder_then_type_in_the_file_name__8; public static String Fi_le_name__9; - public static String Do_not_recurse_into_sub_folders_10; - public static String Do_not_include_new_files_in_patch_11; public static String Diff_output_format_12; public static String Unified__format_required_by_Compare_With_Patch_feature__13; public static String Context_14; @@ -706,6 +708,7 @@ public class CVSUIMessages extends NLS { public static String WatchEditPreferencePage_autoUpdate; public static String WatchEditPreferencePage_promptUpdate; public static String WatchEditPreferencePage_neverUpdate; + public static String WatchEditPreferencePage_0; public static String Uneditaction_confirmMessage; public static String Uneditaction_confirmTitle; @@ -796,7 +799,7 @@ public class CVSUIMessages extends NLS { public static String WorkspaceChangeSetCapability_7; public static String WorkspaceChangeSetCapability_8; - public static String HasProjectMetaFile_taskName; + public static String ProjectMetaFile_taskName; public static String TagFromWorkspace_taskName; public static String TagFromRepository_taskName; public static String UpdateOnlyMergeable_taskName; @@ -821,6 +824,16 @@ public class CVSUIMessages extends NLS { public static String CommitCommentArea_2; public static String CommitCommentArea_3; public static String CommitCommentArea_4; + public static String CommitCommentArea_5; + public static String CommitCommentArea_6; + + public static String CommentTemplatesPreferencePage_Description; + public static String CommentTemplatesPreferencePage_New; + public static String CommentTemplatesPreferencePage_Edit; + public static String CommentTemplatesPreferencePage_Remove; + public static String CommentTemplatesPreferencePage_Preview; + public static String CommentTemplatesPreferencePage_EditCommentTemplateTitle; + public static String CommentTemplatesPreferencePage_EditCommentTemplateMessage; public static String CheckoutProjectOperation_8; public static String CheckoutProjectOperation_9; @@ -846,6 +859,16 @@ public class CVSUIMessages extends NLS { public static String GenerateDiffFileOperation_0; public static String GenerateDiffFileOperation_1; public static String GenerateDiffFileOperation_2; + public static String DiffOperation_0; + public static String DiffOperation_1; + public static String GenerateDiffFileWizard_6; + public static String GenerateDiffFileWizard_7; + public static String GenerateDiffFileWizard_8; + public static String GenerateDiffFileWizard_9; + public static String GenerateDiffFileWizard_10; + public static String GenerateDiffFileWizard_File_multisegments; + public static String GenerateDiffFileWizard_SelectAll; + public static String GenerateDiffFileWizard_DeselectAll; public static String GenerateDiffFileWizard_0; public static String GenerateDiffFileWizard_2; public static String GenerateDiffFileWizard_3; @@ -985,13 +1008,12 @@ public class CVSUIMessages extends NLS { public static String UncommittedChangesDialog_3; public static String UncommittedChangesDialog_4; public static String AddWizard_0; - + + public static String OpenChangeSetAction_0; + public static String OpenChangeSetAction_1; + static { // load message values from bundle file NLS.initializeMessages(BUNDLE_NAME, CVSUIMessages.class); } - - public static String OpenChangeSetAction_0; - public static String OpenChangeSetAction_1; - public static String CVSDecoratorPreferencesPage_39; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java index 869c12d96..7b2f9ffb5 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Philippe Ombredanne - bug 84808 *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui; @@ -81,7 +82,7 @@ public class CVSUIPlugin extends AbstractUIPlugin { private RepositoryManager repositoryManager; private SubscriberChangeSetCollector changeSetManager; - + /** * CVSUIPlugin constructor * @@ -276,8 +277,6 @@ public class CVSUIPlugin extends AbstractUIPlugin { * Initializes the table of images used in this plugin. */ private void initializeImages() { - URL baseURL = getBundle().getEntry("/"); //$NON-NLS-1$ - // objects createImageDescriptor(ICVSUIConstants.IMG_REPOSITORY); createImageDescriptor(ICVSUIConstants.IMG_REFRESH); @@ -500,7 +499,7 @@ public class CVSUIPlugin extends AbstractUIPlugin { /** * Initializes the preferences for this plugin if necessary. */ - protected void initializePreferences() { + protected void initializeDefaultPluginPreferences() { IPreferenceStore store = getPreferenceStore(); // Get the plugin preferences for CVS Core Preferences corePrefs = CVSProviderPlugin.getPlugin().getPluginPreferences(); @@ -531,6 +530,8 @@ public class CVSUIPlugin extends AbstractUIPlugin { store.setDefault(ICVSUIConstants.PREF_COMMIT_SET_DEFAULT_ENABLEMENT, false); store.setDefault(ICVSUIConstants.PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG, false); store.setDefault(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT, true); + store.setDefault(ICVSUIConstants.PREF_ENABLE_WATCH_ON_EDIT, false); + store.setDefault(ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT, false); store.setDefault(ICVSUIConstants.PREF_COMMIT_FILES_DISPLAY_THRESHOLD, 1000); PreferenceConverter.setDefault(store, ICVSUIConstants.PREF_CONSOLE_COMMAND_COLOR, new RGB(0, 0, 0)); @@ -597,7 +598,6 @@ public class CVSUIPlugin extends AbstractUIPlugin { super.start(context); initializeImages(); - initializePreferences(); CVSAdapterFactory factory = new CVSAdapterFactory(); Platform.getAdapterManager().registerAdapters(factory, ICVSRemoteFile.class); @@ -700,4 +700,13 @@ public class CVSUIPlugin extends AbstractUIPlugin { throw new InvocationTargetException(e); } } + + /** + * Helper method which access the preference store to determine if the + * project name from the project description file (.project) should be used + * as the project name on checkout. + */ + public boolean isUseProjectNameOnCheckout() { + return getPreferenceStore().getBoolean(ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommitCommentArea.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommitCommentArea.java index 74fc11402..4be57ec3b 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommitCommentArea.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommitCommentArea.java @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Sebastian Davids - bug 57208 + * Maik Schreiber - bug 102461 *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui; @@ -26,6 +27,7 @@ import org.eclipse.team.core.RepositoryProvider; import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ui.SWTUtils; import org.eclipse.team.internal.ui.dialogs.DialogArea; +import org.eclipse.ui.dialogs.PreferencesUtil; /** * This area provides the widgets for providing the CVS commit comment @@ -125,35 +127,57 @@ public class CommitCommentArea extends DialogArea { private final String fMessage; private final String [] fComments; + private String[] fCommentTemplates; private final Combo fCombo; - public ComboBox(Composite composite, String message, String [] options) { + public ComboBox(Composite composite, String message, String [] options, + String[] commentTemplates) { fMessage= message; fComments= options; + fCommentTemplates = commentTemplates; fCombo = new Combo(composite, SWT.READ_ONLY); fCombo.setLayoutData(SWTUtils.createHFillGridData()); // populate the previous comment list - fCombo.add(fMessage); - for (int i = 0; i < fComments.length; i++) { - fCombo.add(HistoryView.flattenText(fComments[i])); - } - fCombo.setText(fMessage); + populateList(); // We don't want to have an initial selection // (see bug 32078: http://bugs.eclipse.org/bugs/show_bug.cgi?id=32078) fCombo.addFocusListener(this); fCombo.addSelectionListener(this); } + + private void populateList() { + fCombo.removeAll(); + + fCombo.add(fMessage); + for (int i = 0; i < fCommentTemplates.length; i++) { + fCombo.add(CVSUIMessages.CommitCommentArea_6 + ": " + //$NON-NLS-1$ + HistoryView.flattenText(fCommentTemplates[i])); + } + for (int i = 0; i < fComments.length; i++) { + fCombo.add(HistoryView.flattenText(fComments[i])); + } + fCombo.setText(fMessage); + } public void widgetSelected(SelectionEvent e) { - final int index = fCombo.getSelectionIndex(); + int index = fCombo.getSelectionIndex(); if (index > 0) { + index--; setChanged(); - notifyObservers(fComments[index - 1]); + + // map from combo box index to array index + String message; + if (index < fCommentTemplates.length) { + message = fCommentTemplates[index]; + } else { + message = fComments[index - fCommentTemplates.length]; + } + notifyObservers(message); } } @@ -178,10 +202,16 @@ public class CommitCommentArea extends DialogArea { public void setEnabled(boolean enabled) { fCombo.setEnabled(enabled); } + + void setCommentTemplates(String[] templates) { + fCommentTemplates = templates; + populateList(); + } } private static final String EMPTY_MESSAGE= CVSUIMessages.CommitCommentArea_0; - private static final String COMBO_MESSAGE= CVSUIMessages.CommitCommentArea_1; + private static final String COMBO_MESSAGE= CVSUIMessages.CommitCommentArea_1; + private static final String CONFIGURE_TEMPLATES_MESSAGE= CVSUIMessages.CommitCommentArea_5; public static final String OK_REQUESTED = "OkRequested";//$NON-NLS-1$ public static final String COMMENT_MODIFIED = "CommentModified";//$NON-NLS-1$ @@ -206,12 +236,36 @@ public class CommitCommentArea extends DialogArea { fTextBox= new TextBox(fComposite, EMPTY_MESSAGE, getInitialComment()); final String [] comments = CVSUIPlugin.getPlugin().getRepositoryManager().getPreviousComments(); - fComboBox= new ComboBox(fComposite, COMBO_MESSAGE, comments); + final String[] commentTemplates = CVSUIPlugin.getPlugin().getRepositoryManager().getCommentTemplates(); + fComboBox= new ComboBox(fComposite, COMBO_MESSAGE, comments, commentTemplates); + + Link templatesPrefsLink = new Link(fComposite, 0); + templatesPrefsLink.setText("<a href=\"configureTemplates\">" + //$NON-NLS-1$ + CONFIGURE_TEMPLATES_MESSAGE + "</a>"); //$NON-NLS-1$ + templatesPrefsLink.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + openCommentTemplatesPreferencePage(); + } + + public void widgetSelected(SelectionEvent e) { + openCommentTemplatesPreferencePage(); + } + }); fComboBox.addObserver(fTextBox); } - public String getComment(boolean save) { + void openCommentTemplatesPreferencePage() { + PreferencesUtil.createPreferenceDialogOn( + null, + "org.eclipse.team.cvs.ui.CommentTemplatesPreferences", //$NON-NLS-1$ + new String[] { "org.eclipse.team.cvs.ui.CommentTemplatesPreferences" }, //$NON-NLS-1$ + null).open(); + fComboBox.setCommentTemplates( + CVSUIPlugin.getPlugin().getRepositoryManager().getCommentTemplates()); + } + + public String getComment(boolean save) { final String comment= fTextBox.getText(); if (comment == null) return ""; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilter.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilter.java index 7ec888637..06371faaa 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilter.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilter.java @@ -16,15 +16,13 @@ import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.team.internal.ccvs.core.ILogEntry; public class HistoryFilter extends ViewerFilter { - private HistoryView view; public String author; public Date fromDate; public Date toDate; public String comment; public boolean isOr; - public HistoryFilter(HistoryView hView, String author, String comment, Date fromDate, Date toDate, boolean isOr) { - this.view = hView; + public HistoryFilter(String author, String comment, Date fromDate, Date toDate, boolean isOr) { this.author = author; this.comment = comment; this.fromDate = fromDate; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilterDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilterDialog.java index b81650324..b69e3ee23 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilterDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryFilterDialog.java @@ -25,7 +25,6 @@ import org.eclipse.ui.PlatformUI; public class HistoryFilterDialog extends Dialog { - private HistoryView historyView; private HistoryFilter historyFilter; //widgets @@ -42,7 +41,6 @@ public class HistoryFilterDialog extends Dialog { public HistoryFilterDialog(HistoryView view) { super(view.getViewSite().getShell()); - this.historyView = view; } protected void configureShell(Shell newShell) { @@ -218,7 +216,6 @@ public class HistoryFilterDialog extends Dialog { //create the filter historyFilter = new HistoryFilter( - historyView, author.getText(), comment.getText(), fromDate, diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java index d96683588..071ae277a 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Philippe Ombredanne - bug 84808 *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui; @@ -95,7 +96,8 @@ public interface ICVSUIConstants { public final String PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG = "pref_auto_refresh_tags_in_tag_selection_dialog"; //$NON-NLS-1$ public final String PREF_COMMIT_FILES_DISPLAY_THRESHOLD = "pref_commit_files_display_threshold"; //$NON-NLS-1$ public final String PREF_AUTO_SHARE_ON_IMPORT = "pref_auto_share_on_import"; //$NON-NLS-1$ - + public final String PREF_ENABLE_WATCH_ON_EDIT = "pref_enable_watch_on_edit"; //$NON-NLS-1$ + public final String PREF_USE_PROJECT_NAME_ON_CHECKOUT = "pref_use_project_name_on_checkout"; //$NON-NLS-1$ // console preferences public final String PREF_CONSOLE_COMMAND_COLOR = "pref_console_command_color"; //$NON-NLS-1$ public final String PREF_CONSOLE_MESSAGE_COLOR = "pref_console_message_color"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java index effc2f9b7..0f9e407ce 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java @@ -48,6 +48,11 @@ public class WatchEditPreferencePage extends CVSFieldEditorPreferencePage { CVSUIMessages.WatchEditPreferencePage_checkoutReadOnly, BooleanFieldEditor.DEFAULT, getFieldEditorParent())); + addField(new BooleanFieldEditor( + ICVSUIConstants.PREF_ENABLE_WATCH_ON_EDIT, + CVSUIMessages.WatchEditPreferencePage_0, + BooleanFieldEditor.DEFAULT, + getFieldEditorParent())); actionEditor = new RadioGroupFieldEditor( ICVSUIConstants.PREF_EDIT_ACTION, @@ -98,6 +103,9 @@ public class WatchEditPreferencePage extends CVSFieldEditorPreferencePage { target.setValue( CVSProviderPlugin.READ_ONLY, store.getBoolean(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY)); + target.setValue( + CVSProviderPlugin.ENABLE_WATCH_ON_EDIT, + store.getBoolean(ICVSUIConstants.PREF_ENABLE_WATCH_ON_EDIT)); } /* (non-Javadoc) diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java index 4f6a68e46..436a04237 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Philippe Ombredanne - bug 84808 *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.actions; @@ -16,7 +17,9 @@ import org.eclipse.jface.action.IAction; import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; +import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.operations.CheckoutMultipleProjectsOperation; +import org.eclipse.team.internal.ccvs.ui.operations.ProjectMetaFileOperation; /** * Checkout a remote module into the workspace ensuring that the user is prompted for @@ -28,7 +31,7 @@ public class CheckoutAction extends CVSAction { * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) */ protected void execute(IAction action) throws InvocationTargetException, InterruptedException { - new CheckoutMultipleProjectsOperation(getTargetPart(), getSelectedRemoteFolders(), null) + new CheckoutMultipleProjectsOperation(getTargetPart(), getSelectedRemoteFoldersWithProjectName(), null) .run(); } @@ -48,4 +51,18 @@ public class CheckoutAction extends CVSAction { } return true; } + + /** + * Get selected CVS remote folders, and add Project Description + * from metafile if available based on preferences settings + * @throws InterruptedException + * @throws InvocationTargetException + */ + private ICVSRemoteFolder[] getSelectedRemoteFoldersWithProjectName() throws InvocationTargetException, InterruptedException { + ICVSRemoteFolder[] folders = getSelectedRemoteFolders(); + if (CVSUIPlugin.getPlugin().isUseProjectNameOnCheckout()){ + folders = ProjectMetaFileOperation.updateFoldersWithProjectName(getTargetPart(), folders); + } + return folders; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java index 563dd6e76..1efbcb690 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Philippe Ombredanne - bug 84808 *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.actions; @@ -16,7 +17,8 @@ import org.eclipse.jface.action.IAction; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.ui.operations.HasProjectMetaFileOperation; +import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; +import org.eclipse.team.internal.ccvs.ui.operations.ProjectMetaFileOperation; import org.eclipse.team.internal.ccvs.ui.wizards.CheckoutAsWizard; public class CheckoutAsAction extends CVSAction { @@ -26,21 +28,22 @@ public class CheckoutAsAction extends CVSAction { */ public void execute(IAction action) throws InvocationTargetException, InterruptedException { ICVSRemoteFolder[] folders = getSelectedRemoteFolders(); - CheckoutAsWizard wizard = new CheckoutAsWizard(getTargetPart(), folders, allowProjectConfiguration(folders)); + boolean withName = CVSUIPlugin.getPlugin().isUseProjectNameOnCheckout(); + ProjectMetaFileOperation op = new ProjectMetaFileOperation(getTargetPart(), folders, withName); + op.run(); + + // project configuration allowed only if single folder without metafile + boolean allowProjectConfig = (folders.length == 1 && !op.metaFileExists()); + + if (withName) { + folders = op.getUpdatedFolders(); + } + + CheckoutAsWizard wizard = new CheckoutAsWizard(getTargetPart(), folders, allowProjectConfig); WizardDialog dialog = new WizardDialog(shell, wizard); dialog.open(); } - /* - * Return true if the remote project does not have a .project file - * so that the checkout wizard will give the option to launch - * the New Project wizard - */ - protected boolean allowProjectConfiguration(ICVSRemoteFolder[] folders) throws InvocationTargetException, InterruptedException { - if (folders.length != 1) return false; - return !HasProjectMetaFileOperation.hasMetaFile(getTargetPart(), folders[0]); - } - /* (non-Javadoc) * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() */ diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java index 1776758bc..91d79d5d8 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java @@ -10,12 +10,21 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.actions; +import java.lang.reflect.InvocationTargetException; +import java.util.*; + +import org.eclipse.core.internal.resources.mapping.ResourceMapping; +import org.eclipse.core.internal.resources.mapping.ResourceTraversal; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.*; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; +import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; import org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard; +import org.eclipse.team.internal.core.subscribers.SubscriberResourceMappingContext; +import org.eclipse.ui.PlatformUI; /** * Action to generate a patch file using the CVS diff command. @@ -23,29 +32,80 @@ import org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard; * NOTE: This is a temporary action and should eventually be replaced * by a create patch command in the compare viewer. */ -public class GenerateDiffFileAction extends WorkspaceAction { +public class GenerateDiffFileAction extends WorkspaceTraversalAction{ - // The initial size of this wizard. - private final static int INITIAL_WIDTH = 300; - private final static int INITIAL_HEIGHT = 350; - /** (Non-javadoc) * Method declared on IActionDelegate. */ public void execute(IAction action) { - final String title = CVSUIMessages.GenerateCVSDiff_title; - final IResource[] resources = getSelectedResources(); - final GenerateDiffFileWizard wizard = new GenerateDiffFileWizard(resources[0]); - wizard.setWindowTitle(title); - WizardDialog dialog = new WizardDialog(getShell(), wizard); - dialog.setMinimumPageSize(INITIAL_WIDTH, INITIAL_HEIGHT); - dialog.open(); + + try { + final IResource [][] resources = new IResource[][] { null }; + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + try { + resources[0] = getDeepResourcesToPatch(monitor); + } catch (CoreException e) { + throw new InvocationTargetException(e); + } + } + }); + GenerateDiffFileWizard.run(getTargetPart(), resources[0]); + } catch (InvocationTargetException e) { + CVSUIPlugin.openError(getShell(), null, null, e, CVSUIPlugin.LOG_NONTEAM_EXCEPTIONS); + } catch (InterruptedException e) { + // Ignore + } } - + + private IResource[] getDeepResourcesToPatch(IProgressMonitor monitor) throws CoreException { + ResourceMapping[] mappings = getCVSResourceMappings(); + List roots = new ArrayList(); + for (int i = 0; i < mappings.length; i++) { + ResourceMapping mapping = mappings[i]; + ResourceTraversal[] traversals = mapping.getTraversals( + SubscriberResourceMappingContext.getCheckInContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()), + monitor); + for (int j = 0; j < traversals.length; j++) { + ResourceTraversal traversal = traversals[j]; + IResource[] resources = traversal.getResources(); + if (traversal.getDepth() == IResource.DEPTH_INFINITE) { + roots.addAll(Arrays.asList(resources)); + } else if (traversal.getDepth() == IResource.DEPTH_ZERO) { + collectShallowFiles(resources, roots); + } else if (traversal.getDepth() == IResource.DEPTH_ONE) { + collectShallowFiles(resources, roots); + for (int k = 0; k < resources.length; k++) { + IResource resource = resources[k]; + if (resource.getType() != IResource.FILE) { + collectShallowFiles(members(resource), roots); + } + } + } + } + } + return (IResource[]) roots.toArray(new IResource[roots.size()]); + } + + private void collectShallowFiles(IResource[] resources, List roots) { + for (int k = 0; k < resources.length; k++) { + IResource resource = resources[k]; + if (resource.getType() == IResource.FILE) + roots.add(resource); + } + } + + private IResource[] members(IResource resource) throws CoreException { + return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().members(resource); + } /** * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForMultipleResources() */ protected boolean isEnabledForMultipleResources() { + if(Boolean.getBoolean(GenerateDiffFileWizard.WORKSPACEPATCH_FLAG)){ + return true; + } + return false; } @@ -55,6 +115,7 @@ public class GenerateDiffFileAction extends WorkspaceAction { protected boolean isEnabledForUnmanagedResources() { return true; } + /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getId() diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java index b24c71228..937d96d12 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java @@ -55,7 +55,6 @@ public class RestoreFromRepositoryAction extends WorkspaceTraversalAction { * contains files that exist on a branch but not in HEAD */ class AtticLogListener extends CommandOutputListener { - private static final String ATTIC = "Attic"; //$NON-NLS-1$ private static final String RCS_FILE_POSTFIX = ",v"; //$NON-NLS-1$ private static final String LOGGING_PREFIX = "Logging "; //$NON-NLS-1$ ICVSFolder currentFolder; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSConsolePageParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSConsolePageParticipant.java index 4d65641cb..acc4f23de 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSConsolePageParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSConsolePageParticipant.java @@ -25,13 +25,9 @@ import org.eclipse.ui.part.IPageBookViewPage; */ public class CVSConsolePageParticipant implements IConsolePageParticipant { - private CVSOutputConsole console; - private IPageBookViewPage page; private ConsoleRemoveAction consoleRemoveAction; public void init(IPageBookViewPage page, IConsole console) { - this.console = (CVSOutputConsole)console; - this.page = page; this.consoleRemoveAction = new ConsoleRemoveAction(); IActionBars bars = page.getSite().getActionBars(); bars.getToolBarManager().appendToGroup(IConsoleConstants.LAUNCH_GROUP, consoleRemoveAction); @@ -39,8 +35,6 @@ public class CVSConsolePageParticipant implements IConsolePageParticipant { public void dispose() { this.consoleRemoveAction = null; - this.page = null; - this.console = null; } public void activated() { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties index 794179f2e..49aa41f38 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties @@ -7,6 +7,8 @@ # # Contributors: # IBM Corporation - initial API and implementation +# Maik Schreiber - bug 102461 +# Philippe Ombredanne - bug 84808 ############################################################################### PasswordManagementPreferencePage_2=When you create a CVS repository location you have the option of saving the password to disk. This page allows you to manage the stored passwords. The following CVS repository locations have saved passwords: PasswordManagementPreferencePage_3=Location @@ -221,6 +223,7 @@ CVSPreferencesPage_41=A&utomatically save dirty editors before CVS operations CVSPreferencesPage_42=&Open perspective after a 'Show Annotations' operation CVSPreferencesPage_43=D&efault perspective for 'Show Annotations': CVSPreferencesPage_44=Aut&omatically share projects containing CVS meta information +CVSPreferencesPage_45=Use .project &project name instead of module name on check out CVSPropertiesPage_virtualModule=<no corresponding remote folder> @@ -587,10 +590,8 @@ Browse____4=Br&owse... Save_Patch_As_5=Save Patch As patch_txt_6=patch.txt Save_In_Workspace_7=Save in &workspace -Select_a_folder_then_type_in_the_file_name__8=Select a fol&der then type in the file name: +Select_a_folder_then_type_in_the_file_name__8=Select a fol&der in the workspace and type in the file name Fi_le_name__9=Fi&le name: -Do_not_recurse_into_sub_folders_10=&Recurse into sub-folders -Do_not_include_new_files_in_patch_11=&Include new files in patch Diff_output_format_12=Diff output format Unified__format_required_by_Compare_With_Patch_feature__13=&Unified (format required by the Apply Patch wizard) Context_14=&Context @@ -727,6 +728,7 @@ WatchEditPreferencePage_description=Settings for CVS Watch/Edit. WatchEditPreferencePage_checkoutReadOnly=&Configure projects to use Watch/Edit on checkout WatchEditPreferencePage_validateEditSaveAction=When read-only files are modified in an editor WatchEditPreferencePage_edit=Send a CVS &edit notification to the server +WatchEditPreferencePage_0=Enable temporary &watches on edit WatchEditPreferencePage_editInBackground=Send a CVS edit notification to the server in the &background WatchEditPreferencePage_highjack=Edit the file &without informing the server WatchEditPreferencePage_editPrompt=Before a CVS edit notification is sent to the server @@ -835,7 +837,7 @@ WorkspaceChangeSetCapability_7=Edit Change Set Comment WorkspaceChangeSetCapability_8=Edit the name and comment for the change set -HasProjectMetaFile_taskName=Looking for a remote meta file +ProjectMetaFile_taskName=Looking for a remote meta file TagFromWorkspace_taskName=Tagging from workspace TagFromRepository_taskName=Tagging from repository UpdateOnlyMergeable_taskName=Updating mergeable changes @@ -860,6 +862,8 @@ CommitCommentArea_1=<Choose a previously entered comment> CommitCommentArea_2=Empty commit comment CommitCommentArea_3=The commit comment is empty. Are you sure you would like to continue with an empty comment? CommitCommentArea_4=Re&member decision? +CommitCommentArea_5=Configure Comment Templates... +CommitCommentArea_6=Template @@ -905,8 +909,17 @@ GenerateDiffFileOperation_2=An I/O error occured. GenerateDiffFileWizard_0=Please enter a valid location. GenerateDiffFileWizard_2=Please enter a file name. GenerateDiffFileWizard_3=The specified directory does not exist. -GenerateDiffFileWizard_4=Please select a location in the workspace. +GenerateDiffFileWizard_4=Please select a location in the workspace by browsing. GenerateDiffFileWizard_5=Please enter a valid filename. +GenerateDiffFileWizard_6=Workspace (Multi-project Apply Patch wizard specific) +GenerateDiffFileWizard_7=Project +GenerateDiffFileWizard_8=Selection +GenerateDiffFileWizard_9=Patch Location +GenerateDiffFileWizard_10=Patch Root +GenerateDiffFileWizard_File_multisegments=File name cannot contain multiple segments +GenerateDiffFileWizard_SelectAll=Select All +GenerateDiffFileWizard_DeselectAll=Deselect All + @@ -1048,3 +1061,13 @@ UncommittedChangesDialog_2=Select an item to see the dirty resources it contains UncommittedChangesDialog_3=&The dirty resources contained in ''{0}'' UncommittedChangesDialog_4=&The full path of ''{0}'' AddWizard_0=Add to Version Control + +CommentTemplatesPreferencePage_Description=&Create, edit or remove comment templates: +CommentTemplatesPreferencePage_New=&New... +CommentTemplatesPreferencePage_Edit=&Edit... +CommentTemplatesPreferencePage_Remove=&Remove +CommentTemplatesPreferencePage_Preview=Previe&w: +CommentTemplatesPreferencePage_EditCommentTemplateTitle=Enter Comment Template +CommentTemplatesPreferencePage_EditCommentTemplateMessage=Please enter a comment template: +DiffOperation_0=Creating Patch on {0} +DiffOperation_1=Creating Patch diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java index 4bbc9467a..9c667f311 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java @@ -21,6 +21,7 @@ import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.widgets.Shell; +import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ccvs.core.CVSException; import org.eclipse.team.internal.ccvs.core.CVSStatus; import org.eclipse.team.internal.ccvs.core.util.Assert; @@ -208,7 +209,7 @@ public abstract class CVSOperation extends TeamOperation { * @return whether the status is reportable or should be ignored */ protected boolean isReportableError(IStatus status) { - return status.getCode() == CVSStatus.SERVER_ERROR || CVSStatus.isInternalError(status); + return status.getCode() == CVSStatus.SERVER_ERROR || CVSStatus.isInternalError(status) || status.getCode() == TeamException.UNABLE; } protected String getErrorMessage(IStatus[] failures, int totalOperations) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java index 49f29bc9d..a797b48e7 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Philippe Ombredanne - bug 84808 *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.operations; @@ -124,6 +125,19 @@ public abstract class CheckoutProjectOperation extends CheckoutOperation { project = ResourcesPlugin.getWorkspace().getRoot().getProject(name); } + // Check to see if using remote metafile project description name is preferred + if (project == null + && CVSUIPlugin.getPlugin().isUseProjectNameOnCheckout() + && resource instanceof RemoteProjectFolder) { + RemoteProjectFolder rpf = (RemoteProjectFolder) resource; + if (rpf.hasProjectName()) + { + // no project was specified but we need to attempt the creation of one + // based on the metafile project name + project = ResourcesPlugin.getWorkspace().getRoot().getProject(rpf.getProjectName()); + } + } + // Determine the local target projects (either the project provider or the module expansions) // Note: Module expansions can be run over the same connection as a checkout final IProject[] targetProjects = determineProjects(session, resource, project, Policy.subMonitorFor(pm, 5)); @@ -286,6 +300,13 @@ public abstract class CheckoutProjectOperation extends CheckoutOperation { if (expansions.length == 1 && expansions[0].equals(moduleName)) { // For a remote folder, use the last segment as the project to be created String lastSegment = new Path(null, expansions[0]).lastSegment(); + // if using metafile project name is preferred, use it + if (CVSUIPlugin.getPlugin().isUseProjectNameOnCheckout() && remoteFolder instanceof RemoteProjectFolder) { + RemoteProjectFolder rpf = (RemoteProjectFolder) remoteFolder; + if (rpf.hasProjectName()) { + lastSegment = rpf.getProjectName(); + } + } targetProjectSet.add(ResourcesPlugin.getWorkspace().getRoot().getProject(lastSegment)); } else { for (int j = 0; j < expansions.length; j++) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java deleted file mode 100644 index c915904e6..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.operations; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; -import org.eclipse.ui.IWorkbenchPart; - -/** - * Operation which checks for the existance of the .project file - * in a remote folder. The operation can be run using the <code>hasMetaFile</code> - * static method of by executing the operation and then checking <code>metaFileExists</code> - */ -public class HasProjectMetaFileOperation extends CVSOperation { - - private ICVSRemoteFolder remoteFolder; - private boolean metaFileExists; - - public static boolean hasMetaFile(IWorkbenchPart part, ICVSRemoteFolder remoteFolder) throws InvocationTargetException, InterruptedException { - HasProjectMetaFileOperation op = new HasProjectMetaFileOperation(part, remoteFolder); - op.run(); - return op.metaFileExists(); - } - - public HasProjectMetaFileOperation(IWorkbenchPart part, ICVSRemoteFolder remoteFolder) { - super(part); - this.remoteFolder = remoteFolder; - } - - /* - * Return true if the provided remote folder contains a valid meta-file - * (i.e. .project file). - */ - private boolean hasMetaFile(ICVSRemoteFolder folder, IProgressMonitor monitor) throws CVSException { - - // make a copy of the folder so that we will not effect the original folder when we refetch the members - // TODO: this is a strange thing to need to do. We shold fix this. - folder = (ICVSRemoteFolder)folder.forTag(remoteFolder.getTag()); - - try { - folder.members(monitor); - } catch (TeamException e) { - throw CVSException.wrapException(e); - } - // Check for the existance of the .project file - try { - folder.getFile(".project"); //$NON-NLS-1$ - return true; - } catch (TeamException e) { - // We couldn't retrieve the meta file so assume it doesn't exist - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor) - */ - public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { - metaFileExists = hasMetaFile(remoteFolder, monitor); - } - - /** - * Return true if the meta file exists remotely. This method should only be invoked - * after the operation has been executed; - * @return - */ - public boolean metaFileExists() { - return metaFileExists; - } - - protected String getTaskName() { - return CVSUIMessages.HasProjectMetaFile_taskName; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#canRunAsJob() - */ - public boolean canRunAsJob() { - // This operation should never be run in the background. - return false; - } - -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.java index 1cc73d006..dc270f626 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.java @@ -35,7 +35,6 @@ public class ReconcileProjectOperation extends ShareProjectOperation { private ICVSRemoteFolder folder; private ContentComparisonSyncInfoFilter contentCompare = new ContentComparisonSyncInfoFilter(false); - private CVSWorkspaceSubscriber subscriber = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(); public ReconcileProjectOperation(Shell shell, IProject project, ICVSRemoteFolder folder) { super(shell, folder.getRepository(), project, folder.getRepositoryRelativePath()); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java index 0c5f40753..968144af7 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java @@ -19,6 +19,7 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.*; import org.eclipse.jface.dialogs.*; import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -560,6 +561,9 @@ public class CVSRepositoryPropertiesPage extends PropertyPage { return; } CVSUIPlugin.getPlugin().getRepositoryManager().setLabel(location, newLabel); + CVSUIPlugin.broadcastPropertyChange(new PropertyChangeEvent(this, + CVSUIPlugin.P_DECORATORS_CHANGED, null, null)); + } private String getOldLabel(CVSRepositoryLocation location) { return CVSUIPlugin.getPlugin().getRepositoryManager().getRepositoryRootFor(location).getName(); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java index 96424fc02..5cdd6cc9a 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Sebastian Davids <sdavids@gmx.de> - bug 74959 + * Maik Schreiber - bug 102461 *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.repo; @@ -48,8 +49,10 @@ public class RepositoryManager { // new state file private static final String REPOSITORIES_VIEW_FILE = "repositoriesView.xml"; //$NON-NLS-1$ private static final String COMMENT_HIST_FILE = "commitCommentHistory.xml"; //$NON-NLS-1$ + private static final String COMMENT_TEMPLATES_FILE = "commentTemplates.xml"; //$NON-NLS-1$ static final String ELEMENT_COMMIT_COMMENT = "CommitComment"; //$NON-NLS-1$ static final String ELEMENT_COMMIT_HISTORY = "CommitComments"; //$NON-NLS-1$ + static final String ELEMENT_COMMENT_TEMPLATES = "CommitCommentTemplates"; //$NON-NLS-1$ private Map repositoryRoots = new HashMap(); @@ -57,6 +60,7 @@ public class RepositoryManager { // The previously remembered comment static String[] previousComments = new String[0]; + static String[] commentTemplates = new String[0]; public static boolean notifyRepoView = true; @@ -304,6 +308,7 @@ public class RepositoryManager { public void startup() { loadState(); loadCommentHistory(); + loadCommentTemplates(); CVSProviderPlugin.getPlugin().addRepositoryListener(new ICVSListener() { public void repositoryAdded(ICVSRepositoryLocation root) { rootAdded(root); @@ -317,6 +322,7 @@ public class RepositoryManager { public void shutdown() throws TeamException { saveState(); saveCommentHistory(); + saveCommentTemplates(); } private void loadState() { @@ -373,6 +379,23 @@ public class RepositoryManager { CVSUIPlugin.log(e); } } + private void loadCommentTemplates() { + IPath pluginStateLocation = CVSUIPlugin.getPlugin().getStateLocation().append(COMMENT_TEMPLATES_FILE); + File file = pluginStateLocation.toFile(); + if (!file.exists()) return; + try { + BufferedInputStream is = new BufferedInputStream(new FileInputStream(file)); + try { + readCommentTemplates(is); + } finally { + is.close(); + } + } catch (IOException e) { + CVSUIPlugin.log(Status.ERROR, CVSUIMessages.RepositoryManager_ioException, e); //$NON-NLS-1$ + } catch (TeamException e) { + CVSUIPlugin.log(e); + } + } protected void saveState() throws TeamException { IPath pluginStateLocation = CVSUIPlugin.getPlugin().getStateLocation(); @@ -420,6 +443,7 @@ public class RepositoryManager { throw new CVSException(NLS.bind(CVSUIMessages.RepositoryManager_parsingProblem, new String[] { REPOSITORIES_VIEW_FILE }), ex); } } + private void readCommentHistory(InputStream stream) throws IOException, TeamException { try { SAXParserFactory factory = SAXParserFactory.newInstance(); @@ -790,6 +814,9 @@ public class RepositoryManager { makeFirstElement(index); return; } + if (containsCommentTemplate(comment)) + return; + // Insert the comment as the first element String[] newComments = new String[Math.min(previousComments.length + 1, MAX_COMMENTS)]; newComments[0] = comment; @@ -820,4 +847,83 @@ public class RepositoryManager { } previousComments = newComments; } + + private void readCommentTemplates(InputStream stream) throws IOException, TeamException { + try { + SAXParserFactory factory = SAXParserFactory.newInstance(); + SAXParser parser = factory.newSAXParser(); + parser.parse(new InputSource(stream), + new CommentTemplatesContentHandler()); + } catch (SAXException ex) { + throw new CVSException(NLS.bind( + CVSUIMessages.RepositoryManager_parsingProblem, + new String[] { COMMENT_TEMPLATES_FILE }), ex); //$NON-NLS-1$ + } catch (ParserConfigurationException ex) { + throw new CVSException(NLS.bind( + CVSUIMessages.RepositoryManager_parsingProblem, + new String[] { COMMENT_TEMPLATES_FILE }), ex); //$NON-NLS-1$ + } + } + + protected void saveCommentTemplates() throws TeamException { + IPath pluginStateLocation = CVSUIPlugin.getPlugin().getStateLocation(); + File tempFile = pluginStateLocation.append( + COMMENT_TEMPLATES_FILE + ".tmp").toFile(); //$NON-NLS-1$ + File histFile = pluginStateLocation.append(COMMENT_TEMPLATES_FILE) + .toFile(); + try { + XMLWriter writer = new XMLWriter(new BufferedOutputStream( + new FileOutputStream(tempFile))); + try { + writeCommentTemplates(writer); + } finally { + writer.close(); + } + if (histFile.exists()) { + histFile.delete(); + } + boolean renamed = tempFile.renameTo(histFile); + if (!renamed) { + throw new TeamException(new Status(Status.ERROR, + CVSUIPlugin.ID, TeamException.UNABLE, NLS.bind( + CVSUIMessages.RepositoryManager_rename, + new String[] { tempFile.getAbsolutePath() }), + null)); //$NON-NLS-1$ + } + } catch (IOException e) { + throw new TeamException(new Status(Status.ERROR, CVSUIPlugin.ID, + TeamException.UNABLE, NLS.bind( + CVSUIMessages.RepositoryManager_save, + new String[] { histFile.getAbsolutePath() }), e)); //$NON-NLS-1$ + } + } + + private void writeCommentTemplates(XMLWriter writer) { + writer.startTag(ELEMENT_COMMENT_TEMPLATES, null, false); + for (int i = 0; i < commentTemplates.length; i++) + writer.printSimpleTag(ELEMENT_COMMIT_COMMENT, commentTemplates[i]); + writer.endTag(ELEMENT_COMMENT_TEMPLATES); + } + + private boolean containsCommentTemplate(String comment) { + for (int i = 0; i < commentTemplates.length; i++) { + if (commentTemplates[i].equals(comment)) { + return true; + } + } + return false; + } + + /** + * Get list of comment templates. + */ + public String[] getCommentTemplates() { + return commentTemplates; + } + + public void replaceAndSaveCommentTemplates(String[] templates) + throws TeamException { + commentTemplates = templates; + saveCommentTemplates(); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java index f9596ad8a..abe2d4fe3 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java @@ -107,7 +107,7 @@ public class WorkspaceSynchronizeParticipant extends ScopableSubscriberParticipa appendToGroup( ISynchronizePageConfiguration.P_CONTEXT_MENU, CONTEXT_MENU_CONTRIBUTION_GROUP_3, - new CVSActionDelegateWrapper(new GenerateDiffFileAction(), configuration)); + new CreatePatchAction(configuration)); appendToGroup( ISynchronizePageConfiguration.P_CONTEXT_MENU, CONTEXT_MENU_CONTRIBUTION_GROUP_3, diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionArea.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionArea.java index 3cff44444..49c6b0871 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionArea.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionArea.java @@ -26,12 +26,12 @@ import org.eclipse.team.internal.ccvs.core.CVSTag; import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.actions.CVSAction; import org.eclipse.team.internal.ccvs.ui.repo.NewDateTagAction; import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; import org.eclipse.team.internal.ccvs.ui.tags.TagSourceWorkbenchAdapter.ProjectElementSorter; import org.eclipse.team.internal.ui.PixelConverter; import org.eclipse.team.internal.ui.SWTUtils; +import org.eclipse.team.internal.ui.actions.TeamAction; import org.eclipse.team.internal.ui.dialogs.DialogArea; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.model.WorkbenchContentProvider; @@ -76,7 +76,6 @@ public class TagSelectionArea extends DialogArea { private String helpContext; private Text filterText; private TagSource tagSource; - private Label tagAreaTextLabel; private final Shell shell; private TagRefreshButtonArea tagRefreshArea; private final TagSource.ITagSourceChangeListener listener = new TagSource.ITagSourceChangeListener() { @@ -146,9 +145,9 @@ public class TagSelectionArea extends DialogArea { Composite inner = createGrabbingComposite(parent, 1); if (isIncludeFilterInputArea()) { createFilterInput(inner); - tagAreaTextLabel = createWrappingLabel(inner, CVSUIMessages.TagSelectionArea_0, 1); + createWrappingLabel(inner, CVSUIMessages.TagSelectionArea_0, 1); } else { - tagAreaTextLabel = createWrappingLabel(inner, NLS.bind(CVSUIMessages.TagSelectionArea_1, new String[] { getTagAreaLabel() }), 1); + createWrappingLabel(inner, NLS.bind(CVSUIMessages.TagSelectionArea_1, new String[] { getTagAreaLabel() }), 1); } switcher = new PageBook(inner, SWT.NONE); GridData gridData = new GridData(GridData.FILL_BOTH); @@ -430,7 +429,7 @@ public class TagSelectionArea extends DialogArea { dateTagElements = new ArrayList(); Iterator elements = selection.iterator(); while (elements.hasNext()) { - Object next = CVSAction.getAdapter(elements.next(), TagElement.class); + Object next = TeamAction.getAdapter(elements.next(), TagElement.class); if (next instanceof TagElement) { if(((TagElement)next).getTag().getType() == CVSTag.DATE){ dateTagElements.add(next); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java index 189d8d7dd..ff79b25bb 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Philippe Ombredanne - bug 84808 *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.wizards; @@ -24,7 +25,9 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; +import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; +import org.eclipse.team.internal.ccvs.ui.operations.RemoteProjectFolder; import org.eclipse.ui.model.WorkbenchContentProvider; import org.eclipse.ui.model.WorkbenchLabelProvider; import org.eclipse.ui.views.navigator.ResourceSorter; @@ -310,4 +313,20 @@ public abstract class CVSWizardPage extends WizardPage { } return super.canFlipToNextPage(); } + + /** + * Utility method to get a folder name based on preferences. + * Returns the folder name or the project name retrieved from the project metafile + * @param the CVS remote folder + * @return a project name + */ + static protected String getPreferredFolderName(ICVSRemoteFolder folder) { + if (CVSUIPlugin.getPlugin().isUseProjectNameOnCheckout() && folder instanceof RemoteProjectFolder ) { + RemoteProjectFolder rpf = (RemoteProjectFolder) folder; + if (rpf.hasProjectName()) { + return rpf.getProjectName(); + } + } + return folder.getName(); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java index 4145b846f..37b46c000 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Philippe Ombredanne - bug 84808 *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.wizards; @@ -105,7 +106,7 @@ public class CheckoutAsLocationSelectionPage extends CVSWizardPage { private IProject getSingleProject() { if (singleProject == null) { - setProjectName(remoteFolders[0].getName()); + setProjectName(getPreferredFolderName(remoteFolders[0])); } return singleProject; } @@ -295,7 +296,7 @@ public class CheckoutAsLocationSelectionPage extends CVSWizardPage { return locationStatus.getMessage(); } else { for (int i = 0; i < remoteFolders.length; i++) { - String projectName = remoteFolders[i].getName(); + String projectName = getPreferredFolderName(remoteFolders[i]); IStatus locationStatus = ResourcesPlugin.getWorkspace().validateProjectLocation( ResourcesPlugin.getWorkspace().getRoot().getProject(projectName), new Path(targetLocation).append(projectName)); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java index 77a41d17f..495c5f934 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Philippe Ombredanne - bug 84808 *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.wizards; @@ -87,7 +88,7 @@ public class CheckoutAsMainPage extends CVSWizardPage { * For the single folder case, return the name of the folder */ private String getFolderName() { - String name = folders[0].getName(); + String name = getPreferredFolderName(folders[0]); if (name .equals(".")) { //$NON-NLS-1$ name = new Path(null, folders[0].getRepository().getRootDirectory()).lastSegment(); } @@ -194,6 +195,7 @@ public class CheckoutAsMainPage extends CVSWizardPage { if (!nameStatus.isOK()) { setErrorMessage(nameStatus.getMessage()); setPageComplete(false); + return; } } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java index aa721e7f4..6cf866f63 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Philippe Ombredanne - bug 84808 *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.wizards; @@ -73,7 +74,7 @@ public class CheckoutAsProjectSelectionPage extends CVSWizardPage { * For the single folder case, return the name of the folder */ private String getInputFolderName() { - return remoteFolders[0].getName(); + return getPreferredFolderName(remoteFolders[0]); } private String getRepository() throws CVSException { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java index f50a65b8d..400610ca6 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Philippe Ombredanne - bug 84808 *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.wizards; @@ -227,6 +228,18 @@ public class CheckoutAsWizard extends Wizard { return folders; } + /* + * Return the remote folders to be checked out with + * Folder description if available based on preferrences settings + */ + private ICVSRemoteFolder[] getRemoteFoldersWithProjectDescriptions() throws InvocationTargetException, InterruptedException { + ICVSRemoteFolder[] folders = getRemoteFolders(); + if (CVSUIPlugin.getPlugin().isUseProjectNameOnCheckout()) { + folders = ProjectMetaFileOperation.updateFoldersWithProjectName(part, folders); + } + return folders; + } + private CVSTag getSelectedTag() { return tagSelectionPage.getSelectedTag(); } @@ -247,7 +260,7 @@ public class CheckoutAsWizard extends Wizard { private boolean performMultipleCheckoutAs() throws InvocationTargetException, InterruptedException { String targetLocation = locationSelectionPage.getTargetLocation(); // Run the checkout in the background - new CheckoutMultipleProjectsOperation(part, getRemoteFolders(), targetLocation).run(); + new CheckoutMultipleProjectsOperation(part, getRemoteFoldersWithProjectDescriptions(), targetLocation).run(); return true; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java index a7fca3b43..bdfcbcd70 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Philippe Ombredanne - bug 84808 *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.wizards; @@ -24,7 +25,7 @@ import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; import org.eclipse.team.internal.ccvs.ui.*; import org.eclipse.team.internal.ccvs.ui.operations.CheckoutMultipleProjectsOperation; -import org.eclipse.team.internal.ccvs.ui.operations.HasProjectMetaFileOperation; +import org.eclipse.team.internal.ccvs.ui.operations.ProjectMetaFileOperation; import org.eclipse.ui.*; /** @@ -188,7 +189,25 @@ public class CheckoutWizard extends Wizard implements ICVSWizard, INewWizard { boolean hasMetafile = true; if (selectedModules.length == 1) { // Only allow configuration if one module is selected - hasMetafile = hasProjectMetafile(selectedModules[0]); + final ICVSRemoteFolder[] folders = new ICVSRemoteFolder[] {selectedModules[0]}; + final boolean withName = CVSUIPlugin.getPlugin().isUseProjectNameOnCheckout(); + + // attempt to retrieve the project description depending on preferences + // this is a bit circumvoluted to batch the metafile check and retrieval in one op + final ICVSRemoteFolder[] folderResult = new ICVSRemoteFolder [1]; + final boolean[] booleanResult = new boolean[] { true }; + + getContainer().run(true, true, new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + ProjectMetaFileOperation op = new ProjectMetaFileOperation(getPart(), new ICVSRemoteFolder[] {folders[0]}, withName); + op.run(monitor); + folderResult[0] = op.getUpdatedFolders()[0]; + booleanResult[0] = op.metaFileExists(); + } + }); + hasMetafile = booleanResult[0]; + if (withName && hasMetafile) + selectedModules[0] = folderResult[0]; } resetSubwizard(); wizard = new CheckoutAsWizard(getPart(), selectedModules, ! hasMetafile /* allow configuration */); @@ -215,18 +234,6 @@ public class CheckoutWizard extends Wizard implements ICVSWizard, INewWizard { return null; } - private boolean hasProjectMetafile(final ICVSRemoteFolder selectedModule) throws InvocationTargetException, InterruptedException { - final boolean[] result = new boolean[] { true }; - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - HasProjectMetaFileOperation op = new HasProjectMetaFileOperation(getPart(), selectedModule); - op.run(monitor); - result[0] = op.metaFileExists(); - } - }); - return result[0]; - } - private ICVSRemoteFolder[] getSelectedModules() { if (modulePage == null) return null; return modulePage.getSelectedModules(); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java index 34e0a96dd..aeb3fbaab 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java @@ -330,7 +330,7 @@ public class CommitWizard extends ResizableWizard { for (final Iterator iter = infos.iterator(); iter.hasNext();) { final SyncInfo info = (SyncInfo) iter.next(); final IResource file= info.getLocal(); - if (!((file.getType() & IResource.FILE) == 0 || isAdded(file))) + if (!isAdded(file)) unadded.add(info); } return unadded; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileOperation.java deleted file mode 100644 index 1f47524f4..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileOperation.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.dnd.Clipboard; -import org.eclipse.swt.dnd.TextTransfer; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSTeamProvider; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; - -/** - * An operation to run the CVS diff operation on a set of resources. The result - * of the diff is written to a file. If there are no differences found, the - * user is notified and the output file is not created. - */ -public class GenerateDiffFileOperation implements IRunnableWithProgress { - - private File outputFile; - private IResource resource; - private Shell shell; - private LocalOption[] options; - - GenerateDiffFileOperation(IResource resource, File file, LocalOption[] options, Shell shell) { - this.resource = resource; - this.outputFile = file; - this.shell = shell; - this.options = options; - } - - /** - * @see IRunnableWithProgress#run(IProgressMonitor) - */ - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - - final CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()); - monitor.beginTask("", 500); //$NON-NLS-1$ - monitor.setTaskName(CVSUIMessages.GenerateCVSDiff_working); - try { - if (outputFile != null) { - generateDiffToFile(monitor, provider, outputFile); - } else { - generateDiffToClipboard(monitor, provider); - } - } catch (TeamException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - - private void generateDiffToFile(IProgressMonitor monitor, CVSTeamProvider provider, File file) throws TeamException { - - final FileOutputStream os; - try { - os= new FileOutputStream(file); - try { - provider.diff(resource, options, new PrintStream(os), new SubProgressMonitor(monitor, 500)); - } finally { - os.close(); - } - } catch (FileNotFoundException e) { - throw new TeamException(CVSUIMessages.GenerateDiffFileOperation_0, e); - } catch (IOException e) { - throw new TeamException(CVSUIMessages.GenerateDiffFileOperation_1, e); - } - - if (file.length() == 0) { - outputFile.delete(); - reportEmptyDiff(); - } - } - - private void generateDiffToClipboard(IProgressMonitor monitor, CVSTeamProvider provider) throws TeamException { - final ByteArrayOutputStream os = new ByteArrayOutputStream(); - try { - try { - provider.diff(resource, options, new PrintStream(os), new SubProgressMonitor(monitor, 500)); - } finally { - os.close(); - } - } catch (IOException e) { - throw new TeamException(CVSUIMessages.GenerateDiffFileOperation_2, e); - } - if (os.size() == 0) { - reportEmptyDiff(); - } else { - copyToClipboard(os); - } - } - - private void copyToClipboard(final ByteArrayOutputStream baos) { - shell.getDisplay().syncExec(new Runnable() { - public void run() { - TextTransfer plainTextTransfer = TextTransfer.getInstance(); - Clipboard clipboard = new Clipboard(shell.getDisplay()); - clipboard.setContents( - new String[]{baos.toString()}, - new Transfer[]{plainTextTransfer}); - clipboard.dispose(); - } - }); - } - - private void reportEmptyDiff() { - CVSUIPlugin.openDialog(shell, new CVSUIPlugin.IOpenableInShell() { - public void open(Shell shell) { - MessageDialog.openInformation( - shell, - CVSUIMessages.GenerateCVSDiff_noDiffsFoundTitle, - CVSUIMessages.GenerateCVSDiff_noDiffsFoundMsg); - } - }, CVSUIPlugin.PERFORM_SYNC_EXEC); - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java index 2e9c4e1c3..78e073410 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java @@ -20,36 +20,64 @@ import java.util.List; import org.eclipse.core.resources.*; import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.dialogs.*; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.*; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.jface.wizard.*; +import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.*; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ccvs.core.client.Command; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.core.synchronize.SyncInfoSet; +import org.eclipse.team.internal.ccvs.core.CVSException; import org.eclipse.team.internal.ccvs.core.client.Diff; import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; import org.eclipse.team.internal.ccvs.ui.*; +import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; +import org.eclipse.team.internal.ccvs.ui.operations.*; +import org.eclipse.team.internal.ccvs.ui.subscriber.CreatePatchWizardParticipant; +import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant; +import org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoCollector; +import org.eclipse.team.internal.ui.*; +import org.eclipse.team.ui.synchronize.*; +import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.internal.ide.misc.ContainerContentProvider; +import org.eclipse.ui.model.BaseWorkbenchContentProvider; import org.eclipse.ui.model.WorkbenchLabelProvider; +import org.eclipse.ui.part.PageBook; /** * A wizard for creating a patch file by running the CVS diff command. */ public class GenerateDiffFileWizard extends Wizard { - + + //temp falg for enabling workspace patches + public final static String WORKSPACEPATCH_FLAG = "workspacePatch"; //$NON-NLS-1$ + //The initial size of this wizard. + private final static int INITIAL_WIDTH = 300; + private final static int INITIAL_HEIGHT = 350; + + public static void run(IWorkbenchPart part, final IResource[] resources) { + final String title = CVSUIMessages.GenerateCVSDiff_title; + final GenerateDiffFileWizard wizard = new GenerateDiffFileWizard(part,resources); + wizard.setWindowTitle(title); + WizardDialog dialog = new WizardDialog(part.getSite().getShell(), wizard); + dialog.setMinimumPageSize(INITIAL_WIDTH, INITIAL_HEIGHT); + dialog.open(); + } + /** * Page to select a patch file. Overriding validatePage was necessary to allow * entering a file name that already exists. */ - private class LocationPage extends WizardPage { + public class LocationPage extends WizardPage { /** * The possible locations to save a patch. @@ -68,26 +96,203 @@ public class GenerateDiffFileWizard extends Wizard { private Button fsBrowseButton; private Button wsRadio; - protected TreeViewer wsTreeViewer; - private Text wsFilenameText; - + protected Text wsPathText; + private Button wsBrowseButton; + + protected CreatePatchWizardParticipant fParticipant; + private Button chgSelectAll; + private Button chgDeselectAll; /** * State information of this page, updated by the listeners. */ + protected boolean canValidate; protected boolean pageValid; protected IContainer wsSelectedContainer; + protected IPath[] foldersToCreate; protected int selectedLocation; /** * The default values store used to initialize the selections. */ private final DefaultValuesStore store; + + + class LocationPageContentProvider extends BaseWorkbenchContentProvider { + //Never show closed projects + boolean showClosedProjects=false; + + public Object[] getChildren(Object element) { + if (element instanceof IWorkspace) { + // check if closed projects should be shown + IProject[] allProjects = ((IWorkspace) element).getRoot().getProjects(); + if (showClosedProjects) + return allProjects; + + ArrayList accessibleProjects = new ArrayList(); + for (int i = 0; i < allProjects.length; i++) { + if (allProjects[i].isOpen()) { + accessibleProjects.add(allProjects[i]); + } + } + return accessibleProjects.toArray(); + } + + return super.getChildren(element); + } + } + + class WorkspaceDialog extends TitleAreaDialog { + + protected TreeViewer wsTreeViewer; + protected Text wsFilenameText; + protected Image dlgTitleImage; + + public WorkspaceDialog(Shell shell) { + super(shell); + } + + protected Control createContents(Composite parent) { + Control control = super.createContents(parent); + setTitle(CVSUIMessages.Select_a_folder_then_type_in_the_file_name__8); + //create title image + dlgTitleImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_DIFF).createImage(); + setTitleImage(dlgTitleImage); + + return control; + } + + protected Control createDialogArea(Composite parent){ + Composite composite = (Composite) super.createDialogArea(parent); + + + GridLayout layout = new GridLayout(); + layout.numColumns = 1; + composite.setLayout(layout); + final GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); + composite.setLayoutData(data); + + getShell().setText(CVSUIMessages.GenerateDiffFileWizard_9); + + wsTreeViewer = new TreeViewer(composite, SWT.BORDER); + final GridData gd= new GridData(SWT.FILL, SWT.FILL, true, true); + gd.widthHint= 550; + gd.heightHint= 250; + wsTreeViewer.getTree().setLayoutData(gd); + + wsTreeViewer.setContentProvider(new LocationPageContentProvider()); + wsTreeViewer.setLabelProvider(new WorkbenchLabelProvider()); + wsTreeViewer.setInput(ResourcesPlugin.getWorkspace()); + + //Open to whatever is selected in the workspace field + IPath existingWorkspacePath = new Path(wsPathText.getText()); + if (existingWorkspacePath != null){ + //Ensure that this workspace path is valid + IResource selectedResource = ResourcesPlugin.getWorkspace().getRoot().findMember(existingWorkspacePath); + if (selectedResource != null) { + wsTreeViewer.expandToLevel(selectedResource, 0); + wsTreeViewer.setSelection(new StructuredSelection(selectedResource)); + } + } + + final Composite group = new Composite(composite, SWT.NONE); + layout = new GridLayout(2, false); + layout.marginWidth = 0; + group.setLayout(layout); + group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + + final Label label = new Label(group, SWT.NONE); + label.setLayoutData(new GridData()); + label.setText(CVSUIMessages.Fi_le_name__9); + + wsFilenameText = new Text(group,SWT.BORDER); + wsFilenameText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); + + setupListeners(); + + return parent; + } + + protected void okPressed() { + //make sure that a filename has been typed in + + String patchName = wsFilenameText.getText(); + + if (patchName.equals("")){ //$NON-NLS-1$ + setErrorMessage(CVSUIMessages.GenerateDiffFileWizard_2); + return; + } + + //make sure that the filename does not contain more than one segment + if (!(ResourcesPlugin.getWorkspace().validateName(patchName, IResource.FILE)).isOK()){ + wsFilenameText.setText(""); //$NON-NLS-1$ + setErrorMessage(CVSUIMessages.GenerateDiffFileWizard_File_multisegments); + return; + } + + IFile file = wsSelectedContainer.getFile(new Path(wsFilenameText.getText())); + if (file != null) + wsPathText.setText(file.getFullPath().toString()); + + validatePage(); + super.okPressed(); + } + + protected void cancelPressed() { + validatePage(); + super.cancelPressed(); + } + + public boolean close() { + if (dlgTitleImage != null) + dlgTitleImage.dispose(); + return super.close(); + } + + void setupListeners(){ + wsTreeViewer.addSelectionChangedListener( + new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection s = (IStructuredSelection)event.getSelection(); + Object obj=s.getFirstElement(); + if (obj instanceof IContainer) + wsSelectedContainer = (IContainer) obj; + else if (obj instanceof IFile){ + IFile tempFile = (IFile) obj; + wsSelectedContainer = tempFile.getParent(); + wsFilenameText.setText(tempFile.getName()); + } + + } + }); + + wsTreeViewer.addDoubleClickListener( + new IDoubleClickListener() { + public void doubleClick(DoubleClickEvent event) { + ISelection s= event.getSelection(); + if (s instanceof IStructuredSelection) { + Object item = ((IStructuredSelection)s).getFirstElement(); + if (wsTreeViewer.getExpandedState(item)) + wsTreeViewer.collapseToLevel(item, 1); + else + wsTreeViewer.expandToLevel(item, 1); + } + } + }); + wsFilenameText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + setErrorMessage(null); + } + }); + } + } + LocationPage(String pageName, String title, ImageDescriptor image, DefaultValuesStore store) { super(pageName, title, image); setPageComplete(false); this.store= store; + this.canValidate=false; } /** @@ -95,6 +300,9 @@ public class GenerateDiffFileWizard extends Wizard { */ protected boolean validatePage() { + if (!canValidate) + return false; + switch (selectedLocation) { case WORKSPACE: pageValid= validateWorkspaceLocation(); @@ -164,15 +372,32 @@ public class GenerateDiffFileWizard extends Wizard { * - the resource name must be valid */ private boolean validateWorkspaceLocation() { - if (wsSelectedContainer == null) { - setErrorMessage(CVSUIMessages.GenerateDiffFileWizard_4); - return false; + //make sure that the field actually has a filename in it + if (wsPathText.getText().equals("")){ //$NON-NLS-1$ + if (selectedLocation ==WORKSPACE) + setErrorMessage(CVSUIMessages.GenerateDiffFileWizard_5); + return false; } - final String filename= wsFilenameText.getText().trim(); - if (!new Path("").isValidSegment(filename)) { //$NON-NLS-1$ - setErrorMessage(CVSUIMessages.GenerateDiffFileWizard_5); + + //Make sure that all the segments but the last one (i.e. project + all + //folders) exist - file doesn't have to exist. It may have happened that + //some folder refactoring has been done since this path was last saved. + // + //Assume that the path will always be in format project/{folders}*/file - this + //is controlled by the workspace location dialog + + + IPath pathToWorkspaceFile = new Path(wsPathText.getText()); + //Trim file name from path + IPath containerPath = pathToWorkspaceFile.removeLastSegments(1); + + IResource container =ResourcesPlugin.getWorkspace().getRoot().findMember(containerPath); + if (container == null) { + if (selectedLocation == WORKSPACE) + setErrorMessage(CVSUIMessages.GenerateDiffFileWizard_4); return false; } + return true; } @@ -185,21 +410,37 @@ public class GenerateDiffFileWizard extends Wizard { return new File(fsPathText.getText().trim()); } if (pageValid && selectedLocation == WORKSPACE) { - final String filename= wsFilenameText.getText().trim(); - final IFile file= wsSelectedContainer.getFile(new Path(filename)); + final String filename= wsPathText.getText().trim(); + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + final IFile file= root.getFile(new Path(filename)); return file.getLocation().toFile(); } return null; } /** + * Answers the workspace string entered in the dialog or <code>null</code> if the user + * selected to save the patch in the clipboard or file system. + */ + public String getWorkspaceLocation() { + + if (pageValid && selectedLocation == WORKSPACE) { + final String filename= wsPathText.getText().trim(); + return filename; + } + return null; + } + + /** * Get the selected workspace resource if the patch is to be saved in the * workspace, or null otherwise. */ public IResource getResource() { if (pageValid && selectedLocation == WORKSPACE) { - final String filename= wsFilenameText.getText().trim(); - return wsSelectedContainer.getFile(new Path(null, filename)); + IPath pathToWorkspaceFile = new Path(wsPathText.getText().trim()); + //Trim file name from path + IPath containerPath = pathToWorkspaceFile.removeLastSegments(1); + return ResourcesPlugin.getWorkspace().getRoot().findMember(containerPath); } return null; } @@ -218,62 +459,100 @@ public class GenerateDiffFileWizard extends Wizard { // set F1 help PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.PATCH_SELECTION_PAGE); - setupClipboardControls(composite); - setupFilesystemControls(composite); - setupWorkspaceControls(composite); - - Dialog.applyDialogFont(parent); + //Create a location group + Group locationGroup = new Group(composite, SWT.None); + GridLayout layout = new GridLayout(); + locationGroup.setLayout(layout); + GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); + locationGroup.setLayoutData(data); + locationGroup.setText(CVSUIMessages.GenerateDiffFileWizard_9); + // + setupClipboardControls(locationGroup); + setupFilesystemControls(locationGroup); + setupWorkspaceControls(locationGroup); initializeDefaultValues(); + fParticipant = new CreatePatchWizardParticipant(new ResourceScope(((GenerateDiffFileWizard)this.getWizard()).resources), (GenerateDiffFileWizard) this.getWizard()); + try { + getAllOutOfSync(); + } catch (CVSException e) {} + + final PixelConverter converter= new PixelConverter(parent); + createChangesArea(composite, converter); + + createSelectionButtons(composite); + + Dialog.applyDialogFont(parent); + /** * Ensure the page is in a valid state. */ - if (!validatePage()) { + /*if (!validatePage()) { store.storeRadioSelection(CLIPBOARD); initializeDefaultValues(); validatePage(); } - pageValid= true; + pageValid= true;*/ + validatePage(); updateEnablements(); setupListeners(); } - /** + private void createSelectionButtons(Composite composite) { + final Composite buttonGroup = new Composite(composite,SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + layout.marginWidth = 0; + layout.marginHeight = 0; + layout.horizontalSpacing = 0; + layout.verticalSpacing = 0; + buttonGroup.setLayout(layout); + GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END + | GridData.VERTICAL_ALIGN_CENTER); + buttonGroup.setLayoutData(data); + + chgSelectAll = createSelectionButton(CVSUIMessages.GenerateDiffFileWizard_SelectAll, buttonGroup); + chgDeselectAll = createSelectionButton(CVSUIMessages.GenerateDiffFileWizard_DeselectAll, buttonGroup); + } + + private Button createSelectionButton(String buttonName, Composite buttonGroup) { + Button button = new Button(buttonGroup,SWT.PUSH); + button.setText(buttonName); + GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); + Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); + data.widthHint = Math.max(widthHint, minSize.x); + button.setLayoutData(data); + return button; + } + + /** * Setup the controls for the workspace option. */ private void setupWorkspaceControls(Composite composite) { + GridLayout layout; + wsRadio= new Button(composite, SWT.RADIO); wsRadio.setText(CVSUIMessages.Save_In_Workspace_7); - - new Label(composite, SWT.LEFT).setText(CVSUIMessages.Select_a_folder_then_type_in_the_file_name__8); - - wsTreeViewer = new TreeViewer(composite, SWT.BORDER); - final GridData gd= new GridData(SWT.FILL, SWT.FILL, true, true); - gd.widthHint= 0; - gd.heightHint= 0; - wsTreeViewer.getTree().setLayoutData(gd); - - final ContainerContentProvider cp = new ContainerContentProvider(); - cp.showClosedProjects(false); - wsTreeViewer.setContentProvider(cp); - wsTreeViewer.setLabelProvider(new WorkbenchLabelProvider()); - wsTreeViewer.setInput(ResourcesPlugin.getWorkspace()); - - final Composite group = new Composite(composite, SWT.NONE); - final GridLayout layout = new GridLayout(2, false); + + final Composite nameGroup = new Composite(composite,SWT.NONE); + layout = new GridLayout(); + layout.numColumns = 2; layout.marginWidth = 0; - group.setLayout(layout); - group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + nameGroup.setLayout(layout); + final GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); + nameGroup.setLayoutData(data); - final Label label = new Label(group, SWT.NONE); - label.setLayoutData(new GridData()); - label.setText(CVSUIMessages.Fi_le_name__9); + wsPathText= new Text(nameGroup, SWT.BORDER); + GridData gd= new GridData(GridData.FILL_HORIZONTAL); + wsPathText.setLayoutData(gd); + wsPathText.setEditable(false); - wsFilenameText = new Text(group,SWT.BORDER); - wsFilenameText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); + wsBrowseButton = new Button(nameGroup, SWT.NULL); + wsBrowseButton.setText(CVSUIMessages.Browse____4); } /** @@ -290,7 +569,7 @@ public class GenerateDiffFileWizard extends Wizard { layout.numColumns = 2; layout.marginWidth = 0; nameGroup.setLayout(layout); - final GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); + final GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); nameGroup.setLayoutData(data); fsPathText= new Text(nameGroup, SWT.BORDER); @@ -309,7 +588,65 @@ public class GenerateDiffFileWizard extends Wizard { cpRadio.setText(CVSUIMessages.Save_To_Clipboard_2); } + private ParticipantPagePane fPagePane; + private PageBook bottomChild; + private ISynchronizePageConfiguration fConfiguration; + + private void createChangesArea(Composite parent, PixelConverter converter) { + + int size = fParticipant.getSyncInfoSet().size(); + if (size > getFileDisplayThreshold()) { + // Create a page book to allow eventual inclusion of changes + bottomChild = new PageBook(parent, SWT.NONE); + bottomChild.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, false)); + // Create composite for showing the reason for not showing the changes and a button to show them + Composite changeDesc = new Composite(bottomChild, SWT.NONE); + changeDesc.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_NONE)); + SWTUtils.createLabel(changeDesc, NLS.bind(CVSUIMessages.CommitWizardCommitPage_1, new String[] { Integer.toString(size), Integer.toString(getFileDisplayThreshold()) })); + Button showChanges = new Button(changeDesc, SWT.PUSH); + showChanges.setText(CVSUIMessages.CommitWizardCommitPage_5); + showChanges.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + showChangesPane(); + } + }); + showChanges.setLayoutData(new GridData()); + bottomChild.showPage(changeDesc); + } else { + final Composite composite= new Composite(parent, SWT.NONE); + composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_NONE)); + composite.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, true)); + + createPlaceholder(composite); + + Control c = createChangesPage(composite, fParticipant); + c.setLayoutData(SWTUtils.createHVFillGridData()); + } + } + protected void showChangesPane() { + Control c = createChangesPage(bottomChild, fParticipant); + bottomChild.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, true)); + bottomChild.showPage(c); + Dialog.applyDialogFont(getControl()); + ((Composite)getControl()).layout(); + } + + private Control createChangesPage(final Composite composite, WorkspaceSynchronizeParticipant participant) { + fConfiguration= participant.createPageConfiguration(); + fPagePane= new ParticipantPagePane(getShell(), true /* modal */, fConfiguration, participant); + Control control = fPagePane.createPartControl(composite); + return control; + } + + private int getFileDisplayThreshold() { + return CVSUIPlugin.getPlugin().getPreferenceStore().getInt(ICVSUIConstants.PREF_COMMIT_FILES_DISPLAY_THRESHOLD); + } + + private void createPlaceholder(final Composite composite) { + final Composite placeholder= new Composite(composite, SWT.NONE); + placeholder.setLayoutData(new GridData(SWT.DEFAULT, convertHorizontalDLUsToPixels(IDialogConstants.VERTICAL_SPACING) /3)); + } /** * Initialize the controls with the saved default values which are * obtained from the DefaultValuesStore. @@ -317,29 +654,39 @@ public class GenerateDiffFileWizard extends Wizard { private void initializeDefaultValues() { selectedLocation= store.getRadioSelection(); - wsSelectedContainer= store.getWorkspaceSelection(); - /** - * Radio buttons - */ - cpRadio.setSelection(selectedLocation == CLIPBOARD); - fsRadio.setSelection(selectedLocation == FILESYSTEM); - wsRadio.setSelection(selectedLocation == WORKSPACE); + updateRadioButtons(); /** * Text fields. */ fsPathText.setText(store.getFilesystemPath()); - wsFilenameText.setText(store.getWorkspaceFilename()); - - /** - * Tree viewer. - */ - if (wsSelectedContainer != null) { - final ISelection selection= new StructuredSelection(wsSelectedContainer); - wsTreeViewer.setSelection(selection, true); + //We need to ensure that we have a valid workspace path - user + //could have altered workspace since last time this was saved + wsPathText.setText(store.getWorkspacePath()); + if(!validateWorkspaceLocation()) { + wsPathText.setText(""); //$NON-NLS-1$ + + //Don't open wizard with an error - instead change selection + //to clipboard + if (selectedLocation == WORKSPACE){ + //clear the error message caused by the workspace not having + //any workspace path entered + setErrorMessage(null); + selectedLocation=CLIPBOARD; + updateRadioButtons(); + } } } + + private void updateRadioButtons() { + /** + * Radio buttons + */ + cpRadio.setSelection(selectedLocation == CLIPBOARD); + fsRadio.setSelection(selectedLocation == FILESYSTEM); + wsRadio.setSelection(selectedLocation == WORKSPACE); + } /** * Setup all the listeners for the controls. @@ -391,61 +738,153 @@ public class GenerateDiffFileWizard extends Wizard { } }); - wsTreeViewer.addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection s = (IStructuredSelection)event.getSelection(); - wsSelectedContainer = ((IContainer) s.getFirstElement()); - validatePage(); - } - }); - - wsTreeViewer.addDoubleClickListener( - new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - ISelection s= event.getSelection(); - if (s instanceof IStructuredSelection) { - Object item = ((IStructuredSelection)s).getFirstElement(); - if (wsTreeViewer.getExpandedState(item)) - wsTreeViewer.collapseToLevel(item, 1); - else - wsTreeViewer.expandToLevel(item, 1); - } - } - }); + - wsFilenameText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - validatePage(); + wsBrowseButton.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event event) { + final WorkspaceDialog dialog = new WorkspaceDialog(getShell()); + dialog.open(); + + } - }); + }); + + + chgSelectAll.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + initCheckedItems(); + //Only bother changing isPageComplete state if the current state + //is not enabled + if (!isPageComplete()) + setPageComplete((getSelectedResources()).length > 0); + } + }); + + chgDeselectAll.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + ISynchronizePage page = fConfiguration.getPage(); + if (page != null){ + Viewer viewer = page.getViewer(); + if (viewer instanceof CheckboxTreeViewer) { + CheckboxTreeViewer treeViewer =(CheckboxTreeViewer)viewer; + treeViewer.setCheckedElements(new Object[0]); + } + } + //Only bother changing isPageComplete state if the current state + //is enabled + if (isPageComplete()) + setPageComplete((getSelectedResources()).length > 0); + } + }); + + ISynchronizePage page = fConfiguration.getPage(); + if (page != null) { + Viewer viewer = page.getViewer(); + if (viewer instanceof CheckboxTreeViewer) { + ((CheckboxTreeViewer)viewer).addCheckStateListener(new ICheckStateListener() { + public void checkStateChanged(CheckStateChangedEvent event) { + setPageComplete((resources = getSelectedResources()).length > 0); + } + }); + } + } } + protected void initCheckedItems() { + ISynchronizePage page = fConfiguration.getPage(); + if (page != null) { + Viewer viewer = page.getViewer(); + if (viewer instanceof CheckboxTreeViewer) { + TreeItem[] items=((CheckboxTreeViewer)viewer).getTree().getItems(); + for (int i = 0; i < items.length; i++) { + ((CheckboxTreeViewer)viewer).setChecked(items[i].getData(), true); + } + } + } + } + + protected IResource[] getSelectedResources() { + ISynchronizePage page = fConfiguration.getPage(); + if (page != null) { + Viewer viewer = page.getViewer(); + if (viewer instanceof CheckboxTreeViewer) { + Object[] elements = ((CheckboxTreeViewer)viewer).getCheckedElements(); + IResource[]selectedResources = Utils.getResources(elements); + ArrayList result = new ArrayList(); + for (int i = 0; i < selectedResources.length; i++) { + IResource resource = selectedResources[i]; + if (fConfiguration.getSyncInfoSet().getSyncInfo(resource) != null) { + result.add(resource); + } + } + return (IResource[]) result.toArray(new IResource[result.size()]); + } + } + return new IResource[0]; + } + /** * Enable and disable controls based on the selected radio button. */ - protected void updateEnablements() { + public void updateEnablements() { fsBrowseButton.setEnabled(selectedLocation == FILESYSTEM); fsPathText.setEnabled(selectedLocation == FILESYSTEM); - wsTreeViewer.getTree().setEnabled(selectedLocation == WORKSPACE); - wsFilenameText.setEnabled(selectedLocation == WORKSPACE); + wsPathText.setEnabled(selectedLocation == WORKSPACE); + wsBrowseButton.setEnabled(selectedLocation == WORKSPACE); } public int getSelectedLocation() { return selectedLocation; } + + private SyncInfoSet getAllOutOfSync() throws CVSException { + final SubscriberSyncInfoCollector syncInfoCollector = fParticipant.getSubscriberSyncInfoCollector(); + //WaitForChangesJob waits for the syncInfoCollector to get all the changes + //before checking off the tree items and validating the page + class WaitForChangesJob extends Job{ + LocationPage fLocationPage; + + public WaitForChangesJob(LocationPage page) { + super(""); //$NON-NLS-1$ + fLocationPage=page; + } + public IStatus run(IProgressMonitor monitor) { + monitor.beginTask(CVSUIMessages.CommitWizard_4, IProgressMonitor.UNKNOWN); + syncInfoCollector.waitForCollector(monitor); + Utils.syncExec(new Runnable() { + public void run() { + fLocationPage.initCheckedItems(); + fLocationPage.canValidate=true; + fLocationPage.validatePage(); + } + }, getControl()); + monitor.done(); + return Status.OK_STATUS; + } + } + WaitForChangesJob job =new WaitForChangesJob(this); + //Don't need the job in the UI, make it a system job + job.setSystem(true); + job.schedule(); + return fParticipant.getSyncInfoSet(); + } + } /** * Page to select the options for creating the patch. */ private class OptionsPage extends WizardPage { - - private Button recurseOption; + + private Button unifiedDiffOption; + private Button unified_workspaceRelativeOption; //multi-patch format + private Button unified_projectRelativeOption; //full project path + private Button unified_selectionRelativeOption; //use path of whatever is selected private Button contextDiffOption; - private Button unifiedDiffOption; private Button regularDiffOption; - private Button includeNewFilesOptions; + + private boolean patchHasCommonRoot=true; + protected IPath patchRoot=ResourcesPlugin.getWorkspace().getRoot().getFullPath(); /** * Constructor for PatchFileCreationOptionsPage. @@ -466,15 +905,7 @@ public class GenerateDiffFileWizard extends Wizard { // set F1 help PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.PATCH_OPTIONS_PAGE); - - recurseOption = new Button(composite, SWT.CHECK); - recurseOption.setText(CVSUIMessages.Do_not_recurse_into_sub_folders_10); - recurseOption.setSelection(true); - - includeNewFilesOptions = new Button(composite, SWT.CHECK); - includeNewFilesOptions.setText(CVSUIMessages.Do_not_include_new_files_in_patch_11); - includeNewFilesOptions.setSelection(true); - + Group diffTypeGroup = new Group(composite, SWT.NONE); layout = new GridLayout(); layout.marginHeight = 0; @@ -483,41 +914,170 @@ public class GenerateDiffFileWizard extends Wizard { diffTypeGroup.setLayoutData(data); diffTypeGroup.setText(CVSUIMessages.Diff_output_format_12); + unifiedDiffOption = new Button(diffTypeGroup, SWT.RADIO); - unifiedDiffOption.setText(CVSUIMessages.Unified__format_required_by_Compare_With_Patch_feature__13); - unifiedDiffOption.setSelection(true); + unifiedDiffOption.setText(CVSUIMessages.Unified__format_required_by_Compare_With_Patch_feature__13); + contextDiffOption = new Button(diffTypeGroup, SWT.RADIO); contextDiffOption.setText(CVSUIMessages.Context_14); regularDiffOption = new Button(diffTypeGroup, SWT.RADIO); regularDiffOption.setText(CVSUIMessages.Standard_15); + //Unified Format Options + Group unifiedGroup = new Group(composite, SWT.None); + layout = new GridLayout(); + unifiedGroup.setLayout(layout); + data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); + unifiedGroup.setLayoutData(data); + unifiedGroup.setText(CVSUIMessages.GenerateDiffFileWizard_10); + + unified_workspaceRelativeOption = new Button(unifiedGroup, SWT.RADIO); + unified_workspaceRelativeOption.setText(CVSUIMessages.GenerateDiffFileWizard_6); + unified_workspaceRelativeOption.setSelection(true); + + unified_projectRelativeOption = new Button(unifiedGroup, SWT.RADIO); + unified_projectRelativeOption.setText(CVSUIMessages.GenerateDiffFileWizard_7); + + unified_selectionRelativeOption = new Button(unifiedGroup, SWT.RADIO); + unified_selectionRelativeOption.setText(CVSUIMessages.GenerateDiffFileWizard_8); + + //temp disable if workspacePatch flag not set and default to selection + if (!Boolean.getBoolean(GenerateDiffFileWizard.WORKSPACEPATCH_FLAG)){ + unified_selectionRelativeOption.setSelection(true); + unified_workspaceRelativeOption.setSelection(false); + unified_workspaceRelativeOption.setEnabled(false); + unified_projectRelativeOption.setEnabled(false); + unified_selectionRelativeOption.setEnabled(false); + } + Dialog.applyDialogFont(parent); - } + + //add listeners + unifiedDiffOption.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + setEnableUnifiedGroup(true); + updateEnablements(); + } + }); + + contextDiffOption.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + setEnableUnifiedGroup(false); + updateEnablements(); + } + }); + + regularDiffOption.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + setEnableUnifiedGroup(false); + updateEnablements(); + } + }); + + calculatePatchRoot(); + unifiedDiffOption.setSelection(true); + updateEnablements(); + } - /** + protected void updateEnablements() { + if (!patchHasCommonRoot){ + unified_selectionRelativeOption.setEnabled(false); + unified_projectRelativeOption.setEnabled(false); + contextDiffOption.setEnabled(false); + regularDiffOption.setEnabled(false); + } + } + + private void calculatePatchRoot(){ + //check to see if this is a multi select patch, if so disable + IResource[] tempResources = ((GenerateDiffFileWizard)this.getWizard()).resources; + if (((GenerateDiffFileWizard)this.getWizard()).resources.length > 1){ + //Check to see is the selected resources are contained by the same parent (climbing + //parent by parent to the project root) + //If so, then allow selection relative patches -> set the relative path to the common + //parent [also allow project relative patches] + //If parents are different projects, allow only multiproject selection + + patchHasCommonRoot=true; + int segmentMatch=-1; + IPath path = tempResources[0].getFullPath().removeLastSegments(1); + for (int i = 1; i < tempResources.length; i++) { + int segments=path.matchingFirstSegments(tempResources[i].getFullPath()); + //Keep track of the lowest number of matches that were found - the common + //path will be this number + if (segmentMatch == -1 || + segmentMatch>segments){ + segmentMatch=segments; + } + //However, if no segments for any one resource - break out of the loop + if (segments == 0){ + patchHasCommonRoot=false; + break; + } + } + if (patchHasCommonRoot){ + IPath tempPath = path.uptoSegment(segmentMatch); + /*IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + while (!root.exists(tempPath) && + !tempPath.isRoot()){ + tempPath = tempPath.removeLastSegments(1); + }*/ + patchRoot=tempPath; + } + } else { + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + + //take the file name off the path and use that as the patch root + //patchRoot = tempResources[0].getFullPath().removeLastSegments(1); + IPath fullPath = tempResources[0].getFullPath(); + IResource resource = root.findMember(fullPath); + + //keep trimming the path until we find something that can be used as the + //patch root + while (resource == null && + !(resource instanceof IWorkspaceRoot)){ + fullPath=fullPath.removeLastSegments(1); + resource=root.findMember(fullPath); + } + patchRoot = resource.getFullPath(); + if (resource.getType() == IResource.FILE) + patchRoot =resource.getFullPath().removeLastSegments(1); + } + } + /** * Return the list of Diff command options configured on this page. */ public LocalOption[] getOptions() { List options = new ArrayList(5); - if(includeNewFilesOptions.getSelection()) { + /* if(includeNewFilesOptions.getSelection()) { options.add(Diff.INCLUDE_NEWFILES); } if(!recurseOption.getSelection()) { options.add(Command.DO_NOT_RECURSE); - } - if(unifiedDiffOption.getSelection()) { + }*/ + + //Add new files for now + options.add(Diff.INCLUDE_NEWFILES); + + if(unifiedDiffOption.getSelection() || unified_workspaceRelativeOption.getSelection()) { options.add(Diff.UNIFIED_FORMAT); } else if(contextDiffOption.getSelection()) { options.add(Diff.CONTEXT_FORMAT); - } + } + return (LocalOption[]) options.toArray(new LocalOption[options.size()]); } public void setVisible(boolean visible) { super.setVisible(visible); if (visible) { - recurseOption.setFocus(); + unified_workspaceRelativeOption.setFocus(); } } + protected void setEnableUnifiedGroup(boolean enabled){ + unified_workspaceRelativeOption.setEnabled(enabled); + unified_projectRelativeOption.setEnabled(enabled); + unified_selectionRelativeOption.setEnabled(enabled); + } } /** @@ -525,10 +1085,9 @@ public class GenerateDiffFileWizard extends Wizard { */ private final class DefaultValuesStore { - private static final String PREF_LAST_SELECTION= "org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard.PatchFileSelectionPage.selection"; //$NON-NLS-1$ - private static final String PREF_LAST_FS_PATH= "org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard.PatchFileSelectionPage.fs.path"; //$NON-NLS-1$ - private static final String PREF_LAST_WS_FILENAME= "org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard.PatchFileSelectionPage.ws.filename"; //$NON-NLS-1$ - private static final String PREF_LAST_WS_PATH= "org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard.PatchFileSelectionPage.ws.path"; //$NON-NLS-1$ + private static final String PREF_LAST_SELECTION= "org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard.PatchFileSelectionPage.lastselection"; //$NON-NLS-1$ + private static final String PREF_LAST_FS_PATH= "org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard.PatchFileSelectionPage.filesystem.path"; //$NON-NLS-1$ + private static final String PREF_LAST_WS_PATH= "org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard.PatchFileSelectionPage.workspace.path"; //$NON-NLS-1$ private final IDialogSettings dialogSettings; @@ -558,21 +1117,9 @@ public class GenerateDiffFileWizard extends Wizard { return path != null ? path : ""; //$NON-NLS-1$ } - public String getWorkspaceFilename() { - final String filename= dialogSettings.get(PREF_LAST_WS_FILENAME); - return filename != null ? filename : ""; //$NON-NLS-1$ - } - - public IContainer getWorkspaceSelection() { - final String value= dialogSettings.get(PREF_LAST_WS_PATH); - if ( value != null ) { - final IPath path= new Path(value); - final IResource container= ResourcesPlugin.getWorkspace().getRoot().findMember(path); - if (container instanceof IContainer) { - return (IContainer)container; - } - } - return null; + public String getWorkspacePath() { + final String path= dialogSettings.get(PREF_LAST_WS_PATH); + return path != null ? path : ""; //$NON-NLS-1$ } public void storeRadioSelection(int defaultSelection) { @@ -586,23 +1133,20 @@ public class GenerateDiffFileWizard extends Wizard { public void storeWorkspacePath(String path) { dialogSettings.put(PREF_LAST_WS_PATH, path); } - - public void storeWorkspaceFilename(String filename) { - dialogSettings.put(PREF_LAST_WS_FILENAME, filename); - } } - private LocationPage locationPage; private OptionsPage optionsPage; - private final IResource resource; + protected IResource[] resources; private final DefaultValuesStore defaultValuesStore; - - - public GenerateDiffFileWizard(IResource resource) { + private final IWorkbenchPart part; + + + public GenerateDiffFileWizard(IWorkbenchPart part, IResource[] resources) { super(); - this.resource = resource; + this.part = part; + this.resources = resources; setWindowTitle(CVSUIMessages.GenerateCVSDiff_title); initializeDefaultPageImageDescriptor(); defaultValuesStore= new DefaultValuesStore(); @@ -657,18 +1201,29 @@ public class GenerateDiffFileWizard extends Wizard { if (!(file == null || validateFile(file))) { return false; } + + //Is this a multi-patch? + boolean multiPatch=false; + if (optionsPage.unifiedDiffOption.getSelection() && optionsPage.unified_workspaceRelativeOption.getSelection()) + multiPatch=true; + + + //If not a multipatch, patch should use project relative or selection relative paths[default]? + boolean useProjectRelativePaths=false; + if (optionsPage.unifiedDiffOption.getSelection() && + optionsPage.unified_projectRelativeOption.getSelection()) + useProjectRelativePaths=true; /** * Perform diff operation. */ - try { - getContainer().run(true, true, new GenerateDiffFileOperation(resource, file, optionsPage.getOptions(), getShell())); - } catch (InterruptedException e1) { - return true; - } catch (InvocationTargetException e2) { - CVSUIPlugin.openError(getShell(), null, null, e2); - return false; - } + try { + if (file != null) { + generateDiffToFile(file,multiPatch,useProjectRelativePaths); + } else { + generateDiffToClipboard(multiPatch,useProjectRelativePaths); + } + } catch (TeamException e) {} /** * Refresh workspace if necessary and save default selection. @@ -676,15 +1231,19 @@ public class GenerateDiffFileWizard extends Wizard { switch (location) { case LocationPage.WORKSPACE: - defaultValuesStore.storeRadioSelection(LocationPage.WORKSPACE); - final IResource workspaceResource= locationPage.getResource(); - defaultValuesStore.storeWorkspacePath(workspaceResource.getParent().getFullPath().toString()); - defaultValuesStore.storeWorkspaceFilename(workspaceResource.getName()); - try { - workspaceResource.getParent().refreshLocal(IResource.DEPTH_ONE, null); - } catch(CoreException e) { - CVSUIPlugin.openError(getShell(), CVSUIMessages.GenerateCVSDiff_error, null, e); - return false; + final String workspaceResource= locationPage.getWorkspaceLocation(); + if (workspaceResource != null){ + defaultValuesStore.storeRadioSelection(LocationPage.WORKSPACE); + defaultValuesStore.storeWorkspacePath(workspaceResource); + /* try { + workspaceResource.getParent().refreshLocal(IResource.DEPTH_ONE, null); + } catch(CoreException e) { + CVSUIPlugin.openError(getShell(), CVSUIMessages.GenerateCVSDiff_error, null, e); + return false; + } */ + } else { + //Problem with workspace location, open with clipboard next time + defaultValuesStore.storeRadioSelection(LocationPage.CLIPBOARD); } break; @@ -703,7 +1262,30 @@ public class GenerateDiffFileWizard extends Wizard { return true; } - public boolean validateFile(File file) { + private void generateDiffToClipboard(boolean multiPatch, boolean useProjectRelativePaths) throws TeamException { + DiffOperation diffop = new ClipboardDiffOperation(part,RepositoryProviderOperation.asResourceMappers(resources),optionsPage.getOptions(),multiPatch, useProjectRelativePaths, optionsPage.patchRoot); + try { + diffop.run(); + } catch (InvocationTargetException e) {} + catch (InterruptedException e) {} + } + + private void generateDiffToFile(File file, boolean multiPatch, boolean useProjectRelativePaths) throws TeamException { + DiffOperation diffop = null; + if (locationPage.selectedLocation == LocationPage.WORKSPACE){ + diffop = new WorkspaceFileDiffOperation(part,RepositoryProviderOperation.asResourceMappers(resources),optionsPage.getOptions(),file, multiPatch, useProjectRelativePaths, optionsPage.patchRoot); + } + else { + diffop = new FileDiffOperation(part,RepositoryProviderOperation.asResourceMappers(resources),optionsPage.getOptions(),file, multiPatch, useProjectRelativePaths, optionsPage.patchRoot); + } + + try { + diffop.run(); + } catch (InvocationTargetException e) {} + catch (InterruptedException e) {} + } + + public boolean validateFile(File file) { if (file == null) return false; @@ -734,4 +1316,9 @@ public class GenerateDiffFileWizard extends Wizard { return true; } + + public LocationPage getLocationPage() { + return locationPage; + } + } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java index b83bca3d9..ecb15cf91 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java @@ -274,9 +274,13 @@ public class SharingWizardSyncPage extends CVSWizardPage implements ISyncInfoSet } public boolean commitChanges() { - return fCheckbox != null ? fCheckbox.getSelection() : false; + return fCheckbox != null ? fCheckbox.getSelection() && hasOutgoingChanges() : false; } + private boolean hasOutgoingChanges() { + return infos != null && infos.hasOutgoingChanges(); + } + /** * @return Returns the project. */ diff --git a/bundles/org.eclipse.team.ui/plugin.properties b/bundles/org.eclipse.team.ui/plugin.properties index 0e4449e13..85eb60956 100644 --- a/bundles/org.eclipse.team.ui/plugin.properties +++ b/bundles/org.eclipse.team.ui/plugin.properties @@ -26,6 +26,8 @@ IgnorePreferencePage.name=Ignored Resources ConfigureProject.label=&Share Project... ConfigureProject.tooltip=Share the project with others using a version and configuration management system. +ImportProjectSet.label=Import Project &Set... + TeamGroupMenu.label=T&eam Team.viewCategory=Team diff --git a/bundles/org.eclipse.team.ui/plugin.xml b/bundles/org.eclipse.team.ui/plugin.xml index 6f587f98e..ebe153b7a 100644 --- a/bundles/org.eclipse.team.ui/plugin.xml +++ b/bundles/org.eclipse.team.ui/plugin.xml @@ -100,7 +100,19 @@ enablesFor="1" id="nonbound.org.eclipse.team.ui.ConfigureProject"> </action> - </objectContribution> + </objectContribution> + <objectContribution + objectClass="org.eclipse.core.resources.IFile" + nameFilter="*.psf" + id="org.eclipse.team.ui.ProjectSetFileContributions"> + <action + label="%ImportProjectSet.label" + class="org.eclipse.team.internal.ui.actions.ImportProjectSetAction" + menubarPath="team.main" + enablesFor="*" + id="nonbound.org.eclipse.team.ui.ImportProjectSetAction"> + </action> + </objectContribution> </extension> <!-- ************** Views ********************** --> <extension diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java index e71e7c25a..d0a784c18 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java @@ -107,6 +107,7 @@ public class TeamUIMessages extends NLS { public static String ImportProjectSetMainPage_allFiles; public static String ImportProjectSetMainPage_Project_Set_Files_2; public static String ExportProjectSetMainPage__File_name__1; + public static String ImportProjectSetAction_0; public static String SyncViewPreferencePage_lastRefreshRunNever; diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java index e998a2cbc..d199ac1a3 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java @@ -123,7 +123,7 @@ public class TeamUIPlugin extends AbstractUIPlugin { /** * Initializes the preferences for this plugin if necessary. */ - protected void initializePreferences() { + protected void initializeDefaultPluginPreferences() { IPreferenceStore store = getPreferenceStore(); store.setDefault(IPreferenceIds.SYNCVIEW_VIEW_SYNCINFO_IN_LABEL, false); store.setDefault(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS, true); @@ -178,7 +178,6 @@ public class TeamUIPlugin extends AbstractUIPlugin { super.start(context); initializeImages(this); - initializePreferences(); // This is a backwards compatibility check to ensure that repository // provider capability are enabled automatically if an old workspace is diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java index 376420419..aee4be1dd 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java @@ -671,6 +671,10 @@ public class Utils { public static void syncExec(final Runnable r, StructuredViewer v) { if(v == null) return; final Control ctrl = v.getControl(); + syncExec(r, ctrl); + } + + public static void syncExec(final Runnable r, final Control ctrl) { if (ctrl != null && !ctrl.isDisposed()) { ctrl.getDisplay().syncExec(new Runnable() { public void run() { @@ -680,7 +684,7 @@ public class Utils { } }); } - } + } public static SyncInfo getSyncInfo(ISynchronizeModelElement node) { if (node instanceof IAdaptable) { 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 5de8c6ecf..87ce3b318 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 @@ -113,6 +113,7 @@ ProjectSetImportWizard_workingSetExistsMessage=Working set ''{0}'' already exist ExportProjectSetMainPage_Project_Set_Files_3=Team Project Set Files (*.psf) ExportProjectSetMainPage_default=projectSet.psf ImportProjectSetMainPage_allFiles=All Files (*.*) +ImportProjectSetAction_0=An error occurred importing this project set. ImportProjectSetMainPage_Project_Set_Files_2=Team Project Set Files (*.psf) ExportProjectSetMainPage__File_name__1=&File name: diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java index fe99ef879..d1cc3fe6e 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java @@ -49,6 +49,12 @@ public abstract class AbstractSynchronizeModelProvider implements ISynchronizeMo */ public static final String P_VIEWER_SELECTION_STATE = TeamUIPlugin.ID + ".P_VIEWER_SELECTION_STATE"; //$NON-NLS-1$ + /** + * Property constant for the checked state for the elements displayed by the page. The + * checked state is a List of resource paths. + */ + public static final String P_VIEWER_CHECKED_STATE = TeamUIPlugin.ID + ".P_VIEWER_CHECKED_STATE"; //$NON-NLS-1$ + private ISynchronizeModelElement root; private ISynchronizePageConfiguration configuration; @@ -62,7 +68,7 @@ public abstract class AbstractSynchronizeModelProvider implements ISynchronizeMo private SynchronizePageActionGroup actionGroup; private ListenerList listeners; - + private static final boolean DEBUG = false; /** @@ -402,6 +408,20 @@ public abstract class AbstractSynchronizeModelProvider implements ISynchronizeMo } /* + * Return all the resources that are checked in the page. + * This method should only be called in the UI thread + * after validating that the viewer is still valid. + */ + protected IResource[] getCheckedResources() { + StructuredViewer viewer = getViewer(); + if (viewer instanceof CheckboxTreeViewer){ + return getResources(((CheckboxTreeViewer)viewer).getCheckedElements()); + } + + return new IResource[0]; + } + + /* * Expand the resources if they appear in the page. * This method should only be called in the UI thread * after validating that the viewer is still valid. @@ -489,13 +509,19 @@ public abstract class AbstractSynchronizeModelProvider implements ISynchronizeMo // save visible expanded elements and selection final StructuredViewer viewer = getViewer(); if (viewer != null && !viewer.getControl().isDisposed() && viewer instanceof AbstractTreeViewer) { + //check to see if we should store the checked states of the tree + + final boolean storeChecks = ((SynchronizePageConfiguration)configuration).getViewerStyle() == SynchronizePageConfiguration.CHECKBOX; final IResource[][] expandedResources = new IResource[1][0]; final IResource[][] selectedResources = new IResource[1][0]; + final IResource[][] checkedResources = new IResource[1][0]; viewer.getControl().getDisplay().syncExec(new Runnable() { public void run() { if (viewer != null && !viewer.getControl().isDisposed()) { expandedResources[0] = getExpandedResources(); selectedResources[0] = getSelectedResources(); + if (storeChecks) + checkedResources [0] = getCheckedResources(); } } }); @@ -503,6 +529,8 @@ public abstract class AbstractSynchronizeModelProvider implements ISynchronizeMo // Save expansion and selection cacheResources(expandedResources[0], P_VIEWER_EXPANSION_STATE); cacheResources(selectedResources[0], P_VIEWER_SELECTION_STATE); + if (storeChecks) + cacheResources(checkedResources[0], P_VIEWER_CHECKED_STATE); } } @@ -516,6 +544,10 @@ public abstract class AbstractSynchronizeModelProvider implements ISynchronizeMo if (viewer != null && !viewer.getControl().isDisposed() && viewer instanceof AbstractTreeViewer) { IResource[] resourcesToExpand = getCachedResources(P_VIEWER_EXPANSION_STATE); IResource[] resourcesToSelect = getCachedResources(P_VIEWER_SELECTION_STATE); + if (((SynchronizePageConfiguration)configuration).getViewerStyle() == SynchronizePageConfiguration.CHECKBOX){ + IResource[] resourcesToCheck = getCachedResources(P_VIEWER_CHECKED_STATE); + checkResources(resourcesToCheck); + } expandResources(resourcesToExpand); selectResources(resourcesToSelect); } @@ -541,6 +573,34 @@ public abstract class AbstractSynchronizeModelProvider implements ISynchronizeMo } /* + * Check the given resources in the view. This method can + * only be invoked from the UI thread. + */ + protected void checkResources(IResource[] resourcesToCheck) { + Set checkedElements = new HashSet(); + StructuredViewer viewer = getViewer(); + if (!(viewer instanceof CheckboxTreeViewer)) + return; + + for (int j = 0; j < resourcesToCheck.length; j++) { + IResource resource = resourcesToCheck[j]; + if (resource.getType() != IResource.FILE) + continue; + + ISynchronizeModelElement[] elements = getModelObjects(resource); + // Only expand when there is one element per resource + if (elements.length == 1) { + for (int i = 0; i < elements.length; i++) { + ISynchronizeModelElement element = elements[i]; + checkedElements.add(element); + } + } + } + if (!checkedElements.isEmpty()) + ((CheckboxTreeViewer) viewer).setCheckedElements(checkedElements.toArray()); + } + + /* * Convert a path to a resource by first looking in the resource * tree and, if that fails, by using the path format to create * a handle. diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SubscriberActionContribution.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SubscriberActionContribution.java index 6569ab838..083357c26 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SubscriberActionContribution.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SubscriberActionContribution.java @@ -16,7 +16,6 @@ import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.internal.ui.synchronize.ConfigureRefreshScheduleDialog; -import org.eclipse.team.internal.ui.synchronize.SynchronizeView; import org.eclipse.team.ui.synchronize.*; import org.eclipse.ui.IActionBars; @@ -64,7 +63,6 @@ public final class SubscriberActionContribution extends SynchronizePageActionGro d.open(); } }; - String participantName = Utils.shortenText(SynchronizeView.MAX_NAME_LENGTH, configuration.getParticipant().getName()); Utils.initAction(configureSchedule, "action.configureSchedulel."); //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardElement.java index d6b3f3321..2885f18b7 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardElement.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardElement.java @@ -26,7 +26,6 @@ public class ConfigurationWizardElement extends WorkbenchAdapter implements IAda private String id; private String name; private ImageDescriptor imageDescriptor; - private String description; private IConfigurationElement configurationElement; /** @@ -112,7 +111,7 @@ public class ConfigurationWizardElement extends WorkbenchAdapter implements IAda * @param value the new desrciption */ public void setDescription(String value) { - description = value; + // Not used } /** * Sets the id parameter of this element diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java index e5acb11f8..246a29a58 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,7 +11,8 @@ package org.eclipse.team.internal.ui.wizards; import java.io.File; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.eclipse.core.resources.IProject; @@ -19,11 +20,20 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.*; +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.TableLayout; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Table; import org.eclipse.team.core.RepositoryProvider; import org.eclipse.team.internal.ui.IHelpContextIds; import org.eclipse.team.internal.ui.TeamUIMessages; @@ -32,7 +42,7 @@ import org.eclipse.ui.model.WorkbenchContentProvider; import org.eclipse.ui.model.WorkbenchLabelProvider; public class ExportProjectSetMainPage extends TeamWizardPage { - Text fileText; + Combo fileCombo; String file = ""; //$NON-NLS-1$ Button browseButton; List selectedProjects = new ArrayList(); @@ -94,11 +104,14 @@ public class ExportProjectSetMainPage extends TeamWizardPage { inner.setLayout(layout); createLabel(inner, TeamUIMessages.ExportProjectSetMainPage__File_name__1); - fileText = createTextField(inner); - if (file != null) fileText.setText(file); - fileText.addListener(SWT.Modify, new Listener() { + + fileCombo = createDropDownCombo(inner); + file = PsfFilenameStore.getSuggestedDefault(); + fileCombo.setItems(PsfFilenameStore.getHistory()); + fileCombo.setText(file); + fileCombo.addListener(SWT.Modify, new Listener() { public void handleEvent(Event event) { - file = fileText.getText(); + file = fileCombo.getText(); updateEnablement(); } }); @@ -115,11 +128,18 @@ public class ExportProjectSetMainPage extends TeamWizardPage { FileDialog d = new FileDialog(getShell(), SWT.SAVE); d.setFilterExtensions(new String[] {"*.psf"}); //$NON-NLS-1$ d.setFilterNames(new String[] {TeamUIMessages.ExportProjectSetMainPage_Project_Set_Files_3}); - d.setFileName(TeamUIMessages.ExportProjectSetMainPage_default); - d.setFilterPath(new File(".").getAbsolutePath()); //$NON-NLS-1$ + d.setFileName(TeamUIMessages.ExportProjectSetMainPage_default); + String fileName= getFileName(); + if (fileName != null) { + int separator= fileName.lastIndexOf(System.getProperty ("file.separator").charAt (0)); //$NON-NLS-1$ + if (separator != -1) { + fileName= fileName.substring(0, separator); + } + } + d.setFilterPath(fileName); String f = d.open(); if (f != null) { - fileText.setText(f); + fileCombo.setText(f); file = f; } } @@ -186,7 +206,7 @@ public class ExportProjectSetMainPage extends TeamWizardPage { public void setVisible(boolean visible) { super.setVisible(visible); if (visible) { - fileText.setFocus(); + fileCombo.setFocus(); } } } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ImportProjectSetMainPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ImportProjectSetMainPage.java index 7a1e3fc87..b37081886 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ImportProjectSetMainPage.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ImportProjectSetMainPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,20 +12,33 @@ package org.eclipse.team.internal.ui.wizards; import java.io.File; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; +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.*; -import org.eclipse.team.internal.ui.*; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +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.team.internal.ui.IHelpContextIds; +import org.eclipse.team.internal.ui.TeamUIMessages; +import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.PlatformUI; public class ImportProjectSetMainPage extends TeamWizardPage { - Text fileText; + Combo fileCombo; String file = ""; //$NON-NLS-1$ Button browseButton; Button createWorkingSetButton; @@ -61,11 +74,14 @@ public class ImportProjectSetMainPage extends TeamWizardPage { inner.setLayout(layout); createLabel(inner, TeamUIMessages.ImportProjectSetMainPage_Project_Set_File_Name__2); - fileText = createTextField(inner); - if (file != null) fileText.setText(file); - fileText.addListener(SWT.Modify, new Listener() { + + fileCombo = createDropDownCombo(inner); + file = PsfFilenameStore.getSuggestedDefault(); + fileCombo.setItems(PsfFilenameStore.getHistory()); + fileCombo.setText(file); + fileCombo.addListener(SWT.Modify, new Listener() { public void handleEvent(Event event) { - file = fileText.getText(); + file = fileCombo.getText(); updateEnablement(); } }); @@ -81,11 +97,20 @@ public class ImportProjectSetMainPage extends TeamWizardPage { public void handleEvent(Event event) { FileDialog d = new FileDialog(getShell()); d.setFilterExtensions(new String[] {"*.psf", "*"}); //$NON-NLS-1$ //$NON-NLS-2$ - d.setFilterNames(new String[] {TeamUIMessages.ImportProjectSetMainPage_Project_Set_Files_2, TeamUIMessages.ImportProjectSetMainPage_allFiles}); // - d.setFilterPath(new File(".").getAbsolutePath()); //$NON-NLS-1$ + d.setFilterNames(new String[] {TeamUIMessages.ImportProjectSetMainPage_Project_Set_Files_2, TeamUIMessages.ImportProjectSetMainPage_allFiles}); // + String fileName= getFileName(); + if (fileName != null && fileName.length() > 0) { + int separator= fileName.lastIndexOf(System.getProperty ("file.separator").charAt (0)); //$NON-NLS-1$ + if (separator != -1) { + fileName= fileName.substring(0, separator); + } + } else { + fileName= ResourcesPlugin.getWorkspace().getRoot().getLocation().toString(); + } + d.setFilterPath(fileName); String f = d.open(); if (f != null) { - fileText.setText(f); + fileCombo.setText(f); file = f; } } @@ -178,19 +203,15 @@ public class ImportProjectSetMainPage extends TeamWizardPage { } setPageComplete(complete); } - + public String getFileName() { return file; } - public void setFileName(String file) { - if (file != null) { - this.file = file; - } - } + public void setVisible(boolean visible) { super.setVisible(visible); if (visible) { - fileText.setFocus(); + fileCombo.setFocus(); } } @@ -201,5 +222,4 @@ public class ImportProjectSetMainPage extends TeamWizardPage { if (!createWorkingSet) return null; return workingSetName; } - } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard.java index 0a4afcf3a..0189059a8 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -35,8 +35,8 @@ import org.eclipse.team.core.ProjectSetCapability; import org.eclipse.team.core.RepositoryProvider; import org.eclipse.team.core.RepositoryProviderType; import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ui.*; import org.eclipse.team.internal.ui.ITeamUIImages; +import org.eclipse.team.internal.ui.TeamUIMessages; import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.team.internal.ui.UIProjectSetSerializationContext; import org.eclipse.ui.IExportWizard; @@ -55,7 +55,6 @@ public class ProjectSetExportWizard extends Wizard implements IExportWizard { mainPage = new ExportProjectSetMainPage("projectSetMainPage", TeamUIMessages.ProjectSetExportWizard_Export_a_Project_Set_3, TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_PROJECTSET_EXPORT_BANNER)); //$NON-NLS-1$ IProject[] projects = (IProject[])selection.toList().toArray(new IProject[0]); mainPage.setSelectedProjects(projects); - mainPage.setFileName(ProjectSetImportWizard.lastFile); addPage(mainPage); } public boolean performFinish() { @@ -68,7 +67,7 @@ public class ProjectSetExportWizard extends Wizard implements IExportWizard { if (path.getFileExtension() == null) { filename = filename + ".psf"; //$NON-NLS-1$ } - ProjectSetImportWizard.lastFile = filename; + PsfFilenameStore.remember(filename); File file = new File(filename); File parentFile = file.getParentFile(); if (parentFile != null && !parentFile.exists()) { @@ -196,7 +195,7 @@ public class ProjectSetExportWizard extends Wizard implements IExportWizard { } return result[0]; } - + public void init(IWorkbench workbench, IStructuredSelection selection) { this.selection = selection; } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetImportWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetImportWizard.java index 21367ad6c..f580a86b8 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetImportWizard.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetImportWizard.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,30 +10,31 @@ *******************************************************************************/ package org.eclipse.team.internal.ui.wizards; -import java.io.*; import java.lang.reflect.InvocationTargetException; -import java.util.*; - -import javax.xml.parsers.*; import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; 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.osgi.util.NLS; -import org.eclipse.team.core.*; -import org.eclipse.team.internal.core.TeamPlugin; -import org.eclipse.team.internal.ui.*; -import org.eclipse.ui.*; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.internal.ui.ITeamUIImages; +import org.eclipse.team.internal.ui.ProjectSetImporter; +import org.eclipse.team.internal.ui.TeamUIMessages; +import org.eclipse.team.internal.ui.TeamUIPlugin; +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; public class ProjectSetImportWizard extends Wizard implements IImportWizard { ImportProjectSetMainPage mainPage; - public static String lastFile; public ProjectSetImportWizard() { setNeedsProgressMonitor(true); @@ -42,11 +43,10 @@ public class ProjectSetImportWizard extends Wizard implements IImportWizard { public void addPages() { mainPage = new ImportProjectSetMainPage("projectSetMainPage", TeamUIMessages.ProjectSetImportWizard_Import_a_Project_Set_3, TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_PROJECTSET_IMPORT_BANNER)); //$NON-NLS-1$ - mainPage.setFileName(lastFile); addPage(mainPage); } + public boolean performFinish() { - // check if the desired working set exists final String workingSetName = mainPage.getWorkingSetName(); if (workingSetName != null) { @@ -60,87 +60,12 @@ public class ProjectSetImportWizard extends Wizard implements IImportWizard { try { getContainer().run(true, true, new WorkspaceModifyOperation(null) { public void execute(IProgressMonitor monitor) throws InvocationTargetException { - InputStreamReader reader = null; - try { - String filename = mainPage.getFileName(); - lastFile = filename; - reader = new InputStreamReader(new FileInputStream(filename), "UTF-8"); //$NON-NLS-1$ - - SAXParserFactory factory = SAXParserFactory.newInstance(); - SAXParser parser = factory.newSAXParser(); - ProjectSetContentHandler handler = new ProjectSetContentHandler(); - InputSource source = new InputSource(reader); - parser.parse(source, handler); - - 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) { - IProject[] projects = serializer.addToWorkspace(new String[0], filename, getShell(), monitor); - if (projects != null) - newProjects.addAll(Arrays.asList(projects)); - } - } else { - UIProjectSetSerializationContext context = new UIProjectSetSerializationContext(getShell(), filename); - Iterator it = map.keySet().iterator(); - List errors = new ArrayList(); - while (it.hasNext()) { - try { - String id = (String)it.next(); - List references = (List)map.get(id); - RepositoryProviderType providerType = RepositoryProviderType.getProviderType(id); - if (providerType == null) { - // The provider type is absent. Perhaps there is another provider that can import this type - providerType = TeamPlugin.getAliasType(id); - } - if (providerType == null) { - throw new TeamException(new Status(IStatus.ERROR, TeamUIPlugin.ID, 0, NLS.bind(TeamUIMessages.ProjectSetImportWizard_0, new String[] { id }), null)); - } - ProjectSetCapability serializer = providerType.getProjectSetCapability(); - ProjectSetCapability.ensureBackwardsCompatible(providerType, serializer); - if (serializer != null) { - IProject[] projects = serializer.addToWorkspace((String[])references.toArray(new String[references.size()]), context, monitor); - if (projects != null) - newProjects.addAll(Arrays.asList(projects)); - } - } catch (TeamException e) { - errors.add(e); - } - } - if (!errors.isEmpty()) { - if (errors.size() == 1) { - throw (TeamException)errors.get(0); - } else { - TeamException[] exceptions = (TeamException[]) errors.toArray(new TeamException[errors.size()]); - IStatus[] status = new IStatus[exceptions.length]; - for (int i = 0; i < exceptions.length; i++) { - status[i] = exceptions[i].getStatus(); - } - throw new TeamException(new MultiStatus(TeamUIPlugin.ID, 0, status, TeamUIMessages.ProjectSetImportWizard_1, null)); - } - } - } - if (workingSetName != null) - createWorkingSet(workingSetName, (IProject[]) newProjects.toArray(new IProject[newProjects.size()])); - result[0] = true; - } catch (IOException e) { - throw new InvocationTargetException(e); - } catch (SAXException e) { - throw new InvocationTargetException(e); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } catch (ParserConfigurationException e) { - throw new InvocationTargetException(e); - } finally { - if (reader != null) { - try { - reader.close(); - } catch (IOException e) { - throw new InvocationTargetException(e); - } - } - } + String psfFile = mainPage.getFileName(); + PsfFilenameStore.remember(psfFile); + IProject[] newProjects= ProjectSetImporter.importProjectSet(psfFile, getShell(), monitor); + if (workingSetName != null) + createWorkingSet(workingSetName, newProjects); + result[0] = true; } }); } catch (InterruptedException e) { @@ -176,7 +101,10 @@ public class ProjectSetImportWizard extends Wizard implements IImportWizard { oldSet.setElements(projects); } } - + public void init(IWorkbench workbench, IStructuredSelection selection) { + // The code that finds "selection" is broken (it is always empty), so we + // must dig for the selection in the workbench. + PsfFilenameStore.setDefaultFromSelection(workbench); } } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/TeamWizardPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/TeamWizardPage.java index c0e3287cd..cfb8e345a 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/TeamWizardPage.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/TeamWizardPage.java @@ -16,6 +16,7 @@ import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; @@ -97,4 +98,20 @@ public abstract class TeamWizardPage extends WizardPage { text.setLayoutData(data); return text; } + + /** + * Create a drop-down combo box specific for this application + * + * @param parent the parent of the new combo box + * @return the new combo box + */ + protected Combo createDropDownCombo(Composite parent) { + Combo combo = new Combo(parent, SWT.DROP_DOWN); + GridData comboData = new GridData(GridData.FILL_HORIZONTAL); + comboData.verticalAlignment = GridData.CENTER; + comboData.grabExcessVerticalSpace = false; + comboData.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; + combo.setLayoutData(comboData); + return combo; + } } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java index 26ef6cf3d..c5ad0ae01 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java @@ -54,7 +54,6 @@ public class ParticipantPageSaveablePart extends SaveablePartAdapter implements private ISynchronizeParticipant participant; private ISynchronizePageConfiguration pageConfiguration; private Image titleImage; - private Shell shell; private Shell dialogShell; // Tracking of dirty state @@ -143,7 +142,6 @@ public class ParticipantPageSaveablePart extends SaveablePartAdapter implements */ public ParticipantPageSaveablePart(Shell shell, CompareConfiguration cc, ISynchronizePageConfiguration pageConfiguration, ISynchronizeParticipant participant) { this.cc = cc; - this.shell = shell; this.participant = participant; this.pageConfiguration = pageConfiguration; |