Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2004-12-08 21:15:23 +0000
committerJean Michel-Lemieux2004-12-08 21:15:23 +0000
commit7056a918dc8b87bfa91edcc80d43481aefef7bde (patch)
treee0151292f039ed74c0c253265d4899ce1cd22e92
parent753a5d292e888e7c0d55af3949fbe1f48de972a1 (diff)
downloadeclipse.platform.team-7056a918dc8b87bfa91edcc80d43481aefef7bde.tar.gz
eclipse.platform.team-7056a918dc8b87bfa91edcc80d43481aefef7bde.tar.xz
eclipse.platform.team-7056a918dc8b87bfa91edcc80d43481aefef7bde.zip
commit wizard patches from Silvio
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java38
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/KnownModesForNames.java156
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java3
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java1
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommitCommentArea.java446
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java18
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkInProgressPreferencePage.java34
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java28
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties16
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java41
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java131
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantLabelDecorator.java35
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CommitSetDialog.java16
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java38
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java8
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java6
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java411
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java320
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardFileTypePage.java123
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardCommitCommentPage.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/SWTUtils.java63
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/FileTypeTable.java244
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/TextPreferencePage.java442
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/HierarchicalModelManager.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java19
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java36
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveFromViewAction.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageConfiguration.java12
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPagePane.java230
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java15
33 files changed, 2275 insertions, 670 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 74af21766..a2bde8dc4 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
@@ -72,7 +72,9 @@ public final class Team {
*/
public static int getType(IStorage storage) {
String extension = getFileExtension(storage.getName());
- if (extension == null) return UNKNOWN;
+ if (extension == null) {
+ return KnownModesForNames.getType(storage.getName());
+ }
SortedMap table = getFileTypeTable();
Integer integer = (Integer)table.get(extension);
if (integer == null) return UNKNOWN;
@@ -205,21 +207,43 @@ public final class Team {
}
/**
- * Set the file type for the give extension to the given type.
+ * Set the file type for the give extensions to the given types. This
+ * will replace the existing file types with this new list.
*
* Valid types are:
* Team.TEXT
* Team.BINARY
* Team.UNKNOWN
*
- * @param extension the file extension
- * @param type the file type
+ * @param extensions the file extensions
+ * @param types the file types
*/
public static void setAllTypes(String[] extensions, int[] types) {
+ internalAddAllTypes(extensions, types, true);
+ }
+
+ /**
+ * Add the file type for the given extensions to the given types. This
+ * will append to the existing file types.
+ *
+ * Valid types are:
+ * Team.TEXT
+ * Team.BINARY
+ * Team.UNKNOWN
+ *
+ * @param extensions the file extensions
+ * @param types the file types
+ */
+ public static void addAllTypes(String[] extensions, int[] types) {
+ internalAddAllTypes(extensions, types, false);
+ }
+
+ private static void internalAddAllTypes(String[] extensions, int[] types, boolean removeExisting) {
if (pluginTypes == null) {
loadTextState();
}
- globalTypes = new TreeMap();
+ if (removeExisting)
+ globalTypes = new TreeMap();
for (int i = 0; i < extensions.length; i++) {
globalTypes.put(extensions[i], new Integer(types[i]));
}
@@ -241,7 +265,6 @@ public final class Team {
}
TeamPlugin.getPlugin().getPluginPreferences().setValue(PREF_TEAM_TYPES, buf.toString());
}
-
/**
* Add patterns to the list of global ignores.
*/
@@ -337,7 +360,8 @@ public final class Team {
private static void loadTextState() {
globalTypes = new TreeMap();
boolean old = loadBackwardCompatibleTextState();
- if (!old) loadTextPreferences();
+ if (!old)
+ loadTextPreferences();
pluginTypes = new TreeMap();
initializePluginPatterns(pluginTypes, globalTypes);
if (old) TeamPlugin.getPlugin().savePluginPreferences();
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/KnownModesForNames.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/KnownModesForNames.java
new file mode 100644
index 000000000..3b8fc54bb
--- /dev/null
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/KnownModesForNames.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.team.internal.core;
+
+import java.util.*;
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
+import org.eclipse.team.core.IFileTypeInfo;
+import org.eclipse.team.core.Team;
+
+/**
+ *
+ */
+public class KnownModesForNames {
+
+ private static class FileTypeInfo implements IFileTypeInfo {
+
+ private final String fName;
+ private final int fMode;
+
+ public FileTypeInfo(String name, int mode) {
+ fName= name;
+ fMode= mode;
+ }
+
+ public FileTypeInfo(String name, Integer mode) {
+ this(name, mode.intValue());
+ }
+
+ public String getExtension() {
+ return fName;
+ }
+
+ public int getType() {
+ return fMode;
+ }
+ }
+
+ private static class CachedModesForNames implements Preferences.IPropertyChangeListener {
+
+ private static final String PREF_TEAM_TYPES_FOR_FILES= "cvs_mode_for_file_without_extensions";
+ private static final String PREF_TEAM_SEPARATOR = "\n"; //$NON-NLS-1$
+
+ private Map fMap;
+ private final Preferences fPreferences;
+
+ public CachedModesForNames() {
+ fPreferences= TeamPlugin.getPlugin().getPluginPreferences();
+ fPreferences.addPropertyChangeListener(this);
+ }
+
+ public Map referenceMap() {
+ if (fMap == null) {
+ fMap= new HashMap();
+ if (!fPreferences.contains(PREF_TEAM_TYPES_FOR_FILES))
+ return Collections.EMPTY_MAP;
+
+ final String prefTypes = fPreferences.getString(PREF_TEAM_TYPES_FOR_FILES);
+ final StringTokenizer tok = new StringTokenizer(prefTypes, PREF_TEAM_SEPARATOR);
+ try {
+ while (true) {
+ final String name = tok.nextToken();
+ if (name.length()==0)
+ return Collections.EMPTY_MAP;
+ final String mode= tok.nextToken();
+ fMap.put(name, Integer.valueOf(mode));
+ }
+ } catch (NoSuchElementException e) {
+ return Collections.EMPTY_MAP;
+ }
+
+ }
+ return fMap;
+ }
+
+ public void propertyChange(PropertyChangeEvent event) {
+ if(event.getProperty().equals(PREF_TEAM_TYPES_FOR_FILES))
+ fMap= null;
+ }
+
+ public void save() {
+ // Now set into preferences
+ final StringBuffer buffer = new StringBuffer();
+ final Iterator e = fMap.keySet().iterator();
+
+ while (e.hasNext()) {
+ final String filename = (String)e.next();
+ buffer.append(filename);
+ buffer.append(PREF_TEAM_SEPARATOR);
+ final Integer type = (Integer)fMap.get(filename);
+ buffer.append(type);
+ buffer.append(PREF_TEAM_SEPARATOR);
+ }
+ TeamPlugin.getPlugin().getPluginPreferences().setValue(PREF_TEAM_TYPES_FOR_FILES, buffer.toString());
+ }
+ }
+
+ private static final CachedModesForNames fCachedModes= new CachedModesForNames();
+
+ private KnownModesForNames() {
+ }
+
+ public static IFileTypeInfo [] getKnownModesForNames() {
+ return toFileTypeInfoArray(fCachedModes.referenceMap());
+ }
+
+ public static void addModesForFiles(String [] names, int [] modes) {
+ final Map map= fCachedModes.referenceMap();
+ map.putAll(toMap(names, modes));
+ fCachedModes.save();
+ }
+
+ public static void setModesforFiles(String [] names, int [] modes) {
+ final Map map= fCachedModes.referenceMap();
+ map.putAll(toMap(names, modes));
+ fCachedModes.save();
+ }
+
+ private static Map toMap(String [] filenames, int [] modes) {
+ final SortedMap map= new TreeMap();
+ for (int i = 0; i < filenames.length; i++) {
+ map.put(filenames[i], new Integer(modes[i]));
+ }
+ return map;
+ }
+
+ private static IFileTypeInfo [] toFileTypeInfoArray(Map map) {
+
+ final IFileTypeInfo [] result= new IFileTypeInfo[map.size()];
+ int index= 0;
+ for (Iterator iter = map.keySet().iterator(); iter.hasNext();) {
+ final String name = (String) iter.next();
+ result[index++]= new FileTypeInfo(name, (Integer)map.get(name));
+ }
+ return result;
+ }
+
+ /**
+ * @param name
+ * @return
+ */
+ public static int getType(String name) {
+ final Integer mode= (Integer)fCachedModes.referenceMap().get(name);
+ return mode != null ? mode.intValue() : Team.UNKNOWN;
+ }
+}
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 1408a89f2..71d315351 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
@@ -243,12 +243,11 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig
private static void extractFileProperties(IFile resource, CVSDecoration cvsDecoration) throws CVSException {
ICVSFile file = CVSWorkspaceRoot.getCVSFileFor(resource);
ResourceSyncInfo fileInfo = file.getSyncInfo();
- KSubstOption option = KSubstOption.fromFile((IFile) resource);
+ KSubstOption option = KSubstOption.fromFile(resource);
if (fileInfo != null) {
cvsDecoration.setAdded(fileInfo.isAdded());
cvsDecoration.setRevision(fileInfo.getRevision());
cvsDecoration.setReadOnly(file.isReadOnly());
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile) resource);
cvsDecoration.setNeedsMerge(fileInfo.isNeedsMerge(file.getTimeStamp()));
option = fileInfo.getKeywordMode();
}
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 0818ffb2a..fbac6db31 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
@@ -634,6 +634,7 @@ public class CVSUIPlugin extends AbstractUIPlugin {
store.setDefault(ICVSUIConstants.PREF_DEFAULT_PERSPECTIVE_FOR_SHOW_ANNOTATIONS, CVSPerspective.ID);
store.setDefault(ICVSUIConstants.PREF_CHANGE_PERSPECTIVE_ON_SHOW_ANNOTATIONS, MessageDialogWithToggle.PROMPT);
+ store.setDefault(ICVSUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS, MessageDialogWithToggle.PROMPT);
// Set the watch/edit preferences defaults and values
store.setDefault(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY, corePrefs.getDefaultBoolean(CVSProviderPlugin.READ_ONLY));
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 6bc55702a..f59ec651b 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
@@ -11,225 +11,289 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.ui;
+import java.util.Observable;
+import java.util.Observer;
+
import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.dialogs.*;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.*;
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;
/**
* This area provides the widgets for providing the CVS commit comment
*/
public class CommitCommentArea extends DialogArea {
+
+ private class TextBox implements ModifyListener, TraverseListener, FocusListener, Observer {
+
+ private final Text fTextField; // updated only by modify events
+ private final String fMessage;
+
+ private String fText;
+
+ public TextBox(Composite composite, String message, String initialText) {
+
+ fMessage= message;
+ fText= initialText;
+
+ fTextField = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
+ fTextField.setLayoutData(SWTUtils.createHVFillGridData());
+
+ setText(initialText);
+
+ fTextField.addTraverseListener(this);
+ fTextField.addModifyListener(this);
+ fTextField.addFocusListener(this);
+ }
+
+ public void modifyText(ModifyEvent e) {
+ final String old = fText;
+ fText = fTextField.getText();
+ firePropertyChangeChange(COMMENT_MODIFIED, old, fText);
+ }
+
+ public void keyTraversed(TraverseEvent e) {
+ if (e.detail == SWT.TRAVERSE_RETURN && (e.stateMask & SWT.CTRL) != 0) {
+ e.doit = false;
+ firePropertyChangeChange(OK_REQUESTED, null, null);
+ }
+ }
+
+ public void focusGained(FocusEvent e) {
- private static final int WIDTH_HINT = 350;
- private static final int HEIGHT_HINT = 50;
-
- private Text text;
- private Combo previousCommentsCombo;
- private IProject mainProject;
- private String[] comments = new String[0];
- private String comment = ""; //$NON-NLS-1$
-
- public static final String OK_REQUESTED = "OkRequested";//$NON-NLS-1$
- public static final String COMMENT_MODIFIED = "CommentModified";//$NON-NLS-1$
- private String proposedComment;
-
- /**
- * Constructor for CommitCommentArea.
- * @param parentDialog
- * @param settings
- */
- public CommitCommentArea() {
- comments = CVSUIPlugin.getPlugin().getRepositoryManager().getPreviousComments();
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.ui.DialogArea#createArea(org.eclipse.swt.widgets.Composite)
- */
- public void createArea(Composite parent) {
- Dialog.applyDialogFont(parent);
- Composite composite = createGrabbingComposite(parent, 1);
- initializeDialogUnits(composite);
-
- Label label = new Label(composite, SWT.NULL);
- label.setLayoutData(new GridData());
- label.setText(Policy.bind("ReleaseCommentDialog.enterComment")); //$NON-NLS-1$
-
- text = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- GridData data = new GridData(GridData.FILL_BOTH);
- data.widthHint = WIDTH_HINT;
- data.heightHint = HEIGHT_HINT;
-
- text.setLayoutData(data);
- text.selectAll();
- text.addTraverseListener(new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_RETURN && (e.stateMask & SWT.CTRL) != 0) {
- e.doit = false;
- CommitCommentArea.this.signalCtrlEnter();
- }
- }
- });
- text.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String oldComment = comment;
- comment = text.getText();
- CommitCommentArea.this.signalCommentModified(oldComment, comment);
- }
- });
-
-
- label = new Label(composite, SWT.NULL);
- label.setLayoutData(new GridData());
- label.setText(Policy.bind("ReleaseCommentDialog.choosePrevious")); //$NON-NLS-1$
-
- previousCommentsCombo = new Combo(composite, SWT.READ_ONLY);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
- previousCommentsCombo.setLayoutData(data);
-
- // Initialize the values before we register any listeners so
- // we don't get any platform specific selection behavior
- // (see bug 32078: http://bugs.eclipse.org/bugs/show_bug.cgi?id=32078)
- initializeValues();
-
- previousCommentsCombo.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- int index = previousCommentsCombo.getSelectionIndex();
- if (index != -1)
- text.setText(comments[index]);
- }
- });
- }
+ if (fText.length() > 0)
+ return;
+
+ fTextField.removeModifyListener(this);
+ try {
+ fTextField.setText(fText);
+ } finally {
+ fTextField.addModifyListener(this);
+ }
+ }
+
+ public void focusLost(FocusEvent e) {
+
+ if (fText.length() > 0)
+ return;
+
+ fTextField.removeModifyListener(this);
+ try {
+ fTextField.setText(fMessage);
+ fTextField.selectAll();
+ } finally {
+ fTextField.addModifyListener(this);
+ }
+ }
+
+ public void setEnabled(boolean enabled) {
+ fTextField.setEnabled(enabled);
+ }
+
+ public void update(Observable o, Object arg) {
+ if (arg instanceof String) {
+ setText((String)arg); // triggers a modify event
+ }
+ }
+
+ public String getText() {
+ return fText;
+ }
+
+ private void setText(String text) {
+ if (text.length() == 0) {
+ fTextField.setText(fMessage);
+ fTextField.selectAll();
+ } else
+ fTextField.setText(text);
+ }
+ public void setFocus() {
+ fTextField.setFocus();
+ }
+ }
+
+ private static class ComboBox extends Observable implements SelectionListener, FocusListener {
+
+ private final String fMessage;
+ private final String [] fComments;
+ private final Combo fCombo;
+
+
+ public ComboBox(Composite composite, String message, String [] options) {
+
+ fMessage= message;
+ fComments= options;
+
+ 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);
+
+ // 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);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ final int index = fCombo.getSelectionIndex();
+ if (index > 0) {
+ setChanged();
+ notifyObservers(fComments[index - 1]);
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void focusGained(FocusEvent e) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
+ */
+ public void focusLost(FocusEvent e) {
+ fCombo.removeSelectionListener(this);
+ try {
+ fCombo.setText(fMessage);
+ } finally {
+ fCombo.addSelectionListener(this);
+ }
+ }
+
+ public void setEnabled(boolean enabled) {
+ fCombo.setEnabled(enabled);
+ }
+ }
+
+ private static final String EMPTY_MESSAGE= Policy.bind("CommitCommentArea.0"); //$NON-NLS-1$
+ private static final String COMBO_MESSAGE= Policy.bind("CommitCommentArea.1"); //$NON-NLS-1$
+
+ public static final String OK_REQUESTED = "OkRequested";//$NON-NLS-1$
+ public static final String COMMENT_MODIFIED = "CommentModified";//$NON-NLS-1$
+
+ private TextBox fTextBox;
+ private ComboBox fComboBox;
+
+ private IProject fMainProject;
+ private String fProposedComment;
+ private Composite fComposite;
+
/**
- * Method initializeValues.
- */
- private void initializeValues() {
-
- // populate the previous comment list
- for (int i = 0; i < comments.length; i++) {
- previousCommentsCombo.add(HistoryView.flattenText(comments[i]));
- }
-
- // We don't want to have an initial selection
- // (see bug 32078: http://bugs.eclipse.org/bugs/show_bug.cgi?id=32078)
- previousCommentsCombo.setText(""); //$NON-NLS-1$
-
- // determine the initial comment text
- String initialComment = proposedComment;
- if (initialComment == null) {
- try {
- initialComment = getCommitTemplate();
- } catch (CVSException e) {
- CVSUIPlugin.log(e);
- }
- }
- if (initialComment != null && initialComment.length() != 0) {
- text.setText(initialComment);
- }
- }
-
- /**
- * Method signalCtrlEnter.
- */
- private void signalCtrlEnter() {
- firePropertyChangeChange(OK_REQUESTED, null, null);
- }
-
- protected void signalCommentModified(String oldValue, String comment) {
- firePropertyChangeChange(COMMENT_MODIFIED, oldValue, comment);
+ * @see org.eclipse.team.internal.ccvs.ui.DialogArea#createArea(org.eclipse.swt.widgets.Composite)
+ */
+ public void createArea(Composite parent) {
+ Dialog.applyDialogFont(parent);
+ initializeDialogUnits(parent);
+
+ fComposite = createGrabbingComposite(parent, 1);
+ initializeDialogUnits(fComposite);
+
+ fTextBox= new TextBox(fComposite, EMPTY_MESSAGE, getInitialComment());
+
+ final String [] comments = CVSUIPlugin.getPlugin().getRepositoryManager().getPreviousComments();
+ fComboBox= new ComboBox(fComposite, COMBO_MESSAGE, comments);
+
+ fComboBox.addObserver(fTextBox);
}
+
+ public String getComment(boolean save) {
+ final String comment= fTextBox.getText();
+ if (comment == null)
+ return ""; //$NON-NLS-1$
+
+ final String stripped= strip(comment);
+ if (save && comment.length() > 0)
+ CVSUIPlugin.getPlugin().getRepositoryManager().addComment(comment);
- private String getCommitTemplate() throws CVSException {
- CVSTeamProvider provider = getProvider();
- if (provider == null) return ""; //$NON-NLS-1$
- String template = provider.getCommitTemplate();
- if (template == null) template = ""; //$NON-NLS-1$
- return template;
- }
-
- /**
- * Method getProvider.
- */
- private CVSTeamProvider getProvider() {
- if (mainProject == null) return null;
- return (CVSTeamProvider) RepositoryProvider.getProvider(mainProject, CVSProviderPlugin.getTypeId());
- }
-
- /**
- * Return the entered comment
- *
- * @return the comment
- */
- public String[] getComments() {
- return comments;
- }
-
- /**
- * Returns the comment.
- * @return String
- */
- public String getComment() {
- if (comment != null && comment.length() > 0) finished();
- return comment;
- }
-
- /**
- * Method setProject.
- * @param iProject
- */
- public void setProject(IProject iProject) {
- this.mainProject = iProject;
- }
-
- private void finished() {
- // strip template from the comment entered
- try {
- String commitTemplate = getCommitTemplate();
- if (comment.startsWith(commitTemplate)) {
- comment = comment.substring(commitTemplate.length());
- } else if (comment.endsWith(commitTemplate)) {
- comment = comment.substring(0, comment.length() - commitTemplate.length());
- }
- } catch (CVSException e) {
- // we couldn't get the commit template. Log the error and continue
- CVSUIPlugin.log(e);
- }
- // if there is still a comment, remember it
- if (comment.length() > 0) {
- CVSUIPlugin.getPlugin().getRepositoryManager().addComment(comment);
- }
- }
-
- public void setFocus() {
- if (text != null) {
- text.setFocus();
- }
- }
-
+ return stripped;
+ }
+
+ public void setProject(IProject iProject) {
+ this.fMainProject = iProject;
+ }
+
+ public void setFocus() {
+ if (fTextBox != null) {
+ fTextBox.setFocus();
+ }
+ }
+
public void setProposedComment(String proposedComment) {
- this.proposedComment = proposedComment;
+ this.fProposedComment = proposedComment;
}
-
+
public boolean hasCommitTemplate() {
try {
- String commitTemplate = getCommitTemplate();
+ String commitTemplate = getCommitTemplate();
return commitTemplate != null && commitTemplate.length() > 0;
} catch (CVSException e) {
CVSUIPlugin.log(e);
return false;
}
}
+
+ public void setEnabled(boolean enabled) {
+ fTextBox.setEnabled(enabled);
+ fComboBox.setEnabled(enabled);
+ }
+
+ public Composite getComposite() {
+ return fComposite;
+ }
+
+ protected void firePropertyChangeChange(String property, Object oldValue, Object newValue) {
+ super.firePropertyChangeChange(property, oldValue, newValue);
+ }
+
+ private String getInitialComment() {
+ if (fProposedComment != null)
+ return fProposedComment;
+ try {
+ return getCommitTemplate();
+ } catch (CVSException e) {
+ CVSUIPlugin.log(e);
+ return ""; //$NON-NLS-1$
+ }
+ }
+
+ private String strip(String comment) {
+ // strip template from the comment entered
+ try {
+ final String commitTemplate = getCommitTemplate();
+ if (comment.startsWith(commitTemplate)) {
+ return comment.substring(commitTemplate.length());
+ } else if (comment.endsWith(commitTemplate)) {
+ return comment.substring(0, comment.length() - commitTemplate.length());
+ }
+ } catch (CVSException e) {
+ // we couldn't get the commit template. Log the error and continue
+ CVSUIPlugin.log(e);
+ }
+ return comment;
+ }
+
+ private CVSTeamProvider getProvider() {
+ if (fMainProject == null) return null;
+ return (CVSTeamProvider) RepositoryProvider.getProvider(fMainProject, CVSProviderPlugin.getTypeId());
+ }
- public void setEnabled(boolean b) {
- text.setEnabled(b);
- previousCommentsCombo.setEnabled(b);
+ private String getCommitTemplate() throws CVSException {
+ CVSTeamProvider provider = getProvider();
+ if (provider == null)
+ return ""; //$NON-NLS-1$
+ final String template = provider.getCommitTemplate();
+ return template != null ? template : ""; //$NON-NLS-1$
}
}
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 8ac63fa4d..e7024841d 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
@@ -135,6 +135,8 @@ public interface ICVSUIConstants {
public final String PREF_CHANGE_PERSPECTIVE_ON_SHOW_ANNOTATIONS= "pref_change_perspective_on_show_annotations"; //$NON-NLS-1$
public final String PREF_DEFAULT_PERSPECTIVE_FOR_SHOW_ANNOTATIONS= "pref_default_perspective_for_show_annotations"; //$NON-NLS-1$
+ public final String PREF_ALLOW_EMPTY_COMMIT_COMMENTS= "pref_allow_empty_commit_comment"; //$NON-NLS-1$
+
// Wizard banners
public final String IMG_WIZBAN_SHARE = "wizban/newconnect_wizban.gif"; //$NON-NLS-1$
public final String IMG_WIZBAN_MERGE = "wizban/mergestream_wizban.gif"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java
index c92c5b583..9e6164ffb 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java
@@ -32,6 +32,9 @@ public class ReleaseCommentDialog extends DetailsDialog {
CommitCommentArea commitCommentArea;
// dialogs settings that are persistent between workbench sessions
private IDialogSettings settings;
+
+ private static final int DEFAULT_WIDTH_IN_CHARS= 80;
+
private static final String HEIGHT_KEY = "width-key"; //$NON-NLS-1$
private static final String WIDTH_KEY = "height-key"; //$NON-NLS-1$
@@ -98,19 +101,18 @@ public class ReleaseCommentDialog extends DetailsDialog {
* @see org.eclipse.jface.window.Window#getInitialSize()
*/
protected Point getInitialSize() {
- int width, height;
try {
- height = settings.getInt(HEIGHT_KEY);
- width = settings.getInt(WIDTH_KEY);
+ return new Point(settings.getInt(WIDTH_KEY), settings.getInt(HEIGHT_KEY));
} catch(NumberFormatException e) {
- return super.getInitialSize();
+ final Point size= super.getInitialSize();
+ size.x= convertWidthInCharsToPixels(DEFAULT_WIDTH_IN_CHARS);
+ size.y += convertHeightInCharsToPixels(8);
+ return size;
}
- Point p = super.getInitialSize();
- return new Point(width, p.y);
}
public String getComment() {
- return commitCommentArea.getComment();
+ return commitCommentArea.getComment(true);
}
public IResource[] getResourcesToCommit() {
@@ -127,7 +129,7 @@ public class ReleaseCommentDialog extends DetailsDialog {
/* (non-Javadoc)
* @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#updateEnablements()
*/
- protected void updateEnablements() {
+ protected void updateEnablements() {
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkInProgressPreferencePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkInProgressPreferencePage.java
index b97a9bf55..05a660082 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkInProgressPreferencePage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkInProgressPreferencePage.java
@@ -16,20 +16,14 @@ import java.util.Comparator;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.RadioGroupFieldEditor;
+import org.eclipse.jface.preference.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.team.internal.ui.preferences.ComboFieldEditor;
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.IPerspectiveRegistry;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.*;
public class WorkInProgressPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
@@ -47,8 +41,6 @@ public class WorkInProgressPreferencePage extends FieldEditorPreferencePage impl
}
}
- private RadioGroupFieldEditor synchronizePerspectiveSwitch;
-
public WorkInProgressPreferencePage() {
super(GRID);
setTitle(Policy.bind("WorkInProgressPreferencePage.0")); //$NON-NLS-1$
@@ -61,7 +53,7 @@ public class WorkInProgressPreferencePage extends FieldEditorPreferencePage impl
*/
public void createFieldEditors() {
- synchronizePerspectiveSwitch= new RadioGroupFieldEditor(
+ addField(new RadioGroupFieldEditor(
ICVSUIConstants.PREF_CHANGE_PERSPECTIVE_ON_SHOW_ANNOTATIONS,
Policy.bind("WorkInProgressPreferencePage.7"), //$NON-NLS-1$
3,
@@ -70,8 +62,10 @@ public class WorkInProgressPreferencePage extends FieldEditorPreferencePage impl
{Policy.bind("WorkInProgressPreferencePage.2"), MessageDialogWithToggle.NEVER}, //$NON-NLS-1$
{Policy.bind("WorkInProgressPreferencePage.3"), MessageDialogWithToggle.PROMPT} //$NON-NLS-1$
},
- getFieldEditorParent(), true);
- addField(synchronizePerspectiveSwitch);
+ getFieldEditorParent(), true));
+
+
+
final Group perspectiveGroup = createGroup(
getFieldEditorParent(),
@@ -87,9 +81,21 @@ public class WorkInProgressPreferencePage extends FieldEditorPreferencePage impl
perspectiveGroup);
addField(comboEditor);
- Dialog.applyDialogFont(getFieldEditorParent());
+ addField(new RadioGroupFieldEditor(
+ ICVSUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS,
+ "&Allow empty commit comments:", //$NON-NLS-1$
+ 3,
+ new String[][] {
+ { "Yes", MessageDialogWithToggle.ALWAYS}, //$NON-NLS-1$
+ { "No", MessageDialogWithToggle.NEVER}, //$NON-NLS-1$
+ { "Prompt", MessageDialogWithToggle.PROMPT} //$NON-NLS-1$
+ },
+ getFieldEditorParent(), true));
+
updateLayout(perspectiveGroup);
getFieldEditorParent().layout(true);
+
+ Dialog.applyDialogFont(getFieldEditorParent());
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java
index f9972b260..a8106ca59 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java
@@ -2,7 +2,7 @@
* 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 Common Public License v1.0
- * which accompanies this distribution, and is available at
+ * which accocmpanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
@@ -12,12 +12,11 @@ package org.eclipse.team.internal.ccvs.ui.actions;
import java.lang.reflect.InvocationTargetException;
-import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.operations.CommitOperation;
+import org.eclipse.team.internal.ccvs.ui.wizards.CommitWizard;
/**
* Action for checking in files to a CVS provider.
@@ -29,19 +28,14 @@ public class CommitAction extends WorkspaceAction {
* @see CVSAction#execute(IAction)
*/
public void execute(IAction action) throws InvocationTargetException, InterruptedException {
- final CommitOperation operation = new CommitOperation(getTargetPart(), getSelectedResources(), null);
- final boolean[] retVal = {true};
- run(new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- retVal[0] = operation.performPrompting(monitor);
- } catch (CVSException e) {
- new InvocationTargetException(e);
- }
- }
- }, false, PROGRESS_BUSYCURSOR);
- if(retVal[0])
- operation.run();
+
+ try {
+ final IResource [] resources= getSelectedResources();
+ CommitWizard.run(shell, resources);
+
+ } catch (CVSException e) {
+ throw new InvocationTargetException(e);
+ }
}
/**
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 15eeb5723..7fbb1bc3b 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
@@ -278,6 +278,12 @@ CVSAction.refreshQuestion={0} Would you like to refresh project ''{1}''?
CVSAction.refreshMultipleQuestion={0} Would you like to refresh the projects of the selected resources?
CommitAction.commitFailed=Problems encountered performing commit
+CommitWizardCommitPage.0=Commit
+CommitWizardCommitPage.2=Enter a comment for the commit operation.
+CommitWizardCommitPage.3=Please enter a commit comment\!
+CommitWizardFileTypePage.0=Add Resources
+CommitWizardFileTypePage.2=Unknown new files detected.
+CommitWizardFileTypePage.3=New files with the following unknown names or extensions have been detected in the workspace. Please specify whether these files should be stored as text or binary and whether this decision should be remembered.
CommitSyncAction.questionRelease=You have changes that conflict with the server. Release those changes?
CommitSyncAction.titleRelease=Confirm Overwrite
@@ -1100,6 +1106,8 @@ UpdateAction.jobName=CVS Update
MergeUpdateAction.jobName=CVS Merge
MergeUpdateAction.invalidSubscriber=Invalid subscriber: {0}
CommitAction.jobName=CVS Commit
+CommitCommentArea.0=<Click here to enter a commit comment>
+CommitCommentArea.1=<Choose a previously entered comment>
OverrideAndUpdateAction.jobName=Performing CVS Override and Update on {0} resources
WorkInProgressPreferencePage.0=CVS Work In Progress
WorkInProgressPreferencePage.1=Preferences for enabling features that are not complete:
@@ -1304,6 +1312,14 @@ CommitOperation.0=Committing {0}
CommitSetDialog.0=&Name:
CommitSetDialog.2=Use the &title as the commit comment
CommitSetDialog.3=Enter a commit &comment
+CommitWizard.0=Comitting resources
+CommitWizard.1=Comitting resources
+CommitWizard.2=Commit files
+CommitWizard.3=Empty commit comment
+CommitWizard.4=The commit comment is empty. Are you sure you would like to continue with an empty comment?
+CommitWizard.5=Remember decision?
+CommitWizard.6=Nothing to Commit
+CommitWizard.7=You workspace doesn't contain any changes with regard to the repository.
UpdateOperation.0=Updating {0}
ReplaceOperation.0=Replacing {0}
TagOperation.0=Tagging {0}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java
index 6164e3cd5..6137b5ab0 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java
@@ -14,6 +14,7 @@ import java.util.*;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
+import org.eclipse.team.core.Team;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.client.Command;
@@ -30,14 +31,29 @@ import org.eclipse.ui.IWorkbenchPart;
*/
public class AddOperation extends RepositoryProviderOperation {
- public AddOperation(IWorkbenchPart part, IResource[] resources) {
+ private Map fModesForExtensions;
+ private Map fModesForFiles;
+
+ public AddOperation(IWorkbenchPart part, IResource[] resources) {
super(part, resources);
+ fModesForExtensions= Collections.EMPTY_MAP;
+ fModesForFiles= Collections.EMPTY_MAP;
+ }
+
+ public void addModesForExtensions(Map modes) {
+ fModesForExtensions= modes;
+ }
+
+ public void addModesForNames(Map modes) {
+ fModesForFiles= modes;
}
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
*/
protected void execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException {
+ if (resources.length == 0)
+ return;
add(provider, resources, IResource.DEPTH_INFINITE, monitor);
}
@@ -112,7 +128,7 @@ public class AddOperation extends RepositoryProviderOperation {
// added explicitly (is equal currentResource) or is not ignored
if (! isManaged(mResource) && (currentResource.equals(resource) || ! mResource.isIgnored())) {
if (resource.getType() == IResource.FILE) {
- KSubstOption ksubst = KSubstOption.fromFile((IFile) resource);
+ KSubstOption ksubst= getKSubstOption((IFile)resource);
Set set = (Set) files.get(ksubst);
if (set == null) {
set = new HashSet();
@@ -130,7 +146,8 @@ public class AddOperation extends RepositoryProviderOperation {
return false;
}
}
- }, depth, false);
+
+ }, depth, false);
if (exception[0] != null) {
throw exception[0];
}
@@ -192,7 +209,7 @@ public class AddOperation extends RepositoryProviderOperation {
/*
* Consider a folder managed only if it's also a CVS folder
*/
- private boolean isManaged(ICVSResource cvsResource) throws CVSException {
+ protected boolean isManaged(ICVSResource cvsResource) throws CVSException {
return cvsResource.isManaged() && (!cvsResource.isFolder() || ((ICVSFolder)cvsResource).isCVSFolder());
}
@@ -202,4 +219,20 @@ public class AddOperation extends RepositoryProviderOperation {
protected String getErrorMessage(IStatus[] failures, int totalOperations) {
return Policy.bind("AddAction.addFailed"); //$NON-NLS-1$
}
+
+ protected KSubstOption getKSubstOption(IFile file) {
+ final String extension= file.getFileExtension();
+ final Integer mode;
+ if (extension == null) {
+ mode= (Integer)fModesForFiles.get(file.getName());
+ } else {
+ mode= (Integer)fModesForExtensions.get(extension);
+ }
+ if (mode != null) {
+ return mode.intValue() == Team.BINARY ? Command.KSUBST_BINARY : KSubstOption.getDefaultTextMode();
+ } else {
+ return KSubstOption.fromFile(file);
+ }
+ }
+
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java
index 6a641b5f2..add99a3e3 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java
@@ -10,20 +10,16 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.operations;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.client.*;
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager;
import org.eclipse.ui.IWorkbenchPart;
/**
@@ -31,44 +27,11 @@ import org.eclipse.ui.IWorkbenchPart;
*/
public class CommitOperation extends SingleCommandOperation {
- public CommitOperation(IWorkbenchPart part, IResource[] resources, LocalOption[] options) {
+ public CommitOperation(IWorkbenchPart part, IResource[] resources, LocalOption[] options, String comment) {
super(part, resources, options);
- }
-
- /**
- * Perform prompting for unadded resources and comment
- * @param monitor a progess monitor
- * @return <code>true</code> if execution should continue
- */
- public boolean performPrompting(IProgressMonitor monitor) throws CVSException, InvocationTargetException, InterruptedException {
- monitor.beginTask(null, 20);
- IResource[] resourcesToBeAdded = promptForResourcesToBeAdded(Policy.subMonitorFor(monitor, 10));
- if (resourcesToBeAdded == null) return false;
- String comment = promptForComment(getResources());
- if (comment == null) return false;
addLocalOption(Commit.makeArgumentOption(Command.MESSAGE_OPTION, comment));
- if (resourcesToBeAdded.length > 0) {
- new AddOperation(getPart(), resourcesToBeAdded)
- .run(Policy.subMonitorFor(monitor, 10));
- }
- setResources(getSharedResources(getResources()));
- monitor.done();
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
- // Ensure that a comment has been provided
- if (!Command.MESSAGE_OPTION.isElementOf(getLocalOptions())) {
- String comment = promptForComment(getResources());
- if (comment == null) return;
- addLocalOption(Commit.makeArgumentOption(Command.MESSAGE_OPTION, comment));
- }
- super.execute(monitor);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#executeCommand(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.team.internal.ccvs.core.ICVSResource[], org.eclipse.core.runtime.IProgressMonitor)
*/
@@ -76,12 +39,28 @@ public class CommitOperation extends SingleCommandOperation {
return Command.COMMIT.execute(session,
Command.NO_GLOBAL_OPTIONS,
getLocalOptions(),
- resources,
+ resources,
null,
monitor);
}
/* (non-Javadoc)
+ * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#handleErrors(org.eclipse.core.runtime.IStatus[])
+ */
+ protected void handleErrors(IStatus[] errors) throws CVSException {
+ // We are only concerned with server errors
+ List serverErrors = new ArrayList();
+ for (int i = 0; i < errors.length; i++) {
+ IStatus status = errors[i];
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ serverErrors.add(status);
+ }
+ }
+ if (serverErrors.isEmpty()) return;
+ super.handleErrors((IStatus[]) serverErrors.toArray(new IStatus[serverErrors.size()]));
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
*/
protected String getTaskName() {
@@ -102,74 +81,6 @@ public class CommitOperation extends SingleCommandOperation {
return Policy.bind("CommitAction.commitFailed"); //$NON-NLS-1$
}
- private IResource[] getUnaddedResources(IResource[] resources, IProgressMonitor iProgressMonitor) throws CVSException {
- final List unadded = new ArrayList();
- final CVSException[] exception = new CVSException[] { null };
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- // visit each resource deeply
- try {
- resource.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- // skip ignored resources and their children
- try {
- if (cvsResource.isIgnored())
- return false;
- // visit the children of shared resources
- if (cvsResource.isManaged())
- return true;
- if (cvsResource.isFolder() && ((ICVSFolder)cvsResource).isCVSFolder())
- return true;
- } catch (CVSException e) {
- exception[0] = e;
- }
- // don't add folders to avoid comitting empty folders
- if (resource.getType() == IResource.FOLDER)
- return true;
- // file is unshared so record it
- unadded.add(resource);
- // no need to go into children because add is deep
- return false;
- }
- });
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- if (exception[0] != null) throw exception[0];
- }
- return (IResource[]) unadded.toArray(new IResource[unadded.size()]);
- }
-
- protected IResource[] promptForResourcesToBeAdded(IProgressMonitor monitor) throws CVSException {
- IResource[] unadded = getUnaddedResources(getResources(), monitor);
- RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
- return manager.promptForResourcesToBeAdded(getShell(), unadded);
- }
-
- protected String promptForComment(IResource[] resourcesToCommit) {
- RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
- return manager.promptForComment(getShell(), resourcesToCommit, null);
- }
-
- /*
- * Return all resources in the provided collection that are shared with a repo
- * @param resources
- * @return IResource[]
- */
- private IResource[] getSharedResources(IResource[] resources) throws CVSException {
- List shared = new ArrayList();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- if (cvsResource.isManaged()
- || (cvsResource.isFolder() && ((ICVSFolder)cvsResource).isCVSFolder())) {
- shared.add(resource);
- }
- }
- return (IResource[]) shared.toArray(new IResource[shared.size()]);
- }
-
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#isServerModificationOperation()
*/
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantLabelDecorator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantLabelDecorator.java
index 2b749f7e4..3b17f0423 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantLabelDecorator.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantLabelDecorator.java
@@ -13,28 +13,20 @@ package org.eclipse.team.internal.ccvs.ui.subscriber;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.*;
import org.eclipse.swt.graphics.Image;
import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSSyncInfo;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
+import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
-import org.eclipse.team.internal.ccvs.ui.CVSDecoration;
-import org.eclipse.team.internal.ccvs.ui.CVSLightweightDecorator;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
+import org.eclipse.team.internal.ccvs.ui.*;
import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
-class CVSParticipantLabelDecorator extends LabelProvider implements IPropertyChangeListener, ILabelDecorator {
+public class CVSParticipantLabelDecorator extends LabelProvider implements IPropertyChangeListener, ILabelDecorator {
private ISynchronizePageConfiguration configuration;
public CVSParticipantLabelDecorator(ISynchronizePageConfiguration configuration) {
@@ -51,7 +43,7 @@ class CVSParticipantLabelDecorator extends LabelProvider implements IPropertyCha
IResource resource = ((ISynchronizeModelElement) element).getResource();
if (resource != null && resource.getType() != IResource.ROOT) {
// Prepare the decoration but substitute revision and hide dirty indicator
- CVSDecoration decoration = CVSLightweightDecorator.decorate(resource);
+ CVSDecoration decoration = getDecoration(resource);
decoration.setRevision(getRevisionNumber((ISynchronizeModelElement) element));
decoration.setDirty(false);
decoration.compute();
@@ -72,18 +64,29 @@ class CVSParticipantLabelDecorator extends LabelProvider implements IPropertyCha
return input;
}
}
- public Image decorateImage(Image base, Object element) {
+ /**
+ * @return
+ */
+ protected CVSDecoration getDecoration(IResource resource) throws CVSException {
+ return CVSLightweightDecorator.decorate(resource);
+ }
+
+ public Image decorateImage(Image base, Object element) {
return base;
}
public void propertyChange(PropertyChangeEvent event) {
- String property = event.getProperty();
- if(property.equals(CVSUIPlugin.P_DECORATORS_CHANGED) || property.equals(TeamUI.GLOBAL_FILE_TYPES_CHANGED)) {
+ if (needsRefresh(event)) {
Viewer viewer = configuration.getPage().getViewer();
if(viewer instanceof StructuredViewer && !viewer.getControl().isDisposed()) {
((StructuredViewer)viewer).refresh(true);
}
}
}
+
+ protected boolean needsRefresh(PropertyChangeEvent event) {
+ final String property= event.getProperty();
+ return property.equals(CVSUIPlugin.P_DECORATORS_CHANGED) || property.equals(TeamUI.GLOBAL_FILE_TYPES_CHANGED);
+ }
public void dispose() {
CVSUIPlugin.removePropertyChangeListener(this);
TeamUI.removePropertyChangeListener(this);
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CommitSetDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CommitSetDialog.java
index 089250d53..fa539ff2f 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CommitSetDialog.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CommitSetDialog.java
@@ -17,6 +17,7 @@ import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
@@ -30,6 +31,8 @@ import org.eclipse.ui.help.WorkbenchHelp;
*/
public class CommitSetDialog extends Dialog {
+ private static final int DEFAULT_WIDTH_IN_CHARS= 80;
+
private final ActiveChangeSet set;
private CommitCommentArea commitCommentArea;
private Text nameText;
@@ -102,6 +105,17 @@ public class CommitSetDialog extends Dialog {
Dialog.applyDialogFont(parent);
return composite;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#getInitialSize()
+ */
+ protected Point getInitialSize() {
+ final Point size= super.getInitialSize();
+ size.x= convertWidthInCharsToPixels(DEFAULT_WIDTH_IN_CHARS);
+ size.y += convertHeightInCharsToPixels(8);
+ return size;
+ }
+
private void createNameArea(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
@@ -193,7 +207,7 @@ public class CommitSetDialog extends Dialog {
set.setTitle(nameText.getText());
if (isUseCustomComment()) {
// Call getComment so the comment gets saved
- set.setComment(commitCommentArea.getComment());
+ set.setComment(commitCommentArea.getComment(true));
} else {
set.setComment(null);
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java
index eea6dc9e7..639409d22 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java
@@ -12,11 +12,16 @@ package org.eclipse.team.internal.ccvs.ui.subscriber;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.team.core.synchronize.FastSyncInfoFilter;
-import org.eclipse.team.core.synchronize.SyncInfo;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.synchronize.*;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
+import org.eclipse.team.internal.ccvs.ui.wizards.CommitWizard;
+import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.SynchronizeModelOperation;
+import org.eclipse.ui.PlatformUI;
public class WorkspaceCommitAction extends CVSParticipantAction {
@@ -32,7 +37,7 @@ public class WorkspaceCommitAction extends CVSParticipantAction {
* @see org.eclipse.team.ui.sync.SubscriberAction#getSyncInfoFilter()
*/
protected FastSyncInfoFilter getSyncInfoFilter() {
- return new SyncInfoDirectionFilter(new int[] {SyncInfo.OUTGOING});
+ return new SyncInfoDirectionFilter(new int[] { SyncInfo.OUTGOING });
}
/* (non-Javadoc)
@@ -41,4 +46,31 @@ public class WorkspaceCommitAction extends CVSParticipantAction {
protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) {
return new WorkspaceCommitOperation(configuration, elements, false /* override */);
}
+
+ public void runOperation() {
+ final SyncInfoSet set = getSyncInfoSet();
+ final Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ try {
+ CommitWizard.run(shell, set);
+ } catch (CVSException e) {
+ CVSUIPlugin.log(e);
+ }
+ }
+
+ /*
+ * Return the selected SyncInfo for which this action is enabled.
+ *
+ * @return the selected SyncInfo for which this action is enabled.
+ */
+ private SyncInfoSet getSyncInfoSet() {
+ IDiffElement [] elements= getFilteredDiffElements();
+ SyncInfoSet filtered = new SyncInfoSet();
+ for (int i = 0; i < elements.length; i++) {
+ IDiffElement e = elements[i];
+ if (e instanceof SyncInfoModelElement) {
+ filtered.add(((SyncInfoModelElement)e).getSyncInfo());
+ }
+ }
+ return filtered;
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java
index 5079542d6..6b5a3cb9b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java
@@ -11,8 +11,7 @@
package org.eclipse.team.internal.ccvs.ui.subscriber;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.resources.IResource;
@@ -27,7 +26,6 @@ import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.synchronize.SyncInfoSet;
import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Commit;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
@@ -211,9 +209,7 @@ public class WorkspaceCommitOperation extends CVSSubscriberOperation {
private void commit(IResource[] commits, IProgressMonitor monitor) throws TeamException {
try {
- new CommitOperation(getPart(), commits,
- new Command.LocalOption[] { Commit.makeArgumentOption(Command.MESSAGE_OPTION, comment) })
- .run(monitor);
+ new CommitOperation(getPart(), commits, new Command.LocalOption[0], comment).run(monitor);
} catch (InvocationTargetException e) {
throw TeamException.asTeamException(e);
} catch (InterruptedException e) {
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 b40f36d70..118a6874b 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
@@ -190,7 +190,7 @@ public class WorkspaceSynchronizeParticipant extends ScopableSubscriberParticipa
*/
protected void initializeConfiguration(ISynchronizePageConfiguration configuration) {
super.initializeConfiguration(configuration);
- ILabelDecorator labelDecorator = new CVSParticipantLabelDecorator(configuration);
+ ILabelDecorator labelDecorator = getLabelDecorator(configuration);
configuration.addLabelDecorator(labelDecorator);
configuration.addMenuGroup(ISynchronizePageConfiguration.P_TOOLBAR_MENU, TOOLBAR_CONTRIBUTION_GROUP);
configuration.addActionContribution(new WorkspaceActionContribution());
@@ -213,6 +213,10 @@ public class WorkspaceSynchronizeParticipant extends ScopableSubscriberParticipa
CONTEXT_MENU_CONTRIBUTION_GROUP_4);
}
+ protected ILabelDecorator getLabelDecorator(ISynchronizePageConfiguration configuration) {
+ return new CVSParticipantLabelDecorator(configuration);
+ }
+
protected ISynchronizeParticipantDescriptor getDescriptor() {
return TeamUI.getSynchronizeManager().getParticipantDescriptor(ID);
}
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
new file mode 100644
index 000000000..e72a3f181
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java
@@ -0,0 +1,411 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.team.internal.ccvs.ui.wizards;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.*;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.dialogs.*;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.wizard.*;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.IFileTypeInfo;
+import org.eclipse.team.core.Team;
+import org.eclipse.team.core.synchronize.*;
+import org.eclipse.team.internal.ccvs.core.*;
+import org.eclipse.team.internal.ccvs.core.client.Command;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
+import org.eclipse.team.internal.ccvs.ui.*;
+import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ccvs.ui.operations.*;
+import org.eclipse.team.internal.core.KnownModesForNames;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * A wizard to commit the resources whose synchronization state is given in form
+ * of a set of <code>SyncInfo</code>.
+ */
+public class CommitWizard extends Wizard {
+
+ private static final String COMMIT_WIZARD_SECTION = "CommitWizard"; //$NON-NLS-1$
+
+ /**
+ * Persists the size of the wizard dialog.
+ */
+ private static class SettingsSaver {
+
+ private static final String BOUNDS_HEIGHT_KEY = "width"; //$NON-NLS-1$
+ private static final String BOUNDS_WIDTH_KEY = "height"; //$NON-NLS-1$
+
+ private final IWizard fWizard;
+
+ private SettingsSaver(IWizard wizard) {
+ fWizard= wizard;
+ }
+
+ public void saveSize(int width, int height) {
+ final IDialogSettings settings= fWizard.getDialogSettings();
+ settings.addNewSection(COMMIT_WIZARD_SECTION);
+ settings.put(BOUNDS_WIDTH_KEY, width);
+ settings.put(BOUNDS_HEIGHT_KEY, height);
+ }
+
+ public Point getSize() {
+ final Point size= new Point(300, 400);
+ final IDialogSettings settings= fWizard.getDialogSettings();
+ try {
+ size.x= settings.getInt(BOUNDS_WIDTH_KEY);
+ size.y= settings.getInt(BOUNDS_HEIGHT_KEY);
+ } catch (NumberFormatException e) {
+ }
+ return size;
+ }
+ }
+
+ /**
+ * An operation to add and commit resources to a CVS repository.
+ */
+ private static class AddAndCommitOperation extends CVSOperation {
+
+ private final IResource[] fAllResources;
+ private final String fComment;
+
+ private Map fModesForExtensionsForOneTime;
+ private Map fModesForNamesForOneTime;
+
+ private IResource[] fNewResources;
+
+ private AddAndCommitOperation(IWorkbenchPart part, IResource[] allResources, String comment) {
+ super(part);
+ fNewResources = new IResource [0];
+ fModesForExtensionsForOneTime = Collections.EMPTY_MAP;
+ fModesForNamesForOneTime= Collections.EMPTY_MAP;
+ fAllResources = allResources;
+ fComment = comment;
+ }
+
+ public void setModesForExtensionsForOneTime(Map modes) {
+ fModesForExtensionsForOneTime= modes;
+ }
+
+ public void setModesForNamesForOneTime(Map modes) {
+ fModesForNamesForOneTime= modes;
+ }
+
+
+ public void setNewResources(IResource [] newResources) {
+ this.fNewResources= newResources;
+ }
+
+ protected void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
+ try {
+ final AddOperation op= new AddOperation(getPart(), fNewResources);
+ op.addModesForExtensions(fModesForExtensionsForOneTime);
+ op.addModesForNames(fModesForNamesForOneTime);
+ op.run(monitor);
+ new CommitOperation(getPart(), fAllResources, new Command.LocalOption[0], fComment).run(monitor);
+ } catch (InvocationTargetException e) {
+ throw CVSException.wrapException(e);
+ }
+ }
+
+ protected String getJobName() {
+ return Policy.bind("CommitWizard.0"); //$NON-NLS-1$
+ }
+
+ protected String getTaskName() {
+ return Policy.bind("CommitWizard.1"); //$NON-NLS-1$
+ }
+ }
+
+ private final SyncInfoSet fOutOfSyncInfos;
+ private final SyncInfoSet fUnaddedInfos;
+
+ private CommitWizardFileTypePage fFileTypePage;
+ private CommitWizardCommitPage fCommitPage;
+
+ private IResource[] fResources;
+ private SettingsSaver fSettingsSaver;
+
+
+ public CommitWizard(IResource [] resources) throws CVSException {
+ this(resources, getOutOfSyncInfos(resources));
+ }
+
+ public CommitWizard(SyncInfoSet infos) throws CVSException {
+ this(infos.getResources(), infos);
+ }
+
+ private CommitWizard(IResource [] resources, SyncInfoSet syncInfos) throws CVSException {
+ super();
+ setWindowTitle(Policy.bind("CommitWizard.2")); //$NON-NLS-1$
+
+ final IDialogSettings cvsSettings = CVSUIPlugin.getPlugin().getDialogSettings();
+ IDialogSettings section = cvsSettings.getSection(COMMIT_WIZARD_SECTION);
+ if (section == null) {
+ section = cvsSettings.addNewSection(COMMIT_WIZARD_SECTION);
+ }
+ setDialogSettings(section);
+
+ fSettingsSaver= new SettingsSaver(this);
+
+ fResources= resources;
+ fOutOfSyncInfos= syncInfos;
+ fUnaddedInfos= getUnaddedInfos(syncInfos);
+
+ }
+
+ public boolean hasUnaddedInfos() {
+ return fOutOfSyncInfos.size() > 0;
+ }
+
+ private static SyncInfoSet getOutOfSyncInfos(IResource [] resources) {
+ final CVSWorkspaceSubscriber subscriber= CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber();
+ final SyncInfoSet infos= new SyncInfoSet();
+ subscriber.collectOutOfSync(resources, IResource.DEPTH_INFINITE, infos, new NullProgressMonitor());
+
+ return new SyncInfoSet(infos.getNodes(new FastSyncInfoFilter.SyncInfoDirectionFilter(new int [] { SyncInfo.OUTGOING, SyncInfo.CONFLICTING })));
+ }
+
+ private static SyncInfoSet getUnaddedInfos(SyncInfoSet infos) throws CVSException {
+ final SyncInfoSet unadded= new SyncInfoSet();
+ 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)))
+ unadded.add(info);
+ }
+ return unadded;
+ }
+
+ private static void getUnknownNamesAndExtension(SyncInfoSet infos, Collection names, Collection extensions) {
+
+ final Set knownNames= createSetOfStrings(KnownModesForNames.getKnownModesForNames());
+ final Set knownExtensions= createSetOfStrings(Team.getAllTypes());
+
+ for (final Iterator iter = infos.iterator(); iter.hasNext();) {
+
+ final SyncInfo info = (SyncInfo)iter.next();
+ final String extension= info.getLocal().getFileExtension();
+ final String name= info.getLocal().getName();
+
+ if (extension == null && !knownNames.contains(name))
+ names.add(name);
+
+ if (extension != null && !knownExtensions.contains(extension))
+ extensions.add(extension);
+ }
+ }
+
+
+ /**
+ * Create a set of strings from an array of IFileTypeInfo. This set can be used to
+ * determine whether a given name or extension of a file is known.
+ */
+ private static Set createSetOfStrings(IFileTypeInfo [] infos) {
+ final Set result= new HashSet();
+ for (int i = 0; i < infos.length; ++i) {
+ result.add(infos[i].getExtension());
+ }
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ public void addPages() {
+
+ final Collection names= new ArrayList();
+ final Collection extensions= new ArrayList();
+ getUnknownNamesAndExtension(fUnaddedInfos, names, extensions);
+
+ if (names.size() + extensions.size() > 0) {
+ fFileTypePage= new CommitWizardFileTypePage(extensions, names);
+ addPage(fFileTypePage);
+ }
+
+ fCommitPage= new CommitWizardCommitPage(fResources, fFileTypePage);
+ addPage(fCommitPage);
+
+ super.addPages();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.IWizard#performFinish()
+ */
+ public boolean performFinish() {
+
+ final String comment= getComment();
+ if (comment == null)
+ return false;
+
+ final SyncInfoSet infos= fCommitPage.getInfosToCommit();
+ if (infos.size() == 0)
+ return true;
+
+ final SyncInfoSet unadded;
+ try {
+ unadded = getUnaddedInfos(infos);
+ } catch (CVSException e1) {
+ return false;
+ }
+
+ final AddAndCommitOperation operation= new AddAndCommitOperation(getPart(), infos.getResources(), comment);
+
+ if (fFileTypePage != null) {
+ final Map toSave= new HashMap();
+ final Map notToSave= new HashMap();
+
+ fFileTypePage.getModesForExtensions(toSave, notToSave);
+ saveExtensionMappings(toSave);
+ operation.setModesForExtensionsForOneTime(notToSave);
+
+ toSave.clear();
+ notToSave.clear();
+
+ fFileTypePage.getModesForNames(toSave, notToSave);
+ saveNameMappings(toSave);
+ operation.setModesForNamesForOneTime(notToSave);
+ }
+
+ if (unadded.size() > 0) {
+ operation.setNewResources(unadded.getResources());
+ }
+
+ try {
+ operation.run();
+ } catch (InvocationTargetException e) {
+ return false;
+ } catch (InterruptedException e) {
+ return false;
+ }
+
+ final Rectangle bounds= getContainer().getCurrentPage().getControl().getParent().getClientArea();
+ fSettingsSaver.saveSize(bounds.width, bounds.height);
+
+ return true;
+ }
+
+ private String getComment() {
+ final String comment= fCommitPage.getComment();
+ if (comment.length() == 0) {
+
+ final IPreferenceStore store= CVSUIPlugin.getPlugin().getPreferenceStore();
+ final String value= store.getString(ICVSUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS);
+
+ if (MessageDialogWithToggle.NEVER.equals(value))
+ return null;
+
+ if (MessageDialogWithToggle.PROMPT.equals(value)) {
+
+ final String title= Policy.bind("CommitWizard.3"); //$NON-NLS-1$
+ final String message= Policy.bind("CommitWizard.4"); //$NON-NLS-1$
+ final String toggleMessage= Policy.bind("CommitWizard.5"); //$NON-NLS-1$
+
+ final MessageDialogWithToggle dialog= MessageDialogWithToggle.openYesNoQuestion(getShell(), title, message, toggleMessage, false, store, ICVSUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS);
+ if (dialog.getReturnCode() == IDialogConstants.NO_ID) {
+ fCommitPage.setFocus();
+ return null;
+ }
+ }
+ }
+ return comment;
+ }
+
+ public static void run(Shell shell, IResource [] resources) throws CVSException {
+ run(shell, new CommitWizard(resources));
+ }
+
+ public static void run(Shell shell, SyncInfoSet infos) throws CVSException {
+ run(shell, new CommitWizard(infos));
+ }
+
+ private static void run(Shell shell, CommitWizard wizard) {
+ if (!wizard.hasUnaddedInfos()) {
+ MessageDialog.openInformation(shell, Policy.bind("CommitWizard.6"), Policy.bind("CommitWizard.7")); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ final WizardDialog dialog= new WizardDialog(shell, wizard);
+ dialog.setMinimumPageSize(wizard.loadSize());
+ dialog.open();
+ }
+ }
+
+
+ /**
+ * @param modesToPersist
+ */
+ private static void saveExtensionMappings(Map modesToPersist) {
+
+ final String [] extensions= new String [modesToPersist.size()];
+ final int [] modes= new int[modesToPersist.size()];
+
+ int index= 0;
+ for (Iterator iter= modesToPersist.keySet().iterator(); iter.hasNext();) {
+ extensions[index]= (String) iter.next();
+ modes[index]= ((Integer)modesToPersist.get(extensions[index])).intValue();
+ ++index;
+ }
+ Team.addAllTypes(extensions, modes);
+ }
+
+ private static void saveNameMappings(Map modesToPersist) {
+
+ final String [] extensions= new String [modesToPersist.size()];
+ final int [] modes= new int[modesToPersist.size()];
+
+ int index= 0;
+ for (Iterator iter= modesToPersist.keySet().iterator(); iter.hasNext();) {
+ extensions[index]= (String) iter.next();
+ modes[index]= ((Integer)modesToPersist.get(extensions[index])).intValue();
+ ++index;
+ }
+ KnownModesForNames.addModesForFiles(extensions, modes);
+ }
+
+ /**
+ * Get the current workbench part.
+ * @return The workbench part.
+ */
+ private IWorkbenchPart getPart() {
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().getActivePart();
+ }
+
+ private static boolean isAdded(IResource resource) throws CVSException {
+ final ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
+ if (cvsResource.isFolder()) {
+ return ((ICVSFolder)cvsResource).isCVSFolder();
+ }
+ return cvsResource.isManaged();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#canFinish()
+ */
+ public boolean canFinish() {
+ final IWizardPage current= getContainer().getCurrentPage();
+ if (current == fFileTypePage && fCommitPage != null)
+ return false;
+ return super.canFinish();
+ }
+
+ public Point loadSize() {
+ return fSettingsSaver.getSize();
+ }
+}
+
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java
new file mode 100644
index 000000000..ec5ec2805
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java
@@ -0,0 +1,320 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.team.internal.ccvs.ui.wizards;
+
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.dialogs.*;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.wizard.*;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.team.core.synchronize.SyncInfoSet;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.ui.*;
+import org.eclipse.team.internal.ccvs.ui.actions.IgnoreAction;
+import org.eclipse.team.internal.ccvs.ui.subscriber.*;
+import org.eclipse.team.internal.ui.SWTUtils;
+import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.internal.ui.synchronize.*;
+import org.eclipse.team.ui.synchronize.*;
+
+/**
+ * This wizard page shows a preview of the commit operation and allows entering
+ * a commit comment.
+ */
+public class CommitWizardCommitPage extends WizardPage implements IPropertyChangeListener {
+
+ /**
+ * The actions to be displayed in the context menu.
+ */
+ private class ActionContribution extends SynchronizePageActionGroup {
+
+ public void initialize(ISynchronizePageConfiguration configuration) {
+ super.initialize(configuration);
+ appendToGroup(
+ ISynchronizePageConfiguration.P_CONTEXT_MENU,
+ ISynchronizePageConfiguration.OBJECT_CONTRIBUTIONS_GROUP,
+ new CVSActionDelegateWrapper(new IgnoreAction(), configuration));
+ }
+ }
+
+ /**
+ * Saves the size of the wizard dialog.
+ */
+ private class SettingsSaver {
+
+ private static final String PREF_WEIGHT_A = "commit_wizard_page.weight_a"; //$NON-NLS-1$
+ private static final String PREF_WEIGHT_B = "Commit_wizard_page.weigth_b"; //$NON-NLS-1$
+
+ public void saveWeights(int a, int b) {
+ final IDialogSettings settings= getSettings();
+ if (settings == null)
+ return;
+
+ settings.put(PREF_WEIGHT_A, a);
+ settings.put(PREF_WEIGHT_B, b);
+ }
+
+ public int [] loadWeights() {
+ final int [] weights= { 1, 1 };
+ final IDialogSettings settings= getSettings();
+ if (settings == null)
+ return weights;
+ try {
+ weights[0]= settings.getInt(PREF_WEIGHT_A);
+ weights[1]= settings.getInt(PREF_WEIGHT_B);
+ } catch (NumberFormatException e) {
+ }
+ return weights;
+ }
+
+ private IDialogSettings getSettings() {
+ final IWizard wizard= getWizard();
+ if (wizard == null)
+ return null;
+ return wizard.getDialogSettings();
+ }
+ }
+
+ /**
+ * An extension of the standard label decorator which configures the keyword substitution
+ * mode according to the settings on the file type wizard page.
+ */
+ private class Decorator extends CVSParticipantLabelDecorator {
+
+ public Decorator(ISynchronizePageConfiguration configuration) {
+ super(configuration);
+ }
+
+ protected CVSDecoration getDecoration(IResource resource) throws CVSException {
+ final CVSDecoration decoration= super.getDecoration(resource);
+ if (fFileTypePage != null && resource instanceof IFile)
+ decoration.setKeywordSubstitution(fFileTypePage.getOption((IFile)resource).getShortDisplayText());
+ return decoration;
+ }
+ }
+
+ /**
+ * A participant that uses our decorator instead of the standard one.
+ */
+ private class Participant extends WorkspaceSynchronizeParticipant {
+ public Participant(ISynchronizeScope scope) {
+ super(scope);
+ }
+ protected ILabelDecorator getLabelDecorator(ISynchronizePageConfiguration configuration) {
+ return new Decorator(configuration);
+ }
+
+ public ChangeSetCapability getChangeSetCapability() {
+ return null; // we don't want that button
+ }
+ }
+
+ private final CommitCommentArea fCommentArea;
+ private final IResource [] fResources;
+
+ private final SettingsSaver fSettingsSaver;
+
+ private ISynchronizePageConfiguration fConfiguration;
+ private SashForm fSashForm;
+ protected final CommitWizardFileTypePage fFileTypePage;
+
+ /**
+ *
+ */
+ public CommitWizardCommitPage(IResource [] resources, CommitWizardFileTypePage fileTypePage) {
+ super(Policy.bind("CommitWizardCommitPage.0")); //$NON-NLS-1$
+ setTitle(Policy.bind("CommitWizardCommitPage.2")); //$NON-NLS-1$
+ setDescription(Policy.bind("CommitWizardCommitPage.2")); //$NON-NLS-1$
+
+ fSettingsSaver= new SettingsSaver();
+ fFileTypePage= fileTypePage;
+ fCommentArea= new CommitCommentArea();
+ fResources= resources;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ initializeDialogUnits(parent);
+
+ final Composite composite= new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1, true));
+
+ /**
+ * A sash for the comment area and the changes.
+ */
+ fSashForm= new SashForm(composite, SWT.VERTICAL);
+ fSashForm.setLayoutData(SWTUtils.createHVFillGridData());
+
+ createCommentArea(fSashForm);
+ createChangesArea(fSashForm);
+
+ fSashForm.setWeights(fSettingsSaver.loadWeights());
+ setControl(composite);
+
+ fCommentArea.setFocus();
+ validatePage(false);
+ }
+
+ private void createCommentArea(Composite parent) {
+
+ final Composite composite= new Composite(parent, SWT.NONE);
+ composite.setLayout(SWTUtils.createGridLayout(1, 0, 0));
+
+ fCommentArea.createArea(composite);
+ fCommentArea.getComposite().setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, convertHeightInCharsToPixels(8), SWT.FILL, SWT.FILL, true, true));
+ fCommentArea.addPropertyChangeListener(this);
+
+ createPlaceholder(composite);
+
+ if (fResources.length > 0)
+ fCommentArea.setProject(fResources[0].getProject());
+ }
+
+
+ private void createChangesArea(Composite parent) {
+
+ final Composite composite= new Composite(parent, SWT.NONE);
+ composite.setLayout(SWTUtils.createGridLayout(1, 0, 0));
+ composite.setLayoutData(SWTUtils.createHVFillGridData());
+
+ createPlaceholder(composite);
+
+ final WorkspaceSynchronizeParticipant participant = new Participant(new ResourceScope(fResources));
+ fConfiguration= participant.createPageConfiguration();
+ fConfiguration.setProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU, new String[] {ISynchronizePageConfiguration.LAYOUT_GROUP});
+ fConfiguration.setProperty(ISynchronizePageConfiguration.P_CONTEXT_MENU, ISynchronizePageConfiguration.DEFAULT_CONTEXT_MENU);
+ fConfiguration.addActionContribution(new ActionContribution());
+
+ fConfiguration.setProperty(ISynchronizePageConfiguration.P_LAYOUT, ISynchronizePageConfiguration.FLAT_LAYOUT);
+ fConfiguration.setRunnableContext(getContainer());
+ fConfiguration.setMode(ISynchronizePageConfiguration.OUTGOING_MODE);
+
+ final ParticipantPagePane part= new ParticipantPagePane(getShell(), true /* modal */, fConfiguration, participant);
+ Control control = part.createPartControl(composite);
+ control.setLayoutData(SWTUtils.createHVFillGridData());
+
+ }
+ /**
+ * @param composite
+ */
+ 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));
+ }
+
+ /**
+ * @return
+ */
+ public String getComment() {
+ return fCommentArea.getComment(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
+ */
+ public boolean isPageComplete() {
+ return super.isPageComplete();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ fCommentArea.setFocus();
+ fConfiguration.getPage().getViewer().refresh();
+ }
+
+ /**
+ *
+ */
+ boolean validatePage(boolean setMessage) {
+ if (fCommentArea != null && fCommentArea.getComment(false).length() == 0) {
+ final IPreferenceStore store= CVSUIPlugin.getPlugin().getPreferenceStore();
+ final String value= store.getString(ICVSUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS);
+ if (MessageDialogWithToggle.NEVER.equals(value)) {
+ setPageComplete(false);
+ if (setMessage)
+ setErrorMessage(Policy.bind("CommitWizardCommitPage.3")); //$NON-NLS-1$
+ return false;
+ }
+ }
+ setPageComplete(true);
+ setErrorMessage(null);
+ return true;
+ }
+
+ /**
+ *
+ */
+ public void setFocus() {
+ fCommentArea.setFocus();
+ validatePage(true);
+ }
+
+ protected IWizardContainer getContainer() {
+ return super.getContainer();
+ }
+
+ public SyncInfoSet getInfosToCommit() {
+
+ final SyncInfoSet infos= new SyncInfoSet();
+ if (fConfiguration == null)
+ return infos;
+
+ final IDiffElement root = (ISynchronizeModelElement)fConfiguration.getProperty(SynchronizePageConfiguration.P_MODEL);
+ final IDiffElement [] elements= Utils.getDiffNodes(new IDiffElement [] { root });
+
+ for (int i = 0; i < elements.length; i++) {
+ if (elements[i] instanceof SyncInfoModelElement) {
+ infos.add(((SyncInfoModelElement)elements[i]).getSyncInfo());
+ }
+ }
+ return infos;//(IResource [])result.toArray(new IResource[result.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+
+ if (event.getProperty().equals(CommitCommentArea.OK_REQUESTED)) {
+ final IWizardContainer container= getContainer();
+ if (container instanceof WizardDialog) {
+ final WizardDialog dialog= (WizardDialog)container;
+ if (getWizard().canFinish()) {
+ try {
+ getWizard().performFinish();
+ } finally {
+ dialog.close();
+ }
+ }
+ }
+ }
+ if (event.getProperty().equals(CommitCommentArea.COMMENT_MODIFIED)) {
+ validatePage(true);
+ }
+ }
+
+}
+
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardFileTypePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardFileTypePage.java
new file mode 100644
index 000000000..1126f77f0
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardFileTypePage.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.team.internal.ccvs.ui.wizards;
+
+import java.util.*;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.team.core.Team;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.ICVSFile;
+import org.eclipse.team.internal.ccvs.core.client.Command;
+import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
+import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
+import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ui.SWTUtils;
+import org.eclipse.team.internal.ui.preferences.FileTypeTable;
+
+/**
+ *
+ */
+public class CommitWizardFileTypePage extends WizardPage implements FileTypeTable.PixelConverter {
+
+ private final Collection fExtensions;
+ private final Collection fNames;
+
+ public CommitWizardFileTypePage(Collection unknownExtensions, Collection unknownNames) {
+ super(Policy.bind("CommitWizardFileTypePage.0")); //$NON-NLS-1$
+ setTitle("Add Resources"); //$NON-NLS-1$
+ setDescription(Policy.bind("CommitWizardFileTypePage.2")); //$NON-NLS-1$
+
+ fNames= new ArrayList();
+ for (final Iterator iter = unknownNames.iterator(); iter.hasNext();) {
+ final String name = (String) iter.next();
+ fNames.add(new FileTypeTable.Name(name));
+ }
+
+ fExtensions= new ArrayList();
+ for (final Iterator iter = unknownExtensions.iterator(); iter.hasNext();) {
+ final String extension= (String)iter.next();
+ fExtensions.add(new FileTypeTable.Extension(extension));
+ }
+ }
+
+ public void createControl(Composite parent) {
+
+ initializeDialogUnits(parent);
+
+ final Composite composite= new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1, false));
+
+ final Label label= new Label(composite, SWT.WRAP);
+ label.setText(Policy.bind("CommitWizardFileTypePage.3")); //$NON-NLS-1$
+ label.setLayoutData(SWTUtils.createHFillGridData());
+
+ final List items= new ArrayList();
+ items.addAll(fNames);
+ items.addAll(fExtensions);
+ new FileTypeTable(composite, this, items, true);
+
+ setControl(composite);
+ }
+
+ public void getModesForExtensions(Map toSave, Map notToSave) {
+ getModes(fExtensions, toSave, notToSave);
+ }
+
+ public void getModesForNames(Map toSave, Map notToSave) {
+ getModes(fNames, toSave, notToSave);
+ }
+
+ private static void getModes(Collection items, Map toSave, Map notToSave) {
+ for (final Iterator iter = items.iterator(); iter.hasNext();) {
+ final FileTypeTable.Item item= (FileTypeTable.Item)iter.next();
+ final Map destination= item.save ? toSave : notToSave;
+ destination.put(item.name, new Integer(item.mode));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ui.preferences.FileTypeTable.PixelConverter#convertWidthInCharsToPixels(int)
+ */
+ public int convertWidthInCharsToPixels(int chars) {
+ return super.convertWidthInCharsToPixels(chars);
+ }
+
+ public KSubstOption getOption(IFile file) throws CVSException {
+ final String extension= file.getFileExtension();
+ if (extension != null) {
+ for (Iterator iter = fExtensions.iterator(); iter.hasNext();) {
+ final FileTypeTable.Item element = (FileTypeTable.Item) iter.next();
+ if (element.name.equals(extension)) {
+ return element.mode == Team.TEXT ? KSubstOption.getDefaultTextMode() : Command.KSUBST_BINARY;
+ }
+ }
+ } else {
+ final String name= file.getName();
+ for (Iterator iter = fNames.iterator(); iter.hasNext();) {
+ FileTypeTable.Item item = (FileTypeTable.Item) iter.next();
+ if (item.name.equals(name)) {
+ return item.mode == Team.TEXT ? KSubstOption.getDefaultTextMode() : Command.KSUBST_BINARY;
+ }
+ }
+ }
+ final ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file);
+ ResourceSyncInfo fileInfo = cvsFile.getSyncInfo();
+ return fileInfo != null ? fileInfo.getKeywordMode() : KSubstOption.fromFile(file);
+ }
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardCommitCommentPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardCommitCommentPage.java
index d9bbe10e8..e8bfb96ac 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardCommitCommentPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/KSubstWizardCommitCommentPage.java
@@ -59,7 +59,7 @@ public class KSubstWizardCommitCommentPage extends CVSWizardPage {
* @return String
*/
public String getComment() {
- return commitCommentArea.getComment();
+ return commitCommentArea.getComment(true);
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/SWTUtils.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/SWTUtils.java
new file mode 100644
index 000000000..c6086a350
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/SWTUtils.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.team.internal.ui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ *
+ */
+public class SWTUtils {
+
+ public static GridData createGridData(int width, int height, boolean hFill, boolean vFill) {
+ return createGridData(width, height, hFill ? SWT.FILL : SWT.BEGINNING, vFill ? SWT.FILL : SWT.BEGINNING, hFill, vFill);
+ }
+
+ public static GridData createGridData(int width, int height, int hAlign, int vAlign, boolean hGrab, boolean vGrab) {
+ final GridData gd= new GridData(hAlign, vAlign, hGrab, vGrab);
+ gd.widthHint= width;
+ gd.heightHint= height;
+ return gd;
+ }
+
+
+ public static GridData createHFillGridData() {
+ return createGridData(0, SWT.DEFAULT, true, false);
+ }
+
+ public static GridData createHFillGridData(int span) {
+ final GridData gd= createGridData(0, SWT.DEFAULT, true, false);
+ gd.horizontalSpan= span;
+ return gd;
+ }
+
+ public static GridData createHVFillGridData() {
+ return createGridData(0, 0, true, true);
+ }
+
+ public static Composite createGridComposite(Composite parent, int numColumns) {
+ final Composite composite= new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(numColumns, false));
+ return composite;
+ }
+
+ public static GridLayout createGridLayout(int numColumns, int marginWidth, int marginHeight) {
+ final GridLayout layout= new GridLayout(numColumns, false);
+ layout.marginWidth= marginWidth;
+ layout.marginHeight= marginHeight;
+ return layout;
+ }
+
+}
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 f6fe1cb8a..84c472338 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
@@ -99,7 +99,7 @@ TeamAction.internal=Internal error occurred.
TeamFile.saveChanges=Unable to save changes to file: {0}
TeamFile.modified={0}*
-TextPreferencePage.add=&Add...
+TextPreferencePage.add=&Add Extension...
TextPreferencePage.binary=Binary
TextPreferencePage.change=&Change
TextPreferencePage.contents=Contents
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/FileTypeTable.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/FileTypeTable.java
new file mode 100644
index 000000000..7793f8e9e
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/FileTypeTable.java
@@ -0,0 +1,244 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.team.internal.ui.preferences;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.jface.viewers.*;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.team.core.Team;
+import org.eclipse.team.internal.ui.SWTUtils;
+
+
+public class FileTypeTable implements ICellModifier, IStructuredContentProvider, ITableLabelProvider {
+
+ private final static int COMBO_INDEX_BINARY= 0;
+ private final static int COMBO_INDEX_TEXT= 1;
+ private final static String [] MODES_TEXT= { "Binary", "ASCII Text" };
+
+ private final static int COMBO_INDEX_SAVE= 0;
+ private final static int COMBO_INDEX_DONT_SAVE= 1;
+ private static final String [] SAVE_TEXT= { "Yes", "No" };
+
+ public interface PixelConverter {
+
+ int convertWidthInCharsToPixels(int chars);
+
+ }
+
+ public abstract static class Item {
+ public final String name;
+ public boolean save;
+ public int mode;
+
+ public Item(String name) { this.name= name; save= true; mode= Team.BINARY; }
+ }
+
+ public static class Extension extends Item {
+ public Extension(String name) { super(name); }
+
+ }
+
+ public static class Name extends Item {
+ public Name(String name) { super(name); }
+ }
+
+ private final static int SMALL_COLUMN= 15;
+ private final static int LARGE_COLUMN= 30;
+
+ protected static final String ITEM = "item";
+ protected static final String PROPERTY_MODE= "mode";
+ protected static final String PROPERTY_SAVE= "save";
+
+ private final TableViewer fTableViewer;
+ private final List fItems;
+ private final boolean fShowSaveColumn;
+
+ public FileTypeTable(Composite composite, PixelConverter converter, List items, boolean showSaveColumn) {
+
+ fShowSaveColumn= showSaveColumn;
+
+ fItems= items;
+
+ /**
+ * Create a table.
+ */
+ final Table table = new Table(composite, SWT.V_SCROLL | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
+ table.setLayoutData(SWTUtils.createHVFillGridData());
+ table.setLinesVisible(false);
+ table.setHeaderVisible(true);
+
+ /**
+ * Create a viewer for the table.
+ */
+ fTableViewer = new TableViewer(table);
+ fTableViewer.setContentProvider(this);
+ fTableViewer.setLabelProvider(this);
+ fTableViewer.setSorter(new ViewerSorter() {
+ public int category(Object element) {
+ if (element instanceof Extension)
+ return 0;
+ if (element instanceof Name) {
+ return 1;
+ }
+ return 2;
+ }
+
+ });
+
+ /**
+ * The 'Extension' column
+ */
+ final TableColumn fileColumn = new TableColumn(table, SWT.NONE, 0);
+ fileColumn.setWidth(converter.convertWidthInCharsToPixels(LARGE_COLUMN));
+ fileColumn.setText("Name/Extension");
+
+ /**
+ * The 'Mode' column
+ */
+ final TableColumn modeColumn = new TableColumn(table, SWT.NONE, 1);
+ modeColumn.setWidth(converter.convertWidthInCharsToPixels(SMALL_COLUMN));
+ modeColumn.setText("Content");
+
+ /**
+ * The 'Save' column
+ */
+ if (fShowSaveColumn) {
+ final TableColumn saveColumn = new TableColumn(table, SWT.NONE, 2);
+ saveColumn.setWidth(converter.convertWidthInCharsToPixels(LARGE_COLUMN));
+ saveColumn.setText("Remember decision?");
+ }
+
+ /**
+ * Add a cell editor in the Keyword Substitution Mode column
+ */
+ new TableEditor(table);
+
+ final CellEditor modeEditor = new ComboBoxCellEditor(table, MODES_TEXT, SWT.READ_ONLY);
+ final CellEditor saveEditor= new ComboBoxCellEditor(table, SAVE_TEXT, SWT.READ_ONLY);
+
+ if (fShowSaveColumn) {
+ fTableViewer.setCellEditors(new CellEditor[] { null, modeEditor, saveEditor });
+ fTableViewer.setColumnProperties(new String [] { ITEM, PROPERTY_MODE, PROPERTY_SAVE });
+ } else {
+ fTableViewer.setCellEditors(new CellEditor [] { null, modeEditor });
+ fTableViewer.setColumnProperties(new String [] { ITEM, PROPERTY_MODE });
+ }
+
+ fTableViewer.setCellModifier(this);
+
+ fTableViewer.setInput(fItems);
+ }
+
+
+ public Object getValue(Object element, String property) {
+
+ final Item item= (Item)element;
+
+ if (PROPERTY_MODE.equals(property)) {
+ if (item.mode == Team.BINARY)
+ return new Integer(COMBO_INDEX_BINARY);
+ if (item.mode == Team.TEXT)
+ return new Integer(COMBO_INDEX_TEXT);
+ }
+
+ if (fShowSaveColumn && PROPERTY_SAVE.equals(property)) {
+ return new Integer(item.save ? COMBO_INDEX_SAVE : COMBO_INDEX_DONT_SAVE);
+ }
+ return null;
+ }
+
+ public boolean canModify(Object element, String property) {
+ return PROPERTY_MODE.equals(property) || (fShowSaveColumn && PROPERTY_SAVE.equals(property));
+ }
+
+ public void modify(Object element, String property, Object value) {
+
+ final IStructuredSelection selection = (IStructuredSelection)fTableViewer.getSelection();
+ final Item item= (Item)selection.getFirstElement();
+
+ final int comboIndex = ((Integer)value).intValue();
+
+ if (PROPERTY_MODE.equals(property)) {
+ if (comboIndex == COMBO_INDEX_BINARY)
+ item.mode= Team.BINARY;
+ if (comboIndex == COMBO_INDEX_TEXT)
+ item.mode= Team.TEXT;
+ }
+
+ if (fShowSaveColumn && PROPERTY_SAVE.equals(property)) {
+ item.save= COMBO_INDEX_SAVE == comboIndex;
+ }
+ fTableViewer.refresh(item);
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+
+ final Item item= (Item) element;
+
+ if (columnIndex == 0) {
+ return (item instanceof Extension ? "*." : "") + item.name;
+ }
+
+ if (columnIndex == 1) {
+ if (item.mode == Team.BINARY) {
+ return MODES_TEXT[COMBO_INDEX_BINARY];
+ } else if (item.mode == Team.TEXT) {
+ return MODES_TEXT[COMBO_INDEX_TEXT];
+ }
+ }
+
+ if (columnIndex == 2) {
+ if (fShowSaveColumn) return SAVE_TEXT[item.save ? COMBO_INDEX_SAVE : COMBO_INDEX_DONT_SAVE];
+ }
+
+ return null;
+ }
+
+ public void addListener(ILabelProviderListener listener) {}
+
+ public void dispose() {}
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {}
+
+ public Object[] getElements(Object inputElement) {
+ return ((Collection)inputElement).toArray();
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+
+ public IStructuredSelection getSelection() {
+ return (IStructuredSelection)fTableViewer.getSelection();
+ }
+
+ public void setInput(List items) {
+ fItems.clear();
+ fItems.addAll(items);
+ fTableViewer.refresh();
+ }
+
+ public TableViewer getViewer() {
+ return fTableViewer;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/TextPreferencePage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/TextPreferencePage.java
index 0cd7d275b..17aa0a36f 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/TextPreferencePage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/TextPreferencePage.java
@@ -20,16 +20,12 @@ import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.TableEditor;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.team.core.IFileTypeInfo;
import org.eclipse.team.core.Team;
+import org.eclipse.team.internal.core.KnownModesForNames;
import org.eclipse.team.internal.ui.*;
-import org.eclipse.team.internal.ui.IHelpContextIds;
-import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
@@ -39,230 +35,136 @@ import org.eclipse.ui.help.WorkbenchHelp;
* is to be treated as a text file or not. The page allows the user to add or
* remove entries from this table, and change their values from Text to Binary.
*/
-public class TextPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
- // Some string constants for display purposes
- private static final String TEXT = Policy.bind("TextPreferencePage.text"); //$NON-NLS-1$
- private static final String BINARY = Policy.bind("TextPreferencePage.binary"); //$NON-NLS-1$
-
+public class TextPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, FileTypeTable.PixelConverter {
+
// The input for the table viewer
- private List input;
+ private final List fItems;
// Widgets
- private TableViewer viewer;
- private Button removeButton;
- private Button changeButton;
+ private Button fRemoveButton;
+ private Button fChangeButton;
+
+ protected FileTypeTable fTable;
+
+ public TextPreferencePage() {
+ fItems= new ArrayList();
+ initializeItems();
+ }
+
+ private void initializeItems() {
+
+ fItems.clear();
+
+ final IFileTypeInfo [] extensionInfoArray= Team.getAllTypes();
+ final IFileTypeInfo [] nameInfoArray= KnownModesForNames.getKnownModesForNames();
+
+ for (int i = 0; i < extensionInfoArray.length; i++) {
+ final IFileTypeInfo info= extensionInfoArray[i];
+ final FileTypeTable.Extension extension= new FileTypeTable.Extension(info.getExtension());
+ extension.mode= info.getType();
+ fItems.add(extension);
+ }
+
+ for (int i = 0; i < nameInfoArray.length; i++) {
+ final IFileTypeInfo info= nameInfoArray[i];
+ final FileTypeTable.Name name= new FileTypeTable.Name(info.getExtension());
+ name.mode= info.getType();
+ fItems.add(name);
+ }
+
+ }
- /**
- * TableEntry is a pair of strings representing an entry in the table
- */
- class TableEntry {
- String ext;
- String value;
- public TableEntry(String ext, String value) {
- this.ext = ext;
- this.value = value;
- }
- public String getExtension() {
- return ext;
- }
- public String getValue() {
- return value;
- }
- public void setValue(String value) {
- this.value = value;
- }
- }
- /**
- * TableLabelProvider provides labels for TableEntrys.
- */
- class TableLabelProvider extends LabelProvider implements ITableLabelProvider {
- public String getColumnText(Object element, int columnIndex) {
- TableEntry entry = (TableEntry)element;
- switch (columnIndex) {
- case 0:
- return entry.getExtension();
- case 1:
- return entry.getValue();
- default:
- return null;
- }
- }
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
- };
-
- /*
- * Method declared on IWorkbenchPreferencePage
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
public void init(IWorkbench workbench) {
}
- /*
- * @see PreferencePage#createControl
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
- protected Control createContents(Composite ancestor) {
+ protected Control createContents(Composite parent) {
- Composite parent = new Composite(ancestor, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.numColumns = 2;
- parent.setLayout(layout);
-
// set F1 help
WorkbenchHelp.setHelp(parent, IHelpContextIds.FILE_TYPE_PREFERENCE_PAGE);
-
- Label l1 = new Label(parent, SWT.NULL);
- l1.setText(Policy.bind("TextPreferencePage.description")); //$NON-NLS-1$
- GridData data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
- data.horizontalSpan = 2;
- l1.setLayoutData(data);
+ initializeDialogUnits(parent);
+
+ final Composite composite= new Composite(parent, SWT.NONE);
+ composite.setLayout(SWTUtils.createGridLayout(2, 0, 0));
+
+ fTable= new FileTypeTable(composite, this, fItems, false);
- viewer = new TableViewer(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- Table table = viewer.getTable();
- new TableEditor(table);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.widthHint = convertWidthInCharsToPixels(30);
- /*
- * The hardcoded hint does not look elegant, but in reality
- * it does not make anything bound to this 100-pixel value,
- * because in any case the tree on the left is taller and
- * that's what really determines the height.
- */
- gd.heightHint = 100;
- table.setLayoutData(gd);
- table.addListener(SWT.Selection, new Listener() {
+
+ fTable.getViewer().getControl().addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
handleSelection();
}
});
- // Create the table columns
- new TableColumn(table, SWT.NULL);
- new TableColumn(table, SWT.NULL);
- TableColumn[] columns = table.getColumns();
- columns[0].setText(Policy.bind("TextPreferencePage.extension")); //$NON-NLS-1$
- columns[1].setText(Policy.bind("TextPreferencePage.contents")); //$NON-NLS-1$
-
- CellEditor editor = new ComboBoxCellEditor(table, new String[] {TEXT, BINARY});
- viewer.setCellEditors(new CellEditor[] {null, editor});
- viewer.setColumnProperties(new String[] {"extension", "contents"}); //$NON-NLS-1$ //$NON-NLS-2$
- viewer.setCellModifier(new ICellModifier() {
- public Object getValue(Object element, String property) {
- String value = ((TableEntry)element).getValue();
- if (value.equals(TEXT)) {
- return new Integer(0);
- } else {
- return new Integer(1);
- }
- }
- public boolean canModify(Object element, String property) {
- return true;
- }
- public void modify(Object element, String property, Object value) {
- IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
- TableEntry entry = (TableEntry)selection.getFirstElement();
- if (((Integer)value).intValue() == 0) {
- entry.setValue(TEXT);
- } else {
- entry.setValue(BINARY);
- }
- viewer.refresh(entry);
- }
- });
- viewer.setLabelProvider(new TableLabelProvider());
- viewer.setContentProvider(new IStructuredContentProvider() {
- public void dispose() {
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- public Object[] getElements(Object inputElement) {
- if (inputElement == null) return null;
- return ((List)inputElement).toArray();
- }
- });
- viewer.addDoubleClickListener(new IDoubleClickListener() {
+
+ fTable.getViewer().addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
- ISelection selection = event.getSelection();
+ final ISelection selection = event.getSelection();
if (selection == null || !(selection instanceof IStructuredSelection)) {
return;
}
- viewer.editElement(((IStructuredSelection)selection).getFirstElement(), 1);
+ fTable.getViewer().editElement(((IStructuredSelection)selection).getFirstElement(), 1);
}
});
- viewer.setSorter(new ViewerSorter() {
- public int compare(Viewer viewer, Object e1, Object e2) {
- TableEntry entry1 = (TableEntry)e1;
- TableEntry entry2 = (TableEntry)e2;
- return super.compare(viewer, entry1.getExtension(), entry2.getExtension());
+
+ final Composite buttonsComposite = new Composite(composite, SWT.NONE);
+ buttonsComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
+ buttonsComposite.setLayout(SWTUtils.createGridLayout(1, 0, 0));
+
+ final int buttonWidth= (3 *convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH)) / 2;
+
+ final Button addExtensionButton = new Button(buttonsComposite, SWT.PUSH);
+ addExtensionButton.setText(Policy.bind("TextPreferencePage.add")); //$NON-NLS-1$
+ addExtensionButton.setLayoutData(SWTUtils.createGridData(buttonWidth, SWT.DEFAULT, SWT.FILL, SWT.FILL, false, false));
+ addExtensionButton.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ addExtension();
}
});
- TableLayout tl = new TableLayout();
- tl.addColumnData(new ColumnWeightData(50));
- tl.addColumnData(new ColumnWeightData(50));
- table.setLayout(tl);
- Composite buttons = new Composite(parent, SWT.NULL);
- buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
- layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- buttons.setLayout(layout);
-
- Button addButton = new Button(buttons, SWT.PUSH);
- addButton.setText(Policy.bind("TextPreferencePage.add")); //$NON-NLS-1$
- data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
- int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- data.widthHint = Math.max(widthHint, addButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
- addButton.setLayoutData(data);
- addButton.addListener(SWT.Selection, new Listener() {
+ final Button addNameButton = new Button(buttonsComposite, SWT.PUSH);
+ addNameButton.setText("Add Name...");
+ addNameButton.setLayoutData(SWTUtils.createGridData(buttonWidth, SWT.DEFAULT, SWT.FILL, SWT.FILL, false, false));
+ addNameButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
- addPattern();
+ addName();
}
});
+
- changeButton = new Button(buttons, SWT.PUSH);
- changeButton.setText(Policy.bind("TextPreferencePage.change")); //$NON-NLS-1$
- data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
- widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- data.widthHint = Math.max(widthHint, changeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
- changeButton.setLayoutData(data);
- changeButton.setEnabled(false);
- changeButton.addListener(SWT.Selection, new Listener() {
+ fChangeButton = new Button(buttonsComposite, SWT.PUSH);
+ fChangeButton.setText(Policy.bind("TextPreferencePage.change")); //$NON-NLS-1$
+ fChangeButton.setLayoutData(SWTUtils.createGridData(buttonWidth, SWT.DEFAULT, SWT.FILL, SWT.FILL, false, false));
+ fChangeButton.setEnabled(false);
+ fChangeButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
changePattern();
}
});
- removeButton= new Button(buttons, SWT.PUSH);
- removeButton.setText(Policy.bind("TextPreferencePage.remove")); //$NON-NLS-1$
- data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
- widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- data.widthHint = Math.max(widthHint, removeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
- removeButton.setLayoutData(data);
- removeButton.setEnabled(false);
- removeButton.addListener(SWT.Selection, new Listener() {
+ fRemoveButton= new Button(buttonsComposite, SWT.PUSH);
+ fRemoveButton.setText(Policy.bind("TextPreferencePage.remove")); //$NON-NLS-1$
+ fRemoveButton.setLayoutData(SWTUtils.createGridData(buttonWidth, SWT.DEFAULT, SWT.FILL, SWT.FILL, false, false));
+ fRemoveButton.setEnabled(false);
+ fRemoveButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
removePattern();
}
});
- fillTable(Team.getAllTypes());
Dialog.applyDialogFont(parent);
- return parent;
+ return composite;
}
protected void performDefaults() {
super.performDefaults();
- IFileTypeInfo[] infos = Team.getDefaultTypes();
- fillTable(infos);
+ initializeItems();
+ if (fTable != null)
+ fTable.getViewer().refresh();
}
/**
@@ -271,110 +173,140 @@ public class TextPreferencePage extends PreferencePage implements IWorkbenchPref
* @return whether it is okay to close the preference page
*/
public boolean performOk() {
- int size = input.size();
- String[] extensions = new String[size];
- int[] types = new int[size];
- int i = 0;
-
- Iterator it = input.iterator();
- while (it.hasNext()) {
- TableEntry entry = (TableEntry)it.next();
- String value = entry.getValue();
- if (value.equals(TEXT)) {
- types[i] = Team.TEXT;
- } else {
- types[i] = Team.BINARY;
- }
- extensions[i] = entry.getExtension();
- i++;
- }
- Team.setAllTypes(extensions, types);
+ final ArrayList extensionsList= new ArrayList();
+ final ArrayList extensionsModesList= new ArrayList();
+
+ final ArrayList namesList= new ArrayList();
+ final ArrayList namesModesList= new ArrayList();
+
+ for (final Iterator iter = fItems.iterator(); iter.hasNext();) {
+ final FileTypeTable.Item item= (FileTypeTable.Item) iter.next();
+
+ if (item instanceof FileTypeTable.Extension) {
+ extensionsList.add(item.name);
+ extensionsModesList.add(new Integer(item.mode));
+ } else if (item instanceof FileTypeTable.Name) {
+ namesList.add(item.name);
+ namesModesList.add(new Integer(item.mode));
+ }
+ }
+
+ final String [] extensions= (String [])extensionsList.toArray(new String [extensionsList.size()]);
+ final String [] names= (String [])namesList.toArray(new String [namesList.size()]);
+
+ final int [] extensionsModes= integerListToIntArray(extensionsModesList);
+ final int [] namesModes= integerListToIntArray(namesModesList);
+
+ Team.setAllTypes(extensions, extensionsModes);
+ KnownModesForNames.setModesforFiles(names, namesModes);
+
TeamUIPlugin.broadcastPropertyChange(new PropertyChangeEvent(this, TeamUI.GLOBAL_FILE_TYPES_CHANGED, null, null));
+
return true;
}
+
+ private static int [] integerListToIntArray(List integers) {
+ final int [] array= new int [integers.size()];
+ int index= 0;
+ for (Iterator iter = integers.iterator(); iter.hasNext();)
+ array[index++]= ((Integer)iter.next()).intValue();
+ return array;
+ }
+
/**
- * Fill the table with the values from the file type registry
+ * Add a new item to the table with the default type of Text.
*/
- private void fillTable(IFileTypeInfo[] infos) {
- this.input = new ArrayList();
- for (int i = 0; i < infos.length; i++) {
- IFileTypeInfo info = infos[i];
- int type = info.getType();
- switch (type) {
- case Team.TEXT:
- input.add(new TableEntry(info.getExtension(), TEXT));
- break;
- case Team.BINARY:
- input.add(new TableEntry(info.getExtension(), BINARY));
- break;
+ void addExtension() {
+ final InputDialog dialog = new InputDialog(getShell(), Policy.bind("TextPreferencePage.enterExtensionShort"), Policy.bind("TextPreferencePage.enterExtensionLong"), null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ dialog.open();
+ if (dialog.getReturnCode() != InputDialog.OK) return;
+
+ final String extension = dialog.getValue().trim().replaceAll("\\*\\.", "");
+ if (extension.equals(""))
+ return;
+
+ // Check if the item already exists
+ final Iterator it = fItems.iterator();
+ while (it.hasNext()) {
+ final FileTypeTable.Item item= (FileTypeTable.Item)it.next();
+ if (item instanceof FileTypeTable.Extension && item.name.equals(extension)) {
+ MessageDialog.openWarning(getShell(), Policy.bind("TextPreferencePage.extensionExistsShort"), Policy.bind("TextPreferencePage.extensionExistsLong")); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
}
}
- viewer.setInput(input);
+ final FileTypeTable.Item item= new FileTypeTable.Extension(extension);
+ fItems.add(item);
+ fTable.getViewer().refresh();
}
+
/**
* Add a new item to the table with the default type of Text.
*/
- private void addPattern() {
- InputDialog dialog = new InputDialog(getShell(), Policy.bind("TextPreferencePage.enterExtensionShort"), Policy.bind("TextPreferencePage.enterExtensionLong"), null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ void addName() {
+ final InputDialog dialog = new InputDialog(getShell(), "New File Type", "Enter a file name:", null, null); //$NON-NLS-1$ //$NON-NLS-2$
dialog.open();
if (dialog.getReturnCode() != InputDialog.OK) return;
- String pattern = dialog.getValue();
- if (pattern.equals("")) return; //$NON-NLS-1$
+
+ final String name = dialog.getValue();
+ if (name.length() == 0 || name.indexOf(" ") >= 0)
+ return; //$NON-NLS-1$
+
// Check if the item already exists
- Iterator it = input.iterator();
+ final Iterator it = fItems.iterator();
while (it.hasNext()) {
- TableEntry entry = (TableEntry)it.next();
- if (entry.getExtension().equals(pattern)) {
+ final FileTypeTable.Item item= (FileTypeTable.Item)it.next();
+ if (item instanceof FileTypeTable.Name && item.name.equals(name)) {
MessageDialog.openWarning(getShell(), Policy.bind("TextPreferencePage.extensionExistsShort"), Policy.bind("TextPreferencePage.extensionExistsLong")); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
}
- input.add(new TableEntry(pattern, TEXT));
- viewer.refresh();
+ final FileTypeTable.Item item= new FileTypeTable.Name(name);
+ fItems.add(item);
+ fTable.getViewer().refresh();
}
+
/**
* Remove the selected items from the table
*/
- private void removePattern() {
- ISelection selection = viewer.getSelection();
- if (selection == null || !(selection instanceof IStructuredSelection)) {
+ void removePattern() {
+ final IStructuredSelection selection = fTable.getSelection();
+ if (selection == null)
return;
+
+ for (final Iterator it = selection.iterator(); it.hasNext(); ) {
+ final FileTypeTable.Item item= (FileTypeTable.Item)it.next();
+ fItems.remove(item);
}
- IStructuredSelection ss = (IStructuredSelection)selection;
- Iterator it = ss.iterator();
- while (it.hasNext()) {
- TableEntry entry = (TableEntry)it.next();
- input.remove(entry);
- }
- viewer.refresh();
+ fTable.getViewer().refresh();
}
/**
* Toggle the selected items' content types
*/
- private void changePattern() {
- ISelection selection = viewer.getSelection();
- if (selection == null || !(selection instanceof IStructuredSelection)) {
+ void changePattern() {
+ final IStructuredSelection selection = fTable.getSelection();
+ if (selection == null)
return;
- }
- IStructuredSelection ss = (IStructuredSelection)selection;
- Iterator it = ss.iterator();
- while (it.hasNext()) {
- TableEntry entry = (TableEntry)it.next();
- String string = entry.getValue();
- if (string.equals(TEXT)) {
- entry.setValue(BINARY);
- } else {
- entry.setValue(TEXT);
- }
- viewer.refresh(entry);
+
+ for (final Iterator it = selection.iterator(); it.hasNext(); ) {
+ final FileTypeTable.Item item= (FileTypeTable.Item)it.next();
+ item.mode= item.mode == Team.TEXT ? Team.BINARY : Team.TEXT;
+ fTable.getViewer().refresh(item);
}
}
+
/**
* The table viewer selection has changed. Update the remove and change button enablement.
*/
- private void handleSelection() {
- boolean empty = viewer.getSelection().isEmpty();
- removeButton.setEnabled(!empty);
- changeButton.setEnabled(!empty);
+ void handleSelection() {
+ final boolean empty = fTable.getSelection().isEmpty();
+ fRemoveButton.setEnabled(!empty);
+ fChangeButton.setEnabled(!empty);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int)
+ */
+ public int convertWidthInCharsToPixels(int chars) {
+ return super.convertWidthInCharsToPixels(chars);
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/HierarchicalModelManager.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/HierarchicalModelManager.java
index eb031e0be..f2d3b0ce0 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/HierarchicalModelManager.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/HierarchicalModelManager.java
@@ -36,7 +36,7 @@ public class HierarchicalModelManager extends SynchronizeModelManager {
*/
protected ISynchronizeModelProvider createModelProvider(String id) {
if(id == null) {
- id = getDefaultProviderId();
+ id = getConfiguration().getProviderID();
}
if (id.endsWith(FlatModelProvider.FlatModelProviderDescriptor.ID)) {
return new FlatModelProvider(getConfiguration(), getSyncInfoSet());
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java
index d05df4a2f..c9d7639ba 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java
@@ -14,7 +14,6 @@ import org.eclipse.compare.internal.INavigatable;
import org.eclipse.compare.structuremergeviewer.*;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.action.*;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
@@ -490,12 +489,8 @@ public abstract class StructuredViewerAdvisor implements IAdaptable {
IWorkbenchPartSite ws = null;
if (workbenchSite instanceof IWorkbenchPartSite)
ws = (IWorkbenchPartSite)workbenchSite;
-// if (ws == null)
-// ws = Utils.findSite();
if (ws != null) {
ws.registerContextMenu(targetID, menuMgr, viewer);
- } else {
- TeamUIPlugin.log(IStatus.ERROR, "Cannot add menu contributions because the site cannot be found: " + targetID, null); //$NON-NLS-1$
}
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java
index 30d32b44f..d843cbbe1 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java
@@ -20,7 +20,8 @@ import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Display;
import org.eclipse.team.core.synchronize.SyncInfoSet;
import org.eclipse.team.internal.core.Assert;
-import org.eclipse.team.internal.ui.*;
+import org.eclipse.team.internal.ui.Policy;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.ui.synchronize.*;
import org.eclipse.ui.IActionBars;
@@ -105,18 +106,6 @@ public abstract class SynchronizeModelManager extends SynchronizePageActionGroup
return modelProvider;
}
- protected String getDefaultProviderId() {
- String defaultLayout = TeamUIPlugin.getPlugin().getPreferenceStore().getString(IPreferenceIds.SYNCVIEW_DEFAULT_LAYOUT);
- if (defaultLayout.equals(IPreferenceIds.TREE_LAYOUT)) {
- return HierarchicalModelProvider.HierarchicalModelProviderDescriptor.ID;
- }
- if (defaultLayout.equals(IPreferenceIds.FLAT_LAYOUT)) {
- return FlatModelProvider.FlatModelProviderDescriptor.ID;
- }
- // Return compressed folder is the others were not a match
- return CompressedFoldersModelProvider.CompressedFolderModelProviderDescriptor.ID;
- }
-
/**
* Return the id of the selected provider. By default, this is the
* id of the active provider. However, subclasses that use a composite
@@ -129,7 +118,7 @@ public abstract class SynchronizeModelManager extends SynchronizePageActionGroup
if (provider != null) {
return provider.getDescriptor().getId();
}
- return getDefaultProviderId();
+ return configuration.getProviderID();
}
/**
@@ -220,7 +209,7 @@ public abstract class SynchronizeModelManager extends SynchronizePageActionGroup
// The input may of been set already. In that case, don't change it and
// simply assign it to the view.
if(modelProvider == null) {
- String defaultProviderId = getDefaultProviderId(); /* use providers prefered */
+ String defaultProviderId = configuration.getProviderID(); /* use providers prefered */
IDialogSettings pageSettings = configuration.getSite().getPageSettings();
if(pageSettings != null && pageSettings.get(P_LAST_PROVIDER) != null) {
defaultProviderId = pageSettings.get(P_LAST_PROVIDER);
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java
index cc25ba381..2a44b8bf6 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java
@@ -17,19 +17,13 @@ import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.ListenerList;
-import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.util.*;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.team.core.synchronize.SyncInfoSet;
+import org.eclipse.team.internal.ui.IPreferenceIds;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.synchronize.actions.DefaultSynchronizePageActions;
-import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;
-import org.eclipse.team.ui.synchronize.ISynchronizePage;
-import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
-import org.eclipse.team.ui.synchronize.ISynchronizePageSite;
-import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
-import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup;
+import org.eclipse.team.ui.synchronize.*;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.ActionContext;
@@ -545,4 +539,28 @@ public class SynchronizePageConfiguration extends SynchronizePageActionGroup imp
public IRunnableContext getRunnableContext() {
return context;
}
+
+ public String getProviderID() {
+ String layout= (String)getProperty(P_LAYOUT);
+ if (layout == null) {
+ return getDefaultProviderID();
+ }
+ if (FLAT_LAYOUT.equals(layout))
+ return FlatModelProvider.FlatModelProviderDescriptor.ID;
+ if (TREE_LAYOUT.equals(layout))
+ return HierarchicalModelProvider.HierarchicalModelProviderDescriptor.ID;
+ return CompressedFoldersModelProvider.CompressedFolderModelProviderDescriptor.ID;
+ }
+
+ private String getDefaultProviderID() {
+ String defaultLayout = TeamUIPlugin.getPlugin().getPreferenceStore().getString(IPreferenceIds.SYNCVIEW_DEFAULT_LAYOUT);
+ if (defaultLayout.equals(IPreferenceIds.TREE_LAYOUT)) {
+ return HierarchicalModelProvider.HierarchicalModelProviderDescriptor.ID;
+ }
+ if (defaultLayout.equals(IPreferenceIds.FLAT_LAYOUT)) {
+ return FlatModelProvider.FlatModelProviderDescriptor.ID;
+ }
+ // Return compressed folder is the others were not a match
+ return CompressedFoldersModelProvider.CompressedFolderModelProviderDescriptor.ID;
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveFromViewAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveFromViewAction.java
index 6abdfc091..f84053121 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveFromViewAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveFromViewAction.java
@@ -36,7 +36,7 @@ import org.eclipse.team.ui.synchronize.SynchronizeModelOperation;
*/
public class RemoveFromViewAction extends SynchronizeModelAction {
- protected RemoveFromViewAction(ISynchronizePageConfiguration configuration) {
+ public RemoveFromViewAction(ISynchronizePageConfiguration configuration) {
super(null, configuration);
Utils.initAction(this, "action.removeFromView.", Policy.getBundle()); //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageConfiguration.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageConfiguration.java
index cb7f868e2..57f6d5a50 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageConfiguration.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageConfiguration.java
@@ -32,6 +32,9 @@ import org.eclipse.ui.IWorkbenchActionConstants;
*/
public interface ISynchronizePageConfiguration {
+
+ public static final String P_LAYOUT = TeamUIPlugin.ID + "P_LAYOUT"; //$NON-NLS-1$
+
/**
* Property constant for the <code>SyncInfoSet</code> that is being
* displayed by the page.
@@ -106,6 +109,11 @@ public interface ISynchronizePageConfiguration {
*/
public static final String P_SUPPORTED_MODES = TeamUIPlugin.ID + ".P_SUPPORTED_MODES"; //$NON-NLS-1$
+
+ public static final String FLAT_LAYOUT= "flat";
+ public static final String TREE_LAYOUT= "tree";
+ public static final String COMPRESSED_LAYOUT= "compressed";
+
/**
* The id of the synchronize group the determines where the synchronize
* actions appear.
@@ -204,7 +212,7 @@ public interface ISynchronizePageConfiguration {
public final static int BOTH_MODE = 0x4;
public final static int CONFLICTING_MODE = 0x8;
public final static int ALL_MODES = INCOMING_MODE | OUTGOING_MODE | CONFLICTING_MODE | BOTH_MODE;
-
+
/**
* Return the particpant associated with the page to shich this configuration
* is associated.
@@ -387,4 +395,6 @@ public interface ISynchronizePageConfiguration {
* @return a runnable context (or <code>null</code>)
*/
IRunnableContext getRunnableContext();
+
+ public String getProviderID();
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPagePane.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPagePane.java
new file mode 100644
index 000000000..f6de2e4b5
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPagePane.java
@@ -0,0 +1,230 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.team.ui.synchronize;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareViewerPane;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.team.internal.ui.*;
+import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration;
+import org.eclipse.ui.*;
+import org.eclipse.ui.part.IPageBookViewPage;
+
+/**
+ * Standalone presentation of a participant page within a view pane. This
+ * allows showing a participant page with it's toolbar in dialogs and embedded
+ * in views and editors.
+ *
+ * @since 3.1
+ */
+public final class ParticipantPagePane {
+
+ private ISynchronizeParticipant participant;
+ private ISynchronizePageConfiguration pageConfiguration;
+ private Image titleImage;
+ private Shell shell;
+ private boolean isModal;
+
+ // SWT controls
+ private CompareViewerPane fEditionPane;
+ private Viewer viewer;
+
+ private IActionBars actionBars;
+
+ /*
+ * Page site that allows hosting the participant page in a dialog.
+ */
+ class CompareViewerPaneSite implements ISynchronizePageSite {
+ ISelectionProvider selectionProvider;
+ public IWorkbenchPage getPage() {
+ return null;
+ }
+ public ISelectionProvider getSelectionProvider() {
+ if (selectionProvider != null)
+ return selectionProvider;
+ return viewer;
+ }
+ public Shell getShell() {
+ return shell;
+ }
+ public IWorkbenchWindow getWorkbenchWindow() {
+ return null;
+ }
+ public void setSelectionProvider(ISelectionProvider provider) {
+ selectionProvider = provider;
+ }
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+ public IWorkbenchSite getWorkbenchSite() {
+ return null;
+ }
+ public IWorkbenchPart getPart() {
+ return null;
+ }
+ public IKeyBindingService getKeyBindingService() {
+ return null;
+ }
+ public void setFocus() {
+ }
+ public IDialogSettings getPageSettings() {
+ return null;
+ }
+ public IActionBars getActionBars() {
+ return ParticipantPagePane.this.getActionBars();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#isModal()
+ */
+ public boolean isModal() {
+ return isModal;
+ }
+ }
+
+ /**
+ * Creates a part for the provided participant. The page configuration is used when creating the participant page and the resulting
+ * compare/merge panes will be configured with the provided compare configuration.
+ * <p>
+ * For example, clients can decide if the user can edit the compare panes by calling {@link CompareConfiguration#setLeftEditable(boolean)}
+ * or {@link CompareConfiguration#setRightEditable(boolean)}.
+ * </p>
+ * @param shell the parent shell for this part
+ * @param cc the compare configuration that will be used to create the compare panes
+ * @param pageConfiguration the configuration that will be provided to the participant prior to creating the page
+ * @param participant the participant whose page will be displayed in this part
+ */
+ public ParticipantPagePane(Shell shell, boolean isModal, ISynchronizePageConfiguration pageConfiguration, ISynchronizeParticipant participant) {
+ this.isModal = isModal;
+ this.shell = shell;
+ this.participant = participant;
+ this.pageConfiguration = pageConfiguration;
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.SaveablePartAdapter#dispose()
+ */
+ public void dispose() {
+ if(titleImage != null) {
+ titleImage.dispose();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPart#getTitleImage()
+ */
+ public Image getTitleImage() {
+ if(titleImage == null) {
+ titleImage = participant.getImageDescriptor().createImage();
+ }
+ return titleImage;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPart#getTitle()
+ */
+ public String getTitle() {
+ return participant.getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ public Control createPartControl(Composite parent) {
+ Composite top = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.verticalSpacing = 0;
+ top.setLayout(layout);
+
+ shell = parent.getShell();
+
+ fEditionPane = new CompareViewerPane(top, SWT.BORDER | SWT.FLAT);
+ fEditionPane.setText(Policy.bind("ParticipantPageSaveablePart.0")); //$NON-NLS-1$
+
+ fEditionPane.setLayoutData(SWTUtils.createHVFillGridData());
+
+ IPageBookViewPage page = participant.createPage(pageConfiguration);
+ ((SynchronizePageConfiguration)pageConfiguration).setSite(new CompareViewerPaneSite());
+ ToolBarManager tbm = CompareViewerPane.getToolBarManager(fEditionPane);
+ createActionBars(tbm);
+ try {
+ ((ISynchronizePage)page).init(pageConfiguration.getSite());
+ } catch (PartInitException e1) {
+ TeamUIPlugin.log(IStatus.ERROR, "Error creating Synchronize Page", e1);
+ }
+
+ page.createControl(fEditionPane);
+ page.setActionBars(getActionBars());
+ fEditionPane.setContent(page.getControl());
+ tbm.update(true);
+
+ return top;
+ }
+
+ private void createActionBars(final IToolBarManager toolbar) {
+ if (actionBars == null) {
+ actionBars = new IActionBars() {
+ public void clearGlobalActionHandlers() {
+ }
+ public IAction getGlobalActionHandler(String actionId) {
+ return null;
+ }
+ public IMenuManager getMenuManager() {
+ return null;
+ }
+ public IStatusLineManager getStatusLineManager() {
+ return null;
+ }
+ public IToolBarManager getToolBarManager() {
+ return toolbar;
+ }
+ public void setGlobalActionHandler(String actionId, IAction action) {
+ }
+
+ public void updateActionBars() {
+ }
+ };
+ }
+ }
+
+ private IActionBars getActionBars() {
+ return actionBars;
+ }
+
+ /**
+ * Return the synchronize page configuration for this part
+ *
+ * @return Returns the pageConfiguration.
+ */
+ public ISynchronizePageConfiguration getPageConfiguration() {
+ return pageConfiguration;
+ }
+
+ /**
+ * Return the Synchronize participant for this part
+ *
+ * @return Returns the participant.
+ */
+ public ISynchronizeParticipant getParticipant() {
+ return participant;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java
index 2b316cb26..9ebe0630b 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java
@@ -93,7 +93,7 @@ public abstract class SynchronizeModelAction extends BaseSelectionListenerAction
}
}
try {
- getSubscriberOperation(configuration, getFilteredDiffElements()).run();
+ runOperation();
} catch (InvocationTargetException e) {
handle(e);
} catch (InterruptedException e) {
@@ -101,6 +101,19 @@ public abstract class SynchronizeModelAction extends BaseSelectionListenerAction
}
}
+ /**
+ * Create aand run the operation for this action. By default, the operation is created
+ * by calling <code>getSubscriberOperation</code> and then run. Subclasses may
+ * override.
+ *
+ * @throws InvocationTargetException
+ * @throws InterruptedException
+ * @since 3.1
+ */
+ protected void runOperation() throws InvocationTargetException, InterruptedException {
+ getSubscriberOperation(configuration, getFilteredDiffElements()).run();
+ }
+
/**
* Return whether dirty editor should be saved before this action is run.
* Default is <code>true</code>.

Back to the top