From 70f4a9ec781197afff1d9dc3b0df62d0db88d1b1 Mon Sep 17 00:00:00 2001 From: Michael Valenta Date: Mon, 25 Nov 2002 19:55:21 +0000 Subject: *** empty log message *** --- .../eclipse/team/internal/ccvs/ui/DialogArea.java | 158 ++++++++++++ .../team/internal/ccvs/ui/ListSelectionArea.java | 187 ++++++++++++++ .../internal/ccvs/ui/ProjectSelectionDialog.java | 223 ++-------------- .../internal/ccvs/ui/WorkingSetSelectionArea.java | 285 +++++++++++++++++++++ .../team/internal/ccvs/ui/messages.properties | 6 +- .../ccvs/ui/model/RemoteProjectsElement.java | 7 + .../ui/repo/RefreshRemoteProjectSelectionPage.java | 139 ++++++++++ .../ccvs/ui/repo/RefreshRemoteProjectWizard.java | 106 ++++++++ .../internal/ccvs/ui/repo/RefreshTagsAction.java | 62 ++--- .../internal/ccvs/ui/repo/RemoteProjectsView.java | 9 + .../team/internal/ccvs/ui/repo/RemoteTagsView.java | 8 + .../team/internal/ccvs/ui/repo/RemoteViewPart.java | 2 + 12 files changed, 954 insertions(+), 238 deletions(-) create mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/DialogArea.java create mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ListSelectionArea.java create mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkingSetSelectionArea.java create mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectSelectionPage.java create mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/DialogArea.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/DialogArea.java new file mode 100644 index 000000000..c7dc119d2 --- /dev/null +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/DialogArea.java @@ -0,0 +1,158 @@ +/******************************************************************************* + * Copyright (c) 2002 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM - Initial implementation + ******************************************************************************/ +package org.eclipse.team.internal.ccvs.ui; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontMetrics; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + +/** + * This class provides facilities to allow common widget groupings to be shared + * by mulitple dialogs or wizards. + */ +public abstract class DialogArea { + + protected static final int LABEL_WIDTH_HINT = 400; + + protected Dialog parentDialog; + protected FontMetrics fontMetrics; + protected IDialogSettings settings; + + protected List listeners; + + public DialogArea(Dialog parentDialog, IDialogSettings settings) { + this.listeners = new ArrayList(); + this.parentDialog = parentDialog; + this.settings = settings; + } + + /** + * Listener for property change events. The only event of interest is for + * property SELECTED_WORKING_SET which contains the selected working set or + * null if none is selected. + * + * @param listener + */ + public void addPropertyChangeListener(IPropertyChangeListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + /** + * Remove the provided listener from the receiver. + * + * @param listener + */ + public void removePropertyChangeListener(IPropertyChangeListener listener) { + listeners.remove(listener); + } + + /** + * Code copied from org.eclipse.jface.dialogs.Dialog to obtain + * a FontMetrics. + * + * @param control a control from which to obtain the current font + * + * @see org.eclipse.jface.dialogs.Dialog + */ + protected void initializeDialogUnits(Control control) { + // Compute and store a font metric + GC gc = new GC(control); + gc.setFont(control.getFont()); + fontMetrics = gc.getFontMetrics(); + gc.dispose(); + } + + public abstract Control createArea(Composite parent); + + /** + * Returns the shell. + * @return Shell + */ + protected Shell getShell() { + return parentDialog.getShell(); + } + + protected Button createCheckbox(Composite parent, String label, int span) { + Button button = new Button(parent, SWT.CHECK | SWT.LEFT); + button.setText(label); + button.setFont(parent.getFont()); + GridData data = new GridData(); + data.horizontalSpan = span; + button.setLayoutData(data); + return button; + } + + protected Button createButton(Composite parent, String label) { + Button button = new Button(parent, SWT.PUSH); + button.setText(label); + // we need to explicitly set the font to the parent's font for dialogs + button.setFont(parent.getFont()); + GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + data.heightHint = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_HEIGHT); + int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); + data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); + button.setLayoutData(data);; + return button; + } + + protected Label createWrappingLabel(Composite parent, String text, int horizontalSpan) { + Label label = new Label(parent, SWT.LEFT | SWT.WRAP); + label.setText(text); + label.setFont(parent.getFont()); + GridData data = new GridData(); + data.horizontalSpan = horizontalSpan; + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + data.widthHint = LABEL_WIDTH_HINT; + label.setLayoutData(data); + return label; + } + + /** + * Creates composite control and sets the default layout data. + * + * @param parent the parent of the new composite + * @param numColumns the number of columns for the new composite + * @return the newly-created coposite + */ + protected Composite createComposite(Composite parent, int numColumns) { + Composite composite = new Composite(parent, SWT.NULL); + Font font = parent.getFont(); + composite.setFont(parent.getFont()); + + // GridLayout + GridLayout layout = new GridLayout(); + layout.numColumns = numColumns; + composite.setLayout(layout); + + // GridData + GridData data = new GridData(); + data.verticalAlignment = GridData.FILL; + data.horizontalAlignment = GridData.FILL; + composite.setLayoutData(data); + return composite; + } +} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ListSelectionArea.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ListSelectionArea.java new file mode 100644 index 000000000..869797a3a --- /dev/null +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ListSelectionArea.java @@ -0,0 +1,187 @@ +/******************************************************************************* + * Copyright (c) 2002 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM - Initial implementation + ******************************************************************************/ +package org.eclipse.team.internal.ccvs.ui; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +/** + * Reusable area that provides a list to select from and a select all and + * deselect all button. + */ +public class ListSelectionArea extends DialogArea { + private Object inputElement; + private IStructuredContentProvider contentProvider; + private ILabelProvider labelProvider; + private String message; + private List initialSelections; + + // the visual selection widget group + private CheckboxTableViewer listViewer; + + // sizing constants + private final static int SIZING_SELECTION_WIDGET_HEIGHT = 250; + private final static int SIZING_SELECTION_WIDGET_WIDTH = 300; + + /** + * Constructor for ListSelectionArea. + * @param parentDialog + * @param settings + */ + public ListSelectionArea( + Dialog parentDialog, + Object input, + IStructuredContentProvider contentProvider, + ILabelProvider labelProvider, + String message) { + super(parentDialog, null); + this.inputElement = input; + this.contentProvider = contentProvider; + this.labelProvider = labelProvider; + this.message = message; + this.initialSelections = new ArrayList(); + } + + /** + * @see org.eclipse.team.internal.ccvs.ui.DialogArea#createArea(org.eclipse.swt.widgets.Composite) + */ + public Control createArea(Composite parent) { + Composite composite = createComposite(parent, 1); + initializeDialogUnits(composite); + + if (message != null) + createWrappingLabel(composite, message, 1); + + listViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER); + GridData data = new GridData(GridData.FILL_BOTH); + data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT; + data.widthHint = SIZING_SELECTION_WIDGET_WIDTH; + listViewer.getTable().setLayoutData(data); + + listViewer.setLabelProvider(labelProvider); + listViewer.setContentProvider(contentProvider); + listViewer.getControl().setFont(composite.getFont()); + + addSelectionButtons(composite); + + initializeViewer(); + + // initialize page + if (!getInitialElementSelections().isEmpty()) + checkInitialSelections(); + + return composite; + } + + /** + * Initializes this dialog's viewer after it has been laid out. + */ + private void initializeViewer() { + listViewer.setInput(inputElement); + } + + /** + * Visually checks the previously-specified elements in this dialog's list + * viewer. + */ + private void checkInitialSelections() { + Iterator itemsToCheck = getInitialElementSelections().iterator(); + + while (itemsToCheck.hasNext()) + listViewer.setChecked(itemsToCheck.next(),true); + } + + /** + * Add the selection and deselection buttons to the dialog. + * @param composite org.eclipse.swt.widgets.Composite + */ + private void addSelectionButtons(Composite composite) { + Composite buttonComposite = new Composite(composite, SWT.RIGHT); + buttonComposite.setFont(composite.getFont()); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + buttonComposite.setLayout(layout); + GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL); + data.grabExcessHorizontalSpace = true; + composite.setData(data); + + Button selectButton = createButton(buttonComposite, Policy.bind("ListSelectionArea.selectAll")); + + SelectionListener listener = new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + listViewer.setAllChecked(true); + } + }; + selectButton.addSelectionListener(listener); + + + Button deselectButton = createButton(buttonComposite, Policy.bind("ListSelectionArea.deselectAll")); + + listener = new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + listViewer.setAllChecked(false); + + } + }; + deselectButton.addSelectionListener(listener); + } + + /** + * Returns the list of initial element selections. + * @return List + */ + protected List getInitialElementSelections(){ + return initialSelections; + } + + /** + * Sets the initial selection in this selection dialog to the given elements. + * + * @param selectedElements the array of elements to select + */ + public void setInitialSelections(Object[] selectedElements) { + initialSelections = new ArrayList(selectedElements.length); + for (int i = 0; i < selectedElements.length; i++) + initialSelections.add(selectedElements[i]); + } + + /** + * Sets the initial selection in this selection dialog to the given elements. + * + * @param selectedElements the List of elements to select + */ + public void setInitialElementSelections(List selectedElements) { + initialSelections = selectedElements; + } + /** + * Returns the listViewer. + * @return CheckboxTableViewer + */ + public CheckboxTableViewer getViewer() { + return listViewer; + } + +} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ProjectSelectionDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ProjectSelectionDialog.java index 05e68351d..bb52690f5 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ProjectSelectionDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ProjectSelectionDialog.java @@ -13,27 +13,15 @@ package org.eclipse.team.internal.ccvs.ui; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.IWorkingSetManager; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; import org.eclipse.ui.dialogs.ListSelectionDialog; import org.eclipse.ui.help.WorkbenchHelp; @@ -41,49 +29,13 @@ import org.eclipse.ui.help.WorkbenchHelp; * */ public class ProjectSelectionDialog extends ListSelectionDialog { - static final int SELECT_ID = IDialogConstants.CLIENT_ID + 1; - private Button workingSetButton; - private Combo mruList; - private Button selectButton; - private IWorkingSet workingSet; + IWorkingSet workingSet; // dialogs settings that are persistent between workbench sessions private IDialogSettings settings; - private static final String USE_WORKING_SET = "UseWorkingSet"; //$NON-NLS-1$ - private static final String SELECTED_WORKING_SET = "SelectedWorkingSet"; //$NON-NLS-1$ - - /* - * Used to update the mru list box when working sets are - * renamed in the working set selection dialog. - */ - private IPropertyChangeListener workingSetChangeListener = new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - String property = event.getProperty(); - Object newValue = event.getNewValue(); - - if (IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE.equals(property) && - newValue instanceof IWorkingSet) { - String newName = ((IWorkingSet) newValue).getName(); - int count = mruList.getItemCount(); - for (int i = 0; i < count; i++) { - String item = mruList.getItem(i); - IWorkingSet workingSet = (IWorkingSet) mruList.getData(item); - if (workingSet == newValue) { - boolean isTopItem = (mruList.getData(mruList.getText()) == workingSet); - mruList.remove(i); - mruList.add(newName, i); - mruList.setData(newName, workingSet); - if (isTopItem) { - mruList.setText(newName); - } - break; - } - } - } - } - }; - + private WorkingSetSelectionArea workingSetArea; + /** * Creates a filter selection dialog. * @@ -102,22 +54,8 @@ public class ProjectSelectionDialog extends ListSelectionDialog { if (settings == null) { this.settings = workbenchSettings.addNewSection("ProjectSelectionDialog");//$NON-NLS-1$ } - if (settings.getBoolean(USE_WORKING_SET)) { - setWorkingSet(PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(settings.get(SELECTED_WORKING_SET))); - } - - } - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected void buttonPressed(int buttonId) { - if (SELECT_ID == buttonId) { - handleWorkingSetSelection(); - } - else { - super.buttonPressed(buttonId); - } } + /** * Overrides method in Dialog * @@ -125,54 +63,19 @@ public class ProjectSelectionDialog extends ListSelectionDialog { */ protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); - Composite group = new Composite(composite, SWT.NONE); - GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); - group.setLayoutData(data); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - group.setLayout(layout); - - workingSetButton = new Button(group, SWT.CHECK); - workingSetButton.setText(Policy.bind("ResourceSelectionDialog.workingSet")); //$NON-NLS-1$ - workingSetButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleWorkingSetButtonSelection(); - } - }); - data = new GridData(); - data.horizontalSpan = 2; - workingSetButton.setLayoutData(data); - - group = new Composite(group, SWT.NONE); - data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); - group.setLayoutData(data); - layout = new GridLayout(); - layout.marginHeight = 0; - group.setLayout(layout); - - mruList = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY); - data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); - mruList.setLayoutData(data); - mruList.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleMruSelection(); + + workingSetArea = new WorkingSetSelectionArea(this, settings); + setWorkingSet(workingSet); + workingSetArea.addPropertyChangeListener(new IPropertyChangeListener() { + public void propertyChange(PropertyChangeEvent event) { + workingSet = (IWorkingSet)event.getNewValue(); + handleWorkingSetChange(); } }); - selectButton = createButton(group, SELECT_ID, Policy.bind("ResourceSelectionDialog.workingSetOther"), false); //$NON-NLS-1$ - - initializeMru(); - initializeWorkingSet(); + workingSetArea.createArea(composite); return composite; } - /** - * Method handleMruSelection. - */ - private void handleMruSelection() { - workingSet = (IWorkingSet) mruList.getData(mruList.getText()); - handleWorkingSetChange(); - } - /* (non-Javadoc) * Method declared on Window. */ @@ -188,88 +91,6 @@ public class ProjectSelectionDialog extends ListSelectionDialog { public IWorkingSet getWorkingSet() { return workingSet; } - /** - * Opens the working set selection dialog if the "Other..." item - * is selected in the most recently used working set list. - */ - private void handleWorkingSetSelection() { - IWorkingSetSelectionDialog dialog = PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSetSelectionDialog(getShell(), false); - IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); - IWorkingSet workingSet = workingSetManager.getWorkingSet(mruList.getText()); - - if (workingSet != null) { - dialog.setSelection(new IWorkingSet[]{workingSet}); - } - // add a change listener to detect a working set name change - workingSetManager.addPropertyChangeListener(workingSetChangeListener); - if (dialog.open() == Window.OK) { - IWorkingSet[] result = dialog.getSelection(); - if (result != null && result.length > 0) { - workingSet = result[0]; - String workingSetName = workingSet.getName(); - if (mruList.indexOf(workingSetName) != -1) { - mruList.remove(workingSetName); - } - mruList.add(workingSetName, 0); - mruList.setText(workingSetName); - mruList.setData(workingSetName, workingSet); - handleMruSelection(); - } - else { - workingSet = null; - } - // remove deleted working sets from the mru list box - String[] mruNames = mruList.getItems(); - for (int i = 0; i < mruNames.length; i++) { - if (workingSetManager.getWorkingSet(mruNames[i]) == null) { - mruList.remove(mruNames[i]); - } - } - } - workingSetManager.removePropertyChangeListener(workingSetChangeListener); - } - /** - * Sets the enabled state of the most recently used working set list - * based on the checked state of the working set check box. - */ - private void handleWorkingSetButtonSelection() { - boolean useWorkingSet = workingSetButton.getSelection(); - mruList.setEnabled(useWorkingSet); - selectButton.setEnabled(useWorkingSet); - if (useWorkingSet && mruList.getSelectionIndex() >= 0) { - handleMruSelection(); - } - } - - /** - * Populates the most recently used working set list with MRU items from - * the working set manager as well as adds an item to enable selection of - * a working set not in the MRU list. - */ - private void initializeMru() { - IWorkingSet[] workingSets = PlatformUI.getWorkbench().getWorkingSetManager().getRecentWorkingSets(); - - for (int i = 0; i < workingSets.length; i++) { - String workingSetName = workingSets[i].getName(); - mruList.add(workingSetName); - mruList.setData(workingSetName, workingSets[i]); - } - if (workingSets.length > 0) { - mruList.setText(workingSets[0].getName()); - } - } - - /** - * Initializes the state of the working set part of the dialog. - */ - private void initializeWorkingSet() { - workingSetButton.setSelection(workingSet != null); - handleWorkingSetButtonSelection(); - if (workingSet != null && mruList.indexOf(workingSet.getName()) != -1) { - mruList.setText(workingSet.getName()); - } - handleWorkingSetChange(); - } private void handleWorkingSetChange() { if (workingSet != null) { @@ -294,19 +115,9 @@ public class ProjectSelectionDialog extends ListSelectionDialog { * @see org.eclipse.jface.dialogs.Dialog#okPressed() */ protected void okPressed() { - boolean useWorkingSet = workingSetButton.getSelection(); - settings.put(USE_WORKING_SET, useWorkingSet); - if (useWorkingSet) { - String selectedWorkingSet = mruList.getText(); - workingSet = (IWorkingSet) mruList.getData(selectedWorkingSet); - // Add the selected working set to the MRU list - if (workingSet != null) { - PlatformUI.getWorkbench().getWorkingSetManager().addRecentWorkingSet(workingSet); - } - settings.put(SELECTED_WORKING_SET, selectedWorkingSet); - } - else { - workingSet = null; + workingSet = workingSetArea.getWorkingSet(); + if (workingSet != null) { + workingSetArea.useSelectedWorkingSet(); } super.okPressed(); } @@ -322,8 +133,8 @@ public class ProjectSelectionDialog extends ListSelectionDialog { public void setWorkingSet(IWorkingSet workingSet) { this.workingSet = workingSet; - if (workingSetButton != null && mruList != null) { - initializeWorkingSet(); + if (workingSetArea != null) { + workingSetArea.setWorkingSet(workingSet); } } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkingSetSelectionArea.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkingSetSelectionArea.java new file mode 100644 index 000000000..8a1df94c6 --- /dev/null +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkingSetSelectionArea.java @@ -0,0 +1,285 @@ +/******************************************************************************* + * Copyright (c) 2002 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM - Initial implementation + ******************************************************************************/ +package org.eclipse.team.internal.ccvs.ui; + +import java.util.Iterator; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkingSet; +import org.eclipse.ui.IWorkingSetManager; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; + +/** + * @author Administrator + * + * To change this generated comment edit the template variable "typecomment": + * Window>Preferences>Java>Templates. + * To enable and disable the creation of type comments go to + * Window>Preferences>Java>Code Generation. + */ +public class WorkingSetSelectionArea extends DialogArea { + + private Button workingSetButton; + private Combo mruList; + private Button selectButton; + private IWorkingSet workingSet, oldWorkingSet; + + private static final String USE_WORKING_SET = "UseWorkingSet"; //$NON-NLS-1$ + public static final String SELECTED_WORKING_SET = "SelectedWorkingSet"; //$NON-NLS-1$ + + /* + * Used to update the mru list box when working sets are + * renamed in the working set selection dialog. + */ + private IPropertyChangeListener workingSetChangeListener = new IPropertyChangeListener() { + public void propertyChange(PropertyChangeEvent event) { + String property = event.getProperty(); + Object newValue = event.getNewValue(); + + if (IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE.equals(property) && + newValue instanceof IWorkingSet) { + String newName = ((IWorkingSet) newValue).getName(); + int count = mruList.getItemCount(); + for (int i = 0; i < count; i++) { + String item = mruList.getItem(i); + IWorkingSet workingSet = (IWorkingSet) mruList.getData(item); + if (workingSet == newValue) { + boolean isTopItem = (mruList.getData(mruList.getText()) == workingSet); + mruList.remove(i); + mruList.add(newName, i); + mruList.setData(newName, workingSet); + if (isTopItem) { + mruList.setText(newName); + } + break; + } + } + } + } + }; + + public WorkingSetSelectionArea(Dialog parentDialog) { + super(parentDialog, null); + } + + public WorkingSetSelectionArea(Dialog parentDialog, IDialogSettings settings) { + super(parentDialog, settings); + } + + /** + * Overrides method in Dialog + * + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite) + */ + public Control createArea(Composite parent) { + Composite composite = createComposite(parent, 2); + initializeDialogUnits(composite); + GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); + composite.setLayoutData(data); + GridLayout layout = new GridLayout(); + layout.marginWidth = 0; + layout.numColumns = 2; + composite.setLayout(layout); + + // Create the checkbox to enable/disable working set use + workingSetButton = createCheckbox(composite, Policy.bind("WorkingSetSelectionArea.workingSet"), 2); //$NON-NLS-1$ + workingSetButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + handleWorkingSetButtonSelection(); + } + }); + if (settings != null) + workingSetButton.setSelection(settings.getBoolean(USE_WORKING_SET)); + + // Create the combo/button which allows working set selection + mruList = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY); + data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); + mruList.setLayoutData(data); + mruList.setFont(composite.getFont()); + mruList.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + handleMruSelection(); + } + }); + selectButton = createButton(composite, Policy.bind("WorkingSetSelectionArea.workingSetOther")); //$NON-NLS-1$ + selectButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + handleWorkingSetSelection(); + } + }); + + initializeMru(); + initializeWorkingSet(); + return composite; + } + + /** + * Method handleMruSelection. + */ + private void handleMruSelection() { + String selectedWorkingSet = mruList.getText(); + oldWorkingSet = workingSet; + workingSet = (IWorkingSet) mruList.getData(selectedWorkingSet); + if (settings != null) + settings.put(SELECTED_WORKING_SET, selectedWorkingSet); + handleWorkingSetChange(); + } + + /** + * Opens the working set selection dialog if the "Other..." item + * is selected in the most recently used working set list. + */ + private void handleWorkingSetSelection() { + IWorkingSetSelectionDialog dialog = PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSetSelectionDialog(getShell(), false); + IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); + IWorkingSet workingSet = workingSetManager.getWorkingSet(mruList.getText()); + + if (workingSet != null) { + dialog.setSelection(new IWorkingSet[]{workingSet}); + } + // add a change listener to detect a working set name change + workingSetManager.addPropertyChangeListener(workingSetChangeListener); + if (dialog.open() == Window.OK) { + IWorkingSet[] result = dialog.getSelection(); + if (result != null && result.length > 0) { + workingSet = result[0]; + String workingSetName = workingSet.getName(); + if (mruList.indexOf(workingSetName) != -1) { + mruList.remove(workingSetName); + } + mruList.add(workingSetName, 0); + mruList.setText(workingSetName); + mruList.setData(workingSetName, workingSet); + handleMruSelection(); + } + else { + workingSet = null; + } + // remove deleted working sets from the mru list box + String[] mruNames = mruList.getItems(); + for (int i = 0; i < mruNames.length; i++) { + if (workingSetManager.getWorkingSet(mruNames[i]) == null) { + mruList.remove(mruNames[i]); + } + } + } + workingSetManager.removePropertyChangeListener(workingSetChangeListener); + } + + /** + * Sets the enabled state of the most recently used working set list + * based on the checked state of the working set check box. + */ + private void handleWorkingSetButtonSelection() { + boolean useWorkingSet = workingSetButton.getSelection(); + if (settings != null) + settings.put(USE_WORKING_SET, useWorkingSet); + mruList.setEnabled(useWorkingSet); + selectButton.setEnabled(useWorkingSet); + if (useWorkingSet && mruList.getSelectionIndex() >= 0) { + handleMruSelection(); + } + } + + private void handleWorkingSetChange() { + PropertyChangeEvent event = new PropertyChangeEvent(this, SELECTED_WORKING_SET, oldWorkingSet, workingSet); + for (Iterator iter = listeners.iterator(); iter.hasNext();) { + IPropertyChangeListener listener = (IPropertyChangeListener) iter.next(); + listener.propertyChange(event); + } + } + + /** + * Populates the most recently used working set list with MRU items from + * the working set manager as well as adds an item to enable selection of + * a working set not in the MRU list. + */ + private void initializeMru() { + IWorkingSet[] workingSets = PlatformUI.getWorkbench().getWorkingSetManager().getRecentWorkingSets(); + + for (int i = 0; i < workingSets.length; i++) { + String workingSetName = workingSets[i].getName(); + mruList.add(workingSetName); + mruList.setData(workingSetName, workingSets[i]); + } + if (workingSets.length > 0) { + mruList.setText(workingSets[0].getName()); + } + } + + /** + * Initializes the state of the working set part of the dialog. + */ + private void initializeWorkingSet() { + if (workingSet == null && settings != null && settings.getBoolean(USE_WORKING_SET)) { + setWorkingSet(PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(settings.get(SELECTED_WORKING_SET))); + } + workingSetButton.setSelection(workingSet != null); + handleWorkingSetButtonSelection(); + if (workingSet != null && mruList.indexOf(workingSet.getName()) != -1) { + mruList.setText(workingSet.getName()); + } + handleWorkingSetChange(); + } + + /** + * Returns the selected working set or null if none is selected. + * + * @return the selected working set or null if none is selected. + */ + public IWorkingSet getWorkingSet() { + return workingSet; + } + + /** + * Indicate that the selected working set is actually being used so it can + * be added to the "most recently used" list. + */ + public void useSelectedWorkingSet() { + // Add the selected working set to the MRU list before returning it + if (workingSet != null) { + PlatformUI.getWorkbench().getWorkingSetManager().addRecentWorkingSet(workingSet); + } + } + + /** + * Sets the working set that should be selected in the most recently + * used working set list. + * + * @param workingSet the working set that should be selected. + * has to exist in the list returned by + * org.eclipse.ui.IWorkingSetManager#getRecentWorkingSets(). + * Must not be null. + */ + public void setWorkingSet(IWorkingSet workingSet) { + oldWorkingSet = this.workingSet; + this.workingSet = workingSet; + + if (workingSetButton != null && mruList != null) { + initializeWorkingSet(); + } + } + +} 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 b32687a3c..d6e894332 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 @@ -780,8 +780,10 @@ ForceCommitSyncAction.You_have_chosen_to_commit_new_resources_which_have_not_bee SyncAllAction.selectProjects=Select the projects you would like to synchronize -ResourceSelectionDialog.workingSet=Select a &working set (matching projects will be shown): -ResourceSelectionDialog.workingSetOther=&Other... +WorkingSetSelectionArea.workingSet=Select a &working set (matching projects will be checked): +WorkingSetSelectionArea.workingSetOther=&Other... +ListSelectionArea.selectAll=&Select All +ListSelectionArea.deselectAll=&Deselect All CheckoutIntoWizard.title=Checkout Into CheckoutIntoWizard.projectSelectionPageTitle=Select local folder diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteProjectsElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteProjectsElement.java index 968050ad7..6e54762b8 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteProjectsElement.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteProjectsElement.java @@ -28,6 +28,13 @@ public class RemoteProjectsElement extends CVSTagElement { super(CVSTag.DEFAULT, null); } + /** + * Constructor for RemoteProjectsElement. + */ + public RemoteProjectsElement(ICVSRepositoryLocation root) { + super(CVSTag.DEFAULT, root); + } + /** * Sets the root. * @param root The root to set diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectSelectionPage.java new file mode 100644 index 000000000..977a9bbb2 --- /dev/null +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectSelectionPage.java @@ -0,0 +1,139 @@ +/******************************************************************************* + * Copyright (c) 2002 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM - Initial implementation + ******************************************************************************/ +package org.eclipse.team.internal.ccvs.ui.repo; + +import java.util.Arrays; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; +import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; +import org.eclipse.team.internal.ccvs.ui.ListSelectionArea; +import org.eclipse.team.internal.ccvs.ui.Policy; +import org.eclipse.team.internal.ccvs.ui.WorkingSetSelectionArea; +import org.eclipse.team.internal.ccvs.ui.model.RemoteContentProvider; +import org.eclipse.team.internal.ccvs.ui.model.RemoteProjectsElement; +import org.eclipse.team.internal.ccvs.ui.wizards.CVSWizardPage; +import org.eclipse.ui.IWorkingSet; +import org.eclipse.ui.model.WorkbenchLabelProvider; + +/** + * @author Administrator + * + * To change this generated comment edit the template variable "typecomment": + * Window>Preferences>Java>Templates. + * To enable and disable the creation of type comments go to + * Window>Preferences>Java>Code Generation. + */ +public class RefreshRemoteProjectSelectionPage extends CVSWizardPage { + + private Dialog parentDialog; + private ICVSRepositoryLocation root; + private ListSelectionArea listArea; + private WorkingSetSelectionArea workingSetArea; + private IWorkingSet workingSet; + + /** + * Constructor for RemoteProjectSelectionPage. + * @param pageName + * @param title + * @param titleImage + * @param description + */ + public RefreshRemoteProjectSelectionPage( + String pageName, + String title, + ImageDescriptor titleImage, + String description, + Dialog parentDialog, + ICVSRepositoryLocation root) { + super(pageName, title, titleImage, description); + this.parentDialog = parentDialog; + this.root = root; + } + + /** + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + Composite composite = createComposite(parent, 1); + setControl(composite); + // set F1 help + //WorkbenchHelp.setHelp(composite, IHelpContextIds.SHARING_FINISH_PAGE); + + listArea = new ListSelectionArea(parentDialog, + new RemoteProjectsElement(root), + new RemoteContentProvider(), + new WorkbenchLabelProvider(), + Policy.bind("RemoteProjectSelectionPage.selectRemoteProjects")); + listArea.createArea(composite); + + workingSetArea = new WorkingSetSelectionArea(parentDialog); + setWorkingSet(workingSet); + workingSetArea.addPropertyChangeListener(new IPropertyChangeListener() { + public void propertyChange(PropertyChangeEvent event) { + workingSet = (IWorkingSet)event.getNewValue(); + handleWorkingSetChange(); + } + }); + workingSetArea.createArea(composite); + } + + /** + * Sets the working set that should be selected in the most recently + * used working set list. + * + * @param workingSet the working set that should be selected. + * has to exist in the list returned by + * org.eclipse.ui.IWorkingSetManager#getRecentWorkingSets(). + * Must not be null. + */ + public void setWorkingSet(IWorkingSet workingSet) { + this.workingSet = workingSet; + + if (workingSetArea != null) { + workingSetArea.setWorkingSet(workingSet); + } + } + + private void handleWorkingSetChange() { + if (workingSet != null) { + // check any projects in the working set + listArea.getViewer().setAllChecked(false); + IAdaptable[] adaptables = workingSet.getElements(); + for (int i = 0; i < adaptables.length; i++) { + // XXX needs to be modified for remote resources + IAdaptable adaptable = adaptables[i]; + Object adapted = adaptable.getAdapter(IResource.class); + if (adapted != null) { + // Can this code be generalized? + IProject project = ((IResource)adapted).getProject(); + listArea.getViewer().setChecked(project, true); + } + } + } + } + /** + * Method getSelectedRemoteProject. + * @return ICVSRemoteResource[] + */ + public ICVSRemoteResource[] getSelectedRemoteProject() { + Object[] checked = listArea.getViewer().getCheckedElements(); + return (ICVSRemoteResource[]) Arrays.asList(checked).toArray(new ICVSRemoteResource[checked.length]); + } + +} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java new file mode 100644 index 000000000..14c203800 --- /dev/null +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java @@ -0,0 +1,106 @@ +/******************************************************************************* + * Copyright (c) 2002 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM - Initial implementation + ******************************************************************************/ +package org.eclipse.team.internal.ccvs.ui.repo; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.window.Window; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.internal.ccvs.core.ICVSFolder; +import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; +import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; +import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; +import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; +import org.eclipse.team.internal.ccvs.ui.Policy; + +/** + * Wizard for refreshing the tags for a CVS repository location + */ +public class RefreshRemoteProjectWizard extends Wizard { + + private Dialog parentDialog; + private ICVSRepositoryLocation root; + private RefreshRemoteProjectSelectionPage projectSelectionPage; + + public static boolean execute(Shell shell, ICVSRepositoryLocation root) { + RefreshRemoteProjectWizard wizard = new RefreshRemoteProjectWizard(root); + WizardDialog dialog = new WizardDialog(shell, wizard); + wizard.setParentDialog(dialog); + return (dialog.open() == Window.OK); + } + + public RefreshRemoteProjectWizard(ICVSRepositoryLocation root) { + this.root = root; + } + + /** + * @see org.eclipse.jface.wizard.IWizard#addPages() + */ + public void addPages() { + setNeedsProgressMonitor(true); + ImageDescriptor substImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION); + projectSelectionPage = new RefreshRemoteProjectSelectionPage( + "ProjectSelectionPage", //$NON-NLS-1$ + Policy.bind("RefreshRemoteProjectSelectionPage.pageTitle"), //$NON-NLS-1$ + substImage, + Policy.bind("RefreshRemoteProjectSelectionPage.pageDescription"), //$NON-NLS-1$ + parentDialog, root); + addPage(projectSelectionPage); + } + + /** + * @see org.eclipse.jface.wizard.Wizard#performFinish() + */ + public boolean performFinish() { + final ICVSRemoteResource[] selectedFolders = projectSelectionPage.getSelectedRemoteProject(); + try { + getContainer().run(true, true, new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + monitor.beginTask(null, 100 * selectedFolders.length); + try { + RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); + for (int i = 0; i < selectedFolders.length; i++) { + ICVSRemoteResource resource = selectedFolders[i]; + if (resource instanceof ICVSFolder) { + manager.refreshDefinedTags((ICVSFolder)resource, true /* replace */, true, Policy.subMonitorFor(monitor, 100)); + } + } + } catch (TeamException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); + } + } + }); + return true; + } catch (InvocationTargetException e) { + CVSUIPlugin.openError(getShell(), null, null ,e); + } catch (InterruptedException e) { + } + return false; + } + + /** + * Sets the parentDialog. + * @param parentDialog The parentDialog to set + */ + public void setParentDialog(Dialog parentDialog) { + this.parentDialog = parentDialog; + } + +} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshTagsAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshTagsAction.java index 519f6353f..a00add1b3 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshTagsAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshTagsAction.java @@ -32,35 +32,37 @@ public class RefreshTagsAction extends CVSAction { * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) */ protected void execute(IAction action) throws InvocationTargetException, InterruptedException { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - ICVSRepositoryLocation[] locations = getSelectedRepositoryLocations(); - RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); - try { - monitor.beginTask(null, 100 * locations.length); - for (int j = 0; j < locations.length; j++) { - ICVSRepositoryLocation location = locations[j]; - // todo: This omits defined modules when there is no current working set - ICVSRemoteResource[] resources = manager.getWorkingFoldersForTag(location, CVSTag.DEFAULT, Policy.subMonitorFor(monitor, 10)); - if (promptToRefresh(location, resources)) { - IProgressMonitor subMonitor = Policy.subMonitorFor(monitor, 90); - subMonitor.beginTask(null, 100 * resources.length); - for (int i = 0; i < resources.length; i++) { - ICVSRemoteResource resource = resources[i]; - if (resource instanceof ICVSFolder) { - manager.refreshDefinedTags((ICVSFolder)resource, true /* replace */, true, Policy.subMonitorFor(subMonitor, 100)); - } - } - subMonitor.done(); - } - } - manager.saveState(); - monitor.done(); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - }, true, PROGRESS_DIALOG); + ICVSRepositoryLocation[] locations = getSelectedRepositoryLocations(); + RefreshRemoteProjectWizard.execute(getShell(), locations[0]); +// run(new IRunnableWithProgress() { +// public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { +// ICVSRepositoryLocation[] locations = getSelectedRepositoryLocations(); +// RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); +// try { +// monitor.beginTask(null, 100 * locations.length); +// for (int j = 0; j < locations.length; j++) { +// ICVSRepositoryLocation location = locations[j]; +// // todo: This omits defined modules when there is no current working set +// ICVSRemoteResource[] resources = manager.getWorkingFoldersForTag(location, CVSTag.DEFAULT, Policy.subMonitorFor(monitor, 10)); +// if (promptToRefresh(location, resources)) { +// IProgressMonitor subMonitor = Policy.subMonitorFor(monitor, 90); +// subMonitor.beginTask(null, 100 * resources.length); +// for (int i = 0; i < resources.length; i++) { +// ICVSRemoteResource resource = resources[i]; +// if (resource instanceof ICVSFolder) { +// manager.refreshDefinedTags((ICVSFolder)resource, true /* replace */, true, Policy.subMonitorFor(subMonitor, 100)); +// } +// } +// subMonitor.done(); +// } +// } +// manager.saveState(); +// monitor.done(); +// } catch (TeamException e) { +// throw new InvocationTargetException(e); +// } +// } +// }, true, PROGRESS_DIALOG); } /** @@ -68,7 +70,7 @@ public class RefreshTagsAction extends CVSAction { */ protected boolean isEnabled() throws TeamException { ICVSRepositoryLocation[] locations = getSelectedRepositoryLocations(); - if (locations.length == 0) return false; + if (locations.length != 1) return false; return true; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteProjectsView.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteProjectsView.java index 862083e1c..985881cbc 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteProjectsView.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteProjectsView.java @@ -33,6 +33,15 @@ public class RemoteProjectsView extends RemoteViewPart { getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(RemoteTagsView.VIEW_ID, this); } + /** + * @see org.eclipse.ui.IWorkbenchPart#dispose() + */ + public void dispose() { + getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(RepositoriesView.VIEW_ID, this); + getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(RemoteTagsView.VIEW_ID, this); + super.dispose(); + } + /** * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) */ diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteTagsView.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteTagsView.java index ee8c43004..021ff625b 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteTagsView.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteTagsView.java @@ -35,6 +35,14 @@ public class RemoteTagsView extends RemoteViewPart { getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(RepositoriesView.VIEW_ID, this); } + /** + * @see org.eclipse.ui.IWorkbenchPart#dispose() + */ + public void dispose() { + getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(RepositoriesView.VIEW_ID, this); + super.dispose(); + } + /** * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) */ diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteViewPart.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteViewPart.java index c957c53d0..0dfd3b073 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteViewPart.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteViewPart.java @@ -303,6 +303,7 @@ public abstract class RemoteViewPart extends ViewPart implements ISelectionListe } protected void refreshViewer() { + if (viewer == null) return; updateWorkingSetMenu(); viewer.refresh(); } @@ -350,6 +351,7 @@ public abstract class RemoteViewPart extends ViewPart implements ISelectionListe public void dispose() { getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(this); super.dispose(); + viewer = null; } } -- cgit v1.2.3