diff options
Diffstat (limited to 'bundles/org.eclipse.team.ui/src/org')
141 files changed, 0 insertions, 23483 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/IHelpContextIds.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/IHelpContextIds.java deleted file mode 100644 index 5ed5e1da6..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/IHelpContextIds.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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; - -public interface IHelpContextIds { - public static final String PREFIX = TeamUIPlugin.ID + "."; //$NON-NLS-1$ - - // Preference Pages - public static final String TEAM_PREFERENCE_PAGE = PREFIX + "team_preference_page_context"; //$NON-NLS-1$ - public static final String IGNORE_PREFERENCE_PAGE = PREFIX + "ignore_preference_page_context"; //$NON-NLS-1$ - public static final String FILE_TYPE_PREFERENCE_PAGE = PREFIX + "file_type_preference_page_context"; //$NON-NLS-1$ - - // Wizard Pages - public static final String SHARE_PROJECT_PAGE = PREFIX + "share_project_page_context"; //$NON-NLS-1$ - public static final String IMPORT_PROJECT_SET_PAGE = PREFIX + "import_project_set_page_context"; //$NON-NLS-1$ - public static final String EXPORT_PROJECT_SET_PAGE = PREFIX + "export_project_set_page_context"; //$NON-NLS-1$ - public static final String TARGET_NEW_SITE_PAGE = PREFIX + "target_new_site_page_context"; //$NON-NLS-1$ - public static final String TARGET_MAPPING_SELECTION_PAGE = PREFIX + "target_mapping_selection_page_context"; //$NON-NLS-1$ - - // Catchup Release Viewers - public static final String TARGET_CATCHUP_RELEASE_VIEWER = PREFIX + "target_catchup_release_viewer_context"; //$NON-NLS-1$ - - // Target Actions - public static final String SYNC_GET_ACTION = PREFIX + "sync_get_action_context"; //$NON-NLS-1$ - public static final String SYNC_PUT_ACTION = PREFIX + "sync_put_action_context"; //$NON-NLS-1$ - - // Views - public static final String SITE_EXPLORER_VIEW = PREFIX + "site_explorer_view_context"; //$NON-NLS-1$ - public static final String SYNC_VIEW = PREFIX + "sync_view_context"; //$NON-NLS-1$ - - // Site Explorer View Actions - public static final String ADD_SITE_ACTION = PREFIX + "add_site_action_context"; //$NON-NLS-1$ - public static final String NEW_FOLDER_ACTION = PREFIX + "new_folder_action_context"; //$NON-NLS-1$ - - // Sync View Actions - public static final String OPEN_ACTION = PREFIX + "open_action_context"; //$NON-NLS-1$ - public static final String EXPANDALL_ACTION = PREFIX + "expandall_action_context"; //$NON-NLS-1$ - public static final String REMOVE_ACTION = PREFIX + "remove_action_context"; //$NON-NLS-1$ - public static final String NAVIGATOR_SHOW_ACTION = PREFIX + "navigator_show_action_context"; //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/IPreferenceIds.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/IPreferenceIds.java deleted file mode 100644 index caf8e836d..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/IPreferenceIds.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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; - -public interface IPreferenceIds { - public static final String PREFIX = TeamUIPlugin.ID + "."; //$NON-NLS-1$ - - /* - * Default model provider layout to use with SubscriberSynchronizePage. The user can configure but this - * is used to select the initial layout. - */ - public static final String SYNCVIEW_COMPRESS_FOLDERS = PREFIX + "compress_folders"; //$NON-NLS-1$ - - /* - * Preference to enable displaying synchronization state in the elements label. This - * preference is used automatically with {@link StructuredViewerAdvisor}. - */ - public static final String SYNCVIEW_VIEW_SYNCINFO_IN_LABEL = PREFIX + "view_syncinfo_in_label"; //$NON-NLS-1$ - - /* - * Preference to manage the perspective used to synchronize. - */ - public static final String SYNCVIEW_DEFAULT_PERSPECTIVE = PREFIX + "syncview_default_perspective"; //$NON-NLS-1$ - public static final String SYNCVIEW_DEFAULT_PERSPECTIVE_NONE = PREFIX + "sync_view_perspective_none"; //$NON-NLS-1$ - public static final String SYNCHRONIZING_COMPLETE_PERSPECTIVE = PREFIX + "sychronizing_default_perspective_to_show"; //$NON-NLS-1$ - - /* - * Preference to save the last participant selected via the global synchronize action. - */ - public static final String SYNCHRONIZING_DEFAULT_PARTICIPANT = PREFIX + "sychronizing_default_participant"; //$NON-NLS-1$ - public static final String SYNCHRONIZING_DEFAULT_PARTICIPANT_SEC_ID = PREFIX + "sychronizing_default_participant"; //$NON-NLS-1$ - - /* - * Preference for disabling various prompts - */ - public static final String SYNCVIEW_REMOVE_FROM_VIEW_NO_PROMPT = PREFIX + "remove_from_view_without_prompt"; //$NON-NLS-1$ - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/OverlayIcon.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/OverlayIcon.java deleted file mode 100644 index 38011f450..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/OverlayIcon.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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 java.util.Arrays; - -import org.eclipse.jface.resource.CompositeImageDescriptor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.*; - -/** - * An OverlayIcon consists of a main icon and several adornments. - */ -public class OverlayIcon extends CompositeImageDescriptor { - // the base image - private Image base; - // the base as a descriptor - private ImageDescriptor descriptorBase; - // the overlay images - private ImageDescriptor[] overlays; - // the size - private Point size; - // the locations - private int[] locations; - - public static final int TOP_LEFT = 0; - public static final int TOP_RIGHT = 1; - public static final int BOTTOM_LEFT = 2; - public static final int BOTTOM_RIGHT = 3; - - public static final int DEFAULT_WIDTH= 22; - public static final int DEFAULT_HEIGHT= 16; - - /** - * OverlayIcon constructor. - * - * @param base the base image - * @param overlays the overlay images - * @param locations the location of each image - * @param size the size - */ - public OverlayIcon(Image base, ImageDescriptor[] overlays, int[] locations, Point size) { - this.base = base; - this.descriptorBase = null; - this.overlays = overlays; - this.locations = locations; - this.size = size; - } - - /** - * OverlayIcon constructor. - * - * @param base the base image - * @param overlays the overlay images - * @param locations the location of each image - * @param size the size - */ - public OverlayIcon(ImageDescriptor descriptorBase, ImageDescriptor[] overlays, int[] locations, Point size) { - this.descriptorBase = descriptorBase; - this.base = null; - this.overlays = overlays; - this.locations = locations; - this.size = size; - } - - protected void drawOverlays(ImageDescriptor[] overlays, int[] locations) { - Point size = getSize(); - for (int i = 0; i < overlays.length; i++) { - ImageDescriptor overlay = overlays[i]; - ImageData overlayData = overlay.getImageData(); - switch (locations[i]) { - case TOP_LEFT: - drawImage(overlayData, 0, 0); - break; - case TOP_RIGHT: - drawImage(overlayData, size.x - overlayData.width, 0); - break; - case BOTTOM_LEFT: - drawImage(overlayData, 0, size.y - overlayData.height); - break; - case BOTTOM_RIGHT: - drawImage(overlayData, size.x - overlayData.width, size.y - overlayData.height); - break; - } - } - } - - public boolean equals(Object o) { - if (! (o instanceof OverlayIcon)) return false; - OverlayIcon other = (OverlayIcon) o; - return base.equals(other.base) && Arrays.equals(overlays, other.overlays); - } - - public int hashCode() { - int code = base.hashCode(); - for (int i = 0; i < overlays.length; i++) { - code ^= overlays[i].hashCode(); - } - return code; - } - - - protected void drawCompositeImage(int width, int height) { - if(descriptorBase != null) { - ImageData bg; - if (descriptorBase == null || (bg= descriptorBase.getImageData()) == null) - bg= DEFAULT_IMAGE_DATA; - drawImage(bg, 0, 0); - } else { - drawImage(base.getImageData(), 0, 0); - } - drawOverlays(overlays, locations); - } - - protected Point getSize() { - return size; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Policy.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Policy.java deleted file mode 100644 index 700e99613..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Policy.java +++ /dev/null @@ -1,196 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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 java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.*; -import org.eclipse.team.internal.core.InfiniteSubProgressMonitor; -import org.eclipse.team.internal.core.NullSubProgressMonitor; - -/** - * Policy implements NLS convenience methods for the plugin and - * makes progress monitor policy decisions - */ -public class Policy { - // The resource bundle to get strings from - protected static ResourceBundle bundle = null; - - /** - * Creates a NLS catalog for the given locale. - * - * @param bundleName the name of the bundle - */ - public static void localize(String bundleName) { - bundle = ResourceBundle.getBundle(bundleName); - } - - /** - * Lookup the message with the given ID in this catalog and bind its - * substitution locations with the given string. - * - * @param id the id to look up - * @param binding the string to bind to the result - * @return the bound string - */ - public static String bind(String id, String binding) { - return bind(id, new String[] { binding }); - } - - /** - * Lookup the message with the given ID in this catalog and bind its - * substitution locations with the given strings. - * - * @param id the id to look up - * @param binding1 the first string to bind to the result - * @param binding2 the second string to bind to the result - * @return the bound string - */ - public static String bind(String id, String binding1, String binding2) { - return bind(id, new String[] { binding1, binding2 }); - } - - /** - * Lookup the message with the given ID in this catalog and bind its - * substitution locations with the given strings. - * - * @param id the id to look up - * @param binding1 the first string to bind to the result - * @param binding2 the second string to bind to the result - * @param binding3 the third string to bind to the result - * @return the bound string - */ - public static String bind(String id, String binding1, String binding2,String binding3) { - return bind(id, new String[] { binding1, binding2, binding3 }); - } - - /** - * Gets a string from the resource bundle. We don't want to crash because of a missing String. - * Returns the key if not found. - * - * @param key the id to look up - * @return the string with the given key - */ - public static String bind(String key, ResourceBundle b) { - try { - return b.getString(key); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Gets a string from the resource bundle. We don't want to crash because of a missing String. - * Returns the key if not found. - * - * @param key the id to look up - * @return the string with the given key - */ - public static String bind(String key) { - try { - return bundle.getString(key); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Gets a string from the resource bundle and binds it with the given arguments. If the key is - * not found, return the key. - * - * @param key the id to look up - * @param args the strings to bind to the result - * @return the bound string - */ - public static String bind(String key, Object[] args) { - try { - return MessageFormat.format(bind(key), args); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Checks if the progress monitor is canceled. - * - * @param monitor the onitor to check for cancellation - * @throws OperationCanceledException if the monitor is canceled - */ - public static void checkCanceled(IProgressMonitor monitor) { - if (monitor.isCanceled()) { - throw new OperationCanceledException(); - } - } - /** - * Returns a monitor for the given monitor - * - * @param monitor the monitor to return a monitor for - * @return a monitor for the given monitor - */ - public static IProgressMonitor monitorFor(IProgressMonitor monitor) { - if (monitor == null) { - return new NullProgressMonitor(); - } - return monitor; - } - - public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) { - if (monitor == null) - return new NullProgressMonitor(); - if (monitor instanceof NullProgressMonitor) - return monitor; - return new SubProgressMonitor(monitor, ticks); - } - - public static IProgressMonitor subInfiniteMonitorFor(IProgressMonitor monitor, int ticks) { - if (monitor == null) - return new NullProgressMonitor(); - if (monitor instanceof NullProgressMonitor) - return monitor; - return new InfiniteSubProgressMonitor(monitor, ticks); - } - - public static IProgressMonitor subNullMonitorFor(IProgressMonitor monitor) { - if (monitor == null) - return new NullProgressMonitor(); - if (monitor instanceof NullProgressMonitor) - return monitor; - return new NullSubProgressMonitor(monitor); - } - - public static String toTruncatedPath(IPath path, int split) { - // Search backwards until split separators are found - int count = 0; - String stringPath = path.toString(); - int index = stringPath.length(); - while (count++ < split && index != -1) { - index = stringPath.lastIndexOf(IPath.SEPARATOR, index - 1); - } - if (index == -1) { - return stringPath; - } else { - return "..." + stringPath.substring(index); //$NON-NLS-1$ - } - } - - public static ResourceBundle getBundle() { - return bundle; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ProjectSetContentHandler.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ProjectSetContentHandler.java deleted file mode 100644 index 1d58bdff1..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ProjectSetContentHandler.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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 java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -public class ProjectSetContentHandler extends DefaultHandler { - boolean inPsf = false; - boolean inProvider = false; - boolean inProject = false; - Map map; - String id; - List references; - boolean isVersionOne = false; - - /** - * @see ContentHandler#startElement(String, String, String, Attributes) - */ - public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { - String elementName = getElementName(namespaceURI, localName, qName); - if (elementName.equals("psf")) { //$NON-NLS-1$ //$NON-NLS-2$ - map = new HashMap(); - inPsf = true; - String version = atts.getValue("version"); //$NON-NLS-1$ - isVersionOne = version.equals("1.0"); //$NON-NLS-1$ - return; - } - if (isVersionOne) return; - if (elementName.equals("provider")) { //$NON-NLS-1$ //$NON-NLS-2$ - if (!inPsf) throw new SAXException(Policy.bind("ProjectSetContentHandler.Element_provider_must_be_contained_in_element_psf_4")); //$NON-NLS-1$ - inProvider = true; - id = atts.getValue("id"); //$NON-NLS-1$ - references = new ArrayList(); - return; - } - if (elementName.equals("project")) { //$NON-NLS-1$ //$NON-NLS-2$ - if (!inProvider) throw new SAXException(Policy.bind("ProjectSetContentHandler.Element_project_must_be_contained_in_element_provider_7")); //$NON-NLS-1$ - inProject = true; - String reference = atts.getValue("reference"); //$NON-NLS-1$ - references.add(reference); - return; - } - } - - /** - * @see ContentHandler#endElement(String, String, String) - */ - public void endElement(String namespaceURI, String localName, String qName) throws SAXException { - String elementName = getElementName(namespaceURI, localName, qName); - if (elementName.equals("psf")) { //$NON-NLS-1$ //$NON-NLS-2$ - inPsf = false; - return; - } - if (isVersionOne) return; - if (elementName.equals("provider")) { //$NON-NLS-1$ //$NON-NLS-2$ - map.put(id, references); - references = null; - inProvider = false; - return; - } - if (elementName.equals("project")) { //$NON-NLS-1$ //$NON-NLS-2$ - inProject = false; - return; - } - } - - public Map getReferences() { - return map; - } - - public boolean isVersionOne() { - return isVersionOne; - } - - /* - * Couldn't figure out from the SAX API exactly when localName vs. qName is used. - * However, the XML for project sets doesn't use namespaces so either of the two names - * is fine. Therefore, use whichever one is provided. - */ - private String getElementName(String namespaceURI, String localName, String qName) { - if (localName != null && localName.length() > 0) { - return localName; - } else { - return qName; - } - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamAdapterFactory.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamAdapterFactory.java deleted file mode 100644 index 315c9dcc1..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamAdapterFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.compare.structuremergeviewer.DiffNode; -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.team.internal.ui.synchronize.DiffNodeWorkbenchAdapter; -import org.eclipse.ui.model.IWorkbenchAdapter; - - -public class TeamAdapterFactory implements IAdapterFactory { - - private DiffNodeWorkbenchAdapter diffNodeAdapter = new DiffNodeWorkbenchAdapter(); - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - public Object getAdapter(Object adaptableObject, Class adapterType) { - if(adaptableObject instanceof DiffNode && adapterType == IWorkbenchAdapter.class) { - return diffNodeAdapter; - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() - */ - public Class[] getAdapterList() { - // TODO Auto-generated method stub - return new Class[] {IWorkbenchAdapter.class}; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java deleted file mode 100644 index d196efba4..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java +++ /dev/null @@ -1,366 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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 java.lang.reflect.InvocationTargetException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.*; -import org.eclipse.compare.structuremergeviewer.DiffNode; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.dialogs.MessageDialogWithToggle; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; -import org.eclipse.team.internal.ui.synchronize.SynchronizeManager; -import org.eclipse.team.internal.ui.synchronize.TeamSynchronizingPerspective; -import org.eclipse.team.internal.ui.synchronize.actions.GlobalRefreshAction; -import org.eclipse.team.ui.ISharedImages; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.ui.*; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -/** - * TeamUIPlugin is the plugin for generic, non-provider specific, - * team UI functionality in the workbench. - */ -public class TeamUIPlugin extends AbstractUIPlugin { - - private static TeamUIPlugin instance; - - // image paths - public static final String ICON_PATH = "icons/full/"; //$NON-NLS-1$ - - public static final String ID = "org.eclipse.team.ui"; //$NON-NLS-1$ - - // plugin id - public static final String PLUGIN_ID = "org.eclipse.team.ui"; //$NON-NLS-1$ - - private static List propertyChangeListeners = new ArrayList(5); - - private Hashtable imageDescriptors = new Hashtable(20); - - /** - * Creates a new TeamUIPlugin. - * - * @param descriptor the plugin descriptor - */ - public TeamUIPlugin(IPluginDescriptor descriptor) { - super(descriptor); - initializeImages(this); - initializePreferences(); - instance = this; - } - - /** - * Creates an extension. If the extension plugin has not - * been loaded a busy cursor will be activated during the duration of - * the load. - * - * @param element the config element defining the extension - * @param classAttribute the name of the attribute carrying the class - * @return the extension object - */ - public static Object createExtension(final IConfigurationElement element, final String classAttribute) throws CoreException { - // If plugin has been loaded create extension. - // Otherwise, show busy cursor then create extension. - IPluginDescriptor plugin = element.getDeclaringExtension().getDeclaringPluginDescriptor(); - if (plugin.isPluginActivated()) { - return element.createExecutableExtension(classAttribute); - } else { - final Object [] ret = new Object[1]; - final CoreException [] exc = new CoreException[1]; - BusyIndicator.showWhile(null, new Runnable() { - public void run() { - try { - ret[0] = element.createExecutableExtension(classAttribute); - } catch (CoreException e) { - exc[0] = e; - } - } - }); - if (exc[0] != null) - throw exc[0]; - else - return ret[0]; - } - } - - /** - * Convenience method to get the currently active workbench page. Note that - * the active page may not be the one that the usr perceives as active in - * some situations so this method of obtaining the activae page should only - * be used if no other method is available. - * - * @return the active workbench page - */ - public static IWorkbenchPage getActivePage() { - IWorkbenchWindow window = getPlugin().getWorkbench().getActiveWorkbenchWindow(); - if (window == null) return null; - return window.getActivePage(); - } - - /** - * Return the default instance of the receiver. This represents the runtime plugin. - * - * @return the singleton plugin instance - */ - public static TeamUIPlugin getPlugin() { - return instance; - } - /** - * Initializes the preferences for this plugin if necessary. - */ - protected void initializePreferences() { - IPreferenceStore store = getPreferenceStore(); - store.setDefault(IPreferenceIds.SYNCVIEW_VIEW_SYNCINFO_IN_LABEL, false); - store.setDefault(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS, true); - store.setDefault(IPreferenceIds.SYNCVIEW_DEFAULT_PERSPECTIVE, TeamSynchronizingPerspective.ID); - store.setDefault(IPreferenceIds.SYNCHRONIZING_DEFAULT_PARTICIPANT, GlobalRefreshAction.NO_DEFAULT_PARTICPANT); - store.setDefault(IPreferenceIds.SYNCHRONIZING_DEFAULT_PARTICIPANT_SEC_ID, GlobalRefreshAction.NO_DEFAULT_PARTICPANT); - store.setDefault(IPreferenceIds.SYNCHRONIZING_COMPLETE_PERSPECTIVE, MessageDialogWithToggle.PROMPT); - store.setDefault(IPreferenceIds.SYNCVIEW_REMOVE_FROM_VIEW_NO_PROMPT, false); - } - - /** - * Convenience method for logging statuses to the plugin log - * - * @param status the status to log - */ - public static void log(IStatus status) { - getPlugin().getLog().log(status); - } - - /** - * Convenience method for logging a TeamException in such a way that the - * stacktrace is logged as well. - * @param e - */ - public static void log(CoreException e) { - IStatus status = e.getStatus(); - log (status.getSeverity(), status.getMessage(), e); - } - - /** - * Log the given exception along with the provided message and severity indicator - */ - public static void log(int severity, String message, Throwable e) { - log(new Status(severity, ID, 0, message, e)); - } - - /** - * @see Plugin#startup() - */ - public void startup() throws CoreException { - Policy.localize("org.eclipse.team.internal.ui.messages"); //$NON-NLS-1$ - initializePreferences(); - IAdapterFactory factory = new TeamAdapterFactory(); - Platform.getAdapterManager().registerAdapters(factory, DiffNode.class); - ((SynchronizeManager)TeamUI.getSynchronizeManager()).init(); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.Plugin#shutdown() - */ - public void shutdown() throws CoreException { - super.shutdown(); - ((SynchronizeManager)TeamUI.getSynchronizeManager()).dispose(); - } - - /** - * Register for changes made to Team properties. - */ - public static void addPropertyChangeListener(IPropertyChangeListener listener) { - propertyChangeListeners.add(listener); - } - - /** - * Deregister as a Team property changes. - */ - public static void removePropertyChangeListener(IPropertyChangeListener listener) { - propertyChangeListeners.remove(listener); - } - - /** - * Broadcast a Team property change. - */ - public static void broadcastPropertyChange(PropertyChangeEvent event) { - for (Iterator it = propertyChangeListeners.iterator(); it.hasNext();) { - IPropertyChangeListener listener = (IPropertyChangeListener)it.next(); - listener.propertyChange(event); - } - } - - /** - * Creates an image and places it in the image registry. - * - * @param id the identifier for the image - * @param baseURL the base URL for the image - */ - protected static void createImageDescriptor(TeamUIPlugin plugin, String id, URL baseURL) { - // Delegate to the plugin instance to avoid concurrent class loading problems - plugin.privateCreateImageDescriptor(id, baseURL); - } - private void privateCreateImageDescriptor(String id, URL baseURL) { - URL url = null; - try { - url = new URL(baseURL, ICON_PATH + id); - } catch (MalformedURLException e) { - } - ImageDescriptor desc = ImageDescriptor.createFromURL(url); - imageDescriptors.put(id, desc); - } - - /** - * Returns the image descriptor for the given image ID. - * Returns null if there is no such image. - * - * @param id the identifier for the image to retrieve - * @return the image associated with the given ID - */ - public static ImageDescriptor getImageDescriptor(String id) { - // Delegate to the plugin instance to avoid concurrent class loading problems - return getPlugin().privateGetImageDescriptor(id); - } - private ImageDescriptor privateGetImageDescriptor(String id) { - if(! imageDescriptors.containsKey(id)) { - URL baseURL = TeamUIPlugin.getPlugin().getDescriptor().getInstallURL(); - createImageDescriptor(getPlugin(), id, baseURL); - } - return (ImageDescriptor)imageDescriptors.get(id); - } - - /** - * Convenience method to get an image descriptor for an extension - * - * @param extension the extension declaring the image - * @param subdirectoryAndFilename the path to the image - * @return the image - */ - public static ImageDescriptor getImageDescriptorFromExtension(IExtension extension, String subdirectoryAndFilename) { - IPluginDescriptor pluginDescriptor = extension.getDeclaringPluginDescriptor(); - URL path = pluginDescriptor.getInstallURL(); - URL fullPathString = null; - try { - fullPathString = new URL(path,subdirectoryAndFilename); - return ImageDescriptor.createFromURL(fullPathString); - } catch (MalformedURLException e) { - } - return null; - } - /* - * Initializes the table of images used in this plugin. The plugin is - * provided because this method is called before the plugin staic - * variable has been set. See the comment on the getPlugin() method - * for a description of why this is required. - */ - private void initializeImages(TeamUIPlugin plugin) { - URL baseURL = plugin.getDescriptor().getInstallURL(); - - // Overlays - createImageDescriptor(plugin, ISharedImages.IMG_DIRTY_OVR, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_CONFLICT_OVR, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_CHECKEDIN_OVR, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_CHECKEDOUT_OVR, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_ERROR_OVR, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_WARNING_OVR, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_HOURGLASS_OVR, baseURL); - - // Target Management Icons - createImageDescriptor(plugin, ISharedImages.IMG_SITE_ELEMENT, baseURL); - - // Sync View Icons - createImageDescriptor(plugin, ISharedImages.IMG_DLG_SYNC_INCOMING, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_DLG_SYNC_OUTGOING, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_DLG_SYNC_CONFLICTING, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_REFRESH, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_CHANGE_FILTER, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_IGNORE_WHITESPACE, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_CONTENTS, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_COLLAPSE_ALL, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_COLLAPSE_ALL_ENABLED, baseURL); - - createImageDescriptor(plugin, ISharedImages.IMG_DLG_SYNC_INCOMING_DISABLED, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_DLG_SYNC_OUTGOING_DISABLED, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_DLG_SYNC_CONFLICTING_DISABLED, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_REFRESH_DISABLED, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_IGNORE_WHITESPACE_DISABLED, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_CONTENTS_DISABLED, baseURL); - - createImageDescriptor(plugin, ISharedImages.IMG_DLG_SYNC_INCOMING_ENABLED, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_DLG_SYNC_OUTGOING_ENABLED, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_DLG_SYNC_CONFLICTING_ENABLED, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_REFRESH_ENABLED, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_IGNORE_WHITESPACE_ENABLED, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_CONTENTS_ENABLED, baseURL); - - createImageDescriptor(plugin, ISharedImages.IMG_SYNC_MODE_CATCHUP, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_SYNC_MODE_RELEASE, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_SYNC_MODE_FREE, baseURL); - - createImageDescriptor(plugin, ISharedImages.IMG_SYNC_MODE_CATCHUP_DISABLED, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_SYNC_MODE_RELEASE_DISABLED, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_SYNC_MODE_FREE_DISABLED, baseURL); - - createImageDescriptor(plugin, ISharedImages.IMG_SYNC_MODE_CATCHUP_ENABLED, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_SYNC_MODE_RELEASE_ENABLED, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_SYNC_MODE_FREE_ENABLED, baseURL); - - // Wizard banners - createImageDescriptor(plugin, ISharedImages.IMG_PROJECTSET_IMPORT_BANNER, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_PROJECTSET_EXPORT_BANNER, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_WIZBAN_SHARE, baseURL); - - // Live Sync View icons - createImageDescriptor(plugin, ISharedImages.IMG_COMPRESSED_FOLDER, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_SYNC_VIEW, baseURL); - createImageDescriptor(plugin, ISharedImages.IMG_HIERARCHICAL, baseURL); - } - - /** - * Returns the standard display to be used. The method first checks, if - * the thread calling this method has an associated display. If so, this - * display is returned. Otherwise the method returns the default display. - */ - public static Display getStandardDisplay() { - Display display= Display.getCurrent(); - if (display == null) { - display= Display.getDefault(); - } - return display; - } - - public Image getImage(String key) { - Image image = getImageRegistry().get(key); - if(image == null) { - ImageDescriptor d = getImageDescriptor(key); - image = d.createImage(); - getImageRegistry().put(key, image); - } - return image; - } - - public static void run(IRunnableWithProgress runnable) { - try { - PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(true, true, runnable); - } catch (InvocationTargetException e) { - Utils.handleError(getStandardDisplay().getActiveShell(), e, null, null); - } catch (InterruptedException e2) { - // Nothing to be done - } - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/UIProjectSetSerializationContext.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/UIProjectSetSerializationContext.java deleted file mode 100644 index d150c8688..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/UIProjectSetSerializationContext.java +++ /dev/null @@ -1,108 +0,0 @@ -/********************************************************************** - Copyright (c) 2004 Dan Rubel 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: - - Dan Rubel - initial API and implementation - - **********************************************************************/ - -package org.eclipse.team.internal.ui; - -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.util.Assert; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.ProjectSetSerializationContext; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ui.dialogs.IPromptCondition; -import org.eclipse.team.internal.ui.dialogs.PromptingDialog; - -/** - * The UI based context in which project serialization occurs. - * The class may be subclasses to represent different UI based serialization contexts. - * It is recommended that all UI based serialization contexts - * use this class directly or indirectly as their superclass. - * - * @since 3.0 - */ -public class UIProjectSetSerializationContext extends ProjectSetSerializationContext { - - /** - * The parent shell for this UI context - */ - private final Shell shell; - - /** - * Construct a new instance - * - * @param shell The parent shell for this UI context - */ - public UIProjectSetSerializationContext(Shell shell) { - Assert.isNotNull(shell); - this.shell = shell; - } - - /** - * Answer the shell associated with this UI context. - * - * @return the shell (not <code>null</code>) - */ - public Object getShell() { - return shell; - } - - /** - * Given an array of projects that currently exist in the workspace - * prompt the user to determine which of those projects should be overwritten. - * <p> - * This default implementation prompts the user - * to determine which projects should be overwritten. - * Subclasses may override this as appropriate. - * - * @param projects - * an array of projects currently existing in the workspace - * that are desired to be overwritten. - * (not <code>null</code>, contains no <code>null</code>s) - * @return - * an array of zero or more projects that should be overwritten - * or <code>null</code> if the operation is to be canceled - * - * @see org.eclipse.team.core.ProjectSetSerializationContext#confirmOverwrite(org.eclipse.core.resources.IProject[]) - */ - public IProject[] confirmOverwrite(final IProject[] projects) throws TeamException { - IPromptCondition prompt = new IPromptCondition() { - List resources = Arrays.asList(projects); - public boolean needsPrompt(IResource resource) { - return resources.contains(resource); - } - public String promptMessage(IResource resource) { - return "Overwrite " + resource.getName(); - } - }; - PromptingDialog dialog = - new PromptingDialog( - (Shell)getShell(), - projects, - prompt, - "Overwrite projects?"); - IResource[] resourcesToOverwrite; - try { - resourcesToOverwrite = dialog.promptForMultiple(); - } catch (InterruptedException e) { - // Return null indicating that the user canceled the operation - return null; - } - IProject[] projectsToOverwrite = new IProject[resourcesToOverwrite.length]; - System.arraycopy(resourcesToOverwrite, 0, projectsToOverwrite, 0, resourcesToOverwrite.length); - return projectsToOverwrite; - } - -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java deleted file mode 100644 index feb055bbd..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java +++ /dev/null @@ -1,574 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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 java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.util.*; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.ResourceBundle; -import java.util.Set; -import org.eclipse.compare.CompareConfiguration; -import org.eclipse.compare.structuremergeviewer.IDiffContainer; -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.ui.TeamImages; -import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.ui.*; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchPartSite; -import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.progress.IWorkbenchSiteProgressService; - -public class Utils { - - /** - * The SortOperation takes a collection of objects and returns a sorted - * collection of these objects. Concrete instances of this class provide - * the criteria for the sorting of the objects based on the type of the - * objects. - */ - static public abstract class Sorter { - - /** - * Returns true is elementTwo is 'greater than' elementOne This is the - * 'ordering' method of the sort operation. Each subclass overides this - * method with the particular implementation of the 'greater than' - * concept for the objects being sorted. - */ - public abstract boolean compare(Object elementOne, Object elementTwo); - - /** - * Sort the objects in sorted collection and return that collection. - */ - private Object[] quickSort(Object[] sortedCollection, int left, int right) { - int originalLeft = left; - int originalRight = right; - Object mid = sortedCollection[(left + right) / 2]; - do { - while (compare(sortedCollection[left], mid)) - left++; - while (compare(mid, sortedCollection[right])) - right--; - if (left <= right) { - Object tmp = sortedCollection[left]; - sortedCollection[left] = sortedCollection[right]; - sortedCollection[right] = tmp; - left++; - right--; - } - } while (left <= right); - if (originalLeft < right) - sortedCollection = quickSort(sortedCollection, originalLeft, right); - if (left < originalRight) - sortedCollection = quickSort(sortedCollection, left, originalRight); - return sortedCollection; - } - - /** - * Return a new sorted collection from this unsorted collection. Sort - * using quick sort. - */ - public Object[] sort(Object[] unSortedCollection) { - int size = unSortedCollection.length; - Object[] sortedCollection = new Object[size]; - //copy the array so can return a new sorted collection - System.arraycopy(unSortedCollection, 0, sortedCollection, 0, size); - if (size > 1) - quickSort(sortedCollection, 0, size - 1); - return sortedCollection; - } - } - - public static final Comparator resourceComparator = new Comparator() { - public boolean equals(Object obj) { - return false; - } - public int compare(Object o1, Object o2) { - IResource resource0 = (IResource) o1; - IResource resource1 = (IResource) o2; - return resource0.getFullPath().toString().compareTo(resource1.getFullPath().toString()); - } - }; - - /** - * Shows the given errors to the user. - * @param Exception - * the exception containing the error - * @param title - * the title of the error dialog - * @param message - * the message for the error dialog - * @param shell - * the shell to open the error dialog in - */ - public static void handleError(Shell shell, Exception exception, String title, String message) { - IStatus status = null; - boolean log = false; - boolean dialog = false; - Throwable t = exception; - if (exception instanceof TeamException) { - status = ((TeamException) exception).getStatus(); - log = false; - dialog = true; - } else if (exception instanceof InvocationTargetException) { - t = ((InvocationTargetException) exception).getTargetException(); - if (t instanceof TeamException) { - status = ((TeamException) t).getStatus(); - log = false; - dialog = true; - } else if (t instanceof CoreException) { - status = ((CoreException) t).getStatus(); - log = true; - dialog = true; - } else if (t instanceof InterruptedException) { - return; - } else { - status = new Status(IStatus.ERROR, TeamUIPlugin.ID, 1, Policy.bind("TeamAction.internal"), t); //$NON-NLS-1$ - log = true; - dialog = true; - } - } - if (status == null) - return; - if (!status.isOK()) { - IStatus toShow = status; - if (status.isMultiStatus()) { - IStatus[] children = status.getChildren(); - if (children.length == 1) { - toShow = children[0]; - } - } - if (title == null) { - title = status.getMessage(); - } - if (message == null) { - message = status.getMessage(); - } - if (dialog && shell != null) { - ErrorDialog.openError(shell, title, message, toShow); - } - if (log || shell == null) { - TeamUIPlugin.log(toShow.getSeverity(), message, t); - } - } - } - - public static void runWithProgress(Shell parent, boolean cancelable, final IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { - boolean createdShell = false; - try { - if (parent == null || parent.isDisposed()) { - Display display = Display.getCurrent(); - if (display == null) { - // cannot provide progress (not in UI thread) - runnable.run(new NullProgressMonitor()); - return; - } - // get the active shell or a suitable top-level shell - parent = display.getActiveShell(); - if (parent == null) { - parent = new Shell(display); - createdShell = true; - } - } - // pop up progress dialog after a short delay - final Exception[] holder = new Exception[1]; - BusyIndicator.showWhile(parent.getDisplay(), new Runnable() { - - public void run() { - try { - runnable.run(new NullProgressMonitor()); - } catch (InvocationTargetException e) { - holder[0] = e; - } catch (InterruptedException e) { - holder[0] = e; - } - } - }); - if (holder[0] != null) { - if (holder[0] instanceof InvocationTargetException) { - throw (InvocationTargetException) holder[0]; - } else { - throw (InterruptedException) holder[0]; - } - } - //new TimeoutProgressMonitorDialog(parent, TIMEOUT).run(true - // /*fork*/, cancelable, runnable); - } finally { - if (createdShell) - parent.dispose(); - } - } - - /** - * Creates a progress monitor and runs the specified runnable. - * @param parent - * the parent Shell for the dialog - * @param cancelable - * if true, the dialog will support cancelation - * @param runnable - * the runnable - * @exception InvocationTargetException - * when an exception is thrown from the runnable - * @exception InterruptedException - * when the progress monitor is cancelled - */ - public static void runWithProgressDialog(Shell parent, boolean cancelable, final IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { - new ProgressMonitorDialog(parent).run(cancelable, cancelable, runnable); - } - - public static Shell getShell(IWorkbenchSite site) { - if(site != null) { - Shell shell = site.getShell(); - if (!shell.isDisposed()) - return shell; - } - IWorkbench workbench = TeamUIPlugin.getPlugin().getWorkbench(); - if (workbench != null) { - IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); - if (window != null) { - return window.getShell(); - } - } - // Fallback to using the display - Display display = Display.getDefault(); - if (display.isDisposed()) return null; - return new Shell(display); - } - /* - * This method is only for use by the Target Management feature (see bug - * 16509). @param t - */ - public static void handle(Throwable t) { - IStatus error = null; - if (t instanceof InvocationTargetException) { - t = ((InvocationTargetException) t).getTargetException(); - } - if (t instanceof CoreException) { - error = ((CoreException) t).getStatus(); - } else if (t instanceof TeamException) { - error = ((TeamException) t).getStatus(); - } else { - error = new Status(IStatus.ERROR, TeamUIPlugin.ID, 1, Policy.bind("simpleInternal"), t); //$NON-NLS-1$ - } - Shell shell = new Shell(Display.getDefault()); - if (error.getSeverity() == IStatus.INFO) { - MessageDialog.openInformation(shell, Policy.bind("information"), error.getMessage()); //$NON-NLS-1$ - } else { - ErrorDialog.openError(shell, Policy.bind("exception"), null, error); //$NON-NLS-1$ - } - shell.dispose(); - // Let's log non-team exceptions - if (!(t instanceof TeamException)) { - TeamUIPlugin.log(error.getSeverity(), error.getMessage(), t); - } - } - - public static Shell findShell() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if(window != null) { - return window.getShell(); - } - Display display= Display.getCurrent(); - if (display == null) { - display= Display.getDefault(); - return display.getActiveShell(); - } - // worst case, just create our own. - return new Shell(TeamUIPlugin.getStandardDisplay()); - } - - public static IWorkbenchPartSite findSite(Control c) { - while (c != null && !c.isDisposed()) { - Object data = c.getData(); - if (data instanceof IWorkbenchPart) - return ((IWorkbenchPart) data).getSite(); - c = c.getParent(); - } - return null; - } - - public static IWorkbenchPartSite findSite() { - IWorkbench workbench = TeamUIPlugin.getPlugin().getWorkbench(); - IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - if (page != null) { - IWorkbenchPart part = page.getActivePart(); - if (part != null) - return part.getSite(); - } - } - return null; - } - - public static void initAction(IAction a, String prefix) { - Utils.initAction(a, prefix, Policy.bundle); - } - - public static void updateLabels(SyncInfo sync, CompareConfiguration config) { - final IResourceVariant remote = sync.getRemote(); - final IResourceVariant base = sync.getBase(); - String localContentId = sync.getLocalContentIdentifier(); - if (localContentId != null) { - config.setLeftLabel(Policy.bind("SyncInfoCompareInput.localLabelExists", localContentId)); //$NON-NLS-1$ - } else { - config.setLeftLabel(Policy.bind("SyncInfoCompareInput.localLabel")); //$NON-NLS-1$ - } - if (remote != null) { - config.setRightLabel(Policy.bind("SyncInfoCompareInput.remoteLabelExists", remote.getContentIdentifier())); //$NON-NLS-1$ - } else { - config.setRightLabel(Policy.bind("SyncInfoCompareInput.remoteLabel")); //$NON-NLS-1$ - } - if (base != null) { - config.setAncestorLabel(Policy.bind("SyncInfoCompareInput.baseLabelExists", base.getContentIdentifier())); //$NON-NLS-1$ - } else { - config.setAncestorLabel(Policy.bind("SyncInfoCompareInput.baseLabel")); //$NON-NLS-1$ - } - } - - /** - * Initialize the given Action from a ResourceBundle. - */ - public static void initAction(IAction a, String prefix, ResourceBundle bundle) { - String labelKey = "label"; //$NON-NLS-1$ - String tooltipKey = "tooltip"; //$NON-NLS-1$ - String imageKey = "image"; //$NON-NLS-1$ - String descriptionKey = "description"; //$NON-NLS-1$ - if (prefix != null && prefix.length() > 0) { - labelKey = prefix + labelKey; - tooltipKey = prefix + tooltipKey; - imageKey = prefix + imageKey; - descriptionKey = prefix + descriptionKey; - } - String s = Policy.bind(labelKey, bundle); - if (s != null) - a.setText(s); - s = Policy.bind(tooltipKey, bundle); - if (s != null) - a.setToolTipText(s); - s = Policy.bind(descriptionKey, bundle); - if (s != null) - a.setDescription(s); - String relPath = Policy.bind(imageKey, bundle); - if (relPath != null && !relPath.equals(imageKey) && relPath.trim().length() > 0) { - String cPath; - String dPath; - String ePath; - if (relPath.indexOf("/") >= 0) { //$NON-NLS-1$ - String path = relPath.substring(1); - dPath = 'd' + path; - ePath = 'e' + path; - } else { - dPath = "dlcl16/" + relPath; //$NON-NLS-1$ - ePath = "elcl16/" + relPath; //$NON-NLS-1$ - } - ImageDescriptor id = TeamImages.getImageDescriptor(dPath); - if (id != null) - a.setDisabledImageDescriptor(id); - id = TeamUIPlugin.getImageDescriptor(ePath); - if (id != null) - a.setImageDescriptor(id); - } - } - - public static String modeToString(int mode) { - switch (mode) { - case ISynchronizePageConfiguration.INCOMING_MODE : - return Policy.bind("Utils.22"); //$NON-NLS-1$ - case ISynchronizePageConfiguration.OUTGOING_MODE : - return Policy.bind("Utils.23"); //$NON-NLS-1$ - case ISynchronizePageConfiguration.BOTH_MODE : - return Policy.bind("Utils.24"); //$NON-NLS-1$ - case ISynchronizePageConfiguration.CONFLICTING_MODE : - return Policy.bind("Utils.25"); //$NON-NLS-1$ - } - return Policy.bind("Utils.26"); //$NON-NLS-1$ - } - - public static String workingSetToString(IWorkingSet set, int maxLength) { - String text = Policy.bind("StatisticsPanel.noWorkingSet"); //$NON-NLS-1$ - if (set != null) { - text = set.getName(); - if (text.length() > maxLength) { - text = text.substring(0, maxLength - 3) + "..."; //$NON-NLS-1$ - } - } - return text; - } - - /** - * Returns the list of resources contained in the given elements. - * @param elements - * @return the list of resources contained in the given elements. - */ - public static IResource[] getResources(Object[] elements) { - List resources = new ArrayList(); - for (int i = 0; i < elements.length; i++) { - Object element = elements[i]; - IResource resource = null; - if (element instanceof IResource) { - resource = (IResource)element; - } else if (element instanceof ISynchronizeModelElement){ - resource = ((ISynchronizeModelElement) element).getResource(); - } else { - resource = (IResource)getAdapter(element, IResource.class); - if(resource != null && resource.getType() == IResource.ROOT) continue; - } - if (resource != null) { - resources.add(resource); - } - } - return (IResource[]) resources.toArray(new IResource[resources.size()]); - } - - public static Object getAdapter(Object element, Class adapter) { - if (element instanceof IAdaptable) { - return ((IAdaptable) element).getAdapter(adapter); - } - return null; - } - - /** - * This method returns all out-of-sync SyncInfos that are in the current - * selection. - * - * @return the list of selected sync infos - */ - public static IDiffElement[] getDiffNodes(Object[] selected) { - Set result = new HashSet(); - for (int i = 0; i < selected.length; i++) { - Object object = selected[i]; - if(object instanceof IDiffElement) { - collectAllNodes((IDiffElement)object, result); - } - } - return (IDiffElement[]) result.toArray(new IDiffElement[result.size()]); - } - - private static void collectAllNodes(IDiffElement element, Set nodes) { - if(element.getKind() != SyncInfo.IN_SYNC) { - nodes.add(element); - } - if(element instanceof IDiffContainer) { - IDiffElement[] children = ((IDiffContainer)element).getChildren(); - for (int i = 0; i < children.length; i++) { - collectAllNodes(children[i], nodes); - } - } - } - - public static void schedule(Job job, IWorkbenchSite site) { - if (site != null) { - IWorkbenchSiteProgressService siteProgress = (IWorkbenchSiteProgressService) site.getAdapter(IWorkbenchSiteProgressService.class); - if (siteProgress != null) { - siteProgress.schedule(job, 0, true /* use half-busy cursor */); - return; - } - } - job.schedule(); - } - - public static byte[] readBytes(InputStream in) { - ByteArrayOutputStream bos= new ByteArrayOutputStream(); - try { - while (true) { - int c= in.read(); - if (c == -1) - break; - bos.write(c); - } - - } catch (IOException ex) { - return null; - - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException x) { - // silently ignored - } - } - try { - bos.close(); - } catch (IOException x) { - // silently ignored - } - } - return bos.toByteArray(); - } - - public static boolean equalObject(Object o1, Object o2) { - if (o1 == null && o2 == null) return true; - if (o1 == null || o2 == null) return false; - return o1.equals(o2); - } - - public static String getKey(String id, String secondaryId) { - return secondaryId == null ? id : id + '/' + secondaryId; - } - - public static String stripAmpersand(String string) { - if( string.indexOf('&') != -1) { - StringBuffer buffer = new StringBuffer(string); - char last = 'x'; - for (int i = string.length()-1; i > -1; i--) { - char c = string.charAt(i); - if(c == '&') { - buffer.deleteCharAt(i); - break; - } - } - return buffer.toString(); - } - return string; - } - - public static String convertSelection(IResource[] resources, int numElements) { - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < resources.length && i < numElements; i++) { - IResource resource = resources[i]; - if(i > 0) buffer.append(", "); - buffer.append(resource.getFullPath()); - } - if(numElements < resources.length) buffer.append("..."); - return buffer.toString(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ConfigureProjectAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ConfigureProjectAction.java deleted file mode 100644 index 2ec58ed3b..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ConfigureProjectAction.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.actions; - - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard; - -/** - * Action for configuring a project. Configuring involves associating - * the project with a Team provider and performing any provider-specific - * configuration that is necessary. - */ -public class ConfigureProjectAction extends TeamAction { - private static class ResizeWizardDialog extends WizardDialog { - public ResizeWizardDialog(Shell parentShell, IWizard newWizard) { - super(parentShell, newWizard); - setShellStyle(getShellStyle() | SWT.RESIZE); - } - } - - /* - * Method declared on IActionDelegate. - */ - public void run(IAction action) { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - IProject project = getSelectedProjects()[0]; - ConfigureProjectWizard wizard = new ConfigureProjectWizard(); - wizard.init(null, project); - WizardDialog dialog = new ResizeWizardDialog(getShell(), wizard); - //dialog. - dialog.open(); - } catch (Exception e) { - throw new InvocationTargetException(e); - } - } - }, Policy.bind("ConfigureProjectAction.configureProject"), PROGRESS_BUSYCURSOR); //$NON-NLS-1$ - } - /** - * @see TeamAction#isEnabled() - */ - protected boolean isEnabled() { - IProject[] selectedProjects = getSelectedProjects(); - if (selectedProjects.length != 1) return false; - if (!selectedProjects[0].isAccessible()) return false; - if (!RepositoryProvider.isShared(selectedProjects[0])) return true; - return false; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ITeamRunnableContext.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ITeamRunnableContext.java deleted file mode 100644 index 184b68241..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ITeamRunnableContext.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Shell; - -/** - * An ITeamRunnableContext is used to provide the context for a Team operation. - * The hierarchy of contexts is used to configure the following: - * 1) whether the operation is run in the background as a job - * 2) whether the operation modifies the workspace - * 3) what shell the operation should use to display info to the user - */ -public interface ITeamRunnableContext { - - /** - * Run the given runnable in the context of the receiver. By default, the - * progress is provided by the active workbench windows but subclasses may - * override this to provide progress in some other way (Progress Monitor or - * job). - */ - public abstract void run(IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException; - - /** - * Get a shell that can be used to prompt the user. - * @return a shell - */ - public abstract Shell getShell(); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/JobRunnableContext.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/JobRunnableContext.java deleted file mode 100644 index 5da78972b..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/JobRunnableContext.java +++ /dev/null @@ -1,183 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.actions; - -import java.lang.reflect.InvocationTargetException; -import java.net.URL; -import org.eclipse.core.resources.WorkspaceJob; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.*; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.ui.progress.IProgressConstants; - -/** - * This runnable context executes it's operation in the context of a background job. - */ -public final class JobRunnableContext implements ITeamRunnableContext { - - private IJobChangeListener listener; - private IWorkbenchSite site; - private String jobName; - private ISchedulingRule schedulingRule; - private boolean postponeBuild; - private boolean isUser; - private URL icon; - private boolean keep; - private IAction gotoAction; - - public JobRunnableContext(String jobName) { - this(jobName, null, null, false, null, null); - } - - public JobRunnableContext(String jobName, URL icon, IAction action, boolean keep, IJobChangeListener listener, IWorkbenchSite site) { - this.jobName = jobName; - this.listener = listener; - this.site = site; - // By default team actions are user initiated. - this.isUser = true; - this.gotoAction = action; - this.icon = icon; - this.keep = keep; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.ITeamRunnableContext#run(java.lang.String, boolean, org.eclipse.jface.operation.IRunnableWithProgress) - */ - public void run(IRunnableWithProgress runnable) { - Job job; - if (schedulingRule == null && !postponeBuild) { - job = getBasicJob(runnable); - } else { - job = getWorkspaceJob(runnable); - if (schedulingRule != null) { - job.setRule(schedulingRule); - } - } - if (listener != null) { - job.addJobChangeListener(listener); - } - job.setUser(isUser()); - configureJob(job); - Utils.schedule(job, site); - } - - private void configureJob(Job job) { - if(keep) - job.setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE); - if(gotoAction != null) - job.setProperty(IProgressConstants.ACTION_PROPERTY, gotoAction); - if(icon != null) - job.setProperty(IProgressConstants.ICON_PROPERTY, icon); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.ITeamRunnableContext#getShell() - */ - public Shell getShell() { - final Shell[] newShell = new Shell[] { null }; - Display.getDefault().syncExec( - new Runnable() { - public void run() { - newShell[0] = Utils.getShell(site); - } - }); - return newShell[0]; - } - - /** - * Returns whether the auto-build will be postponed while this - * context is executing a runnable. - * @return whether the auto-build will be postponed while this - * context is executing a runnable. - */ - public boolean isPostponeBuild() { - return postponeBuild; - } - - /** - * Set whether the auto-build will be postponed while this - * context is executing a runnable. - * @param postponeBuild whether to postpone the auto-build. - */ - public void setPostponeBuild(boolean postponeBuild) { - this.postponeBuild = postponeBuild; - } - - /** - * Return the scheduling rule that will be obtained before the context - * executes a runnable or <code>null</code> if no scheduling rule is to be onbtained. - * @return the schedulingRule to be obtained or <code>null</code>. - */ - public ISchedulingRule getSchedulingRule() { - return schedulingRule; - } - - /** - * Return whether this job context is user initiated. - * @param boolean <code>true</code> if the job is a result of a user initiated actions - * and <code>false</code> otherwise. - */ - public boolean isUser() { - return isUser; - } - - /** - * Set wheter the job is user initiated. By default the job created by this runnable context - * is a user job. - * @param isUser <code>true</code> if the job is a result of a user initiated actions - * and <code>false</code> otherwise. - */ - public void setUser(boolean isUser) { - this.isUser = isUser; - } - - /** - * Set the scheduling rule that will be obtained before the context - * executes a runnable or <code>null</code> if no scheduling rule is to be onbtained. - * @param schedulingRule The schedulingRule to be obtained or <code>null</code>. - */ - public void setSchedulingRule(ISchedulingRule schedulingRule) { - this.schedulingRule = schedulingRule; - } - - /* private */ IStatus run(IRunnableWithProgress runnable, IProgressMonitor monitor) { - try { - runnable.run(monitor); - } catch (InvocationTargetException e) { - return TeamException.asTeamException(e).getStatus(); - } catch (InterruptedException e) { - return Status.OK_STATUS; - } - return Status.OK_STATUS; - } - - private Job getBasicJob(final IRunnableWithProgress runnable) { - return new Job(jobName) { - public IStatus run(IProgressMonitor monitor) { - return JobRunnableContext.this.run(runnable, monitor); - } - }; - } - - private Job getWorkspaceJob(final IRunnableWithProgress runnable) { - return new WorkspaceJob(jobName) { - public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { - return JobRunnableContext.this.run(runnable, monitor); - } - }; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ProgressDialogRunnableContext.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ProgressDialogRunnableContext.java deleted file mode 100644 index 0896533b1..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ProgressDialogRunnableContext.java +++ /dev/null @@ -1,152 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.progress.IProgressService; - -/** - * This CVS runnable context blocks the UI and can therfore have a shell assigned to - * it (since the shell won't be closed by the user before the runnable completes. - */ -public class ProgressDialogRunnableContext implements ITeamRunnableContext { - - private Shell shell; - private IRunnableContext runnableContext; - private ISchedulingRule schedulingRule; - private boolean postponeBuild; - - public ProgressDialogRunnableContext(Shell shell) { - this.shell = shell; - } - - /** - * Returns whether the auto-build will be postponed while this - * context is executing a runnable. - * @return whether the auto-build will be postponed while this - * context is executing a runnable. - */ - public boolean isPostponeBuild() { - return postponeBuild; - } - - /** - * Set whether the auto-build will be postponed while this - * context is executing a runnable. - * @param postponeBuild whether to postpone the auto-build. - */ - public void setPostponeBuild(boolean postponeBuild) { - this.postponeBuild = postponeBuild; - } - - /** - * Return the scheduling rule that will be obtained before the context - * executes a runnable or <code>null</code> if no scheduling rule is to be onbtained. - * @return the schedulingRule to be obtained or <code>null</code>. - */ - public ISchedulingRule getSchedulingRule() { - return schedulingRule; - } - - /** - * Set the scheduling rule that will be obtained before the context - * executes a runnable or <code>null</code> if no scheduling rule is to be onbtained. - * @param schedulingRule The schedulingRule to be obtained or <code>null</code>. - */ - public void setSchedulingRule(ISchedulingRule schedulingRule) { - this.schedulingRule = schedulingRule; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSRunnableContext#getShell() - */ - public Shell getShell() { - return shell; - } - - /** - * Set the runnable context that is used to execute the runnable. By default, - * the workbench's progress service is used by clients can provide their own. - * @param runnableContext the runnable contentx used to execute runnables. - */ - public void setRunnableContext(IRunnableContext runnableContext) { - this.runnableContext = runnableContext; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.ITeamRunnableContext#run(org.eclipse.jface.operation.IRunnableWithProgress) - */ - public void run(IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { - getRunnableContext().run(true /* fork */, true /* cancelable */, wrapRunnable(runnable)); - } - - private IRunnableContext getRunnableContext() { - if (runnableContext == null) { - return new IRunnableContext() { - public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) - throws InvocationTargetException, InterruptedException { - IProgressService manager = PlatformUI.getWorkbench().getProgressService(); - manager.busyCursorWhile(runnable); - } - }; - } - return runnableContext; - } - - /* - * Return an IRunnableWithProgress that sets the task name for the progress monitor - * and runs in a workspace modify operation if requested. - */ - private IRunnableWithProgress wrapRunnable(final IRunnableWithProgress runnable) { - return new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - if (schedulingRule == null && !postponeBuild) { - runnable.run(monitor); - } else { - final Exception[] exception = new Exception[] { null }; - ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { - public void run(IProgressMonitor pm) throws CoreException { - try { - runnable.run(pm); - } catch (InvocationTargetException e) { - exception[0] = e; - } catch (InterruptedException e) { - exception[0] = e; - } - } - }, schedulingRule, 0 /* allow updates */, monitor); - if (exception[0] != null) { - if (exception[0] instanceof InvocationTargetException) { - throw (InvocationTargetException)exception[0]; - } else if (exception[0] instanceof InterruptedException) { - throw (InterruptedException)exception[0]; - } - } - } - } catch (CoreException e) { - throw new InvocationTargetException(e); - } - } - }; - } - -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java deleted file mode 100644 index 706fe6d96..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java +++ /dev/null @@ -1,362 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.actions; - - -import java.lang.reflect.Array; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.core.TeamPlugin; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.ActionDelegate; - -/** - * The abstract superclass of all Team actions. This class contains some convenience - * methods for getting selected objects and mapping selected objects to their - * providers. - * - * Team providers may subclass this class when creating their actions. - * Team providers may also instantiate or subclass any of the - * subclasses of TeamAction provided in this package. - */ -public abstract class TeamAction extends ActionDelegate implements IObjectActionDelegate, IViewActionDelegate { - // The current selection - protected IStructuredSelection selection; - - // The shell, required for the progress dialog - protected Shell shell; - - // Constants for determining the type of progress. Subclasses may - // pass one of these values to the run method. - public final static int PROGRESS_DIALOG = 1; - public final static int PROGRESS_BUSYCURSOR = 2; - public final static int PROGRESS_WORKBENCH_WINDOW = 3; - - private IWorkbenchPart targetPart; - - /** - * Creates an array of the given class type containing all the - * objects in the selection that adapt to the given class. - * - * @param selection - * @param c - * @return - */ - public static Object[] getSelectedAdaptables(ISelection selection, Class c) { - ArrayList result = null; - if (!selection.isEmpty()) { - result = new ArrayList(); - Iterator elements = ((IStructuredSelection) selection).iterator(); - while (elements.hasNext()) { - Object adapter = getAdapter(elements.next(), c); - if (c.isInstance(adapter)) { - result.add(adapter); - } - } - } - if (result != null && !result.isEmpty()) { - return (Object[])result.toArray((Object[])Array.newInstance(c, result.size())); - } - return (Object[])Array.newInstance(c, 0); - } - - /** - * Find the object associated with the given object when it is adapted to - * the provided class. Null is returned if the given object does not adapt - * to the given class - * - * @param selection - * @param c - * @return Object - */ - public static Object getAdapter(Object adaptable, Class c) { - if (c.isInstance(adaptable)) { - return adaptable; - } - if (adaptable instanceof IAdaptable) { - IAdaptable a = (IAdaptable) adaptable; - Object adapter = a.getAdapter(c); - if (c.isInstance(adapter)) { - return adapter; - } - } - return null; - } - - /** - * Returns the selected projects. - * - * @return the selected projects - */ - protected IProject[] getSelectedProjects() { - IResource[] selectedResources = getSelectedResources(); - if (selectedResources.length == 0) return new IProject[0]; - ArrayList projects = new ArrayList(); - for (int i = 0; i < selectedResources.length; i++) { - IResource resource = selectedResources[i]; - if (resource.getType() == IResource.PROJECT) { - projects.add(resource); - } - } - return (IProject[]) projects.toArray(new IProject[projects.size()]); - } - - /** - * Returns an array of the given class type c that contains all - * instances of c that are either contained in the selection or - * are adapted from objects contained in the selection. - * - * @param c - * @return - */ - protected Object[] getSelectedResources(Class c) { - return getSelectedAdaptables(selection, c); - } - - /** - * Returns the selected resources. - * - * @return the selected resources - */ - protected IResource[] getSelectedResources() { - return (IResource[])getSelectedResources(IResource.class); - } - - /** - * Convenience method for getting the current shell. - * - * @return the shell - */ - protected Shell getShell() { - if (shell != null) { - return shell; - } else { - IWorkbench workbench = TeamUIPlugin.getPlugin().getWorkbench(); - if (workbench == null) return null; - IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); - if (window == null) return null; - return window.getShell(); - } - } - /** - * Convenience method for running an operation with progress and - * error feedback. - * - * @param runnable the runnable which executes the operation - * @param problemMessage the message to display in the case of errors - * @param progressKind one of PROGRESS_BUSYCURSOR or PROGRESS_DIALOG - */ - final protected void run(final IRunnableWithProgress runnable, final String problemMessage, int progressKind) { - final Exception[] exceptions = new Exception[] {null}; - switch (progressKind) { - case PROGRESS_WORKBENCH_WINDOW : - try { - PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(true, true, runnable); - } catch (InterruptedException e1) { - exceptions[0] = null; - e1.printStackTrace(); - } catch (InvocationTargetException e) { - exceptions[0] = e; - } - break; - case PROGRESS_BUSYCURSOR : - BusyIndicator.showWhile(Display.getCurrent(), new Runnable() { - public void run() { - try { - runnable.run(new NullProgressMonitor()); - } catch (InvocationTargetException e) { - exceptions[0] = e; - } catch (InterruptedException e) { - exceptions[0] = null; - } - } - }); - break; - default : - case PROGRESS_DIALOG : - try { - new ProgressMonitorDialog(getShell()).run(true, true, runnable); - } catch (InvocationTargetException e) { - exceptions[0] = e; - } catch (InterruptedException e) { - exceptions[0] = null; - } - break; - } - if (exceptions[0] != null) { - handle(exceptions[0], null, problemMessage); - } - } - - /* - * Method declared on IActionDelegate. - */ - public void selectionChanged(IAction action, ISelection selection) { - if (selection instanceof IStructuredSelection) { - this.selection = (IStructuredSelection) selection; - if (action != null) { - setActionEnablement(action); - } - } - } - - /** - * Method invoked from <code>selectionChanged(IAction, ISelection)</code> - * to set the enablement status of the action. The instance variable - * <code>selection</code> will contain the latest selection so the methods - * <code>getSelectedResources()</code> and <code>getSelectedProjects()</code> - * will provide the proper objects. - * - * This method can be overridden by subclasses but should not be invoked by them. - */ - protected void setActionEnablement(IAction action) { - try { - action.setEnabled(isEnabled()); - } catch (TeamException e) { - if (e.getStatus().getCode() == IResourceStatus.OUT_OF_SYNC_LOCAL) { - // Enable the action to allow the user to discover the problem - action.setEnabled(true); - } else { - action.setEnabled(false); - // We should not open a dialog when determining menu enablements so log it instead - TeamPlugin.log(e); - } - } - } - - /* - * Method declared on IObjectActionDelegate. - */ - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - if(targetPart != null) { - this.shell = targetPart.getSite().getShell(); - this.targetPart = targetPart; - } - } - /** - * Shows the given errors to the user. - * - * @param status the status containing the error - * @param title the title of the error dialog - * @param message the message for the error dialog - * @param shell the shell to open the error dialog in - */ - protected void handle(Exception exception, String title, String message) { - Utils.handleError(getShell(), exception, title, message); - } - - /** - * Concrete action enablement code. - * Subclasses must implement. - * - * @return whether the action is enabled - * @throws TeamException if an error occurs during enablement detection - */ - abstract protected boolean isEnabled() throws TeamException; - - /** - * Convenience method that maps the selected resources to their providers. - * The returned Hashtable has keys which are ITeamProviders, and values - * which are Lists of IResources that are shared with that provider. - * - * @return a hashtable mapping providers to their selected resources - */ - protected Hashtable getProviderMapping() { - return getProviderMapping(getSelectedResources()); - } - /** - * Convenience method that maps the given resources to their providers. - * The returned Hashtable has keys which are ITeamProviders, and values - * which are Lists of IResources that are shared with that provider. - * - * @return a hashtable mapping providers to their resources - */ - protected Hashtable getProviderMapping(IResource[] resources) { - Hashtable result = new Hashtable(); - for (int i = 0; i < resources.length; i++) { - RepositoryProvider provider = RepositoryProvider.getProvider(resources[i].getProject()); - List list = (List)result.get(provider); - if (list == null) { - list = new ArrayList(); - result.put(provider, list); - } - list.add(resources[i]); - } - return result; - } - - /** - * @return IWorkbenchPart - */ - protected IWorkbenchPart getTargetPart() { - return targetPart; - } - - /** - * Return the path that was active when the menu item was selected. - * @return IWorkbenchPage - */ - protected IWorkbenchPage getTargetPage() { - if (getTargetPart() == null) return TeamUIPlugin.getActivePage(); - return getTargetPart().getSite().getPage(); - } - - /** - * Show the view with the given ID in the perspective from which the action - * was executed. Returns null if the view is not registered. - * - * @param viewId - * @return IViewPart - */ - protected IViewPart showView(String viewId) { - try { - return getTargetPage().showView(viewId); - } catch (PartInitException pe) { - return null; - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) - */ - public void init(IViewPart view) { - targetPart = view; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DetailsDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DetailsDialog.java deleted file mode 100644 index 3d8ac1177..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DetailsDialog.java +++ /dev/null @@ -1,310 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.dialogs; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; - -/** - * A simple superclass for detail button dialogs. - */ -abstract public class DetailsDialog extends Dialog { - /** - * The Details button. - */ - private Button detailsButton; - - /** - * The Ok button. - */ - private Button okButton; - - /** - * The title of the dialog. - */ - private String title; - - /** - * The error message - */ - private Label errorMessageLabel; - - /** - * The SWT list control that displays the error details. - */ - private Composite detailsComposite; - - /** - * Indicates whether the error details viewer is currently created. - */ - private boolean detailsCreated = false; - - /** - * The key for the image to be displayed (one of the image constants on Dialog) - */ - private String imageKey = null; - - /** - * Creates a details pane dialog. - * Note that the dialog will have no visual representation (no widgets) - * until it is told to open. - * - * @param parentShell the shell under which to create this dialog - * @param dialogTitle the title to use for this dialog - * @param message the message to show in this dialog - * @param status the error to show to the user - * @param displayMask the mask to use to filter the displaying of child items, - * as per <code>IStatus.matches</code> - * @see org.eclipse.core.runtime.IStatus#matches - */ - public DetailsDialog(Shell parentShell, String dialogTitle) { - super(parentShell); - this.title = dialogTitle; - setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL); - } - - /* (non-Javadoc) - * Method declared on Dialog. - * Handles the pressing of the Ok or Details button in this dialog. - * If the Ok button was pressed then close this dialog. If the Details - * button was pressed then toggle the displaying of the error details area. - * Note that the Details button will only be visible if the error being - * displayed specifies child details. - */ - protected void buttonPressed(int id) { - if (id == IDialogConstants.DETAILS_ID) { // was the details button pressed? - toggleDetailsArea(); - } else { - super.buttonPressed(id); - } - } - - /* (non-Javadoc) - * Method declared in Window. - */ - protected void configureShell(Shell shell) { - super.configureShell(shell); - shell.setText(title); - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected void createButtonsForButtonBar(Composite parent) { - // create OK and Details buttons - if(includeOkButton()) { - okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - } - if (includeCancelButton()) { - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - if(includeDetailsButton()) { - detailsButton = createButton(parent, IDialogConstants.DETAILS_ID, getDetailsButtonLabelShow(), false); - } - updateEnablements(); - } - - protected String getDetailsButtonLabelShow() { - return IDialogConstants.SHOW_DETAILS_LABEL; - } - - protected String getDetailsButtonLabelHide() { - return IDialogConstants.HIDE_DETAILS_LABEL; - } - - /* (non-Javadoc) - * Method declared on Dialog. - * Creates and returns the contents of the upper part - * of the dialog (above the button bar). - */ - final protected Control createDialogArea(Composite parent) { - // create composite - Composite composite = (Composite)super.createDialogArea(parent); - - // create image - String key = getImageKey(); - Image image = null; - if (key != null) { - image = JFaceResources.getImageRegistry().get(key); - } - if (image != null) { - // create a composite to split the dialog area in two - Composite top = new Composite(composite, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.verticalSpacing = 0; - layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - layout.numColumns = 2; - top.setLayout(layout); - top.setLayoutData(new GridData(GridData.FILL_BOTH)); - - // add the image to the left of the composite - Label label = new Label(top, 0); - image.setBackground(label.getBackground()); - label.setImage(image); - label.setLayoutData(new GridData( - GridData.HORIZONTAL_ALIGN_CENTER | - GridData.VERTICAL_ALIGN_BEGINNING)); - - // add a composite to the right to contain the custom components - Composite right = new Composite(top, SWT.NONE); - layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - right.setLayout(layout); - right.setLayoutData(new GridData(GridData.FILL_BOTH)); - createMainDialogArea(right); - } else { - createMainDialogArea(composite); - } - - if(includeErrorMessage()) { - errorMessageLabel = new Label(composite, SWT.NONE); - errorMessageLabel.setLayoutData(new GridData( - GridData.GRAB_HORIZONTAL | - GridData.HORIZONTAL_ALIGN_FILL)); - errorMessageLabel.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_RED)); - } - - Dialog.applyDialogFont(parent); - return composite; - } - - /** - * Creates the dialog's top composite - * - * @param parent the parent composite - */ - abstract protected void createMainDialogArea(Composite parent); - - /** - * Create this dialog's drop-down list component. - * - * @param parent the parent composite - * @return the drop-down list component - */ - abstract protected Composite createDropDownDialogArea(Composite parent); - - /** - * Toggles the unfolding of the details area. This is triggered by - * the user pressing the details button. - */ - private void toggleDetailsArea() { - Point windowSize = getShell().getSize(); - Point oldSize = getContents().computeSize(SWT.DEFAULT, SWT.DEFAULT); - - if (detailsCreated) { - detailsComposite.dispose(); - detailsCreated = false; - detailsButton.setText(getDetailsButtonLabelShow()); - } else { - detailsComposite = createDropDownDialogArea((Composite)getContents()); - detailsCreated = true; - detailsButton.setText(getDetailsButtonLabelHide()); - } - Dialog.applyDialogFont(getContents()); - Point newSize = getContents().computeSize(SWT.DEFAULT, SWT.DEFAULT); - - getShell().setSize(new Point(windowSize.x, windowSize.y + (newSize.y - oldSize.y))); - } - - final protected void setErrorMessage(String error) { - if(errorMessageLabel != null) { - if(error == null || error.length() == 0) { - errorMessageLabel.setText(""); //$NON-NLS-1$ - } else { - errorMessageLabel.setText(error); - } - errorMessageLabel.update(); - } - } - - final protected void setPageComplete(boolean complete) { - if(okButton != null ) { - okButton.setEnabled(complete); - } - } - - abstract protected void updateEnablements(); - - protected boolean includeCancelButton() { - return true; - } - - protected boolean includeOkButton() { - return true; - } - - /** - * Returns the imageKey. - * @return String - */ - protected String getImageKey() { - return imageKey; - } - - - /** - * Sets the imageKey. - * @param imageKey The imageKey to set - */ - protected void setImageKey(String imageKey) { - this.imageKey = imageKey; - } - - protected static final int LABEL_WIDTH_HINT = 400; - protected Label createWrappingLabel(Composite parent, String text) { - Label label = new Label(parent, SWT.LEFT | SWT.WRAP); - label.setText(text); - GridData data = new GridData(); - data.horizontalSpan = 1; - data.horizontalAlignment = GridData.FILL; - data.horizontalIndent = 0; - data.grabExcessHorizontalSpace = true; - data.widthHint = LABEL_WIDTH_HINT; - label.setLayoutData(data); - return label; - } - - protected Composite createComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - return composite; - } - - protected boolean isDetailsVisible() { - return detailsCreated; - } - - protected boolean includeErrorMessage() { - return true; - } - - protected boolean includeDetailsButton() { - return true; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DetailsDialogWithProjects.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DetailsDialogWithProjects.java deleted file mode 100644 index 30dcc23c6..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DetailsDialogWithProjects.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.dialogs; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; - -/** - * Display a message with a details that can contain a list of projects - */ -public class DetailsDialogWithProjects extends DetailsDialog { - - private String message; - private String detailsTitle; - private IProject[] projects; - private org.eclipse.swt.widgets.List detailsList; - - private boolean includeCancelButton; - - /** - * Constructor for DetailsDialogWithProjects. - * @param parentShell - * @param dialogTitle - */ - public DetailsDialogWithProjects(Shell parentShell, String dialogTitle, String dialogMessage, String detailsTitle, IProject[] projects, boolean includeCancelButton, String imageKey) { - super(parentShell, dialogTitle); - setImageKey(imageKey); - this.message = dialogMessage; - this.detailsTitle = detailsTitle; - this.projects = projects; - this.includeCancelButton = includeCancelButton; - } - - /** - * @see DetailsDialog#createMainDialogArea(Composite) - */ - protected void createMainDialogArea(Composite composite) { - Label label = new Label(composite, SWT.WRAP); - label.setText(message); //$NON-NLS-1$ - GridData data = new GridData( - GridData.GRAB_HORIZONTAL | - GridData.GRAB_VERTICAL | - GridData.HORIZONTAL_ALIGN_FILL | - GridData.VERTICAL_ALIGN_CENTER); - data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); - label.setLayoutData(data); - updateEnablements(); - } - - /** - * @see DetailsDialog#createDropDownDialogArea(Composite) - */ - protected Composite createDropDownDialogArea(Composite parent) { - // create a composite with standard margins and spacing - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - detailsList = new org.eclipse.swt.widgets.List(composite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - GridData data = new GridData (); - data.heightHint = 75; - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - detailsList.setLayoutData(data); - - if (detailsTitle != null) { - detailsList.add(detailsTitle); - } - - for (int i = 0; i < projects.length; i++) { - IProject project = projects[i]; - detailsList.add(projects[i].getName()); //$NON-NLS-1$ - } - return composite; - } - - /** - * @see DetailsDialog#updateEnablements() - */ - protected void updateEnablements() { - setPageComplete(true); - } - - /** - * @see DetailsDialog#includeCancelButton() - */ - protected boolean includeCancelButton() { - return includeCancelButton; - } - -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DialogArea.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DialogArea.java deleted file mode 100644 index df4b19af6..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DialogArea.java +++ /dev/null @@ -1,218 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.dialogs; - -import java.util.*; -import java.util.List; - -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; - -/** - * 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; - - /** - * Create a dialog area - * @param parentDialog the parent dialog or <code>null</code> - * @param settings the dialog settings stroe or <code>null</code> - */ - protected 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 - * <code>null</code> 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); - } - - protected void firePropertyChangeChange(String property, Object oldValue, Object newValue) { - PropertyChangeEvent event = new PropertyChangeEvent(this, property, oldValue, newValue); - for (Iterator iter = listeners.iterator(); iter.hasNext();) { - IPropertyChangeListener listener = (IPropertyChangeListener) iter.next(); - listener.propertyChange(event); - } - } - - /** - * Code copied from <code>org.eclipse.jface.dialogs.Dialog</code> 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(); - } - - /** - * Create the area using the given parent as the containing composite - * @param parent - */ - public abstract void createArea(Composite parent); - - /** - * Returns a shell that can be used to show error conditions, etc. - * This method will return <code>null</code> if there is no parent dialog. - * @return a shell or <code>null</code> - */ - protected Shell getShell() { - if (parentDialog == null) { - return null; - } - 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, int style) { - 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(style); - 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 Button createRadioButton(Composite parent, String label, int span) { - Button button = new Button(parent, SWT.RADIO); - button.setText(label); - GridData data = new GridData(); - data.horizontalSpan = span; - 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; - } - protected Label createLabel(Composite parent, String text, int horizontalSpan) { - Label label = new Label(parent, SWT.LEFT); - label.setText(text); - GridData data = new GridData(); - data.horizontalSpan = horizontalSpan; - data.horizontalAlignment = GridData.FILL; - 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(font); - - // 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; - } - - /** - * 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 createGrabbingComposite(Composite parent, int numColumns) { - Composite composite = new Composite(parent, SWT.NULL); - Font font = parent.getFont(); - composite.setFont(font); - - // GridLayout - GridLayout layout = new GridLayout(); - layout.numColumns = numColumns; - layout.marginHeight = 0; - layout.marginWidth = 0; - composite.setLayout(layout); - - // GridData - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = true; - composite.setLayoutData(data); - return composite; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/IPromptCondition.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/IPromptCondition.java deleted file mode 100644 index 79f9b6c81..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/IPromptCondition.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.dialogs; - -import org.eclipse.core.resources.IResource; - -/** - * Input to a confirm prompt - * - * @see PromptingDialog - */ -public interface IPromptCondition { - /** - * Answers <code>true</code> if a prompt is required for this resource and - * false otherwise. - */ - public boolean needsPrompt(IResource resource); - - /** - * Answers the message to include in the prompt. - */ - public String promptMessage(IResource resource); -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java deleted file mode 100644 index 3bc3b6a5d..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java +++ /dev/null @@ -1,395 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.dialogs; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.preference.*; -import org.eclipse.jface.resource.*; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.internal.ui.Utils; - -public class PreferencePageContainerDialog extends Dialog implements IPreferencePageContainer { - - PreferencePage page; - - private class PageLayout extends Layout { - public void layout(Composite composite, boolean force) { - Rectangle rect = composite.getClientArea(); - Control [] children = composite.getChildren(); - for (int i= 0; i < children.length; i++) { - children[i].setSize(rect.width, rect.height); - } - } - public Point computeSize(Composite composite, int wHint, int hHint, boolean force) { - if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) - return new Point(wHint, hHint); - int x= fMinimumPageSize.x; - int y= fMinimumPageSize.y; - - Control[] children= composite.getChildren(); - for (int i= 0; i < children.length; i++) { - Point size= children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, force); - x= Math.max(x, size.x); - y= Math.max(y, size.y); - } - if (wHint != SWT.DEFAULT) x = wHint; - if (hHint != SWT.DEFAULT) y = hHint; - return new Point(x, y); - } - } - - private Composite fTitleArea; - private Label fTitleImage; - private CLabel fMessageLabel; - - private String fMessage; - private Color fNormalMsgAreaBackground; - private Image fErrorMsgImage; - - private Button fOkButton; - - /** - * Must declare our own images as the JFaceResource images will not be created unless - * a property/preference dialog has been shown - */ - protected static final String PREF_DLG_TITLE_IMG = "preference_page_container_image";//$NON-NLS-1$ - protected static final String PREF_DLG_IMG_TITLE_ERROR = "preference_page_container_title_error_image";//$NON-NLS-1$ - static { - ImageRegistry reg = TeamUIPlugin.getPlugin().getImageRegistry(); - reg.put(PREF_DLG_TITLE_IMG, ImageDescriptor.createFromFile(PreferenceDialog.class, "images/pref_dialog_title.gif"));//$NON-NLS-1$ - reg.put(PREF_DLG_IMG_TITLE_ERROR, ImageDescriptor.createFromFile(Dialog.class, "images/message_error.gif"));//$NON-NLS-1$ - } - - /** - * The Composite in which a page is shown. - */ - private Composite fPageContainer; - - /** - * The minimum page size; 200 by 200 by default. - * - * @see #setMinimumPageSize(Point) - */ - private Point fMinimumPageSize = new Point(200,200); - - public PreferencePageContainerDialog(Shell shell, PreferencePage page) { - super(shell); - this.page = page; - } - - /** - * @see Dialog#okPressed() - */ - protected void okPressed() { - final List changedProperties = new ArrayList(5); - getPreferenceStore().addPropertyChangeListener( new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - changedProperties.add(event.getProperty()); - } - }); - - page.performOk(); - - handleSave(); - - super.okPressed(); - } - - /** - * Sets the title for this dialog. - * @param title the title. - */ - public void setTitle(String title) { - Shell shell= getShell(); - if ((shell != null) && !shell.isDisposed()) { - shell.setText(title); - } - } - - /** - * @see Dialog#createDialogArea(Composite) - */ - protected Control createDialogArea(Composite parent) { - Composite composite = (Composite)super.createDialogArea(parent); - ((GridLayout) composite.getLayout()).numColumns = 1; - - // Build the title area and separator line - Composite titleComposite = new Composite(composite, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.verticalSpacing = 0; - layout.horizontalSpacing = 0; - titleComposite.setLayout(layout); - titleComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - createTitleArea(titleComposite); - - Label titleBarSeparator = new Label(titleComposite, SWT.HORIZONTAL | SWT.SEPARATOR); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - titleBarSeparator.setLayoutData(gd); - - // Build the Page container - fPageContainer = createPageContainer(composite); - fPageContainer.setLayoutData(new GridData(GridData.FILL_BOTH)); - - page.setContainer(this); - page.createControl(fPageContainer); - setTitle(page.getTitle()); - - // Build the separator line - Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR); - gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 2; - separator.setLayoutData(gd); - - applyDialogFont(parent); - return composite; - } - - /** - * Creates the dialog's title area. - * - * @param parent the SWT parent for the title area composite - * @return the created title area composite - */ - private Composite createTitleArea(Composite parent) { - Font font = parent.getFont(); - - // Create the title area which will contain - // a title, message, and image. - fTitleArea = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.verticalSpacing = 0; - layout.horizontalSpacing = 0; - layout.numColumns = 2; - - // Get the colors for the title area - Display display = parent.getDisplay(); - Color bg = JFaceColors.getBannerBackground(display); - Color fg = JFaceColors.getBannerForeground(display); - - GridData layoutData = new GridData(GridData.FILL_BOTH); - fTitleArea.setLayout(layout); - fTitleArea.setLayoutData(layoutData); - fTitleArea.setBackground(bg); - - // Message label - fMessageLabel = new CLabel(fTitleArea, SWT.LEFT); - fMessageLabel.setBackground(bg); - fMessageLabel.setForeground(fg); - fMessageLabel.setText(" ");//$NON-NLS-1$ - fMessageLabel.setFont(JFaceResources.getBannerFont()); - - final IPropertyChangeListener fontListener = new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if(JFaceResources.BANNER_FONT.equals(event.getProperty()) || - JFaceResources.DIALOG_FONT.equals(event.getProperty())) { - updateMessage(); - } - } - }; - - fMessageLabel.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent event) { - JFaceResources.getFontRegistry().removeListener(fontListener); - } - }); - - JFaceResources.getFontRegistry().addListener(fontListener); - - GridData gd = new GridData(GridData.FILL_BOTH); - fMessageLabel.setLayoutData(gd); - - // Title image - fTitleImage = new Label(fTitleArea, SWT.LEFT); - fTitleImage.setBackground(bg); - fTitleImage.setImage(TeamUIPlugin.getPlugin().getImageRegistry().get(PREF_DLG_TITLE_IMG)); - gd = new GridData(); - gd.horizontalAlignment = GridData.END; - fTitleImage.setLayoutData(gd); - updateMessage(); - return fTitleArea; - } - - /** - * Creates the inner page container. - */ - private Composite createPageContainer(Composite parent) { - Composite result = new Composite(parent, SWT.NULL); - result.setLayout(new PageLayout()); - return result; - } - - /** - * Sets the minimum page size. - * - * @param size the page size encoded as - * <code>new Point(width,height)</code> - * @see #setMinimumPageSize(int,int) - */ - public void setMinimumPageSize(Point size) { - fMinimumPageSize.x = size.x; - fMinimumPageSize.y = size.y; - } - - /** - * Display the given error message. The currently displayed message - * is saved and will be redisplayed when the error message is set - * to <code>null</code>. - * - * @param errorMessage the errorMessage to display or <code>null</code> - */ - public void setErrorMessage(String errorMessage) { - if (errorMessage == null) { - if (fMessageLabel.getImage() != null) { - // we were previously showing an error - fMessageLabel.setBackground(fNormalMsgAreaBackground); - fMessageLabel.setImage(null); - fTitleImage.setImage(TeamUIPlugin.getPlugin().getImageRegistry().get(PREF_DLG_TITLE_IMG)); - fTitleArea.layout(true); - } - - // show the message - setMessage(fMessage); - - } else { - fMessageLabel.setText(errorMessage); - if (fMessageLabel.getImage() == null) { - // we were not previously showing an error - - // lazy initialize the error background color and image - if (fErrorMsgImage == null) { - fErrorMsgImage = TeamUIPlugin.getPlugin().getImageRegistry().get(PREF_DLG_IMG_TITLE_ERROR); - } - - // show the error - fNormalMsgAreaBackground = fMessageLabel.getBackground(); - fMessageLabel.setBackground(JFaceColors.getErrorBackground(fMessageLabel.getDisplay())); - fMessageLabel.setImage(fErrorMsgImage); - fTitleImage.setImage(null); - fTitleArea.layout(true); - } - } - } - /** - * Set the message text. If the message line currently displays an error, - * the message is stored and will be shown after a call to clearErrorMessage - */ - public void setMessage(String newMessage) { - fMessage = newMessage; - if (fMessage == null) { - fMessage = "";//$NON-NLS-1$ - } - if (fMessageLabel.getImage() == null) { - // we are not showing an error - fMessageLabel.setText(fMessage); - } - } - - /** - * @see IPreferencePageContainer#updateMessage() - */ - public void updateMessage() { - String pageMessage = page.getMessage(); - String pageErrorMessage = page.getErrorMessage(); - - // Adjust the font - if (pageMessage == null && pageErrorMessage == null) - fMessageLabel.setFont(JFaceResources.getBannerFont()); - else - fMessageLabel.setFont(JFaceResources.getDialogFont()); - - // Set the message and error message - if (pageMessage == null) { - setMessage(page.getTitle()); - } else { - setMessage(pageMessage); - } - setErrorMessage(pageErrorMessage); - } - - /** - * @see IPreferencePageContainer#getPreferenceStore() - */ - public IPreferenceStore getPreferenceStore() { - return page.getPreferenceStore(); - } - - /** - * @see IPreferencePageContainer#updateButtons() - */ - public void updateButtons() { - if (fOkButton != null) { - fOkButton.setEnabled(page.isValid()); - } - } - - /** - * @see IPreferencePageContainer#updateTitle() - */ - public void updateTitle() { - setTitle(page.getTitle()); - } - - /** - * @see Dialog#createButtonsForButtonBar(Composite) - */ - protected void createButtonsForButtonBar(Composite parent) { - fOkButton= createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - /** - * Save the values specified in the pages. - * <p> - * The default implementation of this framework method saves all - * pages of type <code>PreferencePage</code> (if their store needs saving - * and is a <code>PreferenceStore</code>). - * </p> - * <p> - * Subclasses may override. - * </p> - */ - protected void handleSave() { - if (page instanceof PreferencePage) { - // Save now in case tbe workbench does not shutdown cleanly - IPreferenceStore store = - ((PreferencePage) page).getPreferenceStore(); - if (store != null - && store.needsSaving() - && store instanceof IPersistentPreferenceStore) { - try { - ((IPersistentPreferenceStore) store).save(); - } catch (IOException e) { - Utils.handle(e); - } - } - } - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PromptingDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PromptingDialog.java deleted file mode 100644 index 1f40ecd2b..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PromptingDialog.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.dialogs; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Shell; - -/** - * A confirmation dialog helper that will either show a 'yes/no/yes to all/cancel' - * dialog to confirm an action performed on several resources or if only one - * resource is specified 'ok/cancel' will be shown. - */ -public class PromptingDialog { - private IResource[] resources; - private Shell shell; - private String[] buttons; - private boolean confirmOverwrite = true; - private IPromptCondition condition; - private String title; - private boolean hasMultipleResources; - private boolean allOrNothing; - - /** - * Prompt for the given resources using the specific condition. The prompt dialog will - * have the title specified. - */ - public PromptingDialog(Shell shell, IResource[] resources, IPromptCondition condition, String title) { - this(shell, resources, condition, title, false /* all or nothing */); - } - - public PromptingDialog(Shell shell, IResource[] resources, IPromptCondition condition, String title, boolean allOrNothing) { - this.condition = condition; - this.resources = resources; - this.title = title; - this.shell = shell; - this.hasMultipleResources = resources.length > 1; - this.allOrNothing = allOrNothing; - if (hasMultipleResources) { - if (allOrNothing) { - buttons = new String[] { - IDialogConstants.YES_LABEL, - IDialogConstants.YES_TO_ALL_LABEL, - IDialogConstants.CANCEL_LABEL}; - } else { - buttons = new String[] { - IDialogConstants.YES_LABEL, - IDialogConstants.YES_TO_ALL_LABEL, - IDialogConstants.NO_LABEL, - IDialogConstants.CANCEL_LABEL}; - } - } else { - buttons = new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}; - } - } - /** - * Call to calculate and show prompt. If no resources satisfy the prompt condition - * a dialog won't be shown. The resources for which the user confirmed the action - * are returned. - */ - public IResource[] promptForMultiple() throws InterruptedException { - List targetResources = new ArrayList(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - if (condition.needsPrompt(resource) && confirmOverwrite) { - if (confirmOverwrite(condition.promptMessage(resource))) { - targetResources.add(resource); - } - } else { - targetResources.add(resource); - } - } - return (IResource[]) targetResources.toArray(new IResource[targetResources.size()]); - } - - /** - * Opens the confirmation dialog based on the prompt condition settings. - */ - private boolean confirmOverwrite(String msg) throws InterruptedException { - if (!confirmOverwrite) { - return true; - } - final MessageDialog dialog = - new MessageDialog(shell, title, null, msg, MessageDialog.QUESTION, buttons, 0); - - // run in syncExec because callback is from an operation, - // which is probably not running in the UI thread. - shell.getDisplay().syncExec( - new Runnable() { - public void run() { - dialog.open(); - } - }); - if (hasMultipleResources) { - switch (dialog.getReturnCode()) { - case 0://Yes - return true; - case 1://Yes to all - confirmOverwrite = false; - return true; - case 2://No (or CANCEL for all-or-nothing) - if (allOrNothing) { - throw new InterruptedException(); - } - return false; - case 3://Cancel - default: - throw new InterruptedException(); - } - } else { - return dialog.getReturnCode() == 0; - } - } -} 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 deleted file mode 100644 index b915512b8..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties +++ /dev/null @@ -1,434 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 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 -############################################################################### -############################################### -# Message catalog for org.eclipse.team.ui -############################################### - -CatchupReleaseViewer.open=&Show Content Comparison -CatchupReleaseViewer.expand=&Expand All -CatchupReleaseViewer.ignoreWhiteSpace=&Ignore White Space -CatchupReleaseViewer.refreshAction=&Refresh With Remote -CatchupReleaseViewer.showIncomingAction=Toggle showing of incoming Changes -CatchupReleaseViewer.showInNavigator=Show in &Navigator -CatchupReleaseViewer.showOnlyConflictsAction=Toggle showing of conflicting -CatchupReleaseViewer.showOutgoingAction=Toggle showing of outgoing Changes -CatchupReleaseViewer.removeFromView=Remove &From View -CatchupReleaseViewer.copyAllRightToLeft=Copy &All Changes From Right To Left -CatchupReleaseViewer.Compare_File_Contents_1=Compare File Contents -CatchupReleaseViewer.Copying_right_contents_into_workspace_2=Copying right contents into workspace -CatchupReleaseViewer.MakingLocalLikeRemote=Processing {0} - -ConfigureProjectAction.configureProject=Configure Project -ConfigureProjectWizard.configureProject=Share Project -ConfigureProjectWizard.description=Select the repository plug-in that will be used to share the selected project. -ConfigureProjectWizard.title=Share Project -ConfigureProjectWizardMainPage.selectRepository=Select a repository type: - -ConfigurationWizard.exceptionCreatingWizard=Exception creating wizard. - -IgnorePreferencePage.description=Use this page to specify a list of resource name patterns to exclude from version control. -IgnorePreferencePage.add=&Add... -IgnorePreferencePage.enterPatternLong=Please enter a pattern: -IgnorePreferencePage.enterPatternShort=Enter Ignore Pattern -IgnorePreferencePage.ignorePatterns=&Ignore Patterns: -IgnorePreferencePage.patternExistsLong=The entered pattern already exists. -IgnorePreferencePage.patternExistsShort=Pattern Already Exists -IgnorePreferencePage.remove=&Remove - -MergeResource.commonFile=Common file: {0} -MergeResource.noCommonFile=No common file -MergeResource.noRepositoryFile=No remote file -MergeResource.repositoryFile=Remote file: {0} -MergeResource.workspaceFile=Workspace file: {0} - -nothingToSynchronize=Nothing to Synchronize -simpleInternal=Internal error -exception=An exception occurred - -SyncCompareInput.nothingText=Workspace resources are the same as remote. -SyncCompareInput.refresh=Error During Refresh with Remote -SyncCompareInput.synchronize=Synchronize -SyncCompareInput.taskTitle=Synchronizing with Remote... - -SyncSet.conflicts={0} conflicts, -SyncSet.incomings={0} incoming change(s), -SyncSet.noConflicts=No conflicts, -SyncSet.noIncomings=no incoming changes, -SyncSet.noOutgoings=no outgoing changes. -SyncSet.outgoings={0} outgoing change(s). - -SyncView.freeModeAction=Incoming/Outgoing Mode -SyncView.freeModeTitle=Synchronize - Incoming/Outgoing Mode -SyncView.freeModeToolTip=Incoming/Outgoing Mode -SyncView.incomingModeAction=Incoming Mode -SyncView.incomingModeTitle=Synchronize - Incoming Mode -SyncView.incomingModeToolTip=Incoming Mode -SyncView.outgoingModeAction=Outgoing Mode -SyncView.outgoingModeTitle=Synchronize - Outgoing Mode -SyncView.outgoingModeToolTip=Outgoing Mode -SyncView.same=Workspace resources are the same as remote. -SyncView.text=Synchronize resources with their remote to display them here. -SyncView.unableSynchronize=Unable to Synchronize -SyncView.saveTitle=Save Resource -SyncView.saveMessage=Resource has been modified. Save changes? -SyncView.errorSaving=Error while saving modified resources -SyncView.cantSaveError=Can't save changes: {0} -SyncView.dirtyIndicatorInTitle=*{0} - -LiveSyncView.titleTooltip=Working Set: {0} -LiveSyncView.title=Synchronize -LiveSyncView.titleSubscriber=Synchronize - {0} - -SyncInfoCompareInput.localLabel=Local File -SyncInfoCompareInput.localLabelExists=Local File ({0}) -SyncInfoCompareInput.remoteLabel=Remote File -SyncInfoCompareInput.baseLabel=Common Ancestor -SyncInfoCompareInput.remoteLabelExists=Remote File ({0}) -SyncInfoCompareInput.baseLabelExists=Common Ancestor ({0}) -SyncInfoCompareInput.title={0} -SyncInfoCompareInput.tooltip={0}: {1} - -TeamAction.internal=Internal error occurred. -TeamFile.saveChanges=Unable to save changes to file: {0} -TeamFile.modified={0}* - -TextPreferencePage.add=&Add... -TextPreferencePage.binary=Binary -TextPreferencePage.change=&Change -TextPreferencePage.contents=Contents -TextPreferencePage.description=&File extensions with known content: -TextPreferencePage.enterExtensionLong=Please enter a file extension: -TextPreferencePage.enterExtensionShort=Enter File Extension -TextPreferencePage.extension=Extension -TextPreferencePage.extensionExistsLong=The entered extension already exists. -TextPreferencePage.extensionExistsShort=Extension Already Exists -TextPreferencePage.remove=&Remove -TextPreferencePage.text=ASCII - -TextPreferencePage.columnExtension=extension -TextPreferencePage.columnContents=contents - -SynchronizationViewPreference.defaultPerspectiveNone=None -SynchronizationViewPreference.defaultPerspectiveDescription=This setting controls which perspective to activate when resources are synchronized.\nTo indicate that a perspective switch should not occur select ''None''. -SynchronizationViewPreference.defaultPerspectiveLabel=Perspective: - -ScheduledSyncViewRefresh.taskName=Refreshing synchronize view partners with remote -SyncViewRefresh.taskName=Refreshing ''{0}'' - -ExportProjectSetMainPage.Select_the_projects_to_include_in_the_project_set__2=&Select the projects to include in the Team Project Set: -ExportProjectSetMainPage.Project_Set_File_Name__3=Select the export destination: -ExportProjectSetMainPage.Browse_4=B&rowse... -ExportProjectSetMainPage.You_have_specified_a_folder_5=You have specified a folder - -ImportProjectSetMainPage.Project_Set_File_Name__2=F&ile name: -ImportProjectSetMainPage.Browse_3=B&rowse... -ImportProjectSetMainPage.The_specified_file_does_not_exist_4=The specified file does not exist -ImportProjectSetMainPage.You_have_specified_a_folder_5=You have specified a folder -ImportProjectSetMainPage.workingSetNameEmpty=The working set name must not be empty -ImportProjectSetMainPage.workingSetNameExists=The specified working set already exists -ImportProjectSetMainPage.createWorkingSetLabel=&Create a working set containing the imported projects -ImportProjectSetMainPage.workingSetLabel=&Working Set Name: - -ProjectSetContentHandler.Element_provider_must_be_contained_in_element_psf_4=Element provider must be contained in element psf -ProjectSetContentHandler.Element_project_must_be_contained_in_element_provider_7=Element project must be contained in element provider - -ProjectSetExportWizard.Project_Set_1=Team Project Set -ProjectSetExportWizard.Export_a_Project_Set_3=Export a Team Project Set -ProjectSetExportWizard.Question_4=Question -ProjectSetExportWizard.Target_directory_does_not_exist._Would_you_like_to_create_it__5=Target directory does not exist. Would you like to create it? -ProjectSetExportWizard.Export_Problems_6=Export Problems -ProjectSetExportWizard.An_error_occurred_creating_the_target_directory_7=An error occurred creating the target directory -ProjectSetExportWizard.Question_8=Question -ProjectSetExportWizard.Target_already_exists._Would_you_like_to_overwrite_it__9=Target already exists. Would you like to overwrite it? -ProjectSetImportWizard.Project_Set_1=Team Project Set -ProjectSetImportWizard.Import_a_Project_Set_3=Import a Team Project Set -ProjectSetImportWizard.workingSetExistsTitle=Working Set Exists -ProjectSetImportWizard.workingSetExistsMessage=Working set ''{0}'' already exists. Overwrite? - -ExportProjectSetMainPage.Project_Set_Files_3=Team Project Set Files (*.psf) -ExportProjectSetMainPage.default=projectSet.psf -ImportProjectSetMainPage.allFiles=All Files (*.*) -ImportProjectSetMainPage.Project_Set_Files_2=Team Project Set Files (*.psf) -ExportProjectSetMainPage.&File_name__1=&File name: -TeamPreferencePage.General_settings_for_Team_support_1=General settings for Team support -TeamPreferencePage.&Use_Incoming/Outgoing_mode_when_synchronizing_2=&Use Incoming/Outgoing mode when synchronizing - -SynchronizeView.noSubscribersMessage=Synchronize resources with their remote to display them here. Some Team plugins may also show resources here automatically when their plugin is activated. - -SyncViewerDirectionFilters.incomingTitle=Incoming -SyncViewerDirectionFilters.incomingToolTip=Toggle showing of incoming changes -SyncViewerDirectionFilters.outgoingTitle=Outgoing -SyncViewerDirectionFilters.outgoingToolTip=Toggle showing of outgoing changes -SyncViewerDirectionFilters.conflictingTitle=Conflicting -SyncViewerDirectionFilters.conflictingToolTip=Toggle showing of conflicting changes - -SyncViewPreferencePage.lastRefreshRun=The last background synchronize was run at: {0} -SyncViewPreferencePage.lastRefreshRunNever=Never - -############################################### -# Sync view actions -############################################### - -action.collapseAll.label=Collapse All -action.collapseAll.tooltip=Collapse All -action.collapseAll.description=Collapse All -action.collapseAll.image=collapseall.gif - -action.configureSchedulel.label=Schedule... -action.configureSchedulel.tooltip=Configure the Synchronize Schedule... - -action.refreshWithRemote.label=&Synchronize... -action.refreshWithRemote.tooltip=Synchronize... -action.refreshWithRemote.description=Synchronize... -action.refreshWithRemote.image=refresh_remote.gif - -action.directionFilterIncoming.label=Incoming -action.directionFilterIncoming.tooltip=Incoming Mode -action.directionFilterIncoming.description=Incoming Mode (shows incoming changes and conflicts) -action.directionFilterIncoming.image=catchup_rls.gif - -action.directionFilterOutgoing.label=Outgoing -action.directionFilterOutgoing.tooltip=Outgoing Mode -action.directionFilterOutgoing.description=Outgoing Mode (shows outgoing changes and conflicts) -action.directionFilterOutgoing.image=release_rls.gif - -action.directionFilterConflicts.label=Conflicts -action.directionFilterConflicts.tooltip=Conflicts Mode -action.directionFilterConflicts.description=Conflicts Mode (shows conflicts) -action.directionFilterConflicts.image=conflict_synch.gif - -action.directionFilterBoth.label=Both -action.directionFilterBoth.tooltip=Incoming/Outgoing mode -action.directionFilterBoth.description=Incoming/Outgoing mode (shows outgoing changes, incoming changes, and conflicts) -action.directionFilterBoth.image=catchuprelease_rls.gif - -action.refreshSubscriber.label=Synchronizations -action.refreshSubscriber.tooltip=Synchronizations -action.refreshSubscriber.description=Synchronizations -action.refreshSubscriber.image=synch_participants.gif - -action.comparisonCriteria.label=Comparison Criteria -action.comparisonCriteria.tooltip=Select the comparison method -action.comparisonCriteria.description=Select the comparison method -action.comparisonCriteria.image=showsync_rn.gif - -action.navigateNext.label=Go to Next Difference -action.navigateNext.tooltip=Go to Next Difference -action.navigateNext.description=Go to Next Difference -action.navigateNext.image=next_nav.gif - -action.navigatePrevious.label=Go to Previous Difference -action.navigatePrevious.tooltip=Go to Previous Difference -action.navigatePrevious.description=Go to Next Difference -action.navigatePrevious.image=prev_nav.gif - -action.removePage.label=Remove Current Synchronization -action.removePage.tooltip=Remove Current Synchronization -action.removePage.description=Remove Current Synchronization -action.removePage.image=participant_rem.gif - -action.removeAllPage.label=Remove Un-Pinned Synchronizations -action.removeAllPage.tooltip=Remove Un-Pinned Synchronizations -action.removeAllPage.description=Remove Un-Pinned Synchronizations -action.removeAllPage.image=participant_remall.gif - -action.pinParticipant.label=Pin Current Synchronization -action.pinParticipant.tooltip=Pin Current Synchronization -action.pinParticipant.description=Pin Current Synchronization -action.pinParticipant.image=pin.gif - -action.expandAll.label=E&xpand All -action.open.label=&Open -action.openInCompareEditor.label=Open In Compare Editor -action.cancelSubscriber.label=Cancel - -action.syncViewPreferences.label=Preferences... -action.refreshViewContents.label=Refresh View Contents -action.changeFilterShowAdditions.label=Show Additions -action.changeFilterShowDeletions.label=Show Deletions -action.changeFilterShowChanges.label=Show Changes -action.layout.label=Layout -action.modes.label=Modes - -action.removeFromView.label=&Remove from View - -############################################### -# Misc -############################################### - -SynchronizeView.12=One item selected -SynchronizeView.13=\ items selected -SynchronizeView.14=Error opening perspective -SynchronizeView.16=Error opening view - -StatisticsPanel.outgoing=Outgoing: -StatisticsPanel.incoming=Incoming: -StatisticsPanel.conflicting=Conflicting: -StatisticsPanel.changeNumbers={0}/{1} -StatisticsPanel.outgoing=Outgoing -StatisticsPanel.conflicting=Conflicting -StatisticsPanel.incoming=Incoming -StatisticsPanel.noWorkingSet=<No Working Set> -StatisticsPanel.workingSetTooltip=Double-click to change the working set applied to the Synchronize View. -StatisticsPanel.numbersTooltip=The number of ''{0}'' changes in the entire workspace. -StatisticsPanel.numbersWorkingSetTooltip=The number of ''{0}'' changes in working set ''{1}'' versus those in the entire workspace. -StatisticsPanel.numberTotal={0} changes - -SyncViewerPreferencePage.6=General Synchronize Settings -SyncViewerPreferencePage.7=General Team Settings: -SyncViewerPreferencePage.8=Display -SyncViewerPreferencePage.9=Compress in-sync folder paths when using the tree view -SyncViewerPreferencePage.10=Use incoming/outgoing mode when synchronizing -SyncViewerPreferencePage.11=Refreshing with Remote -SyncViewerPreferencePage.15=Perspective Switching - -RefreshSubscriberInputJob.1=Synchronizing ''{0}'' with remote: {1} resources -RefreshSubscriberJob.1=Team synchronize {0} folders for {1} -RefreshSubscriberJob.0=An error occured while synchronizing with remote contents. -RefreshSubscriberJob.2=Synchronizing {1} - -CopyAction.title=&Copy -CopyAction.toolTip=Copy -CopyAction.errorTitle=Problem Copying to Clipboard -CopyAction.errorMessage=There was a problem when accessing the system clipboard. Retry? -PasteAction.title=&Paste -PasteAction.toolTip=Paste -RefactorActionGroup.0=Edi&t -SynchronizeManager.7=Error notifying of added/removal of synchronization -SynchronizeManager.8=Error initializing Synchronization -SynchronizeManager.9=Synchronization with id {0} is not in the registry -SynchronizeManager.10=Error saving synchronization -SynchronizeView.1=Synchronize -SynchronizeView.2={1} -SyncViewerPreferencePage.19=Show all synchronization information in a resource\'s text label -TeamSubscriberParticipantPage.7=Resource -TeamSubscriberParticipantPage.8=In Folder -TeamSubscriberSyncPage.labelWithSyncKind={0} {1} -AbstractSynchronizeParticipant.4=Cannot initialize synchronization. Wrong descriptor type - -SynchronizeManager.11=Error creating Synchronization {0}: -AbstractSynchronizeParticipant.5=Exception notifying participant listeners of changes. -SynchronizeManager.13=Error initializing synchronize participant - -ChangesSection.filterHides=The current ''{0}'' mode is empty. -ChangesSection.filterHidesSingular=However there is {0} change in the ''{1}'' mode. -ChangesSection.filterHidesPlural=However there are {0} changes in the ''{1}'' mode. -ChangesSection.filterChange=Change to ''{0}'' mode. -ChangesSection.workingSetHiding=The current working set ''{0}'' is hiding changes in your workspace. -ChangesSection.workingSetRemove=Remove working set. -ChangesSection.noChanges=No changes in ''{0}''. -Utils.22=Incoming -Utils.23=Outgoing -Utils.24=Incoming/Outgoing -Utils.25=Conflicting -Utils.26=unknown mode -RefreshCompleteDialog.4=Synchronize Complete - {0} -RefreshCompleteDialog.4a=Scheduled Synchronize Complete - {0} -RefreshCompleteDialog.5={0}: {1} changes found. -RefreshCompleteDialog.5a={0}: {1} new changes found. -RefreshCompleteDialog.6={0}: No changes found. -RefreshCompleteDialog.17=Details >> -RefreshCompleteDialog.18=<< Details -RefreshUserNotificationPolicy.0=Synchronize of ''{0}'' Complete. -ConfigureRefreshScheduleDialog.0=Configure Synchronize Schedule - {0} -ConfigureRefreshScheduleDialog.1=You can allow ''{0}'' to periodically synchronize in the background. -ConfigureRefreshScheduleDialog.1a=The last synchronize occured at: {0} -ConfigureRefreshScheduleDialog.2=Don't schedule the synchronize operation to run periodically. -ConfigureRefreshScheduleDialog.3=Using the following schedule: -ConfigureRefreshScheduleDialog.4=Every: -ConfigureRefreshScheduleDialog.5=hour(s) -ConfigureRefreshScheduleDialog.6=minutes(s) -ConfigureRefreshScheduleDialog.7=Number must be a positive number greater than 0 -ConfigureRefreshScheduleDialog.8=Number must be a positive number greater than 0 -RefreshSchedule.6=\ ({0} changes found) -RefreshSchedule.7=\ (No changes found) -RefreshSchedule.8=Not Scheduled -RefreshSchedule.9=hours -RefreshSchedule.10=minutes -RefreshSchedule.11=hour -RefreshSchedule.12=minute -RefreshSchedule.13=Every {0} {1} -RefreshSchedule.14=Scheduled Synchronize -RefreshSchedule.15={0} {1} -DiffNodeControllerHierarchical.0=Updating labels -ChangesSection.8=Show Errors -ChangesSection.9=Reset View -ChangesSection.10=Errors have occurred calculating the synchronization state for {0} -ChangesSection.11=Errors Populating View -ChangesSection.12=Multiple errors occurred while attempting to populate the view. - -OpenComparedDialog.diffViewTitleMany=Changes -OpenComparedDialog.diffViewTitleOne=Changes -OpenComparedDialog.noChangeTitle=Operation Complete -OpenComparedDialog.noChangesMessage=No Changes Found. -GlobalRefreshAction.4=Synchronize... -GlobalRefreshAction.5=Synchronize {0} -SubscriberRefreshWizard.0=Synchronize -ParticipantCompareDialog.1=Remember this result by placing it in the Synchronize View. -ParticipantCompareDialog.2=Confirm Save -ParticipantCompareDialog.3=Do you want to save changes? -RefreshCompleteDialog.21=Show only the latest new incoming changes -RefreshCompleteDialog.22=Don't show this dialog again. -SynchronizeManager.27=Confirm Perspective Switch -SynchronizeManager.31=&Remember my decision -SynchronizeManager.30=Synchronization is associated with the {0} perspective. Do you want to switch to that perspective now? -RefreshCompleteDialog.9=Changes -RefreshSubscriberJob.2=Synchronizing {0} -Participant.comparing=Comparing -Participant.merging=Merging -Participant.synchronizing=Synchronizing -Participant.comparingDetail=Comparing {0} -Participant.mergingDetail=Merging {0} -Participant.synchronizingDetails=Synchronizing {0} -GlobalRefreshResourceSelectionPage.1=Synchronize -GlobalRefreshResourceSelectionPage.2=Select the resources to synchronize or select a scope to automatically select a group of resources. -GlobalRefreshResourceSelectionPage.3=Synchronize -GlobalRefreshResourceSelectionPage.4=There are no resources to synchronize. -GlobalRefreshResourceSelectionPage.5=Available resources to Synchronize: -GlobalRefreshResourceSelectionPage.6=Scope -GlobalRefreshResourceSelectionPage.7=W&orkspace -GlobalRefreshResourceSelectionPage.8=&Selected Resources -GlobalRefreshResourceSelectionPage.9=&Enclosing Projects -GlobalRefreshResourceSelectionPage.10=&Working Set: -GlobalRefreshResourceSelectionPage.11=&Choose... -GlobalRefreshResourceSelectionPage.12=Select &All -GlobalRefreshResourceSelectionPage.13=&Deselect All -GlobalRefreshParticipantSelectionPage.0=Synchronize -GlobalRefreshParticipantSelectionPage.1=Select the type of synchronization -GlobalRefreshParticipantSelectionPage.2=Synchronize -GlobalRefreshParticipantSelectionPage.3=Available synchronization types: - -GlobalRefreshSubscriberPage.0=Synchronize -GlobalRefreshSubscriberPage.1=Synchronize {0} -GlobalRefreshSubscriberPage.2=Select the resources or working sets to be synchronized. - - -SyncViewerPreferencePage.31=Prompt at the end of a synchronize operation. -SyncViewerPreferencePage.12=Prompt at the end of a scheduled synchronize operation. -SyncViewerPreferencePage.13=Switch to the associated perspective when a synchronize operation completes -SyncViewerPreferencePage.14=Always -SyncViewerPreferencePage.42=Never -SyncViewerPreferencePage.16=Prompt -GlobalRefreshSchedulePage.0=Configure a scheduled synchronization -GlobalRefreshSchedulePage.1=Synchronize Schedule -GlobalRefreshSchedulePage.2=Set the interval at which the resources associated with {0} will be synchronized in the background. -SynchronizeManager.18=Could not cast {0} as ISynchronizeView -GlobalSynchronizeWizard.11=Synchronize -SynchronizeManager.19=Could not create synchronization: {0} -SynchronizeManager.20=Not allowed to create multiple synchronize instances of this type: {0} -WorkspaceScope.0=Workspace -WorkingSetScope.0=Workspace -SubscriberParticipant.namePattern={0} ({1}) - -RemoveFromView.warningTitle=Confirm Remove -RemoveFromView.warningMessage=The selected resources will be removed from the view. A resource will reappear if it is modified or if its synchronization state changes. -RemoveFromView.warningDontShow=Don't show me this again - diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/ComboFieldEditor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/ComboFieldEditor.java deleted file mode 100644 index a64177bcc..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/ComboFieldEditor.java +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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 org.eclipse.jface.preference.FieldEditor; -import org.eclipse.jface.util.Assert; -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.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * A field editor for a combo box that allows the drop-down selection of one of a list of items. - * - * XXX: Note this is a copy from org.eclipse.debug.internal.ui.preferences - * This class can be removed once bug 24928 is fixed. - * - * @since 2.1 - */ -public class ComboFieldEditor extends FieldEditor { - - /** - * The <code>Combo</code> widget. - */ - private Combo fCombo; - - /** - * The value (not the name) of the currently selected item in the Combo widget. - */ - private String fValue; - - /** - * The names (labels) and underlying values to populate the combo widget. These should be - * arranged as: { {name1, value1}, {name2, value2}, ...} - */ - private String[][] fEntryNamesAndValues; - - public ComboFieldEditor(String name, String labelText, String[][] entryNamesAndValues, Composite parent) { - init(name, labelText); - Assert.isTrue(checkArray(entryNamesAndValues)); - fEntryNamesAndValues= entryNamesAndValues; - createControl(parent); - } - - /** - * Checks whether given <code>String[][]</code> is of "type" - * <code>String[][2]</code>. - * - * @return <code>true</code> if it is ok, and <code>false</code> otherwise - */ - private boolean checkArray(String[][] table) { - if (table == null) { - return false; - } - for (int i= 0; i < table.length; i++) { - String[] array= table[i]; - if (array == null || array.length != 2) { - return false; - } - } - return true; - } - - /* - * @see FieldEditor#adjustForNumColumns(int) - */ - protected void adjustForNumColumns(int numColumns) { - Control control= getLabelControl(); - if (control != null) { - ((GridData)control.getLayoutData()).horizontalSpan= numColumns; - } - ((GridData)fCombo.getLayoutData()).horizontalSpan= numColumns; - } - - /* - * @see FieldEditor#doFillIntoGrid(Composite, int) - */ - protected void doFillIntoGrid(Composite parent, int numColumns) { - Control control= getLabelControl(parent); - GridData gd= new GridData(); - gd.horizontalSpan= numColumns; - control.setLayoutData(gd); - control= getComboBoxControl(parent); - gd= new GridData(); - gd.horizontalSpan= numColumns; - control.setLayoutData(gd); - } - - /* - * @see FieldEditor#doLoad() - */ - protected void doLoad() { - updateComboForValue(getPreferenceStore().getString(getPreferenceName())); - } - - /* - * @see FieldEditor#doLoadDefault() - */ - protected void doLoadDefault() { - updateComboForValue(getPreferenceStore().getDefaultString(getPreferenceName())); - } - - /* - * @see FieldEditor#doStore() - */ - protected void doStore() { - if (fValue == null) { - getPreferenceStore().setToDefault(getPreferenceName()); - return; - } - - getPreferenceStore().setValue(getPreferenceName(), fValue); - } - - /* - * @see FieldEditor#getNumberOfControls() - */ - public int getNumberOfControls() { - return 1; - } - - /** - * Lazily create and return the Combo control. - */ - public Combo getComboBoxControl(Composite parent) { - if (fCombo == null) { - fCombo= new Combo(parent, SWT.READ_ONLY); - for (int i= 0; i < fEntryNamesAndValues.length; i++) { - fCombo.add(fEntryNamesAndValues[i][0], i); - } - fCombo.setFont(parent.getFont()); - fCombo.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent evt) { - String oldValue= fValue; - String name= fCombo.getText(); - fValue= getValueForName(name); - setPresentsDefaultValue(false); - fireValueChanged(VALUE, oldValue, fValue); - } - }); - } - return fCombo; - } - - /** - * Given the name (label) of an entry, return the corresponding value. - */ - protected String getValueForName(String name) { - for (int i= 0; i < fEntryNamesAndValues.length; i++) { - String[] entry= fEntryNamesAndValues[i]; - if (name.equals(entry[0])) { - return entry[1]; - } - } - return fEntryNamesAndValues[0][0]; - } - - /** - * Set the name in the combo widget to match the specified value. - */ - protected void updateComboForValue(String value) { - fValue= value; - for (int i= 0; i < fEntryNamesAndValues.length; i++) { - if (value.equals(fEntryNamesAndValues[i][1])) { - fCombo.setText(fEntryNamesAndValues[i][0]); - return; - } - } - if (fEntryNamesAndValues.length > 0) { - fValue= fEntryNamesAndValues[0][1]; - fCombo.setText(fEntryNamesAndValues[0][0]); - } - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/IgnorePreferencePage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/IgnorePreferencePage.java deleted file mode 100644 index 4374a8fa0..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/IgnorePreferencePage.java +++ /dev/null @@ -1,183 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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 org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.IIgnoreInfo; -import org.eclipse.team.core.Team; -import org.eclipse.team.internal.ui.*; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.help.WorkbenchHelp; -public class IgnorePreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - private Table ignoreTable; - private Button addButton; - private Button removeButton; - public void init(IWorkbench workbench) { - setDescription(Policy.bind("IgnorePreferencePage.description")); //$NON-NLS-1$ - } - - /** - * Creates preference page controls on demand. - * - * @param parent the parent for the preference page - */ - protected Control createContents(Composite ancestor) { - - Composite parent = new Composite(ancestor, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.numColumns = 2; - parent.setLayout(layout); - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - parent.setLayoutData(data); - - // set F1 help - WorkbenchHelp.setHelp(parent, IHelpContextIds.IGNORE_PREFERENCE_PAGE); - - Label l1 = new Label(parent, SWT.NULL); - l1.setText(Policy.bind("IgnorePreferencePage.ignorePatterns")); //$NON-NLS-1$ - data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); - data.horizontalSpan = 2; - l1.setLayoutData(data); - - ignoreTable = new Table(parent, SWT.CHECK | SWT.BORDER); - GridData gd = new GridData(GridData.FILL_BOTH); - //gd.widthHint = convertWidthInCharsToPixels(30); - gd.heightHint = 300; - ignoreTable.setLayoutData(gd); - ignoreTable.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - handleSelection(); - } - }); - - 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); - - addButton = new Button(buttons, SWT.PUSH); - addButton.setText(Policy.bind("IgnorePreferencePage.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() { - public void handleEvent(Event e) { - addIgnore(); - } - }); - - - removeButton = new Button(buttons, SWT.PUSH); - removeButton.setText(Policy.bind("IgnorePreferencePage.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() { - public void handleEvent(Event e) { - removeIgnore(); - } - }); - fillTable(Team.getAllIgnores()); - Dialog.applyDialogFont(ancestor); - return parent; - } - /** - * Do anything necessary because the OK button has been pressed. - * - * @return whether it is okay to close the preference page - */ - public boolean performOk() { - int count = ignoreTable.getItemCount(); - String[] patterns = new String[count]; - boolean[] enabled = new boolean[count]; - TableItem[] items = ignoreTable.getItems(); - for (int i = 0; i < count; i++) { - patterns[i] = items[i].getText(); - enabled[i] = items[i].getChecked(); - } - Team.setAllIgnores(patterns, enabled); - TeamUIPlugin.broadcastPropertyChange(new PropertyChangeEvent(this, TeamUI.GLOBAL_IGNORES_CHANGED, null, null)); - return true; - } - - protected void performDefaults() { - super.performDefaults(); - ignoreTable.removeAll(); - IIgnoreInfo[] ignore = Team.getDefaultIgnores(); - fillTable(ignore); - } - - /** - * @param ignore - */ - private void fillTable(IIgnoreInfo[] ignore) { - for (int i = 0; i < ignore.length; i++) { - IIgnoreInfo info = ignore[i]; - TableItem item = new TableItem(ignoreTable, SWT.NONE); - item.setText(info.getPattern()); - item.setChecked(info.getEnabled()); - } - } - - private void addIgnore() { - InputDialog dialog = new InputDialog(getShell(), Policy.bind("IgnorePreferencePage.enterPatternShort"), Policy.bind("IgnorePreferencePage.enterPatternLong"), 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$ - // Check if the item already exists - TableItem[] items = ignoreTable.getItems(); - for (int i = 0; i < items.length; i++) { - if (items[i].getText().equals(pattern)) { - MessageDialog.openWarning(getShell(), Policy.bind("IgnorePreferencePage.patternExistsShort"), Policy.bind("IgnorePreferencePage.patternExistsLong")); //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - } - TableItem item = new TableItem(ignoreTable, SWT.NONE); - item.setText(pattern); - item.setChecked(true); - } - - private void removeIgnore() { - int[] selection = ignoreTable.getSelectionIndices(); - ignoreTable.remove(selection); - } - private void handleSelection() { - if (ignoreTable.getSelectionCount() > 0) { - removeButton.setEnabled(true); - } else { - removeButton.setEnabled(false); - } - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/SyncViewerPreferencePage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/SyncViewerPreferencePage.java deleted file mode 100644 index 747029423..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/SyncViewerPreferencePage.java +++ /dev/null @@ -1,220 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.text.Collator; -import java.text.DateFormat; -import java.util.*; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.MessageDialogWithToggle; -import org.eclipse.jface.preference.*; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ui.*; -import org.eclipse.ui.*; - -/** - * This area provides the widgets for providing the CVS commit comment - */ -public class SyncViewerPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage, IPreferenceIds { - - private BooleanFieldEditor compressFolders = null; - private BooleanFieldEditor showSyncInLabels = null; - private BooleanFieldEditor useDefaultPerspective = null; - private RadioGroupFieldEditor synchronizePerspectiveSwitch = null; - - private static class PerspectiveDescriptorComparator implements Comparator { - /* - * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) - */ - public int compare(Object o1, Object o2) { - if (o1 instanceof IPerspectiveDescriptor && o2 instanceof IPerspectiveDescriptor) { - String id1= ((IPerspectiveDescriptor)o1).getLabel(); - String id2= ((IPerspectiveDescriptor)o2).getLabel(); - return Collator.getInstance().compare(id1, id2); - } - return 0; - } - } - - public SyncViewerPreferencePage() { - super(GRID); - setTitle(Policy.bind("SyncViewerPreferencePage.6")); //$NON-NLS-1$ - setDescription(Policy.bind("SyncViewerPreferencePage.7")); //$NON-NLS-1$ - setPreferenceStore(TeamUIPlugin.getPlugin().getPreferenceStore()); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - super.createControl(parent); - //WorkbenchHelp.setHelp(getControl(), IDebugHelpContextIds.CONSOLE_PREFERENCE_PAGE); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() - */ - public void createFieldEditors() { - compressFolders = new BooleanFieldEditor(SYNCVIEW_COMPRESS_FOLDERS, Policy.bind("SyncViewerPreferencePage.9"), SWT.NONE, getFieldEditorParent()); //$NON-NLS-1$ - addField(compressFolders); - showSyncInLabels = new BooleanFieldEditor(SYNCVIEW_VIEW_SYNCINFO_IN_LABEL, Policy.bind("SyncViewerPreferencePage.19"), SWT.NONE, getFieldEditorParent()); //$NON-NLS-1$ - addField(showSyncInLabels); - - synchronizePerspectiveSwitch= new RadioGroupFieldEditor(SYNCHRONIZING_COMPLETE_PERSPECTIVE, Policy.bind("SyncViewerPreferencePage.13"), 3, //$NON-NLS-1$ - new String[][] { - {Policy.bind("SyncViewerPreferencePage.14"), MessageDialogWithToggle.ALWAYS}, //$NON-NLS-1$ - {Policy.bind("SyncViewerPreferencePage.42"), MessageDialogWithToggle.NEVER}, //$NON-NLS-1$ - {Policy.bind("SyncViewerPreferencePage.16"), MessageDialogWithToggle.PROMPT} //$NON-NLS-1$ - }, - getFieldEditorParent(), true); - addField(synchronizePerspectiveSwitch); - - Group perspectiveGroup = createGroup(getFieldEditorParent(), Policy.bind("SyncViewerPreferencePage.15")); //$NON-NLS-1$ - - createLabel(perspectiveGroup, Policy.bind("SynchronizationViewPreference.defaultPerspectiveDescription"), 1); //$NON-NLS-1$ - - handleDeletedPerspectives(); - String[][] perspectiveNamesAndIds = getPerspectiveNamesAndIds(); - ComboFieldEditor comboEditor= new ComboFieldEditor( - SYNCVIEW_DEFAULT_PERSPECTIVE, - Policy.bind("SynchronizationViewPreference.defaultPerspectiveLabel"), //$NON-NLS-1$ - perspectiveNamesAndIds, - perspectiveGroup); - addField(comboEditor); - - Dialog.applyDialogFont(getFieldEditorParent()); - updateLayout(perspectiveGroup); - getFieldEditorParent().layout(true); - } - - private Label createLabel(Composite parent, String title, int spacer) { - GridData data; - Label l = new Label(parent, SWT.WRAP); - l.setFont(parent.getFont()); - data = new GridData(); - data.horizontalSpan = 2; - if(spacer != 0) { - data.verticalSpan = spacer; - } - data.horizontalAlignment = GridData.FILL; - l.setLayoutData(data); - if(title != null) { - l.setText(title); //$NON-NLS-1$ - } - return l; - } - - private Group createGroup(Composite parent, String title) { - Group display = new Group(parent, SWT.NONE); - updateLayout(display); - GridData data = new GridData(); - data.horizontalSpan = 2; - data.horizontalAlignment = GridData.FILL; - display.setLayoutData(data); - display.setText(title); - return display; - } - - private void updateLayout(Composite composite) { - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginWidth = 5; - layout.marginHeight =5; - layout.horizontalSpacing = 5; - layout.verticalSpacing = 5; - composite.setLayout(layout); - } - - private void updateLastRunTime(Label label) { - String text; - long mills = 0; - if(mills == 0) { - String never = Policy.bind("SyncViewPreferencePage.lastRefreshRunNever"); //$NON-NLS-1$ - text = Policy.bind("SyncViewPreferencePage.lastRefreshRun", never); //$NON-NLS-1$ - } else { - Date lastTimeRun = new Date(mills); - String sLastTimeRun = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(lastTimeRun); - text = Policy.bind("SyncViewPreferencePage.lastRefreshRun", sLastTimeRun); //$NON-NLS-1$ - } - label.setText(text); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) - */ - public void init(IWorkbench workbench) { - } - - /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - //if(event.getSource() == bkgScheduledRefresh || event.getSource() == scheduledDelay) { - // updateEnablements(); - // } - super.propertyChange(event); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferencePage#performOk() - */ - public boolean performOk() { - TeamUIPlugin.getPlugin().savePluginPreferences(); - return super.performOk(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.FieldEditorPreferencePage#checkState() - */ - protected void initialize() { - super.initialize(); - updateEnablements(); - } - - protected void updateEnablements() { - //boolean enabled = bkgScheduledRefresh.getBooleanValue(); - //scheduledDelay.setEnabled(enabled, refreshGroup); - //scheduledDelay.refreshValidState(); - } - - /** - * Return a 2-dimensional array of perspective names and ids. - */ - private String[][] getPerspectiveNamesAndIds() { - - IPerspectiveRegistry registry= PlatformUI.getWorkbench().getPerspectiveRegistry(); - IPerspectiveDescriptor[] perspectiveDescriptors= registry.getPerspectives(); - - Arrays.sort(perspectiveDescriptors, new PerspectiveDescriptorComparator()); - - String[][] table = new String[perspectiveDescriptors.length + 1][2]; - table[0][0] = Policy.bind("SynchronizationViewPreference.defaultPerspectiveNone"); //$NON-NLS-1$; - table[0][1] = SYNCVIEW_DEFAULT_PERSPECTIVE_NONE; - for (int i = 0; i < perspectiveDescriptors.length; i++) { - table[i + 1][0] = perspectiveDescriptors[i].getLabel(); - table[i + 1][1] = perspectiveDescriptors[i].getId(); - } - return table; - } - - private static void handleDeletedPerspectives() { - IPreferenceStore store= TeamUIPlugin.getPlugin().getPreferenceStore(); - String id= store.getString(SYNCVIEW_DEFAULT_PERSPECTIVE); - if (PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId(id) == null) { - store.putValue(SYNCVIEW_DEFAULT_PERSPECTIVE, SYNCVIEW_DEFAULT_PERSPECTIVE_NONE); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/TeamPreferencePage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/TeamPreferencePage.java deleted file mode 100644 index c65178491..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/TeamPreferencePage.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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 org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ui.*; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.help.WorkbenchHelp; - -public class TeamPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - Button syncModeButton; - - public TeamPreferencePage() { - setDescription(Policy.bind("TeamPreferencePage.General_settings_for_Team_support_1")); //$NON-NLS-1$ - } - - /** - * @see PreferencePage#createContents(Composite) - */ - protected Control createContents(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - - // set F1 help - WorkbenchHelp.setHelp(composite, IHelpContextIds.TEAM_PREFERENCE_PAGE); - - // GridLayout - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.marginWidth = 0; - layout.marginHeight = 0; - composite.setLayout(layout); - - // GridData - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - composite.setLayoutData(data); - - // Create the checkbox for sync mode - syncModeButton = createCheckBox(composite, Policy.bind("TeamPreferencePage.&Use_Incoming/Outgoing_mode_when_synchronizing_2")); //$NON-NLS-1$ - - initializeValues(); - Dialog.applyDialogFont(parent); - return composite; - } - /** - * Creates an new checkbox instance and sets the default - * layout data. - * - * @param group the composite in which to create the checkbox - * @param label the string to set into the checkbox - * @return the new checkbox - */ - private Button createCheckBox(Composite group, String label) { - Button button = new Button(group, SWT.CHECK | SWT.LEFT); - button.setText(label); - GridData data = new GridData(); - data.horizontalSpan = 1; - button.setLayoutData(data); - return button; - } - /** - * Returns preference store that belongs to the our plugin. - * This is important because we want to store - * our preferences separately from the desktop. - * - * @return the preference store for this plugin - */ - protected IPreferenceStore doGetPreferenceStore() { - return TeamUIPlugin.getPlugin().getPreferenceStore(); - } - /** - * Defaults was clicked. Restore the CVS preferences to - * their default values - */ - protected void performDefaults() { - super.performDefaults(); - IPreferenceStore store = getPreferenceStore(); - //syncModeButton.setSelection(store.getDefaultBoolean(ISharedImages.PREF_ALWAYS_IN_INCOMING_OUTGOING)); - } - /** - * OK was clicked. Store the CVS preferences. - * - * @return whether it is okay to close the preference page - */ - public boolean performOk() { - IPreferenceStore store = getPreferenceStore(); - //store.setValue(ISharedImages.PREF_ALWAYS_IN_INCOMING_OUTGOING, syncModeButton.getSelection()); - TeamUIPlugin.getPlugin().savePluginPreferences(); - return true; - } - /** - * Initializes states of the controls from the preference store. - */ - private void initializeValues() { - IPreferenceStore store = getPreferenceStore(); - //syncModeButton.setSelection(store.getBoolean(ISharedImages.PREF_ALWAYS_IN_INCOMING_OUTGOING)); - } - /** - * @see IWorkbenchPreferencePage#init(IWorkbench) - */ - public void init(IWorkbench workbench) { - } -} 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 deleted file mode 100644 index 7aca276af..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/preferences/TextPreferencePage.java +++ /dev/null @@ -1,375 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.*; -import java.util.List; - -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.PreferencePage; -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.ui.IHelpContextIds; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.help.WorkbenchHelp; -/** - * This preference page displays all patterns which determine whether a resource - * 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$ - - // The input for the table viewer - private List input; - - // Widgets - private TableViewer viewer; - private Button removeButton; - private Button changeButton; - - /** - * 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 - */ - public void init(IWorkbench workbench) { - } - /* - * @see PreferencePage#createControl - */ - protected Control createContents(Composite ancestor) { - - 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); - - 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() { - 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() { - public void doubleClick(DoubleClickEvent event) { - ISelection selection = event.getSelection(); - if (selection == null || !(selection instanceof IStructuredSelection)) { - return; - } - viewer.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()); - } - }); - 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() { - public void handleEvent(Event e) { - addPattern(); - } - }); - - 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() { - public void handleEvent(Event e) { - removePattern(); - } - }); - - 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() { - public void handleEvent(Event e) { - changePattern(); - } - }); - fillTable(Team.getAllTypes()); - Dialog.applyDialogFont(parent); - return parent; - } - - protected void performDefaults() { - super.performDefaults(); - IFileTypeInfo[] infos = Team.getDefaultTypes(); - fillTable(infos); - } - - /** - * Do anything necessary because the OK button has been pressed. - * - * @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); - return true; - } - /** - * Fill the table with the values from the file type registry - */ - 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; - } - } - viewer.setInput(input); - } - /** - * 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$ - dialog.open(); - if (dialog.getReturnCode() != InputDialog.OK) return; - String pattern = dialog.getValue(); - if (pattern.equals("")) return; //$NON-NLS-1$ - // Check if the item already exists - Iterator it = input.iterator(); - while (it.hasNext()) { - TableEntry entry = (TableEntry)it.next(); - if (entry.getExtension().equals(pattern)) { - 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(); - } - /** - * Remove the selected items from the table - */ - private void removePattern() { - ISelection selection = viewer.getSelection(); - if (selection == null || !(selection instanceof IStructuredSelection)) { - return; - } - IStructuredSelection ss = (IStructuredSelection)selection; - Iterator it = ss.iterator(); - while (it.hasNext()) { - TableEntry entry = (TableEntry)it.next(); - input.remove(entry); - } - viewer.refresh(); - } - /** - * Toggle the selected items' content types - */ - private void changePattern() { - ISelection selection = viewer.getSelection(); - if (selection == null || !(selection instanceof IStructuredSelection)) { - 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); - } - } - /** - * 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); - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/RegistryReader.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/RegistryReader.java deleted file mode 100644 index 5768755f7..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/RegistryReader.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.registry; - -import java.util.Hashtable; - -import org.eclipse.core.runtime.*; -import org.eclipse.team.internal.ui.Utils.Sorter; -import org.eclipse.ui.internal.WorkbenchPlugin; - -public abstract class RegistryReader { - protected static final String TAG_DESCRIPTION = "description"; //$NON-NLS-1$ - protected static Hashtable extensionPoints = new Hashtable(); - /** - * The constructor. - */ - protected RegistryReader() { - } - /** - * This method extracts description as a subelement of the given element. - * - * @return description string if defined, or empty string if not. - */ - protected String getDescription(IConfigurationElement config) { - IConfigurationElement[] children = config.getChildren(TAG_DESCRIPTION); - if (children.length >= 1) { - return children[0].getValue(); - } - return ""; //$NON-NLS-1$ - } - /** - * Logs the error in the workbench log using the provided text and the - * information in the configuration element. - */ - protected void logError(IConfigurationElement element, String text) { - IExtension extension = element.getDeclaringExtension(); - IPluginDescriptor descriptor = extension.getDeclaringPluginDescriptor(); - StringBuffer buf = new StringBuffer(); - buf.append("Plugin " + descriptor.getUniqueIdentifier() + ", extension " + extension.getExtensionPointUniqueIdentifier()); //$NON-NLS-2$//$NON-NLS-1$ - buf.append("\n" + text); //$NON-NLS-1$ - WorkbenchPlugin.log(buf.toString()); - } - /** - * Logs a very common registry error when a required attribute is missing. - */ - protected void logMissingAttribute(IConfigurationElement element, String attributeName) { - logError(element, "Required attribute '" + attributeName + "' not defined"); //$NON-NLS-2$//$NON-NLS-1$ - } - - /** - * Logs a very common registry error when a required child is missing. - */ - protected void logMissingElement(IConfigurationElement element, String elementName) { - logError(element, "Required sub element '" + elementName + "' not defined"); //$NON-NLS-2$//$NON-NLS-1$ - } - - /** - * Logs a registry error when the configuration element is unknown. - */ - protected void logUnknownElement(IConfigurationElement element) { - logError(element, "Unknown extension tag found: " + element.getName()); //$NON-NLS-1$ - } - /** - * Apply a reproducable order to the list of extensions provided, such that - * the order will not change as extensions are added or removed. - */ - protected IExtension[] orderExtensions(IExtension[] extensions) { - // By default, the order is based on plugin id sorted - // in ascending order. The order for a plugin providing - // more than one extension for an extension point is - // dependent in the order listed in the XML file. - Sorter sorter = new Sorter() { - public boolean compare(Object extension1, Object extension2) { - String s1 = ((IExtension) extension1).getDeclaringPluginDescriptor().getUniqueIdentifier(); - String s2 = ((IExtension) extension2).getDeclaringPluginDescriptor().getUniqueIdentifier(); - //Return true if elementTwo is 'greater than' elementOne - return s2.compareToIgnoreCase(s1) > 0; - } - }; - - Object[] sorted = sorter.sort(extensions); - IExtension[] sortedExtension = new IExtension[sorted.length]; - System.arraycopy(sorted, 0, sortedExtension, 0, sorted.length); - return sortedExtension; - } - /** - * Implement this method to read element's attributes. If children should - * also be read, then implementor is responsible for calling <code>readElementChildren</code>. - * Implementor is also responsible for logging missing attributes. - * - * @return true if element was recognized, false if not. - */ - protected abstract boolean readElement(IConfigurationElement element); - /** - * Read the element's children. This is called by the subclass' readElement - * method when it wants to read the children of the element. - */ - protected void readElementChildren(IConfigurationElement element) { - readElements(element.getChildren()); - } - /** - * Read each element one at a time by calling the subclass implementation - * of <code>readElement</code>. - * - * Logs an error if the element was not recognized. - */ - protected void readElements(IConfigurationElement[] elements) { - for (int i = 0; i < elements.length; i++) { - if (!readElement(elements[i])) - logUnknownElement(elements[i]); - } - } - /** - * Read one extension by looping through its configuration elements. - */ - protected void readExtension(IExtension extension) { - readElements(extension.getConfigurationElements()); - } - /** - * Start the registry reading process using the supplied plugin ID and - * extension point. - */ - public void readRegistry(IPluginRegistry registry, String pluginId, String extensionPoint) { - String pointId = pluginId + "-" + extensionPoint; //$NON-NLS-1$ - IExtension[] extensions = (IExtension[]) extensionPoints.get(pointId); - if (extensions == null) { - IExtensionPoint point = registry.getExtensionPoint(pluginId, extensionPoint); - if (point == null) - return; - extensions = point.getExtensions(); - extensionPoints.put(pointId, extensions); - } - for (int i = 0; i < extensions.length; i++) - readExtension(extensions[i]); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantDescriptor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantDescriptor.java deleted file mode 100644 index d8b96a3dc..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantDescriptor.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.registry; - -import org.eclipse.core.runtime.*; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor; - -public class SynchronizeParticipantDescriptor implements ISynchronizeParticipantDescriptor { - public static final String ATT_ID = "id"; //$NON-NLS-1$ - public static final String ATT_NAME = "name"; //$NON-NLS-1$ - public static final String ATT_ICON = "icon"; //$NON-NLS-1$ - public static final String ATT_CLASS = "class"; //$NON-NLS-1$ - private static final String ATT_TYPE = "type"; //$NON-NLS-1$ - private static final String ATT_PERSISTENT = "persistent"; //$NON-NLS-1$ - - private String label; - private String className; - private String type; - private String id; - private boolean persistent; - private ImageDescriptor imageDescriptor; - private String description; - - private IConfigurationElement configElement; - - /** - * Create a new ViewDescriptor for an extension. - */ - public SynchronizeParticipantDescriptor(IConfigurationElement e, String desc) throws CoreException { - configElement = e; - description = desc; - loadFromExtension(); - } - - public IConfigurationElement getConfigurationElement() { - return configElement; - } - - /** - * Returns this view's description. This is the value of its <code>"description"</code> - * attribute. - * - * @return the description - */ - public String getDescription() { - return description; - } - - public String getId() { - return id; - } - - public String getType() { - return type; - } - - public ImageDescriptor getImageDescriptor() { - if (imageDescriptor != null) - return imageDescriptor; - String iconName = configElement.getAttribute(ATT_ICON); - if (iconName == null) - return null; - imageDescriptor = TeamUIPlugin.getImageDescriptorFromExtension(configElement.getDeclaringExtension(), iconName); - return imageDescriptor; - } - - public String getName() { - return label; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor#isPersistent() - */ - public boolean isPersistent() { - return persistent; - } - - /** - * load a view descriptor from the registry. - */ - private void loadFromExtension() throws CoreException { - String identifier = configElement.getAttribute(ATT_ID); - label = configElement.getAttribute(ATT_NAME); - className = configElement.getAttribute(ATT_CLASS); - type = configElement.getAttribute(ATT_TYPE); - String persistentString = configElement.getAttribute(ATT_PERSISTENT); - if(persistentString == null) { - persistent = true; - } else { - persistent = Boolean.valueOf(persistentString).booleanValue(); - } - // Sanity check. - if ((label == null) || (className == null) || (identifier == null)) { - throw new CoreException(new Status(IStatus.ERROR, configElement.getDeclaringExtension().getDeclaringPluginDescriptor().getUniqueIdentifier(), 0, "Invalid extension (missing label or class name): " + identifier, //$NON-NLS-1$ - null)); - } - id = identifier; - } - - /** - * Returns a string representation of this descriptor. For debugging - * purposes only. - */ - public String toString() { - return "Synchronize Participant(" + getId() + ")"; //$NON-NLS-2$//$NON-NLS-1$ - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantRegistry.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantRegistry.java deleted file mode 100644 index 73ab80fe3..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantRegistry.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.registry; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.team.internal.ui.TeamUIPlugin; - -public class SynchronizeParticipantRegistry extends RegistryReader { - - private static final String TAG_SYNCPARTICIPANT = "participant"; //$NON-NLS-1$ - private Map participants = new HashMap(); - - public SynchronizeParticipantRegistry() { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.registry.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement) - */ - protected boolean readElement(IConfigurationElement element) { - if (element.getName().equals(TAG_SYNCPARTICIPANT)) { - String descText = getDescription(element); - SynchronizeParticipantDescriptor desc; - try { - desc = new SynchronizeParticipantDescriptor(element, descText); - participants.put(desc.getId(), desc); - } catch (CoreException e) { - TeamUIPlugin.log(e); - } - return true; - } - return false; - } - - public SynchronizeParticipantDescriptor[] getSynchronizeParticipants() { - return (SynchronizeParticipantDescriptor[])participants.values().toArray(new SynchronizeParticipantDescriptor[participants.size()]); - } - - public SynchronizeParticipantDescriptor find(String id) { - return (SynchronizeParticipantDescriptor)participants.get(id); - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeWizardDescription.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeWizardDescription.java deleted file mode 100644 index ef53295c0..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeWizardDescription.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.registry; - -import org.eclipse.core.runtime.*; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.ui.internal.WorkbenchPlugin; - -/** - * Descriptor for accessing and creating synchronize wizards - */ -public class SynchronizeWizardDescription { - - public static final String ATT_ID = "id"; //$NON-NLS-1$ - public static final String ATT_NAME = "name"; //$NON-NLS-1$ - public static final String ATT_ICON = "icon"; //$NON-NLS-1$ - public static final String ATT_CLASS = "class"; //$NON-NLS-1$ - public static final String ATT_DESCRIPTION = "description"; //$NON-NLS-1$ - - private String label; - private String className; - private String description; - private String id; - private ImageDescriptor imageDescriptor; - - private IConfigurationElement configElement; - - public SynchronizeWizardDescription(IConfigurationElement e, String descText) throws CoreException { - configElement = e; - loadFromExtension(); - } - - public IWizard createWizard() throws CoreException { - Object obj = WorkbenchPlugin.createExtension(configElement, ATT_CLASS); - return (IWizard) obj; - } - - private void loadFromExtension() throws CoreException { - String identifier = configElement.getAttribute(ATT_ID); - label = configElement.getAttribute(ATT_NAME); - className = configElement.getAttribute(ATT_CLASS); - description = configElement.getAttribute(ATT_DESCRIPTION); - - // Sanity check. - if ((label == null) || (className == null) || (identifier == null) || (description == null)) { - throw new CoreException(new Status(IStatus.ERROR, configElement.getDeclaringExtension().getDeclaringPluginDescriptor().getUniqueIdentifier(), 0, "Invalid extension (missing label or class name): " + identifier, //$NON-NLS-1$ - null)); - } - - id = identifier; - } - - public String getId() { - return id; - } - - public String getDescription() { - return description; - } - - public ImageDescriptor getImageDescriptor() { - if (imageDescriptor != null) - return imageDescriptor; - String iconName = configElement.getAttribute(ATT_ICON); - if (iconName == null) - return null; - imageDescriptor = TeamUIPlugin.getImageDescriptorFromExtension(configElement.getDeclaringExtension(), iconName); - return imageDescriptor; - } - - public String getName() { - return label; - } - - public String toString() { - return "Synchronize Participant Creation Wizard(" + getId() + ")"; //$NON-NLS-2$//$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeWizardRegistry.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeWizardRegistry.java deleted file mode 100644 index 1caf7c75d..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeWizardRegistry.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.registry; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.team.internal.ui.TeamUIPlugin; - -public class SynchronizeWizardRegistry extends RegistryReader { - - private static final String TAG_SYNCHRONIZE_WIZARD = "wizard"; //$NON-NLS-1$ - private Map wizards = new HashMap(); - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.registry.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement) - */ - protected boolean readElement(IConfigurationElement element) { - if (element.getName().equals(TAG_SYNCHRONIZE_WIZARD)) { - String descText = getDescription(element); - SynchronizeWizardDescription desc; - try { - desc = new SynchronizeWizardDescription(element, descText); - wizards.put(desc.getId(), desc); - } catch (CoreException e) { - TeamUIPlugin.log(e); - } - return true; - } - return false; - } - - public SynchronizeWizardDescription[] getSynchronizeWizards() { - return (SynchronizeWizardDescription[])wizards.values().toArray(new SynchronizeWizardDescription[wizards.size()]); - } - - public SynchronizeWizardDescription find(String id) { - return (SynchronizeWizardDescription)wizards.get(id); - } - -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActionDelegateWrapper.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActionDelegateWrapper.java deleted file mode 100644 index d85b8878d..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActionDelegateWrapper.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.synchronize; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.ui.IActionDelegate; -import org.eclipse.ui.IEditorActionDelegate; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IWorkbenchPart; - -/** - * An Action that wraps IActionDelegates so they can be used programatically - * in toolbars, etc. - */ -public class ActionDelegateWrapper extends Action implements ISelectionChangedListener { - - private IActionDelegate delegate; - - public ActionDelegateWrapper(IActionDelegate delegate, ISynchronizePageConfiguration configuration) { - this.delegate = delegate; - IWorkbenchPart part = configuration.getSite().getPart(); - if(part != null) { - if (delegate instanceof IObjectActionDelegate) { - ((IObjectActionDelegate)delegate).setActivePart(this, part); - } - if (part instanceof IViewPart - && delegate instanceof IViewActionDelegate) { - ((IViewActionDelegate)delegate).init((IViewPart)part); - } - if (part instanceof IEditorPart - && delegate instanceof IViewActionDelegate) { - ((IEditorActionDelegate)delegate).setActiveEditor(this, (IEditorPart)part); - } - } - initialize(configuration); - } - - /** - * Method invoked from the constructor when a configuration is provided. - * The default implementation registers the action as a selection change - * listener. Subclass may override. - * @param configuration the synchronize page configuration - */ - protected void initialize(final ISynchronizePageConfiguration configuration) { - configuration.getSite().getSelectionProvider().addSelectionChangedListener(this); - configuration.getPage().getViewer().getControl().addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - configuration.getSite().getSelectionProvider().removeSelectionChangedListener(ActionDelegateWrapper.this); - } - }); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ - public void selectionChanged(SelectionChangedEvent event) { - getDelegate().selectionChanged(this, event.getSelection()); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - getDelegate().run(this); - } - - /** - * Return the delegate associated with this action. - * @return the delegate associated with this action - */ - public IActionDelegate getDelegate() { - return delegate; - } - -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangesSection.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangesSection.java deleted file mode 100644 index 3d3c5c919..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangesSection.java +++ /dev/null @@ -1,343 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.ITeamStatus; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.internal.ui.*; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.forms.HyperlinkGroup; -import org.eclipse.ui.forms.events.HyperlinkAdapter; -import org.eclipse.ui.forms.events.HyperlinkEvent; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.Hyperlink; -import org.eclipse.ui.part.PageBook; - -/** - * Section shown in a participant page to show the changes for this participant. This - * includes a diff viewer for browsing the changes. - * - * @since 3.0 - */ -public class ChangesSection extends Composite { - - private ISynchronizeParticipant participant; - private SyncInfoSetSynchronizePage page; - private FormToolkit forms; - - /** - * Page book either shows the diff tree viewer if there are changes or - * shows a message to the user if there are no changes that would be - * shown in the tree. - */ - private PageBook changesSectionContainer; - - /** - * Shows message to user is no changes are to be shown in the diff - * tree viewer. - */ - private Composite filteredContainer; - - /** - * Diff tree viewer that shows synchronization changes. This is created - * by the participant. - */ - private Viewer changesViewer; - - /** - * Boolean that indicates whether the error page is being shown. - * This is used to avoid redrawing the error page when new events come in - */ - private boolean showingError; - - /** - * Register an action contribution in order to receive model - * change notification so that we can update message to user and totals. - */ - private SynchronizePageActionGroup changedListener = new SynchronizePageActionGroup() { - public void modelChanged(ISynchronizeModelElement root) { - calculateDescription(); - } - }; - - /** - * Listener registered with the subscriber sync info set which contains - * all out-of-sync resources for the subscriber. - */ - private ISyncInfoSetChangeListener subscriberListener = new ISyncInfoSetChangeListener() { - public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) { - // Handled by output set listener - } - public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor) { - calculateDescription(); - } - public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) { - // Handled by output set listener - } - }; - - /** - * Listener registered with the output sync info set which contains - * only the visible sync info. - */ - private ISyncInfoSetChangeListener outputSetListener = new ISyncInfoSetChangeListener() { - public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) { - calculateDescription(); - } - public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor) { - // Input changed listener will call calculateDescription() - // The input will then react to output set changes - } - public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) { - calculateDescription(); - } - }; - private ISynchronizePageConfiguration configuration; - - /** - * Create a changes section on the following page. - * - * @param parent the parent control - * @param page the page showing this section - */ - public ChangesSection(Composite parent, SyncInfoSetSynchronizePage page, ISynchronizePageConfiguration configuration) { - super(parent, SWT.NONE); - this.page = page; - this.configuration = configuration; - this.participant = configuration.getParticipant(); - - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - setLayout(layout); - GridData data = new GridData(GridData.FILL_BOTH); - data.grabExcessVerticalSpace = true; - setLayoutData(data); - - forms = new FormToolkit(parent.getDisplay()); - forms.setBackground(getBackgroundColor()); - HyperlinkGroup group = forms.getHyperlinkGroup(); - group.setBackground(getBackgroundColor()); - - changesSectionContainer = new PageBook(this, SWT.NONE); - data = new GridData(GridData.FILL_BOTH); - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = true; - changesSectionContainer.setLayoutData(data); - } - - public Composite getComposite() { - return changesSectionContainer; - } - - public void setViewer(Viewer viewer) { - this.changesViewer = viewer; - calculateDescription(); - configuration.addActionContribution(changedListener); - getWorkingSetSyncInfoSet().addSyncSetChangedListener(subscriberListener); - getSyncInfoTree().addSyncSetChangedListener(outputSetListener); - } - - private void calculateDescription() { - SyncInfoTree syncInfoTree = getSyncInfoTree(); - if (syncInfoTree.getErrors().length > 0) { - if (!showingError) { - TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - if (changesSectionContainer.isDisposed()) return; - if(filteredContainer != null) { - filteredContainer.dispose(); - filteredContainer = null; - } - filteredContainer = getErrorComposite(changesSectionContainer); - changesSectionContainer.showPage(filteredContainer); - showingError = true; - } - }); - } - return; - } - - showingError = false; - if(syncInfoTree.size() == 0) { - TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - if (changesSectionContainer.isDisposed()) return; - if(filteredContainer != null) { - filteredContainer.dispose(); - filteredContainer = null; - } - filteredContainer = getEmptyChangesComposite(changesSectionContainer); - changesSectionContainer.showPage(filteredContainer); - } - }); - } else { - TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - if(filteredContainer != null) { - filteredContainer.dispose(); - filteredContainer = null; - } - Control control = changesViewer.getControl(); - if (!changesSectionContainer.isDisposed() && !control.isDisposed()) { - changesSectionContainer.showPage(control); - } - } - }); - } - } - - private boolean isThreeWay() { - return ISynchronizePageConfiguration.THREE_WAY.equals(configuration.getComparisonType()); - } - - private Composite getEmptyChangesComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - composite.setBackground(getBackgroundColor()); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - composite.setLayout(layout); - GridData data = new GridData(GridData.FILL_BOTH); - data.grabExcessVerticalSpace = true; - composite.setLayoutData(data); - - if(! isThreeWay()) { - createDescriptionLabel(composite,Policy.bind("ChangesSection.noChanges", participant.getName())); //$NON-NLS-1$ - return composite; - } - - SyncInfoSet workingSet = getWorkingSetSyncInfoSet(); - SyncInfoSet filteredSet = getSyncInfoTree(); - - int changesInWorkingSet = workingSet.size(); - int changesInFilter = filteredSet.size(); - - long outgoingChanges = workingSet.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK); - long incomingChanges = workingSet.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK); - - if(changesInFilter == 0 && changesInWorkingSet != 0) { - final int newMode = outgoingChanges != 0 ? ISynchronizePageConfiguration.OUTGOING_MODE : ISynchronizePageConfiguration.INCOMING_MODE; - long numChanges = outgoingChanges != 0 ? outgoingChanges : incomingChanges; - StringBuffer text = new StringBuffer(); - text.append(Policy.bind("ChangesSection.filterHides", Utils.modeToString(configuration.getMode()))); //$NON-NLS-1$ - if(numChanges > 1) { - text.append(Policy.bind("ChangesSection.filterHidesPlural", Long.toString(numChanges), Utils.modeToString(newMode))); //$NON-NLS-1$ - } else { - text.append(Policy.bind("ChangesSection.filterHidesSingular", Long.toString(numChanges), Utils.modeToString(newMode))); //$NON-NLS-1$ - } - - Label warning = new Label(composite, SWT.NONE); - warning.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING)); - - Hyperlink link = forms.createHyperlink(composite, Policy.bind("ChangesSection.filterChange", Utils.modeToString(newMode)), SWT.WRAP); //$NON-NLS-1$ - link.addHyperlinkListener(new HyperlinkAdapter() { - public void linkActivated(HyperlinkEvent e) { - configuration.setMode(newMode); - } - }); - forms.getHyperlinkGroup().add(link); - createDescriptionLabel(composite, text.toString()); - } else { - createDescriptionLabel(composite,Policy.bind("ChangesSection.noChanges", participant.getName())); //$NON-NLS-1$ - } - return composite; - } - - private Label createDescriptionLabel(Composite parent, String text) { - Label description = new Label(parent, SWT.WRAP); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - data.widthHint = 100; - description.setLayoutData(data); - description.setText(text); - description.setBackground(getBackgroundColor()); - return description; - } - - public void dispose() { - super.dispose(); - forms.dispose(); - configuration.removeActionContribution(changedListener); - getWorkingSetSyncInfoSet().removeSyncSetChangedListener(subscriberListener); - } - - private Composite getErrorComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - composite.setBackground(getBackgroundColor()); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - composite.setLayout(layout); - GridData data = new GridData(GridData.FILL_BOTH); - data.grabExcessVerticalSpace = true; - composite.setLayoutData(data); - - Hyperlink link = new Hyperlink(composite, SWT.WRAP); - link.setText(Policy.bind("ChangesSection.8")); //$NON-NLS-1$ - link.addHyperlinkListener(new HyperlinkAdapter() { - public void linkActivated(HyperlinkEvent e) { - showErrors(); - } - }); - link.setBackground(getBackgroundColor()); - link.setUnderlined(true); - - link = new Hyperlink(composite, SWT.WRAP); - link.setText(Policy.bind("ChangesSection.9")); //$NON-NLS-1$ - link.addHyperlinkListener(new HyperlinkAdapter() { - public void linkActivated(HyperlinkEvent e) { - page.reset(); - } - }); - link.setBackground(getBackgroundColor()); - link.setUnderlined(true); - - createDescriptionLabel(composite, Policy.bind("ChangesSection.10", participant.getName())); //$NON-NLS-1$ - - return composite; - } - - /* private */ void showErrors() { - ITeamStatus[] status = getSyncInfoTree().getErrors(); - String title = Policy.bind("ChangesSection.11"); //$NON-NLS-1$ - if (status.length == 1) { - ErrorDialog.openError(getShell(), title, status[0].getMessage(), status[0]); - } else { - MultiStatus multi = new MultiStatus(TeamUIPlugin.ID, 0, status, Policy.bind("ChangesSection.12"), null); //$NON-NLS-1$ - ErrorDialog.openError(getShell(), title, null, multi); - } - } - - protected Color getBackgroundColor() { - return getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND); - } - - private SyncInfoTree getSyncInfoTree() { - return (SyncInfoTree)configuration.getProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET); - } - - private SyncInfoSet getWorkingSetSyncInfoSet() { - return (SyncInfoSet)configuration.getProperty(SynchronizePageConfiguration.P_WORKING_SET_SYNC_INFO_SET); - } - - private SyncInfoSet getParticpantSyncInfoSet() { - return (SyncInfoSet)configuration.getProperty(SynchronizePageConfiguration.P_PARTICIPANT_SYNC_INFO_SET); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompressedFoldersModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompressedFoldersModelProvider.java deleted file mode 100644 index e986c0e2c..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompressedFoldersModelProvider.java +++ /dev/null @@ -1,304 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import java.util.*; - -import org.eclipse.compare.structuremergeviewer.IDiffContainer; -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.*; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.ui.ISharedImages; -import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; - -public class CompressedFoldersModelProvider extends HierarchicalModelProvider { - - protected class UnchangedCompressedDiffNode extends UnchangedResourceModelElement { - public UnchangedCompressedDiffNode(IDiffContainer parent, IResource resource) { - super(parent, resource); - } - - /* (non-Javadoc) - * @see org.eclipse.compare.structuremergeviewer.DiffNode#getName() - */ - public String getName() { - IResource resource = getResource(); - return resource.getProjectRelativePath().toString(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SyncInfoModelElement#getImageDescriptor(java.lang.Object) - */ - public ImageDescriptor getImageDescriptor(Object object) { - return TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_COMPRESSED_FOLDER); - } - } - - /** - * A compressed folder appears under a project and contains out-of-sync resources - */ - public class CompressedFolderDiffNode extends SyncInfoModelElement { - - public CompressedFolderDiffNode(IDiffContainer parent, SyncInfo info) { - super(parent, info); - } - - /* (non-Javadoc) - * @see org.eclipse.compare.structuremergeviewer.DiffNode#getName() - */ - public String getName() { - IResource resource = getResource(); - return resource.getProjectRelativePath().toString(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SyncInfoModelElement#getImageDescriptor(java.lang.Object) - */ - public ImageDescriptor getImageDescriptor(Object object) { - return TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_COMPRESSED_FOLDER); - } - } - - public static class CompressedFolderModelProviderDescriptor implements ISynchronizeModelProviderDescriptor { - public static final String ID = TeamUIPlugin.ID + ".modelprovider_compressedfolders"; - public String getId() { - return ID; - } - public String getName() { - return "Compressed Folders"; - } - public ImageDescriptor getImageDescriptor() { - return TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_COMPRESSED_FOLDER); - } - }; - private static final CompressedFolderModelProviderDescriptor compressedDescriptor = new CompressedFolderModelProviderDescriptor(); - - public CompressedFoldersModelProvider(ISynchronizePageConfiguration configuration, SyncInfoTree set) { - super(configuration, set); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.HierarchicalModelProvider#getDescriptor() - */ - public ISynchronizeModelProviderDescriptor getDescriptor() { - return compressedDescriptor; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SyncInfoDiffNodeRoot#getSorter() - */ - public ViewerSorter getViewerSorter() { - return new SynchronizeModelElementSorter() { - protected int compareNames(IResource resource1, IResource resource2) { - if (resource1.getType() == IResource.FOLDER && resource2.getType() == IResource.FOLDER) { - return collator.compare(resource1.getProjectRelativePath().toString(), resource2.getProjectRelativePath().toString()); - } - return super.compareNames(resource1, resource2); - } - }; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.HierarchicalModelProvider#createModelObjects(org.eclipse.compare.structuremergeviewer.DiffNode) - */ - protected IDiffElement[] createModelObjects(ISynchronizeModelElement container) { - IResource resource = null; - if (container == getModelRoot()) { - resource = ResourcesPlugin.getWorkspace().getRoot(); - } else { - resource = container.getResource(); - } - if(resource != null) { - if (resource.getType() == IResource.PROJECT) { - return getProjectChildren(container, (IProject)resource); - } - if (resource.getType() == IResource.FOLDER) { - return getFolderChildren(container, resource); - } - } - return super.createModelObjects(container); - } - - private IDiffElement[] getFolderChildren(ISynchronizeModelElement parent, IResource resource) { - // Folders will only contain out-of-sync children - IResource[] children = getSyncInfoTree().members(resource); - List result = new ArrayList(); - for (int i = 0; i < children.length; i++) { - IResource child = children[i]; - if (child.getType() == IResource.FILE) { - result.add(createModelObject(parent, child)); - } - } - return (IDiffElement[])result.toArray(new IDiffElement[result.size()]); - } - - private IDiffElement[] getProjectChildren(ISynchronizeModelElement parent, IProject project) { - // The out-of-sync elements could possibly include the project so the code - // below is written to ignore the project - SyncInfo[] outOfSync = getSyncInfoTree().getSyncInfos(project, IResource.DEPTH_INFINITE); - Set result = new HashSet(); - Set resourcesToShow = new HashSet(); - for (int i = 0; i < outOfSync.length; i++) { - SyncInfo info = outOfSync[i]; - IResource local = info.getLocal(); - if (local.getProjectRelativePath().segmentCount() == 1 && local.getType() == IResource.FILE) { - resourcesToShow.add(local); - } else { - if (local.getType() == IResource.FILE) { - resourcesToShow.add(local.getParent()); - } else if (local.getType() == IResource.FOLDER){ - resourcesToShow.add(local); - } - } - } - for (Iterator iter = resourcesToShow.iterator(); iter.hasNext();) { - IResource resource = (IResource) iter.next(); - result.add(createModelObject(parent, resource)); - } - - return (IDiffElement[])result.toArray(new IDiffElement[result.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.views.HierarchicalModelProvider#createChildNode(org.eclipse.compare.structuremergeviewer.DiffNode, org.eclipse.core.resources.IResource) - */ - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.HierarchicalModelProvider#createModelObject(org.eclipse.compare.structuremergeviewer.DiffNode, org.eclipse.core.resources.IResource) - */ - protected ISynchronizeModelElement createModelObject(ISynchronizeModelElement parent, IResource resource) { - if (resource.getType() == IResource.FOLDER) { - SyncInfo info = getSyncInfoTree().getSyncInfo(resource); - ISynchronizeModelElement newNode; - if(info != null) { - newNode = new CompressedFolderDiffNode(parent, info); - } else { - newNode = new UnchangedCompressedDiffNode(parent, resource); - } - addToViewer(newNode); - return newNode; - } - return super.createModelObject(parent, resource); - } - - /** - * Update the viewer for the sync set additions in the provided event. - * This method is invoked by <code>handleChanges(ISyncInfoSetChangeEvent)</code>. - * Subclasses may override. - * @param event - */ - protected void handleResourceAdditions(ISyncInfoTreeChangeEvent event) { - SyncInfo[] infos = event.getAddedResources(); - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - addResource(info); - } - } - - private void addResource(SyncInfo info) { - IResource local = info.getLocal(); - ISynchronizeModelElement existingNode = getModelObject(local); - if (existingNode == null) { - if (local.getType() == IResource.FILE) { - ISynchronizeModelElement parentNode = getModelObject(local.getParent()); - if (parentNode == null) { - ISynchronizeModelElement projectNode = getModelObject(local.getProject()); - if (projectNode == null) { - projectNode = createModelObject(getModelRoot(), local.getProject()); - } - if (local.getParent().getType() == IResource.PROJECT) { - parentNode = projectNode; - } else { - parentNode = createModelObject(projectNode, local.getParent()); - } - } - createModelObject(parentNode, local); - } else { - ISynchronizeModelElement projectNode = getModelObject(local.getProject()); - if (projectNode == null) { - projectNode = createModelObject(getModelRoot(), local.getProject()); - } - createModelObject(projectNode, local); - } - } else { - // Either The folder node was added as the parent of a newly added out-of-sync file - // or the file was somehow already there so just refresh - handleChange(existingNode, info); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.sync.views.SyncSetContentProvider#handleResourceRemovals(org.eclipse.team.internal.ui.sync.views.SyncSetChangedEvent) - */ - protected void handleResourceRemovals(ISyncInfoTreeChangeEvent event) { - IResource[] roots = event.getRemovedSubtreeRoots(); - - // First, deal with any projects that have been removed - List removedProjects = new ArrayList(); - for (int i = 0; i < roots.length; i++) { - IResource resource = roots[i]; - if (resource.getType() == IResource.PROJECT) { - removeFromViewer(resource); - removedProjects.add(resource); - } - } - - IResource[] resources = event.getRemovedResources(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - if (!removedProjects.contains(resource.getProject())) { - if (resource.getType() == IResource.FILE) { - if (isCompressedParentEmpty(resource)) { - // The parent compressed folder is also empty so remove it - removeFromViewer(resource.getParent()); - } else { - removeFromViewer(resource); - } - } else { - // A folder has been removed (i.e. is in-sync) - // but may still contain children - removeFromViewer(resource); - if (hasFileMembers((IContainer)resource)) { - createModelObject(getModelObject(resource.getProject()), resource); - buildModelObjects(getModelObject(resource)); - } - } - } - } - } - - private boolean isCompressedParentEmpty(IResource resource) { - IContainer parent = resource.getParent(); - if (parent == null - || parent.getType() == IResource.ROOT - || parent.getType() == IResource.PROJECT) { - return false; - } - return !hasFileMembers(parent); - } - - private boolean hasFileMembers(IContainer parent) { - // Check if the sync set has any file children of the parent - IResource[] members = getSyncInfoTree().members(parent); - for (int i = 0; i < members.length; i++) { - IResource member = members[i]; - if (member.getType() == IResource.FILE) { - return true; - } - } - // The parent does not contain any files - return false; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureRefreshScheduleDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureRefreshScheduleDialog.java deleted file mode 100644 index 8e8d2fdd6..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureRefreshScheduleDialog.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.eclipse.team.internal.ui.synchronize; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.dialogs.DetailsDialog; - -/** - * Dialog that allows configuring a subscriber refresh schedule. - * - * @since 3.0 - */ -public class ConfigureRefreshScheduleDialog extends DetailsDialog { - - private ConfigureSynchronizeScheduleComposite scheduleComposite; - private SubscriberRefreshSchedule schedule; - - public ConfigureRefreshScheduleDialog(Shell parentShell, SubscriberRefreshSchedule schedule) { - super(parentShell, Policy.bind("ConfigureRefreshScheduleDialog.0", schedule.getParticipant().getName())); //$NON-NLS-1$ - this.schedule = schedule; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected void createMainDialogArea(Composite parent) { - IPageValidator validator = new IPageValidator() { - public void setComplete(String errorMessage) { - setPageComplete(errorMessage == null); - setErrorMessage(errorMessage); - } - }; - scheduleComposite = new ConfigureSynchronizeScheduleComposite(parent, schedule, validator); - Dialog.applyDialogFont(parent); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#okPressed() - */ - protected void okPressed() { - scheduleComposite.saveValues(); - super.okPressed(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#includeDetailsButton() - */ - protected boolean includeDetailsButton() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#createDropDownDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Composite createDropDownDialogArea(Composite parent) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#updateEnablements() - */ - protected void updateEnablements() { - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java deleted file mode 100644 index 0fe5a4e1d..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java +++ /dev/null @@ -1,198 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ui.Policy; - -/** - * A composite that allows editing a subscriber refresh schedule. A validator can be used to allow - * containers to show page completiong. - * - * @since 3.0 - */ -public class ConfigureSynchronizeScheduleComposite extends Composite { - - private SubscriberRefreshSchedule schedule; - private Button userRefreshOnly; - private Button enableBackgroundRefresh; - private Text time; - private Combo hoursOrSeconds; - private String errorMessage; - private IPageValidator validator; - - public ConfigureSynchronizeScheduleComposite(Composite parent, SubscriberRefreshSchedule schedule, IPageValidator validator) { - super(parent, SWT.NONE); - this.schedule = schedule; - this.validator = validator; - createMainDialogArea(parent); - } - - private void initializeValues() { - boolean enableBackground = schedule.isEnabled(); - boolean hours = false; - - userRefreshOnly.setSelection(! enableBackground); - enableBackgroundRefresh.setSelection(enableBackground); - - long seconds = schedule.getRefreshInterval(); - if(seconds <= 60) { - seconds = 60; - } - - long minutes = seconds / 60; - - if(minutes >= 60) { - minutes = minutes / 60; - hours = true; - } - hoursOrSeconds.select(hours ? 0 : 1); - time.setText(Long.toString(minutes)); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected void createMainDialogArea(Composite parent) { - final GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - setLayout(gridLayout); - setLayoutData(new GridData()); - Composite area = this; - - { - final Label label = new Label(area, SWT.WRAP); - final GridData gridData = new GridData(GridData.FILL_HORIZONTAL); - gridData.horizontalSpan = 2; - label.setLayoutData(gridData); - label.setText(Policy.bind("ConfigureRefreshScheduleDialog.1", schedule.getParticipant().getName())); //$NON-NLS-1$ - } - { - final Label label = new Label(area, SWT.WRAP); - final GridData gridData = new GridData(GridData.FILL_HORIZONTAL); - gridData.horizontalSpan = 2; - label.setLayoutData(gridData); - label.setText(Policy.bind("ConfigureRefreshScheduleDialog.1a", SubscriberRefreshSchedule.refreshEventAsString(schedule.getLastRefreshEvent()))); //$NON-NLS-1$ - } - { - userRefreshOnly = new Button(area, SWT.RADIO); - final GridData gridData = new GridData(); - gridData.horizontalSpan = 2; - userRefreshOnly.setLayoutData(gridData); - userRefreshOnly.setText(Policy.bind("ConfigureRefreshScheduleDialog.2")); //$NON-NLS-1$ - userRefreshOnly.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - updateEnablements(); - } - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - } - { - enableBackgroundRefresh = new Button(area, SWT.RADIO); - final GridData gridData = new GridData(); - gridData.horizontalSpan = 2; - enableBackgroundRefresh.setLayoutData(gridData); - enableBackgroundRefresh.setText(Policy.bind("ConfigureRefreshScheduleDialog.3")); //$NON-NLS-1$ - enableBackgroundRefresh.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - updateEnablements(); - } - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - } - { - final Composite composite = new Composite(area, SWT.NONE); - final GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_BEGINNING); - gridData.horizontalSpan = 2; - composite.setLayoutData(gridData); - final GridLayout gridLayout_1 = new GridLayout(); - gridLayout_1.numColumns = 3; - composite.setLayout(gridLayout_1); - { - final Label label = new Label(composite, SWT.NONE); - label.setText(Policy.bind("ConfigureRefreshScheduleDialog.4")); //$NON-NLS-1$ - } - { - time = new Text(composite, SWT.BORDER | SWT.RIGHT); - final GridData gridData_1 = new GridData(); - gridData_1.widthHint = 35; - time.setLayoutData(gridData_1); - time.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - updateEnablements(); - } - }); - } - { - hoursOrSeconds = new Combo(composite, SWT.READ_ONLY); - hoursOrSeconds.setItems(new String[] { Policy.bind("ConfigureRefreshScheduleDialog.5"), Policy.bind("ConfigureRefreshScheduleDialog.6") }); //$NON-NLS-1$ //$NON-NLS-2$ - final GridData gridData_1 = new GridData(); - gridData_1.widthHint = 75; - hoursOrSeconds.setLayoutData(gridData_1); - } - } - initializeValues(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#okPressed() - */ - public void saveValues() { - int hours = hoursOrSeconds.getSelectionIndex(); - long seconds = Long.parseLong(time.getText()); - if(hours == 0) { - seconds = seconds * 3600; - } else { - seconds = seconds * 60; - } - schedule.setRefreshInterval(seconds); - if(schedule.isEnabled() != enableBackgroundRefresh.getSelection()) { - schedule.setEnabled(enableBackgroundRefresh.getSelection(), true /* allow to start */); - } - - // update schedule - schedule.getParticipant().setRefreshSchedule(schedule); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.dialogs.DetailsDialog#updateEnablements() - */ - public void updateEnablements() { - boolean complete = false; - try { - long number = Long.parseLong(time.getText()); - if(number <= 0) { - validator.setComplete(Policy.bind("ConfigureRefreshScheduleDialog.7")); //$NON-NLS-1$ - } else { - validator.setComplete(null); - complete = true; - } - } catch (NumberFormatException e) { - validator.setComplete(Policy.bind("ConfigureRefreshScheduleDialog.8")); //$NON-NLS-1$ - } - time.setEnabled(enableBackgroundRefresh.getSelection()); - hoursOrSeconds.setEnabled(enableBackgroundRefresh.getSelection()); - } - - protected void setErrorMessage(String error) { - this.errorMessage = error; - } - - public String getErrorMessage() { - return errorMessage; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/DecoratingColorLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/DecoratingColorLabelProvider.java deleted file mode 100644 index 1b8960775..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/DecoratingColorLabelProvider.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; - -/** - * Decorating label provider that supports multiple decorators and color providers. - * - * @since 3.0 - */ -public class DecoratingColorLabelProvider extends DecoratingLabelProvider implements IColorProvider, IFontProvider { - - static class MultiLabelDecorator extends LabelProvider implements ILabelDecorator { - private ILabelDecorator[] decorators; - - public MultiLabelDecorator(ILabelDecorator[] decorators) { - this.decorators = decorators; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ILabelDecorator#decorateImage(org.eclipse.swt.graphics.Image, java.lang.Object) - */ - public Image decorateImage(Image image, Object element) { - for (int i = 0; i < decorators.length; i++) { - ILabelDecorator decorator = decorators[i]; - Image newImage = decorator.decorateImage(image, element); - if (newImage != null) { - image = newImage; - } - } - return image; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ILabelDecorator#decorateText(java.lang.String, java.lang.Object) - */ - public String decorateText(String text, Object element) { - for (int i = 0; i < decorators.length; i++) { - ILabelDecorator decorator = decorators[i]; - String newText = decorator.decorateText(text, element); - if (newText != null) { - text = newText; - } - } - return text; - } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ - public void dispose() { - for (int i = 0; i < decorators.length; i++) { - ILabelDecorator d = decorators[i]; - d.dispose(); - } - } - } - public DecoratingColorLabelProvider(ILabelProvider provider, ILabelDecorator[] decorators) { - super(provider, new MultiLabelDecorator(decorators)); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) - */ - public Color getForeground(Object element) { - ILabelProvider p = getLabelProvider(); - if (p instanceof IColorProvider) { - return ((IColorProvider) p).getForeground(element); - } - return null; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) - */ - public Color getBackground(Object element) { - ILabelProvider p = getLabelProvider(); - if (p instanceof IColorProvider) { - return ((IColorProvider) p).getBackground(element); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object) - */ - public Font getFont(Object element) { - ILabelProvider p = getLabelProvider(); - if (p instanceof IFontProvider) { - return ((IFontProvider) p).getFont(element); - } - return null; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/DiffNodeWorkbenchAdapter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/DiffNodeWorkbenchAdapter.java deleted file mode 100644 index 6ebb34afd..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/DiffNodeWorkbenchAdapter.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.compare.structuremergeviewer.DiffNode; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; -import org.eclipse.ui.model.IWorkbenchAdapter; - -public class DiffNodeWorkbenchAdapter implements IWorkbenchAdapter { - - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object) - */ - public Object[] getChildren(Object o) { - DiffNode node = getDiffNode(o); - return node != null ? node.getChildren() : new Object[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object) - */ - public ImageDescriptor getImageDescriptor(Object o) { - DiffNode node = getDiffNode(o); - if(node instanceof ISynchronizeModelElement) { - return ((ISynchronizeModelElement)node).getImageDescriptor(o); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object) - */ - public String getLabel(Object o) { - DiffNode node = getDiffNode(o); - return node != null ? node.getName() : ""; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object) - */ - public Object getParent(Object o) { - DiffNode node = getDiffNode(o); - return node != null ? node.getParent() : null; - } - - /* - * Return a diff node if the input object is a diff node or null otherwise. - */ - private DiffNode getDiffNode(Object element) { - if(element instanceof DiffNode) { - return (DiffNode)element; - } - return null; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/GlobalRefreshResourceSelectionPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/GlobalRefreshResourceSelectionPage.java deleted file mode 100644 index 7febaad28..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/GlobalRefreshResourceSelectionPage.java +++ /dev/null @@ -1,413 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import java.util.*; -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -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.internal.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.*; -import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.internal.dialogs.ContainerCheckedTreeViewer; -import org.eclipse.ui.model.BaseWorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; -import org.eclipse.ui.views.navigator.ResourceSorter; - -/** - * Page that allows the user to select a set of resources that are managed by a subscriber - * participant. Callers can provide a scope hint to determine the initial selection for the - * resource list. By default, the resources in the current selection are checked, otherwise - * all resources are checked. - * - * @see SubscriberRefreshWizard - * @since 3.0 - */ -public class GlobalRefreshResourceSelectionPage extends WizardPage { - - private boolean scopeCheckingElement = false; - - // Set of scope hint to determine the initial selection - private Button participantScope; - private Button selectedResourcesScope; - private Button workingSetScope; - private Button selectWorkingSetButton; - - // The checked tree viewer - private ContainerCheckedTreeViewer fViewer; - - // Working set label and holder - private Text workingSetLabel; - private IWorkingSet[] workingSets; - private List resources; - - /** - * Content provider that accepts a <code>SubscriberParticipant</code> as input and - * returns the participants root resources. - */ - class MyContentProvider extends BaseWorkbenchContentProvider { - public Object[] getChildren(Object element) { - if(element instanceof List) { - return (IResource[]) ((List)element).toArray(new IResource[((List)element).size()]); - } - return super.getChildren(element); - } - } - - /** - * Label decorator that will display the full path for participant roots that are folders. This - * is useful for participants that have non-project roots. - */ - class MyLabelProvider extends LabelProvider { - private LabelProvider workbenchProvider = new WorkbenchLabelProvider(); - public String getText(Object element) { - if(element instanceof IContainer) { - IContainer c = (IContainer)element; - if(c.getType() != IResource.PROJECT && resources.contains(c)) { - return c.getFullPath().toString(); - } - } - return workbenchProvider.getText(element); - } - public Image getImage(Object element) { - return workbenchProvider.getImage(element); - } - } - - /** - * Create a new page for the given participant. The scope hint will determine the initial selection. - * - * @param participant the participant to synchronize - */ - public GlobalRefreshResourceSelectionPage(IResource[] resources) { - super(Policy.bind("GlobalRefreshResourceSelectionPage.1")); //$NON-NLS-1$ - // Caching the roots so that the decorator doesn't have to recompute all the time. - this.resources = Arrays.asList(resources); - setDescription(Policy.bind("GlobalRefreshResourceSelectionPage.2")); //$NON-NLS-1$ - setTitle(Policy.bind("GlobalRefreshResourceSelectionPage.3")); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent2) { - Composite top = new Composite(parent2, SWT.NULL); - top.setLayout(new GridLayout()); - - GridData data = new GridData(GridData.FILL_BOTH); - data.widthHint = 50; - top.setLayoutData(data); - setControl(top); - - if (resources.isEmpty()) { - Label l = new Label(top, SWT.NULL); - l.setText(Policy.bind("GlobalRefreshResourceSelectionPage.4")); //$NON-NLS-1$ - setPageComplete(false); - } else { - Label l = new Label(top, SWT.NULL); - l.setText(Policy.bind("GlobalRefreshResourceSelectionPage.5")); //$NON-NLS-1$ - - // The viewer - fViewer = new ContainerCheckedTreeViewer(top, SWT.BORDER); - data = new GridData(GridData.FILL_BOTH); - //data.widthHint = 200; - data.heightHint = 100; - fViewer.getControl().setLayoutData(data); - fViewer.setContentProvider(new MyContentProvider()); - fViewer.setLabelProvider( new DecoratingLabelProvider( - new MyLabelProvider(), - PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator())); - fViewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - updateOKStatus(); - } - }); - fViewer.setSorter(new ResourceSorter(ResourceSorter.NAME)); - fViewer.setInput(resources); - - // Scopes - Group scopeGroup = new Group(top, SWT.NULL); - scopeGroup.setText(Policy.bind("GlobalRefreshResourceSelectionPage.6")); //$NON-NLS-1$ - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - layout.makeColumnsEqualWidth = false; - scopeGroup.setLayout(layout); - data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = 50; - scopeGroup.setLayoutData(data); - - participantScope = new Button(scopeGroup, SWT.RADIO); - participantScope.setText(Policy.bind("GlobalRefreshResourceSelectionPage.7")); //$NON-NLS-1$ - participantScope.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateParticipantScope(); - } - }); - - selectedResourcesScope = new Button(scopeGroup, SWT.RADIO); - selectedResourcesScope.setText(Policy.bind("GlobalRefreshResourceSelectionPage.8")); //$NON-NLS-1$ - selectedResourcesScope.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateSelectedResourcesScope(); - } - }); - data = new GridData(); - data.horizontalSpan = 2; - selectedResourcesScope.setLayoutData(data); - - - workingSetScope = new Button(scopeGroup, SWT.RADIO); - workingSetScope.setText(Policy.bind("GlobalRefreshResourceSelectionPage.10")); //$NON-NLS-1$ - workingSetScope.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if(workingSetScope.getSelection()) { - updateWorkingSetScope(); - } - } - }); - - workingSetLabel = new Text(scopeGroup, SWT.BORDER); - workingSetLabel.setEditable(false); - data = new GridData(GridData.FILL_HORIZONTAL); - workingSetLabel.setLayoutData(data); - - Button selectWorkingSetButton = new Button(scopeGroup, SWT.NULL); - selectWorkingSetButton.setText(Policy.bind("GlobalRefreshResourceSelectionPage.11")); //$NON-NLS-1$ - selectWorkingSetButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - selectWorkingSetAction(); - } - }); - data = new GridData(GridData.HORIZONTAL_ALIGN_END); - selectWorkingSetButton.setLayoutData(data); - Dialog.applyDialogFont(selectWorkingSetButton); - - Composite selectGroup = new Composite(top, SWT.SHADOW_NONE); - layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.makeColumnsEqualWidth = false; - selectGroup.setLayout(layout); - data = new GridData(GridData.FILL_HORIZONTAL); - selectGroup.setLayoutData(data); - - Button selectAll = new Button(selectGroup, SWT.NULL); - selectAll.setText(Policy.bind("GlobalRefreshResourceSelectionPage.12")); //$NON-NLS-1$ - selectAll.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - participantScope.setSelection(true); - selectedResourcesScope.setSelection(false); - workingSetScope.setSelection(false); - updateParticipantScope(); - scopeCheckingElement = true; - updateOKStatus(); - scopeCheckingElement = false; - } - }); - selectAll.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - - Button deSelectAll = new Button(selectGroup, SWT.NULL); - deSelectAll.setText(Policy.bind("GlobalRefreshResourceSelectionPage.13")); //$NON-NLS-1$ - deSelectAll.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - fViewer.setCheckedElements(new Object[0]); - updateOKStatus(); - } - }); - deSelectAll.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - - //workingSet = participant.getWorkingSet(); - //updateWorkingSetLabel(); - initializeScopingHint(); - } - Dialog.applyDialogFont(top); - } - - /** - * Allow the finish button to be pressed if there are checked resources. - * - */ - protected void updateOKStatus() { - if(fViewer != null) { - if(! scopeCheckingElement) { - if(! selectedResourcesScope.getSelection()) { - selectedResourcesScope.setSelection(true); - participantScope.setSelection(false); - workingSetScope.setSelection(false); - updateSelectedResourcesScope(); - } - } - setPageComplete(areAnyElementsChecked() != null); - } else { - setPageComplete(false); - } - } - - /** - * Returns <code>true</code> if any of the root resources are grayed. - */ - private IResource areAnyElementsChecked() { - TreeItem[] item = fViewer.getTree().getItems(); - List checked = new ArrayList(); - for (int i = 0; i < item.length; i++) { - TreeItem child = item[i]; - if(child.getChecked() || child.getGrayed()) { - return (IResource)child.getData(); - } - } - return null; - } - - /** - * Return the list of top-most resources that have been checked. - * - * @return the list of top-most resources that have been checked or an - * empty list if nothing is selected. - */ - public IResource[] getRootResources() { - TreeItem[] item = fViewer.getTree().getItems(); - List checked = new ArrayList(); - for (int i = 0; i < item.length; i++) { - TreeItem child = item[i]; - collectCheckedItems(child, checked); - } - return (IResource[]) checked.toArray(new IResource[checked.size()]); - } - - public ISynchronizeScope getSynchronizeScope() { - if (workingSetScope.getSelection()) { - return new WorkingSetScope(workingSets); - } - if (participantScope.getSelection()) { - return new WorkspaceScope(); - } - return new ResourceScope(getRootResources()); - } - - private void initializeScopingHint() { - participantScope.setSelection(true); - updateParticipantScope(); - } - - private void intializeSelectionInViewer(IResource[] resources) { - } - - private void updateParticipantScope() { - if(participantScope.getSelection()) { - scopeCheckingElement = true; - fViewer.setCheckedElements(resources.toArray()); - scopeCheckingElement = false; - } - } - - private void updateSelectedResourcesScope() { - setPageComplete(getRootResources().length > 0); - } - - private void selectWorkingSetAction() { - IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager(); - IWorkingSetSelectionDialog dialog = manager.createWorkingSetSelectionDialog(getShell(), true); - dialog.open(); - IWorkingSet[] sets = dialog.getSelection(); - if(sets != null) { - workingSets = sets; - } else { - // dialog cancelled - return; - } - updateWorkingSetScope(); - updateWorkingSetLabel(); - - participantScope.setSelection(false); - selectedResourcesScope.setSelection(false); - workingSetScope.setSelection(true); - } - - private void updateWorkingSetScope() { - if(workingSets != null) { - for (int i = 0; i < workingSets.length; i++) { - IWorkingSet set = workingSets[i]; - List resources = IDE.computeSelectedResources(new StructuredSelection(set.getElements())); - if(! resources.isEmpty()) { - IResource[] resources2 = (IResource[])resources.toArray(new IResource[resources.size()]); - scopeCheckingElement = true; - fViewer.setCheckedElements(resources2); - scopeCheckingElement = false; - intializeSelectionInViewer(resources2); - } - } - setPageComplete(true); - } else { - scopeCheckingElement = true; - fViewer.setCheckedElements(new Object[0]); - scopeCheckingElement = false; - setPageComplete(false); - } - } - - private IResource[] getResourcesFromSelection() { - IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (activeWorkbenchWindow != null) { - IWorkbenchPart activePart = activeWorkbenchWindow.getPartService().getActivePart(); - if (activePart != null) { - ISelectionProvider selectionProvider = activePart.getSite().getSelectionProvider(); - if (selectionProvider != null) { - ISelection selection = selectionProvider.getSelection(); - if(selection instanceof IStructuredSelection) { - return Utils.getResources(((IStructuredSelection)selection).toArray()); - } - } - } - } - return new IResource[0]; - } - - private void collectCheckedItems(TreeItem item, List checked) { - if(item.getChecked() && !item.getGrayed()) { - checked.add(item.getData()); - } else if(item.getGrayed()) { - TreeItem[] children = item.getItems(); - for (int i = 0; i < children.length; i++) { - TreeItem child = children[i]; - collectCheckedItems(child, checked); - } - } - } - - private void updateWorkingSetLabel() { - if (workingSets == null) { - workingSetLabel.setText(Policy.bind("StatisticsPanel.noWorkingSet")); //$NON-NLS-1$ - } else { - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < workingSets.length; i++) { - IWorkingSet set = workingSets[i]; - if(i != 0) buffer.append(" ,"); //$NON-NLS-1$ - buffer.append(set.getName()); - } - workingSetLabel.setText(buffer.toString()); - } - } -} 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 deleted file mode 100644 index 4a252226f..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/HierarchicalModelManager.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.synchronize; - -import org.eclipse.team.core.synchronize.SyncInfoTree; -import org.eclipse.team.internal.ui.IPreferenceIds; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; - -/** - * Manager for hierarchical models - */ -public class HierarchicalModelManager extends SynchronizeModelManager { - - /** - * @param configuration - */ - public HierarchicalModelManager(ISynchronizePageConfiguration configuration) { - super(configuration); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.SynchronizeModelManager#getSupportedModelProviders() - */ - protected ISynchronizeModelProviderDescriptor[] getSupportedModelProviders() { - return new ISynchronizeModelProviderDescriptor[] { - new HierarchicalModelProvider.HierarchicalModelProviderDescriptor(), - new CompressedFoldersModelProvider.CompressedFolderModelProviderDescriptor() }; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.SynchronizeModelManager#createModelProvider(java.lang.String) - */ - protected ISynchronizeModelProvider createModelProvider(String id) { - if(id == null) { - if (getShowCompressedFolders()) { - id = CompressedFoldersModelProvider.CompressedFolderModelProviderDescriptor.ID; - } else { - id = HierarchicalModelProvider.HierarchicalModelProviderDescriptor.ID; - } - } - if(id.endsWith(CompressedFoldersModelProvider.CompressedFolderModelProviderDescriptor.ID)) { - return new CompressedFoldersModelProvider(getConfiguration(), getSyncInfoSet()); - } else { - return new HierarchicalModelProvider(getConfiguration(), getSyncInfoSet()); - } - } - - private SyncInfoTree getSyncInfoSet() { - return (SyncInfoTree)getConfiguration().getProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET); - } - - /** - * Return the state of the compressed folder setting. - * - * @return the state of the compressed folder setting. - */ - private boolean getShowCompressedFolders() { - return TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS); - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/HierarchicalModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/HierarchicalModelProvider.java deleted file mode 100644 index e4a5e6c35..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/HierarchicalModelProvider.java +++ /dev/null @@ -1,249 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.AbstractTreeViewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.ui.ISharedImages; -import org.eclipse.team.ui.TeamImages; -import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; - -/** - * An input that can be used with both {@link } and - * {@link }. The - * job of this input is to create the logical model of the contents of the - * sync set for displaying to the user. The created logical model must diff - * nodes. - * <p> - * 1. First, prepareInput is called to initialize the model with the given sync - * set. Building the model occurs in the ui thread. - * 2. The input must react to changes in the sync set and adjust its diff node - * model then update the viewer. In effect mediating between the sync set - * changes and the model shown to the user. This happens in the ui thread. - * </p> - * NOT ON DEMAND - model is created then maintained! - * @since 3.0 - */ -public class HierarchicalModelProvider extends SynchronizeModelProvider { - - public static class HierarchicalModelProviderDescriptor implements ISynchronizeModelProviderDescriptor { - public static final String ID = TeamUIPlugin.ID + ".modelprovider_hierarchical"; - public String getId() { - return ID; - } - public String getName() { - return "Tree"; - } - public ImageDescriptor getImageDescriptor() { - return TeamImages.getImageDescriptor(ISharedImages.IMG_HIERARCHICAL); - } - }; - private static final HierarchicalModelProviderDescriptor hierarchicalDescriptor = new HierarchicalModelProviderDescriptor(); - - /** - * Create an input based on the provide sync set. The input is not initialized - * until <code>prepareInput</code> is called. - * - * @param set the sync set used as the basis for the model created by this input. - */ - public HierarchicalModelProvider(ISynchronizePageConfiguration configuration, SyncInfoTree set) { - super(configuration, set); - } - - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.ISynchronizeModelProvider#getDescriptor() - */ - public ISynchronizeModelProviderDescriptor getDescriptor() { - return hierarchicalDescriptor; - } - - public ViewerSorter getViewerSorter() { - return new SynchronizeModelElementSorter(); - } - - protected SyncInfoTree getSyncInfoTree() { - return (SyncInfoTree)getSyncInfoSet(); - } - - /** - * Invoked by the <code>buildModelObject</code> method to create - * the childen of the given node. This method can be overriden - * by subclasses but subclasses should inv - * @param container - * @return - */ - protected IDiffElement[] createModelObjects(ISynchronizeModelElement container) { - IResource resource = null; - if (container == getModelRoot()) { - resource = ResourcesPlugin.getWorkspace().getRoot(); - } else { - resource = container.getResource(); - } - if(resource != null) { - SyncInfoTree infoTree = getSyncInfoTree(); - IResource[] children = infoTree.members(resource); - ISynchronizeModelElement[] nodes = new ISynchronizeModelElement[children.length]; - for (int i = 0; i < children.length; i++) { - nodes[i] = createModelObject(container, children[i]); - } - return nodes; - } - return new IDiffElement[0]; - } - - protected ISynchronizeModelElement createModelObject(ISynchronizeModelElement parent, IResource resource) { - SyncInfo info = getSyncInfoTree().getSyncInfo(resource); - SynchronizeModelElement newNode; - if(info != null) { - newNode = new SyncInfoModelElement(parent, info); - } else { - newNode = new UnchangedResourceModelElement(parent, resource); - } - addToViewer(newNode); - return newNode; - } - - /** - * Invokes <code>getModelObject(Object)</code> on an array of resources. - * @param resources - * the resources - * @return the model objects for the resources - */ - protected Object[] getModelObjects(IResource[] resources) { - Object[] result = new Object[resources.length]; - for (int i = 0; i < resources.length; i++) { - result[i] = getModelObject(resources[i]); - } - return result; - } - - /** - * Handle the change for the existing diff node. The diff node - * should be changed to have the given sync info - * @param diffNode the diff node to be changed - * @param info the new sync info for the diff node - */ - protected void handleChange(ISynchronizeModelElement diffNode, SyncInfo info) { - IResource local = info.getLocal(); - - if(diffNode instanceof SyncInfoModelElement) { - ((SyncInfoModelElement)diffNode).update(info); - calculateProperties(diffNode, false); - } else { - removeFromViewer(local); - addResources(new IResource[] {local}); - } - } - - protected void addResources(IResource[] added) { - for (int i = 0; i < added.length; i++) { - IResource resource = added[i]; - ISynchronizeModelElement node = getModelObject(resource); - if (node != null) { - // Somehow the node exists. Remove it and read it to ensure - // what is shown matches the contents of the sync set - removeFromViewer(resource); - } - // Build the sub-tree rooted at this node - ISynchronizeModelElement parent = getModelObject(resource.getParent()); - if (parent != null) { - node = createModelObject(parent, resource); - buildModelObjects(node); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.SynchronizeModelProvider#buildModelObjects(org.eclipse.team.ui.synchronize.viewers.SynchronizeModelElement) - */ - protected IDiffElement[] buildModelObjects(ISynchronizeModelElement node) { - IDiffElement[] children = createModelObjects(node); - for (int i = 0; i < children.length; i++) { - IDiffElement element = children[i]; - if (element instanceof ISynchronizeModelElement) { - buildModelObjects((ISynchronizeModelElement) element); - } - } - return children; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.SynchronizeModelProvider#doAdd(org.eclipse.team.ui.synchronize.viewers.SynchronizeModelElement, org.eclipse.team.ui.synchronize.viewers.SynchronizeModelElement) - */ - protected void doAdd(ISynchronizeModelElement parent, ISynchronizeModelElement element) { - AbstractTreeViewer viewer = (AbstractTreeViewer)getViewer(); - viewer.add(parent, element); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.SynchronizeModelProvider#doRemove(org.eclipse.team.ui.synchronize.viewers.SynchronizeModelElement) - */ - protected void doRemove(ISynchronizeModelElement element) { - AbstractTreeViewer viewer = (AbstractTreeViewer)getViewer(); - viewer.remove(element); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.SynchronizeModelProvider#handleResourceAdditions(org.eclipse.team.core.synchronize.ISyncInfoTreeChangeEvent) - */ - protected void handleResourceAdditions(ISyncInfoTreeChangeEvent event) { - IResource[] added = event.getAddedSubtreeRoots(); - addResources(added); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.SynchronizeModelProvider#handleResourceChanges(org.eclipse.team.core.synchronize.ISyncInfoTreeChangeEvent) - */ - protected void handleResourceChanges(ISyncInfoTreeChangeEvent event) { - // Refresh the viewer for each changed resource - SyncInfo[] infos = event.getChangedResources(); - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - IResource local = info.getLocal(); - ISynchronizeModelElement diffNode = getModelObject(local); - if (diffNode != null) { - handleChange(diffNode, info); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.SynchronizeModelProvider#handleResourceRemovals(org.eclipse.team.core.synchronize.ISyncInfoTreeChangeEvent) - */ - protected void handleResourceRemovals(ISyncInfoTreeChangeEvent event) { - // Remove the removed subtrees - IResource[] removedRoots = event.getRemovedSubtreeRoots(); - for (int i = 0; i < removedRoots.length; i++) { - removeFromViewer(removedRoots[i]); - } - // We have to look for folders that may no longer be in the set - // (i.e. are in-sync) but still have descendants in the set - IResource[] removedResources = event.getRemovedResources(); - for (int i = 0; i < removedResources.length; i++) { - IResource resource = removedResources[i]; - if (resource.getType() != IResource.FILE) { - ISynchronizeModelElement node = getModelObject(resource); - if (node != null) { - removeFromViewer(resource); - addResources(new IResource[] {resource}); - } - } - } - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IPageValidator.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IPageValidator.java deleted file mode 100644 index f5d10431d..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IPageValidator.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -/** - * Allows clients to perform custom page completion. - * @since 3.0 - */ -public interface IPageValidator { - /** - * If errorMessage in <code>null</code> then the page is complete otherwise - * the error message indicates that the reason why the page is not complete. - */ - public void setComplete(String errorMessage); -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshEvent.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshEvent.java deleted file mode 100644 index a56aacaa8..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshEvent.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.core.subscribers.Subscriber; -import org.eclipse.team.core.synchronize.SyncInfo; - -/** - * An event describing the lifecycle of a {@link Subscriber#refresh(IResource[], int, IProgressMonitor)} operation. - * <p> - * This interface is not intended to be implemented by clients. - * </p> - * @see Subscriber - * @see IRefreshSubscriberListener - * @since 3.0 - */ -public interface IRefreshEvent { - /** - * Status code indicating that the refresh has changes to the selected - * resources that were refreshed. - */ - public static final int STATUS_CHANGES = 1; - - /** - * Status code indicating that the refresh didn't find changes on the selected - * resources that were refreshed. - */ - public static final int STATUS_NO_CHANGES = 2; - - /** - * Constant which identifies this event as generated by a scheduled refresh. - * @see #getRefreshType() - */ - public static final int SCHEDULED_REFRESH = 1; - - /** - * Constant which identifies the event as a refresh initiated by a user. - * @see #getRefreshType() - */ - public static final int USER_REFRESH = 2; - - /** - * Returns the type of this event. The returned value will be one of <code>SCHEDULED_REFRESH</code>, - * <code>USER_REFRESH</code>. - * - * @return the type of this event - * @see #SCHEDULED_REFRESH - * @see #USER_REFRESH - */ - public int getRefreshType(); - - /** - * The subscriber that was refreshed. - * - * @return the subscriber that was refreshed. - */ - public Subscriber getSubscriber(); - - /** - * The changes found during the refresh or an empty list if no changes were found. - * - * @return the changes found during the refresh or an empty list if no changes were found. - */ - public SyncInfo[] getChanges(); - - /** - * The time, in milliseconds, at which the refresh was started. - * - * @return the time, in milliseconds, at which the refresh was started. - */ - public long getStartTime(); - - /** - * The time, in milliseconds, at which the refresh was completed. - * - * @return the time, in milliseconds, at which the refresh was completed. - */ - public long getStopTime(); - - /** - * Returns the status of the refresh operation. This can be used to determine if the - * refresh completed successfuly, with an error, or was cancelled. - * - * @return the status of the refresh operation. - */ - public IStatus getStatus(); - - /** - * Returns the list of resources that were refreshed. - * - * @return the list of resources that were refreshed. - */ - public IResource[] getResources(); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshSubscriberListener.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshSubscriberListener.java deleted file mode 100644 index a8fbe4ff9..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshSubscriberListener.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.subscribers.Subscriber; -import org.eclipse.ui.actions.ActionFactory; - -/** - * Callback interface for clients interested in being notified about the lifecycle of - * a {@link Subscriber#refresh(IResource[], int, IProgressMonitor)} operation. - * <p> - * Clients may implement this interface. - * </p> - * @see IRefreshEvent - * @see Subscriber - * @since 3.0 - */ -public interface IRefreshSubscriberListener { - /** - * Notification that a refresh is about to start. The event contains the resources - * that will be refreshed. - * - * @param event an event describing the state of the refresh. - */ - public void refreshStarted(IRefreshEvent event); - - /** - * Notification that a refresh has completed. The event contains the changes - * found during the refresh as well as the status of the refresh. - * - * @param event the event describing the result of the refresh. - */ - public ActionFactory.IWorkbenchAction refreshDone(IRefreshEvent event); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ISynchronizeModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ISynchronizeModelProvider.java deleted file mode 100644 index ad9754ee1..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ISynchronizeModelProvider.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; - -/** - * This class represents provisional API. A provider is not required to - * implement this API. Implementers, and those who reference it, do so with the - * awareness that this class may be removed or substantially changed at future - * times without warning. - */ -public interface ISynchronizeModelProvider { - /** - * Property constant for the expansion state for the elements displayed by the page. The - * expansion state is a List of resource paths. - */ - public static final String P_VIEWER_EXPANSION_STATE = TeamUIPlugin.ID + ".P_VIEWER_EXPANSION_STATE"; //$NON-NLS-1$ - - /** - * Property constant for the selection state for the elements displayed by the page. The - * selection state is a List of resource paths. - */ - public static final String P_VIEWER_SELECTION_STATE = TeamUIPlugin.ID + ".P_VIEWER_SELECTION_STATE"; //$NON-NLS-1$ - - /** - * Returns the sync set this model provider is showing. - * @return the sync set this model provider is showing. - */ - public abstract SyncInfoSet getSyncInfoSet(); - - /** - * Returns the description for this model provider. - * @return the description for this model provider. - */ - public ISynchronizeModelProviderDescriptor getDescriptor(); - - /** - * Return the <code>AbstractTreeViewer</code> asociated with this content - * provider or <code>null</code> if the viewer is not of the proper type. - * @return - */ - public abstract StructuredViewer getViewer(); - - /** - * Installed the viewer to be used to display the model. - * @param viewer the viewer in which to diplay the model. - */ - public abstract void setViewer(StructuredViewer viewer); - - /** - * Builds the viewer model based on the contents of the sync set. - * @return the root element of the generated model. - */ - public abstract ISynchronizeModelElement prepareInput(IProgressMonitor monitor); - - /** - * The provider can try and return a mapping for the provided object. Providers often use mappings - * to store the source of a logical element they have created. For example, when displaying resource - * based logical elements, a provider will cache the resource -> element mapping for quick retrieval - * of the element when resource based changes are made. - * - * @param object the object to query for a mapping - * @return an object created by this provider that would be shown in a viewer, or <code>null</code> - * if the provided object is not mapped by this provider. - */ - public abstract Object getMapping(Object object); - - /** - * Dispose of the builder - */ - public abstract void dispose(); - - /** - * Returns the input created by this controller or <code>null</code> if - * {@link #prepareInput(IProgressMonitor)} hasn't been called on this object yet. - * @return - */ - public abstract ISynchronizeModelElement getModelRoot(); - - /** - * Returns the sorter for this model. - * @return the sorter for this model. - */ - public abstract ViewerSorter getViewerSorter(); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ISynchronizeModelProviderDescriptor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ISynchronizeModelProviderDescriptor.java deleted file mode 100644 index 9b6e4b83e..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ISynchronizeModelProviderDescriptor.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.jface.resource.ImageDescriptor; - -public interface ISynchronizeModelProviderDescriptor { - /** - * Returns the name of this model provider. This can be shown to the user. - * @return the name of this model provider. - */ - public String getName(); - - /** - * Returns the unique identifier for this model provider. - * @return the unique identifier for this model provider. - */ - public String getId(); - - /** - * Returns the image that represents this model provider. This image - * will be shown to the user. - * @return the image that represents this model provider. - */ - public ImageDescriptor getImageDescriptor(); -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java deleted file mode 100644 index 114278588..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import java.io.*; - -import org.eclipse.compare.*; -import org.eclipse.compare.internal.BufferedResourceNode; -import org.eclipse.compare.structuremergeviewer.IStructureComparator; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * A resource node that is not buffered. Changes made to it are applied directly - * to the underlying resource. - * - * @since 3.0 - */ -public class LocalResourceTypedElement extends ResourceNode { - - private boolean fDirty= false; - private IFile fDeleteFile; - - /** - * Creates a <code>ResourceNode</code> for the given resource. - * - * @param resource the resource - */ - public LocalResourceTypedElement(IResource resource) { - super(resource); - } - - protected IStructureComparator createChild(IResource child) { - return new LocalResourceTypedElement(child); - } - - public void setContent(byte[] contents) { - fDirty= true; - super.setContent(contents); - } - - /** - * Commits buffered contents to resource. - */ - public void commit(IProgressMonitor pm) throws CoreException { - if (fDirty) { - - if (fDeleteFile != null) { - fDeleteFile.delete(true, true, pm); - return; - } - - IResource resource= getResource(); - if (resource instanceof IFile) { - ByteArrayInputStream is= new ByteArrayInputStream(getContent()); - try { - IFile file= (IFile) resource; - if (file.exists()) - file.setContents(is, false, true, pm); - else - file.create(is, false, pm); - fDirty= false; - } finally { - fireContentChanged(); - if (is != null) - try { - is.close(); - } catch(IOException ex) { - } - } - } - } - } - - public ITypedElement replace(ITypedElement child, ITypedElement other) { - - if (child == null) { // add resource - // create a node without a resource behind it! - IResource resource= getResource(); - if (resource instanceof IFolder) { - IFolder folder= (IFolder) resource; - IFile file= folder.getFile(other.getName()); - child= new BufferedResourceNode(file); - } - } - - if (other == null) { // delete resource - IResource resource= getResource(); - if (resource instanceof IFolder) { - IFolder folder= (IFolder) resource; - IFile file= folder.getFile(child.getName()); - if (file != null && file.exists()) { - fDeleteFile= file; - fDirty= true; - } - } - return null; - } - - if (other instanceof IStreamContentAccessor && child instanceof IEditableContent) { - IEditableContent dst= (IEditableContent) child; - - try { - InputStream is= ((IStreamContentAccessor)other).getContents(); - byte[] bytes= readBytes(is); - if (bytes != null) - dst.setContent(bytes); - } catch (CoreException ex) { - } - } - fireContentChanged(); - return child; - } - - public static byte[] readBytes(InputStream in) { - ByteArrayOutputStream bos= new ByteArrayOutputStream(); - try { - while (true) { - int c= in.read(); - if (c == -1) - break; - bos.write(c); - } - - } catch (IOException ex) { - return null; - - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException x) { - } - } - try { - bos.close(); - } catch (IOException x) { - } - } - return bos.toByteArray(); - } - - /* (non-Javadoc) - * @see org.eclipse.compare.ResourceNode#getContents() - */ - public InputStream getContents() throws CoreException { - if(getResource().exists()) - return super.getContents(); - return null; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/PartNavigator.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/PartNavigator.java deleted file mode 100644 index 3c34350f8..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/PartNavigator.java +++ /dev/null @@ -1,171 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.synchronize; - -import org.eclipse.compare.CompareEditorInput; -import org.eclipse.compare.CompareViewerSwitchingPane; -import org.eclipse.compare.internal.*; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.widgets.Control; -import org.eclipse.team.internal.ui.synchronize.actions.NavigateAction; - -/** - * A navigator that coordinates navigation between several navigable - * objects. This is copied from the compare plugin and enhanced to - * support navigating adaptables. - * <p> - * This navigator can be used as input to the {@link NavigateAction} - * actions and should be passed to the actions via the - * {@link SynchronizePageConfiguration.P_NAVIGATOR}. - * </p> - * @since 3.0 - */ -public class PartNavigator implements INavigatable { - - private boolean fLastDirection= true; - private Object[] fPanes; - // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - private boolean fNextFirstTime= true; - - public PartNavigator(Object[] panes) { - fPanes= panes; - } - - public Object[] getPanes() { - return fPanes; - } - - public boolean gotoDifference(boolean next) { - - fLastDirection= next; - - // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - if (next && fNextFirstTime && mustOpen()) { - fNextFirstTime= false; - openElement(); - } - - // find most down stream CompareViewerPane - int n= 0; - INavigatable[] navigators= new INavigatable[4]; - for (int i= 0; i < fPanes.length; i++) { - navigators[n]= getNavigator(fPanes[i]); - if (navigators[n] != null) - n++; - } - - while (n > 0) { - n--; - if (navigators[n].gotoDifference(next)) { - // at end of this navigator - continue; - } else // not at end - return false; - } - return true; - } - - private static INavigatable getNavigator(Object p) { - if (p == null) - return null; - Control control = null; - if (p instanceof CompareViewerSwitchingPane) { - CompareViewerSwitchingPane pane = (CompareViewerSwitchingPane) p; - if (pane.isEmpty()) - return null; - Viewer viewer = pane.getViewer(); - if (viewer == null) - return null; - control = viewer.getControl(); - if (control == null) - return null; - Object data = control.getData(INavigatable.NAVIGATOR_PROPERTY); - if (data instanceof INavigatable) - return (INavigatable) data; - } else if(p instanceof IAdaptable) { - return (INavigatable)((IAdaptable)p).getAdapter(INavigatable.class); - } - return null; - } - - private static CompareNavigator findNavigator(Control c) { - while (c != null && !c.isDisposed()) { // PR 1GEUVV2 - Object data= c.getData(); - if (data instanceof CompareEditorInput) { - CompareEditorInput cei= (CompareEditorInput) data; - Object adapter= cei.getAdapter(CompareNavigator.class); - if (adapter instanceof CompareNavigator) - return (CompareNavigator)adapter; - } - c= c.getParent(); - } - return null; - } - - private boolean resetDirection() { - boolean last= fLastDirection; - fLastDirection= true; - return last; - } - - /* - * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - */ - private boolean mustOpen() { - if (fPanes == null || fPanes.length == 0) - return false; - for (int i= 1; i < fPanes.length; i++) { - Object p= fPanes[i]; - if (p instanceof CompareViewerSwitchingPane) { - CompareViewerSwitchingPane pane = (CompareViewerSwitchingPane) p; - if (pane != null && pane.getInput() != null) - return false; - } - } - return true; - } - - /* - * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - */ - private void openElement() { - if (fPanes == null || fPanes.length == 0) - return; - IOpenable openable= getOpenable(fPanes[0]); - if (openable != null) { - openable.openSelected(); - } - } - - /* - * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - */ - private static IOpenable getOpenable(Object p) { - if (p instanceof CompareViewerSwitchingPane) { - CompareViewerSwitchingPane pane = (CompareViewerSwitchingPane) p; - if (pane == null) - return null; - if (pane.isEmpty()) - return null; - Viewer viewer = pane.getViewer(); - if (viewer == null) - return null; - Control control = viewer.getControl(); - if (control == null) - return null; - Object data = control.getData(IOpenable.OPENABLE_PROPERTY); - if (data instanceof IOpenable) - return (IOpenable) data; - } - return null; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ReferenceCounter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ReferenceCounter.java deleted file mode 100644 index 645e60a2b..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ReferenceCounter.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import java.util.*; - -/** - * A ReferenceCounter is used to reference counting objects. - * Each object is identified by a unique ID. Together they form - * an ID - value pair. An object is added to the counter by calling - * #put(id, object). From this point on additional refs can be made - * by calling #addRef(id) or #removeRef(id). - */ -public class ReferenceCounter -{ - private Map mapIdToRec = new HashMap(11); - - /** - * Capture the information about an object. - */ - public class RefRec { - public RefRec(Object id, Object value) { - this.id = id; - this.value = value; - addRef(); - } - public Object getId() { - return id; - } - public Object getValue() { - return value; - } - public int addRef() { - ++ refCount; - return refCount; - } - public int removeRef() { - -- refCount; - return refCount; - } - public int getRef() { - return refCount; - } - public boolean isNotReferenced() { - return (refCount <= 0); - } - public Object id; - public Object value; - private int refCount; - } -/** - * Creates a new counter. - */ -public ReferenceCounter() { - super(); -} -/** - * Adds one reference to an object in the counter. - * - * @param id is a unique ID for the object. - * @return the new ref count - */ -public int addRef(Object id) { - RefRec rec = (RefRec)mapIdToRec.get(id); - if (rec == null) - return 0; - return rec.addRef(); -} -/** - * Returns the object defined by an ID. If the ID is not - * found <code>null</code> is returned. - * - * @return the object or <code>null</code> - */ -public Object get(Object id) { - RefRec rec = (RefRec)mapIdToRec.get(id); - if (rec == null) - return null; - return rec.getValue(); -} -/** - * Returns a complete list of the keys in the counter. - * - * @return a Set containing the ID for each. - */ -public Set keySet() { - return mapIdToRec.keySet(); -} -/** - * Adds an object to the counter for counting and gives - * it an initial ref count of 1. - * - * @param id is a unique ID for the object. - * @param value is the object itself. - */ -public void put(Object id, Object value) { - RefRec rec = new RefRec(id, value); - mapIdToRec.put(id, rec); -} -/** - * Removes one reference from an object in the counter. - * If the ref count drops to 0 the object is removed from - * the counter completely. - * - * @param id is a unique ID for the object. - * @return the new ref count - */ -public int removeRef(Object id) { - RefRec rec = (RefRec)mapIdToRec.get(id); - if (rec == null) - return 0; - int newCount = rec.removeRef(); - if (newCount <= 0) - mapIdToRec.remove(id); - return newCount; -} -/** - * Returns a complete list of the values in the counter. - * - * @return a Collection containing the values. - */ -public List values() { - int size = mapIdToRec.size(); - ArrayList list = new ArrayList(size); - Iterator iter = mapIdToRec.values().iterator(); - while (iter.hasNext()) { - RefRec rec = (RefRec)iter.next(); - list.add(rec.getValue()); - } - return list; -} -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java deleted file mode 100644 index c576182d8..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.eclipse.team.internal.ui.synchronize; - -import java.util.*; - -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.team.core.subscribers.*; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoCollector; - -public class RefreshChangeListener implements ISubscriberChangeListener { - private List changes = new ArrayList(); - private SubscriberSyncInfoCollector collector; - - public RefreshChangeListener(SubscriberSyncInfoCollector collector) { - this.collector = collector; - } - public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas) { - for (int i = 0; i < deltas.length; i++) { - ISubscriberChangeEvent delta = deltas[i]; - if (delta.getFlags() == ISubscriberChangeEvent.SYNC_CHANGED) { - changes.add(delta); - } - } - } - public SyncInfo[] getChanges() { - collector.waitForCollector(new NullProgressMonitor()); - List changedSyncInfos = new ArrayList(); - SyncInfoSet set = collector.getSyncInfoSet(); - for (Iterator it = changes.iterator(); it.hasNext();) { - ISubscriberChangeEvent delta = (ISubscriberChangeEvent) it.next(); - SyncInfo info = set.getSyncInfo(delta.getResource()); - if (info != null && interestingChange(info)) { - changedSyncInfos.add(info); - } - } - return (SyncInfo[]) changedSyncInfos.toArray(new SyncInfo[changedSyncInfos.size()]); - } - - private boolean interestingChange(SyncInfo info) { - int kind = info.getKind(); - if(isThreeWay()) { - int direction = SyncInfo.getDirection(kind); - return (direction == SyncInfo.INCOMING || direction == SyncInfo.CONFLICTING); - } else { - return SyncInfo.getChange(kind) != SyncInfo.IN_SYNC; - } - } - - private boolean isThreeWay() { - return collector.getSubscriber().getResourceComparator().isThreeWay(); - } - - public void clear() { - changes.clear(); - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshEvent.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshEvent.java deleted file mode 100644 index 6ba5bee62..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshEvent.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.core.subscribers.Subscriber; -import org.eclipse.team.core.synchronize.SyncInfo; - -/** - * A refresh event generated to notify clients of the refresh lifecycle. - */ -public class RefreshEvent implements IRefreshEvent { - int type; - Subscriber subscriber; - SyncInfo[] changes; - long startTime = 0; - long stopTime = 0; - IStatus status; - IResource[] resources; - - public RefreshEvent(int type, IResource[] resources, Subscriber subscriber) { - this.type = type; - this.subscriber = subscriber; - this.resources = resources; - } - - public int getRefreshType() { - return type; - } - - public Subscriber getSubscriber() { - return subscriber; - } - - public SyncInfo[] getChanges() { - return changes != null ? changes : new SyncInfo[0]; - } - - public void setChanges(SyncInfo[] changes) { - this.changes = changes; - } - - public long getStartTime() { - return startTime; - } - - public void setStartTime(long startTime) { - this.startTime = startTime; - } - - public long getStopTime() { - return stopTime; - } - - public void setStopTime(long stopTime) { - this.stopTime = stopTime; - } - - public IStatus getStatus() { - return status; - } - - public void setStatus(IStatus status) { - this.status = status; - } - - public IResource[] getResources() { - return resources; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshSubscriberJob.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshSubscriberJob.java deleted file mode 100644 index 25e4c6901..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshSubscriberJob.java +++ /dev/null @@ -1,533 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.*; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.Subscriber; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.internal.core.Assert; -import org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoCollector; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.ui.synchronize.ISynchronizeManager; -import org.eclipse.team.ui.synchronize.SubscriberParticipant; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; -import org.eclipse.ui.internal.progress.ProgressManager; -import org.eclipse.ui.progress.IProgressConstants; -import org.eclipse.ui.progress.UIJob; - -/** - * Job to refresh a {@link Subscriber} in the background. The job can be configured - * to be re-scheduled and run at a specified interval. - * <p> - * The job supports a basic workflow for modal/non-modal usage. If the job is - * run in the foreground (e.g. in a modal progress dialog) the refresh listeners - * action is invoked immediately after the refresh is completed. Otherwise the refresh - * listeners action is associated to the job as a <i>goto</i> action. This will - * allow the user to select the action in the progress view and run it when they - * choose. - * </p> - * @since 3.0 - */ -public final class RefreshSubscriberJob extends WorkspaceJob { - - /** - * Uniquely identifies this type of job. This is used for cancellation. - */ - private final static Object FAMILY_ID = new Object(); - - /** - * If true this job will be restarted when it completes - */ - private boolean reschedule = false; - - /** - * If true a rescheduled refresh job should be retarted when cancelled - */ - private boolean restartOnCancel = true; - - /** - * The schedule delay used when rescheduling a completed job - */ - private static long scheduleDelay; - - /** - * The subscribers and resources to refresh. - */ - private IResource[] resources; - - /** - * The participant that is being refreshed. - */ - private SubscriberParticipant participant; - - /** - * The task name for this refresh. This is usually more descriptive than the - * job name. - */ - private String taskName; - - /** - * Refresh started/completed listener for every refresh - */ - private static List listeners = new ArrayList(1); - private static final int STARTED = 1; - private static final int DONE = 2; - - /* - * Constant used for postponement - */ - private static final IStatus POSTPONED = new Status(IStatus.CANCEL, TeamUIPlugin.ID, 0, "Scheduled refresh postponed due to conflicting operation", null); //$NON-NLS-1$ - - /** - * Notification for safely notifying listeners of refresh lifecycle. - */ - private abstract class Notification implements ISafeRunnable { - private IRefreshSubscriberListener listener; - public void handleException(Throwable exception) { - // don't log the exception....it is already being logged in Platform#run - } - public void run(IRefreshSubscriberListener listener) { - this.listener = listener; - Platform.run(this); - } - public void run() throws Exception { - notify(listener); - } - /** - * Subsclasses overide this method to send an event safely to a lsistener - * @param listener - */ - protected abstract void notify(IRefreshSubscriberListener listener); - } - - /** - * Monitor wrapper that will indicate that the job is cancelled - * if the job is blocking another. - */ - private class NonblockingProgressMonitor extends ProgressMonitorWrapper { - private final RefreshSubscriberJob job; - private long blockTime; - private static final int THRESHOLD = 250; - protected NonblockingProgressMonitor(IProgressMonitor monitor, RefreshSubscriberJob job) { - super(monitor); - this.job = job; - } - public boolean isCanceled() { - if (super.isCanceled()) { - return true; - } - if (job.shouldReschedule() && job.isBlocking()) { - if (blockTime == 0) { - blockTime = System.currentTimeMillis(); - } else if (System.currentTimeMillis() - blockTime > THRESHOLD) { - // We've been blocking for too long - return true; - } - } else { - blockTime = 0; - } - return false; - } - } - - /** - * Create a job to refresh the specified resources with the subscriber. - * - * @param participant the subscriber participant - * @param name - * @param resources - * @param subscriber - */ - public RefreshSubscriberJob(SubscriberParticipant participant, String jobName, String taskName, IResource[] resources, IRefreshSubscriberListener listener) { - super(taskName); - Assert.isNotNull(resources); - Assert.isNotNull(participant); - Assert.isNotNull(resources); - this.resources = resources; - this.participant = participant; - this.taskName = jobName; - setPriority(Job.DECORATE); - setRefreshInterval(3600 /* 1 hour */); - - // Handle restarting of job if it is configured as a scheduled refresh job. - addJobChangeListener(new JobChangeAdapter() { - public void done(IJobChangeEvent event) { - if(shouldReschedule()) { - IStatus result = event.getResult(); - if(result.getSeverity() == IStatus.CANCEL && ! restartOnCancel) { - return; - } - long delay = scheduleDelay; - if (result == POSTPONED) { - // Restart in 5 seconds - delay = 5000; - } - RefreshSubscriberJob.this.schedule(delay); - restartOnCancel = true; - } - } - }); - - initialize(listener); - } - - /** - * If a collector is available then run the refresh and the background event processing - * within the same progess group. - */ - public boolean shouldRun() { - // Ensure that any progress shown as a result of this refresh occurs hidden in a progress group. - return getSubscriber() != null; - } - - public boolean belongsTo(Object family) { - if(family instanceof RefreshSubscriberJob) { - return ((RefreshSubscriberJob)family).getSubscriber() == getSubscriber(); - } else if (family instanceof SubscriberParticipant) { - return family == participant; - } else { - return (family == getFamily() || family == ISynchronizeManager.FAMILY_SYNCHRONIZE_OPERATION); - } - } - - public static Object getFamily() { - return FAMILY_ID; - } - - /** - * This is run by the job scheduler. A list of subscribers will be refreshed, errors will not stop the job - * and it will continue to refresh the other subscribers. - */ - public IStatus runInWorkspace(IProgressMonitor monitor) { - // Perform a pre-check for auto-build or manual build jobs - // when auto-refreshing - if (shouldReschedule() && - (isJobInFamilyRunning(ResourcesPlugin.FAMILY_AUTO_BUILD) - || isJobInFamilyRunning(ResourcesPlugin.FAMILY_MANUAL_BUILD))) { - return POSTPONED; - } - // Only allow one refresh job at a time - // NOTE: It would be cleaner if this was done by a scheduling - // rule but at the time of writting, it is not possible due to - // the scheduling rule containment rules. - // Synchronized to ensure only one refresh job is running at a particular time - synchronized (getFamily()) { - Subscriber subscriber = getSubscriber(); - IResource[] roots = getResources(); - - // if there are no resources to refresh, just return - if(subscriber == null || roots == null) { - return Status.OK_STATUS; - } - SubscriberSyncInfoCollector collector = getCollector(); - RefreshEvent event = new RefreshEvent(reschedule ? IRefreshEvent.SCHEDULED_REFRESH : IRefreshEvent.USER_REFRESH, roots, collector.getSubscriber()); - RefreshChangeListener changeListener = new RefreshChangeListener(collector); - try { - event.setStartTime(System.currentTimeMillis()); - if(monitor.isCanceled()) { - return Status.CANCEL_STATUS; - } - // Set-up change listener so that we can determine the changes found - // during this refresh. - subscriber.addListener(changeListener); - // Pre-Notify - notifyListeners(STARTED, event); - // Perform the refresh - monitor.setTaskName(getName()); - NonblockingProgressMonitor wrappedMonitor = new NonblockingProgressMonitor(monitor, this); - subscriber.refresh(roots, IResource.DEPTH_INFINITE, wrappedMonitor); - // Prepare the results - setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.valueOf(! isJobModal())); - event.setStatus(calculateStatus(event)); - } catch(OperationCanceledException e2) { - if (monitor.isCanceled()) { - // The refresh was cancelled by the user - event.setStatus(Status.CANCEL_STATUS); - } else { - // The refresh was cancelled due to a blockage - event.setStatus(POSTPONED); - } - } catch(TeamException e) { - event.setStatus(e.getStatus()); - } finally { - event.setStopTime(System.currentTimeMillis()); - subscriber.removeListener(changeListener); - monitor.done(); - } - - // Post-Notify - event.setChanges(changeListener.getChanges()); - notifyListeners(DONE, event); - return event.getStatus(); - } - } - - private boolean isJobInFamilyRunning(Object family) { - Job[] jobs = Platform.getJobManager().find(family); - if (jobs != null && jobs.length > 0) { - for (int i = 0; i < jobs.length; i++) { - Job job = jobs[i]; - if (job.getState() != Job.NONE) { - return true; - } - } - } - return false; - } - - private IStatus calculateStatus(IRefreshEvent event) { - StringBuffer text = new StringBuffer(); - int code = IStatus.OK; - SyncInfo[] changes = event.getChanges(); - IResource[] resources = event.getResources(); - SubscriberSyncInfoCollector collector = getCollector(); - if (collector != null) { - SyncInfoSet set = collector.getSyncInfoSet(); - int numChanges = refreshedResourcesContainChanges(event); - if (numChanges > 0) { - code = IRefreshEvent.STATUS_CHANGES; - String outgoing = Long.toString(set.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK)); - String incoming = Long.toString(set.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK)); - String conflicting = Long.toString(set.countFor(SyncInfo.CONFLICTING, SyncInfo.DIRECTION_MASK)); - if (changes.length > 0) { - // New changes found - String numNewChanges = Integer.toString(event.getChanges().length); - text.append(Policy.bind("RefreshCompleteDialog.5a", new Object[]{getName(), numNewChanges})); //$NON-NLS-1$ - } else { - // Refreshed resources contain changes - text.append(Policy.bind("RefreshCompleteDialog.5", new Object[]{getName(), new Integer(numChanges)})); //$NON-NLS-1$ - } - } else { - // No changes found - code = IRefreshEvent.STATUS_NO_CHANGES; - text.append(Policy.bind("RefreshCompleteDialog.6", getName())); //$NON-NLS-1$ - } - return new Status(IStatus.OK, TeamUIPlugin.ID, code, text.toString(), null); - } - return Status.OK_STATUS; - } - - private int refreshedResourcesContainChanges(IRefreshEvent event) { - int numChanges = 0; - SubscriberSyncInfoCollector collector = getCollector(); - if (collector != null) { - SyncInfoTree set = collector.getSyncInfoSet(); - IResource[] resources = event.getResources(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - SyncInfo[] infos = set.getSyncInfos(resource, IResource.DEPTH_INFINITE); - if(infos != null && infos.length > 0) { - numChanges += infos.length; - } - } - } - return numChanges; - } - - private void initialize(final IRefreshSubscriberListener listener) { - final IWorkbenchAction[] gotoAction = new IWorkbenchAction[] {null}; - final IWorkbenchAction actionWrapper = new WorkbenchAction() { - public void run() { - if(gotoAction[0] != null) { - gotoAction[0].run(); - } - } - public boolean isEnabled() { - if(gotoAction[0] != null) { - return gotoAction[0].isEnabled(); - } - return true; - } - - public void dispose() { - super.dispose(); - if(gotoAction[0] != null) { - gotoAction[0].dispose(); - } - } - }; - - IProgressMonitor group = Platform.getJobManager().createProgressGroup(); - group.beginTask(taskName, 100); - setProgressGroup(group, 80); - getCollector().setProgressGroup(group, 20); - setProperty(IProgressConstants.ICON_PROPERTY, participant.getImageDescriptor()); - setProperty(IProgressConstants.ACTION_PROPERTY, actionWrapper); - setProperty(IProgressConstants.KEEPONE_PROPERTY, Boolean.valueOf(! isJobModal())); - // Listener delagate - IRefreshSubscriberListener autoListener = new IRefreshSubscriberListener() { - public void refreshStarted(IRefreshEvent event) { - if(listener != null) { - listener.refreshStarted(event); - } - } - public ActionFactory.IWorkbenchAction refreshDone(IRefreshEvent event) { - if(listener != null) { - boolean isModal = isJobModal(); - ActionFactory.IWorkbenchAction runnable = listener.refreshDone(event); - if(runnable != null) { - // If the job is being run modally then simply prompt the user immediatly - if(isModal) { - if(runnable != null) { - final IAction[] r = new IAction[] {runnable}; - Job update = new UIJob("") { //$NON-NLS-1$ - public IStatus runInUIThread(IProgressMonitor monitor) { - r[0].run(); - return Status.OK_STATUS; - } - }; - update.setSystem(true); - update.schedule(); - } - // If the job is being run in the background, don't interrupt the user and simply update the goto action - // to perform the results. - } else { - gotoAction[0] = runnable; - actionWrapper.setEnabled(runnable.isEnabled()); - runnable.addPropertyChangeListener(new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if(event.getProperty().equals(IAction.ENABLED)) { - Boolean bool = (Boolean) event.getNewValue(); - actionWrapper.setEnabled(bool.booleanValue()); - } - } - }); - } - } - RefreshSubscriberJob.removeRefreshListener(this); - } - return null; - } - }; - - if (listener != null) { - RefreshSubscriberJob.addRefreshListener(autoListener); - } - } - - protected IResource[] getResources() { - return resources; - } - - protected Subscriber getSubscriber() { - return participant.getSubscriber(); - } - - protected SubscriberSyncInfoCollector getCollector() { - return participant.getSubscriberSyncInfoCollector(); - } - - public long getScheduleDelay() { - return scheduleDelay; - } - - protected void start() { - if(getState() == Job.NONE) { - if(shouldReschedule()) { - schedule(getScheduleDelay()); - } - } - } - - /** - * Specify the interval in seconds at which this job is scheduled. - * @param seconds delay specified in seconds - */ - public void setRefreshInterval(long seconds) { - boolean restart = false; - if(getState() == Job.SLEEPING) { - restart = true; - cancel(); - } - scheduleDelay = seconds * 1000; - if(restart) { - start(); - } - } - - /** - * Returns the interval of this job in seconds. - * @return - */ - public long getRefreshInterval() { - return scheduleDelay / 1000; - } - - public void setRestartOnCancel(boolean restartOnCancel) { - this.restartOnCancel = restartOnCancel; - } - - public void setReschedule(boolean reschedule) { - this.reschedule = reschedule; - } - - public boolean shouldReschedule() { - return reschedule; - } - - public static void addRefreshListener(IRefreshSubscriberListener listener) { - synchronized(listeners) { - if(! listeners.contains(listener)) { - listeners.add(listener); - } - } - } - - public static void removeRefreshListener(IRefreshSubscriberListener listener) { - synchronized(listeners) { - listeners.remove(listener); - } - } - - protected void notifyListeners(final int state, final IRefreshEvent event) { - // Get a snapshot of the listeners so the list doesn't change while we're firing - IRefreshSubscriberListener[] listenerArray; - synchronized (listeners) { - listenerArray = (IRefreshSubscriberListener[]) listeners.toArray(new IRefreshSubscriberListener[listeners.size()]); - } - // Notify each listener in a safe manner (i.e. so their exceptions don't kill us) - for (int i = 0; i < listenerArray.length; i++) { - IRefreshSubscriberListener listener = listenerArray[i]; - Notification notification = new Notification() { - protected void notify(IRefreshSubscriberListener listener) { - switch (state) { - case STARTED: - listener.refreshStarted(event); - break; - case DONE: - listener.refreshDone(event); - break; - default: - break; - } - } - }; - notification.run(listener); - } - } - - private boolean isJobModal() { - Boolean isModal = (Boolean)getProperty(ProgressManager.PROPERTY_IN_DIALOG); - if(isModal == null) return false; - return isModal.booleanValue(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java deleted file mode 100644 index f1107cf34..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.eclipse.team.internal.ui.synchronize; - -import java.util.*; -import org.eclipse.compare.CompareUI; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.ui.*; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.actions.ActionFactory; - -/** - * This class manages the notification and setup that occurs after a refresh is completed. - */ -public class RefreshUserNotificationPolicy implements IRefreshSubscriberListener { - - private SubscriberParticipant participant; - - public RefreshUserNotificationPolicy(SubscriberParticipant participant) { - this.participant = participant; - } - - /* - * (non-Javadoc) - * @see org.eclipse.team.internal.ui.jobs.IRefreshSubscriberListener#refreshStarted(org.eclipse.team.internal.ui.jobs.IRefreshEvent) - */ - public void refreshStarted(IRefreshEvent event) { - TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - ISynchronizeView view = TeamUI.getSynchronizeManager().showSynchronizeViewInActivePage(); - if(view != null) { - view.display(participant); - } - } - }); - } - - /* - * (non-Javadoc) - * @see org.eclipse.team.internal.ui.jobs.IRefreshSubscriberListener#refreshDone(org.eclipse.team.internal.ui.jobs.IRefreshEvent) - */ - public ActionFactory.IWorkbenchAction refreshDone(final IRefreshEvent event) { - // Ensure that this event was generated for this participant - if (event.getSubscriber() != participant.getSubscriberSyncInfoCollector().getSubscriber()) return null; - // If the event is for a cancelled operation, there's nothing to do - int severity = event.getStatus().getSeverity(); - if(severity == Status.CANCEL || severity == Status.ERROR) return null; - // Decide on what action to take after the refresh is completed - return new WorkbenchAction() { - public void run() { - boolean prompt = (event.getStatus().getCode() == IRefreshEvent.STATUS_NO_CHANGES); - - SyncInfo[] infos = event.getChanges(); - List selectedResources = new ArrayList(); - selectedResources.addAll(Arrays.asList(event.getResources())); - for (int i = 0; i < infos.length; i++) { - selectedResources.add(infos[i].getLocal()); - } - IResource[] resources = (IResource[]) selectedResources.toArray(new IResource[selectedResources.size()]); - - // If it's a file, simply show the compare editor - if (resources.length == 1 && resources[0].getType() == IResource.FILE) { - IResource file = resources[0]; - SyncInfo info = participant.getSubscriberSyncInfoCollector().getSyncInfoSet().getSyncInfo(file); - if(info != null) { - SyncInfoCompareInput input = new SyncInfoCompareInput(participant.getName(), info); - CompareUI.openCompareEditor(input); - prompt = false; - } - } - - // Prompt user if preferences are set for this type of refresh. - if (prompt) { - notifyIfNeededModal(event); - } else { - // Else simply show the synchronize view - ISynchronizeView view = TeamUI.getSynchronizeManager().showSynchronizeViewInActivePage(); - if(view != null) { - view.display(participant); - } - } - } - }; - } - - private void notifyIfNeededModal(final IRefreshEvent event) { - TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - String title = (event.getRefreshType() == IRefreshEvent.SCHEDULED_REFRESH ? - Policy.bind("RefreshCompleteDialog.4a", participant.getName()) : //$NON-NLS-1$ - Policy.bind("RefreshCompleteDialog.4", participant.getName()) //$NON-NLS-1$ - ); - MessageDialog.openInformation(Utils.getShell(null), title, event.getStatus().getMessage()); - } - }); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java deleted file mode 100644 index e8fc36fc4..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.compare.CompareConfiguration; -import org.eclipse.compare.CompareUI; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.actions.ActionFactory; - -public class RefreshUserNotificationPolicyInModalDialog implements IRefreshSubscriberListener { - - private SubscriberParticipant participant; - private ISynchronizePageConfiguration configuration; - private Shell shell; - private String title; - - public RefreshUserNotificationPolicyInModalDialog(Shell shell, String title, ISynchronizePageConfiguration configuration, SubscriberParticipant participant) { - this.title = title; - this.configuration = configuration; - this.participant = participant; - this.shell = shell; - } - - public void refreshStarted(IRefreshEvent event) { - } - - public ActionFactory.IWorkbenchAction refreshDone(final IRefreshEvent event) { - // Ensure that this event was generated for this participant - if (event.getSubscriber() != participant.getSubscriber()) - return null; - // If the event is for a cancelled operation, there's nothing to do - int severity = event.getStatus().getSeverity(); - if(severity == Status.CANCEL || severity == Status.ERROR) - return null; - - return new WorkbenchAction() { - public void run() { - // If there are no changes - if (event.getStatus().getCode() == IRefreshEvent.STATUS_NO_CHANGES) { - MessageDialog.openInformation(shell, Policy.bind("OpenComparedDialog.noChangeTitle"), Policy.bind("OpenComparedDialog.noChangesMessage")); //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - compareAndOpenDialog(event, participant); - setEnabled(false); - } - public void dispose() { - if (TeamUI.getSynchronizeManager().get(participant.getId(), participant.getSecondaryId()) == null) { - participant.dispose(); - } - } - }; - } - - protected boolean isSingleFileCompare(IResource[] resources) { - return resources.length == 1 && resources[0].getType() == IResource.FILE; - } - - protected void compareAndOpenEditors(IRefreshEvent event, SubscriberParticipant participant) { - IResource[] resources = event.getResources(); - for (int i = 0; i < resources.length; i++) { - SyncInfo info = participant.getSyncInfoSet().getSyncInfo(resources[i]); - if (info != null) { - SyncInfoCompareInput input = new SyncInfoCompareInput(event.getSubscriber().getName(), info); - CompareUI.openCompareEditor(input); - } - } - } - - protected void compareAndOpenDialog(final IRefreshEvent event, final SubscriberParticipant participant) { - CompareConfiguration cc = new CompareConfiguration(); - ParticipantPageSaveablePart input = new ParticipantPageSaveablePart(Utils.getShell(null), cc, configuration, participant) { - public String getTitle() { - return RefreshUserNotificationPolicyInModalDialog.this.title; - } - }; - ParticipantPageDialog dialog = new ParticipantPageDialog(shell, input, participant); - dialog.setBlockOnOpen(true); - dialog.open(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RemoteResourceTypedElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RemoteResourceTypedElement.java deleted file mode 100644 index 73a16661a..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RemoteResourceTypedElement.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import java.io.InputStream; - -import org.eclipse.compare.*; -import org.eclipse.core.resources.IEncodedStorage; -import org.eclipse.core.resources.IStorage; -import org.eclipse.core.runtime.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.internal.core.Assert; - -/** - * RemoteResourceTypedElement - */ -public class RemoteResourceTypedElement extends BufferedContent implements ITypedElement, IEditableContent, IEncodedStreamContentAccessor { - - private IResourceVariant remote; - private IStorage bufferedContents; - - /** - * Creates a new content buffer for the given team node. - */ - public RemoteResourceTypedElement(IResourceVariant remote) { - Assert.isNotNull(remote); - this.remote = remote; - } - - public Image getImage() { - return CompareUI.getImage(getType()); - } - - public String getName() { - return remote.getName(); - } - - public String getContentIdentifier() { - return remote.getContentIdentifier(); - } - - public String getType() { - if (remote.isContainer()) { - return ITypedElement.FOLDER_TYPE; - } - String name = getName(); - if (name != null) { - int index = name.lastIndexOf('.'); - if (index == -1) - return ""; //$NON-NLS-1$ - if (index == (name.length() - 1)) - return ""; //$NON-NLS-1$ - return name.substring(index + 1); - } - return ITypedElement.FOLDER_TYPE; - } - - /** - * Returns true if this object can be modified. - * If it returns <code>false</code> the other methods must not be called. - * - * @return <code>true</code> if this object can be modified. - */ - public boolean isEditable() { - return false; - } - - /** - * This is not the definitive API! - * This method is called on a parent to - * - add a child, - * - remove a child, - * - copy the contents of a child - * - * What to do is encoded in the two arguments as follows: - * add: child == null other != null - * remove: child != null other == null - * copy: child != null other != null - */ - public ITypedElement replace(ITypedElement child, ITypedElement other) { - return null; - } - - /* (non-Javadoc) - * @see BufferedContent#createStream() - */ - protected InputStream createStream() throws CoreException { - if(bufferedContents == null) { - cacheContents(new NullProgressMonitor()); - } - if (bufferedContents != null) { - return bufferedContents.getContents(); - } - return null; - } - - public IResourceVariant getRemote() { - return remote; - } - - /** - * Cache the contents for the remote resource in a local buffer - * @param monitor - */ - public void cacheContents(IProgressMonitor monitor) throws TeamException { - bufferedContents = remote.getStorage(monitor); - } - - /** - * Update the remote handle in this typed element. - * @param variant the new remote handle - */ - public void update(IResourceVariant variant) { - Assert.isNotNull(variant); - discardBuffer(); - remote = variant; - fireContentChanged(); - } - - /* (non-Javadoc) - * @see org.eclipse.compare.IEncodedStreamContentAccessor#getCharset() - */ - public String getCharset() throws CoreException { - if(bufferedContents == null) { - cacheContents(new NullProgressMonitor()); - } - if (bufferedContents instanceof IEncodedStorage) { - return ((IEncodedStorage)bufferedContents).getCharset(); - } - return null; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ScopableSubscriberParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ScopableSubscriberParticipant.java deleted file mode 100644 index ddb607ae7..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ScopableSubscriberParticipant.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.synchronize; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.team.core.subscribers.Subscriber; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor; -import org.eclipse.team.ui.synchronize.ISynchronizeScope; -import org.eclipse.team.ui.synchronize.SubscriberParticipant; - -/** - * subscriber particpant that supports filtering using scopes. - */ -public abstract class ScopableSubscriberParticipant extends SubscriberParticipant { - - /** - * No arg contructor used to create workspace scope and for - * creation of persisted participant after startup - */ - public ScopableSubscriberParticipant() { - } - - public ScopableSubscriberParticipant(ISynchronizeScope scope) { - super(scope); - } - - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant#setSubscriber(org.eclipse.team.core.subscribers.Subscriber) - */ - protected void setSubscriber(Subscriber subscriber) { - super.setSubscriber(subscriber); - try { - ISynchronizeParticipantDescriptor descriptor = getDescriptor(); - setInitializationData(descriptor); - } catch (CoreException e) { - TeamUIPlugin.log(e); - } - if (getSecondaryId() == null) { - setSecondaryId(Long.toString(System.currentTimeMillis())); - } - } - - /** - * Return the descriptor for this participant - * @return the descriptor for this participant - */ - protected abstract ISynchronizeParticipantDescriptor getDescriptor(); - -} 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 deleted file mode 100644 index e2c55e998..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java +++ /dev/null @@ -1,512 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.compare.internal.INavigatable; -import org.eclipse.compare.structuremergeviewer.DiffNode; -import org.eclipse.compare.structuremergeviewer.ICompareInput; -import org.eclipse.compare.structuremergeviewer.ICompareInputChangeListener; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.action.ActionContributionItem; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.IOpenListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.OpenEvent; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.MenuEvent; -import org.eclipse.swt.events.MenuListener; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.core.Assert; -import org.eclipse.team.internal.ui.IPreferenceIds; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.internal.ui.synchronize.actions.StatusLineContributionGroup; -import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SynchronizeModelAction; -import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.actions.ActionContext; -import org.eclipse.ui.actions.ActionGroup; -import org.eclipse.ui.model.BaseWorkbenchContentProvider; - -/** - * A <code>StructuredViewerAdvisor</code> controls various UI - * aspects of viewers that show {@link SyncInfoSet} like the context menu, toolbar, - * content provider, label provider, navigation, and model provider. The - * advisor allows decoupling viewer behavior from the viewers presentation. This - * allows viewers that aren't in the same class hierarchy to re-use basic - * behavior. - * <p> - * This advisor allows viewer contributions made in a plug-in manifest to - * be scoped to a particular unique id. As a result the context menu for the - * viewer can be configured to show object contributions for random id schemes. - * To enable declarative action contributions for a configuration there are two - * steps required: - * <ul> - * <li>Create a viewer contribution with a <code>targetID</code> that groups - * sets of actions that are related. A common pratice for synchronize view - * configurations is to use the participant id as the targetID. - * - * <pre> - * <viewerContribution - * id="org.eclipse.team.ccvs.ui.CVSCompareSubscriberContributions" - * targetID="org.eclipse.team.cvs.ui.compare-participant"> - * ... - * </pre> - * - * <li>Create a configuration instance with a <code>menuID</code> that - * matches the targetID in the viewer contribution. - * </ul> - * </p><p> - * Clients may subclass to add behavior for concrete structured viewers. - * </p> - * - * @see TreeViewerAdvisor - * @since 3.0 - */ -public abstract class StructuredViewerAdvisor implements IAdaptable { - - // The physical model shown to the user in the provided viewer. The information in - // this set is transformed by the model provider into the actual logical model displayed - // in the viewer. - private StructuredViewer viewer; - - // The page configuration - private ISynchronizePageConfiguration configuration; - - // Special actions that could not be contributed using an ActionGroup - private StatusLineContributionGroup statusLine; - private SynchronizeModelManager modelManager; - - private INavigatable nav; - - // Property change listener which reponds to: - // - working set selection by the user - // - decorator format change selected by the user - private IPropertyChangeListener propertyListener = new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - // Change to showing of sync state in text labels preference - if(event.getProperty().equals(IPreferenceIds.SYNCVIEW_VIEW_SYNCINFO_IN_LABEL)) { - if(viewer != null && !viewer.getControl().isDisposed()) { - viewer.refresh(true /* update labels */); - } - } - } - }; - - /** - * Create an advisor that will allow viewer contributions with the given <code>targetID</code>. This - * advisor will provide a presentation model based on the given sync info set. The model is disposed - * when the viewer is disposed. - * - * @param targetID the targetID defined in the viewer contributions in a plugin.xml file. - * @param site the workbench site with which to register the menuId. Can be <code>null</code> in which - * case a site will be found using the default workbench page. - * @param set the set of <code>SyncInfo</code> objects that are to be shown to the user. - */ - public StructuredViewerAdvisor(ISynchronizePageConfiguration configuration) { - this.configuration = configuration; - configuration.setProperty(SynchronizePageConfiguration.P_ADVISOR, this); - - // Allow the configuration to provide it's own model manager but if one isn't initialized, then - // simply use the default provided by the advisor. - modelManager = (SynchronizeModelManager)configuration.getProperty(SynchronizePageConfiguration.P_MODEL_MANAGER); - if(modelManager == null) { - modelManager = createModelManager(configuration); - } - Assert.isNotNull(modelManager, "model manager must be set"); //$NON-NLS-1$ - modelManager.setViewerAdvisor(this); - } - - /** - * Create the model manager to be used by this advisor - * @param configuration - */ - protected abstract SynchronizeModelManager createModelManager(ISynchronizePageConfiguration configuration); - - /** - * Install a viewer to be configured with this advisor. An advisor can only be installed with - * one viewer at a time. When this method completes the viewer is considered initialized and - * can be shown to the user. - - * @param viewer the viewer being installed - */ - public final void initializeViewer(final StructuredViewer viewer) { - Assert.isTrue(this.viewer == null, "Can only be initialized once."); //$NON-NLS-1$ - Assert.isTrue(validateViewer(viewer)); - this.viewer = viewer; - - initializeListeners(viewer); - viewer.setLabelProvider(getLabelProvider()); - viewer.setContentProvider(getContentProvider()); - hookContextMenu(viewer); - } - - /* (non-Javadoc) - * Allow adding an advisor to the PartNavigator and support coordinated - * navigation between several objects. - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - if(adapter == INavigatable.class) { - if(nav == null) { - nav = new INavigatable() { - public boolean gotoDifference(boolean next) { - return StructuredViewerAdvisor.this.navigate(next); - } - }; - } - return nav; - } - return null; - } - - private void initializeStatusLine() { - statusLine = new StatusLineContributionGroup( - configuration.getSite().getShell(), - configuration); - } - - /** - * Must be called when an advisor is no longer needed. - */ - public void dispose() { - if (statusLine != null) { - statusLine.dispose(); - } - if (getActionGroup() != null) { - getActionGroup().dispose(); - } - TeamUIPlugin.getPlugin().getPreferenceStore().removePropertyChangeListener(propertyListener); - } - - /** - * Subclasses must implement to allow navigation of their viewers. - * - * @param next if <code>true</code> then navigate forwards, otherwise navigate - * backwards. - * @return <code>true</code> if the end is reached, and <code>false</code> otherwise. - */ - public abstract boolean navigate(boolean next); - - /** - * Sets a new selection for this viewer and optionally makes it visible. - * This is required because the model - * provider controls the actual model elements in the viewer and must be consulted in order to - * understand what objects can be selected in the viewer. - * - * @param object the objects to select - * @param reveal <code>true</code> if the selection is to be made visible, and - * <code>false</code> otherwise - */ - public void setSelection(ISelection selection, boolean reveal) { - if (!selection.isEmpty()) { - viewer.setSelection(selection, reveal); - } - } - - /** - * Method invoked from <code>initializeViewer(Composite, StructuredViewer)</code> - * in order to initialize any listeners for the viewer. - * - * @param viewer the viewer being initialize - */ - protected void initializeListeners(final StructuredViewer viewer) { - viewer.getControl().addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - StructuredViewerAdvisor.this.dispose(); - } - }); - viewer.addOpenListener(new IOpenListener() { - public void open(OpenEvent event) { - handleOpen(); - } - }); - viewer.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - handleDoubleClick(viewer, event); - } - }); - viewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - // Update the action bars enablement for any contributed action groups - updateActionBars((IStructuredSelection)viewer.getSelection()); - } - }); - TeamUIPlugin.getPlugin().getPreferenceStore().addPropertyChangeListener(propertyListener); - } - - protected boolean handleDoubleClick(StructuredViewer viewer, DoubleClickEvent event) { - IStructuredSelection selection = (IStructuredSelection) event.getSelection(); - DiffNode node = (DiffNode) selection.getFirstElement(); - if (node != null && node instanceof SyncInfoModelElement) { - SyncInfoModelElement syncNode = (SyncInfoModelElement) node; - IResource resource = syncNode.getResource(); - if (syncNode != null && resource != null && resource.getType() == IResource.FILE) { - handleOpen(); - return true; - } - } - return false; - } - - private void handleOpen() { - Object o = getConfiguration().getProperty(SynchronizePageConfiguration.P_OPEN_ACTION); - if (o instanceof IAction) { - IAction action = (IAction)o; - action.run(); - } - } - - /** - * Subclasses can validate that the viewer being initialized with this advisor - * is of the correct type. - * - * @param viewer the viewer to validate - * @return <code>true</code> if the viewer is valid, <code>false</code> otherwise. - */ - protected abstract boolean validateViewer(StructuredViewer viewer); - - /** - * Returns the content provider for the viewer. - * - * @return the content provider for the viewer. - */ - protected IStructuredContentProvider getContentProvider() { - return new BaseWorkbenchContentProvider(); - } - - /** - * Get the label provider that will be assigned to the viewer initialized - * by this configuration. Subclass may override but should either wrap the - * default one provided by this method or subclass <code>TeamSubscriberParticipantLabelProvider</code>. - * In the later case, the logical label provider should still be assigned - * to the subclass of <code>TeamSubscriberParticipantLabelProvider</code>. - * @param logicalProvider - * the label provider for the selected logical view - * @return a label provider - * @see SynchronizeModelElementLabelProvider - */ - protected ILabelProvider getLabelProvider() { - ILabelProvider provider = new SynchronizeModelElementLabelProvider(); - ILabelDecorator[] decorators = (ILabelDecorator[])getConfiguration().getProperty(ISynchronizePageConfiguration.P_LABEL_DECORATORS); - if (decorators == null) { - return provider; - } - return new DecoratingColorLabelProvider(provider, decorators); - } - - /** - * Returns the viewer configured by this advisor. - * - * @return the viewer configured by this advisor. - */ - public final StructuredViewer getViewer() { - return viewer; - } - - /** - * Called to set the input to a viewer. The input to a viewer is always the model created - * by the model provider. - * - * @param viewer the viewer to set the input. - */ - public final void setInput(ISynchronizeModelProvider modelProvider) { - final ISynchronizeModelElement modelRoot = modelProvider.getModelRoot(); - getActionGroup().modelChanged(modelRoot); - modelRoot.addCompareInputChangeListener(new ICompareInputChangeListener() { - public void compareInputChanged(ICompareInput source) { - getActionGroup().modelChanged(modelRoot); - } - }); - if (viewer != null) { - modelProvider.setViewer(viewer); - viewer.setSorter(modelProvider.getViewerSorter()); - viewer.setInput(modelRoot); - } - } - - /** - * @return Returns the configuration. - */ - public ISynchronizePageConfiguration getConfiguration() { - return configuration; - } - - /** - * Method invoked from the synchronize page when the action - * bars are set. The advisor uses the configuration to determine - * which groups appear in the action bar menus and allows all - * action groups registered with the configuration to fill the action bars. - * @param actionBars the Action bars for the page - */ - public final void setActionBars(IActionBars actionBars) { - if(actionBars != null) { - IToolBarManager manager = actionBars.getToolBarManager(); - - // Populate the toobar menu with the configured groups - Object o = configuration.getProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU); - if (!(o instanceof String[])) { - o = ISynchronizePageConfiguration.DEFAULT_TOOLBAR_MENU; - } - String[] groups = (String[])o; - for (int i = 0; i < groups.length; i++) { - String group = groups[i]; - // The groupIds must be converted to be unique since the toolbar is shared - manager.add(new Separator(getGroupId(group))); - } - - // view menu - IMenuManager menu = actionBars.getMenuManager(); - if (menu != null) { - // Populate the view dropdown menu with the configured groups - o = configuration.getProperty(ISynchronizePageConfiguration.P_VIEW_MENU); - if (!(o instanceof String[])) { - o = ISynchronizePageConfiguration.DEFAULT_VIEW_MENU; - } - groups = (String[]) o; - initializeStatusLine(); - for (int i = 0; i < groups.length; i++) { - String group = groups[i]; - // The groupIds must be converted to be unique since the - // view menu is shared - menu.add(new Separator(getGroupId(group))); - } - } - // status line - IStatusLineManager statusLineMgr = actionBars.getStatusLineManager(); - if (statusLineMgr != null && statusLine != null) { - statusLine.fillActionBars(actionBars); - } - - getActionGroup().fillActionBars(actionBars); - updateActionBars((IStructuredSelection) getViewer().getSelection()); - Object input = viewer.getInput(); - if (input instanceof ISynchronizeModelElement) { - getActionGroup().modelChanged((ISynchronizeModelElement) input); - } - } - } - - /* - * Method invoked from <code>initializeViewer(StructuredViewer)</code> - * in order to configure the viewer to call <code>fillContextMenu(StructuredViewer, IMenuManager)</code> - * when a context menu is being displayed in viewer. - * - * @param viewer the viewer being initialized - * @see fillContextMenu(StructuredViewer, IMenuManager) - */ - private void hookContextMenu(final StructuredViewer viewer) { - final MenuManager menuMgr = new MenuManager(null); //$NON-NLS-1$ - menuMgr.setRemoveAllWhenShown(true); - menuMgr.addMenuListener(new IMenuListener() { - - public void menuAboutToShow(IMenuManager manager) { - fillContextMenu(viewer, manager); - } - }); - Menu menu = menuMgr.createContextMenu(viewer.getControl()); - menu.addMenuListener(new MenuListener() { - - public void menuHidden(MenuEvent e) { - } - - // Hack to allow action contributions to update their - // state before the menu is shown. This is required when - // the state of the selection changes and the contributions - // need to update enablement based on this. - // TODO: Is this hack still needed - public void menuShown(MenuEvent e) { - IContributionItem[] items = menuMgr.getItems(); - for (int i = 0; i < items.length; i++) { - IContributionItem item = items[i]; - if (item instanceof ActionContributionItem) { - IAction actionItem = ((ActionContributionItem) item).getAction(); - if (actionItem instanceof SynchronizeModelAction) { - ((SynchronizeModelAction) actionItem).selectionChanged(viewer.getSelection()); - } - } - } - } - }); - viewer.getControl().setMenu(menu); - } - - /* - * Callback that is invoked when a context menu is about to be shown in the - * viewer. Subsclasses must implement to contribute menus. Also, menus can - * contributed by creating a viewer contribution with a <code>targetID</code> - * that groups sets of actions that are related. - * - * @param viewer the viewer in which the context menu is being shown. - * @param manager the menu manager to which actions can be added. - */ - private void fillContextMenu(StructuredViewer viewer, final IMenuManager manager) { - // Populate the menu with the configured groups - Object o = configuration.getProperty(ISynchronizePageConfiguration.P_CONTEXT_MENU); - if (!(o instanceof String[])) { - o = ISynchronizePageConfiguration.DEFAULT_CONTEXT_MENU; - } - String[] groups = (String[])o; - for (int i = 0; i < groups.length; i++) { - String group = groups[i]; - // There is no need to adjust the group ids in a contetx menu (see setActionBars) - manager.add(new Separator(group)); - } - getActionGroup().setContext(new ActionContext(viewer.getSelection())); - getActionGroup().fillContextMenu(manager); - } - - private void updateActionBars(IStructuredSelection selection) { - ActionGroup group = getActionGroup(); - if (group != null) { - group.setContext(new ActionContext(selection)); - group.updateActionBars(); - } - } - - private SynchronizePageActionGroup getActionGroup() { - return (SynchronizePageActionGroup)configuration; - } - - private String getGroupId(String group) { - return ((SynchronizePageConfiguration)configuration).getGroupId(group); - } - - /* - * For use by test cases only - * @return Returns the modelManager. - */ - public SynchronizeModelManager getModelManager() { - return modelManager; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberParticipantPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberParticipantPage.java deleted file mode 100644 index 15f241aa5..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberParticipantPage.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoCollector; -import org.eclipse.team.internal.core.subscribers.WorkingSetFilteredSyncInfoCollector; -import org.eclipse.team.internal.ui.synchronize.actions.SubscriberActionContribution; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SubscriberParticipant; - -/** - * A synchronize view page that works with participants that are subclasses of - * {@link SubscriberParticipant}. It shows changes in the tree or table view - * and supports navigation, opening, and filtering changes. - * <p> - * Clients can subclass to extend the label decoration or add action bar - * contributions. For more extensive modifications, clients should create - * their own custom page. - * </p> - * @since 3.0 - */ -public final class SubscriberParticipantPage extends SyncInfoSetSynchronizePage implements IAdaptable { - - private SubscriberParticipant participant; - - private final static int[] INCOMING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.INCOMING}; - private final static int[] OUTGOING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.OUTGOING}; - private final static int[] BOTH_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.INCOMING, SyncInfo.OUTGOING}; - private final static int[] CONFLICTING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING}; - - /** - * Filters out-of-sync resources by working set and mode - */ - private WorkingSetFilteredSyncInfoCollector collector; - - /** - * Constructs a new SynchronizeView. - */ - public SubscriberParticipantPage(ISynchronizePageConfiguration configuration, SubscriberSyncInfoCollector subscriberCollector) { - super(configuration); - this.participant = (SubscriberParticipant)configuration.getParticipant(); - configuration.setComparisonType(isThreeWay() - ? ISynchronizePageConfiguration.THREE_WAY - : ISynchronizePageConfiguration.TWO_WAY); - configuration.addActionContribution(new SubscriberActionContribution()); - initializeCollector(configuration, subscriberCollector); - } - - /** - * @return Returns the participant. - */ - public SubscriberParticipant getParticipant() { - return participant; - } - - /* - * This method is invoked from <code>setMode</code> when the mode has changed. - * It sets the filter on the collector to show the <code>SyncInfo</code> - * appropriate for the mode. - * @param mode the new mode (one of <code>INCOMING_MODE_FILTER</code>, - * <code>OUTGOING_MODE_FILTER</code>, <code>CONFLICTING_MODE_FILTER</code> - * or <code>BOTH_MODE_FILTER</code>) - */ - protected void updateMode(int mode) { - if(collector != null && isThreeWay()) { - - int[] modeFilter = BOTH_MODE_FILTER; - switch(mode) { - case ISynchronizePageConfiguration.INCOMING_MODE: - modeFilter = INCOMING_MODE_FILTER; break; - case ISynchronizePageConfiguration.OUTGOING_MODE: - modeFilter = OUTGOING_MODE_FILTER; break; - case ISynchronizePageConfiguration.BOTH_MODE: - modeFilter = BOTH_MODE_FILTER; break; - case ISynchronizePageConfiguration.CONFLICTING_MODE: - modeFilter = CONFLICTING_MODE_FILTER; break; - } - - collector.setFilter( - new FastSyncInfoFilter.AndSyncInfoFilter( - new FastSyncInfoFilter[] { - new FastSyncInfoFilter.SyncInfoDirectionFilter(modeFilter) - })); - } - } - - private void initializeCollector(ISynchronizePageConfiguration configuration, SubscriberSyncInfoCollector subscriberCollector) { - SubscriberParticipant participant = getParticipant(); - collector = new WorkingSetFilteredSyncInfoCollector(subscriberCollector, participant.getSubscriber().roots()); - updateMode(configuration.getMode()); - collector.reset(); - configuration.setProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET, collector.getSyncInfoTree()); - configuration.setProperty(SynchronizePageConfiguration.P_WORKING_SET_SYNC_INFO_SET, collector.getWorkingSetSyncInfoSet()); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SyncInfoSetSynchronizePage#isThreeWay() - */ - protected boolean isThreeWay() { - return getParticipant().getSubscriber().getResourceComparator().isThreeWay(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.SyncInfoSetSynchronizePage#reset() - */ - public void reset() { - getParticipant().reset(); - } - - /* - * Provide internal access to the collector - * @return Returns the collector. - */ - public WorkingSetFilteredSyncInfoCollector getCollector() { - return collector; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberParticipantWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberParticipantWizard.java deleted file mode 100644 index 871f03548..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberParticipantWizard.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.synchronize; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.ui.*; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; -import org.eclipse.team.ui.synchronize.ISynchronizeScope; -import org.eclipse.team.ui.synchronize.SubscriberParticipant; - -/** - * This is the class registered with the org.eclipse.team.ui.synchronizeWizard - */ -public abstract class SubscriberParticipantWizard extends Wizard { - - private GlobalRefreshResourceSelectionPage selectionPage; - - public SubscriberParticipantWizard() { - setDefaultPageImageDescriptor(TeamImages.getImageDescriptor(ISharedImages.IMG_WIZBAN_SHARE)); - setNeedsProgressMonitor(false); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.Wizard#getWindowTitle() - */ - public String getWindowTitle() { - return Policy.bind("GlobalRefreshSubscriberPage.0"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.Wizard#addPages() - */ - public void addPages() { - selectionPage = new GlobalRefreshResourceSelectionPage(getRootResources()); - selectionPage.setTitle(Policy.bind("GlobalRefreshSubscriberPage.1", getName())); //$NON-NLS-1$ - selectionPage.setMessage(Policy.bind("GlobalRefreshSubscriberPage.2")); //$NON-NLS-1$ - addPage(selectionPage); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#performFinish() - */ - public boolean performFinish() { - IResource[] resources = selectionPage.getRootResources(); - if(resources != null && resources.length > 0) { - SubscriberParticipant participant = createParticipant(selectionPage.getSynchronizeScope()); - TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] {participant}); - // We don't know in which site to show progress because a participant could actually be shown in multiple sites. - participant.run(null /* no site */); - } - return true; - } - - protected abstract IResource[] getRootResources(); - - protected abstract SubscriberParticipant createParticipant(ISynchronizeScope scope); - - protected abstract String getName(); -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java deleted file mode 100644 index 74e93867d..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java +++ /dev/null @@ -1,209 +0,0 @@ -package org.eclipse.team.internal.ui.synchronize; - -import java.text.DateFormat; -import java.util.Date; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.ui.synchronize.SubscriberParticipant; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.actions.ActionFactory; - -/** - * Schedule to refresh a subscriber at a specified interval. The schedule can be disabled or enabled - * and will create the refresh job. - * - * @since 3.0 - */ -public class SubscriberRefreshSchedule { - private long refreshInterval = 3600; // 1 hour default - - private boolean enabled = false; - - private RefreshSubscriberJob job; - - private SubscriberParticipant participant; - - private IRefreshEvent lastRefreshEvent; - - /** - * Key for settings in memento - */ - private static final String CTX_REFRESHSCHEDULE_INTERVAL = TeamUIPlugin.ID + ".CTX_REFRESHSCHEDULE_INTERVAL"; //$NON-NLS-1$ - - /** - * Key for schedule in memento - */ - private static final String CTX_REFRESHSCHEDULE_ENABLED = TeamUIPlugin.ID + ".CTX_REFRESHSCHEDULE_ENABLED"; //$NON-NLS-1$ - - private IRefreshSubscriberListener refreshSubscriberListener = new IRefreshSubscriberListener() { - public void refreshStarted(IRefreshEvent event) { - } - public ActionFactory.IWorkbenchAction refreshDone(final IRefreshEvent event) { - if (event.getSubscriber() == participant.getSubscriber()) { - lastRefreshEvent = event; - if(enabled && event.getRefreshType() == IRefreshEvent.SCHEDULED_REFRESH) { - RefreshUserNotificationPolicy policy = new RefreshUserNotificationPolicy(participant); - policy.refreshDone(event); - } - } - return null; - } - }; - - - public SubscriberRefreshSchedule(SubscriberParticipant participant) { - this.participant = participant; - RefreshSubscriberJob.addRefreshListener(refreshSubscriberListener); - } - - /** - * @return Returns the enabled. - */ - public boolean isEnabled() { - return enabled; - } - - /** - * @param enabled The enabled to set. - */ - public void setEnabled(boolean enabled, boolean allowedToStart) { - boolean wasEnabled = isEnabled(); - this.enabled = enabled; - if(enabled && ! wasEnabled) { - if(allowedToStart) { - startJob(); - } - } else { - stopJob(); - } - } - - /** - * @return Returns the refreshInterval. - */ - public long getRefreshInterval() { - return refreshInterval; - } - - public SubscriberParticipant getParticipant() { - return participant; - } - - /** - * @param refreshInterval The refreshInterval to set. - */ - public void setRefreshInterval(long refreshInterval) { - if(refreshInterval != getRefreshInterval()) { - stopJob(); - this.refreshInterval = refreshInterval; - if(isEnabled()) { - startJob(); - } - } - } - - public void startJob() { - SyncInfoSet set = participant.getSubscriberSyncInfoCollector().getSyncInfoSet(); - if(set == null) { - return; - } - if(job == null) { - SubscriberParticipant participant = getParticipant(); - job = new RefreshSubscriberJob(participant, Policy.bind("RefreshSchedule.14"), Policy.bind("RefreshSchedule.15", participant.getName(), getRefreshIntervalAsString()), participant.getResources(), new RefreshUserNotificationPolicy(getParticipant())); //$NON-NLS-1$ - job.setUser(false); - } else if(job.getState() != Job.NONE){ - stopJob(); - } - job.setRefreshInterval(getRefreshInterval()); - job.setRestartOnCancel(true); - job.setReschedule(true); - job.schedule(getRefreshInterval()); - } - - protected void stopJob() { - if(job != null) { - job.setRestartOnCancel(false /* don't restart the job */); - job.setReschedule(false); - job.cancel(); - job = null; - } - } - - public void dispose() { - stopJob(); - RefreshSubscriberJob.removeRefreshListener(refreshSubscriberListener); - } - - public void saveState(IMemento memento) { - memento.putString(CTX_REFRESHSCHEDULE_ENABLED, Boolean.toString(enabled)); - memento.putInteger(CTX_REFRESHSCHEDULE_INTERVAL, (int)refreshInterval); - } - - public static SubscriberRefreshSchedule init(IMemento memento, SubscriberParticipant participant) { - SubscriberRefreshSchedule schedule = new SubscriberRefreshSchedule(participant); - if(memento != null) { - String enabled = memento.getString(CTX_REFRESHSCHEDULE_ENABLED); - int interval = memento.getInteger(CTX_REFRESHSCHEDULE_INTERVAL).intValue(); - schedule.setRefreshInterval(interval); - schedule.setEnabled("true".equals(enabled) ? true : false, false /* don't start job */); //$NON-NLS-1$ - } - // Use the defaults if a schedule hasn't been saved or can't be found. - return schedule; - } - - public static String refreshEventAsString(IRefreshEvent event) { - if(event == null) { - return Policy.bind("SyncViewPreferencePage.lastRefreshRunNever"); //$NON-NLS-1$ - } - long stopMills = event.getStopTime(); - long startMills = event.getStartTime(); - StringBuffer text = new StringBuffer(); - if(stopMills <= 0) { - text.append(Policy.bind("SyncViewPreferencePage.lastRefreshRunNever")); //$NON-NLS-1$ - } else { - Date lastTimeRun = new Date(stopMills); - text.append(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(lastTimeRun)); - } - SyncInfo[] changes = event.getChanges(); - if (changes.length != 0) { - text.append(Policy.bind("RefreshSchedule.6", Integer.toString(changes.length))); //$NON-NLS-1$ - } else { - text.append(Policy.bind("RefreshSchedule.7")); //$NON-NLS-1$ - } - return text.toString(); - } - - public String getScheduleAsString() { - if(! isEnabled()) { - return Policy.bind("RefreshSchedule.8"); //$NON-NLS-1$ - } - return getRefreshIntervalAsString(); - } - - public IRefreshEvent getLastRefreshEvent() { - return lastRefreshEvent; - } - - private String getRefreshIntervalAsString() { - boolean hours = false; - long seconds = getRefreshInterval(); - if(seconds <= 60) { - seconds = 60; - } - long minutes = seconds / 60; - if(minutes >= 60) { - minutes = minutes / 60; - hours = true; - } - String unit; - if(minutes >= 1) { - unit = (hours ? Policy.bind("RefreshSchedule.9") : Policy.bind("RefreshSchedule.10")); //$NON-NLS-1$ //$NON-NLS-2$ - } else { - unit = (hours ? Policy.bind("RefreshSchedule.11") : Policy.bind("RefreshSchedule.12")); //$NON-NLS-1$ //$NON-NLS-2$ - } - return Policy.bind("RefreshSchedule.13", Long.toString(minutes), unit); //$NON-NLS-1$ - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoModelElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoModelElement.java deleted file mode 100644 index f6cc756c0..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoModelElement.java +++ /dev/null @@ -1,263 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.compare.ITypedElement; -import org.eclipse.compare.ResourceNode; -import org.eclipse.compare.structuremergeviewer.*; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.internal.ui.Policy; - -/** - * A diff node used to display the synchronization state for resources described by - * existing {@link SyncInfo} objects. The synchronization state for a node can - * change after it has been created. Since it implements the <code>ITypedElement</code> - * and <code>ICompareInput</code> interfaces it can be used directly to - * display the compare result in a <code>DiffTreeViewer</code> and as the - * input to any other compare/merge viewer. - * <p> - * Clients typically use this class as is, but may subclass if required. - * </p> - * @see DiffTreeViewer - * @see Differencer - */ -public class SyncInfoModelElement extends SynchronizeModelElement { - - private ITypedElement ancestor; - private SyncInfo info; - - /** - * Construct a <code>SyncInfoModelElement</code> for the given resource. - * - * @param set The set associated with the diff tree veiwer - * @param resource The resource for the node - */ - public SyncInfoModelElement(IDiffContainer parent, SyncInfo info) { - super(parent); - this.info = info; - // update state - setKind(info.getKind()); - // local - setLeft(createLocalTypeElement(info)); - // remote - setRight(createRemoteTypeElement(info)); - // base - setAncestor(createBaseTypeElement(info)); - - fireChange(); - } - - /** - * Update this element with a changed sync info. The remote and base handles have to be updated - * with the new handles in the sync info. - * - * @param info the new sync info - */ - public void update(SyncInfo info) { - this.info = info; - // update state - setKind(info.getKind()); - // never have to update the local, it's always the workspace resource - // Remote - RemoteResourceTypedElement rightEl = (RemoteResourceTypedElement)getRight(); - IResourceVariant remote = info.getRemote(); - if(rightEl == null && remote != null) { - setRight(createRemoteTypeElement(info)); - } else if(rightEl != null) { - if(remote == null) { - setRight(null); - } else { - rightEl.update(remote); - } - } - // Base - RemoteResourceTypedElement ancestorEl = (RemoteResourceTypedElement)getRight(); - IResourceVariant base = info.getBase(); - if(ancestorEl == null && base != null) { - setAncestor(createBaseTypeElement(info)); - } else if(ancestorEl != null) { - if(base == null) { - setAncestor(null); - } else { - ancestorEl.update(base); - } - } - - fireChange(); - } - - /* (non-Javadoc) - * @see org.eclipse.compare.structuremergeviewer.DiffElement#getKind() - */ - public int getKind() { - SyncInfo info = getSyncInfo(); - if (info != null) { - return info.getKind(); - } else { - return SyncInfo.IN_SYNC; - } - } - - /** - * We have to track the base because <code>DiffNode</code> doesn't provide a - * setter. See: - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52261 - */ - public void setAncestor(ITypedElement ancestor) { - this.ancestor = ancestor; - } - - /* (non-Javadoc) - * @see org.eclipse.compare.structuremergeviewer.DiffNode#getAncestor() - */ - public ITypedElement getAncestor() { - return this.ancestor; - } - - /* (non-Javadoc) - * @see org.eclipse.compare.structuremergeviewer.DiffNode#getName() - */ - public String getName() { - IResource resource = getResource(); - if(resource != null) { - return resource.getName(); - } else { - return super.getName(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - if(adapter == SyncInfo.class) { - return getSyncInfo(); - } - return super.getAdapter(adapter); - } - - /** - * Helper method that returns the resource associated with this node. A node is not - * required to have an associated local resource. - * @return the resource associated with this node or <code>null</code> if the local - * contributor is not a resource. - */ - public IResource getResource() { - ITypedElement element = getLeft(); - if(element instanceof ResourceNode) { - return ((ResourceNode)element).getResource(); - } - return null; - } - - /** - * Return true if the receiver's Subscriber and Resource are equal to that of object. - * @param object The object to test - * @return true has the same subsriber and resource - */ - public boolean equals(Object object) { - return this==object; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - IResource resource = getResource(); - if (resource == null) { - return super.hashCode(); - } - return resource.hashCode(); - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString() { - return getResource() != null ? getResource().getFullPath().toString() : getName(); - } - - /** - * Cache the contents for the base and remote. - * @param monitor - */ - public void cacheContents(IProgressMonitor monitor) throws TeamException { - ITypedElement base = getAncestor(); - ITypedElement remote = getRight(); - int work = Math.min((remote== null ? 0 : 50) + (base == null ? 0 : 50), 10); - monitor.beginTask(null, work); - try { - if (base != null && base instanceof RemoteResourceTypedElement) { - ((RemoteResourceTypedElement)base).cacheContents(Policy.subMonitorFor(monitor, 50)); - } - if (remote != null && remote instanceof RemoteResourceTypedElement) { - ((RemoteResourceTypedElement)remote).cacheContents(Policy.subMonitorFor(monitor, 50)); - } - } finally { - monitor.done(); - } - } - - public SyncInfo getSyncInfo() { - return info; - } - - /** - * Create an ITypedElement for the given local resource. The returned ITypedElement - * will prevent editing of outgoing deletions. - */ - private static ITypedElement createTypeElement(final IResource resource, final int kind) { - if(resource != null) { - return new LocalResourceTypedElement(resource) { - public boolean isEditable() { - if(! resource.exists() && SyncInfo.getDirection(kind) == SyncInfo.OUTGOING && SyncInfo.getChange(kind) == SyncInfo.DELETION) { - return false; - } - return super.isEditable(); - } - }; - } - return null; - } - - /** - * Create an ITypedElement for the given remote resource. The contents for the remote resource - * will be retrieved from the given IStorage which is a local cache used to buffer the remote contents - */ - protected static ITypedElement createTypeElement(IResourceVariant remoteResource) { - return new RemoteResourceTypedElement(remoteResource); - } - - protected static ITypedElement createRemoteTypeElement(SyncInfo info) { - if(info != null && info.getRemote() != null) { - return createTypeElement(info.getRemote()); - } - return null; - } - - protected static ITypedElement createLocalTypeElement(SyncInfo info) { - if(info != null && info.getLocal() != null) { - return createTypeElement(info.getLocal(), info.getKind()); - } - return null; - } - - protected static ITypedElement createBaseTypeElement(SyncInfo info) { - if(info != null && info.getBase() != null) { - return createTypeElement(info.getBase()); - } - return null; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoSetSynchronizePage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoSetSynchronizePage.java deleted file mode 100644 index e82186f34..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoSetSynchronizePage.java +++ /dev/null @@ -1,300 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.synchronize; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.Viewer; -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.Control; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.actions.DirectionFilterActionGroup; -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.SynchronizePageActionGroup; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.part.IShowInSource; -import org.eclipse.ui.part.IShowInTargetList; -import org.eclipse.ui.part.Page; -import org.eclipse.ui.part.ShowInContext; - -/** - * Abstract synchronize page that populates the view using a sync info set - * that is possibly filtered by a working set and a mode incoming, outgoing, - * both or conflicting). - * <p> - * The particpant creating this page must set the particpant set property - * of the page configuration before the page is created. Subclasses - * should set the working set sync info set and output sync info set - * in the configuration. These sets are used by the page to display - * appropriate messages when the view is empty. - */ -public abstract class SyncInfoSetSynchronizePage extends Page implements ISynchronizePage, IAdaptable { - - private ISynchronizePageConfiguration configuration; - private ISynchronizePageSite site; - - // Parent composite of this view. It is remembered so that we can dispose of its children when - // the viewer type is switched. - private Composite composite; - private ChangesSection changesSection; - private Viewer changesViewer; - private StructuredViewerAdvisor viewerAdvisor; - - /* - * Contribute actions for changing modes to the page. - */ - class SyncInfoSetActions extends SynchronizePageActionGroup { - private DirectionFilterActionGroup modes; - public void initialize(ISynchronizePageConfiguration configuration) { - super.initialize(configuration); - if (isThreeWay()) { - modes = new DirectionFilterActionGroup(configuration); - } - } - public void fillActionBars(IActionBars actionBars) { - super.fillActionBars(actionBars); - if (modes == null) return; - IToolBarManager manager = actionBars.getToolBarManager(); - IContributionItem group = findGroup(manager, ISynchronizePageConfiguration.MODE_GROUP); - if (manager != null && group != null) { - modes.fillToolBar(group.getId(), manager); - } - IMenuManager viewMenu = actionBars.getMenuManager(); - group = findGroup(manager, ISynchronizePageConfiguration.MODE_GROUP); - if (viewMenu != null && group != null) { - IContributionItem layoutGroup = findGroup(manager, ISynchronizePageConfiguration.LAYOUT_GROUP); - if (layoutGroup != null) { - // Put the modes in the layout group to save space - group = layoutGroup; - } - MenuManager modesItem = new MenuManager(Policy.bind("action.modes.label")); //$NON-NLS-1$ - viewMenu.appendToGroup(group.getId(), modesItem); - modes.fillMenu(modesItem); - } - } - private boolean isThreeWay() { - return ISynchronizePageConfiguration.THREE_WAY.equals(configuration.getComparisonType()); - } - } - - /** - * Create a new instance of the page - * @param configuration a synchronize page configuration - */ - protected SyncInfoSetSynchronizePage(ISynchronizePageConfiguration configuration) { - this.configuration = configuration; - configuration.setPage(this); - configuration.addActionContribution(new SyncInfoSetActions()); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - composite = new Composite(parent, SWT.NONE); - //sc.setContent(composite); - GridLayout gridLayout= new GridLayout(); - gridLayout.makeColumnsEqualWidth= false; - gridLayout.marginWidth= 0; - gridLayout.marginHeight = 0; - gridLayout.verticalSpacing = 0; - composite.setLayout(gridLayout); - GridData data = new GridData(GridData.FILL_BOTH); - data.grabExcessVerticalSpace = true; - composite.setLayoutData(data); - - // Create the changes section which, in turn, creates the changes viewer and its configuration - this.changesSection = new ChangesSection(composite, this, configuration); - this.changesViewer = createChangesViewer(changesSection.getComposite()); - changesSection.setViewer(changesViewer); - } - - protected Viewer createChangesViewer(Composite parent) { - viewerAdvisor = new TreeViewerAdvisor(parent, configuration); - return viewerAdvisor.getViewer(); - } - - public StructuredViewerAdvisor getViewerAdvisor() { - return viewerAdvisor; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#getControl() - */ - public Control getControl() { - return composite; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#setFocus() - */ - public void setFocus() { - changesSection.setFocus(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePage#init(org.eclipse.team.ui.synchronize.ISynchronizePageSite) - */ - public void init(ISynchronizePageSite site) { - this.site = site; - IDialogSettings settings = getSettings(); - if (settings != null) { - try { - int mode = settings.getInt(ISynchronizePageConfiguration.P_MODE); - if (mode != 0) { - configuration.setMode(mode); - } - } catch (NumberFormatException e) { - // The mode settings does not exist. - // Leave the mode as is (assuming the - // participant initialized it to an - // appropriate value - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars) - */ - public void setActionBars(IActionBars actionBars) { - // Delegate menu creation to the advisor - viewerAdvisor.setActionBars(actionBars); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.Page#dispose() - */ - public void dispose() { - changesSection.dispose(); - composite.dispose(); - super.dispose(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePage#getViewer() - */ - public Viewer getViewer() { - return changesViewer; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePage#aboutToChangeProperty(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration, java.lang.String, java.lang.Object) - */ - public boolean aboutToChangeProperty( - ISynchronizePageConfiguration configuration, String key, - Object newValue) { - if (key.equals(ISynchronizePageConfiguration.P_MODE)) { - return (internalSetMode(configuration.getMode(), ((Integer)newValue).intValue())); - } - return true; - } - - private boolean internalSetMode(int oldMode, int mode) { - if(oldMode == mode) return false; - updateMode(mode); - IDialogSettings settings = getSettings(); - if (settings != null) { - settings.put(ISynchronizePageConfiguration.P_MODE, mode); - } - return true; - } - - /* - * This method enables "Show In" support for this view - * - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class key) { - if (key.equals(ISelectionProvider.class)) - return changesViewer; - if (key == IShowInSource.class) { - return new IShowInSource() { - public ShowInContext getShowInContext() { - StructuredViewer v = (StructuredViewer)changesViewer; - if (v == null) return null; - ISelection s = v.getSelection(); - if (s instanceof IStructuredSelection) { - Object[] resources = Utils.getResources(((IStructuredSelection)s).toArray()); - return new ShowInContext(null, new StructuredSelection(resources)); - } - return null; - } - }; - } - if (key == IShowInTargetList.class) { - return new IShowInTargetList() { - public String[] getShowInTargetIds() { - return new String[] { IPageLayout.ID_RES_NAV }; - } - - }; - } - return null; - } - - /** - * Return the page site that was assigned to this page. - * @return the page site that was assigned to this page - */ - public ISynchronizePageSite getSynchronizePageSite() { - return site; - } - - /** - * Return the synchronize page configuration that was used to create - * this page. - * @return Returns the configuration. - */ - public ISynchronizePageConfiguration getConfiguration() { - return configuration; - } - - /** - * Return the settings for the page from the configuration - * os <code>null</code> if settings can not be persisted - * for the page - * @return the persisted page settings - */ - protected IDialogSettings getSettings() { - return configuration.getSite().getPageSettings(); - } - - /** - * Callback from the changes section that indicates that the - * user has chosen to reset the view contents after an error - * has occurred - */ - public abstract void reset(); - - /** - * Change the mode to the given mode. This method is invoked - * when the mode in the configuration is changed by a client. - * @param mode the mode to be used - */ - protected abstract void updateMode(int mode); -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java deleted file mode 100644 index cd0f467a2..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java +++ /dev/null @@ -1,641 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import java.io.*; -import java.util.*; - -import org.eclipse.core.runtime.*; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialogWithToggle; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.util.ListenerList; -import org.eclipse.swt.widgets.Display; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ui.*; -import org.eclipse.team.internal.ui.registry.*; -import org.eclipse.team.ui.ITeamUIConstants; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.*; - -/** - * Manages the registered synchronize participants. It handles notification of - * participant lifecycles, creation of <code>static</code> participants, management - * of dynamic participants, and the re-creation of persisted participants. - * <p> - * A participant is defined in a plugin manifest and can have several properties: - * - static: means that they always exist and don't have to be added to the manager - * - dynamic: will be added to the manager at some later time - * - * Part (title, id, icon, composite) - described in plugin.xml (IPartInstance) - * Can have multiple parts of the same type at runtime -> (IPart) - * - must acquire a part (IPartInstance.createPart()) - * - must released to part when done (IPartInstance.releasePart()) - * Some parts can added dynamically to the registry and events are fired to listeners. Listeners can create the newly added part via - * the #createPart() method. - * Parts can be persisted/restored with some state - * - * - * - * Lifecycle: - * startup -> registry read and stored in a participant instance - * createParticipant(id) -> - * releaseParticipant(IParticipantDescriptor) -> - * getParticipantRegistry -> return IParticipantDescriptors that describe the participants - * shutdown -> persist all settings - * - * @see ISynchronizeView - * @see ISynchronizeParticipant - * @since 3.0 - */ -public class SynchronizeManager implements ISynchronizeManager { - /** - * Synchronize participants listeners - */ - private ListenerList fListeners = null; - - /** - * Contains the participant descriptions - */ - private SynchronizeParticipantRegistry participantRegistry = new SynchronizeParticipantRegistry(); - - /** - * Contains the synchronize wizard descriptions - */ - private SynchronizeWizardRegistry wizardRegistry = new SynchronizeWizardRegistry(); - - /** - * Contains a table of the state saved between sessions for a participant. The set is keyed - * as such {String key -> ISynchronizeParticipantReference}. - */ - private Map participantReferences = Collections.synchronizedMap(new HashMap(10)); - - // change notification constants - private final static int ADDED = 1; - private final static int REMOVED = 2; - - // save context constants - private final static String CTX_PARTICIPANTS = "syncparticipants"; //$NON-NLS-1$ - private final static String CTX_PARTICIPANT = "participant"; //$NON-NLS-1$ - private final static String CTX_ID = "id"; //$NON-NLS-1$ - private final static String CTX_SECONDARY_ID = "secondary_id"; //$NON-NLS-1$ - private final static String CTX_PARTICIPANT_DISPLAY_NAME = "displayName"; //$NON-NLS-1$ - private final static String CTX_PARTICIPANT_DATA = "data"; //$NON-NLS-1$ - private final static String FILENAME = "syncParticipants.xml"; //$NON-NLS-1$ - - /** - * Notifies a participant listeners of additions or removals of participant references. - */ - class SynchronizeViewPageNotifier implements ISafeRunnable { - - private ISynchronizeParticipantListener fListener; - private int fType; - private ISynchronizeParticipant[] fChanged; - - public void handleException(Throwable exception) { - TeamUIPlugin.log(IStatus.ERROR, Policy.bind("SynchronizeManager.7"), exception); //$NON-NLS-1$ - } - - public void run() throws Exception { - switch (fType) { - case ADDED : - fListener.participantsAdded(fChanged); - break; - case REMOVED : - fListener.participantsRemoved(fChanged); - break; - } - } - - /** - * Notifies the given listener of the adds/removes - * @param participants the participants that changed - * @param update the type of change - */ - public void notify(ISynchronizeParticipant[] participants, int update) { - if (fListeners == null) { - return; - } - fChanged = participants; - fType = update; - Object[] copiedListeners = fListeners.getListeners(); - for (int i = 0; i < copiedListeners.length; i++) { - fListener = (ISynchronizeParticipantListener) copiedListeners[i]; - Platform.run(this); - } - fChanged = null; - fListener = null; - } - } - - /** - * Represents a paticipant instance and allows lazy initialization of the instance - * only when the participant is required. - */ - private class ParticipantInstance implements ISynchronizeParticipantReference { - private ReferenceCounter counter; - private IMemento savedState; - private SynchronizeParticipantDescriptor descriptor; - private String secondaryId; - private String displayName; - - public ParticipantInstance(SynchronizeParticipantDescriptor descriptor, String secondaryId, String displayName, IMemento savedState) { - this.counter = new ReferenceCounter(); - this.secondaryId = secondaryId; - this.savedState = savedState; - this.descriptor = descriptor; - this.displayName = displayName; - } - - public void save(IMemento memento) { - String key = Utils.getKey(descriptor.getId(), getSecondaryId()); - ISynchronizeParticipant ref = (ISynchronizeParticipant) counter.get(key); - if(ref != null) { - ref.saveState(memento); - } else if(savedState != null) { - memento.putMemento(savedState); - } - } - - public boolean equals(Object other) { - if(other == this) return true; - if (! (other instanceof ISynchronizeParticipantReference)) return false; - ISynchronizeParticipantReference otherRef = (ISynchronizeParticipantReference) other; - String otherSecondaryId = otherRef.getSecondaryId(); - return otherRef.getId().equals(getId()) && Utils.equalObject(getSecondaryId(), otherSecondaryId); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference#getId() - */ - public String getId() { - return descriptor.getId(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference#getSecondaryId() - */ - public String getSecondaryId() { - return secondaryId; - } - - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference#getDisplayName() - */ - public String getDisplayName() { - return displayName != null ? displayName : descriptor.getName(); - } - - public boolean isInstantiated() { - String key = Utils.getKey(descriptor.getId(), getSecondaryId()); - return (ISynchronizeParticipant) counter.get(key) != null; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference#createParticipant() - */ - public ISynchronizeParticipant getParticipant() throws TeamException { - String key = Utils.getKey(descriptor.getId(), getSecondaryId()); - try { - ISynchronizeParticipant participant = (ISynchronizeParticipant) counter.get(key); - int refCount = 1; - if (participant == null) { - participant = instantiate(); - if(participant != null) - counter.put(key, participant); - } else { - refCount = counter.addRef(key); - } - return participant; - } catch (TeamException e) { - TeamUIPlugin.log(e); - // TODO: Temporary handling of bad participant - participantReferences.remove(key); - throw new TeamException(Policy.bind("SynchronizeManager.8"), e); //$NON-NLS-1$ - } - } - - public void setParticipant(ISynchronizeParticipant participant) { - String key = Utils.getKey(descriptor.getId(), getSecondaryId()); - counter.put(key, participant); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference#getDescriptor() - */ - public ISynchronizeParticipantDescriptor getDescriptor() { - return descriptor; - } - - private ISynchronizeParticipant instantiate() throws TeamException { - try { - ISynchronizeParticipant participant = (ISynchronizeParticipant) TeamUIPlugin.createExtension(descriptor.getConfigurationElement(), SynchronizeParticipantDescriptor.ATT_CLASS); - participant.setInitializationData(descriptor.getConfigurationElement(), null, null); - participant.init(getSecondaryId(), savedState); - savedState = null; - return participant; - } catch (PartInitException e) { - throw new TeamException(Policy.bind("SynchronizeManager.11", descriptor.getName()), e); //$NON-NLS-1$ - } catch (CoreException e) { - throw TeamException.asTeamException(e); - } catch(Exception e) { - throw new TeamException(Policy.bind("SynchronizeManager.11", descriptor.getName()), e); //$NON-NLS-1$ - } - } - } - - public SynchronizeManager() { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.team.ui.sync.ISynchronizeManager#addSynchronizeParticipantListener(org.eclipse.team.ui.sync.ISynchronizeParticipantListener) - */ - public void addSynchronizeParticipantListener(ISynchronizeParticipantListener listener) { - if (fListeners == null) { - fListeners = new ListenerList(5); - } - fListeners.add(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.team.ui.sync.ISynchronizeManager#removeSynchronizeParticipantListener(org.eclipse.team.ui.sync.ISynchronizeParticipantListener) - */ - public void removeSynchronizeParticipantListener(ISynchronizeParticipantListener listener) { - if (fListeners != null) { - fListeners.remove(listener); - } - } - - /** - * Creates a new participant reference with of the provided type. If the secondayId is specified it - * is used as the qualifier for multiple instances of the same type. - * <p> - * The returned participant reference is a light weight handle describing the participant. The plug-in - * defining the participant is not loaded. To instantiate a participant a client must call - * {@link ISynchronizeParticipantReference#createParticipant()} and must call - * {@link ISynchronizeParticipantReference#releaseParticipant()} when finished with the participant. - * </p> - * @param type the type of the participant - * @param secondaryId a unique id for multiple instance support - * @return a reference to a participant - */ - private ParticipantInstance createParticipantReference(String type, String secondaryId, String displayName) throws PartInitException { - SynchronizeParticipantDescriptor desc = participantRegistry.find(type); - // ensure that the view id is valid - if (desc == null) - throw new PartInitException(Policy.bind("SynchronizeManager.19", type)); //$NON-NLS-1$ - // ensure that multiple instances are allowed if a secondary id is given - if (secondaryId != null) { -// if (!desc.isMultipleInstances()) { -// throw new PartInitException(Policy.bind("SynchronizeManager.20", type)); //$NON-NLS-1$ -// } - } - String key = Utils.getKey(type, secondaryId); - ParticipantInstance ref = (ParticipantInstance) participantReferences.get(key); - if (ref == null) { - ref = new ParticipantInstance(desc, secondaryId, displayName, null); - } - return ref; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.team.ui.sync.ISynchronizeManager#addSynchronizeParticipants(org.eclipse.team.ui.sync.ISynchronizeParticipant[]) - */ - public synchronized void addSynchronizeParticipants(ISynchronizeParticipant[] participants) { - // renamed to createSynchronizeParticipant(id) - List added = new ArrayList(participants.length); - for (int i = 0; i < participants.length; i++) { - ISynchronizeParticipant participant = participants[i]; - String key = Utils.getKey(participant.getId(), participant.getSecondaryId()); - if(! participantReferences.containsKey(key)) { - try { - ParticipantInstance ref = createParticipantReference(participant.getId(), participant.getSecondaryId(), participant.getName()); - ref.setParticipant(participant); - removeMatchingPinnedParticipant(participant.getId()); - participantReferences.put(key, ref); - added.add(participant); - } catch (PartInitException e) { - TeamUIPlugin.log(e); - continue; - } - } - } - if (!added.isEmpty()) { - saveState(); - fireUpdate((ISynchronizeParticipant[]) added.toArray(new ISynchronizeParticipant[added.size()]), ADDED); - } - } - - private void removeMatchingPinnedParticipant(String id) { - ISynchronizeParticipantReference[] refs = get(id); - if (refs.length > 0) { - // Find an un-pinned participant and replace it - for (int i = 0; i < refs.length; i++) { - ISynchronizeParticipantReference reference = refs[i]; - ISynchronizeParticipant p; - try { - p = reference.getParticipant(); - if (!p.isPinned()) { - removeSynchronizeParticipants(new ISynchronizeParticipant[]{p}); - break; - } - } catch (TeamException e) { - continue; - } - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.team.ui.sync.ISynchronizeManager#removeSynchronizeParticipants(org.eclipse.team.ui.sync.ISynchronizeParticipant[]) - */ - public synchronized void removeSynchronizeParticipants(ISynchronizeParticipant[] participants) { - List removed = new ArrayList(participants.length); - for (int i = 0; i < participants.length; i++) { - ISynchronizeParticipant participant = participants[i]; - String key = Utils.getKey(participant.getId(), participant.getSecondaryId()); - if(participantReferences.containsKey(key)) { - ParticipantInstance ref = (ParticipantInstance)participantReferences.remove(key); - if(ref.isInstantiated()) { - try { - ref.getParticipant().dispose(); - } catch (TeamException e) { - continue; - } - } - removed.add(participant); - } - } - if (!removed.isEmpty()) { - saveState(); - fireUpdate((ISynchronizeParticipant[]) removed.toArray(new ISynchronizeParticipant[removed.size()]), REMOVED); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeManager#get(java.lang.String) - */ - public ISynchronizeParticipantReference get(String id, String secondaryId) { - String key = Utils.getKey(id, secondaryId); - return (ISynchronizeParticipantReference) participantReferences.get(key); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeManager#get(java.lang.String) - */ - public ISynchronizeParticipantReference[] get(String id) { - ISynchronizeParticipantReference[] refs = getSynchronizeParticipants(); - ArrayList refsForId = new ArrayList(); - for (int i = 0; i < refs.length; i++) { - ISynchronizeParticipantReference reference = refs[i]; - if(reference.getId().equals(id)) { - refsForId.add(reference); - } - } - return (ISynchronizeParticipantReference[]) refsForId.toArray(new ISynchronizeParticipantReference[refsForId.size()]); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.team.ui.sync.ISynchronizeManager#getSynchronizeParticipants() - */ - public synchronized ISynchronizeParticipantReference[] getSynchronizeParticipants() { - return (ISynchronizeParticipantReference[]) participantReferences.values().toArray(new ISynchronizeParticipantReference[participantReferences.values().size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeManager#showSynchronizeViewInActivePage() - */ - public ISynchronizeView showSynchronizeViewInActivePage() { - IWorkbench workbench = TeamUIPlugin.getPlugin().getWorkbench(); - IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); - - boolean switchPerspectives = promptForPerspectiveSwitch(); - IWorkbenchPage activePage = null; - if(switchPerspectives) { - try { - String pId = TeamUIPlugin.getPlugin().getPreferenceStore().getString(IPreferenceIds.SYNCVIEW_DEFAULT_PERSPECTIVE); - activePage = workbench.showPerspective(pId, window); - } catch (WorkbenchException e) { - Utils.handleError(window.getShell(), e, Policy.bind("SynchronizeView.14"), e.getMessage()); //$NON-NLS-1$ - } - } - try { - if (activePage == null) { - activePage = TeamUIPlugin.getActivePage(); - if (activePage == null) - return null; - } - //IViewPart part = activePage.showView(ISynchronizeView.VIEW_ID, Long.toString(System.currentTimeMillis()), IWorkbenchPage.VIEW_ACTIVATE); - IViewPart part = activePage.showView(ISynchronizeView.VIEW_ID); - try { - return (ISynchronizeView) part; - } catch (ClassCastException e) { - // Strange that we cannot cast the part (see bug 53671) - TeamUIPlugin.log(IStatus.ERROR, Policy.bind("SynchronizeManager.18", part.getClass().getName()), e); //$NON-NLS-1$ - return null; - } - } catch (PartInitException pe) { - Utils.handleError(window.getShell(), pe, Policy.bind("SynchronizeView.16"), pe.getMessage()); //$NON-NLS-1$ - return null; - } - } - - /** - * Decides what action to take when switching perspectives and showing the synchronize view. Basically there are a - * set of user preferences that control how perspective switching. - */ - private boolean promptForPerspectiveSwitch() { - // Decide if a prompt is even required - IPreferenceStore store = TeamUIPlugin.getPlugin().getPreferenceStore(); - String option = store.getString(IPreferenceIds.SYNCHRONIZING_COMPLETE_PERSPECTIVE); - if(option.equals(MessageDialogWithToggle.ALWAYS)) { - return true; - } else if(option.equals(MessageDialogWithToggle.NEVER)) { - return false; - } - - // Otherwise determine if a prompt is required - IPerspectiveRegistry registry= PlatformUI.getWorkbench().getPerspectiveRegistry(); - String defaultSyncPerspectiveId = store.getString(IPreferenceIds.SYNCVIEW_DEFAULT_PERSPECTIVE); - IPerspectiveDescriptor perspectiveDescriptor = registry.findPerspectiveWithId(defaultSyncPerspectiveId); - IWorkbenchPage page = TeamUIPlugin.getActivePage(); - if(page != null) { - IPerspectiveDescriptor p = page.getPerspective(); - if(p != null && p.getId().equals(defaultSyncPerspectiveId)) { - // currently in default perspective - return false; - } - } - - if(perspectiveDescriptor != null) { - String perspectiveName = perspectiveDescriptor.getLabel(); - - MessageDialogWithToggle m = MessageDialogWithToggle.openYesNoQuestion(Display.getDefault().getActiveShell(), - Policy.bind("SynchronizeManager.27"), //$NON-NLS-1$ - Policy.bind("SynchronizeManager.30", perspectiveDescriptor.getLabel()), //$NON-NLS-1$ - Policy.bind("SynchronizeManager.31"), //$NON-NLS-1$ - false /* toggle state */, - store, - IPreferenceIds.SYNCHRONIZING_COMPLETE_PERSPECTIVE); - - int result = m.getReturnCode(); - switch (result) { - // yes, ok - case IDialogConstants.YES_ID: - case IDialogConstants.OK_ID : - return true; - // no - case IDialogConstants.NO_ID : - return false; - } - } - return false; - } - - /** - * Creates the participant registry and restore any saved participants. - * Will also instantiate any static participants. - */ - public void init() { - try { - // Initialize the participant registry - reads all participant extension descriptions. - participantRegistry.readRegistry(Platform.getPluginRegistry(), TeamUIPlugin.ID, ITeamUIConstants.PT_SYNCPARTICIPANTS); - // Initialize the wizard registry - wizardRegistry.readRegistry(Platform.getPluginRegistry(), TeamUIPlugin.ID, ITeamUIConstants.PT_SYNCHRONIZE_WIZARDS); - - // Instantiate and register any dynamic participants saved from a - // previous session. - restoreSavedParticipants(); - } catch (CoreException e) { - TeamUIPlugin.log(new Status(IStatus.ERROR, TeamUIPlugin.ID, 1, Policy.bind("SynchronizeManager.8"), e)); //$NON-NLS-1$ - } - } - - /** - * Allow participant instances to clean-up. - */ - public void dispose() { - // save state and settings for existing participants. - saveState(); - for (Iterator it = participantReferences.values().iterator(); it.hasNext();) { - ParticipantInstance ref = (ParticipantInstance) it.next(); - if((ref).isInstantiated()) { - try { - ref.getParticipant().dispose(); - } catch (TeamException e) { - continue; - } - } - } - participantReferences = null; - } - - /** - * Restores participants that have been saved between sessions. - */ - private void restoreSavedParticipants() throws CoreException { - File file = getStateFile(); - Reader reader; - try { - reader = new BufferedReader(new FileReader(file)); - } catch (FileNotFoundException e) { - return; - } - IMemento memento = XMLMemento.createReadRoot(reader); - IMemento[] participantNodes = memento.getChildren(CTX_PARTICIPANT); - for (int i = 0; i < participantNodes.length; i++) { - IMemento memento2 = participantNodes[i]; - String id = memento2.getString(CTX_ID); - String secondayId = memento2.getString(CTX_SECONDARY_ID); - if (secondayId != null) { - String displayName = memento2.getString(CTX_PARTICIPANT_DISPLAY_NAME); - SynchronizeParticipantDescriptor desc = participantRegistry.find(id); - if (desc != null) { - String key = Utils.getKey(id, secondayId); - participantReferences.put(key, new ParticipantInstance(desc, secondayId, displayName, memento2.getChild(CTX_PARTICIPANT_DATA))); - } else { - TeamUIPlugin.log(new Status(IStatus.ERROR, TeamUIPlugin.ID, 1, Policy.bind("SynchronizeManager.9", id), null)); //$NON-NLS-1$ - } - } - } - } - - /** - * Saves a file containing the list of participant ids that are registered - * with this manager. Each initialized participant is also given the chance to save - * it's state. - */ - private void saveState() { - XMLMemento xmlMemento = XMLMemento.createWriteRoot(CTX_PARTICIPANTS); - List children = new ArrayList(); - for (Iterator it = participantReferences.values().iterator(); it.hasNext(); ) { - ParticipantInstance ref = (ParticipantInstance) it.next(); - // Participants can opt out of being saved between sessions - if(! ref.getDescriptor().isPersistent()) continue; - // Create the state placeholder for a participant - IMemento participantNode = xmlMemento.createChild(CTX_PARTICIPANT); - participantNode.putString(CTX_ID, ref.getId()); - String secondaryId = ref.getSecondaryId(); - if(secondaryId != null) { - participantNode.putString(CTX_SECONDARY_ID,secondaryId); - } - participantNode.putString(CTX_PARTICIPANT_DISPLAY_NAME, ref.getDisplayName()); - IMemento participantData = participantNode.createChild(CTX_PARTICIPANT_DATA); - ref.save(participantData); - } - try { - Writer writer = new BufferedWriter(new FileWriter(getStateFile())); - try { - xmlMemento.save(writer); - } finally { - writer.close(); - } - } catch (IOException e) { - TeamUIPlugin.log(new Status(IStatus.ERROR, TeamUIPlugin.ID, 1, Policy.bind("SynchronizeManager.10"), e)); //$NON-NLS-1$ - } - } - - private File getStateFile() { - IPath pluginStateLocation = TeamUIPlugin.getPlugin().getStateLocation(); - return pluginStateLocation.append(FILENAME).toFile(); //$NON-NLS-1$ - } - - /** - * Fires notification. - * @param participants participants added/removed - * @param type ADD or REMOVE - */ - private void fireUpdate(ISynchronizeParticipant[] participants, int type) { - new SynchronizeViewPageNotifier().notify(participants, type); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeManager#getDescriptor() - */ - public ISynchronizeParticipantDescriptor getParticipantDescriptor(String id) { - return participantRegistry.find(id); - } - - public SynchronizeWizardDescription[] getWizardDescriptors() { - return wizardRegistry.getSynchronizeWizards(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElement.java deleted file mode 100644 index fcda55e62..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElement.java +++ /dev/null @@ -1,196 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.compare.structuremergeviewer.*; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.*; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * A model element that can be shown in viewers. - * - * @since 3.0 - */ -public abstract class SynchronizeModelElement extends DiffNode implements IAdaptable, ISynchronizeModelElement { - - /* - * Internal flags bits for stroing properties in the flags variable - */ - private static final int BUSY_FLAG = 0x01; - private static final int PROPAGATED_CONFLICT_FLAG = 0x02; - private static final int PROPAGATED_ERROR_FLAG = 0x04; - private static final int PROPAGATED_WARNING_FLAG =0x08; - - // Instance variable containing the flags for this node - private int flags; - private ListenerList listeners; - - public SynchronizeModelElement(IDiffContainer parent) { - super(parent, SyncInfo.IN_SYNC); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - return Platform.getAdapterManager().getAdapter(this, adapter); - } - - public synchronized void addPropertyChangeListener(IPropertyChangeListener listener) { - if (listeners == null) { - listeners = new ListenerList(); - } - listeners.add(listener); - } - - public synchronized void removePropertyChangeListener(IPropertyChangeListener listener) { - if (listeners != null) { - listeners.remove(listener); - if (listeners.isEmpty()) { - listeners = null; - } - } - } - - /** - * Return whether this node has the given property set. - * @param propertyName the flag to test - * @return <code>true</code> if the property is set - */ - public boolean getProperty(String propertyName) { - return (getFlags() & getFlag(propertyName)) > 0; - } - - /** - * Add the flag to the flags for this node - * @param propertyName the flag to add - */ - public void setProperty(String propertyName, boolean value) { - if (value) { - if (!getProperty(propertyName)) { - int flag = getFlag(propertyName); - flags |= flag; - firePropertyChange(propertyName); - } - } else { - if (getProperty(propertyName)) { - int flag = getFlag(propertyName); - flags ^= flag; - firePropertyChange(propertyName); - } - } - } - - public void setPropertyToRoot(String propertyName, boolean value) { - if (value) { - addToRoot(propertyName); - } else { - removeToRoot(propertyName); - } - } - - public void fireChanges() { - fireChange(); - } - - public ImageDescriptor getImageDescriptor(Object object) { - IResource resource = getResource(); - if(resource != null) { - IWorkbenchAdapter adapter = (IWorkbenchAdapter)((IAdaptable) resource).getAdapter(IWorkbenchAdapter.class); - return adapter.getImageDescriptor(resource); - } - return null; - } - - public abstract IResource getResource(); - - private void addToRoot(String flag) { - setProperty(flag, true); - SynchronizeModelElement parent = (SynchronizeModelElement)getParent(); - if (parent != null) { - if (parent.getProperty(flag)) return; - parent.addToRoot(flag); - } - } - - private void firePropertyChange(String propertyName) { - Object[] allListeners; - synchronized(this) { - if (listeners == null) return; - allListeners = listeners.getListeners(); - } - boolean set = getProperty(propertyName); - final PropertyChangeEvent event = new PropertyChangeEvent(this, propertyName, Boolean.valueOf(!set), Boolean.valueOf(set)); - for (int i = 0; i < allListeners.length; i++) { - Object object = allListeners[i]; - if (object instanceof IPropertyChangeListener) { - final IPropertyChangeListener listener = (IPropertyChangeListener)object; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Exceptions logged by the platform - } - public void run() throws Exception { - listener.propertyChange(event); - } - }); - } - } - } - - private int getFlag(String propertyName) { - if (propertyName == BUSY_PROPERTY) { - return BUSY_FLAG; - } else if (propertyName == PROPAGATED_CONFLICT_PROPERTY) { - return PROPAGATED_CONFLICT_FLAG; - } else if(propertyName == PROPAGATED_ERROR_MARKER_PROPERTY) { - return PROPAGATED_ERROR_FLAG; - } else if(propertyName == PROPAGATED_WARNING_MARKER_PROPERTY) { - return PROPAGATED_WARNING_FLAG; - } - return 0; - } - - private int getFlags() { - return flags; - } - - private boolean hasChildWithFlag(String flag) { - IDiffElement[] childen = getChildren(); - for (int i = 0; i < childen.length; i++) { - IDiffElement element = childen[i]; - if (((SynchronizeModelElement)element).getProperty(flag)) { - return true; - } - } - return false; - } - - private void removeToRoot(String flag) { - boolean hasProperty = getProperty(flag); - if(hasProperty) { - setProperty(flag, false); - SynchronizeModelElement parent = (SynchronizeModelElement)getParent(); - if (parent != null) { - // If the parent doesn't have the tag, no recalculation is required - // Also, if the parent still has a child with the tag, no recalculation is needed - if (parent.getProperty(flag) && !parent.hasChildWithFlag(flag)) { - // The parent no longer has the flag so propogate the reclaculation - parent.removeToRoot(flag); - } - } - } - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElementLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElementLabelProvider.java deleted file mode 100644 index f201c60ee..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElementLabelProvider.java +++ /dev/null @@ -1,229 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import java.util.*; -import org.eclipse.compare.CompareConfiguration; -import org.eclipse.compare.structuremergeviewer.DiffNode; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.*; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.ui.*; -import org.eclipse.team.ui.ISharedImages; -import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -/** - * A label provider that decorates viewers showing - * {@link ISynchronizeModelElement}. - * - * @since 3.0 - */ -public class SynchronizeModelElementLabelProvider extends LabelProvider implements IColorProvider, IFontProvider { - - // Cache for folder images that have been overlayed with conflict icon - private Map fgImageCache; - - // Contains direction images - CompareConfiguration compareConfig = new CompareConfiguration(); - - // Used as the base label provider for retreiving image and text from - // the workbench adapter. - private WorkbenchLabelProvider workbenchLabelProvider = new WorkbenchLabelProvider(); - - // Font used to display busy elements - private Font busyFont; - - public SynchronizeModelElementLabelProvider() { - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) - */ - public Color getForeground(Object element) { - return null; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) - */ - public Color getBackground(Object element) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object) - */ - public Font getFont(Object element) { - if (element instanceof ISynchronizeModelElement) { - ISynchronizeModelElement node = (ISynchronizeModelElement)element; - if(node.getProperty(ISynchronizeModelElement.BUSY_PROPERTY)) { - if (busyFont == null) { - Font defaultFont = JFaceResources.getDefaultFont(); - FontData[] data = defaultFont.getFontData(); - for (int i = 0; i < data.length; i++) { - data[i].setStyle(SWT.ITALIC); - } - busyFont = new Font(TeamUIPlugin.getStandardDisplay(), data); - } - return busyFont; - } - } - return null; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) - */ - public Image getImage(Object element) { - Image base = workbenchLabelProvider.getImage(element); - if (base != null) { - if (element instanceof ISynchronizeModelElement) { - ISynchronizeModelElement syncNode = (ISynchronizeModelElement) element; - int kind = syncNode.getKind(); - Image decoratedImage; - decoratedImage = getCompareImage(base, kind); - // The reason we still overlay the compare image is to - // ensure that the image width for all images shown in the viewer - // are consistent. - return propagateConflicts(decoratedImage, syncNode); - } - } - return base; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) - */ - public String getText(Object element) { - String base = workbenchLabelProvider.getText(element); - if (element instanceof DiffNode) { - if (TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_VIEW_SYNCINFO_IN_LABEL)) { - // if the folder is already conflicting then don't bother - // propagating the conflict - int kind = ((DiffNode) element).getKind(); - if (kind != SyncInfo.IN_SYNC) { - String syncKindString = SyncInfo.kindToString(kind); - return Policy.bind("TeamSubscriberSyncPage.labelWithSyncKind", base, syncKindString); //$NON-NLS-1$ - } - } - } - return base; - } - - protected Image getCompareImage(Image base, int kind) { - switch (kind & SyncInfo.DIRECTION_MASK) { - case SyncInfo.OUTGOING : - kind = (kind & ~SyncInfo.OUTGOING) | SyncInfo.INCOMING; - break; - case SyncInfo.INCOMING : - kind = (kind & ~SyncInfo.INCOMING) | SyncInfo.OUTGOING; - break; - } - return compareConfig.getImage(base, kind); - } - - private Image propagateConflicts(Image base, ISynchronizeModelElement element) { - // if the folder is already conflicting then don't bother propagating - // the conflict - List overlays = new ArrayList(); - List locations = new ArrayList(); - - // Decorate with the busy indicator - if (element.getProperty(ISynchronizeModelElement.BUSY_PROPERTY)) { - overlays.add(TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_HOURGLASS_OVR)); - locations.add(new Integer(OverlayIcon.TOP_LEFT)); - } - // Decorate with propagated conflicts and problem markers - int kind = element.getKind(); - if ((kind & SyncInfo.DIRECTION_MASK) != SyncInfo.CONFLICTING) { - if (hasDecendantConflicts(element)) { - overlays.add(TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_CONFLICT_OVR)); - locations.add(new Integer(OverlayIcon.BOTTOM_RIGHT)); - } - } - if (hasErrorMarker(element)) { - overlays.add(TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_ERROR_OVR)); - locations.add(new Integer(OverlayIcon.BOTTOM_LEFT)); - } else if (hasWarningMarker(element)) { - overlays.add(TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_WARNING_OVR)); - locations.add(new Integer(OverlayIcon.BOTTOM_LEFT)); - } - if (!overlays.isEmpty()) { - ImageDescriptor[] overlayImages = (ImageDescriptor[]) overlays.toArray(new ImageDescriptor[overlays.size()]); - int[] locationInts = new int[locations.size()]; - for (int i = 0; i < locations.size(); i++) { - locationInts[i] = ((Integer) locations.get(i)).intValue(); - } - ImageDescriptor overlay = new OverlayIcon(base, overlayImages, locationInts, new Point(base.getBounds().width, base.getBounds().height)); - if (fgImageCache == null) { - fgImageCache = new HashMap(10); - } - Image conflictDecoratedImage = (Image) fgImageCache.get(overlay); - if (conflictDecoratedImage == null) { - conflictDecoratedImage = overlay.createImage(); - fgImageCache.put(overlay, conflictDecoratedImage); - } - return conflictDecoratedImage; - } - return base; - } - - /** - * Return whether this diff node has descendant conflicts in the view in - * which it appears. - * @return whether the node has descendant conflicts - */ - private boolean hasDecendantConflicts(ISynchronizeModelElement node) { - return ((ISynchronizeModelElement)node).getProperty(ISynchronizeModelElement.PROPAGATED_CONFLICT_PROPERTY); - } - - /** - * Return whether this diff node has descendant conflicts in the view in which it appears. - * @return whether the node has descendant conflicts - */ - private boolean hasErrorMarker(ISynchronizeModelElement node) { - return node.getProperty(ISynchronizeModelElement.PROPAGATED_ERROR_MARKER_PROPERTY); - } - - /** - * Return whether this diff node has descendant conflicts in the view in which it appears. - * @return whether the node has descendant conflicts - */ - private boolean hasWarningMarker(ISynchronizeModelElement node) { - return node.getProperty(ISynchronizeModelElement.PROPAGATED_WARNING_MARKER_PROPERTY); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ - public void dispose() { - if(busyFont != null) { - busyFont.dispose(); - } - compareConfig.dispose(); - if (fgImageCache != null) { - Iterator it = fgImageCache.values().iterator(); - while (it.hasNext()) { - Image element = (Image) it.next(); - element.dispose(); - } - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElementSorter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElementSorter.java deleted file mode 100644 index 43ce736f5..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElementSorter.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.ui.views.navigator.ResourceSorter; - -/** - * This class sorts <code>SyncInfoModelElement</code> instances. - * It is not thread safe so it should not be reused between views. - */ -public class SynchronizeModelElementSorter extends ResourceSorter { - - public SynchronizeModelElementSorter() { - super(ResourceSorter.NAME); - } - - /* (non-Javadoc) - * Method declared on ViewerSorter. - */ - public int compare(Viewer viewer, Object o1, Object o2) { - IResource resource1 = getResource(o1); - IResource resource2 = getResource(o2); - int result; - if (resource1 != null && resource2 != null) { - result = super.compare(viewer, resource1, resource2); - } else { - result = super.compare(viewer, o1, o2); - } - return result; - } - - protected IResource getResource(Object obj) { - IResource[] resources = Utils.getResources(new Object[] {obj}); - return resources.length == 1 ? resources[0] : null; - } -} 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 deleted file mode 100644 index 936ea2efc..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java +++ /dev/null @@ -1,239 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.synchronize; - -import java.util.*; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.*; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.*; -import org.eclipse.team.internal.core.Assert; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.IActionBars; - -/** - * Manages the models that can be displayed by a synchronize page - */ -public abstract class SynchronizeModelManager extends SynchronizePageActionGroup { - - private ISynchronizeModelProvider modelProvider; - private List toggleModelProviderActions; - private ISynchronizePageConfiguration configuration; - private StructuredViewerAdvisor advisor; - - /** - * Action that allows changing the model providers supported by this advisor. - */ - private class ToggleModelProviderAction extends Action implements IPropertyChangeListener { - private ISynchronizeModelProviderDescriptor descriptor; - protected ToggleModelProviderAction(ISynchronizeModelProviderDescriptor descriptor) { - super(descriptor.getName(), Action.AS_RADIO_BUTTON); - setImageDescriptor(descriptor.getImageDescriptor()); - setToolTipText(descriptor.getName()); - this.descriptor = descriptor; - update(); - configuration.addPropertyChangeListener(this); - } - - public void run() { - ISynchronizeModelProvider mp = getActiveModelProvider(); - IStructuredSelection selection = null; - if(mp != null) { - if(mp.getDescriptor().getId().equals(descriptor.getId())) return; - selection = (IStructuredSelection)configuration.getSite().getSelectionProvider().getSelection(); - } - internalPrepareInput(descriptor.getId(), null); - setInput(); - if(selection != null) { - setSelection(selection.toArray(), true); - } - } - - public void update() { - ISynchronizeModelProvider mp = getActiveModelProvider(); - if(mp != null) { - setChecked(mp.getDescriptor().getId().equals(descriptor.getId())); - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(SynchronizePageConfiguration.P_MODEL)) { - update(); - } - } - } - - public SynchronizeModelManager(ISynchronizePageConfiguration configuration) { - Assert.isNotNull(configuration, "configuration cannot be null"); //$NON-NLS-1$ - this.configuration = configuration; - configuration.addActionContribution(this); - } - - /** - * Initialize the model manager to be used with the provided advisor. - */ - public void setViewerAdvisor(StructuredViewerAdvisor advisor) { - this.advisor = advisor; - } - - /** - * Return the list of supported model providers for this advisor. - * @param viewer - * @return - */ - protected abstract ISynchronizeModelProviderDescriptor[] getSupportedModelProviders(); - - /** - * Get the model provider that will be used to create the input - * for the adviser's viewer. - * @return the model provider - */ - protected abstract ISynchronizeModelProvider createModelProvider(String id); - - protected ISynchronizeModelProvider getActiveModelProvider() { - return modelProvider; - } - - protected Object internalPrepareInput(String id, IProgressMonitor monitor) { - if(modelProvider != null) { - modelProvider.dispose(); - } - modelProvider = createModelProvider(id); - return modelProvider.prepareInput(monitor); - } - - /** - * Gets a new selection that contains the view model objects that - * correspond to the given objects. The advisor will try and - * convert the objects into the appropriate viewer objects. - * This is required because the model provider controls the actual - * model elements in the viewer and must be consulted in order to - * understand what objects can be selected in the viewer. - * <p> - * This method does not affect the selection of the viewer itself. - * It's main purpose is for testing and should not be used by other - * clients. - * </p> - * @param object the objects to select - * @return a selection corresponding to the given objects - */ - public ISelection getSelection(Object[] objects) { - if (modelProvider != null) { - Object[] viewerObjects = new Object[objects.length]; - for (int i = 0; i < objects.length; i++) { - viewerObjects[i] = modelProvider.getMapping(objects[i]); - } - return new StructuredSelection(viewerObjects); - } else { - return StructuredSelection.EMPTY; - } - } - - /** - * Sets a new selection for this viewer and optionally makes it visible. The advisor will try and - * convert the objects into the appropriate viewer objects. This is required because the model - * provider controls the actual model elements in the viewer and must be consulted in order to - * understand what objects can be selected in the viewer. - * - * @param object the objects to select - * @param reveal <code>true</code> if the selection is to be made visible, and - * <code>false</code> otherwise - */ - protected void setSelection(Object[] objects, boolean reveal) { - ISelection selection = getSelection(objects); - if (!selection.isEmpty()) { - advisor.setSelection(selection, reveal); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.IActionContribution#initialize(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) - */ - public void initialize(ISynchronizePageConfiguration configuration) { - super.initialize(configuration); - ISynchronizeModelProviderDescriptor[] providers = getSupportedModelProviders(); - // We only need switching of layouts if there is more than one model provider - if (providers.length > 1) { - toggleModelProviderActions = new ArrayList(); - for (int i = 0; i < providers.length; i++) { - final ISynchronizeModelProviderDescriptor provider = providers[i]; - toggleModelProviderActions.add(new ToggleModelProviderAction(provider)); - } - } - // The input may of been set already. In that case, don't change it and - // simply assign it to the view. - if(modelProvider == null) { - internalPrepareInput(null, null); - } - setInput(); - } - - /** - * Set the input of the viewer - */ - protected void setInput() { - configuration.setProperty(SynchronizePageConfiguration.P_MODEL, modelProvider.getModelRoot()); - if(advisor != null) - advisor.setInput(modelProvider); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.IActionContribution#setActionBars(org.eclipse.ui.IActionBars) - */ - public void fillActionBars(IActionBars actionBars) { - if (toggleModelProviderActions == null) return; - IToolBarManager toolbar = actionBars.getToolBarManager(); - IMenuManager menu = actionBars.getMenuManager(); - IContributionItem group = findGroup(menu, ISynchronizePageConfiguration.LAYOUT_GROUP); - if(menu != null && group != null) { - MenuManager layout = new MenuManager(Policy.bind("action.layout.label")); //$NON-NLS-1$ - menu.appendToGroup(group.getId(), layout); - appendToMenu(null, layout); - } else if(toolbar != null) { - group = findGroup(toolbar, ISynchronizePageConfiguration.LAYOUT_GROUP); - if (group != null) { - appendToMenu(group.getId(), toolbar); - } - } - } - - private void appendToMenu(String groupId, IContributionManager menu) { - for (Iterator iter = toggleModelProviderActions.iterator(); iter.hasNext();) { - if (groupId == null) { - menu.add((Action) iter.next()); - } else { - menu.appendToGroup(groupId, (Action) iter.next()); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.IActionContribution#dispose() - */ - public void dispose() { - if(modelProvider != null) { - modelProvider.dispose(); - } - super.dispose(); - } - - /** - * @return Returns the configuration. - */ - public ISynchronizePageConfiguration getConfiguration() { - return configuration; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelProvider.java deleted file mode 100644 index 1a85a4612..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelProvider.java +++ /dev/null @@ -1,779 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.*; - -import org.eclipse.compare.structuremergeviewer.IDiffContainer; -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Control; -import org.eclipse.team.core.ITeamStatus; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.internal.core.Assert; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.ui.progress.WorkbenchJob; - -/** - * This class is reponsible for creating and maintaining a presentation model of - * {@link SynchronizeModelElement} elements that can be shown in a viewer. The model - * is based on the synchronization information contained in the provided {@link SyncInfoSet}. - * <p> - * label updates (property propagation to parent nodes) - * sync change listener (changes, additions, removals, reset) - * batching busy updates - * </p> - * - * @see HierarchicalModelProvider - * @see CompressedFoldersModelProvider - * @since 3.0 - */ -public abstract class SynchronizeModelProvider implements ISyncInfoSetChangeListener, ISynchronizeModelProvider, IResourceChangeListener { - - private static boolean DEBUG = false; - - // Flags to indicate if tree control should be updated while building the model. - private boolean refreshViewer; - - protected Map resourceMap = Collections.synchronizedMap(new HashMap()); - - protected SynchronizeModelElement root; - - // The viewer this input is being displayed in - private StructuredViewer viewer; - - private Set pendingLabelUpdates = new HashSet(); - - private LabelUpdateJob labelUpdater = new LabelUpdateJob(); - - private ISynchronizePageConfiguration configuration; - - private IPropertyChangeListener listener = new IPropertyChangeListener() { - public void propertyChange(final PropertyChangeEvent event) { - if (event.getProperty() == SynchronizeModelElement.BUSY_PROPERTY) { - labelUpdater.add(event.getSource(), ((Boolean)event.getNewValue()).booleanValue()); - } - } - }; - - class LabelUpdateJob extends WorkbenchJob { - public static final int BATCH_WAIT_INCREMENT = 100; - Set nodes = new HashSet(); - public LabelUpdateJob() { - super(Policy.bind("HierarchicalModelProvider.0")); //$NON-NLS-1$ - setSystem(true); - } - public IStatus runInUIThread(IProgressMonitor monitor) { - Object[] updates; - synchronized(nodes) { - updates = nodes.toArray(new Object[nodes.size()]); - nodes.clear(); - } - if (canUpdateViewer()) { - StructuredViewer tree = getViewer(); - tree.update(updates, null); - } - schedule(BATCH_WAIT_INCREMENT); - return Status.OK_STATUS; - } - public void add(Object node, boolean isBusy) { - synchronized(nodes) { - nodes.add(node); - } - if (isBusy) { - schedule(BATCH_WAIT_INCREMENT); - } else { - // Wait when unbusying to give the events a chance to propogate through - // the collector - schedule(BATCH_WAIT_INCREMENT * 10); - } - } - public boolean shouldRun() { - return !nodes.isEmpty(); - } - } - - private SyncInfoSet set; - - /** - * Create an input based on the provide sync set. The input is not - * initialized until <code>prepareInput</code> is called. - * @param set - * the sync set used as the basis for the model created by this - * input. - */ - public SynchronizeModelProvider(ISynchronizePageConfiguration configuration, SyncInfoSet set) { - this(new UnchangedResourceModelElement(null, ResourcesPlugin.getWorkspace().getRoot()) { - /* - * Override to ensure that the diff viewer will appear in CompareEditorInputs - */ - public boolean hasChildren() { - return true; - } - }, configuration, set); - } - - public SynchronizeModelProvider(SynchronizeModelElement parent, ISynchronizePageConfiguration configuration, SyncInfoSet set) { - Assert.isNotNull(set); - Assert.isNotNull(parent); - this.root = parent; - this.set = set; - this.configuration = configuration; - } - - /** - * Return the set that contains the elements this provider is using as - * a basis for creating a presentation model. This cannot be null. - * - * @return the set that contains the elements this provider is - * using as a basis for creating a presentation model. - */ - public SyncInfoSet getSyncInfoSet() { - return set; - } - - /** - * Return the page configuration for this provider. - * - * @return the page configuration for this provider. - */ - public ISynchronizePageConfiguration getConfiguration() { - return configuration; - } - - /** - * Return the <code>AbstractTreeViewer</code> asociated with this content - * provider or <code>null</code> if the viewer is not of the proper type. - * @return - */ - public StructuredViewer getViewer() { - return viewer; - } - - public void setViewer(StructuredViewer viewer) { - Assert.isTrue(viewer instanceof AbstractTreeViewer); - this.viewer = (AbstractTreeViewer) viewer; - } - - /** - * Builds the viewer model based on the contents of the sync set. - */ - public ISynchronizeModelElement prepareInput(IProgressMonitor monitor) { - // Connect to the sync set which will register us as a listener and give us a reset event - // in a background thread - getSyncInfoSet().connect(this, monitor); - ResourcesPlugin.getWorkspace().addResourceChangeListener(this); - return getModelRoot(); - } - - /** - * The provider can try and return a mapping for the provided object. Providers often use mappings - * to store the source of a logical element they have created. For example, when displaying resource - * based logical elements, a provider will cache the resource -> element mapping for quick retrieval - * of the element when resource based changes are made. - * - * @param object the object to query for a mapping - * @return an object created by this provider that would be shown in a viewer, or <code>null</code> - * if the provided object is not mapped by this provider. - */ - public Object getMapping(Object object) { - return resourceMap.get(object); - } - - /** - * Dispose of the builder - */ - public void dispose() { - resourceMap.clear(); - getSyncInfoSet().removeSyncSetChangedListener(this); - ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); - } - - /** - * Returns the input created by this provider or <code>null</code> if - * {@link #prepareInput(IProgressMonitor)} hasn't been called on this object yet. - * - * @return the input created by this provider. - */ - public ISynchronizeModelElement getModelRoot() { - return root; - } - - /** - * Returns the sorter for this model provider. - * - * @return the sorter for this model provider. - */ - public abstract ViewerSorter getViewerSorter(); - - /** - * Return the model object (i.e. an instance of <code>SyncInfoModelElement</code> - * or one of its subclasses) for the given IResource. - * @param resource - * the resource - * @return the <code>SyncInfoModelElement</code> for the given resource - */ - protected ISynchronizeModelElement getModelObject(IResource resource) { - return (ISynchronizeModelElement) resourceMap.get(resource); - } - - public void syncInfoChanged(final ISyncInfoSetChangeEvent event, IProgressMonitor monitor) { - synchronized(this) { - if (! (event instanceof ISyncInfoTreeChangeEvent)) { - reset(); - } else { - final Control ctrl = getViewer().getControl(); - if (ctrl != null && !ctrl.isDisposed()) { - ctrl.getDisplay().syncExec(new Runnable() { - public void run() { - if (!ctrl.isDisposed()) { - BusyIndicator.showWhile(ctrl.getDisplay(), new Runnable() { - public void run() { - handleChanges((ISyncInfoTreeChangeEvent)event); - ISynchronizeModelElement root = getModelRoot(); - if(root instanceof SynchronizeModelElement) - ((SynchronizeModelElement)root).fireChanges(); - } - }); - } - } - }); - } - } - } - } - - /** - * For each node create children based on the contents of - * @param node - * @return - */ - protected abstract IDiffElement[] buildModelObjects(ISynchronizeModelElement node); - - protected abstract void doAdd(ISynchronizeModelElement parent, ISynchronizeModelElement element); - - protected abstract void doRemove(ISynchronizeModelElement element); - - protected void associateDiffNode(ISynchronizeModelElement node) { - IResource resource = node.getResource(); - if(resource != null) { - resourceMap.put(resource, node); - } - } - - protected void unassociateDiffNode(IResource resource) { - resourceMap.remove(resource); - } - - /** - * Handle the changes made to the viewer's <code>SyncInfoSet</code>. - * This method delegates the changes to the three methods <code>handleResourceChanges(ISyncInfoSetChangeEvent)</code>, - * <code>handleResourceRemovals(ISyncInfoSetChangeEvent)</code> and - * <code>handleResourceAdditions(ISyncInfoSetChangeEvent)</code>. - * @param event - * the event containing the changed resourcses. - */ - protected void handleChanges(ISyncInfoTreeChangeEvent event) { - StructuredViewer viewer = getViewer(); - try { - viewer.getControl().setRedraw(false); - handleResourceChanges(event); - handleResourceRemovals(event); - handleResourceAdditions(event); - firePendingLabelUpdates(); - } finally { - viewer.getControl().setRedraw(true); - } - } - - /** - * Update the viewer for the sync set additions in the provided event. This - * method is invoked by <code>handleChanges(ISyncInfoSetChangeEvent)</code>. - * Subclasses may override. - * @param event - */ - protected abstract void handleResourceAdditions(ISyncInfoTreeChangeEvent event); - - /** - * Update the viewer for the sync set changes in the provided event. This - * method is invoked by <code>handleChanges(ISyncInfoSetChangeEvent)</code>. - * Subclasses may override. - * @param event - */ - protected abstract void handleResourceChanges(ISyncInfoTreeChangeEvent event); - - protected boolean isConflicting(ISynchronizeModelElement diffNode) { - return (diffNode.getKind() & SyncInfo.DIRECTION_MASK) == SyncInfo.CONFLICTING; - } - - /** - * Update the viewer for the sync set removals in the provided event. This - * method is invoked by <code>handleChanges(ISyncInfoSetChangeEvent)</code>. - * Subclasses may override. - * @param event - */ - protected abstract void handleResourceRemovals(ISyncInfoTreeChangeEvent event); - - protected void reset() { - try { - setAllowRefreshViewer(false); - // save expansion state - if(! resourceMap.isEmpty()) { - saveViewerState(); - } - - // Clear existing model, but keep the root node - resourceMap.clear(); - clearModelObjects(getModelRoot()); - // remove all from tree viewer - IDiffElement[] elements = getModelRoot().getChildren(); - for (int i = 0; i < elements.length; i++) { - doRemove((ISynchronizeModelElement)elements[i]); - } - - // Rebuild the model - associateDiffNode(getModelRoot()); - buildModelObjects(getModelRoot()); - - // Notify listeners that model has changed - ISynchronizeModelElement root = getModelRoot(); - if(root instanceof SynchronizeModelElement) { - ((SynchronizeModelElement)root).fireChanges(); - } - } finally { - setAllowRefreshViewer(true); - } - TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - StructuredViewer viewer = getViewer(); - if (viewer != null && !viewer.getControl().isDisposed()) { - viewer.refresh(); - // restore expansion state - restoreViewerState(); - } - } - }); - } - - /** - * Remove any traces of the resource and any of it's descendants in the - * hiearchy defined by the content provider from the content provider and - * the viewer it is associated with. - * @param resource - */ - protected void removeFromViewer(IResource resource) { - ISynchronizeModelElement node = getModelObject(resource); - if (node == null) return; - calculateProperties(node, true); - clearModelObjects(node); - if (canUpdateViewer()) { - doRemove(node); - } - } - - /** - * Clear the model objects from the diff tree, cleaning up any cached state - * (such as resource to model object map). This method recurses deeply on - * the tree to allow the cleanup of any cached state for the children as - * well. - * @param node - * the root node - */ - protected void clearModelObjects(ISynchronizeModelElement node) { - IDiffElement[] children = node.getChildren(); - for (int i = 0; i < children.length; i++) { - IDiffElement element = children[i]; - if (element instanceof ISynchronizeModelElement) { - clearModelObjects((ISynchronizeModelElement) element); - } - } - IResource resource = node.getResource(); - if (resource != null) { - unassociateDiffNode(resource); - } - IDiffContainer parent = node.getParent(); - if (parent != null) { - parent.removeToRoot(node); - } - } - - protected void addToViewer(ISynchronizeModelElement node) { - associateDiffNode(node); - node.addPropertyChangeListener(listener); - calculateProperties(node, false); - if (canUpdateViewer()) { - doAdd((SynchronizeModelElement)node.getParent(), node); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener#syncInfoSetReset(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) - */ - public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) { - reset(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener#syncInfoSetErrors(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.team.core.ITeamStatus[], org.eclipse.core.runtime.IProgressMonitor) - */ - public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) { - // When errors occur we currently don't process them. It may be possible to decorate - // elements in the model with errors, but currently we prefer to let ignore and except - // another listener to display them. - } - - protected void saveViewerState() { - // save visible expanded elements and selection - if (viewer != null && !viewer.getControl().isDisposed() && viewer instanceof AbstractTreeViewer) { - final Object[][] expandedElements = new Object[1][1]; - final Object[][] selectedElements = new Object[1][1]; - viewer.getControl().getDisplay().syncExec(new Runnable() { - public void run() { - if (viewer != null && !viewer.getControl().isDisposed()) { - expandedElements[0] = ((AbstractTreeViewer) viewer).getVisibleExpandedElements(); - selectedElements[0] = ((IStructuredSelection) viewer.getSelection()).toArray(); - } - } - }); - // - // Save expansion - // - if (expandedElements[0].length > 0) { - ISynchronizePageConfiguration config = getConfiguration(); - ArrayList savedExpansionState = new ArrayList(); - for (int i = 0; i < expandedElements[0].length; i++) { - if (expandedElements[0][i] instanceof ISynchronizeModelElement) { - IResource resource = ((ISynchronizeModelElement) expandedElements[0][i]).getResource(); - if(resource != null) - savedExpansionState.add(resource.getFullPath().toString()); - } - } - config.setProperty(P_VIEWER_EXPANSION_STATE, savedExpansionState); - } - // - // Save selection - // - if (selectedElements[0].length > 0) { - ISynchronizePageConfiguration config = getConfiguration(); - ArrayList savedSelectedState = new ArrayList(); - for (int i = 0; i < selectedElements[0].length; i++) { - if (selectedElements[0][i] instanceof ISynchronizeModelElement) { - IResource resource = ((ISynchronizeModelElement) selectedElements[0][i]).getResource(); - if(resource != null) - savedSelectedState.add(resource.getFullPath().toString()); - } - } - config.setProperty(P_VIEWER_SELECTION_STATE, savedSelectedState); - } - } - } - - protected void restoreViewerState() { - // restore expansion state and selection state - if (viewer != null && !viewer.getControl().isDisposed() && viewer instanceof AbstractTreeViewer) { - List savedExpansionState = (List)configuration.getProperty(P_VIEWER_EXPANSION_STATE); - List savedSelectionState = (List)configuration.getProperty(P_VIEWER_SELECTION_STATE); - IContainer container = ResourcesPlugin.getWorkspace().getRoot(); - final ArrayList expandedElements = new ArrayList(); - if (savedExpansionState != null) { - for (Iterator it = savedExpansionState.iterator(); it.hasNext();) { - String path = (String) it.next(); - IResource resource = container.findMember(path, true /* include phantoms */); - ISynchronizeModelElement element = getModelObject(resource); - if (element != null) { - expandedElements.add(element); - } - } - } - final ArrayList selectedElements = new ArrayList(); - if (savedSelectionState != null) { - for (Iterator it = savedSelectionState.iterator(); it.hasNext();) { - String path = (String) it.next(); - IResource resource = container.findMember(path, true /* include phantoms */); - ISynchronizeModelElement element = getModelObject(resource); - if (element != null) { - selectedElements.add(element); - } - } - } - asyncExec(new Runnable() { - public void run() { - ((AbstractTreeViewer) viewer).setExpandedElements(expandedElements.toArray()); - viewer.setSelection(new StructuredSelection(selectedElements)); - } - }); - } - } - - /** - * Update the label of the given diff node. Diff nodes - * are accumulated and updated in a single call. - * @param diffNode the diff node to be updated - */ - protected void updateLabel(ISynchronizeModelElement diffNode) { - pendingLabelUpdates.add(diffNode); - } - - /** - * @param tree - * @return - */ - private boolean canUpdateViewer() { - StructuredViewer viewer = getViewer(); - return getAllowRefreshViewer() && viewer != null && ! viewer.getControl().isDisposed(); - } - - protected void setAllowRefreshViewer(boolean allowRefresh) { - this.refreshViewer = allowRefresh; - } - - protected boolean getAllowRefreshViewer() { - return this.refreshViewer; - } - - /** - * Forces the viewer to update the labels for parents whose children have - * changed during this round of sync set changes. - */ - protected void firePendingLabelUpdates() { - try { - if (canUpdateViewer()) { - StructuredViewer tree = getViewer(); - tree.update(pendingLabelUpdates.toArray(new Object[pendingLabelUpdates.size()]), null); - } - } finally { - pendingLabelUpdates.clear(); - } - } - - protected void calculateProperties(ISynchronizeModelElement element, boolean clear) { - element.setPropertyToRoot(ISynchronizeModelElement.PROPAGATED_CONFLICT_PROPERTY, clear ? false : isConflicting(element)); - propagateProblemMarkers(element, clear); - updateParentLabels(element); - } - - /** - * Calculate and propagate problem markers in the element model - * @param element - * @param clear - */ - private void propagateProblemMarkers(ISynchronizeModelElement element, boolean clear) { - IResource resource = element.getResource(); - if(resource != null && resource.exists()) { - try { - String property = null; - if(! clear) { - IMarker[] markers = resource.findMarkers(IMarker.PROBLEM, true, getLogicalModelDepth()); - for (int i = 0; i < markers.length; i++) { - IMarker marker = markers[i]; - try { - Integer severity = (Integer)marker.getAttribute(IMarker.SEVERITY); - if(severity != null) { - if(severity.intValue() == IMarker.SEVERITY_ERROR) { - property = ISynchronizeModelElement.PROPAGATED_ERROR_MARKER_PROPERTY; - break; - } else if(severity.intValue() == IMarker.SEVERITY_WARNING) { - property = ISynchronizeModelElement.PROPAGATED_WARNING_MARKER_PROPERTY; - // Keep going because there may be errors on other resources - } - } - } catch(CoreException e) { - // the marker has been deleted skip this marker and keep going - if(! (e.getStatus().getCode() == IResourceStatus.MARKER_NOT_FOUND)) { - return; - } - continue; - } - } - } - // If it doesn't have a direct change, a parent might - boolean recalculateParentDecorations = hadProblemProperty(element, property); - if(recalculateParentDecorations) { - ISynchronizeModelElement parent = (ISynchronizeModelElement)element.getParent(); - if(parent != null) { - propagateProblemMarkers(parent, false); - } - } - } catch (CoreException e) { - // ignore problems on this item and keep going - return; - } - } - } - - // none -> error - // error -> none - // none -> warning - // warning -> none - // warning -> error - // error -> warning - private boolean hadProblemProperty(ISynchronizeModelElement element, String property) { - boolean hadError = element.getProperty(ISynchronizeModelElement.PROPAGATED_ERROR_MARKER_PROPERTY); - boolean hadWarning = element.getProperty(ISynchronizeModelElement.PROPAGATED_WARNING_MARKER_PROPERTY); - - if(hadError) { - if(! (property == ISynchronizeModelElement.PROPAGATED_ERROR_MARKER_PROPERTY)) { - element.setPropertyToRoot(ISynchronizeModelElement.PROPAGATED_ERROR_MARKER_PROPERTY, false); - if(property != null) { - // error -> warning - element.setPropertyToRoot(property, true); - } - // error -> none - // recalculate parents - return true; - } - return false; - } else if(hadWarning) { - if(! (property == ISynchronizeModelElement.PROPAGATED_WARNING_MARKER_PROPERTY)) { - element.setPropertyToRoot(ISynchronizeModelElement.PROPAGATED_WARNING_MARKER_PROPERTY, false); - if(property != null) { - // warning -> error - element.setPropertyToRoot(property, true); - return false; - } - // warning -> none - return true; - } - return false; - } else { - if(property == ISynchronizeModelElement.PROPAGATED_ERROR_MARKER_PROPERTY) { - // none -> error - element.setPropertyToRoot(property, true); - return false; - } else if(property == ISynchronizeModelElement.PROPAGATED_WARNING_MARKER_PROPERTY) { - // none -> warning - element.setPropertyToRoot(property, true); - return true; - } - return false; - } - } - - private void updateParentLabels(ISynchronizeModelElement diffNode) { - updateLabel(diffNode); - while (diffNode.getParent() != null) { - diffNode = (ISynchronizeModelElement)diffNode.getParent(); - updateLabel(diffNode); - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) - */ - public void resourceChanged(final IResourceChangeEvent event) { - String[] markerTypes = getMarkerTypes(); - boolean refreshNeeded = false; - Map changes = new HashMap(); - - // Accumulate all distinct resources that have had problem marker - // changes - for (int idx = 0; idx < markerTypes.length; idx++) { - IMarkerDelta[] markerDeltas = event.findMarkerDeltas(markerTypes[idx], true); - for (int i = 0; i < markerDeltas.length; i++) { - IMarkerDelta delta = markerDeltas[i]; - int kind = delta.getKind(); - IResource resource = delta.getResource(); - if(! changes.containsKey(resource)) { - ISynchronizeModelElement element = getClosestExistingParent(delta.getResource()); - if(element != null) { - changes.put(resource, element); - } - } - } - } - - if (!changes.isEmpty()) { - processMarkerChanges(changes); - } - } - - /** - * Calculate the properties for affected resources in our model and fire - * label changes for changed elements. - * - * @param changes the model elements that have changed. - */ - private void processMarkerChanges(final Map changes) { - Job job = new Job("Synchronize View: Processing marker changes") { - protected IStatus run(IProgressMonitor monitor) { - long start = System.currentTimeMillis(); - synchronized (this) { - // Changes contains all resources with marker changes - for (Iterator it = changes.values().iterator(); it.hasNext();) { - ISynchronizeModelElement element = (ISynchronizeModelElement) it.next(); - calculateProperties(element, false); - } - } - if (DEBUG) { - long time = System.currentTimeMillis() - start; - DateFormat TIME_FORMAT = new SimpleDateFormat("m:ss.SSS"); //$NON-NLS-1$ - String took = TIME_FORMAT.format(new Date(time)); - System.out.println(took + " for " + changes.size() + " files"); //$NON-NLS-1$//$NON-NLS-2$ - } - // Fire label changed - asyncExec(new Runnable() { - public void run() { - firePendingLabelUpdates(); - } - }); - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.schedule(); - } - - protected ISynchronizeModelElement getClosestExistingParent(IResource resource) { - ISynchronizeModelElement element = getModelObject(resource); - if(element == null) { - do { - resource = resource.getParent(); - element = getModelObject(resource); - } while(element == null && resource != null); - } - return element; - } - - protected int getLogicalModelDepth() { - return IResource.DEPTH_INFINITE; - } - - protected String[] getMarkerTypes() { - return new String[] {IMarker.PROBLEM}; - } - - private void asyncExec(final Runnable r) { - if (canUpdateViewer()) { - final Control ctrl = getViewer().getControl(); - if (ctrl != null && !ctrl.isDisposed()) { - ctrl.getDisplay().asyncExec(new Runnable() { - public void run() { - if (!ctrl.isDisposed()) { - BusyIndicator.showWhile(ctrl.getDisplay(), r); - } - } - }); - } - } - } -}
\ No newline at end of file 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 deleted file mode 100644 index 9fe90fdce..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java +++ /dev/null @@ -1,548 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.synchronize; - -import java.util.HashMap; -import java.util.Map; - -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.viewers.ILabelDecorator; -import org.eclipse.team.core.synchronize.SyncInfoSet; -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.ui.IActionBars; -import org.eclipse.ui.actions.ActionContext; - -/** - * Concrete implementation of the ISynchronizePageConfiguration. It - * extends SynchronizePageActionGroup in order to delegate action group - * operations. - * - * @since 3.0 - */ -public class SynchronizePageConfiguration extends SynchronizePageActionGroup implements ISynchronizePageConfiguration { - - /** - * Property constant for the page's viewer input which is - * an instance of <code>ISynchronizeModelElement</code>. - * This property can be queried by clients but should not be - * set. - */ - public static final String P_MODEL = TeamUIPlugin.ID + ".P_MODEL"; //$NON-NLS-1$ - - /** - * Property constant for the page's viewer advisor which is - * an instance of <code>StructuredViewerAdvisor</code>. - * The page's viewer can be obtained from the advisor. - * This property can be queried by clients but should not be - * set. - */ - public static final String P_ADVISOR = TeamUIPlugin.ID + ".P_ADVISOR"; //$NON-NLS-1$ - - /** - * Property constant for the page's navigator - * an instance of <code>INavigable</code>. - * This property can be queried by clients and can be set. By default - * the advisors navigator will be used. - */ - public static final String P_NAVIGATOR = TeamUIPlugin.ID + ".P_NAVIGATOR"; //$NON-NLS-1$ - - /** - * Property constant for the page's model manager which is - * an instance of <code>SynchronizeModelManager</code>. - * This property can be queried by clients but should not be - * set. - */ - public static final String P_MODEL_MANAGER = TeamUIPlugin.ID + ".P_MODEL_MANAGER"; //$NON-NLS-1$ - - /** - * Property that gives access to a set the - * contains all out-of-sync resources for the particpant - * in the selected working set. - */ - public static final String P_WORKING_SET_SYNC_INFO_SET = TeamUIPlugin.ID + ".P_WORKING_SET_SYNC_INFO_SET"; //$NON-NLS-1$ - - /** - * Property that gives access to a set the - * contains all out-of-sync resources for the particpant - * before any filtering (working set or modes) is applied. - */ - public static final String P_PARTICIPANT_SYNC_INFO_SET = TeamUIPlugin.ID + ".P_PARTICIPANT_SYNC_INFO_SET"; //$NON-NLS-1$ - - /** - * The hidden configuration property that opens the current selection in the - * page. The registered <code>IAction</code> is invoked on a single or - * double click depending on the open strategy chosen by the user. - */ - public static final String P_OPEN_ACTION = TeamUIPlugin.ID + ".P_OPEN_ACTION"; //$NON-NLS-1$ - - /** - * Property constant for the style of the view to be used by the page. - */ - public static final String P_VIEWER_STYLE = TeamUIPlugin.ID + ".P_VIEWER_STYLE"; //$NON-NLS-1$ - - public static final int CHECKBOX = TreeViewerAdvisor.CHECKBOX; - - private ISynchronizeParticipant participant; - private ISynchronizePageSite site; - private ListenerList propertyChangeListeners = new ListenerList(); - private ListenerList actionContributions = new ListenerList(); - private Map properties = new HashMap(); - private boolean actionsInitialized = false; - private ISynchronizePage page; - private IRunnableContext context; - - /** - * Create a configuration for creating a page from the given particpant. - * @param participant the particpant whose page is being configured - */ - public SynchronizePageConfiguration(ISynchronizeParticipant participant) { - this.participant = participant; - setProperty(P_CONTEXT_MENU, DEFAULT_CONTEXT_MENU); - setProperty(P_TOOLBAR_MENU, DEFAULT_TOOLBAR_MENU); - setProperty(P_VIEW_MENU, DEFAULT_VIEW_MENU); - setProperty(P_COMPARISON_TYPE, THREE_WAY); - addActionContribution(new DefaultSynchronizePageActions()); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getParticipant() - */ - public ISynchronizeParticipant getParticipant() { - return participant; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getSite() - */ - public ISynchronizePageSite getSite() { - return site; - } - - /** - * Set the site that is associated with the page that was - * configured using this configuration. - * @param site a synchronize page site - */ - public void setSite(ISynchronizePageSite site) { - this.site = site; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - synchronized(propertyChangeListeners) { - propertyChangeListeners.add(listener); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - synchronized(propertyChangeListeners) { - propertyChangeListeners.remove(listener); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#setProperty(java.lang.String, java.lang.Object) - */ - public void setProperty(String key, Object newValue) { - Object oldValue = properties.get(key); - if (page == null || page.aboutToChangeProperty(this, key, newValue)) { - properties.put(key, newValue); - if (oldValue == null || !oldValue.equals(newValue)) - firePropertyChange(key, oldValue, newValue); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getProperty(java.lang.String) - */ - public Object getProperty(String key) { - return properties.get(key); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#addActionContribution(org.eclipse.team.ui.synchronize.IActionContribution) - */ - public void addActionContribution(SynchronizePageActionGroup contribution) { - synchronized(actionContributions) { - actionContributions.add(contribution); - } - if (actionsInitialized) { - contribution.initialize(this); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#removeActionContribution(org.eclipse.team.ui.synchronize.IActionContribution) - */ - public void removeActionContribution(SynchronizePageActionGroup contribution) { - synchronized(actionContributions) { - actionContributions.remove(contribution); - } - } - - private void firePropertyChange(String key, Object oldValue, Object newValue) { - Object[] listeners; - synchronized(propertyChangeListeners) { - listeners = propertyChangeListeners.getListeners(); - } - final PropertyChangeEvent event = new PropertyChangeEvent(this, key, oldValue, newValue); - for (int i = 0; i < listeners.length; i++) { - final IPropertyChangeListener listener = (IPropertyChangeListener)listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Error is logged by platform - } - public void run() throws Exception { - listener.propertyChange(event); - } - }); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.IActionContribution#initialize(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) - */ - public void initialize(final ISynchronizePageConfiguration configuration) { - super.initialize(configuration); - final Object[] listeners = actionContributions.getListeners(); - for (int i= 0; i < listeners.length; i++) { - final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Logged by Platform - } - public void run() throws Exception { - contribution.initialize(configuration); - } - }); - } - actionsInitialized = true; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.ActionContext) - */ - public void setContext(final ActionContext context) { - super.setContext(context); - final Object[] listeners = actionContributions.getListeners(); - for (int i= 0; i < listeners.length; i++) { - final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Logged by Platform - } - public void run() throws Exception { - contribution.setContext(context); - } - }); - } - } - - /** - * Callback invoked from the advisor each time the context menu is - * about to be shown. - * @param manager the context menu manager - */ - public void fillContextMenu(final IMenuManager manager) { - final Object[] listeners = actionContributions.getListeners(); - for (int i= 0; i < listeners.length; i++) { - final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Logged by Platform - } - public void run() throws Exception { - contribution.fillContextMenu(manager); - } - }); - } - } - - /** - * Callback invoked from the page to fil the action bars. - * @param actionBars the action bars of the view - */ - public void fillActionBars(final IActionBars actionBars) { - if (!actionsInitialized) { - initialize(this); - } - final Object[] listeners = actionContributions.getListeners(); - for (int i= 0; i < listeners.length; i++) { - final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Logged by Platform - } - public void run() throws Exception { - contribution.fillActionBars(actionBars); - } - }); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.ActionGroup#updateActionBars() - */ - public void updateActionBars() { - final Object[] listeners = actionContributions.getListeners(); - for (int i= 0; i < listeners.length; i++) { - final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Logged by Platform - } - public void run() throws Exception { - contribution.updateActionBars(); - } - }); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SynchronizePageActionGroup#modelChanged(org.eclipse.team.ui.synchronize.ISynchronizeModelElement) - */ - public void modelChanged(final ISynchronizeModelElement root) { - final Object[] listeners = actionContributions.getListeners(); - for (int i= 0; i < listeners.length; i++) { - final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Logged by Platform - } - public void run() throws Exception { - contribution.modelChanged(root); - } - }); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.IActionContribution#dispose() - */ - public void dispose() { - super.dispose(); - final Object[] listeners = actionContributions.getListeners(); - for (int i= 0; i < listeners.length; i++) { - final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i]; - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Logged by Platform - } - public void run() throws Exception { - contribution.dispose(); - } - }); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#setMenu(java.lang.String, java.lang.String[]) - */ - public void setMenuGroups(String menuPropertyId, String[] groups) { - setProperty(menuPropertyId, groups); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#appendMenu(java.lang.String, java.lang.String) - */ - public void addMenuGroup(String menuPropertyId, String groupId) { - String[] menuGroups = (String[])getProperty(menuPropertyId); - if (menuGroups == null) { - menuGroups = getDefault(menuPropertyId); - } - String[] newGroups = new String[menuGroups.length + 1]; - System.arraycopy(menuGroups, 0, newGroups, 0, menuGroups.length); - newGroups[menuGroups.length] = groupId; - setProperty(menuPropertyId, newGroups); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#hasMenuGroup(java.lang.String, java.lang.String) - */ - public boolean hasMenuGroup(String menuPropertyId, String groupId) { - String[] groups = (String[])getProperty(menuPropertyId); - if (groups == null) { - groups = getDefault(menuPropertyId); - } - for (int i = 0; i < groups.length; i++) { - String string = groups[i]; - if (string.equals(groupId)) return true; - } - return false; - } - - protected String[] getDefault(String menuPropertyId) { - if (menuPropertyId.equals(P_CONTEXT_MENU)) { - return DEFAULT_CONTEXT_MENU; - } else if (menuPropertyId.equals(P_VIEW_MENU)) { - return DEFAULT_VIEW_MENU; - } else if (menuPropertyId.equals(P_TOOLBAR_MENU)) { - return DEFAULT_TOOLBAR_MENU; - } else { - return new String[0]; - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#addLabelDecorator(org.eclipse.jface.viewers.ILabelDecorator) - */ - public void addLabelDecorator(ILabelDecorator decorator) { - ILabelDecorator[] decorators = (ILabelDecorator[])getProperty(P_LABEL_DECORATORS); - if (decorators == null) { - decorators = new ILabelDecorator[0]; - } - // Ensure we don't have it registered already - for (int i = 0; i < decorators.length; i++) { - ILabelDecorator d = decorators[i]; - if (d == decorator) { - return; - } - } - ILabelDecorator[] newDecorators = new ILabelDecorator[decorators.length + 1]; - System.arraycopy(decorators, 0, newDecorators, 0, decorators.length); - newDecorators[decorators.length] = decorator; - setProperty(P_LABEL_DECORATORS, newDecorators); - } - - /** - * @param group - * @return - */ - public String getGroupId(String group) { - String id = getParticipant().getId(); - if (getParticipant().getSecondaryId() != null) { - id += "."; //$NON-NLS-1$ - id += getParticipant().getSecondaryId(); - } - return id + "." + group; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscribers.ISubscriberPageConfiguration#getMode() - */ - public int getMode() { - Object o = getProperty(P_MODE); - if (o instanceof Integer) { - return ((Integer)o).intValue(); - } - return 0; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscribers.ISubscriberPageConfiguration#setMode(int) - */ - public void setMode(int mode) { - setProperty(P_MODE, new Integer(mode)); - } - - public int getSupportedModes() { - Object o = getProperty(P_SUPPORTED_MODES); - if (o instanceof Integer) { - return ((Integer)o).intValue(); - } - return 0; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscribers.ISubscriberPageConfiguration#setSupportedModes(int) - */ - public void setSupportedModes(int modes) { - setProperty(P_SUPPORTED_MODES, new Integer(modes)); - } - - /** - * @return Returns the page. - */ - public ISynchronizePage getPage() { - return page; - } - /** - * @param page The page to set. - */ - public void setPage(ISynchronizePage page) { - this.page = page; - } - - /** - * @return - */ - public int getViewerStyle() { - Object o = getProperty(P_VIEWER_STYLE); - if (o instanceof Integer) { - return ((Integer)o).intValue(); - } - return 0; - } - - /** - * @param style - */ - public void setViewerStyle(int style) { - setProperty(P_VIEWER_STYLE, new Integer(style)); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getSyncInfoSet() - */ - public SyncInfoSet getSyncInfoSet() { - Object o = getProperty(P_SYNC_INFO_SET); - if (o instanceof SyncInfoSet) { - return (SyncInfoSet)o; - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getComparisonType() - */ - public String getComparisonType() { - return (String)getProperty(P_COMPARISON_TYPE); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#setComparisonType(java.lang.String) - */ - public void setComparisonType(String type) { - setProperty(P_COMPARISON_TYPE,type); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#setRunnableContext(org.eclipse.jface.operation.IRunnableContext) - */ - public void setRunnableContext(IRunnableContext context) { - this.context = context; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getRunnableContext() - */ - public IRunnableContext getRunnableContext() { - return context; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java deleted file mode 100644 index 76da2ad01..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java +++ /dev/null @@ -1,487 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import java.util.*; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.dialogs.DialogSettings; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.IBasicPropertyConstants; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ui.*; -import org.eclipse.team.internal.ui.synchronize.actions.*; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.*; -import org.eclipse.ui.part.*; -import org.eclipse.ui.progress.IWorkbenchSiteProgressService; - -/** - * Implements a Synchronize View that contains multiple synchronize participants. - */ -public class SynchronizeView extends PageBookView implements ISynchronizeView, ISynchronizeParticipantListener, IPropertyChangeListener { - - /** - * The participant being displayed, or <code>null</code> if none - */ - private ISynchronizeParticipant activeParticipantRef = null; - - /** - * Map of participants to dummy participant parts (used to close pages) - */ - private Map fParticipantToPart; - - /** - * Map of parts to participants - */ - private Map fPartToParticipant; - - /** - * Drop down action to switch between participants - */ - private SynchronizePageDropDownAction fPageDropDown; - - /** - * Action to remove the selected participant - */ - private PinParticipantAction fPinAction; - - /** - * Action to remove the currently shown partipant - */ - private RemoveSynchronizeParticipantAction fRemoveCurrentAction; - - /** - * Action to remove all non-pinned participants - */ - private RemoveSynchronizeParticipantAction fRemoveAllAction; - - /** - * Preference key to save - */ - private static final String KEY_LAST_ACTIVE_PARTICIPANT = "lastactiveparticipant"; //$NON-NLS-1$ - private static final String KEY_SETTINGS_SECTION= "SynchronizeViewSettings"; //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - Object source = event.getSource(); - if (source instanceof ISynchronizeParticipant && event.getProperty().equals(IBasicPropertyConstants.P_TEXT)) { - if (source.equals(getParticipant())) { - updateTitle(); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart) - */ - public void partClosed(IWorkbenchPart part) { - super.partClosed(part); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.ISynchronizeView#getParticipant() - */ - public ISynchronizeParticipant getParticipant() { - return activeParticipantRef; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.PageBookView#showPageRec(org.eclipse.ui.part.PageBookView.PageRec) - */ - protected void showPageRec(PageRec pageRec) { - super.showPageRec(pageRec); - activeParticipantRef = (ISynchronizeParticipant)fPartToParticipant.get(pageRec.part); - updateActionEnablements(); - updateTitle(); - } - - /* - * Updates the view title based on the active participant - */ - protected void updateTitle() { - ISynchronizeParticipant participant = getParticipant(); - if (participant == null) { - setTitle(getViewName()); //$NON-NLS-1$ - } else { - SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)fParticipantToPart.get(participant); - setTitle(Policy.bind("SynchronizeView.2", getViewName(), part.getParticipant().getName())); //$NON-NLS-1$ - } - } - - protected String getViewName() { - return Policy.bind("SynchronizeView.1"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.PageBookView#doDestroyPage(org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.part.PageBookView.PageRec) - */ - protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) { - IPage page = pageRecord.page; - page.dispose(); - pageRecord.dispose(); - SynchronizeViewWorkbenchPart syncPart = (SynchronizeViewWorkbenchPart) part; - ISynchronizeParticipant participant = syncPart.getParticipant(); - participant.removePropertyChangeListener(this); - - // empty cross-reference cache - fPartToParticipant.remove(part); - fParticipantToPart.remove(participant); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.PageBookView#doCreatePage(org.eclipse.ui.IWorkbenchPart) - */ - protected PageRec doCreatePage(IWorkbenchPart dummyPart) { - SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)dummyPart; - ISynchronizeParticipant participant = part.getParticipant(); - participant.addPropertyChangeListener(this); - ISynchronizePageConfiguration configuration = participant.createPageConfiguration(); - IPageBookViewPage page = participant.createPage(configuration); - if(page != null) { - initPage(page); - initPage(configuration, page); - page.createControl(getPageBook()); - PageRec rec = new PageRec(dummyPart, page); - return rec; - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.PageBookView#initPage(org.eclipse.ui.part.IPageBookViewPage) - */ - protected void initPage(ISynchronizePageConfiguration configuration, IPageBookViewPage page) { - // A page site does not provide everything the page may need - // Also provide the synchronize page site if the page is a synchronize view page - ((SynchronizePageConfiguration)configuration).setSite(new WorkbenchPartSynchronizePageSite(this, page.getSite(), getDialogSettings(configuration.getParticipant()))); - if (page instanceof ISynchronizePage) { - try { - ((ISynchronizePage)page).init(configuration.getSite()); - } catch (PartInitException e) { - TeamUIPlugin.log(IStatus.ERROR, e.getMessage(), e); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.PageBookView#isImportant(org.eclipse.ui.IWorkbenchPart) - */ - protected boolean isImportant(IWorkbenchPart part) { - return part instanceof SynchronizeViewWorkbenchPart; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#dispose() - */ - public void dispose() { - super.dispose(); - TeamUI.getSynchronizeManager().removeSynchronizeParticipantListener(this); - if(activeParticipantRef != null) { - IDialogSettings section = getDialogSettings(); - section.put(KEY_LAST_ACTIVE_PARTICIPANT, activeParticipantRef.getId()); - } - fParticipantToPart = null; - fPartToParticipant = null; - - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.PageBookView#createDefaultPage(org.eclipse.ui.part.PageBook) - */ - protected IPage createDefaultPage(PageBook book) { - Page page = new MessagePage(); - page.createControl(getPageBook()); - initPage(page); - return page; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.ISynchronizeParticipantListener#participantsAdded(org.eclipse.team.ui.sync.ISynchronizeParticipant[]) - */ - public void participantsAdded(final ISynchronizeParticipant[] participants) { - for (int i = 0; i < participants.length; i++) { - ISynchronizeParticipant participant = participants[i]; - if (isAvailable() && select(TeamUI.getSynchronizeManager().get(participant.getId(), participant.getSecondaryId()))) { - SynchronizeViewWorkbenchPart part = new SynchronizeViewWorkbenchPart(participant, getSite()); - fParticipantToPart.put(participant, part); - fPartToParticipant.put(part, participant); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.ISynchronizeParticipantListener#participantsRemoved(org.eclipse.team.ui.sync.ISynchronizeParticipant[]) - */ - public void participantsRemoved(final ISynchronizeParticipant[] participants) { - if (isAvailable()) { - Runnable r = new Runnable() { - public void run() { - for (int i = 0; i < participants.length; i++) { - ISynchronizeParticipant participant = participants[i]; - if (isAvailable()) { - SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)fParticipantToPart.get(participant); - if (part != null) { - partClosed(part); - } - // Remove any settings created for the participant - removeDialogSettings(participant); - if (getParticipant() == null) { - ISynchronizeParticipantReference[] available = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); - if (available.length > 0) { - ISynchronizeParticipant p; - try { - p = available[available.length - 1].getParticipant(); - } catch (TeamException e) { - return; - } - display(p); - } - } - } - } - } - }; - asyncExec(r); - } - } - - /** - * Constructs a synchronize view - */ - public SynchronizeView() { - super(); - fParticipantToPart = new HashMap(); - fPartToParticipant = new HashMap(); - updateTitle(); - } - - /** - * Create the default actions for the view. These will be shown regardless of the - * participant being displayed. - */ - protected void createActions() { - fPageDropDown = new SynchronizePageDropDownAction(this); - fPinAction = new PinParticipantAction(); - fRemoveCurrentAction = new RemoveSynchronizeParticipantAction(this, false); - fRemoveAllAction = new RemoveSynchronizeParticipantAction(this, true); - updateActionEnablements(); - } - - private void updateActionEnablements() { - if (fPinAction != null) { - fPinAction.setParticipant(activeParticipantRef); - } - if (fRemoveAllAction != null) { - fRemoveAllAction.setEnabled(getParticipant() != null); - } - if (fRemoveCurrentAction != null) { - fRemoveCurrentAction.setEnabled(getParticipant() != null); - } - } - - /** - * Add the actions to the toolbar - * - * @param mgr toolbar manager - */ - protected void configureToolBar(IActionBars bars) { - IToolBarManager mgr = bars.getToolBarManager(); - mgr.add(fPageDropDown); - mgr.add(fPinAction); - IMenuManager menu = bars.getMenuManager(); - menu.add(fRemoveCurrentAction); - menu.add(fRemoveAllAction); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeView#display(org.eclipse.team.ui.synchronize.ISynchronizeParticipant) - */ - public void display(ISynchronizeParticipant participant) { - SynchronizeViewWorkbenchPart part = (SynchronizeViewWorkbenchPart)fParticipantToPart.get(participant); - if (part != null) { - partActivated(part); - fPageDropDown.update(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.PageBookView#getBootstrapPart() - */ - protected IWorkbenchPart getBootstrapPart() { - return null; - } - - /** - * Registers the given runnable with the display - * associated with this view's control, if any. - */ - public void asyncExec(Runnable r) { - if (isAvailable()) { - getPageBook().getDisplay().asyncExec(r); - } - } - - /** - * Creates this view's underlying viewer and actions. - * Hooks a pop-up menu to the underlying viewer's control, - * as well as a key listener. When the delete key is pressed, - * the <code>REMOVE_ACTION</code> is invoked. Hooks help to - * this view. Subclasses must implement the following methods - * which are called in the following order when a view is - * created:<ul> - * <li><code>createViewer(Composite)</code> - the context - * menu is hooked to the viewer's control.</li> - * <li><code>createActions()</code></li> - * <li><code>configureToolBar(IToolBarManager)</code></li> - * <li><code>getHelpContextId()</code></li> - * </ul> - * @see IWorkbenchPart#createPartControl(Composite) - */ - public void createPartControl(Composite parent) { - super.createPartControl(parent); - createActions(); - configureToolBar(getViewSite().getActionBars()); - updateForExistingParticipants(); - getViewSite().getActionBars().updateActionBars(); - updateTitle(); - - IWorkbenchSiteProgressService progress = (IWorkbenchSiteProgressService)getSite().getAdapter(IWorkbenchSiteProgressService.class); - if(progress != null) { - progress.showBusyForFamily(ISynchronizeManager.FAMILY_SYNCHRONIZE_OPERATION); - } - } - - /** - * Initialize for existing participants - */ - private void updateForExistingParticipants() { - ISynchronizeManager manager = TeamUI.getSynchronizeManager(); - List participants = Arrays.asList(getParticipants()); - boolean errorOccurred = false; - for (int i = 0; i < participants.size(); i++) { - try { - ISynchronizeParticipantReference ref = (ISynchronizeParticipantReference)participants.get(i); - participantsAdded(new ISynchronizeParticipant[] {ref.getParticipant()}); - } catch (TeamException e) { - errorOccurred = true; - continue; - } - - } - if (errorOccurred) { - participants = Arrays.asList(getParticipants()); - } - try { - // decide which participant to show on startup - if (participants.size() > 0) { - ISynchronizeParticipantReference participantToSelect = (ISynchronizeParticipantReference)participants.get(0); - IDialogSettings section = getDialogSettings(); - String selectedParticipantId = section.get(KEY_LAST_ACTIVE_PARTICIPANT); - if(selectedParticipantId != null) { - ISynchronizeParticipantReference selectedParticipant = manager.get(selectedParticipantId, null); - if(selectedParticipant != null) { - participantToSelect = selectedParticipant; - } - } - display(participantToSelect.getParticipant()); - } - - // add as a listener to update when new participants are added - manager.addSynchronizeParticipantListener(this); - } catch (TeamException e) { - Utils.handle(e); - } - } - - private ISynchronizeParticipantReference[] getParticipants() { - ISynchronizeManager manager = TeamUI.getSynchronizeManager(); - // create pages - List participants = new ArrayList(); - ISynchronizeParticipantReference[] refs = manager.getSynchronizeParticipants(); - for (int i = 0; i < refs.length; i++) { - ISynchronizeParticipantReference ref =refs[i]; - if(select(ref)) { - participants.add(ref); - } - } - return (ISynchronizeParticipantReference[]) participants.toArray(new ISynchronizeParticipantReference[participants.size()]); - } - - private boolean isAvailable() { - return getPageBook() != null && !getPageBook().isDisposed(); - } - - /* - * Method used by test cases to access the page for a participant - */ - public IPage getPage(ISynchronizeParticipant participant) { - IWorkbenchPart part = (IWorkbenchPart)fParticipantToPart.get(participant); - if (part == null) return null; - try { - return getPageRec(part).page; - } catch (NullPointerException e) { - // The PageRec class is not visible so we can't do a null check - // before accessing the page. - return null; - } - } - - protected boolean select(ISynchronizeParticipantReference ref) { - return true; - } - - /* - * Return the dialog settings for the view - */ - private IDialogSettings getDialogSettings() { - IDialogSettings workbenchSettings = TeamUIPlugin.getPlugin().getDialogSettings(); - IDialogSettings syncViewSettings = workbenchSettings.getSection(KEY_SETTINGS_SECTION); //$NON-NLS-1$ - if (syncViewSettings == null) { - syncViewSettings = workbenchSettings.addNewSection(KEY_SETTINGS_SECTION); - } - return syncViewSettings; - } - - private String getSettingsKey(ISynchronizeParticipant participant) { - String id = participant.getId(); - String secondaryId = participant.getSecondaryId(); - return secondaryId == null ? id : id + '.' + secondaryId; - } - - private IDialogSettings getDialogSettings(ISynchronizeParticipant participant) { - String key = getSettingsKey(participant); - IDialogSettings viewsSettings = getDialogSettings(); - IDialogSettings settings = viewsSettings.getSection(key); - if (settings == null) { - settings = viewsSettings.addNewSection(key); - } - return settings; - } - - private void removeDialogSettings(ISynchronizeParticipant participant) { - String key = getSettingsKey(participant); - IDialogSettings settings = getDialogSettings(); - if (settings.getSection(key) != null) { - // There isn't an explicit remove so just make sure - // That the old settings are forgotten - getDialogSettings().addSection(new DialogSettings(key)); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewDefaultPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewDefaultPage.java deleted file mode 100644 index 0ecda0faf..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewDefaultPage.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.WizardDialog; -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.Control; -import org.eclipse.team.internal.ui.wizards.GlobalSynchronizeWizard; -import org.eclipse.ui.forms.HyperlinkGroup; -import org.eclipse.ui.forms.events.HyperlinkAdapter; -import org.eclipse.ui.forms.events.HyperlinkEvent; -import org.eclipse.ui.forms.widgets.FormText; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.part.Page; - -public class SynchronizeViewDefaultPage extends Page { - - private FormToolkit forms; - private FormText text; - private Composite composite; - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - composite = new Composite(parent, SWT.NONE); - composite.setBackground(parent.getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - composite.setLayout(layout); - GridData data = new GridData(GridData.FILL_BOTH); - data.grabExcessVerticalSpace = true; - composite.setLayoutData(data); - - forms = new FormToolkit(parent.getDisplay()); - forms.setBackground(parent.getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); - HyperlinkGroup group = forms.getHyperlinkGroup(); - group.setBackground(parent.getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); - - text = forms.createFormText(composite, true); - String introText = new String("<form><p>" + - "The Synchronize View allows you to view and manipulate differences between sets of resources. To start using this view you first " + - "have to <a href='create'>create a synchronize participant</a> that you will configure to determine the resources to synchronize.</p></form>"); - text.setText(introText, true, false); - text.addHyperlinkListener(new HyperlinkAdapter() { - public void linkActivated(HyperlinkEvent e) { - IWizard wizard = new GlobalSynchronizeWizard(); - WizardDialog dialog = new WizardDialog(composite.getShell(), wizard); - dialog.open(); - } - }); - text.setLayoutData(new GridData(GridData.FILL_BOTH)); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.MessagePage#setFocus() - */ - public void setFocus() { - if(composite != null && ! composite.isDisposed()) - composite.setFocus(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.Page#dispose() - */ - public void dispose() { - forms.dispose(); - super.dispose(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.Page#getControl() - */ - public Control getControl() { - return composite; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewWorkbenchPart.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewWorkbenchPart.java deleted file mode 100644 index adecc65a6..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewWorkbenchPart.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; -import org.eclipse.ui.IPropertyListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchPartSite; - -/** - * Fake part to use as keys in page book for synchronize participants - */ -public class SynchronizeViewWorkbenchPart implements IWorkbenchPart { - - private ISynchronizeParticipant participant; - private IWorkbenchPartSite site; - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) { - return (obj instanceof SynchronizeViewWorkbenchPart) && - participant.equals(((SynchronizeViewWorkbenchPart)participant).getParticipant()); - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return participant.hashCode(); - } - - /** - * Constructs a part for the given participant that binds to the given - * site - */ - public SynchronizeViewWorkbenchPart(ISynchronizeParticipant participant, IWorkbenchPartSite site) { - this.participant = participant; - this.site = site; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#addPropertyListener(org.eclipse.ui.IPropertyListener) - */ - public void addPropertyListener(IPropertyListener listener) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - public void createPartControl(Composite parent) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#dispose() - */ - public void dispose() { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#getSite() - */ - public IWorkbenchPartSite getSite() { - return site; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#getTitle() - */ - public String getTitle() { - return ""; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#getTitleImage() - */ - public Image getTitleImage() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#getTitleToolTip() - */ - public String getTitleToolTip() { - return ""; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#removePropertyListener(org.eclipse.ui.IPropertyListener) - */ - public void removePropertyListener(IPropertyListener listener) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#setFocus() - */ - public void setFocus() { - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - return null; - } - - /** - * Returns the participant associated with this part. - * - * @return participant associated with this part - */ - public ISynchronizeParticipant getParticipant() { - return participant; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TeamSynchronizingPerspective.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TeamSynchronizingPerspective.java deleted file mode 100644 index 3387a7b4c..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TeamSynchronizingPerspective.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.ui.*; - -public class TeamSynchronizingPerspective implements IPerspectiveFactory { - - public final static String ID = "org.eclipse.team.ui.TeamSynchronizingPerspective"; //$NON-NLS-1$ - - /* (Non-javadoc) - * Method declared on IPerpsectiveFactory - */ - public void createInitialLayout(IPageLayout layout) { - defineActions(layout); - defineLayout(layout); - } - - /** - * Defines the initial actions for a page. - */ - public void defineActions(IPageLayout layout) { - - // Add "new wizards". - layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.project"); //$NON-NLS-1$ - layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder"); //$NON-NLS-1$ - layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file"); //$NON-NLS-1$ - - // Add "show views". - layout.addShowViewShortcut(SynchronizeView.VIEW_ID); - layout.addShowViewShortcut(IPageLayout.ID_RES_NAV); - layout.addShowViewShortcut(IPageLayout.ID_OUTLINE); - layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST); - layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW); - - layout.addActionSet("org.eclipse.team.ui.actionSet"); //$NON-NLS-1$ - } - - /** - * Defines the initial layout for a page. - */ - public void defineLayout(IPageLayout layout) { - String editorArea = layout.getEditorArea(); - IFolderLayout top = layout.createFolder("top", IPageLayout.LEFT, 0.25f, editorArea); //$NON-NLS-1$ - top.addView(SynchronizeView.VIEW_ID); - layout.setEditorAreaVisible(true); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java deleted file mode 100644 index 11261403d..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java +++ /dev/null @@ -1,401 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.compare.internal.INavigatable; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.viewers.AbstractTreeViewer; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.OpenEvent; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.actions.ExpandAllAction; -import org.eclipse.team.internal.ui.synchronize.actions.NavigateAction; -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.ui.IActionBars; -import org.eclipse.ui.IViewSite; -import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.ui.internal.dialogs.ContainerCheckedTreeViewer; - -/** - * A <code>TreeViewerAdvisor</code> that works with TreeViewers. Two default - * tree viewers are provided that support navigation: <code>NavigableTreeViewer</code> - * and <code>NavigableCheckboxTreeViewer</code>. - * <p> - * Note that this advisor can be used with any tree viewer. By default it provides an - * expand all action, double click behavior on containers, and navigation support for - * tree viewers. - * </p><p> - * By default this advisor supports hierarchical models and honour the compressed - * folder Team preference for showing the sync set as compressed folders. Subclasses - * can provide their own presentation models. - * <p> - * @since 3.0 - */ -public class TreeViewerAdvisor extends StructuredViewerAdvisor { - - /** - * Style bit that indicates that a checkbox viewer is desired. - */ - public static final int CHECKBOX = 1; - - private ExpandAllAction expandAllAction; - private Action collapseAll; - private NavigateAction gotoNext; - private NavigateAction gotoPrevious; - - class NavigationActionGroup extends SynchronizePageActionGroup { - public void initialize(ISynchronizePageConfiguration configuration) { - super.initialize(configuration); - final StructuredViewer viewer = getViewer(); - if (viewer instanceof AbstractTreeViewer) { - - expandAllAction = new ExpandAllAction((AbstractTreeViewer) viewer); - Utils.initAction(expandAllAction, "action.expandAll."); //$NON-NLS-1$ - - collapseAll = new Action() { - public void run() { - if (viewer == null || viewer.getControl().isDisposed() || !(viewer instanceof AbstractTreeViewer)) return; - viewer.getControl().setRedraw(false); - ((AbstractTreeViewer)viewer).collapseToLevel(viewer.getInput(), TreeViewer.ALL_LEVELS); - viewer.getControl().setRedraw(true); - } - }; - Utils.initAction(collapseAll, "action.collapseAll."); //$NON-NLS-1$ - - ISynchronizeParticipant participant = configuration.getParticipant(); - ISynchronizePageSite site = configuration.getSite(); - - gotoNext = new NavigateAction(site, participant.getName(), configuration, true /*next*/); - gotoPrevious = new NavigateAction(site, participant.getName(), configuration, false /*previous*/); - } - } - public void fillContextMenu(IMenuManager manager) { - appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, expandAllAction); - } - public void fillActionBars(IActionBars actionBars) { - IToolBarManager manager = actionBars.getToolBarManager(); - appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, gotoNext); - appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, gotoPrevious); - appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, collapseAll); - } - } - - /** - * Interface used to implement navigation for tree viewers. This interface is used by - * {@link TreeViewerAdvisor#navigate(TreeViewer, boolean, boolean, boolean) to open - * selections and navigate. - */ - public interface ITreeViewerAccessor { - public void createChildren(TreeItem item); - public void openSelection(); - } - - /** - * A navigable checkboxec tree viewer that will work with the <code>navigate</code> method of - * this advisor. - */ - public static class NavigableCheckboxTreeViewer extends ContainerCheckedTreeViewer implements ITreeViewerAccessor { - public NavigableCheckboxTreeViewer(Composite parent, int style) { - super(parent, style); - } - - public void createChildren(TreeItem item) { - super.createChildren(item); - } - - public void openSelection() { - fireOpen(new OpenEvent(this, getSelection())); - } - } - - /** - * A navigable tree viewer that will work with the <code>navigate</code> method of - * this advisor. - */ - public static class NavigableTreeViewer extends TreeViewer implements ITreeViewerAccessor { - public NavigableTreeViewer(Composite parent, int style) { - super(parent, style); - } - - public void createChildren(TreeItem item) { - super.createChildren(item); - } - - public void openSelection() { - fireOpen(new OpenEvent(this, getSelection())); - } - } - - public static StructuredViewer createViewer(Composite parent, ISynchronizePageConfiguration configuration) { - int style = ((SynchronizePageConfiguration)configuration).getViewerStyle(); - if ((style & CHECKBOX) > 0) { - NavigableCheckboxTreeViewer v = new TreeViewerAdvisor.NavigableCheckboxTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - configuration.getSite().setSelectionProvider(v); - return v; - } else { - NavigableTreeViewer v = new TreeViewerAdvisor.NavigableTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - configuration.getSite().setSelectionProvider(v); - return v; - } - } - - /** - * Create an advisor that will allow viewer contributions with the given <code>targetID</code>. This - * advisor will provide a presentation model based on the given sync info set. Note that it's important - * to call {@link #dispose()} when finished with an advisor. - * - * @param targetID the targetID defined in the viewer contributions in a plugin.xml file. - * @param site the workbench site with which to register the menuId. Can be <code>null</code> in which - * case a site will be found using the default workbench page. - * @param set the set of <code>SyncInfo</code> objects that are to be shown to the user. - */ - public TreeViewerAdvisor(Composite parent, ISynchronizePageConfiguration configuration) { - super(configuration); - INavigatable nav = (INavigatable)configuration.getProperty(SynchronizePageConfiguration.P_NAVIGATOR); - if (nav == null) { - configuration.setProperty(SynchronizePageConfiguration.P_NAVIGATOR, getAdapter(INavigatable.class)); - } - configuration.addActionContribution(new NavigationActionGroup()); - StructuredViewer viewer = TreeViewerAdvisor.createViewer(parent, configuration); - GridData data = new GridData(GridData.FILL_BOTH); - viewer.getControl().setLayoutData(data); - initializeViewer(viewer); - } - - /** - * Create the model manager to be used by this advisor - * @param configuration - */ - protected SynchronizeModelManager createModelManager(ISynchronizePageConfiguration configuration) { - return new HierarchicalModelManager(configuration); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.StructuredViewerAdvisor#navigate(boolean) - */ - public boolean navigate(boolean next) { - return TreeViewerAdvisor.navigate((TreeViewer)getViewer(), next, false, false); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.StructuredViewerAdvisor#initializeViewer(org.eclipse.jface.viewers.StructuredViewer) - */ - public boolean validateViewer(StructuredViewer viewer) { - return viewer instanceof AbstractTreeViewer; - } - - /** - * Handles a double-click event from the viewer. Expands or collapses a folder when double-clicked. - * - * @param viewer the viewer - * @param event the double-click event - */ - protected boolean handleDoubleClick(StructuredViewer viewer, DoubleClickEvent event) { - if (super.handleDoubleClick(viewer, event)) return true; - IStructuredSelection selection = (IStructuredSelection) event.getSelection(); - Object element = selection.getFirstElement(); - AbstractTreeViewer treeViewer = (AbstractTreeViewer) getViewer(); - if(element != null) { - if (treeViewer.getExpandedState(element)) { - treeViewer.collapseToLevel(element, AbstractTreeViewer.ALL_LEVELS); - } else { - TreeViewerAdvisor.navigate((TreeViewer)getViewer(), true /* next */, false /* no-open */, true /* only-expand */); - } - } - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.StructuredViewerAdvisor#initializeListeners(org.eclipse.jface.viewers.StructuredViewer) - */ - protected void initializeListeners(final StructuredViewer viewer) { - super.initializeListeners(viewer); - viewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - updateStatusLine((IStructuredSelection) event.getSelection()); - } - }); - } - - private void updateStatusLine(IStructuredSelection selection) { - IWorkbenchSite ws = getConfiguration().getSite().getWorkbenchSite(); - if (ws != null && ws instanceof IViewSite) { - String msg = getStatusLineMessage(selection); - ((IViewSite)ws).getActionBars().getStatusLineManager().setMessage(msg); - } - } - - private String getStatusLineMessage(IStructuredSelection selection) { - if (selection.size() == 1) { - Object first = selection.getFirstElement(); - if (first instanceof SyncInfoModelElement) { - SyncInfoModelElement node = (SyncInfoModelElement) first; - IResource resource = node.getResource(); - if (resource == null) { - return node.getName(); - } else { - return resource.getFullPath().makeRelative().toString(); - } - } - } - if (selection.size() > 1) { - return selection.size() + Policy.bind("SynchronizeView.13"); //$NON-NLS-1$ - } - return ""; //$NON-NLS-1$ - } - - private static TreeItem findNextPrev(TreeViewer viewer, TreeItem item, boolean next) { - if (item == null || !(viewer instanceof ITreeViewerAccessor)) - return null; - TreeItem children[] = null; - ITreeViewerAccessor treeAccessor = (ITreeViewerAccessor) viewer; - if (!next) { - TreeItem parent = item.getParentItem(); - if (parent != null) - children = parent.getItems(); - else - children = item.getParent().getItems(); - if (children != null && children.length > 0) { - // goto previous child - int index = 0; - for (; index < children.length; index++) - if (children[index] == item) - break; - if (index > 0) { - item = children[index - 1]; - while (true) { - treeAccessor.createChildren(item); - int n = item.getItemCount(); - if (n <= 0) - break; - item.setExpanded(true); - item = item.getItems()[n - 1]; - } - // previous - return item; - } - } - // go up - return parent; - } else { - item.setExpanded(true); - treeAccessor.createChildren(item); - if (item.getItemCount() > 0) { - // has children: go down - children = item.getItems(); - return children[0]; - } - while (item != null) { - children = null; - TreeItem parent = item.getParentItem(); - if (parent != null) - children = parent.getItems(); - else - children = item.getParent().getItems(); - if (children != null && children.length > 0) { - // goto next child - int index = 0; - for (; index < children.length; index++) - if (children[index] == item) - break; - if (index < children.length - 1) { - // next - return children[index + 1]; - } - } - // go up - item = parent; - } - } - return item; - } - - private static void setSelection(TreeViewer viewer, TreeItem ti, boolean fireOpen, boolean expandOnly) { - if (ti != null) { - Object data= ti.getData(); - if (data != null) { - // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - ISelection selection = new StructuredSelection(data); - if (expandOnly) { - viewer.expandToLevel(data, 0); - } else { - viewer.setSelection(selection, true); - ISelection currentSelection = viewer.getSelection(); - if (fireOpen && currentSelection != null && selection.equals(currentSelection)) { - if (viewer instanceof ITreeViewerAccessor) { - ((ITreeViewerAccessor) viewer).openSelection(); - } - } - } - } - } - } - - /** - * Selects the next (or previous) node of the current selection. - * If there is no current selection the first (last) node in the tree is selected. - * Wraps around at end or beginning. - * Clients may not override. - * - * @param next if <code>true</code> the next node is selected, otherwise the previous node - * @return <code>true</code> if at end (or beginning) - */ - public static boolean navigate(TreeViewer viewer, boolean next, boolean fireOpen, boolean expandOnly) { - Tree tree = viewer.getTree(); - if (tree == null) - return false; - TreeItem item = null; - TreeItem children[] = tree.getSelection(); - if (children != null && children.length > 0) - item = children[0]; - if (item == null) { - children = tree.getItems(); - if (children != null && children.length > 0) { - item = children[0]; - if (item != null && item.getItemCount() <= 0) { - setSelection(viewer, item, fireOpen, expandOnly); // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - return false; - } - } - } - while (true) { - item = findNextPrev(viewer, item, next); - if (item == null) - break; - if (item.getItemCount() <= 0) - break; - } - if (item != null) { - setSelection(viewer, item, fireOpen, expandOnly); // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 - return false; - } - return true; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/UnchangedResourceModelElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/UnchangedResourceModelElement.java deleted file mode 100644 index a9f0459aa..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/UnchangedResourceModelElement.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.compare.structuremergeviewer.IDiffContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; - -/** - * DiffNode that represents a resource that is in sync. - */ -public class UnchangedResourceModelElement extends SynchronizeModelElement implements IAdaptable { - - private IResource resource; - - public UnchangedResourceModelElement(IDiffContainer parent, IResource resource) { - super(parent); - this.resource = resource; - } - - /** - * @return Returns the resource. - */ - public IResource getResource() { - return resource; - } - - /* (non-Javadoc) - * @see org.eclipse.compare.structuremergeviewer.DiffNode#getName() - */ - public String getName() { - return resource.getName(); - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchAction.java deleted file mode 100644 index fc1f5f500..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchAction.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize; - -import org.eclipse.jface.action.Action; -import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; - -/** - * Class used as <i>goto</i> actions for synchronize jobs. - * - * @since 3.0 - */ -public class WorkbenchAction extends Action implements IWorkbenchAction { - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.ActionFactory.IWorkbenchAction#dispose() - */ - public void dispose() { - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchPartSynchronizePageSite.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchPartSynchronizePageSite.java deleted file mode 100644 index 6334c0410..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchPartSynchronizePageSite.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.synchronize; - -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.ui.synchronize.ISynchronizePageSite; -import org.eclipse.ui.*; -import org.eclipse.ui.part.IPageSite; - -/** - * Maps a workbench part to a synchronize page site. - */ -public class WorkbenchPartSynchronizePageSite implements ISynchronizePageSite { - private IWorkbenchPart part; - private IDialogSettings settings; - private IPageSite site; - private IActionBars actionBars; - - public WorkbenchPartSynchronizePageSite(IWorkbenchPart part, IPageSite site, IDialogSettings settings) { - this.part = part; - this.site = site; - this.settings = settings; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getPart() - */ - public IWorkbenchPart getPart() { - return part; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getShell() - */ - public Shell getShell() { - return part.getSite().getShell(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getSelectionProvider() - */ - public ISelectionProvider getSelectionProvider() { - return site.getSelectionProvider(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#setSelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) - */ - public void setSelectionProvider(ISelectionProvider provider) { - site.setSelectionProvider(provider); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getWorkbenchSite() - */ - public IWorkbenchSite getWorkbenchSite() { - return part.getSite(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getKeyBindingService() - */ - public IKeyBindingService getKeyBindingService() { - return part.getSite().getKeyBindingService(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#setFocus() - */ - public void setFocus() { - part.getSite().getPage().activate(part); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getPageSettings() - */ - public IDialogSettings getPageSettings() { - return settings; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getActionBars() - */ - public IActionBars getActionBars() { - return site.getActionBars(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#isModal() - */ - public boolean isModal() { - return false; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DefaultSynchronizePageActions.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DefaultSynchronizePageActions.java deleted file mode 100644 index 4d5b3ca0c..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DefaultSynchronizePageActions.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.synchronize.actions; - -import org.eclipse.jface.action.*; -import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.*; - -/** - * General synchronize page actions - */ -public class DefaultSynchronizePageActions extends SynchronizePageActionGroup { - - // Actions - private OpenWithActionGroup openWithActions; - private RefactorActionGroup refactorActions; - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.IActionContribution#initialize(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) - */ - public void initialize(ISynchronizePageConfiguration configuration) { - super.initialize(configuration); - ISynchronizePageSite site = configuration.getSite(); - IWorkbenchSite ws = site.getWorkbenchSite(); - if (ws instanceof IViewSite) { - openWithActions = new OpenWithActionGroup(site, configuration.getParticipant().getName()); - refactorActions = new RefactorActionGroup(site); - configuration.setProperty(SynchronizePageConfiguration.P_OPEN_ACTION, new Action() { - public void run() { - openWithActions.openInCompareEditor(); - } - }); - } else { - // TODO: Add open menu action which opens in compare editor input - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.IActionContribution#fillContextMenu(org.eclipse.jface.action.IMenuManager) - */ - public void fillContextMenu(IMenuManager manager) { - IContributionItem group = findGroup(manager, ISynchronizePageConfiguration.FILE_GROUP); - if (openWithActions != null && group != null) { - openWithActions.fillContextMenu(manager, group.getId()); - } - group = findGroup(manager, ISynchronizePageConfiguration.EDIT_GROUP); - if (refactorActions != null && group != null) { - refactorActions.fillContextMenu(manager, group.getId()); - } - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DirectionFilterActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DirectionFilterActionGroup.java deleted file mode 100644 index 3af7efa9b..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DirectionFilterActionGroup.java +++ /dev/null @@ -1,206 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize.actions; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IContributionManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SubscriberParticipant; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.actions.ActionGroup; - -/** - * This action group provides radio buttons for each possible direction of synchronization information. The - * modes created by this action group can be configured. The actions directly set the mode of a - * {@link SubscriberParticipant}. - * - * @see SubscriberParticipant - * @since 3.0 - */ -public class DirectionFilterActionGroup extends ActionGroup implements IPropertyChangeListener { - - // The list of created actions - private List actions = new ArrayList(3); - - // The modes - private DirectionFilterAction incomingMode; - private DirectionFilterAction outgoingMode; - private DirectionFilterAction bothMode; - private DirectionFilterAction conflictsMode; - - private ISynchronizePageConfiguration configuration; - - /** - * An action filter for a specific mode. - */ - class DirectionFilterAction extends Action { - private int modeId; - - public DirectionFilterAction(String prefix,String commandId, int modeId) { - super("", AS_RADIO_BUTTON); //$NON-NLS-1$ - this.modeId = modeId; - Utils.initAction(this, prefix, Policy.getBundle()); - } - public void run() { - if(isChecked()) { - configuration.setMode(modeId); - } - } - public int getModeId() { - return modeId; - } - } - - /** - * Creates a direction filter group with the given supported modes. The - * possible values for modes are defined by the {@link SubscriberParticipant} - * class. - * - * @see SubscriberParticipant#BOTH_MODE - * @see SubscriberParticipant#OUTGOING_MODE - * @see SubscriberParticipant#INCOMING_MODE - * @see SubscriberParticipant#CONFLICTING_MODE - * @see SubscriberParticipant#ALL_MODES - * - * @param participant the participant showing this group - * @param supportedModes the modes to be shown - */ - public DirectionFilterActionGroup(ISynchronizePageConfiguration configuration) { - this.configuration = configuration; - createActions(); - configuration.addPropertyChangeListener(this); - checkMode(configuration.getMode()); - } - - /** - * Sets up the sync modes and the actions for switching between them. - */ - private void createActions() { - // Create the actions - int supportedModes = configuration.getSupportedModes(); - if (supportedModes == 0) return; - int currentMode = configuration.getMode(); - if ((supportedModes & currentMode) == 0) { - currentMode = getSupportedMode(supportedModes); - if (currentMode == 0) return; - configuration.setMode(currentMode); - } - if((supportedModes & ISynchronizePageConfiguration.INCOMING_MODE) != 0) { - incomingMode = new DirectionFilterAction("action.directionFilterIncoming.", "org.eclipse.team.ui.syncview.incomingFilter", ISynchronizePageConfiguration.INCOMING_MODE); //$NON-NLS-1$ //$NON-NLS-2$ - actions.add(incomingMode); - incomingMode.setChecked(currentMode == ISynchronizePageConfiguration.INCOMING_MODE); - } - - if((supportedModes & ISynchronizePageConfiguration.OUTGOING_MODE) != 0) { - outgoingMode = new DirectionFilterAction("action.directionFilterOutgoing.", "org.eclipse.team.ui.syncview.outgoingFilter", ISynchronizePageConfiguration.OUTGOING_MODE); //$NON-NLS-1$ //$NON-NLS-2$ - actions.add(outgoingMode); - outgoingMode.setChecked(currentMode == ISynchronizePageConfiguration.OUTGOING_MODE); - } - - if((supportedModes & ISynchronizePageConfiguration.BOTH_MODE) != 0) { - bothMode = new DirectionFilterAction("action.directionFilterBoth.", "org.eclipse.team.ui.syncview.bothFilter", ISynchronizePageConfiguration.BOTH_MODE); //$NON-NLS-1$ //$NON-NLS-2$ - actions.add(bothMode); - bothMode.setChecked(currentMode == ISynchronizePageConfiguration.BOTH_MODE); - } - - if((supportedModes & ISynchronizePageConfiguration.CONFLICTING_MODE) != 0) { - conflictsMode = new DirectionFilterAction("action.directionFilterConflicts.", "org.eclipse.team.ui.syncview.conflictsFilter", ISynchronizePageConfiguration.CONFLICTING_MODE); //$NON-NLS-1$ //$NON-NLS-2$ - actions.add(conflictsMode); - conflictsMode.setChecked(currentMode == ISynchronizePageConfiguration.CONFLICTING_MODE); - } - } - - /** - * @param supportedModes - * @return - */ - private int getSupportedMode(int supportedModes) { - if((supportedModes & ISynchronizePageConfiguration.INCOMING_MODE) != 0) { - return ISynchronizePageConfiguration.INCOMING_MODE; - } - if((supportedModes & ISynchronizePageConfiguration.OUTGOING_MODE) != 0) { - return ISynchronizePageConfiguration.OUTGOING_MODE; - } - if((supportedModes & ISynchronizePageConfiguration.BOTH_MODE) != 0) { - return ISynchronizePageConfiguration.BOTH_MODE; - } - if((supportedModes & ISynchronizePageConfiguration.CONFLICTING_MODE) != 0) { - return ISynchronizePageConfiguration.CONFLICTING_MODE; - } - return 0; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars) - */ - public void fillActionBars(IActionBars actionBars, String group) { - super.fillActionBars(actionBars); - IToolBarManager toolBar = actionBars.getToolBarManager(); - for (Iterator it = actions.iterator(); it.hasNext();) { - DirectionFilterAction action = (DirectionFilterAction) it.next(); - if(group != null) { - toolBar.appendToGroup(group, action); - } else { - toolBar.add(action); - } - } - } - - public void fillToolBar(String groupId, IToolBarManager toolBar) { - for (Iterator it = actions.iterator(); it.hasNext();) { - DirectionFilterAction action = (DirectionFilterAction) it.next(); - toolBar.appendToGroup(groupId, action); - } - } - - public void fillMenu(IContributionManager manager) { - for (Iterator it = actions.iterator(); it.hasNext();) { - DirectionFilterAction action = (DirectionFilterAction) it.next(); - manager.add(action); - } - } - - private void checkMode(int mode) { - for (Iterator it = actions.iterator(); it.hasNext();) { - DirectionFilterAction action = (DirectionFilterAction)it.next(); - if(action.getModeId() == mode) { - action.setChecked(true); - } else { - action.setChecked(false); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - if(event.getProperty().equals(ISynchronizePageConfiguration.P_MODE)) { - Integer mode = (Integer)event.getNewValue(); - checkMode(mode.intValue()); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.ActionGroup#dispose() - */ - public void dispose() { - super.dispose(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ExpandAllAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ExpandAllAction.java deleted file mode 100644 index 0d305b152..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ExpandAllAction.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize.actions; - -import java.util.Iterator; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.*; - - -public class ExpandAllAction extends Action implements ISelectionChangedListener { - - private final AbstractTreeViewer viewer; - - public ExpandAllAction(AbstractTreeViewer viewer) { - this.viewer = viewer; - viewer.addSelectionChangedListener(this); - } - public void run() { - expandAllFromSelection(); - } - - protected void expandAllFromSelection() { - AbstractTreeViewer tree = viewer; - if (tree == null) return; - ISelection selection = tree.getSelection(); - if(! selection.isEmpty()) { - Iterator elements = ((IStructuredSelection)selection).iterator(); - while (elements.hasNext()) { - Object next = elements.next(); - tree.expandToLevel(next, AbstractTreeViewer.ALL_LEVELS); - } - } - } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ - public void selectionChanged(SelectionChangedEvent event) { - ISelection selection = event.getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection)selection; - setEnabled(!ss.isEmpty()); - return; - } - setEnabled(false); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java deleted file mode 100644 index 9c55f5b86..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize.actions; - -import org.eclipse.jface.action.*; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ui.*; -import org.eclipse.team.internal.ui.wizards.GlobalSynchronizeWizard; -import org.eclipse.team.ui.*; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowPulldownDelegate; - -/** - * A global refresh action that allows the user to select the participant to refresh - * or the default action is to refresh the last selected participant. Participants are - * only listed if they support - * <p> - * This action is normally associated with the Team action set and is enabled by default - * in the Team Synchronizing perspective. - * </p> - * @since 3.0 - */ -public class GlobalRefreshAction extends Action implements IMenuCreator, IWorkbenchWindowPulldownDelegate { - - public final static String NO_DEFAULT_PARTICPANT = "none"; //$NON-NLS-1$ - private Menu fMenu; - private Action synchronizeAction; - private IWorkbenchWindow window; - - class RefreshParticipantAction extends Action { - private ISynchronizeParticipantReference participant; - - public void run() { - TeamUIPlugin.getPlugin().getPreferenceStore().setValue(IPreferenceIds.SYNCHRONIZING_DEFAULT_PARTICIPANT, participant.getId()); - TeamUIPlugin.getPlugin().getPreferenceStore().setValue(IPreferenceIds.SYNCHRONIZING_DEFAULT_PARTICIPANT_SEC_ID, participant.getSecondaryId()); - GlobalRefreshAction.this.run(participant); - } - - public RefreshParticipantAction(int prefix, ISynchronizeParticipantReference participant) { - super("&" + prefix + " " + participant.getDisplayName()); //$NON-NLS-1$ //$NON-NLS-2$ - this.participant = participant; - setImageDescriptor(participant.getDescriptor().getImageDescriptor()); - } - } - - public GlobalRefreshAction() { - synchronizeAction = new Action(Policy.bind("GlobalRefreshAction.4")) { //$NON-NLS-1$ - public void run() { - IWizard wizard = new GlobalSynchronizeWizard(); - WizardDialog dialog = new WizardDialog(window.getShell(), wizard); - dialog.open(); - } - }; - synchronizeAction.setImageDescriptor(TeamImages.getImageDescriptor(ISharedImages.IMG_SYNC_VIEW)); - setMenuCreator(this); - updateTooltipMessage(); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.action.IMenuCreator#dispose() - */ - public void dispose() { - if (fMenu != null) { - fMenu.dispose(); - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu) - */ - public Menu getMenu(Menu parent) { - return null; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control) - */ - public Menu getMenu(Control parent) { - if (fMenu != null) { - fMenu.dispose(); - } - fMenu = new Menu(parent); - ISynchronizeParticipantReference[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); - for (int i = 0; i < participants.length; i++) { - ISynchronizeParticipantReference description = participants[i]; - Action action = new RefreshParticipantAction(i + 1, description); - addActionToMenu(fMenu, action); - } - if(participants.length > 0) addMenuSeparator(); - addActionToMenu(fMenu, synchronizeAction); - return fMenu; - } - - protected void addActionToMenu(Menu parent, Action action) { - ActionContributionItem item = new ActionContributionItem(action); - item.fill(parent, -1); - } - - protected void addMenuSeparator() { - new MenuItem(fMenu, SWT.SEPARATOR); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) - */ - public void init(IWorkbenchWindow window) { - this.window = window; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - String id = TeamUIPlugin.getPlugin().getPreferenceStore().getString(IPreferenceIds.SYNCHRONIZING_DEFAULT_PARTICIPANT); - String secondaryId = TeamUIPlugin.getPlugin().getPreferenceStore().getString(IPreferenceIds.SYNCHRONIZING_DEFAULT_PARTICIPANT_SEC_ID); - IWizard wizard = new GlobalSynchronizeWizard(); - if (! id.equals(NO_DEFAULT_PARTICPANT)) { - ISynchronizeParticipantReference participant = TeamUI.getSynchronizeManager().get(id, secondaryId); - if (participant != null) { - run(participant); - } - } - synchronizeAction.run(); - } - - private void run(ISynchronizeParticipantReference participant) { - ISynchronizeParticipant p; - try { - p = participant.getParticipant(); - p.run(null /* no workbench part */); - updateTooltipMessage(); - } catch (TeamException e) { - Utils.handle(e); - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, - * org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - } - - protected void updateTooltipMessage() { - setToolTipText(Policy.bind("GlobalRefreshAction.4")); //$NON-NLS-1$ - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java deleted file mode 100644 index fd1c983e3..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize.actions; - -import org.eclipse.compare.CompareEditorInput; -import org.eclipse.compare.ICompareNavigator; -import org.eclipse.compare.internal.INavigatable; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement; -import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.ISynchronizePageSite; -import org.eclipse.ui.*; -import org.eclipse.ui.actions.ActionFactory; - -/** - * Action to navigate the changes shown in the Synchronize View. This - * will coordinate change browsing between the view and the compare - * editors. - * - * @since 3.0 - */ -public class NavigateAction extends Action { - private final boolean next; - private ISynchronizePageSite site; - private String title; - private ISynchronizePageConfiguration configuration; - - public NavigateAction(ISynchronizePageSite site, String title, ISynchronizePageConfiguration configuration, boolean next) { - this.site = site; - this.title = title; - this.configuration = configuration; - this.next = next; - IActionBars bars = site.getActionBars(); - if (next) { - Utils.initAction(this, "action.navigateNext."); //$NON-NLS-1$ - if (bars != null) - bars.setGlobalActionHandler(ActionFactory.NEXT.getId(), this); - } else { - Utils.initAction(this, "action.navigatePrevious."); //$NON-NLS-1$ - if (bars != null) - bars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), this); - } - } - - /** - * Two types of navigation is supported: navigation that is specific to coordinating between a view - * and a compare editor and navigation simply using the configured navigator. - */ - public void run() { - IWorkbenchSite ws = site.getWorkbenchSite(); - INavigatable nav = (INavigatable)configuration.getProperty(SynchronizePageConfiguration.P_NAVIGATOR); - if (nav != null && ws != null && ws instanceof IViewSite) { - navigate(nav); - } else { - nav.gotoDifference(next); - } - } - - private void navigate(INavigatable nav) { - SyncInfo info = getSyncInfoFromSelection(); - if(info == null) { - if(nav.gotoDifference(next)) { - return; - } else { - info = getSyncInfoFromSelection(); - if(info == null) return; - } - } - - if(info.getLocal().getType() != IResource.FILE) { - if(! nav.gotoDifference(next)) { - info = getSyncInfoFromSelection(); - OpenInCompareAction.openCompareEditor(site, getTitle(), info, true /* keep focus */); - } - return; - } - - IWorkbenchSite ws = site.getWorkbenchSite(); - if (ws instanceof IWorkbenchPartSite) { - IEditorPart editor = OpenInCompareAction.findOpenCompareEditor((IWorkbenchPartSite)ws, info.getLocal()); - CompareEditorInput input; - ICompareNavigator navigator; - - if(editor != null) { - // if an existing editor is open on the current selection, use it - input = (CompareEditorInput)editor.getEditorInput(); - navigator = (ICompareNavigator)input.getAdapter(ICompareNavigator.class); - if(navigator != null) { - if(navigator.selectChange(next)) { - if(! nav.gotoDifference(next)) { - info = getSyncInfoFromSelection(); - OpenInCompareAction.openCompareEditor(site, getTitle(), info, true /* keep focus */); - } - } - } - } else { - // otherwise, select the next change and open a compare editor which will automatically - // show the first change. - OpenInCompareAction.openCompareEditor(site, getTitle(), info, true /* keep focus */); - } - } - } - - private SyncInfo getSyncInfoFromSelection() { - IStructuredSelection selection = (IStructuredSelection)site.getSelectionProvider().getSelection(); - if(selection == null) return null; - Object obj = selection.getFirstElement(); - if (obj instanceof SyncInfoModelElement) { - return ((SyncInfoModelElement) obj).getSyncInfo(); - } else { - return null; - } - } - - private String getTitle() { - return title; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenFileInSystemEditorAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenFileInSystemEditorAction.java deleted file mode 100644 index 8564d3d8e..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenFileInSystemEditorAction.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize.actions; - -import java.util.*; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.actions.OpenFileAction; - -public class OpenFileInSystemEditorAction extends OpenFileAction { - - public OpenFileInSystemEditorAction(IWorkbenchPage page) { - super(page); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.SelectionListenerAction#getSelectedResources() - */ - protected List getSelectedResources() { - IStructuredSelection selection = getStructuredSelection(); - IResource[] resources = Utils.getResources(selection.toArray()); - return Arrays.asList(resources); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.SelectionListenerAction#getSelectedNonResources() - */ - protected List getSelectedNonResources() { - return Collections.EMPTY_LIST; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java deleted file mode 100644 index 641a4f56a..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java +++ /dev/null @@ -1,165 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize.actions; - -import org.eclipse.compare.CompareUI; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement; -import org.eclipse.team.ui.synchronize.ISynchronizePageSite; -import org.eclipse.team.ui.synchronize.SyncInfoCompareInput; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IReusableEditor; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPartSite; -import org.eclipse.ui.IWorkbenchSite; - -/** - * Action to open a compare editor from a SyncInfo object. - * - * @see SyncInfoCompareInput - * @since 3.0 - */ -public class OpenInCompareAction extends Action { - - private String name; - private ISynchronizePageSite site; - - public OpenInCompareAction(ISynchronizePageSite site, String name) { - this.name = name; - this.site = site; - Utils.initAction(this, "action.openInCompareEditor."); //$NON-NLS-1$ - } - - public void run() { - ISelection selection = site.getSelectionProvider().getSelection(); - if(selection instanceof IStructuredSelection) { - Object obj = ((IStructuredSelection) selection).getFirstElement(); - if (obj instanceof SyncInfoModelElement) { - SyncInfo info = ((SyncInfoModelElement) obj).getSyncInfo(); - if (info != null) { - openCompareEditor(site, name, info, true); - } - } - } - } - - public static SyncInfoCompareInput openCompareEditor(ISynchronizePageSite site, String name, SyncInfo info, boolean keepFocus) { - SyncInfoCompareInput input = getCompareInput(name, info); - if(input != null) { - IWorkbenchSite ws = site.getWorkbenchSite(); - if (ws == null) return null; - IWorkbenchPage wpage = ws.getPage(); - IEditorPart editor = findReusableCompareEditor(wpage); - - if(editor != null) { - IEditorInput otherInput = editor.getEditorInput(); - if(otherInput instanceof SyncInfoCompareInput && otherInput.equals(input)) { - // simply provide focus to editor - wpage.activate(editor); - } else { - // if editor is currently not open on that input either re-use existing - if(editor != null && editor instanceof IReusableEditor) { - CompareUI.reuseCompareEditor(input, (IReusableEditor)editor); - wpage.activate(editor); - } - } - } else { - CompareUI.openCompareEditor(input); - editor = wpage.getActiveEditor(); - } - - if(keepFocus) { - site.setFocus(); - } - return input; - } - return null; - } - - /** - * Returns a SyncInfoCompareInput instance for the current selection. - */ - private static SyncInfoCompareInput getCompareInput(String name, SyncInfo info) { - if (info != null && info.getLocal() instanceof IFile) { - return new SyncInfoCompareInput(name, info); - } - return null; - } - - /** - * Returns an editor that can be re-used. An open compare editor that - * has un-saved changes cannot be re-used. - */ - public static IEditorPart findReusableCompareEditor(IWorkbenchPage page) { - IEditorReference[] editorRefs = page.getEditorReferences(); - - for (int i = 0; i < editorRefs.length; i++) { - IEditorPart part = editorRefs[i].getEditor(true); - if(part != null && part.getEditorInput() instanceof SyncInfoCompareInput) { - if(! part.isDirty()) { - return part; - } - } - } - return null; - } - - /** - * Close a compare editor that is opened on the given IResource. - * - * @param site the view site in which to close the editors - * @param resource the resource to use to find the compare editor - */ - public static void closeCompareEditorFor(final IWorkbenchPartSite site, final IResource resource) { - site.getShell().getDisplay().asyncExec(new Runnable() { - public void run() { - IEditorPart editor = findOpenCompareEditor(site, resource); - if(editor != null) { - site.getPage().closeEditor(editor, true /*save changes if required */); - } - } - }); - } - - /** - * Returns an editor handle if a SyncInfoCompareInput compare editor is opened on - * the given IResource. - * - * @param site the view site in which to search for editors - * @param resource the resource to use to find the compare editor - * @return an editor handle if found and <code>null</code> otherwise - */ - public static IEditorPart findOpenCompareEditor(IWorkbenchPartSite site, IResource resource) { - IWorkbenchPage page = site.getPage(); - IEditorReference[] editorRefs = page.getEditorReferences(); - for (int i = 0; i < editorRefs.length; i++) { - final IEditorPart part = editorRefs[i].getEditor(false /* don't restore editor */); - if(part != null) { - IEditorInput input = part.getEditorInput(); - if(part != null && input instanceof SyncInfoCompareInput) { - SyncInfo inputInfo = ((SyncInfoCompareInput)input).getSyncInfo(); - if(inputInfo.getLocal().equals(resource)) { - return part; - } - } - } - } - return null; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenWithActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenWithActionGroup.java deleted file mode 100644 index 3639d929b..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenWithActionGroup.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize.actions; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.synchronize.ISynchronizePageSite; -import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.ui.actions.ActionGroup; -import org.eclipse.ui.actions.OpenWithMenu; -import org.eclipse.ui.views.navigator.ResourceNavigatorMessages; - -/** - * This is the action group for the open actions. It contains open - * actions for - */ -public class OpenWithActionGroup extends ActionGroup { - - private OpenFileInSystemEditorAction openFileAction; - private OpenInCompareAction openInCompareAction; - private String name; - private ISynchronizePageSite site; - - public OpenWithActionGroup(ISynchronizePageSite site, String name) { - this.name = name; - this.site = site; - makeActions(); - } - - protected void makeActions() { - IWorkbenchSite ws = site.getWorkbenchSite(); - if (ws != null) { - openFileAction = new OpenFileInSystemEditorAction(ws.getPage()); - openInCompareAction = new OpenInCompareAction(site, name); - } - } - - public void fillContextMenu(IMenuManager menu, String groupId) { - ISelection selection = site.getSelectionProvider().getSelection(); - if (selection instanceof IStructuredSelection) { - fillOpenWithMenu(menu, groupId, (IStructuredSelection)selection); - } - } - - /** - * Adds the OpenWith submenu to the context menu. - * - * @param menu the context menu - * @param selection the current selection - */ - private void fillOpenWithMenu(IMenuManager menu, String groupId, IStructuredSelection selection) { - - // Only supported if exactly one file is selected. - if (selection == null || selection.size() != 1) - return; - Object element = selection.getFirstElement(); - IResource resources[] = Utils.getResources(new Object[] {element}); - IResource resource = null; - if(resources.length == 0) { - return; - } - resource = resources[0]; - - if(resource.getType() != IResource.FILE) return; - - menu.appendToGroup(groupId, openInCompareAction); - - if(!((resource.exists()))) { - return; - } - - if (openFileAction != null) { - openFileAction.selectionChanged(selection); - menu.appendToGroup(groupId, openFileAction); - } - - IWorkbenchSite ws = site.getWorkbenchSite(); - if (ws != null) { - MenuManager submenu = - new MenuManager(ResourceNavigatorMessages.getString("ResourceNavigator.openWith")); //$NON-NLS-1$ - submenu.add(new OpenWithMenu(ws.getPage(), resource)); - menu.appendToGroup(groupId, submenu); - } - } - - public void openInCompareEditor() { - openInCompareAction.run(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/PinParticipantAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/PinParticipantAction.java deleted file mode 100644 index bfd1d5afd..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/PinParticipantAction.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.synchronize.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; -import org.eclipse.ui.PlatformUI; - -/** - * Action that toggles pinned state of a participant - */ -public class PinParticipantAction extends Action { - - private ISynchronizeParticipant participant; - - public PinParticipantAction() { - super(); - Utils.initAction(this, "action.pinParticipant.", Policy.getBundle()); //$NON-NLS-1$ - } - - public void setParticipant(ISynchronizeParticipant participant) { - this.participant = participant; - setEnabled(participant != null); - updateState(); - } - - private void updateState() { - setChecked(participant != null && participant.isPinned()); - } - - public void run() { - if (participant != null) { - try { - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { - participant.setPinned(!participant.isPinned()); - updateState(); - } - }); - } catch (InvocationTargetException e) { - Utils.handle(e); - } catch (InterruptedException e) { - // Cancelled. Just ignore - } - } - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java deleted file mode 100644 index 19d49452f..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize.actions; - -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.synchronize.ISynchronizePageSite; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IKeyBindingService; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.ActionGroup; -import org.eclipse.ui.actions.DeleteResourceAction; -import org.eclipse.ui.actions.MoveResourceAction; -import org.eclipse.ui.actions.RenameResourceAction; -import org.eclipse.ui.actions.TextActionHandler; - -/** - * This action group is modeled after the class of the same name in - * the org.eclipse.ui.workbench plugin. We couldn't reuse that class - * because of a hard dependency on the navigator. - */ -public class RefactorActionGroup extends ActionGroup { - - private MoveResourceAction moveAction; - private RenameResourceAction renameAction; - private TextActionHandler textActionHandler; - private ISynchronizePageSite site; - private DeleteResourceAction deleteAction; - - public RefactorActionGroup(ISynchronizePageSite site) { - this.site = site; - makeActions(); - } - - public void fillContextMenu(IMenuManager parentMenu, String groupId) { - IStructuredSelection selection = getSelection(); - if (selection == null) return; - boolean anyResourceSelected = - !selection.isEmpty() - && allResourcesAreOfType( - selection, - IResource.PROJECT | IResource.FOLDER | IResource.FILE); - - MenuManager menu = new MenuManager(Policy.bind("RefactorActionGroup.0")); //$NON-NLS-1$ - IStructuredSelection convertedSelection = convertSelection(selection); - - if (anyResourceSelected) { - deleteAction.selectionChanged(convertedSelection); - menu.add(deleteAction); - moveAction.selectionChanged(convertedSelection); - menu.add(moveAction); - renameAction.selectionChanged(convertedSelection); - menu.add(renameAction); - } - parentMenu.appendToGroup(groupId, menu); - } - - private IStructuredSelection convertSelection(IStructuredSelection selection) { - return new StructuredSelection(Utils.getResources(selection.toArray())); - } - - public void fillActionBars(IActionBars actionBars) { - textActionHandler = new TextActionHandler(actionBars); // hooks handlers - textActionHandler.setDeleteAction(deleteAction); - renameAction.setTextActionHandler(textActionHandler); - deleteAction.selectionChanged(getSelection()); - } - - protected void makeActions() { - - Shell shell = site.getShell(); - ISharedImages images = PlatformUI.getWorkbench().getSharedImages(); - - moveAction = new MoveResourceAction(shell); - renameAction = new RenameResourceAction(shell); - - deleteAction = new DeleteResourceAction(shell) { - protected List getSelectedResources() { - return Arrays.asList(Utils.getResources(getSelection().toArray())); - } - }; - deleteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); - deleteAction.setActionDefinitionId("org.eclipse.ui.edit.delete"); //$NON-NLS-1$ - - // Get the key binding service for registering actions with commands. - IKeyBindingService keyBindingService = site.getKeyBindingService(); - if (keyBindingService != null) { - keyBindingService.registerAction(deleteAction); - } - } - - public void updateActionBars() { - IStructuredSelection selection = getSelection(); - deleteAction.selectionChanged(selection); - moveAction.selectionChanged(selection); - renameAction.selectionChanged(selection); - } - - private IStructuredSelection getSelection() { - return (IStructuredSelection)site.getSelectionProvider().getSelection(); - } - - private boolean allResourcesAreOfType(IStructuredSelection selection, int resourceMask) { - Iterator resources = selection.iterator(); - while (resources.hasNext()) { - Object next = resources.next(); - IResource resource = null; - if (next instanceof IResource) { - resource = (IResource)next; - } else if (next instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable)next; - resource = (IResource)adaptable.getAdapter(IResource.class); - } - if(resource == null) { - IResource[] r = Utils.getResources(new Object[] {next}); - if(r.length == 1) { - resource = r[0]; - } - } - if (resource == null || (resource.getType() & resourceMask) == 0) { - return false; - } - } - return true; - } -} 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 deleted file mode 100644 index 6abdfc091..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveFromViewAction.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.synchronize.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.MessageDialogWithToggle; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.core.subscribers.WorkingSetFilteredSyncInfoCollector; -import org.eclipse.team.internal.ui.IPreferenceIds; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.SubscriberParticipantPage; -import org.eclipse.team.ui.synchronize.ISynchronizePage; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SynchronizeModelAction; -import org.eclipse.team.ui.synchronize.SynchronizeModelOperation; - -/** - * Remove the selected elemements from the page - */ -public class RemoveFromViewAction extends SynchronizeModelAction { - - protected RemoveFromViewAction(ISynchronizePageConfiguration configuration) { - super(null, configuration); - Utils.initAction(this, "action.removeFromView.", Policy.getBundle()); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#run() - */ - public void run() { - if (confirmRemove()) { - super.run(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSubscriberOperation(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration, org.eclipse.compare.structuremergeviewer.IDiffElement[]) - */ - protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - return new SynchronizeModelOperation(configuration, elements) { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - SyncInfoSet set = getSyncInfoSet(); - removeFromView(set); - } - protected boolean canRunAsJob() { - return false; - } - /** - * Remove the sync info contained in the given set from the view. - * @param set the sync info set - */ - private void removeFromView(final SyncInfoSet set) { - ISynchronizePage page = getConfiguration().getPage(); - if (page instanceof SubscriberParticipantPage) { - final WorkingSetFilteredSyncInfoCollector collector = ((SubscriberParticipantPage)page).getCollector(); - collector.run(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - collector.getWorkingSetSyncInfoSet().removeAll(set.getResources()); - } - }); - } - } - }; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#needsToSaveDirtyEditors() - */ - protected boolean needsToSaveDirtyEditors() { - return false; - } - - private boolean confirmRemove() { - IPreferenceStore store = TeamUIPlugin.getPlugin().getPreferenceStore(); - if (store.getBoolean(IPreferenceIds.SYNCVIEW_REMOVE_FROM_VIEW_NO_PROMPT)) { - return true; - } else { - MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm( - getConfiguration().getSite().getShell(), - Policy.bind("RemoveFromView.warningTitle"), //$NON-NLS-1$ - Policy.bind("RemoveFromView.warningMessage"), //$NON-NLS-1$ - Policy.bind("RemoveFromView.warningDontShow"), //$NON-NLS-1$ - false, - null, - null); - store.setValue(IPreferenceIds.SYNCVIEW_REMOVE_FROM_VIEW_NO_PROMPT, dialog.getToggleState()); - return dialog.getReturnCode() == Dialog.OK; - } - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveSynchronizeParticipantAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveSynchronizeParticipantAction.java deleted file mode 100644 index cbd664810..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveSynchronizeParticipantAction.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize.actions; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Display; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.PlatformUI; - -/** - * Action to remove the given participant from the synchronize manager. - * @since 3.0 - */ -public class RemoveSynchronizeParticipantAction extends Action { - - private ISynchronizeParticipant participant; - private final ISynchronizeView view; - private boolean removeAll; - - public RemoveSynchronizeParticipantAction(ISynchronizeView view, boolean removeAll) { - this.view = view; - this.removeAll = removeAll; - if (removeAll) { - Utils.initAction(this, "action.removeAllPage.", Policy.getBundle()); //$NON-NLS-1$ - } else { - Utils.initAction(this, "action.removePage.", Policy.getBundle()); //$NON-NLS-1$ - } - } - - public void run() { - try { - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - if (removeAll) { - removeAll(); - } else { - removeCurrent(); - } - } - }); - } catch (InvocationTargetException e) { - Utils.handle(e); - } catch (InterruptedException e) { - // Cancelled. Just ignore - } - } - - private void removeCurrent() { - final ISynchronizeParticipant participant = view.getParticipant(); - if (participant != null) { - if (participant.isPinned()) { - final boolean[] bail = new boolean[] { false }; - Display.getDefault().syncExec(new Runnable() { - public void run() { - bail[0] = !MessageDialog.openQuestion( - view.getSite().getShell(), - "Remove Pinned Synchronization?", - "The current synchronization is pinned. Are you sure you want to remove it?"); - - } - }); - if (bail[0]) { - return; - } - } - TeamUI.getSynchronizeManager().removeSynchronizeParticipants(new ISynchronizeParticipant[]{participant}); - } - } - - private void removeAll() { - ISynchronizeManager manager = TeamUI.getSynchronizeManager(); - ISynchronizeParticipantReference[] refs = manager.getSynchronizeParticipants(); - ArrayList removals = new ArrayList(); - for (int i = 0; i < refs.length; i++) { - ISynchronizeParticipantReference reference = refs[i]; - ISynchronizeParticipant p; - try { - p = reference.getParticipant(); - if (! p.isPinned()) - removals.add(p); - } catch (TeamException e) { - // keep going - } - } - manager.removeSynchronizeParticipants((ISynchronizeParticipant[]) removals.toArray(new ISynchronizeParticipant[removals.size()])); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ShowSynchronizeParticipantAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ShowSynchronizeParticipantAction.java deleted file mode 100644 index 059de2a9f..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ShowSynchronizeParticipantAction.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; -import org.eclipse.team.ui.synchronize.ISynchronizeView; - -public class ShowSynchronizeParticipantAction extends Action { - - private ISynchronizeParticipantReference fPage; - private ISynchronizeView fView; - - public void run() { - try { - if (!fPage.equals(fView.getParticipant())) { - fView.display(fPage.getParticipant()); - } - } catch (TeamException e) { - Utils.handle(e); - } - } - - /** - * Constructs an action to display the given synchronize participant in the - * synchronize view. - * - * @param view the synchronize view in which the given page is contained - * @param participant the participant to show - */ - public ShowSynchronizeParticipantAction(ISynchronizeView view, ISynchronizeParticipantReference ref) { - super(ref.getDisplayName(), Action.AS_RADIO_BUTTON); - fPage = ref; - fView = view; - setImageDescriptor(ref.getDescriptor().getImageDescriptor()); - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineCLabelContribution.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineCLabelContribution.java deleted file mode 100644 index da68d4cf6..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineCLabelContribution.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize.actions; - -import org.eclipse.jface.action.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.graphics.FontMetrics; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; - -public class StatusLineCLabelContribution extends ContributionItem { - - public final static int DEFAULT_CHAR_WIDTH = 40; - - private int charWidth; - private CLabel label; - private Image image; - private String text = ""; //$NON-NLS-1$ - private int widthHint = -1; - private int heightHint = -1; - - private Listener listener; - private int eventType; - private String tooltip; - - public StatusLineCLabelContribution(String id) { - this(id, DEFAULT_CHAR_WIDTH); - } - - public StatusLineCLabelContribution(String id, int charWidth) { - super(id); - this.charWidth = charWidth; - setVisible(false); // no text to start with - } - - public void fill(Composite parent) { - Label sep = new Label(parent, SWT.SEPARATOR); - label = new CLabel(parent, SWT.SHADOW_NONE); - StatusLineLayoutData statusLineLayoutData = new StatusLineLayoutData(); - - if (widthHint < 0) { - GC gc = new GC(parent); - gc.setFont(parent.getFont()); - FontMetrics fm = gc.getFontMetrics(); - widthHint = fm.getAverageCharWidth() * charWidth; - heightHint = fm.getHeight(); - gc.dispose(); - } - - statusLineLayoutData.widthHint = widthHint; - label.setLayoutData(statusLineLayoutData); - label.setText(text); - label.setImage(image); - if(listener != null) { - label.addListener(eventType, listener); - } - if(tooltip != null) { - label.setToolTipText(tooltip); - } - - statusLineLayoutData = new StatusLineLayoutData(); - statusLineLayoutData.heightHint = heightHint; - sep.setLayoutData(statusLineLayoutData); - } - - public void addListener(int eventType, Listener listener) { - this.eventType = eventType; - this.listener = listener; - } - - public String getText() { - return text; - } - - public void setText(String text) { - if (text == null) - throw new NullPointerException(); - - this.text = text; - - if (label != null && !label.isDisposed()) - label.setText(this.text); - - if (this.text.length() == 0) { - if (isVisible()) { - setVisible(false); - IContributionManager contributionManager = getParent(); - - if (contributionManager != null) - contributionManager.update(true); - } - } else { - if (!isVisible()) { - setVisible(true); - IContributionManager contributionManager = getParent(); - - if (contributionManager != null) - contributionManager.update(true); - } - } - } - - public void setTooltip(String tooltip) { - if (tooltip == null) - throw new NullPointerException(); - - this.tooltip = tooltip; - - if (label != null && !label.isDisposed()) { - label.setToolTipText(this.tooltip); - } - } - - public void setImage(Image image) { - if (image == null) - throw new NullPointerException(); - - this.image = image; - - if (label != null && !label.isDisposed()) - label.setImage(this.image); - - if (!isVisible()) { - setVisible(true); - IContributionManager contributionManager = getParent(); - - if (contributionManager != null) - contributionManager.update(true); - } - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineContributionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineContributionGroup.java deleted file mode 100644 index cff38c9bc..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineContributionGroup.java +++ /dev/null @@ -1,164 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize.actions; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.ITeamStatus; -import org.eclipse.team.core.synchronize.ISyncInfoSetChangeEvent; -import org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration; -import org.eclipse.team.ui.ISharedImages; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.SubscriberParticipant; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.actions.ActionGroup; - -public class StatusLineContributionGroup extends ActionGroup implements ISyncInfoSetChangeListener { - - private static final String INCOMING_ID = TeamUIPlugin.ID + "org.eclipse.team.iu.statusline.incoming"; //$NON-NLS-1$ - private static final String OUTGOING_ID = TeamUIPlugin.ID + "org.eclipse.team.iu.statusline.outgoing"; //$NON-NLS-1$ - private static final String CONFLICTING_ID = TeamUIPlugin.ID + "org.eclipse.team.iu.statusline.conflicting"; //$NON-NLS-1$ - private static final String WORKINGSET_ID = TeamUIPlugin.ID + "org.eclipse.team.iu.statusline.workingset"; //$NON-NLS-1$ - private static final String TOTALS_ID = TeamUIPlugin.ID + "org.eclipse.team.iu.statusline.totals"; //$NON-NLS-1$ - private final static int TEXT_FIELD_MAX_SIZE = 25; - - private StatusLineCLabelContribution incoming; - private StatusLineCLabelContribution outgoing; - private StatusLineCLabelContribution conflicting; - private StatusLineCLabelContribution totalChanges; - - private Image incomingImage = TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_DLG_SYNC_INCOMING).createImage(); - private Image outgoingImage = TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_DLG_SYNC_OUTGOING).createImage(); - private Image conflictingImage = TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_DLG_SYNC_CONFLICTING).createImage(); - - private ISynchronizePageConfiguration configuration; - - public StatusLineContributionGroup(final Shell shell, ISynchronizePageConfiguration configuration) { - this.configuration = configuration; - this.incoming = createStatusLineContribution(INCOMING_ID, ISynchronizePageConfiguration.INCOMING_MODE, "0", incomingImage); //$NON-NLS-1$ - this.outgoing = createStatusLineContribution(OUTGOING_ID, ISynchronizePageConfiguration.OUTGOING_MODE, "0", outgoingImage); //$NON-NLS-1$ - this.conflicting = createStatusLineContribution(CONFLICTING_ID, ISynchronizePageConfiguration.CONFLICTING_MODE, "0", conflictingImage); //$NON-NLS-1$ - this.totalChanges = new StatusLineCLabelContribution(TOTALS_ID, TEXT_FIELD_MAX_SIZE); - - // Listen to changes to update the counts - SyncInfoSet set = getSyncInfoSet(); - set.addSyncSetChangedListener(this); - updateCounts(); - } - - private boolean isThreeWay() { - return getParticipant().getSubscriber().getResourceComparator().isThreeWay(); - } - - private SubscriberParticipant getParticipant() { - return (SubscriberParticipant)configuration.getParticipant(); - } - - private StatusLineCLabelContribution createStatusLineContribution(String id, final int mode, String label, Image image) { - StatusLineCLabelContribution item = new StatusLineCLabelContribution(id, 15); - item.addListener(SWT.MouseDown, new Listener() { - public void handleEvent(Event event) { - configuration.setMode(mode); - } - }); - item.setText(label); //$NON-NLS-1$ - item.setImage(image); - return item; - } - - public void dispose() { - getSyncInfoSet().removeSyncSetChangedListener(this); - incomingImage.dispose(); - outgoingImage.dispose(); - conflictingImage.dispose(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.team.internal.ui.sync.sets.ISyncSetChangedListener#syncSetChanged(org.eclipse.team.internal.ui.sync.sets.SyncSetChangedEvent) - */ - public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor) { - updateCounts(); - } - - private void updateCounts() { - if (getParticipant().getSubscriber() != null) { - SyncInfoSet workspaceSetStats = getWorkingSetSyncInfoSet(); - - final int total = workspaceSetStats.size(); - final int workspaceConflicting = (int) workspaceSetStats.countFor(SyncInfo.CONFLICTING, SyncInfo.DIRECTION_MASK); - final int workspaceOutgoing = (int) workspaceSetStats.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK); - final int workspaceIncoming = (int) workspaceSetStats.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK); - - TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - conflicting.setText(new Integer(workspaceConflicting).toString()); //$NON-NLS-1$ - incoming.setText(new Integer(workspaceIncoming).toString()); //$NON-NLS-1$ - outgoing.setText(new Integer(workspaceOutgoing).toString()); //$NON-NLS-1$ - - conflicting.setTooltip(Policy.bind("StatisticsPanel.numbersTooltip", Policy.bind("StatisticsPanel.conflicting"))); //$NON-NLS-1$ //$NON-NLS-2$ - outgoing.setTooltip(Policy.bind("StatisticsPanel.numbersTooltip", Policy.bind("StatisticsPanel.outgoing"))); //$NON-NLS-1$ //$NON-NLS-2$ - incoming.setTooltip(Policy.bind("StatisticsPanel.numbersTooltip", Policy.bind("StatisticsPanel.incoming"))); //$NON-NLS-1$ //$NON-NLS-2$ - totalChanges.setText(Policy.bind("StatisticsPanel.numberTotal", Integer.toString(total))); //$NON-NLS-1$ - } - }); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars) - */ - public void fillActionBars(IActionBars actionBars) { - IStatusLineManager mgr = actionBars.getStatusLineManager(); - if (isThreeWay()) { - mgr.add(incoming); - mgr.add(outgoing); - mgr.add(conflicting); - } else { - mgr.add(totalChanges); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.ISyncInfoSetChangeListener#syncInfoSetReset(org.eclipse.team.core.subscribers.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) - */ - public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) { - updateCounts(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.ISyncInfoSetChangeListener#syncInfoSetError(org.eclipse.team.core.subscribers.SyncInfoSet, org.eclipse.team.core.ITeamStatus[], org.eclipse.core.runtime.IProgressMonitor) - */ - public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) { - // Nothing to do for errors - } - - private SyncInfoSet getSyncInfoSet() { - return (SyncInfoSet)configuration.getProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET); - } - - private SyncInfoSet getWorkingSetSyncInfoSet() { - return (SyncInfoSet)configuration.getProperty(SynchronizePageConfiguration.P_WORKING_SET_SYNC_INFO_SET); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SubscriberActionContribution.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SubscriberActionContribution.java deleted file mode 100644 index a2effa3d5..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SubscriberActionContribution.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.synchronize.actions; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.ConfigureRefreshScheduleDialog; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.team.ui.synchronize.ISynchronizePageSite; -import org.eclipse.team.ui.synchronize.SubscriberParticipant; -import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup; -import org.eclipse.ui.IActionBars; - -/** - * Provides the actions to be associated with a synchronize page - */ -public final class SubscriberActionContribution extends SynchronizePageActionGroup { - - // the changes viewer are contributed via the viewer and not the page. - private Action configureSchedule; - private SyncViewerShowPreferencesAction showPreferences; - private Action refreshSelectionAction; - private RemoveFromViewAction removeFromViewAction; - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.IActionContribution#initialize(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) - */ - public void initialize(final ISynchronizePageConfiguration configuration) { - super.initialize(configuration); - final SubscriberParticipant participant = (SubscriberParticipant)configuration.getParticipant(); - final ISynchronizePageSite site = configuration.getSite(); - // toolbar - if(participant.doesSupportSynchronize()) { - - refreshSelectionAction = new Action() { - public void run() { - IStructuredSelection selection = (IStructuredSelection)site.getSelectionProvider().getSelection(); - IResource[] resources = Utils.getResources(selection.toArray()); - participant.refresh(resources, Policy.bind("Participant.synchronizing"), Policy.bind("Participant.synchronizingDetails", participant.getName()), site.getWorkbenchSite()); //$NON-NLS-1$ //$NON-NLS-2$ - } - }; - Utils.initAction(refreshSelectionAction, "action.refreshWithRemote."); //$NON-NLS-1$ - - configureSchedule = new Action() { - public void run() { - ConfigureRefreshScheduleDialog d = new ConfigureRefreshScheduleDialog( - site.getShell(), participant.getRefreshSchedule()); - d.setBlockOnOpen(false); - d.open(); - } - }; - Utils.initAction(configureSchedule, "action.configureSchedulel."); //$NON-NLS-1$ - } - - showPreferences = new SyncViewerShowPreferencesAction(site.getShell()); - removeFromViewAction = new RemoveFromViewAction(configuration); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.IActionContribution#fillContextMenu(org.eclipse.jface.action.IMenuManager) - */ - public void fillContextMenu(IMenuManager manager) { - if (findGroup(manager, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP) != null - && findGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP) != null) { - // Place synchronize with navigato to save space - appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, refreshSelectionAction); - appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, removeFromViewAction); - } else { - appendToGroup(manager, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP, refreshSelectionAction); - appendToGroup(manager, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP, removeFromViewAction); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.IActionContribution#setActionBars(org.eclipse.ui.IActionBars) - */ - public void fillActionBars(IActionBars actionBars) { - if(actionBars != null) { - - // view menu - IMenuManager menu = actionBars.getMenuManager(); - if (findGroup(menu, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP) != null - && findGroup(menu, ISynchronizePageConfiguration.PREFERENCES_GROUP) != null) { - appendToGroup(menu, ISynchronizePageConfiguration.PREFERENCES_GROUP, configureSchedule); - } else { - appendToGroup(menu, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP, configureSchedule); - } - appendToGroup(menu, ISynchronizePageConfiguration.PREFERENCES_GROUP, showPreferences); - } - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SyncViewerShowPreferencesAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SyncViewerShowPreferencesAction.java deleted file mode 100644 index ca6abf4a0..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SyncViewerShowPreferencesAction.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.dialogs.PreferencePageContainerDialog; -import org.eclipse.team.internal.ui.preferences.SyncViewerPreferencePage; - -public class SyncViewerShowPreferencesAction extends Action { - private final Shell shell; - - public SyncViewerShowPreferencesAction(Shell shell) { - this.shell = shell; - Utils.initAction(this, "action.syncViewPreferences."); //$NON-NLS-1$ - } - - public void run() { - PreferencePage page = new SyncViewerPreferencePage(); - Dialog dialog = new PreferencePageContainerDialog(shell, page); - dialog.setBlockOnOpen(true); - dialog.open(); - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SynchronizePageDropDownAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SynchronizePageDropDownAction.java deleted file mode 100644 index 95b9e67ad..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SynchronizePageDropDownAction.java +++ /dev/null @@ -1,176 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.synchronize.actions; - -import org.eclipse.jface.action.*; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ui.*; -import org.eclipse.team.internal.ui.wizards.GlobalSynchronizeWizard; -import org.eclipse.team.ui.*; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.texteditor.IUpdate; - -public class SynchronizePageDropDownAction extends Action implements IMenuCreator, ISynchronizeParticipantListener, IUpdate { - - private ISynchronizeView fView; - private Menu fMenu; - private Action synchronizeAction; - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IUpdate#update() - */ - public void update() { - ISynchronizeParticipantReference[] refs = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); - updateTooltipText(); - IActionBars bars = fView.getViewSite().getActionBars(); - } - - protected ISynchronizeParticipantReference[] getParticipants() { - return TeamUI.getSynchronizeManager().getSynchronizeParticipants(); - } - - protected boolean select(ISynchronizeParticipantReference ref) { - return true; - } - - public SynchronizePageDropDownAction(ISynchronizeView view) { - fView= view; - Utils.initAction(this, "action.refreshSubscriber."); //$NON-NLS-1$ - - synchronizeAction = new Action(Policy.bind("GlobalRefreshAction.4")) { //$NON-NLS-1$ - public void run() { - IWizard wizard = new GlobalSynchronizeWizard(); - WizardDialog dialog = new WizardDialog(fView.getViewSite().getShell(), wizard); - dialog.open(); - } - }; - synchronizeAction.setImageDescriptor(TeamImages.getImageDescriptor(ISharedImages.IMG_SYNC_VIEW)); - setMenuCreator(this); - update(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.action.IMenuCreator#dispose() - */ - public void dispose() { - if (fMenu != null) { - fMenu.dispose(); - fMenu = null; - } - TeamUI.getSynchronizeManager().removeSynchronizeParticipantListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu) - */ - public Menu getMenu(Menu parent) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control) - */ - public Menu getMenu(Control parent) { - if (fMenu != null) { - fMenu.dispose(); - } - fMenu= new Menu(parent); - final ISynchronizeParticipantReference[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); - addParticipantsToMenu(fMenu, participants); - if(participants.length > 0) addMenuSeparator(); - addActionToMenu(fMenu, synchronizeAction); - TeamUI.getSynchronizeManager().addSynchronizeParticipantListener(this); - return fMenu; - } - - protected void addParticipantsToMenu(Menu parent, ISynchronizeParticipantReference[] refs) { - ISynchronizeParticipant current = fView.getParticipant(); - for (int i = 0; i < refs.length; i++) { - ISynchronizeParticipantReference page = refs[i]; - Action action = new ShowSynchronizeParticipantAction(fView, page); - try { - boolean isCurrent = page.getParticipant().equals(current); - action.setChecked(isCurrent); - } catch (TeamException e) { - continue; - } - addActionToMenu(fMenu, action); - } - } - - protected void addActionToMenu(Menu parent, Action action) { - ActionContributionItem item= new ActionContributionItem(action); - item.fill(parent, -1); - } - - protected void addMenuSeparator() { - new MenuItem(fMenu, SWT.SEPARATOR); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - ISynchronizeParticipant current = fView.getParticipant(); - if(current != null) { - current.run(fView); - } else { - synchronizeAction.run(); - } - update(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.ISynchronizeParticipantListener#participantsAdded(org.eclipse.team.ui.sync.ISynchronizeParticipant[]) - */ - public void participantsAdded(ISynchronizeParticipant[] consoles) { - Display display = TeamUIPlugin.getStandardDisplay(); - display.asyncExec(new Runnable() { - public void run() { - update(); - } - }); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.ISynchronizeParticipantListener#participantsRemoved(org.eclipse.team.ui.sync.ISynchronizeParticipant[]) - */ - public void participantsRemoved(ISynchronizeParticipant[] consoles) { - Display display = TeamUIPlugin.getStandardDisplay(); - display.asyncExec(new Runnable() { - public void run() { - if (fMenu != null) { - fMenu.dispose(); - } - update(); - } - }); - } - - private void updateTooltipText() { - ISynchronizeParticipant current = fView.getParticipant(); - String text = null; - if(current != null) { - text = Policy.bind("GlobalRefreshAction.5", current.getName()); //$NON-NLS-1$ - setToolTipText(text); - setText(text); - } else { - text = Policy.bind("GlobalRefreshAction.4"); //$NON-NLS-1$ - setToolTipText(text); - setText(text); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardElement.java deleted file mode 100644 index ba17383a1..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardElement.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.wizards; - - -import org.eclipse.core.runtime.*; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.ui.model.IWorkbenchAdapter; -import org.eclipse.ui.model.WorkbenchAdapter; - -/** - * ConfigurationWizardElement represents an item in the configuration wizard table, - * declared by an extension to the configurationWizards extension point. - */ -public class ConfigurationWizardElement extends WorkbenchAdapter implements IAdaptable { - private String id; - private String name; - private ImageDescriptor imageDescriptor; - private String description; - private IConfigurationElement configurationElement; - - /** - * Creates a new instance of this class - * - * @param name the name of the element - */ - public ConfigurationWizardElement(String name) { - this.name = name; - } - /** - * Create an the instance of the object described by the configuration - * element. That is, create the instance of the class the isv supplied in - * the extension point. - * - * @throws CoreException if an error occurs creating the extension - */ - public Object createExecutableExtension() throws CoreException { - return TeamUIPlugin.createExtension(configurationElement, ConfigureProjectWizard.ATT_CLASS); - } - /* - * Method declared on IAdaptable. - */ - public Object getAdapter(Class adapter) { - if (adapter == IWorkbenchAdapter.class) { - return this; - } - return Platform.getAdapterManager().getAdapter(this, adapter); - } - /** - * Returns the configuration element - * - * @return the configuration element - */ - public IConfigurationElement getConfigurationElement() { - return configurationElement; - } - /** - * Returns the description parameter of this element - * - * @return the description of this elemnet - */ - public String getDescription() { - return description; - } - /** - * Returns the image for the given element - * - * @param element the element to get the image for - * @return the image for the given element - */ - public ImageDescriptor getImageDescriptor(Object element) { - return imageDescriptor; - } - /** - * Returns the label for the given element - * - * @param element the element to get the label for - * @return the label for the given element - */ - public String getLabel(Object element) { - return name; - } - /** - * Returns the id as specified in the extension. - * - * @return java.lang.String - */ - public String getID() { - return id; - } - /** - * Returns the image for this element. - * - * @return the image for this element - */ - public ImageDescriptor getImageDescriptor() { - return imageDescriptor; - } - /** - * Set the configuration element - * - * @param newConfigurationElement the new configuration element - */ - public void setConfigurationElement(IConfigurationElement newConfigurationElement) { - configurationElement = newConfigurationElement; - } - /** - * Set the description parameter of this element - * - * @param value the new desrciption - */ - public void setDescription(String value) { - description = value; - } - /** - * Sets the id parameter of this element - * - * @param value the new ID - */ - public void setID(String value) { - id = value; - } - /** - * Sets the image for this element. - * - * @param value the new image - */ - public void setImageDescriptor(ImageDescriptor value) { - imageDescriptor = value; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardNode.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardNode.java deleted file mode 100644 index 05a8a6eef..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardNode.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.wizards; - - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.IWizardNode; -import org.eclipse.swt.graphics.Point; -import org.eclipse.team.internal.ui.Policy; - -/** - * ConfigurationWizardNode represents the objects in the - * table in the Configuration wizard. - */ -public class ConfigurationWizardNode implements IWizardNode { - // The element this node represents - ConfigurationWizardElement element; - // The wizard this node is in - IWizard wizard; - - /** - * Create a new ConfigurationWizardNode - * - * @param element the configuration wizard element for this node - */ - public ConfigurationWizardNode(ConfigurationWizardElement element) { - this.element = element; - } - /* - * Method declared on IWizardNode. - */ - public void dispose() { - if (wizard != null) { - wizard.dispose(); - wizard = null; - } - } - /* - * Method declared on IWizardNode. - */ - public Point getExtent() { - return new Point(-1, -1); - } - /* - * Method declared on IWizardNode. - */ - public IWizard getWizard() { - if (wizard == null) { - try { - wizard = (IWizard)element.createExecutableExtension(); - } catch (CoreException e) { - System.out.println(Policy.bind("ConfigurationWizard.exceptionCreatingWizard")); //$NON-NLS-1$ - } - } - return wizard; - } - /* - * Method declared on IWizardNode. - */ - public boolean isContentCreated() { - return wizard != null; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizard.java deleted file mode 100644 index 165bab491..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizard.java +++ /dev/null @@ -1,241 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.wizards; - - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.ui.*; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.model.AdaptableList; - -/** - * The wizard for associating projects with team providers - */ -public class ConfigureProjectWizard extends Wizard implements IConfigurationWizard { - protected IWorkbench workbench; - protected IProject project; - protected IConfigurationWizard wizard; - - protected ConfigureProjectWizardMainPage mainPage; - private String pluginId = TeamUIPlugin.PLUGIN_ID; - - protected final static String TAG_WIZARD = "wizard"; //$NON-NLS-1$ - protected final static String TAG_DESCRIPTION = "description"; //$NON-NLS-1$ - protected final static String ATT_NAME = "name"; //$NON-NLS-1$ - protected final static String ATT_CLASS = "class"; //$NON-NLS-1$ - protected final static String ATT_ICON = "icon"; //$NON-NLS-1$ - protected final static String ATT_ID = "id"; //$NON-NLS-1$ - - public ConfigureProjectWizard() { - setNeedsProgressMonitor(true); - setWindowTitle(getWizardWindowTitle()); //$NON-NLS-1$ - } - - protected String getExtensionPoint() { - return ITeamUIConstants.PT_CONFIGURATION; - } - - protected String getWizardWindowTitle() { - return Policy.bind("ConfigureProjectWizard.title"); //$NON-NLS-1$ - } - - protected String getWizardLabel() { - return Policy.bind("ConfigureProjectWizard.configureProject"); //$NON-NLS-1$ - } - - protected String getWizardDescription() { - return Policy.bind("ConfigureProjectWizard.description"); //$NON-NLS-1$ - } - - /* - * @see Wizard#addPages - */ - public void addPages() { - AdaptableList wizards = getAvailableWizards(); - if (wizards.size() == 1) { - // If there is only one wizard, skip the first page. - // Only skip the first page if the one wizard has at least one page. - ConfigurationWizardElement element = (ConfigurationWizardElement)wizards.getChildren()[0]; - try { - this.wizard = (IConfigurationWizard)element.createExecutableExtension(); - wizard.init(workbench, project); - wizard.addPages(); - if (wizard.getPageCount() > 0) { - wizard.setContainer(getContainer()); - IWizardPage[] pages = wizard.getPages(); - for (int i = 0; i < pages.length; i++) { - addPage(pages[i]); - } - return; - } - } catch (CoreException e) { - TeamUIPlugin.log(e); - return; - } - } - mainPage = new ConfigureProjectWizardMainPage("configurePage1", getWizardLabel(), TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_WIZBAN_SHARE), wizards); //$NON-NLS-1$ - mainPage.setDescription(getWizardDescription()); - mainPage.setProject(project); - mainPage.setWorkbench(workbench); - addPage(mainPage); - } - public IWizardPage getNextPage(IWizardPage page) { - if (wizard != null) { - return wizard.getNextPage(page); - } - return super.getNextPage(page); - } - public boolean canFinish() { - // If we are on the first page, never allow finish unless the selected wizard has no pages. - if (getContainer().getCurrentPage() == mainPage) { - if (mainPage.getSelectedWizard() != null && mainPage.getNextPage() == null) { - return true; - } - return false; - } - if (wizard != null) { - return wizard.canFinish(); - } - return super.canFinish(); - } - /* - * @see Wizard#performFinish - */ - public boolean performFinish() { - // There is only one wizard with at least one page - if (wizard != null) { - return wizard.performFinish(); - } - // If we are on the first page and the selected wizard has no pages then - // allow it to finish. - if (getContainer().getCurrentPage() == mainPage) { - IConfigurationWizard noPageWizard = mainPage.getSelectedWizard(); - if (noPageWizard != null) { - if (noPageWizard.canFinish()) - { - return noPageWizard.performFinish(); - } - } - } - // If the wizard has pages and there are several - // wizards registered then the registered wizard - // will call it's own performFinish(). - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#performCancel() - */ - public boolean performCancel() { - if (wizard != null) { - return wizard.performCancel(); - } - return super.performCancel(); - } - - /** - * Returns the configuration wizards that are available for invocation. - * - * @return the available wizards - */ - protected AdaptableList getAvailableWizards() { - AdaptableList result = new AdaptableList(); - IPluginRegistry registry = Platform.getPluginRegistry(); - IExtensionPoint point = registry.getExtensionPoint(pluginId, getExtensionPoint()); - if (point != null) { - IExtension[] extensions = point.getExtensions(); - for (int i = 0; i < extensions.length; i++) { - IConfigurationElement[] elements = extensions[i].getConfigurationElements(); - for (int j = 0; j < elements.length; j++) { - IConfigurationElement element = elements[j]; - if (element.getName().equals(TAG_WIZARD)) { - ConfigurationWizardElement wizard = createWizardElement(element); - if (wizard != null) { - result.add(wizard); - } - } - } - } - } - - return result; - } - /** - * Returns a new ConfigurationWizardElement configured according to the parameters - * contained in the passed Registry. - * - * May answer null if there was not enough information in the Extension to create - * an adequate wizard - * - * @param element the element for which to create a wizard element - * @return the wizard element for the given element - */ - protected ConfigurationWizardElement createWizardElement(IConfigurationElement element) { - // WizardElements must have a name attribute - String nameString = element.getAttribute(ATT_NAME); - if (nameString == null) { - // Missing attribute - return null; - } - ConfigurationWizardElement result = new ConfigurationWizardElement(nameString); - if (initializeWizard(result, element)) { - // initialization was successful - return result; - } - return null; - } - /** - * Initialize the passed element's properties based on the contents of - * the passed registry. Answer a boolean indicating whether the element - * was able to be adequately initialized. - * - * @param element the element to initialize the properties for - * @param extension the registry to get properties from - * @return whether initialization was successful - */ - protected boolean initializeWizard(ConfigurationWizardElement element, IConfigurationElement config) { - element.setID(config.getAttribute(ATT_ID)); - String description = ""; //$NON-NLS-1$ - IConfigurationElement [] children = config.getChildren(TAG_DESCRIPTION); - if (children.length >= 1) { - description = children[0].getValue(); - } - - element.setDescription(description); - - // apply CLASS and ICON properties - element.setConfigurationElement(config); - String iconName = config.getAttribute(ATT_ICON); - if (iconName != null) { - IExtension extension = config.getDeclaringExtension(); - element.setImageDescriptor(TeamUIPlugin.getImageDescriptorFromExtension(extension, iconName)); - } - // ensure that a class was specified - if (element.getConfigurationElement() == null) { - // Missing attribute - return false; - } - setForcePreviousAndNextButtons(true); - return true; - } - /* - * Method declared on IConfigurationWizard - */ - public void init(IWorkbench workbench, IProject project) { - this.workbench = workbench; - this.project = project; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizardMainPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizardMainPage.java deleted file mode 100644 index b0849aa9a..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizardMainPage.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.wizards; - - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ui.IHelpContextIds; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.ui.IConfigurationWizard; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.model.*; - -/** - * The main page of the configure project wizard. It contains a table - * which lists possible team providers with which to configure the project. - * The user may select one and press "Next", which will display a provider- - * specific wizard page. - */ -public class ConfigureProjectWizardMainPage extends WizardPage { - private Table table; - private TableViewer viewer; - private AdaptableList wizards; - private IWorkbench workbench; - private IProject project; - private String description; - - private IConfigurationWizard selectedWizard; - - /** - * Create a new ConfigureProjectWizardMainPage - * - * @param pageName the name of the page - * @param title the title of the page - * @param titleImage the image for the page title - * @param wizards the wizards to populate the table with - */ - public ConfigureProjectWizardMainPage(String pageName, String title, ImageDescriptor titleImage, AdaptableList wizards) { - this(pageName,title,titleImage,wizards,Policy.bind("ConfigureProjectWizardMainPage.selectRepository")); //$NON-NLS-1$ - } - - /** - * Create a new ConfigureProjectWizardMainPage - * - * @param pageName the name of the page - * @param title the title of the page - * @param titleImage the image for the page title - * @param wizards the wizards to populate the table with - * @param description The string to use as a description label - */ - public ConfigureProjectWizardMainPage(String pageName, String title, ImageDescriptor titleImage, AdaptableList wizards, String description) { - super(pageName, title, titleImage); - this.wizards = wizards; - this.description = description; - } - - public IConfigurationWizard getSelectedWizard() { - return selectedWizard; - } - /* - * @see WizardPage#canFlipToNextPage - */ - public boolean canFlipToNextPage() { - return selectedWizard != null && selectedWizard.getPageCount() > 0; - } - /* - * @see WizardPage#createControl - */ - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - setControl(composite); - - // set F1 help - WorkbenchHelp.setHelp(composite, IHelpContextIds.SHARE_PROJECT_PAGE); - - Label label = new Label(composite, SWT.LEFT); - label.setText(description); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - label.setLayoutData(data); - - table = new Table(composite, SWT.SINGLE | SWT.BORDER); - data = new GridData(GridData.FILL_BOTH); - data.heightHint = table.getItemHeight() * 7; - table.setLayoutData(data); - viewer = new TableViewer(table); - viewer.setContentProvider(new WorkbenchContentProvider()); - viewer.setLabelProvider(new WorkbenchLabelProvider()); - viewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - // Initialize the wizard so we can tell whether to enable the Next button - ISelection selection = event.getSelection(); - if (selection == null || !(selection instanceof IStructuredSelection)) { - selectedWizard = null; - setPageComplete(false); - return; - } - IStructuredSelection ss = (IStructuredSelection)selection; - if (ss.size() != 1) { - selectedWizard = null; - setPageComplete(false); - return; - } - ConfigurationWizardElement selectedElement = (ConfigurationWizardElement)ss.getFirstElement(); - try { - selectedWizard = (IConfigurationWizard)selectedElement.createExecutableExtension(); - selectedWizard.init(workbench, project); - } catch (CoreException e) { - return; - } - selectedWizard.addPages(); - - // Ask the container to update button enablement - setPageComplete(true); - } - }); - viewer.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - getWizard().getContainer().showPage(getNextPage()); - } - }); - viewer.setInput(wizards); - Dialog.applyDialogFont(parent); - } - /** - * The <code>WizardSelectionPage</code> implementation of - * this <code>IWizardPage</code> method returns the first page - * of the currently selected wizard if there is one. - * - * @see WizardPage#getNextPage - */ - public IWizardPage getNextPage() { - if (selectedWizard == null) return null; - return selectedWizard.getStartingPage(); - } - /** - * Set the workbench to the argument - * - * @param workbench the workbench to set - */ - public void setWorkbench(IWorkbench workbench) { - this.workbench = workbench; - } - /** - * Set the project to the argument - * - * @param project the project to set - */ - public void setProject(IProject project) { - this.project = project; - } - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - table.setFocus(); - } - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java deleted file mode 100644 index 693f6fd3a..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java +++ /dev/null @@ -1,202 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.wizards; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Text; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.internal.ui.IHelpContextIds; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -public class ExportProjectSetMainPage extends TeamWizardPage { - Text fileText; - String file = ""; //$NON-NLS-1$ - Button browseButton; - List selectedProjects = new ArrayList(); - - CheckboxTableViewer tableViewer; - Table table; - - class ProjectContentProvider extends WorkbenchContentProvider { - public Object[] getElements(Object element) { - if (element instanceof IProject[]) return (IProject[]) element; - return null; - } - }; - - public ExportProjectSetMainPage(String pageName, String title, ImageDescriptor titleImage) { - super(pageName, title, titleImage); - } - - /* - * @see IDialogPage#createControl(Composite) - */ - public void createControl(Composite parent) { - Composite composite = createComposite(parent, 1); - initializeDialogUnits(composite); - - // set F1 help - WorkbenchHelp.setHelp(composite, IHelpContextIds.EXPORT_PROJECT_SET_PAGE); - - createLabel(composite, Policy.bind("ExportProjectSetMainPage.Select_the_projects_to_include_in_the_project_set__2")); //$NON-NLS-1$ - - table = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); - tableViewer = new CheckboxTableViewer(table); - table.setLayout(new TableLayout()); - GridData data = new GridData(GridData.FILL_BOTH); - data.heightHint = 300; - table.setLayoutData(data); - tableViewer.setContentProvider(new ProjectContentProvider()); - tableViewer.setLabelProvider(new WorkbenchLabelProvider()); - tableViewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - IProject project = (IProject)event.getElement(); - if (event.getChecked()) { - selectedProjects.add(project); - } else { - selectedProjects.remove(project); - } - updateEnablement(); - } - }); - createLabel(composite, Policy.bind("ExportProjectSetMainPage.Project_Set_File_Name__3")); //$NON-NLS-1$ - - Composite inner = new Composite(composite, SWT.NULL); - inner.setLayoutData(new GridData(GridData.FILL_BOTH)); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - layout.marginHeight = 0; - layout.marginWidth = 0; - inner.setLayout(layout); - - createLabel(inner, Policy.bind("ExportProjectSetMainPage.&File_name__1")); //$NON-NLS-1$ - fileText = createTextField(inner); - if (file != null) fileText.setText(file); - fileText.addListener(SWT.Modify, new Listener() { - public void handleEvent(Event event) { - file = fileText.getText(); - updateEnablement(); - } - }); - - browseButton = new Button(inner, SWT.PUSH); - browseButton.setText(Policy.bind("ExportProjectSetMainPage.Browse_4")); //$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, browseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); - browseButton.setLayoutData(data); - browseButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - FileDialog d = new FileDialog(getShell(), SWT.SAVE); - d.setFilterExtensions(new String[] {"*.psf"}); //$NON-NLS-1$ - d.setFilterNames(new String[] {Policy.bind("ExportProjectSetMainPage.Project_Set_Files_3")}); //$NON-NLS-1$ - d.setFileName(Policy.bind("ExportProjectSetMainPage.default")); //$NON-NLS-1$ - d.setFilterPath(new File(".").getAbsolutePath()); //$NON-NLS-1$ - String f = d.open(); - if (f != null) { - fileText.setText(f); - file = f; - } - } - }); - - initializeProjects(); - setControl(composite); - updateEnablement(); - Dialog.applyDialogFont(parent); - } - - private void initializeProjects() { - List projectList = new ArrayList(); - IProject[] workspaceProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - for (int i = 0; i < workspaceProjects.length; i++) { - if (RepositoryProvider.getProvider(workspaceProjects[i]) != null) { - projectList.add(workspaceProjects[i]); - } - } - tableViewer.setInput((IProject[]) projectList.toArray(new IProject[projectList.size()])); - // Check any necessary projects - if (selectedProjects != null) { - tableViewer.setCheckedElements((IProject[])selectedProjects.toArray(new IProject[selectedProjects.size()])); - } - } - private void updateEnablement() { - boolean complete; - if (selectedProjects.size() == 0) { - setMessage(null); - complete = false; - } else if (file.length() == 0) { - setMessage(null); - complete = false; - } else { - File f = new File(file); - if (f.isDirectory()) { - setMessage(Policy.bind("ExportProjectSetMainPage.You_have_specified_a_folder_5"), ERROR); //$NON-NLS-1$ - complete = false; - } else { - complete = true; - } - } - if (complete) { - setMessage(null); - } - setPageComplete(complete); - } - - public String getFileName() { - return file; - } - public void setFileName(String file) { - if (file != null) { - this.file = file; - } - } - - public IProject[] getSelectedProjects() { - return (IProject[])selectedProjects.toArray(new IProject[selectedProjects.size()]); - } - public void setSelectedProjects(IProject[] selectedProjects) { - this.selectedProjects.addAll(Arrays.asList(selectedProjects)); - } - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - fileText.setFocus(); - } - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalRefreshWizardSelectionPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalRefreshWizardSelectionPage.java deleted file mode 100644 index 44702cada..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalRefreshWizardSelectionPage.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.wizards; - -import java.util.*; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.wizard.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.registry.SynchronizeWizardDescription; -import org.eclipse.team.internal.ui.synchronize.SynchronizeManager; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.ui.model.BaseWorkbenchContentProvider; -import org.eclipse.ui.views.navigator.ResourceSorter; - -/** - * Page that allows the user to select a set of resources that are managed - * by a synchronize participant. - * - * Remembers last participant - * - * @since 3.0 - */ -public class GlobalRefreshWizardSelectionPage extends WizardPage implements IDoubleClickListener, ISelectionChangedListener { - - private TableViewer fViewer; - private IWizard wizard; - private List createdImages; - - class MyContentProvider extends BaseWorkbenchContentProvider { - public Object[] getChildren(Object element) { - if(element instanceof SynchronizeManager) { - SynchronizeManager manager = (SynchronizeManager)element; - return manager.getWizardDescriptors(); - } - return super.getChildren(element); - } - } - - class MyLabelProvider extends LabelProvider { - public String getText(Object element) { - if(element instanceof SynchronizeWizardDescription) { - SynchronizeWizardDescription descriptor = (SynchronizeWizardDescription)element; - return descriptor.getName(); - } - return null; - } - - public Image getImage(Object element) { - if(element instanceof SynchronizeWizardDescription) { - SynchronizeWizardDescription descriptor = (SynchronizeWizardDescription)element; - ImageDescriptor d = descriptor.getImageDescriptor(); - if(createdImages == null) { - createdImages = new ArrayList(3); - } - Image image = d.createImage(); - createdImages.add(image); - return image; - } - return null; - } - } - - public GlobalRefreshWizardSelectionPage() { - super(Policy.bind("GlobalRefreshParticipantSelectionPage.0")); //$NON-NLS-1$ - setDescription(Policy.bind("GlobalRefreshParticipantSelectionPage.1")); //$NON-NLS-1$ - setTitle(Policy.bind("GlobalRefreshParticipantSelectionPage.2")); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#dispose() - */ - public void dispose() { - if (createdImages != null) { - for (Iterator it = createdImages.iterator(); it.hasNext();) { - Image image = (Image) it.next(); - image.dispose(); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent2) { - Composite top = new Composite(parent2, SWT.NULL); - top.setLayout(new GridLayout()); - setControl(top); - - Label l = new Label(top, SWT.NULL); - l.setText(Policy.bind("GlobalRefreshParticipantSelectionPage.3")); //$NON-NLS-1$ - fViewer = new TableViewer(top, SWT.BORDER); - GridData data = new GridData(GridData.FILL_BOTH); - fViewer.getControl().setLayoutData(data); - fViewer.setContentProvider(new MyContentProvider()); - fViewer.addDoubleClickListener(this); - fViewer.setLabelProvider(new MyLabelProvider()); - fViewer.setSorter(new ResourceSorter(ResourceSorter.NAME)); - fViewer.setInput(TeamUI.getSynchronizeManager()); - fViewer.addSelectionChangedListener(this); - fViewer.getTable().setFocus(); - Dialog.applyDialogFont(parent2); - } - - public void doubleClick(DoubleClickEvent event) { - selectionChanged( - new SelectionChangedEvent( - event.getViewer(), - event.getViewer().getSelection())); - getContainer().showPage(getNextPage()); - } - - public void selectionChanged(SelectionChangedEvent event) { - // Initialize the wizard so we can tell whether to enable the - // Next button - ISelection selection = event.getSelection(); - if (selection == null || !(selection instanceof IStructuredSelection)) { - wizard = null; - setPageComplete(false); - return; - } - IStructuredSelection ss = (IStructuredSelection) selection; - if (ss.size() != 1) { - wizard = null; - setPageComplete(false); - return; - } - SynchronizeWizardDescription selectedDescriptor = (SynchronizeWizardDescription)ss.getFirstElement(); - try { - wizard = selectedDescriptor.createWizard(); - wizard.addPages(); - // Ask the container to update button enablement - setPageComplete(true); - setDescription(selectedDescriptor.getDescription()); - } catch (CoreException e) { - Utils.handle(e); - setPageComplete(false); - } - } - - public IWizard getSelectedWizard() { - return this.wizard; - } - - public IWizardPage getNextPage() { - if (wizard == null) return null; - return wizard.getStartingPage(); - } - - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - fViewer.getTable().setFocus(); - } - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalSynchronizeWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalSynchronizeWizard.java deleted file mode 100644 index 5b269fb42..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/GlobalSynchronizeWizard.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.wizards; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.registry.SynchronizeWizardDescription; -import org.eclipse.team.internal.ui.synchronize.SynchronizeManager; -import org.eclipse.team.ui.ISharedImages; -import org.eclipse.team.ui.TeamImages; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference; -import org.eclipse.ui.IWorkbench; - -/** - * The wizard for synchronizing a synchronize participant. - * - * @since 3.0 - */ -public class GlobalSynchronizeWizard extends Wizard { - - protected IWorkbench workbench; - protected IWizard wizard; - protected GlobalRefreshWizardSelectionPage mainPage; - protected ISynchronizeParticipantReference participant; - - public GlobalSynchronizeWizard() { - setWindowTitle(Policy.bind("GlobalSynchronizeWizard.11")); //$NON-NLS-1$ - setDefaultPageImageDescriptor(TeamImages.getImageDescriptor(ISharedImages.IMG_WIZBAN_SHARE)); - setForcePreviousAndNextButtons(true); - setNeedsProgressMonitor(false); - } - - /* - * @see Wizard#addPages - */ - public void addPages() { - SynchronizeWizardDescription[] wizards = getWizards(); - if (wizards.length == 1) { - // If there is only one wizard, skip the first page. - // Only skip the first page if the one wizard has at least one - // page. - try { - wizard = wizards[0].createWizard(); - wizard.addPages(); - if (wizard.getPageCount() > 0) { - wizard.setContainer(getContainer()); - IWizardPage[] pages = wizard.getPages(); - for (int i = 0; i < pages.length; i++) { - addPage(pages[i]); - } - return; - } - } catch (CoreException e) { - Utils.handle(e); - return; - } - } - mainPage = new GlobalRefreshWizardSelectionPage(); - addPage(mainPage); - } - - public boolean canFinish() { - // If we are on the first page, never allow finish unless the selected - // wizard has no pages. - if (getContainer().getCurrentPage() == mainPage) { - if (mainPage.getSelectedWizard() != null && mainPage.getNextPage() == null) { - return true; - } - return false; - } - if (wizard != null) { - return wizard.canFinish(); - } - return super.canFinish(); - } - - /* - * @see Wizard#performFinish - */ - public boolean performFinish() { - // There is only one wizard with at least one page - if (wizard != null) { - return wizard.performFinish(); - } - // If we are on the first page and the selected wizard has no pages then allow it to finish. - if (getContainer().getCurrentPage() == mainPage) { - IWizard noPageWizard = mainPage.getSelectedWizard(); - if (noPageWizard != null) { - if (noPageWizard.canFinish()) { - return noPageWizard.performFinish(); - } - } - } - return true; - } - - protected SynchronizeWizardDescription[] getWizards() { - SynchronizeManager manager = (SynchronizeManager) TeamUI.getSynchronizeManager(); - return manager.getWizardDescriptors(); - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ImportProjectSetMainPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ImportProjectSetMainPage.java deleted file mode 100644 index e1a5b9133..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ImportProjectSetMainPage.java +++ /dev/null @@ -1,216 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.wizards; - -import java.io.File; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Text; -import org.eclipse.team.internal.ui.IHelpContextIds; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.help.WorkbenchHelp; - -public class ImportProjectSetMainPage extends TeamWizardPage { - Text fileText; - String file = ""; //$NON-NLS-1$ - Button browseButton; - Button createWorkingSetButton; - Text workingSetNameField; - - private boolean createWorkingSet = false; - private String workingSetName = ""; //$NON-NLS-1$ - - // constants - private static final int SIZING_TEXT_FIELD_WIDTH = 80; - - public ImportProjectSetMainPage(String pageName, String title, ImageDescriptor titleImage) { - super(pageName, title, titleImage); - } - - /* - * @see IDialogPage#createControl(Composite) - */ - public void createControl(Composite parent) { - Composite composite = createComposite(parent, 1); - initializeDialogUnits(composite); - - // set F1 help - WorkbenchHelp.setHelp(composite, IHelpContextIds.IMPORT_PROJECT_SET_PAGE); - - Composite inner = new Composite(composite, SWT.NULL); - inner.setLayoutData(new GridData(GridData.FILL_BOTH)); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - layout.marginHeight = 0; - layout.marginWidth = 0; - inner.setLayout(layout); - - createLabel(inner, Policy.bind("ImportProjectSetMainPage.Project_Set_File_Name__2")); //$NON-NLS-1$ - fileText = createTextField(inner); - if (file != null) fileText.setText(file); - fileText.addListener(SWT.Modify, new Listener() { - public void handleEvent(Event event) { - file = fileText.getText(); - updateEnablement(); - } - }); - - browseButton = new Button(inner, SWT.PUSH); - browseButton.setText(Policy.bind("ImportProjectSetMainPage.Browse_3")); //$NON-NLS-1$ - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); - int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); - data.widthHint = Math.max(widthHint, browseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); - browseButton.setLayoutData(data); - browseButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - FileDialog d = new FileDialog(getShell()); - d.setFilterExtensions(new String[] {"*.psf", "*"}); //$NON-NLS-1$ //$NON-NLS-2$ - d.setFilterNames(new String[] {Policy.bind("ImportProjectSetMainPage.Project_Set_Files_2"), Policy.bind("ImportProjectSetMainPage.allFiles")}); //$NON-NLS-1$ //$NON-NLS-2$ - d.setFilterPath(new File(".").getAbsolutePath()); //$NON-NLS-1$ - String f = d.open(); - if (f != null) { - fileText.setText(f); - file = f; - } - } - }); - - createWorkinSetCreationArea(inner, 3); - setControl(composite); - updateEnablement(); - Dialog.applyDialogFont(parent); - } - - /** - * Method createWorkinSetCreationArea. - * @param inner - */ - private void createWorkinSetCreationArea(Composite composite, int numColumns) { - - createWorkingSetButton = new Button(composite, SWT.CHECK | SWT.RIGHT); - createWorkingSetButton.setText(Policy.bind("ImportProjectSetMainPage.createWorkingSetLabel")); //$NON-NLS-1$ - createWorkingSetButton.setSelection(createWorkingSet); - GridData data = new GridData(); - data.horizontalSpan = numColumns; - createWorkingSetButton.setLayoutData(data); - - final Label label = new Label(composite, SWT.NONE); - label.setText(Policy.bind("ImportProjectSetMainPage.workingSetLabel")); //$NON-NLS-1$ - data = new GridData(); - data.horizontalSpan = 1; - label.setLayoutData(data); - label.setEnabled(createWorkingSet); - - workingSetNameField = new Text(composite, SWT.BORDER); - data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = SIZING_TEXT_FIELD_WIDTH; - data.horizontalSpan = 1; - workingSetNameField.setLayoutData(data); - workingSetNameField.setEnabled(createWorkingSet); - - createWorkingSetButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - createWorkingSet = createWorkingSetButton.getSelection(); - label.setEnabled(createWorkingSet); - workingSetNameField.setEnabled(createWorkingSet); - updateEnablement(); - } - }); - workingSetNameField.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - updateEnablement(); - } - }); - } - - private boolean validateWorkingSetName() { - if (createWorkingSet) { - workingSetName = workingSetNameField.getText(); - if (workingSetName.length() == 0) { - setMessage(Policy.bind("ImportProjectSetMainPage.workingSetNameEmpty"), ERROR); //$NON-NLS-1$ - return false; - } else { - // todo: verify name doesn't already exist - IWorkingSet existingSet = TeamUIPlugin.getPlugin().getWorkbench().getWorkingSetManager().getWorkingSet(workingSetName); - if (existingSet != null) { - setMessage(Policy.bind("ImportProjectSetMainPage.workingSetNameExists"), WARNING); //$NON-NLS-1$ - return true; - } - } - } - setMessage(null); - return true; - } - - private void updateEnablement() { - boolean complete; - setMessage(null); - if (file.length() == 0) { - complete = false; - } else { - // See if the file exists - File f = new File(file); - if (!f.exists()) { - setMessage(Policy.bind("ImportProjectSetMainPage.The_specified_file_does_not_exist_4"), ERROR); //$NON-NLS-1$ - complete = false; - } else if (f.isDirectory()) { - setMessage(Policy.bind("ImportProjectSetMainPage.You_have_specified_a_folder_5"), ERROR); //$NON-NLS-1$ - complete = false; - } else { - complete = validateWorkingSetName(); - } - } - setPageComplete(complete); - } - - public String getFileName() { - return file; - } - public void setFileName(String file) { - if (file != null) { - this.file = file; - } - } - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - fileText.setFocus(); - } - } - - /** - * @return String - */ - public String getWorkingSetName() { - if (!createWorkingSet) return null; - return workingSetName; - } - -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard.java deleted file mode 100644 index 64bb068d5..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard.java +++ /dev/null @@ -1,191 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.wizards; - -import java.io.*; -import java.lang.reflect.InvocationTargetException; -import java.util.*; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.*; -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.ISharedImages; -import org.eclipse.ui.IExportWizard; -import org.eclipse.ui.IWorkbench; - -public class ProjectSetExportWizard extends Wizard implements IExportWizard { - ExportProjectSetMainPage mainPage; - IStructuredSelection selection; - - public ProjectSetExportWizard() { - setNeedsProgressMonitor(true); - setWindowTitle(Policy.bind("ProjectSetExportWizard.Project_Set_1")); //$NON-NLS-1$ - } - - public void addPages() { - mainPage = new ExportProjectSetMainPage("projectSetMainPage", Policy.bind("ProjectSetExportWizard.Export_a_Project_Set_3"), TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_PROJECTSET_EXPORT_BANNER)); //$NON-NLS-1$ //$NON-NLS-2$ - IProject[] projects = (IProject[])selection.toList().toArray(new IProject[0]); - mainPage.setSelectedProjects(projects); - mainPage.setFileName(ProjectSetImportWizard.lastFile); - addPage(mainPage); - } - public boolean performFinish() { - final boolean[] result = new boolean[] {false}; - try { - getContainer().run(false, false, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - String filename = mainPage.getFileName(); - Path path = new Path(filename); - if (path.getFileExtension() == null) { - filename = filename + ".psf"; //$NON-NLS-1$ - } - ProjectSetImportWizard.lastFile = filename; - File file = new File(filename); - File parentFile = file.getParentFile(); - if (parentFile != null && !parentFile.exists()) { - boolean r = MessageDialog.openQuestion(getShell(), Policy.bind("ProjectSetExportWizard.Question_4"), Policy.bind("ProjectSetExportWizard.Target_directory_does_not_exist._Would_you_like_to_create_it__5")); //$NON-NLS-1$ //$NON-NLS-2$ - if (!r) { - result[0] = false; - return; - } - r = parentFile.mkdirs(); - if (!r) { - MessageDialog.openError(getShell(), Policy.bind("ProjectSetExportWizard.Export_Problems_6"), Policy.bind("ProjectSetExportWizard.An_error_occurred_creating_the_target_directory_7")); //$NON-NLS-1$ //$NON-NLS-2$ - result[0] = false; - return; - } - } - if (file.exists() && file.isFile()) { - boolean r = MessageDialog.openQuestion(getShell(), Policy.bind("ProjectSetExportWizard.Question_8"), Policy.bind("ProjectSetExportWizard.Target_already_exists._Would_you_like_to_overwrite_it__9")); //$NON-NLS-1$ //$NON-NLS-2$ - if (!r) { - result[0] = false; - return; - } - } - - // Hash the projects by provider - IProject[] projects = mainPage.getSelectedProjects(); - Map map = new HashMap(); - for (int i = 0; i < projects.length; i++) { - IProject project = projects[i]; - RepositoryProvider provider = RepositoryProvider.getProvider(project); - if (provider != null) { - String id = provider.getID(); - List list = (List)map.get(id); - if (list == null) { - list = new ArrayList(); - map.put(id, list); - } - list.add(project); - } - } - - Shell shell = getShell(); - UIProjectSetSerializationContext context = new UIProjectSetSerializationContext(getShell()); - - BufferedWriter writer = null; - try { - writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); //$NON-NLS-1$ - - writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //$NON-NLS-1$ - writer.newLine(); - writer.write("<psf version=\"2.0\">"); //$NON-NLS-1$ - writer.newLine(); - - // For each provider id, do the writing - - Iterator it = map.keySet().iterator(); - monitor.beginTask(null, 1000 * map.keySet().size()); - while (it.hasNext()) { - String id = (String)it.next(); - writer.write("\t<provider id=\""); //$NON-NLS-1$ - writer.write(id); - writer.write("\">"); //$NON-NLS-1$ - writer.newLine(); - List list = (List)map.get(id); - IProject[] projectArray = (IProject[])list.toArray(new IProject[list.size()]); - RepositoryProviderType providerType = RepositoryProviderType.getProviderType(id); - ProjectSetCapability serializer = providerType.getProjectSetCapability(); - ProjectSetCapability.ensureBackwardsCompatible(providerType, serializer); - if (serializer != null) { - String[] references = serializer.asReference(projectArray, context, new SubProgressMonitor(monitor, 990)); - for (int i = 0; i < references.length; i++) { - writer.write("\t\t<project reference=\""); //$NON-NLS-1$ - writer.write(references[i]); - writer.write("\"/>"); //$NON-NLS-1$ - writer.newLine(); - } - } - writer.write("\t</provider>"); //$NON-NLS-1$ - writer.newLine(); - } - writer.write("</psf>"); //$NON-NLS-1$ - writer.newLine(); - result[0] = true; - } catch (IOException e) { - throw new InvocationTargetException(e); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } finally { - if (writer != null) { - try { - writer.close(); - } catch (IOException e) { - throw new InvocationTargetException(e); - } - } - } - - // notify provider types of the project set write - for (Iterator iter = map.keySet().iterator();iter.hasNext();) { - String id = (String) iter.next(); - RepositoryProviderType type = RepositoryProviderType.getProviderType(id); - if (type != null) { - ProjectSetCapability capability = type.getProjectSetCapability(); - if (capability != null) { - capability.projectSetCreated(file, context, new SubProgressMonitor(monitor, 10)); - } - } - } - - monitor.done(); - } - }); - } catch (InterruptedException e) { - return true; - } catch (InvocationTargetException e) { - Throwable target = e.getTargetException(); - if (target instanceof TeamException) { - ErrorDialog.openError(getShell(), null, null, ((TeamException)target).getStatus()); - return false; - } - if (target instanceof RuntimeException) { - throw (RuntimeException)target; - } - if (target instanceof Error) { - throw (Error)target; - } - } - return result[0]; - } - - public void init(IWorkbench workbench, IStructuredSelection selection) { - this.selection = selection; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetImportWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetImportWizard.java deleted file mode 100644 index 40e2fcaae..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetImportWizard.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.wizards; - -import java.io.*; -import java.lang.reflect.InvocationTargetException; -import java.util.*; -import javax.xml.parsers.*; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.team.core.*; -import org.eclipse.team.internal.ui.*; -import org.eclipse.team.ui.ISharedImages; -import org.eclipse.ui.*; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -public class ProjectSetImportWizard extends Wizard implements IImportWizard { - ImportProjectSetMainPage mainPage; - public static String lastFile; - - public ProjectSetImportWizard() { - setNeedsProgressMonitor(true); - setWindowTitle(Policy.bind("ProjectSetImportWizard.Project_Set_1")); //$NON-NLS-1$ - } - - public void addPages() { - mainPage = new ImportProjectSetMainPage("projectSetMainPage", Policy.bind("ProjectSetImportWizard.Import_a_Project_Set_3"), TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_PROJECTSET_IMPORT_BANNER)); //$NON-NLS-1$ //$NON-NLS-2$ - mainPage.setFileName(lastFile); - addPage(mainPage); - } - public boolean performFinish() { - - // check if the desired working set exists - final String workingSetName = mainPage.getWorkingSetName(); - if (workingSetName != null) { - IWorkingSet existingSet = TeamUIPlugin.getPlugin().getWorkbench().getWorkingSetManager().getWorkingSet(workingSetName); - if (existingSet != null && - !MessageDialog.openConfirm(getShell(), Policy.bind("ProjectSetImportWizard.workingSetExistsTitle"), Policy.bind("ProjectSetImportWizard.workingSetExistsMessage", workingSetName))) //$NON-NLS-1$ //$NON-NLS-2$ - return false; - } - - final boolean[] result = new boolean[] {false}; - try { - getContainer().run(true, true, new WorkspaceModifyOperation(null) { - public void execute(IProgressMonitor monitor) throws InvocationTargetException { - InputStreamReader reader = null; - try { - String filename = mainPage.getFileName(); - lastFile = filename; - reader = new InputStreamReader(new FileInputStream(filename), "UTF-8"); //$NON-NLS-1$ - - SAXParserFactory factory = SAXParserFactory.newInstance(); - SAXParser parser = factory.newSAXParser(); - ProjectSetContentHandler handler = new ProjectSetContentHandler(); - InputSource source = new InputSource(reader); - parser.parse(source, handler); - - Map map = handler.getReferences(); - List newProjects = new ArrayList(); - if (map.size() == 0 && handler.isVersionOne()) { - IProjectSetSerializer serializer = Team.getProjectSetSerializer("versionOneSerializer"); //$NON-NLS-1$ - if (serializer != null) { - IProject[] projects = serializer.addToWorkspace(new String[0], filename, getShell(), monitor); - if (projects != null) - newProjects.addAll(Arrays.asList(projects)); - } - } else { - UIProjectSetSerializationContext context = new UIProjectSetSerializationContext(getShell()); - Iterator it = map.keySet().iterator(); - while (it.hasNext()) { - String id = (String)it.next(); - List references = (List)map.get(id); - RepositoryProviderType providerType = RepositoryProviderType.getProviderType(id); - ProjectSetCapability serializer = providerType.getProjectSetCapability(); - ProjectSetCapability.ensureBackwardsCompatible(providerType, serializer); - if (serializer != null) { - IProject[] projects = serializer.addToWorkspace((String[])references.toArray(new String[references.size()]), context, monitor); - if (projects != null) - newProjects.addAll(Arrays.asList(projects)); - } - } - } - if (workingSetName != null) - createWorkingSet(workingSetName, (IProject[]) newProjects.toArray(new IProject[newProjects.size()])); - result[0] = true; - } catch (IOException e) { - throw new InvocationTargetException(e); - } catch (SAXException e) { - throw new InvocationTargetException(e); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } catch (ParserConfigurationException e) { - throw new InvocationTargetException(e); - } finally { - if (reader != null) { - try { - reader.close(); - } catch (IOException e) { - throw new InvocationTargetException(e); - } - } - } - } - }); - } catch (InterruptedException e) { - return true; - } catch (InvocationTargetException e) { - Throwable target = e.getTargetException(); - if (target instanceof TeamException) { - ErrorDialog.openError(getShell(), null, null, ((TeamException)target).getStatus()); - return false; - } - if (target instanceof RuntimeException) { - throw (RuntimeException)target; - } - if (target instanceof Error) { - throw (Error)target; - } - } - return result[0]; - } - - /* private */ void createWorkingSet(String workingSetName, IProject[] projects) { - IWorkingSetManager manager = TeamUIPlugin.getPlugin().getWorkbench().getWorkingSetManager(); - IWorkingSet oldSet = manager.getWorkingSet(workingSetName); - if (oldSet == null) { - IWorkingSet newSet = manager.createWorkingSet(workingSetName, projects); - manager.addWorkingSet(newSet); - }else { - oldSet.setElements(projects); - } - } - - public void init(IWorkbench workbench, IStructuredSelection selection) { - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/TeamWizardPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/TeamWizardPage.java deleted file mode 100644 index a38c5c28d..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/TeamWizardPage.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.wizards; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -public abstract class TeamWizardPage extends WizardPage { - /** - * CVSWizardPage constructor comment. - * @param pageName the name of the page - */ - public TeamWizardPage(String pageName) { - super(pageName); - } - /** - * CVSWizardPage constructor comment. - * @param pageName the name of the page - * @param title the title of the page - * @param titleImage the image for the page - */ - public TeamWizardPage(String pageName, String title, ImageDescriptor titleImage) { - super(pageName, title, titleImage); - } - /** - * 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); - - // 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; - } - /** - * Utility method that creates a label instance - * and sets the default layout data. - * - * @param parent the parent for the new label - * @param text the text for the new label - * @return the new label - */ - protected Label createLabel(Composite parent, String text) { - return createIndentedLabel(parent, text, 0); - } - /** - * Utility method that creates a label instance indented by the specified - * number of pixels and sets the default layout data. - * - * @param parent the parent for the new label - * @param text the text for the new label - * @param indent the indent in pixels, or 0 for none - * @return the new label - */ - protected Label createIndentedLabel(Composite parent, String text, int indent) { - Label label = new Label(parent, SWT.LEFT); - label.setText(text); - GridData data = new GridData(); - data.horizontalSpan = 1; - data.horizontalAlignment = GridData.FILL; - data.horizontalIndent = indent; - label.setLayoutData(data); - return label; - } - /** - * Create a text field specific for this application - * - * @param parent the parent of the new text field - * @return the new text field - */ - protected Text createTextField(Composite parent) { - Text text = new Text(parent, SWT.SINGLE | SWT.BORDER); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.verticalAlignment = GridData.CENTER; - data.grabExcessVerticalSpace = false; - data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; - text.setLayoutData(data); - return text; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IConfigurationWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IConfigurationWizard.java deleted file mode 100644 index 4f218794f..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IConfigurationWizard.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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; - - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.ui.IWorkbench; - -/** - * IConfigurationWizard defines the interface that users of the extension - * point org.eclipse.team.ui.configurationWizards must implement. - */ -public interface IConfigurationWizard extends IWizard { - /** - * Initializes this creation wizard using the passed workbench and - * object selection. - * <p> - * This method is called after the no argument constructor and - * before other methods are called. - * </p> - * - * @param workbench the current workbench - * @param project the selected project - */ - void init(IWorkbench workbench, IProject project); -} - diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/ISaveableWorkbenchPart.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/ISaveableWorkbenchPart.java deleted file mode 100644 index 5a6f90e64..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/ISaveableWorkbenchPart.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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; - -import org.eclipse.ui.ISaveablePart; -import org.eclipse.ui.IWorkbenchPart; - -public interface ISaveableWorkbenchPart extends ISaveablePart, IWorkbenchPart { - - /** - * The property id for <code>isDirty</code>. - */ - public static final int PROP_DIRTY = ISaveableWorkbenchPart.PROP_DIRTY; -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/ISharedImages.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/ISharedImages.java deleted file mode 100644 index 3d729cad8..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/ISharedImages.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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; - -/** - * Images that are available for providers to re-use. They include - * common overlays and wizard images. A provider can use their own - * custom images, these shared images are only available for - * convenience. - */ -public interface ISharedImages { - public final String IMG_DIRTY_OVR = "ovr/dirty_ov.gif"; //$NON-NLS-1$ - public final String IMG_CHECKEDIN_OVR = "ovr/version_controlled.gif"; //$NON-NLS-1$ - public final String IMG_CHECKEDOUT_OVR = "ovr/checkedout_ov.gif"; //$NON-NLS-1$ - public final String IMG_CONFLICT_OVR = "ovr/confchg_ov.gif"; //$NON-NLS-1$ - public final String IMG_ERROR_OVR = "ovr/error_co.gif"; //$NON-NLS-1$ - public final String IMG_WARNING_OVR = "ovr/warning_co.gif"; //$NON-NLS-1$ - public final String IMG_HOURGLASS_OVR = "ovr/waiting_ovr.gif"; //$NON-NLS-1$ - - public final String IMG_COLLAPSE_ALL = "clcl16/collapseall.gif"; //$NON-NLS-1$ - public final String IMG_COLLAPSE_ALL_ENABLED = "elcl16/collapseall.gif"; //$NON-NLS-1$ - - public final String IMG_SYNC_VIEW = "eview16/synch_synch.gif"; //$NON-NLS-1$ - - // local toolbars (colour) - public final String IMG_DLG_SYNC_INCOMING = "elcl16/incom_synch.gif"; //$NON-NLS-1$ - public final String IMG_DLG_SYNC_OUTGOING = "elcl16/outgo_synch.gif"; //$NON-NLS-1$ - public final String IMG_DLG_SYNC_CONFLICTING = "elcl16/conflict_synch.gif"; //$NON-NLS-1$ - public final String IMG_REFRESH = "elcl16/refresh.gif"; //$NON-NLS-1$ - public final String IMG_IGNORE_WHITESPACE = "elcl16/ignorews_edit.gif"; //$NON-NLS-1$ - public final String IMG_CONTENTS = "elcl16/contents.gif"; //$NON-NLS-1$ - - // local toolbars (disabled) - public final String IMG_DLG_SYNC_INCOMING_DISABLED = "dlcl16/incom_synch.gif"; //$NON-NLS-1$ - public final String IMG_DLG_SYNC_OUTGOING_DISABLED = "dlcl16/outgo_synch.gif"; //$NON-NLS-1$ - public final String IMG_DLG_SYNC_CONFLICTING_DISABLED = "dlcl16/conflict_synch.gif"; //$NON-NLS-1$ - public final String IMG_REFRESH_DISABLED = "dlcl16/refresh.gif"; //$NON-NLS-1$ - public final String IMG_IGNORE_WHITESPACE_DISABLED = "dlcl16/ignorews_edit.gif"; //$NON-NLS-1$ - public final String IMG_CONTENTS_DISABLED = "dlcl16/contents.gif"; //$NON-NLS-1$ - - // local toolbars (enabled) - public final String IMG_DLG_SYNC_INCOMING_ENABLED = "elcl16/incom_synch.gif"; //$NON-NLS-1$ - public final String IMG_DLG_SYNC_OUTGOING_ENABLED = "elcl16/outgo_synch.gif"; //$NON-NLS-1$ - public final String IMG_DLG_SYNC_CONFLICTING_ENABLED = "elcl16/conflict_synch.gif"; //$NON-NLS-1$ - public final String IMG_REFRESH_ENABLED = "elcl16/refresh.gif"; //$NON-NLS-1$ - public final String IMG_IGNORE_WHITESPACE_ENABLED = "elcl16/ignorews_edit.gif"; //$NON-NLS-1$ - public final String IMG_CONTENTS_ENABLED = "elcl16/contents.gif"; //$NON-NLS-1$ - - // sync view modes - public final String IMG_SYNC_MODE_CATCHUP = "elcl16/catchup_rls.gif"; //$NON-NLS-1$ - public final String IMG_SYNC_MODE_RELEASE = "elcl16/release_rls.gif"; //$NON-NLS-1$ - public final String IMG_SYNC_MODE_FREE = "elcl16/catchuprelease_rls.gif"; //$NON-NLS-1$ - - // sync view modes (disabled) - public final String IMG_SYNC_MODE_CATCHUP_DISABLED = "dlcl16/catchup_rls.gif"; //$NON-NLS-1$ - public final String IMG_SYNC_MODE_RELEASE_DISABLED = "dlcl16/release_rls.gif"; //$NON-NLS-1$ - public final String IMG_SYNC_MODE_FREE_DISABLED = "dlcl16/catchuprelease_rls.gif"; //$NON-NLS-1$ - - // sync view modes (enabled) - public final String IMG_SYNC_MODE_CATCHUP_ENABLED = "elcl16/catchup_rls.gif"; //$NON-NLS-1$ - public final String IMG_SYNC_MODE_RELEASE_ENABLED = "elcl16/release_rls.gif"; //$NON-NLS-1$ - public final String IMG_SYNC_MODE_FREE_ENABLED = "elcl16/catchuprelease_rls.gif"; //$NON-NLS-1$ - - // wizard banners - public final String IMG_WIZBAN_SHARE = "wizban/share_wizban.gif"; //$NON-NLS-1$ - public final String IMG_PROJECTSET_IMPORT_BANNER = "wizban/import_projectset_wizban.gif"; //$NON-NLS-1$ - public final String IMG_PROJECTSET_EXPORT_BANNER = "wizban/export_projectset_wizban.gif"; //$NON-NLS-1$ - public final String IMG_KEY_LOCK = "wizban/keylock.gif"; //$NON-NLS-1$ - - //objects - public final String IMG_SITE_ELEMENT = "elcl16/site_element.gif"; //$NON-NLS-1$ - public final String IMG_CHANGE_FILTER = "elcl16/change_filter.gif"; //$NON-NLS-1$ - public final String IMG_COMPRESSED_FOLDER = "obj/compressed_folder_obj.gif"; //$NON-NLS-1$ - public final String IMG_HIERARCHICAL = "elcl16/hierarchicalLayout.gif"; //$NON-NLS-1$ -} - diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/ITeamUIConstants.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/ITeamUIConstants.java deleted file mode 100644 index 951f3d25b..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/ITeamUIConstants.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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; - -public interface ITeamUIConstants { - - // extension points - public static final String PT_SYNCHRONIZE_WIZARDS = "synchronizeWizards"; //$NON-NLS-1$ - public static final String PT_SYNCPARTICIPANTS = "synchronizeParticipants"; //$NON-NLS-1$ - public static final String PT_CONFIGURATION ="configurationWizards"; //$NON-NLS-1$ - public static final String PT_TARGETCONFIG ="targetConfigWizards"; //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartAdapter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartAdapter.java deleted file mode 100644 index 05fc563df..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartAdapter.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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; - -import org.eclipse.ui.*; - -/** - * This adapter provides default implementations for methods on {@link ISaveableWorkbenchPart} and - * {@link IWorkbenchPart}. - * <p> - * Classes that want to implement a saveable part can simply implement the methods that - * they need while accepting the provided defaults for most of the methods. - * </p> - * @see SaveablePartDialog - * @since 3.0 - */ -public abstract class SaveablePartAdapter implements ISaveableWorkbenchPart { - - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveablePart#doSaveAs() - */ - public void doSaveAs() { - // TODO Auto-generated method stub - } - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed() - */ - public boolean isSaveAsAllowed() { - // TODO Auto-generated method stub - return false; - } - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveablePart#isSaveOnCloseNeeded() - */ - public boolean isSaveOnCloseNeeded() { - // TODO Auto-generated method stub - return false; - } - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#addPropertyListener(org.eclipse.ui.IPropertyListener) - */ - public void addPropertyListener(IPropertyListener listener) { - // TODO Auto-generated method stub - } - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#dispose() - */ - public void dispose() { - // TODO Auto-generated method stub - } - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#getSite() - */ - public IWorkbenchPartSite getSite() { - // TODO Auto-generated method stub - return null; - } - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#getTitleToolTip() - */ - public String getTitleToolTip() { - // TODO Auto-generated method stub - return null; - } - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#removePropertyListener(org.eclipse.ui.IPropertyListener) - */ - public void removePropertyListener(IPropertyListener listener) { - // TODO Auto-generated method stub - } - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#setFocus() - */ - public void setFocus() { - // TODO Auto-generated method stub - } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - // TODO Auto-generated method stub - return null; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartDialog.java deleted file mode 100644 index 8415e18e2..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartDialog.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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; - -import org.eclipse.compare.internal.ResizableDialog; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ui.Policy; - -/** - * A dialog that displays a {@link org.eclipse.team.ui.SaveablePartAdapter} and - * ensures that changes made to the input are saved when the dialog is closed. - * - * @see SaveablePartAdapter - * @since 3.0 - */ -public class SaveablePartDialog extends ResizableDialog { - - private ISaveableWorkbenchPart input; - private Button saveButton; - - /** - * Creates a dialog with the given title and input. The input is not created until the dialog - * is opened. - * - * @param shell the parent shell or <code>null</code> to create a top level shell. - * @param title the shell's title - * @param input the compare input to show in the dialog - */ - public SaveablePartDialog(Shell shell, ISaveableWorkbenchPart input) { - super(shell, null); - this.input = input; - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected void createButtonsForButtonBar(Composite parent) { - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected Control createDialogArea(Composite parent2) { - Composite parent = (Composite) super.createDialogArea(parent2); - input.createPartControl(parent); - Shell shell = getShell(); - shell.setText(input.getTitle()); - shell.setImage(input.getTitleImage()); - Dialog.applyDialogFont(parent2); - return parent; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) - */ - protected void buttonPressed(int buttonId) { - saveChanges(); - super.buttonPressed(buttonId); - } - - /* (non-Javadoc) - * @see org.eclipse.compare.internal.ResizableDialog#close() - */ - public boolean close() { - saveChanges(); - return super.close(); - } - - /** - * Save any changes to the compare editor. - */ - private void saveChanges() { - if (input.isDirty() && MessageDialog.openConfirm(getShell(), Policy.bind("ParticipantCompareDialog.2"), Policy.bind("ParticipantCompareDialog.3"))) { //$NON-NLS-1$ //$NON-NLS-2$ - BusyIndicator.showWhile(null, new Runnable() { - public void run() { - input.doSave(new NullProgressMonitor()); - } - }); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamImages.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamImages.java deleted file mode 100644 index 5af378995..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamImages.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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; - -import org.eclipse.core.runtime.IExtension; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.internal.ui.TeamUIPlugin; - -/** - * TeamImages provides convenience methods for accessing shared images - * provided by the org.eclipse.team.ui plug-in. - * <p> - * This class provides <code>Image</code> and <code>ImageDescriptor</code>s - * for each named image in the interface. All <code>Image</code> objects provided - * by this class are managed by this class and must never be disposed - * by other clients. - * </p> - */ -public class TeamImages { - /** - * Returns the image descriptor for the given image ID. - * Returns null if there is no such image. - * - * @param id the identifier for the image to retrieve - * @return the image associated with the given ID - */ - public static ImageDescriptor getImageDescriptor(String id) { - return TeamUIPlugin.getImageDescriptor(id); - } - /** - * Convenience method to get an image descriptor for an extension - * - * @param extension the extension declaring the image - * @param subdirectoryAndFilename the path to the image - * @return the image - */ - public static ImageDescriptor getImageDescriptorFromExtension(IExtension extension, String subdirectoryAndFilename) { - return TeamUIPlugin.getImageDescriptorFromExtension(extension, subdirectoryAndFilename); - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamOperation.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamOperation.java deleted file mode 100644 index 2eceb112c..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamOperation.java +++ /dev/null @@ -1,239 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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; - -import java.lang.reflect.InvocationTargetException; -import java.net.URL; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.core.runtime.jobs.JobChangeAdapter; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.actions.*; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchSite; - -/** - * An operation that can be configured to run in the foreground using - * the {@link org.eclipse.ui.progress.IProgressService} or the background - * as a {@link org.eclipse.core.runtime.Job}. The execution context is determined - * by what is returned by the {@link #canRunAsJob()} hint which may be overriden by subclasses. - * Subsclass must override the <code>run(IProgressMonitor)</code> method to perform - * the behavior of the operation in the desired execution context. - * <p> - * If this operation is run as a job, it is registered with the job as a - * {@link org.eclipse.core.runtime.jobs.IJobChangeListener} and is scheduled with - * the part of this operation if it is not <code>null</code>. - * Subsclasses can override the methods of this - * interface to receive job change notificaton. - * - * @see org.eclipse.ui.progress.IProgressService - * @see org.eclipse.core.runtime.Job - * @see org.eclipse.core.runtime.ISchedulingRule - * @see org.eclipse.core.runtime.jobs.IJobChangeListener - */ -public abstract class TeamOperation extends JobChangeAdapter implements IRunnableWithProgress { - - private IWorkbenchPart part; - private IRunnableContext context; - - /** - * Create an team operation associated with the given part. - * @param part the part the operation is associated with or <code>null</code> - */ - protected TeamOperation(IWorkbenchPart part) { - this(part, null); - } - - /** - * Create an team operation that will run in the given context. - * @param context a runnable context - */ - protected TeamOperation(IRunnableContext context) { - this(null, context); - } - - /** - * Create an team operation associated with the given part - * that will run in the given context. - * @param part the part the operation is associated with or <code>null</code> - * @param context a runnable context - */ - protected TeamOperation(IWorkbenchPart part, IRunnableContext context) { - this.part = part; - this.context = context; - } - - /** - * Return the part that is associated with this operation. - * @return Returns the part or <code>null</code> - */ - public IWorkbenchPart getPart() { - return part; - } - - /** - * Run the operation in a context that is determined by the <code>canRunAsJob()</code> - * hint. If this operation can run as a job then it will be run in a background thread. - * Otherwise it will run in the foreground and block the caller. - */ - public final void run() throws InvocationTargetException, InterruptedException { - if (shouldRun()) { - getRunnableContext().run(this); - } - } - - /** - * This method is invoked from the <code>run()</code> method before - * the operation is run in the operation's context. Subclasses may - * override in order to perform prechecks to determine if the operation - * should run. This may include prompting the user for information, etc. - * @return whether the operation should be run. - */ - protected boolean shouldRun() { - return true; - } - - /** - * Returns the scheduling rule that is to be obtained before this - * operation is executed by it's context or <code>null</code> if - * no scheduling rule is to be obtained. If the operation is run - * as a job, the schdulin rule is used as the schduling rule of the - * job. Otherwise, it is obtained before execution of the operation - * occurs. - * <p> - * By default, no scheduling - * rule is obtained. Sublcasses can override to in order ot obtain a - * scheduling rule or can obtain schduling rules withing their operation - * if finer grained schduling is desired. - * @return the schduling rule to be obtained by this operation - * or <code>null</code> - */ - protected ISchedulingRule getSchedulingRule() { - return null; - } - - /** - * Return whether the auto-build should be postponed until after - * the operation is complete. The default is to postpone the auto-build. - * subclas can override. - * @return whether to postpone the auto-build while the operation is executing - */ - protected boolean isPostponeAutobuild() { - return true; - } - - /** - * If this operation can safely be run in the background, then subclasses can - * override this method and return <code>true</code>. This will make their - * action run in a {@link org.eclipse.core.runtime.Job}. - * Subsclass that override this method should - * also override the <code>getJobName()</code> method. - * - * @return <code>true</code> if this action can be run in the background and - * <code>false</code> otherwise. - */ - protected boolean canRunAsJob() { - return false; - } - - /** - * Return the job name to be used if the action can run as a job. (i.e. - * if <code>canRunAsJob()</code> returns <code>true</code>). - * - * @return the string to be used as the job name - */ - protected String getJobName() { - return ""; //$NON-NLS-1$ - } - - /** - * This method is called to allow subclasses to configure an action that could be run to show - * the results of the action to the user. Default is to return null. - * @return an action that could be run to see the results of this operation - */ - protected IAction getGotoAction() { - return null; - } - - /** - * This method is called to allow subclasses to configure an icon to show when running this - * operation. - * @return an URL to an icon - */ - protected URL getOperationIcon() { - return null; - } - - /** - * This method is called to allow subclasses to have the operation remain in the progress - * indicator even after the job is done. - * @return <code>true</code> to keep the operation and <code>false</code> otherwise. - */ - protected boolean getKeepOperation() { - return false; - } - - /** - * Return a shell that can be used by the operation to display dialogs, etc. - * @return a shell - */ - protected Shell getShell() { - final Shell[] shell = new Shell[] { null }; - if (canRunAsJob()) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - shell[0] = Utils.getShell(getSite()); - } - }); - } else { - shell[0] = Utils.getShell(getSite()); - } - return shell[0]; - } - - /* - * Uses the {@link #canRunAsJob()} hint to return a {@link ITeamRunnableContext} - * that is used to execute the <code>run(SyncInfoSet, IProgressMonitor)</code> - * method of this action. - * - * @param syncSet the sync info set containing the selected elements for which this - * action is enabled. - * @return the runnable context in which to run this action. - */ - private ITeamRunnableContext getRunnableContext() { - if (context == null && canRunAsJob()) { - JobRunnableContext context = new JobRunnableContext(getJobName(), getOperationIcon(), getGotoAction(), getKeepOperation(), this, getSite()); - context.setPostponeBuild(isPostponeAutobuild()); - context.setSchedulingRule(getSchedulingRule()); - return context; - } else { - ProgressDialogRunnableContext context = new ProgressDialogRunnableContext(getShell()); - context.setPostponeBuild(isPostponeAutobuild()); - context.setSchedulingRule(getSchedulingRule()); - if (this.context != null) { - context.setRunnableContext(this.context); - } - return context; - } - } - - private IWorkbenchSite getSite() { - IWorkbenchSite site = null; - if(part != null) { - site = part.getSite(); - } - return site; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java deleted file mode 100644 index 29a752129..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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; - -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.internal.ui.synchronize.SynchronizeManager; -import org.eclipse.team.ui.synchronize.ISynchronizeManager; - -/** - * TeamUI contains public API for generic UI-based Team functionality - */ -public class TeamUI { - - // manages synchronize participants - private static ISynchronizeManager synchronizeManager; - - /** - * Property constant indicating the global ignores list has changed. - */ - public static String GLOBAL_IGNORES_CHANGED = TeamUIPlugin.ID + "global_ignores_changed"; //$NON-NLS-1$ - - /** - * Return the synchronize manager. - * - * @return the synchronize manager - * @since 3.0 - */ - public static ISynchronizeManager getSynchronizeManager() { - if (synchronizeManager == null) { - synchronizeManager = new SynchronizeManager(); - } - return synchronizeManager; - } - - /** - * Register for changes made to Team properties. - * - * @param listener the listener to add - */ - public static void addPropertyChangeListener(IPropertyChangeListener listener) { - TeamUIPlugin.addPropertyChangeListener(listener); - } - - /** - * Deregister as a Team property changes. - * - * @param listener the listener to remove - */ - public static void removePropertyChangeListener(IPropertyChangeListener listener) { - TeamUIPlugin.removePropertyChangeListener(listener); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/package.html b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/package.html deleted file mode 100644 index 8a222f458..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/package.html +++ /dev/null @@ -1,21 +0,0 @@ -<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> -<html> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> - <meta name="Author" content="IBM"> - <title>Package-level Javadoc</title> -</head> -<body> -Provides basic support for managing Team providers. -<h2>Package Specification</h2> -<p>This package specifies the API for integrating Team support plug-ins into -the workbench. This support includes:</p> -<ul> -<li>A set of common images for enabling a common Team look in the workbench. -<li>A configuration wizard extension for allowing Team providers to associate their -provider with a project in the workspace. -<li>A synchronization infrastructure to allow Team providers to extend or participate -in the Synchronize View. -</ul> -</body> -</html>
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeParticipant.java deleted file mode 100644 index 3f6726753..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeParticipant.java +++ /dev/null @@ -1,323 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.ISafeRunnable; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.ListenerList; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.IBasicPropertyConstants; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.registry.SynchronizeParticipantDescriptor; -import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration; -import org.eclipse.team.ui.TeamImages; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.PartInitException; - -/** - * AbstractSynchronizeParticipant is the abstract base class for all - * synchronize view participants. It provides default lifecycle support - * for participants. - * - * @see ISynchronizeParticipant - * @since 3.0 - */ -public abstract class AbstractSynchronizeParticipant implements ISynchronizeParticipant { - - private final static String CTX_PINNED = "root"; //$NON-NLS-1$ - - // property listeners - private ListenerList fListeners; - - private String fName; - private String fId; - private String fSecondaryId; - private boolean pinned; - private ImageDescriptor fImageDescriptor; - protected IConfigurationElement configElement; - - /** - * Notifies listeners of property changes, handling any exceptions - */ - class PropertyNotifier implements ISafeRunnable { - - private IPropertyChangeListener fListener; - private PropertyChangeEvent fEvent; - - /** - * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable) - */ - public void handleException(Throwable exception) { - TeamUIPlugin.log(IStatus.ERROR, Policy.bind("AbstractSynchronizeParticipant.5"), exception); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.core.runtime.ISafeRunnable#run() - */ - public void run() throws Exception { - fListener.propertyChange(fEvent); - } - - /** - * Notifies listeners of the property change - * - * @param property - * the property that has changed - */ - public void notify(PropertyChangeEvent event) { - if (fListeners == null) { - return; - } - fEvent = event; - Object[] copiedListeners = fListeners.getListeners(); - for (int i = 0; i < copiedListeners.length; i++) { - fListener = (IPropertyChangeListener) copiedListeners[i]; - Platform.run(this); - } - fListener = null; - } - } - - public AbstractSynchronizeParticipant() { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.console.IConsole#getName() - */ - public String getName() { - return fName; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.console.IConsole#getImageDescriptor() - */ - public ImageDescriptor getImageDescriptor() { - return fImageDescriptor; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.ISynchronizeParticipant#getId() - */ - public String getId() { - return fId; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#getSecondaryId() - */ - public String getSecondaryId() { - return fSecondaryId; - } - - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#setPinned(boolean) - */ - public final void setPinned(boolean pinned) { - this.pinned = pinned; - pinned(pinned); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#isPinned() - */ - public final boolean isPinned() { - return pinned; - } - - /** - * Called when the pinned state is changed. - * - * @param pinned whether the participant is pinned. - */ - protected void pinned(boolean pinned) { - // Subclasses can re-act to changes in the pinned state - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) { - if(obj == this) return true; - if( ! (obj instanceof ISynchronizeParticipant)) return false; - ISynchronizeParticipant other = (ISynchronizeParticipant)obj; - return getId().equals(other.getId()) && Utils.equalObject(getSecondaryId(), other.getSecondaryId()); - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return Utils.getKey(getId(), getSecondaryId()).hashCode(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#doesSupportRefresh() - */ - public boolean doesSupportSynchronize() { - return true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.console.IConsole#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - if (fListeners == null) { - fListeners = new ListenerList(); - } - fListeners.add(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.console.IConsole#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - if (fListeners != null) { - fListeners.remove(listener); - } - } - - /** - * Notify all listeners that the given property has changed. - * - * @param source - * the object on which a property has changed - * @param property - * identifier of the property that has changed - * @param oldValue - * the old value of the property, or <code>null</code> - * @param newValue - * the new value of the property, or <code>null</code> - */ - public void firePropertyChange(Object source, String property, Object oldValue, Object newValue) { - if (fListeners == null) { - return; - } - PropertyNotifier notifier = new PropertyNotifier(); - notifier.notify(new PropertyChangeEvent(source, property, oldValue, newValue)); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, - * java.lang.String, java.lang.Object) - */ - public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { - // Save config element. - configElement = config; - - // Id - fId = config.getAttribute("id"); //$NON-NLS-1$ - - // Title. - fName = config.getAttribute("name"); //$NON-NLS-1$ - if (config == null) { - fName = "Unknown"; //$NON-NLS-1$ - } - - // Icon. - String strIcon = config.getAttribute("icon"); //$NON-NLS-1$ - if (strIcon != null) { - fImageDescriptor = TeamImages.getImageDescriptorFromExtension(configElement.getDeclaringExtension(), strIcon); - } - } - - protected void setInitializationData(ISynchronizeParticipantDescriptor descriptor) throws CoreException { - if(descriptor instanceof SynchronizeParticipantDescriptor) { - setInitializationData(((SynchronizeParticipantDescriptor)descriptor).getConfigurationElement(), null, null); - } else { - throw new TeamException(Policy.bind("AbstractSynchronizeParticipant.4")); //$NON-NLS-1$ - } - } - - /** - * Sets the name of this console to the specified value and notifies - * property listeners of the change. - * - * @param name the new name - */ - protected void setName(String name) { - String old = fName; - fName = name; - firePropertyChange(this, IBasicPropertyConstants.P_TEXT, old, name); - } - - /** - * Sets the image descriptor for this console to the specified value and - * notifies property listeners of the change. - * - * @param imageDescriptor the new image descriptor - */ - protected void setImageDescriptor(ImageDescriptor imageDescriptor) { - ImageDescriptor old = fImageDescriptor; - fImageDescriptor = imageDescriptor; - firePropertyChange(this, IBasicPropertyConstants.P_IMAGE, old, imageDescriptor); - } - - /** - * Sets the secondary id for this participant. - * - * @param secondaryId the secondary id for this participant. - */ - protected void setSecondaryId(String secondaryId) { - this.fSecondaryId = secondaryId; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#init(org.eclipse.ui.IMemento) - */ - public void init(String secondaryId, IMemento memento) throws PartInitException { - setSecondaryId(secondaryId); - pinned = Boolean.valueOf(memento.getString(CTX_PINNED)).booleanValue(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#saveState(org.eclipse.ui.IMemento) - */ - public void saveState(IMemento memento) { - memento.putString(CTX_PINNED, Boolean.toString(pinned)); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#createPageConfiguration() - */ - public final ISynchronizePageConfiguration createPageConfiguration() { - SynchronizePageConfiguration configuration = new SynchronizePageConfiguration(this); - initializeConfiguration(configuration); - return configuration; - } - - /** - * This method is invoked after a page configuration is created but before - * it is returned by the <code>createPageConfiguration</code> method. - * Subclasses can implement this method to tailor the configuration - * in ways appropriate to the participant. - * @param configuration the newly create page configuration - */ - protected abstract void initializeConfiguration(ISynchronizePageConfiguration configuration); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeScope.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeScope.java deleted file mode 100644 index 1e25fbdc7..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeScope.java +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.core.resources.IResource; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.ListenerList; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.util.SafeRunnable; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.ui.IMemento; - -/** - * Abstract superclass of resource scopes for <code>SubscriberParticipant</code> - * instances. - * <p> - * Clients are not expected to subclass this class. - * - * @see SubscriberParticipant - * @since 3.0 - */ -public abstract class AbstractSynchronizeScope implements ISynchronizeScope { - - /* - * Key for scope in memento - */ - private static final String CTX_SUBSCRIBER_SCOPE_TYPE = TeamUIPlugin.ID + ".SCOPE_TYPE"; //$NON-NLS-1$ - - /** - * Save the scope to the given memento - * @param scope a scope - * @param memento a memento - */ - protected static void saveScope(ISynchronizeScope scope, IMemento settings) { - settings.putString(CTX_SUBSCRIBER_SCOPE_TYPE, getType(scope)); - ((AbstractSynchronizeScope)scope).saveState(settings); - } - - /** - * Restore a scope from the given memento - * @param scope a scope - * @param memento a memento - */ - protected static ISynchronizeScope createScope(IMemento settings) { - String type = settings.getString(CTX_SUBSCRIBER_SCOPE_TYPE); - if (type == null) { - return new WorkspaceScope(); - } - if (type.equals("ResourceScope")) { //$NON-NLS-1$ - return new ResourceScope(settings); - } - if (type.equals("WorkingSetScope")) { //$NON-NLS-1$ - return new WorkingSetScope(settings); - } - return new WorkspaceScope(); - } - - private static String getType(ISynchronizeScope scope) { - String name = scope.getClass().getName(); - int lastDot = name.lastIndexOf("."); //$NON-NLS-1$ - if (lastDot == -1) { - return name; - } - return name.substring(lastDot + 1); //$NON-NLS-1$ - } - - private ListenerList listeners = new ListenerList(); - - /** - * Constuctor a scope from scratch - */ - protected AbstractSynchronizeScope() { - } - - /** - * Constuctor a scope from a previously saved state - */ - protected AbstractSynchronizeScope(IMemento memento) { - init(memento); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.ScopableSubscriberParticipant.ISynchronizeScope#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - synchronized(listeners) { - listeners.add(listener); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.ScopableSubscriberParticipant.ISynchronizeScope#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - synchronized(listeners) { - listeners.remove(listeners); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeScope#dispose() - */ - public void dispose() { - // Do nothing by default - } - - /** - * Fires the given property change event to all registered listsners. - * @param event the property change event to be fired - */ - protected void firePropertyChangedEvent(final PropertyChangeEvent event) { - Object[] allListeners; - synchronized(listeners) { - allListeners = listeners.getListeners(); - } - for (int i = 0; i < allListeners.length; i++) { - final IPropertyChangeListener listener = (IPropertyChangeListener)allListeners[i]; - Platform.run(new SafeRunnable() { - public void run() throws Exception { - listener.propertyChange(event); - } - }); - } - } - /** - * Firs a change event for property <code>ISynchronizeScope.ROOTS</code> - * containing the new roots. The old roots are not provided in the event. - */ - protected void fireRootsChanges() { - firePropertyChangedEvent(new PropertyChangeEvent(this, ROOTS, new IResource[0], getRoots())); - } - - /** - * Persist the state of this scope. Clients must persist enough additional - * state to know what type (i.e. subclass) of scope to be recreated. - * @param memento the memento into which the scope is to be saved - */ - public void saveState(IMemento memento) { - // Do nothing by default - } - - /** - * Method invoked from the contructor which repopulats the fields of this scope - * @param memento the memento into which the scope was previously saved - */ - protected void init(IMemento memento) { - // Do nothing by default - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeManager.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeManager.java deleted file mode 100644 index 8d352ab78..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeManager.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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; - -/** - * Manages synchronization view participants. Clients can programatically add - * or remove participants from this manager. Managed participants are available to - * clients whereas un-managed participants can still exist but won't be available - * generally available to clients until explicitly added to the manager. - * <p> - * Participants added to the manager will benefit from the manager's lifecycle - * support. The participants will automatically have their #init method and #dispose - * called when the manager starts and is shutdown. - * </p><p> - * Clients are not intended to implement this interface. - * </p> - * @see ISynchronizeParticipant - * @since 3.0 - */ -public interface ISynchronizeManager { - - /** - * Constant identifying the job family identifier for a background job that affects the - * synchronization state of resources. All clients - * that schedule background jobs that affect synchronization state should include this job - * family in their implementation of <code>belongsTo</code>. - * @see Job#belongsTo(Object) - */ - public static final Object FAMILY_SYNCHRONIZE_OPERATION = new Object(); - - /** - * Registers the given listener for participant notifications. Has - * no effect if an identical listener is already registered. - * - * @param listener listener to register - */ - public void addSynchronizeParticipantListener(ISynchronizeParticipantListener listener); - - /** - * Deregisters the given listener for participant notifications. Has - * no effect if an identical listener is not already registered. - * - * @param listener listener to deregister - */ - public void removeSynchronizeParticipantListener(ISynchronizeParticipantListener listener); - - /** - * Adds the given participants to the synchronize manager. Has no effect for - * equivalent participants are already registered. The participants will be added - * to any existing synchronize views. - * - * @param consoles consoles to add - */ - public void addSynchronizeParticipants(ISynchronizeParticipant[] participants); - - /** - * Removes the given participants from the synchronize manager. If the participants are - * being displayed in any synchronize views, the associated pages will be closed. - * - * @param consoles consoles to remove - */ - public void removeSynchronizeParticipants(ISynchronizeParticipant[] participants); - - /** - * Returns a collection of synchronize participants registered with the synchronize manager. - * - * @return a collection of synchronize participants registered with the synchronize manager. - */ - public ISynchronizeParticipantReference[] getSynchronizeParticipants(); - - /** - * Returns the registered synchronize participants with the given type id. It is - * possible to have multiple instances of the same participant type. - * - * @param id the type indentifier for the participant - * @return the registered synchronize participants with the given id, or - * an empty list if there are none with that id registered. - */ - public ISynchronizeParticipantReference[] get(String id); - - /** - * Returns the registered synchronize participants with the given id. It is - * possible to have multiple instances of the same participant type. - * - * @param id the type indentifier for the participant - * @param secondaryId the instance identifier for this participant type or <code>null</code> - * if this participant doesn't support multiple instances. - * @return the registered synchronize participants with the given id, or - * <code>null</code> if none with that id is not registered. - */ - public ISynchronizeParticipantReference get(String id, String secondayId); - - /** - * Opens the synchronize views in the perspective defined by the user in the team synchronize - * perferences. - * - * @return the opened synchronize view or <code>null</code> if it can't be opened. - */ - public ISynchronizeView showSynchronizeViewInActivePage(); - - /** - * Returns the participant descriptor for the given participant id or - * <code>null</code> if a descriptor is not found for that id. - * - * @return the participant descriptor for the given participant id or - * <code>null</code> if a descriptor is not found for that id. - */ - public ISynchronizeParticipantDescriptor getParticipantDescriptor(String type); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeModelChangeListener.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeModelChangeListener.java deleted file mode 100644 index 1a38d88e1..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeModelChangeListener.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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; - - -/** - * Listener that gets informed when the model created by the model provider is created or updated. - * <p> - * Clients may implement this interface. - * </p> - * @since 3.0 - */ -public interface ISynchronizeModelChangeListener { - /** - * Called whenever the input model shown in a diff node viewer is updated. - * - * @param input the root <code>DiffNode</code> of the model. - */ - public void modelChanged(ISynchronizeModelElement root); -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeModelElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeModelElement.java deleted file mode 100644 index 01903b4f3..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeModelElement.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.ITypedElement; -import org.eclipse.compare.structuremergeviewer.ICompareInput; -import org.eclipse.compare.structuremergeviewer.IDiffContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.team.internal.ui.TeamUIPlugin; - -/** - * These are elements created to display synchronization state in the UI. - * Since it implements the <code>ITypedElement</code> and <code>ICompareInput</code> - * interfaces it can be used directly to display the - * compare result in a <code>DiffTreeViewer</code> and as the input to any other - * compare/merge viewer. - * <p> - * <code>DiffNode</code>s are typically created as the result of performing - * a compare with the <code>Differencer</code>. - * <p> - * Clients typically use this class as is, but may subclass if required. - * - * @see DiffTreeViewer - * @see Differencer - */ -public interface ISynchronizeModelElement extends IDiffContainer, ITypedElement, ICompareInput { - - public static final String BUSY_PROPERTY = TeamUIPlugin.ID + ".busy"; //$NON-NLS-1$ - public static final String PROPAGATED_CONFLICT_PROPERTY = TeamUIPlugin.ID + ".conflict"; //$NON-NLS-1$ - public static final String PROPAGATED_ERROR_MARKER_PROPERTY = TeamUIPlugin.ID + ".error"; //$NON-NLS-1$ - public static final String PROPAGATED_WARNING_MARKER_PROPERTY = TeamUIPlugin.ID + ".warning"; //$NON-NLS-1$ - - public abstract void addPropertyChangeListener(IPropertyChangeListener listener); - - public abstract void removePropertyChangeListener(IPropertyChangeListener listener); - - public void setPropertyToRoot(String propertyName, boolean value); - - public void setProperty(String propertyName, boolean value); - - /** - * Return whether this node has the given property set. - * @param propertyName the flag to test - * @return <code>true</code> if the property is set - */ - public abstract boolean getProperty(String propertyName); - - public abstract ImageDescriptor getImageDescriptor(Object object); - - public abstract IResource getResource(); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePage.java deleted file mode 100644 index 4069774bd..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePage.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.jface.viewers.Viewer; -import org.eclipse.ui.PartInitException; - -/** - * Interface for {@link org.eclipse.ui.part.Page} subclasses that can appear in the - * synchronize view {@link ISynchronizeView} and other views, - * editors or dialogs that - * display synchronization information. It is not a requirement - * that pages that appear in the synchronize view implement this interface. - * However, by doing so, the page is initialized with a - * {@link ISynchronizePageSite) which provides a context for the page. - * The page is given this context in addition to the - * {@link org.eclipse.ui.part.IPageSite} - * provided when the page is used in a view. However, the page site - * may not be provided when the page appears in an editor or dialog. - */ -public interface ISynchronizePage { - - /** - * Initialize this page with workbench part that contains the page. - * This method will be called after the <code>Page#init(IPageSite)</code> - * but before <code>Page#createControl(Composite)</code> - * - * @param part the workbench part for the view containing the page - * @throws PartInitException - */ - public void init(ISynchronizePageSite site) throws PartInitException; - - /** - * Returns the viewer associated with this page or <code>null</code> if the page - * doesn't have a viewer. - */ - public Viewer getViewer(); - - /** - * Callback that is invoked from the synchronize configuration - * whenever a property's value is about to be changed. The page - * can react to the change before change events are fired or - * veto the change. - * @param configuration the synchronize page configuration - * @param key the property key - * @param newValue - * @return - */ - public boolean aboutToChangeProperty(ISynchronizePageConfiguration configuration, String key, Object newValue); - -} 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 deleted file mode 100644 index e562c1bd3..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageConfiguration.java +++ /dev/null @@ -1,368 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.jface.operation.IRunnableContext; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.ui.TeamUIPlugin; - -/** - * Configures the model, actions and label decorations of an - * {@link ISynchronizePage}. Clients can - * <ul> - * <li>set properties to affect the page contents and react to property changes - * <li>add and configure the actions available to the user (context menu, - * toolbar and view menu) - * </ul> - * - * This interface is not intended to be implemented by clients. - * - * @since 3.0 - */ -public interface ISynchronizePageConfiguration { - - /** - * Property constant for the <code>SyncInfoSet</code> that is being - * displayed by the page. - */ - public static final String P_SYNC_INFO_SET = TeamUIPlugin.ID + ".P_SYNC_INFO_SET"; //$NON-NLS-1$ - - /** - * Property constant for the list of label decorators - * (instance of <code>ILabelDecorator[]</code>) that will be - * applied to the text and image from the label provider. - */ - public static final String P_LABEL_DECORATORS = TeamUIPlugin.ID + ".P_LABEL_DECORATORS"; //$NON-NLS-1$ - - /** - * Property constant that defines the groups in the toolbar - * menu of the page. The value for this - * property should be a string array. If this property is - * set to <code>null</code>, the <code>DEFAULT_TOOLBAR_MENU</code> - * is used. Also, the groups mentioned in the <code>DEFAULT_TOOLBAR_MENU</code> - * can be removed but will always appear in the same order if - * included. - */ - public static final String P_TOOLBAR_MENU = TeamUIPlugin.ID + ".P_TOOLBAR_MENU"; //$NON-NLS-1$ - - /** - * The configuration property that defines - * the groups in the context menu of the page. The value for this - * property should be a string array. - */ - public static final String P_CONTEXT_MENU = TeamUIPlugin.ID + ".P_CONTEXT_MENU"; //$NON-NLS-1$ - - /** - * Property constant that defines the groups in the dropdown view - * menu of the page. The value for this - * property should be a string array. If this property is - * set to <code>null</code>, the <code>DEFAULT_VIEW_MENU</code> - * is used. Also, the groups mentioned in the <code>DEFAULT_VIEW_MENU</code> - * can be removed but will always appear in the same order if - * included. - */ - public static final String P_VIEW_MENU = TeamUIPlugin.ID + ".P_VIEW_MENU"; //$NON-NLS-1$ - - /** - * Property constant for the type of comparison used to create - * the <code>SyncInfo</code> in the P_SYNC_INFO_SET property. - * If the comparison type is <code>THREE_WAY</code> then - * modes selection applies. - */ - public static final String P_COMPARISON_TYPE = TeamUIPlugin.ID + ".P_COMPARISON_TYPE"; //$NON-NLS-1$ - - /** - * Property constant for the mode used to filter the visible - * elements of the model. The value can be one of the mode integer - * constants. - */ - public static final String P_MODE = TeamUIPlugin.ID + ".P_SYNCVIEWPAGE_MODE"; //$NON-NLS-1$ - - /** - * Property constant which indicates which modes are to be available to the user. - * The value is to be an integer that combines one or more of the - * mode bit values. - * Either <code>null</code> or <code>0</code> can be used to indicate that - * mode filtering is not supported. - */ - public static final String P_SUPPORTED_MODES = TeamUIPlugin.ID + ".P_SUPPORTED_MODES"; //$NON-NLS-1$ - - /** - * The id of the synchronize group the determines where the synchronize - * actions appear. - */ - public static final String SYNCHRONIZE_GROUP = "synchronize"; //$NON-NLS-1$ - - /** - * The id of the navigate group that determines where the navigation - * actions appear - */ - public static final String NAVIGATE_GROUP = "navigate"; //$NON-NLS-1$ - - /** - * The id of the mode group that determines where the mode selection - * actions appear - */ - public static final String MODE_GROUP = "modes"; //$NON-NLS-1$ - - /** - * The id of the file group that determines where the file - * actions appear. File actions include the open actions. - */ - public static final String FILE_GROUP = "file"; //$NON-NLS-1$ - - /** - * The id of the edit group that determines where the edit - * actions appear (e.g. move and delete). - */ - public static final String EDIT_GROUP = "edit"; //$NON-NLS-1$ - - /** - * The id of the preferences group that determines whether the preferences - * actions appear in the view dropdown. - */ - public static final String PREFERENCES_GROUP = "preferences"; //$NON-NLS-1$ - - /** - * The id of the layout group that determines whether the layout selection - * actions appear in the view dropdown or toolbar. - */ - public static final String LAYOUT_GROUP = "layout"; //$NON-NLS-1$ - - /** - * These are the default groups used for the context menu of a page. - * Clients can remove, add and change the ordering for groups in - * the context menu. - */ - public static final String[] DEFAULT_CONTEXT_MENU = new String[] { FILE_GROUP, EDIT_GROUP, SYNCHRONIZE_GROUP, NAVIGATE_GROUP}; - - /** - * These are the default groups used for the toolbar of a page. - * These groups will always appear in this order in the toolbar. - * Clients can disable one or more of these groups by setting - * the <code>P_TOOLBAR_MENU</code> property to an array that - * contains a subset of these. Clients can also add groups - * by adding new unique group ids to the array. Added groups - * will appear in the order specified but after the default groups. - */ - public static final String[] DEFAULT_TOOLBAR_MENU = new String[] { SYNCHRONIZE_GROUP, NAVIGATE_GROUP, MODE_GROUP, LAYOUT_GROUP }; - - /** - * These are the default groups used for the dropdown view menu of a page. - * These groups will always appear in this order in the view menu. - * Clients can disable one or more of these groups by setting - * the <code>P_VIEW_MENU</code> property to an array that - * contains a subset of these. Clients can also add groups - * by adding new unique group ids to the array. Added groups - * will appear in the order specified but after the default groups. - */ - public static final String[] DEFAULT_VIEW_MENU = new String[] { LAYOUT_GROUP, MODE_GROUP, SYNCHRONIZE_GROUP, PREFERENCES_GROUP }; - - /** - * Comparison type contstants - */ - public final static String TWO_WAY = "two-way"; //$NON-NLS-1$ - public final static String THREE_WAY = "three-way"; //$NON-NLS-1$ - - /** - * Modes are direction filters for the view - */ - public final static int INCOMING_MODE = 0x1; - public final static int OUTGOING_MODE = 0x2; - 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. - * @return the particpant - */ - public abstract ISynchronizeParticipant getParticipant(); - - /** - * Return the site which provieds access to certain workbench - * services. - * @return the page site - */ - public abstract ISynchronizePageSite getSite(); - - /** - * Return the page created from and associated with this - * configuration. - * @return Returns the page for this configuration - */ - public ISynchronizePage getPage(); - - /** - * Set the page for this configuration. This methpd should only - * be called once by the {@link ISynchronzeParticipant} that created - * the page. - * @param page the configuration's page - */ - public void setPage(ISynchronizePage page); - - /** - * Add a property change listener to the configuration. - * Registered listeners will receive notification when - * any property changes. - * @param listener a property change listener - */ - public abstract void addPropertyChangeListener(IPropertyChangeListener listener); - - /** - * Remove the registered change listener. Removing an unregistered listener - * has no effects. - * @param listener a property change listener - */ - public abstract void removePropertyChangeListener(IPropertyChangeListener listener); - - /** - * Sets the property with the given name. - * If the new value differs from the old a <code>PropertyChangeEvent</code> - * is sent to registered listeners. - * - * @param propertyName the name of the property to set - * @param value the new value of the property - */ - public abstract void setProperty(String key, Object newValue); - - /** - * Returns the property with the given name, or <code>null</code> - * if no such property exists. - * - * @param propertyName the name of the property to retrieve - * @return the property with the given name, or <code>null</code> if not found - */ - public abstract Object getProperty(String key); - - /** - * Register the action group with the configuration. The - * registered action groups will have the oportunity to add - * actions to the action bars and context menu of the synchronize - * page created using the configuration. - * @param group a synchronize page action group - */ - public abstract void addActionContribution(SynchronizePageActionGroup group); - - /** - * Remove a previously registered action group. Removing - * a group that is not registered has no effect. - * @param group a synchronize page action group - */ - public abstract void removeActionContribution(SynchronizePageActionGroup group); - - /** - * Add a label decorator to the page configuration. - * @param decorator a label decorator - */ - public void addLabelDecorator(ILabelDecorator decorator); - - /** - * Set the groups that are to be added to the menu identified - * by the menu property id. - * @param menuPropertyId the menu property id (one of <code>P_CONTEXT_MENU</code>, - * <code>P_VIEW_MENU</code> or <code>P_TOOLBAR_MENU</code>) - * @param groups a array of groups Ids - */ - public void setMenuGroups(String menuPropertyId, String[] groups); - - /** - * Adds a menu group of the gievn id to the end of the menu groups list - * for the given menu property id. - * @param menuPropertyId the menu property id (one of <code>P_CONTEXT_MENU</code>, - * <code>P_VIEW_MENU</code> or <code>P_TOOLBAR_MENU</code>) - * @param groupId the id of the group to be added to the end of the menu - * group list - */ - public void addMenuGroup(String menuPropertyId, String groupId); - - /** - * Returns whether the given group appears in the given menu - * @param menuPropertyId the property id that identifies the menu - * @param groupId the id of the group - * @return <code>true</code> if the group identified by the groupId appears - * in the menu identified by the menuPropertyId and <code>false</code> - * otherwise - */ - public abstract boolean hasMenuGroup(String menuPropertyId, String groupId); - - /** - * Return the value of the P_MODE property of this configuration. - * @return the mode property value - */ - int getMode(); - - /** - * Set the P_MODE property of this configuration to the - * given mode flag (one of <code>INCOMING_MODE</code>, - * <code>OUTGOING_MODE</code>, <code>BOTH_MODE</code> - * or <code>CONFLICTING_MODE</code>). - * @param mode the mode value - */ - void setMode(int mode); - - /** - * Return the value of the P_SUPPORTED_MODES property of this configuration. - * @return the supported modes property value - */ - int getSupportedModes(); - - /** - * Set the P_SUPPORTED_MODES property of this configuration to the - * ORed combination of one or more mode flags (<code>INCOMING_MODE</code>, - * <code>OUTGOING_MODE</code>, <code>BOTH_MODE</code> - * and <code>CONFLICTING_MODE</code>). - * @param modes the supported modes - */ - void setSupportedModes(int modes); - - /** - * Return the set associated with the P_SYNC_INFO_SET property - * or <code>null</code> if the property is not set. - * @return the set associated with the P_SYNC_INFO_SET property - * or <code>null</code> if the property is not set - */ - public abstract SyncInfoSet getSyncInfoSet(); - - /** - * Return the comparison type used by the page's <code>SyncInfo</code> - * modes. - * @return comparison type (could be <code>TWO_WAY</code>, <code>THREE_WAY</code> - * or a cusom type). - */ - String getComparisonType(); - - /** - * Set the comparison type used by the page's <code>SyncInfo</code> - * modes. The default type is <code>THREE_WAY</code>. - * @param type the comparison type (could be <code>TWO_WAY</code>, <code>THREE_WAY</code> - * or a cusom type). - */ - void setComparisonType(String type); - - /** - * Sets the runnable context that can be used by the page's - * actions to display progress. - * @param context a runnable context (or null) - */ - void setRunnableContext(IRunnableContext context); - - /** - * Return the runnable context. If <code>null</code> is returned, - * actions can use their own method of progress feedback either - * using a background job or the progress service - * @return a runnable context (or <code>null</code>) - */ - IRunnableContext getRunnableContext(); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageSite.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageSite.java deleted file mode 100644 index c9602f150..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageSite.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.jface.dialogs.IDialogSettings; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IKeyBindingService; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchSite; - -/** - * A site which provides access to the context in which this page - * is being displayed. Instances of this interface serve a similar purpose - * to <code>IWorkbenchSite</code> instances but is provided as a separate - * objects to allow clients to access the different site types - * (view, editor, dialog) using a common interface. This interface also provides - * access to the part for the site because this is required by some UI - * components. Clients should not need to access the part. - * <p> - * Clients can determine the type of workbench site by doing <code>instanceof</code> - * checks on the object returned by <code>getWorkbenchSite</code>. Similar - * <code>instanceof</code> checks can be done with the part. - * <p> - * Clients are not intended to implement this interface - * - * @since 3.0 - */ -public interface ISynchronizePageSite { - - /** - * Return the workbench site for the page - * or <code>null</code> if a workbench site is not available (e.g. if - * the page is being shown in a dialog). - * @return the workbench site for the page or <code>null</code> - */ - IWorkbenchSite getWorkbenchSite(); - - /** - * Return the workbench part for the page - * or <code>null</code> if a workbench part is not available (e.g. if - * the page is being shown in a dialog). - * @return the workbench part for the page or <code>null</code> - */ - IWorkbenchPart getPart(); - - /** - * Returns the shell for this site. - * @return the shell for this site - */ - Shell getShell(); - - /** - * Get the selection provider that gives access to the selection - * of the synchronize page associated with this page site. - * @return the selection provider for the page - */ - ISelectionProvider getSelectionProvider(); - - /** - * Sets the selection provider for this workbench site. - * @param provider the selection provider, or <code>null</code> to clear it - */ - void setSelectionProvider(ISelectionProvider provider); - - /** - * Get the keybinding service for the site or <code>null</code> - * if one is not available. - * @return the keybinding service for the site or <code>null</code> - * if one is not available - */ - IKeyBindingService getKeyBindingService(); - - /** - * Give the page focus. - */ - void setFocus(); - - /** - * Return a settings node that can be used by the - * page to save state. A <code>null</code> value - * is returned if the site does not allow for - * persisted settings. - * @return a settings node or <code>null</code> - */ - IDialogSettings getPageSettings(); - - /** - * Returns the action bars for this synchronize page site. - * - * @return the action bars - */ - IActionBars getActionBars(); - - /** - * Returns whether the site is associated with a page being - * shown in a modal dialog - * @return whether the site is associated with a page being - * shown in a modal dialog - */ - boolean isModal(); - -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipant.java deleted file mode 100644 index 62a428970..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipant.java +++ /dev/null @@ -1,219 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.core.runtime.IExecutableExtension; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.ui.*; -import org.eclipse.ui.part.IPageBookViewPage; - -/** - * A synchronize participant is a visual compoment that can be displayed within any - * control (e.g. view, editor, dialog). Typically a participant is used to show changes between - * local resources and variant states of those resources and allows the user to perform actions - * to manipulate the changes. For example, a participant could show the relative synchronization - * between local resources and those on an FTP server, or alternatively, between local - * resources and local history. - * <p> - * When a participant is registered with the {@link ISynchronizeManager} it will automatically display - * in the <i>Synchronize View</i> and if the participant extension point - * enabled <code>globalSynchronize</code> it will also appear in the global synchronize action - * toolbar. - * <p> - * A participant is added to the workbench as follows: - * <ul> - * <li>A <code>synchronizeParticipant</code> extension is contributed to - * the team registry. This extension defines the participant id, name, icon, type, and - * participant class. - * <li>The participant type is <code>static</code> it is automatically added - * to the {@link ISynchronizeManager}. - * <li>If a participant is not static, plug-in developers can add the participant to the - * manager via {@link ISynchronizeManager#addSynchronizeParticipants(ISynchronizeParticipant[]) and - * remove it using {@link ISynchronizeManager#removeSynchronizeParticipants(ISynchronizeParticipant[]). - * Note that you don't have to add the participant to the manager. You can instead create the - * participant, display it, and then dispose of it yourself. - * <li>For non-static participants you can configure the participant to support multiple instances. This will - * allow multiple instances to be created and registered with the synchronize manager. - * </ul></p> - * <p> - * Once a participant is added to the synchronize manager its lifecycle will be managed. On shutdown if - * the <code>persistent</code> property is set, the participant will be asked to persist state via - * the <code>saveState()</code> method. At startup the <code>init()</code> method is called - * with a handle to the state that was saved. The dispose method is called when the participant is - * removed from the manager and at shutdown. - * </p><p> - * Clients are not intended to implement this interface. Instead, sublcass {@link AbstractSynchronizeParticpant}. - * </p> - * @see ISynchronizeView - * @see ISynchronizeManager - * @see AbstractSynchronizeParticpant - * @since 3.0 - */ -public interface ISynchronizeParticipant extends IExecutableExtension { - /** - * Returns the unique id that identified the <i>type</i> of this - * synchronize participant. The synchronize manager supports registering - * several instances of the same participant type. - * - * @return the unique id that identified the <i>type</i> of this - * synchronize participant. - */ - public String getId(); - - /** - * Returns the instance id that identified the unique instance of this - * participant. The synchronize manager supports registering - * several instances of the same participant type and this id is used - * to differentiate between them. - * - * @return the instance id that identified the unique instance of this - * participant or <code>null</code> if this participant doesn't support - * multiple instances. - */ - public String getSecondaryId(); - - /** - * Returns the name of this synchronize participant. This name is displayed to the user. - * - * @return the name of this synchronize participant - */ - public String getName(); - - /** - * Returns an image descriptor for this synchronize participant, or <code>null</code> - * if none. - * - * @return an image descriptor for this synchronize participant, or <code>null</code> - * if none - */ - public ImageDescriptor getImageDescriptor(); - - /** - * Returns if this participant is pinned. Pinned participants will only be removed from the - * synchronize manager until they are un-pinned. - * - * @return <code>true</code> if this participant is pinned and <code>false</code> - * otherwise. - */ - public boolean isPinned(); - - /** - * Sets whether this participant is pinned. - * - * @param pinned sets if the participant is pinned. - */ - public void setPinned(boolean pinned); - - /** - * Creates the configuration for the participant page. The configuration controls the - * options for displaying the participant. The configuration used to initialize the page - * when {@link #createPage(ISynchronizePageConfiguration)} is called and as such - * can be used to pre-configure visual properties of the displayed page. - * - * @return the configuration for the participant page. - */ - public ISynchronizePageConfiguration createPageConfiguration(); - - /** - * Creates and returns a new page for this synchronize participant. The - * page is displayed using the parameters from the configuration. For example, - * the configuration defines the context in which the page is shown, via the - * {@link ISynchronizePageSite}. - * - * @param configuration used to initialize the page - * @return a page book view page representation of this synchronize - * participant - */ - public IPageBookViewPage createPage(ISynchronizePageConfiguration configuration); - - /** - * Runs the participants action. Typically this would be some action to refresh the synchronizatin - * state of the participant. This action is run from the global synchronize drop-down. - * - * @param part the part in which the action is run or <code>null</code> if the action - * is not being run in a workbench part. - */ - public void run(IWorkbenchPart part); - - /** - * Initializes this participant with the given participant state. - * A memento is passed to the participant which contains a snapshot - * of the participants state from a previous session. - * <p> - * This method is automatically called by the team plugin shortly after - * participant construction. It marks the start of the views - * lifecycle. Clients must not call this method. - * </p> - * @param secondaryId the secondayId of this participant instance or <code>null</code> - * if this participant doesn't support multiple instances. - * @param memento the participant state or <code>null</code> if there - * is no previous saved state - * @exception PartInitException if this participant was not initialized - * successfully - */ - public void init(String secondaryId, IMemento memento) throws PartInitException; - - /** - * Disposes of this synchronize participant and is called to free the - * resources associated with a participant. When a participant is added - * to the {@link ISynchronizeManager} this method is called when the - * manager is shutdown or the participant is removed from the manager. - * </p> - * <p> - * Within this method a participant may release any resources, fonts, images, etc. - * held by this part. It is also very important to deregister all listeners. - * </p> - * <p> - * Clients should not call this method (the synchronize manager calls this - * method at appropriate times). - * </p> - */ - public void dispose(); - - /** - * Saves the participants object state within the memento. This state - * will be available when the participant is restored via <code>init</code>. - * <p> - * This method can be called multiple times during the lifetime of the - * participant object. - * </p> - * @param memento a memento to receive the object state - */ - public void saveState(IMemento memento); - - /** - * Adds a listener for changes to properties of this synchronize - * participant. Has no effect if an identical listener is already - * registered. - * <p> - * The changes supported by the synchronize view are as follows: - * <ul> - * <li><code>IBasicPropertyConstants.P_TEXT</code>- indicates the name - * of a synchronize participant has changed</li> - * <li><code>IBasicPropertyConstants.P_IMAGE</code>- indicates the - * image of a synchronize participant has changed</li> - * </ul></p> - * <p> - * Clients may define additional properties as required. - * </p> - * @param listener a property change listener - */ - public void addPropertyChangeListener(IPropertyChangeListener listener); - - /** - * Removes the given property listener from this synchronize participant. - * Has no effect if an identical listener is not alread registered. - * - * @param listener a property listener - */ - public void removePropertyChangeListener(IPropertyChangeListener listener); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantDescriptor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantDescriptor.java deleted file mode 100644 index 1054570f9..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantDescriptor.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.jface.resource.ImageDescriptor; - -/** - * A participant descriptor contains the content of the - * <code>synchronizeParticipants</code> extension section for - * for a registered participant type in the declaring plug-in's - * manifest (<code>plugin.xml</code>) file. - * <p> - * Clients are not intended to implement this interface. - * </p> - * @see ISynchronizeManager#getParticipantDescriptor(String) - * @since 3.0 - */ -public interface ISynchronizeParticipantDescriptor { - /** - * Returns the name of this participant. This can be shown to the user. - * - * @return the name of this participant. This can be shown to the user. - */ - public String getName(); - - /** - * Returns a string describing this participant type. - * - * @return a string describing this participant type. - */ - public String getDescription(); - - /** - * Returns the unique id that identifies this participant type. - * - * @return the unique id that identifies this participant type. - */ - public String getId(); - - /** - * Returns the image descriptor for this participant type. - * - * @return the image descriptor for this participant type. - */ - public ImageDescriptor getImageDescriptor(); - - /** - * Returns if this participant can be persisted between sessions. - * - * @return <code>true</code> if this participant can be persisted between sessions - * and false otherwise. - */ - public boolean isPersistent(); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantListener.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantListener.java deleted file mode 100644 index 6dde603ae..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantListener.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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; - -/** - * A synchronize participant listener is notified when participants are added or - * removed from the synchronize manager. - * <p> - * Clients may implement this interface. - * </p> - * @since 3.0 - */ -public interface ISynchronizeParticipantListener { - /** - * Notification the given participants have been added to the synchronize - * manager. - * - * @param participants added participants - */ - public void participantsAdded(ISynchronizeParticipant[] participants); - - /** - * Notification the given participants have been removed from the - * synchronize manager. - * - * @param participants removed participants - */ - public void participantsRemoved(ISynchronizeParticipant[] participants); - -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantReference.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantReference.java deleted file mode 100644 index 2594892f4..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantReference.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.team.core.TeamException; - -/** - * A reference is a light weight handle used by the {@link ISynchronizeManager} - * to manage registered participants. It is used to reference information - * about a particular participant instance without requiring the particpant - * to be instantiated. - * <p> - * Clients are not intended to implement this interface. - * - * @see ISynchronizeManager - * @since 3.0 - */ -public interface ISynchronizeParticipantReference { - /** - * Returns the id of the participant type referenced by this handle. - * @return the id of the participant type references by this handle. - */ - public String getId(); - - /** - * Returns the secondary id (e.g. instance id) of the participant type referenced - * by this handle or <code>null</code> if the participant doesn't support - * multiple instances. - * @return the secondary id of the participant type referenced - * by this handle or <code>null</code> if the participant doesn't support - * multiple instances. - */ - public String getSecondaryId(); - - /** - * Returns the fully qualified name of this participant reference. This includes the - * secondaryId if available. This can be displayed in the user interface to allow - * the user to distinguish between multiple instances of a participant. - * - * @return the fully qualified name of this participant reference - */ - public String getDisplayName(); - - /** - * Returns the participant referenced by this handle. This may trigger loading of the - * participant and and a result may be long running. The method may return <code>null</code> - * if the participant cannot be de-referenced. - * @return the participant referencesd by this handle. - */ - public ISynchronizeParticipant getParticipant() throws TeamException; - - /** - * Returns the descriptor for this participant type. - * @return the descriptor for this participant type. - */ - public ISynchronizeParticipantDescriptor getDescriptor(); -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeScope.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeScope.java deleted file mode 100644 index f93428e3b..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeScope.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.core.resources.IResource; -import org.eclipse.jface.util.IPropertyChangeListener; - -/** - * A synchronize scope defines the set of resources involved in a synchronize. - * Instance of this interface are used to scope the resources of a - * {@link SubscriberParticipant}. - * <p> - * This interface is not intended to be implemented by clients - * @see SubscriberParticipant - * @since 3.0 - */ -public interface ISynchronizeScope { - - /** - * Property used to indicate when the roots of the scope have changed. - */ - public static final String ROOTS = "prop_roots"; //$NON-NLS-1$ - - /** - * Return the name of the scope - * @return the name of the scope - */ - public String getName(); - - /** - * Return the root resources that define this scope. A return value - * of <code>null</code> indicates that the participant should use - * its default set of resources. - * - * @return the root resources of <code>null</code> - */ - public IResource[] getRoots(); - - /** - * Add a propety change listener that will get invoked when a - * property of the reciever cnahges. - * @param listener - */ - public void addPropertyChangeListener(IPropertyChangeListener listener); - - /** - * Remove a propety change listener. Removing an unregistered listener - * has no effect. - * @param listener - */ - public void removePropertyChangeListener(IPropertyChangeListener listener); - - /** - * Dispose of the scope when it is no longer needed. - */ - public void dispose(); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeView.java deleted file mode 100644 index 4b1e2ecb3..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeView.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.team.internal.ui.synchronize.StructuredViewerAdvisor; -import org.eclipse.ui.IViewPart; - -/** - * A view that displays synchronization participants that are registered with the - * synchronize manager. This is essentially a generic container that allows - * multiple {@link ISynchronizeParticipant} implementations to share the same - * view. The only behavior provided by the view is a mechanism for switching - * between participants. - * <p> - * Clients should not add viewActions to this view because they will be global - * to all participants. Instead, add participant specific actions as described - * in {@link StructuredViewerAdvisor}. - * </p> - * <p> - * Clients are not intended to implement this interface. - * </p> - * @see ISynchronizeManager - * @since 3.0 - */ -public interface ISynchronizeView extends IViewPart { - /** - * The id for this view - */ - public static final String VIEW_ID = "org.eclipse.team.sync.views.SynchronizeView"; //$NON-NLS-1$ - - public static final String COMPARE_VIEW_ID = "org.eclipse.team.sync.views.CompareView"; //$NON-NLS-1$ - - /** - * Displays the given synchronize participant in the Synchronize View. This - * has no effect if this participant is already being displayed. - * - * @param participant participant to be displayed, cannot be <code>null</code> - */ - public void display(ISynchronizeParticipant participant); - - /** - * Returns the participant currently being displayed in the Synchronize View - * or <code>null</code> if none. - * - * @return the participant currently being displayed in the Synchronize View - * or <code>null</code> if none - */ - public ISynchronizeParticipant getParticipant(); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageDialog.java deleted file mode 100644 index 6daad094e..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageDialog.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.ui.*; -import org.eclipse.team.ui.SaveablePartDialog; -import org.eclipse.team.ui.TeamUI; - -/** - * A dialog that displays the option of adding the participant to the {@link org.eclipse.team.ui.synchronize.ISynchronizeManager} - * when the dialog is closed. This can be useful for showing changes for a participant modally and allowing the - * user to decide if the participant shown be made available non-modally. - * - * @see SaveablePartAdapter - * @see ISynchronizeParticipant - * @since 3.0 - */ -public class ParticipantPageDialog extends SaveablePartDialog { - - private ISynchronizeParticipant participant; - private Button rememberParticipantButton; - - /** - * Creates a dialog with the given title and input. The input is not created until the dialog - * is opened. - * - * @param shell the parent shell or <code>null</code> to create a top level shell. - * @param title the shell's title - * @param input the compare input to show in the dialog - */ - public ParticipantPageDialog(Shell shell, SaveablePartAdapter input, ISynchronizeParticipant participant) { - super(shell, input); - this.participant = participant; - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - protected Control createDialogArea(Composite parent2) { - Composite parent = (Composite) super.createDialogArea(parent2); - ISynchronizeParticipantReference[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); - if (participant != null && ! particantRegisteredWithSynchronizeManager(participant)) { - rememberParticipantButton = new Button(parent, SWT.CHECK); - rememberParticipantButton.setText(Policy.bind("ParticipantCompareDialog.1")); //$NON-NLS-1$ - } - Dialog.applyDialogFont(parent2); - return parent; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) - */ - protected void buttonPressed(int buttonId) { - if(buttonId == IDialogConstants.OK_ID && isRememberParticipant()) { - rememberParticipant(); - } - super.buttonPressed(buttonId); - } - - private boolean isRememberParticipant() { - return getParticipant() != null && rememberParticipantButton != null && rememberParticipantButton.getSelection(); - } - - private boolean particantRegisteredWithSynchronizeManager(ISynchronizeParticipant participant) { - return TeamUI.getSynchronizeManager().get(participant.getId(), participant.getSecondaryId()) != null; - } - - private void rememberParticipant() { - if(getParticipant() != null) { - ISynchronizeManager mgr = TeamUI.getSynchronizeManager(); - ISynchronizeView view = mgr.showSynchronizeViewInActivePage(); - mgr.addSynchronizeParticipants(new ISynchronizeParticipant[] {getParticipant()}); - view.display(participant); - } - } - - protected ISynchronizeParticipant getParticipant() { - return participant; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java deleted file mode 100644 index 0196e5c7c..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java +++ /dev/null @@ -1,526 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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 java.lang.reflect.InvocationTargetException; -import java.util.*; -import java.util.ArrayList; -import java.util.List; -import org.eclipse.compare.*; -import org.eclipse.compare.internal.CompareEditor; -import org.eclipse.compare.structuremergeviewer.*; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.action.*; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -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.TeamException; -import org.eclipse.team.internal.core.Assert; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.*; -import org.eclipse.team.ui.SaveablePartAdapter; -import org.eclipse.ui.*; -import org.eclipse.ui.commands.*; -import org.eclipse.ui.commands.ActionHandler; -import org.eclipse.ui.commands.HandlerSubmission; -import org.eclipse.ui.part.IPageBookViewPage; -import org.eclipse.ui.progress.IProgressService; - -/** - * Displays a synchronize participant page combined with the compare/merge - * infrastructured. This only works if the synchronize page viewer provides - * selections that ITypedElement and ICompareInput. - * - * @since 3.0 - */ -public class ParticipantPageSaveablePart extends SaveablePartAdapter implements IContentChangeListener { - - private CompareConfiguration cc; - private ISynchronizeParticipant participant; - private ISynchronizePageConfiguration pageConfiguration; - private Image titleImage; - private Shell shell; - private Shell dialogShell; - - // Tracking of dirty state - private boolean fDirty= false; - private ArrayList fDirtyViewers= new ArrayList(); - private IPropertyChangeListener fDirtyStateListener; - - // SWT controls - private CompareViewerSwitchingPane fContentPane; - private CompareViewerPane fEditionPane; - private CompareViewerSwitchingPane fStructuredComparePane; - private Viewer viewer; - private Control control; - - // Keybindings enabled in the dialog, these should be removed - // when the dialog is closed. - private IActionBars actionBars; - private List actionHandlers = new ArrayList(2); - - /* - * 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 dialogShell; - } - 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 ParticipantPageSaveablePart.this.getActionBars(); - } - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#isModal() - */ - public boolean isModal() { - return true; - } - } - - /** - * 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 ParticipantPageSaveablePart(Shell shell, CompareConfiguration cc, ISynchronizePageConfiguration pageConfiguration, ISynchronizeParticipant participant) { - this.cc = cc; - this.shell = shell; - this.participant = participant; - this.pageConfiguration = pageConfiguration; - - fDirtyStateListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent e) { - String propertyName= e.getProperty(); - if (CompareEditorInput.DIRTY_STATE.equals(propertyName)) { - boolean changed= false; - Object newValue= e.getNewValue(); - if (newValue instanceof Boolean) - changed= ((Boolean)newValue).booleanValue(); - setDirty(e.getSource(), changed); - } - } - }; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.SaveablePartAdapter#dispose() - */ - public void dispose() { - if(titleImage != null) { - titleImage.dispose(); - } - IWorkbenchCommandSupport cm = PlatformUI.getWorkbench().getCommandSupport(); - for (Iterator it = actionHandlers.iterator(); it.hasNext();) { - HandlerSubmission handler = (HandlerSubmission) it.next(); - cm.removeHandlerSubmission(handler); - } - super.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.ISaveablePart#isDirty() - */ - public boolean isDirty() { - return fDirty || fDirtyViewers.size() > 0; - } - - /* (non-Javadoc) - * @see org.eclipse.compare.IContentChangeListener#contentChanged(org.eclipse.compare.IContentChangeNotifier) - */ - public void contentChanged(IContentChangeNotifier source) { - try { - if (source instanceof DiffNode) { - commit(new NullProgressMonitor(), (DiffNode) source); - } else if (source instanceof LocalResourceTypedElement) { - ((LocalResourceTypedElement) source).commit(new NullProgressMonitor()); - } - } catch (CoreException e) { - Utils.handle(e); - } - } - - /* - * (non-Javadoc) - * @see CompareEditorInput#saveChanges(org.eclipse.core.runtime.IProgressMonitor) - */ - public void doSave(IProgressMonitor pm) { - //super.saveChanges(pm); - ISynchronizeModelElement root = (ISynchronizeModelElement)viewer.getInput(); - if (root != null && root instanceof DiffNode) { - try { - commit(pm, (DiffNode)root); - } catch (CoreException e) { - Utils.handle(e); - } finally { - setDirty(false); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - public void createPartControl(Composite parent2) { - Composite parent = new Composite(parent2, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.verticalSpacing = 0; - GridData data = new GridData(GridData.FILL_BOTH); - data.grabExcessHorizontalSpace = true; - parent.setLayout(layout); - parent.setLayoutData(data); - - dialogShell = parent2.getShell(); - - Splitter vsplitter = new Splitter(parent, SWT.VERTICAL); - vsplitter.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL)); - // we need two panes: the left for the elements, the right one for the structured diff - Splitter hsplitter = new Splitter(vsplitter, SWT.HORIZONTAL); - fEditionPane = new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT); - fStructuredComparePane = new CompareViewerSwitchingPane(hsplitter, SWT.BORDER | SWT.FLAT, false) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - if (input instanceof ICompareInput) - return CompareUI.findStructureViewer(oldViewer, (ICompareInput) input, this, cc); - return null; - } - }; - fStructuredComparePane.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent e) { - feedInput2(e.getSelection()); - } - }); - fEditionPane.setText("Changes"); - - 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) { - } - - page.createControl(fEditionPane); - - if(page instanceof ISynchronizePage) { - ((ISynchronizePage)page).getViewer().addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - ISelection sel = event.getSelection(); - if (sel instanceof IStructuredSelection) { - IStructuredSelection ss= (IStructuredSelection) sel; - if (ss.size() == 1) - setInput(ss.getFirstElement()); - } - } - }); - initializeDiffViewer(((ISynchronizePage)page).getViewer()); - } - - page.setActionBars(getActionBars()); - fEditionPane.setContent(page.getControl()); - tbm.update(true); - if(page instanceof ISynchronizePage) { - this.viewer = ((ISynchronizePage)page).getViewer(); - } - - fContentPane = new CompareViewerSwitchingPane(vsplitter, SWT.BORDER | SWT.FLAT) { - protected Viewer getViewer(Viewer oldViewer, Object input) { - Viewer newViewer= CompareUI.findContentViewer(oldViewer, input, this, cc); - boolean isNewViewer= newViewer != oldViewer; - if (isNewViewer && newViewer instanceof IPropertyChangeNotifier) { - final IPropertyChangeNotifier dsp= (IPropertyChangeNotifier) newViewer; - dsp.addPropertyChangeListener(fDirtyStateListener); - Control c= newViewer.getControl(); - c.addDisposeListener( - new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - dsp.removePropertyChangeListener(fDirtyStateListener); - } - } - ); - } - return newViewer; - } - }; - vsplitter.setWeights(new int[]{30, 70}); - setNavigator(pageConfiguration); - control = parent; - } - - /* (non Javadoc) - * TODO: using internal compare classes to support page navigation. This is required because - * we are building our own compare editor input that includes a participant page instead of a - * viewer. - */ - public void setNavigator(ISynchronizePageConfiguration configuration) { - configuration.setProperty(SynchronizePageConfiguration.P_NAVIGATOR, new PartNavigator( - new Object[] { - configuration.getProperty(SynchronizePageConfiguration.P_ADVISOR), - fStructuredComparePane, - fContentPane - } - )); - } - - /* - * Feeds input from the participant page into the content and structured viewers. - */ - private void setInput(Object input) { - fContentPane.setInput(input); - if (fStructuredComparePane != null) - fStructuredComparePane.setInput(input); - } - - /* - * Feeds selection from structure viewer to content viewer. - */ - private void feedInput2(ISelection sel) { - if (sel instanceof IStructuredSelection) { - IStructuredSelection ss= (IStructuredSelection) sel; - if (ss.size() == 1) - fContentPane.setInput(ss.getFirstElement()); - } - } - - /** - * Returns the primary control for this part. - * - * @return the primary control for this part. - */ - public Control getControl() { - return control; - } - - /** - * Initialize the diff viewer created for this compare input. If a subclass - * overrides the <code>createDiffViewer(Composite)</code> method, it should - * invoke this method on the created viewer in order to get the proper - * labelling in the compare input's contents viewers. - * @param viewer the diff viewer created by the compare input - */ - private void initializeDiffViewer(Viewer viewer) { - if (viewer instanceof StructuredViewer) { - ((StructuredViewer) viewer).addOpenListener(new IOpenListener() { - public void open(OpenEvent event) { - ISelection s = event.getSelection(); - final SyncInfoModelElement node = getElement(s); - if (node != null) { - IResource resource = node.getResource(); - int kind = node.getKind(); - if (resource != null && resource.getType() == IResource.FILE) { - // Cache the contents because compare doesn't show progress - // when calling getContents on a diff node. - IProgressService manager = PlatformUI.getWorkbench().getProgressService(); - try { - manager.busyCursorWhile(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - node.cacheContents(monitor); - hookContentChangeListener(node); - } catch (TeamException e) { - Utils.handle(e); - } finally { - // Update the labels even if the content wasn't fetched correctly. This is - // required because the selection would still of changed. - Utils.updateLabels(node.getSyncInfo(), cc); - } - } - }); - } catch (InvocationTargetException e) { - Utils.handle(e); - } catch (InterruptedException e) { - return; - } - } - } - } - }); - } - } - - private void hookContentChangeListener(DiffNode node) { - ITypedElement left = node.getLeft(); - if(left instanceof IContentChangeNotifier) { - ((IContentChangeNotifier)left).addContentChangeListener(this); - } - ITypedElement right = node.getRight(); - if(right instanceof IContentChangeNotifier) { - ((IContentChangeNotifier)right).addContentChangeListener(this); - } - } - - private SyncInfoModelElement getElement(ISelection selection) { - if (selection != null && selection instanceof IStructuredSelection) { - IStructuredSelection ss= (IStructuredSelection) selection; - if (ss.size() == 1) { - Object o = ss.getFirstElement(); - if(o instanceof SyncInfoModelElement) { - return (SyncInfoModelElement)o; - } - } - } - return null; - } - - private static void commit(IProgressMonitor pm, DiffNode node) throws CoreException { - ITypedElement left = node.getLeft(); - if (left instanceof LocalResourceTypedElement) - ((LocalResourceTypedElement) left).commit(pm); - - ITypedElement right = node.getRight(); - if (right instanceof LocalResourceTypedElement) - ((LocalResourceTypedElement) right).commit(pm); - - IDiffElement[] children = node.getChildren(); - for (int i = 0; i < children.length; i++) { - commit(pm, (DiffNode)children[i]); - } - } - - private void setDirty(boolean dirty) { - boolean confirmSave= true; - Object o= cc.getProperty(CompareEditor.CONFIRM_SAVE_PROPERTY); - if (o instanceof Boolean) - confirmSave= ((Boolean)o).booleanValue(); - - if (!confirmSave) { - fDirty= dirty; - if (!fDirty) - fDirtyViewers.clear(); - } - } - - private void setDirty(Object source, boolean dirty) { - Assert.isNotNull(source); - boolean oldDirty= fDirtyViewers.size() > 0; - if (dirty) - fDirtyViewers.add(source); - else - fDirtyViewers.remove(source); - boolean newDirty= fDirtyViewers.size() > 0; - } - - 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) { - IHandler handler = new ActionHandler(action); - HandlerSubmission handlerSubmission = new HandlerSubmission(null, - dialogShell, null, actionId, handler, Priority.MEDIUM); - PlatformUI.getWorkbench().getCommandSupport().addHandlerSubmission(handlerSubmission); - actionHandlers.add(handlerSubmission); - } - - public void updateActionBars() { - } - }; - } - } - - private IActionBars getActionBars() { - return actionBars; - } - - - /** - * Return the synchronize page configiration 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; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ResourceScope.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ResourceScope.java deleted file mode 100644 index dffa69160..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ResourceScope.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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 java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.ui.IMemento; - -/** - * A synchronize scope whose roots are a set of resources. - * <p> - * Clients are not expected to subclass this class. - * @since 3.0 - */ -public class ResourceScope extends AbstractSynchronizeScope { - - /* - * Constants used to save and restore this scope - */ - private final static String CTX_ROOT = "resource_scope_roots"; //$NON-NLS-1$ - private final static String CTX_ROOT_PATH = "resource_scope_root_resource"; //$NON-NLS-1$ - - /* - * The resources that define this scope - */ - private IResource[] resources; - - /** - * Create the resource scope for the given resources - * @param resources the resources that define this scope - */ - public ResourceScope(IResource[] resources) { - this.resources = resources; - } - - /** - * Create this scope from it's previously saved state - * @param memento - */ - protected ResourceScope(IMemento memento) { - super(memento); - } - - /** - * Set the resources that define this scope - * @param resources the resources that define this scope - */ - public void setResources(IResource[] resources) { - this.resources = resources; - fireRootsChanges(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.ScopableSubscriberParticipant.ISynchronizeScope#getName() - */ - public String getName() { - return Utils.convertSelection(resources, 4); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.ScopableSubscriberParticipant.ISynchronizeScope#getRoots() - */ - public IResource[] getRoots() { - return resources; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.ScopableSubscriberParticipant.ISynchronizeScope#dispose() - */ - public void dispose() { - // Nothing to dispose - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.ScopableSubscriberParticipant.ISynchronizeScope#saveState(org.eclipse.ui.IMemento) - */ - public void saveState(IMemento memento) { - if (resources != null) { - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - IMemento rootNode = memento.createChild(CTX_ROOT); - rootNode.putString(CTX_ROOT_PATH, resource.getFullPath().toString()); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeScope#init(org.eclipse.ui.IMemento) - */ - protected void init(IMemento memento) { - IMemento[] rootNodes = memento.getChildren(CTX_ROOT); - if(rootNodes != null) { - List resources = new ArrayList(); - for (int i = 0; i < rootNodes.length; i++) { - IMemento rootNode = rootNodes[i]; - IPath path = new Path(rootNode.getString(CTX_ROOT_PATH)); //$NON-NLS-1$ - IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path, true /* include phantoms */); - if(resource != null) { - resources.add(resource); - } - } - this.resources = (IResource[]) resources.toArray(new IResource[resources.size()]); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SubscriberParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SubscriberParticipant.java deleted file mode 100644 index 747a1ced7..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SubscriberParticipant.java +++ /dev/null @@ -1,400 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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 java.util.Arrays; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.Subscriber; -import org.eclipse.team.core.synchronize.SyncInfoFilter; -import org.eclipse.team.core.synchronize.SyncInfoTree; -import org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoCollector; -import org.eclipse.team.internal.ui.*; -import org.eclipse.team.internal.ui.synchronize.*; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.ui.*; -import org.eclipse.ui.part.IPageBookViewPage; - -/** - * A synchronize participant that displays synchronization information for local resources that are - * managed via a {@link Subscriber}. It maintains a dynamic collection of all out-of-sync resources - * by listening to workspace resource changes and remote changes. - * <p> - * The subscriber can be configured to be synchronized in the background based on a schedule. This - * effectively refreshes the subscriber and updates the dynamic sync set. - * </p><p> - * Subclasses will typically want to override the following methods: - * <ul> - * <li>initializeConfiguration: participants can add toolbar actions, configure the context menu, decorator. - * <li>saveState and init: persist settings between sessions. - * </ul> - * This class is intended to be subclassed. - * </p> - * @since 3.0 - */ -public abstract class SubscriberParticipant extends AbstractSynchronizeParticipant implements IPropertyChangeListener { - - /* - * Collects and maintains set of all out-of-sync resources of the subscriber - */ - private SubscriberSyncInfoCollector collector; - - /* - * Controls the automatic synchronization of this participant - */ - private SubscriberRefreshSchedule refreshSchedule; - - /* - * Provides the resource scope for this participant - */ - private ISynchronizeScope scope; - - /* - * Key for settings in memento - */ - private static final String CTX_SUBSCRIBER_PARTICIPANT_SETTINGS = TeamUIPlugin.ID + ".TEAMSUBSRCIBERSETTINGS"; //$NON-NLS-1$ - - /* - * Key for schedule in memento - */ - private static final String CTX_SUBSCRIBER_SCHEDULE_SETTINGS = TeamUIPlugin.ID + ".TEAMSUBSRCIBER_REFRESHSCHEDULE"; //$NON-NLS-1$ - - /** - * Constructor initializes the schedule. Subclasses must call this method. - */ - public SubscriberParticipant() { - refreshSchedule = new SubscriberRefreshSchedule(this); - } - - /** - * Constructor which should be called when creating a particpant whose resources - * are to be scoped. - * @param scope a synchronize scope - */ - public SubscriberParticipant(ISynchronizeScope scope) { - this(); - this.scope = scope; - scope.addPropertyChangeListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.ISynchronizeViewPage#createPage(org.eclipse.team.ui.sync.ISynchronizeView) - */ - public final IPageBookViewPage createPage(ISynchronizePageConfiguration configuration) { - validateConfiguration(configuration); - return new SubscriberParticipantPage(configuration, getSubscriberSyncInfoCollector()); - } - - /** - * Returns the resources supervised by this participant. It will - * either be the roots of the subscriber or the resources - * provided when the subscriber was set. - * - * @return the resources supervised by this participant. - */ - public IResource[] getResources() { - return collector.getRoots(); - } - - /* - * Set the resources supervised by this participant. If <code>null</code>, - * the participant will include all roots of its subscriber - * @param roots the root resources to consider or <code>null</code> - * to consider all roots of the subscriber - */ - private void setResources(IResource[] roots) { - collector.setRoots(roots); - } - - /** - * Refresh this participants synchronization state and displays the result in a model dialog. - * @param resources - * @param taskName - * @param site - */ - public final void refreshInDialog(Shell shell, IResource[] resources, String jobName, String taskName, ISynchronizePageConfiguration configuration, IWorkbenchSite site) { - IRefreshSubscriberListener listener = new RefreshUserNotificationPolicyInModalDialog(shell, taskName, configuration, this); - internalRefresh(resources, jobName, taskName, site, listener); - } - - /** - * Refresh a participant in the background the result of the refresh are shown in the progress view. - * - * @param resources the resources to be refreshed. - */ - public final void refresh(IResource[] resources, String shortTaskName, String longTaskName, IWorkbenchSite site) { - IRefreshSubscriberListener listener = new RefreshUserNotificationPolicy(this); - internalRefresh(resources, shortTaskName, longTaskName, site, listener); - } - - /** - * Refresh a participant. The returned status describes the result of the refresh. - */ - public final IStatus refreshNow(IResource[] resources, String taskName, IProgressMonitor monitor) { - RefreshSubscriberJob job = new RefreshSubscriberJob(this, taskName, taskName, resources, null); - return job.runInWorkspace(monitor); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.AbstractSynchronizeViewPage#dispose() - */ - public void dispose() { - Platform.getJobManager().cancel(this); - refreshSchedule.dispose(); - TeamUI.removePropertyChangeListener(this); - collector.dispose(); - scope.dispose(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant#getName() - */ - public String getName() { - String name = super.getName(); - return Policy.bind("SubscriberParticipant.namePattern", name, scope.getName()); //$NON-NLS-1$ - } - - /** - * Returns the <code>SyncInfoTree</code> for this participant. This set - * contains the out-of-sync resources supervised by this participant. - * - * @return the sync info set that contains the out-of-sync resources - * for this participant. - */ - public SyncInfoTree getSyncInfoSet() { - return getSubscriberSyncInfoCollector().getSyncInfoSet(); - } - - /** - * Return the <code>Subscriber</code> associated with this this participant. This - * method will only return <code>null</code> if the participant has not been initialized - * yet. - * - * @return the <code>Subscriber</code> associated with this this participant. - */ - public Subscriber getSubscriber() { - if (collector == null) return null; - return collector.getSubscriber(); - } - - /** - * Returns a participant that matches the scoping - */ - public static SubscriberParticipant getMatchingParticipant(String ID, IResource[] resources) { - ISynchronizeParticipantReference[] refs = TeamUI.getSynchronizeManager().getSynchronizeParticipants(); - for (int i = 0; i < refs.length; i++) { - ISynchronizeParticipantReference reference = refs[i]; - if(reference.getId().equals(ID)) { - SubscriberParticipant p; - try { - p = (SubscriberParticipant)reference.getParticipant(); - } catch (TeamException e) { - continue; - } - IResource[] roots = p.getResources(); - Arrays.sort(resources, Utils.resourceComparator); - Arrays.sort(roots, Utils.resourceComparator); - if (Arrays.equals(resources, roots)) { - return p; - } - } - } - return null; - } - - /* (non-Javadoc) - * @see IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(TeamUI.GLOBAL_IGNORES_CHANGED)) { - collector.reset(); - } - if (event.getProperty().equals(ISynchronizeScope.ROOTS)) { - setResources(scope.getRoots()); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#init(org.eclipse.ui.IMemento) - */ - public void init(String secondaryId, IMemento memento) throws PartInitException { - super.init(secondaryId, memento); - if(memento != null) { - IMemento settings = memento.getChild(CTX_SUBSCRIBER_PARTICIPANT_SETTINGS); - if(settings != null) { - SubscriberRefreshSchedule schedule = SubscriberRefreshSchedule.init(settings.getChild(CTX_SUBSCRIBER_SCHEDULE_SETTINGS), this); - setRefreshSchedule(schedule); - this.scope = AbstractSynchronizeScope.createScope(settings); - scope.addPropertyChangeListener(this); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#saveState(org.eclipse.ui.IMemento) - */ - public void saveState(IMemento memento) { - super.saveState(memento); - IMemento settings = memento.createChild(CTX_SUBSCRIBER_PARTICIPANT_SETTINGS); - refreshSchedule.saveState(settings.createChild(CTX_SUBSCRIBER_SCHEDULE_SETTINGS)); - AbstractSynchronizeScope.saveScope(scope, settings); - } - - /** - * Reset the sync set of the particpant by repopulating it from scratch. - */ - public void reset() { - getSubscriberSyncInfoCollector().reset(); - } - - /* (non-Javadoc) - * Return the <code>SubscriberSyncInfoCollector</code> for the participant. - * This collector maintains the set of all out-of-sync resources for the subscriber. - * - * @return the <code>SubscriberSyncInfoCollector</code> for this participant - */ - public SubscriberSyncInfoCollector getSubscriberSyncInfoCollector() { - return collector; - } - - /*(non-Javadoc) - * Not to be called by clients. - */ - public void setRefreshSchedule(SubscriberRefreshSchedule schedule) { - this.refreshSchedule = schedule; - } - - /* (non-Javadoc) - * Not to be called by clients. - */ - public SubscriberRefreshSchedule getRefreshSchedule() { - return refreshSchedule; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) - */ - protected void initializeConfiguration(ISynchronizePageConfiguration configuration) { - configuration.setProperty(SynchronizePageConfiguration.P_PARTICIPANT_SYNC_INFO_SET, collector.getSyncInfoSet()); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#run(org.eclipse.ui.IWorkbenchPart) - */ - public void run(IWorkbenchPart part) { - refresh(getResources(), getShortTaskName(), getLongTaskName(), part != null ? part.getSite() : null); - } - - /** - * Returns the short task name (e.g. no more than 25 characters) to describe the behavior of the - * refresh operation to the user. This is typically shown in the status line when this subcriber is refreshed - * in the backgroud. When refreshed in the foreground, only the long task name is shown. - * - * @return the short task name to show in the status line. - */ - protected String getShortTaskName() { - return Policy.bind("Participant.synchronizing"); //$NON-NLS-1$ - } - - /** - * Returns the short task name (e.g. no more than 25 characters) to describe the behavior of the - * refresh operation to the user. This is typically shown in the status line when this subcriber is refreshed - * in the backgroud. When refreshed in the foreground, only the long task name is shown. - * - * @return the short task name to show in the status line. - */ - protected String getLongTaskName() { - return Policy.bind("Participant.synchronizing"); //$NON-NLS-1$ - } - - /** - * This method is invoked before the given configuration is used to - * create the page (see <code>createPage(ISynchronizePageConfiguration)</code>). - * The configuration would have been initialized by - * <code>initializeConfiguration(ISynchronizePageConfiguration)</code> - * but may have also been tailored further. This method gives the particpant - * a chance to validate those changes before the page is created. - * @param configuration the page configuration that is about to be used to create a page. - */ - protected void validateConfiguration(ISynchronizePageConfiguration configuration) { - // Do nothing by default - } - - /** - * Subclasses must call this method to initialize the participant. Typically this - * method is called in {@link #init(String, IMemento)}. This method will initialize - * the sync info collector. - * - * @param subscriber the subscriber to associate with this participant. - * @param roots the root resources to be consider by this participant - * (or <code>null</code> if all roots of the subscriber should be considered - */ - protected void setSubscriber(Subscriber subscriber) { - if (scope == null) { - scope = new WorkspaceScope(); - } - collector = new SubscriberSyncInfoCollector(subscriber, scope.getRoots()); - - // listen for global ignore changes - TeamUI.addPropertyChangeListener(this); - - // Start collecting changes - collector.start(); - - // Start the refresh now that a subscriber has been added - SubscriberRefreshSchedule schedule = getRefreshSchedule(); - if(schedule.isEnabled()) { - getRefreshSchedule().startJob(); - } - } - - /** - * Provide a filter that is used to filter the contents of the - * sync info set for the participant. Normally, all out-of-sync - * resources from the subscriber will be included in the - * participant's set. However, a filter can be used to exclude - * some of these out-of-sync resources, if desired. - * <p> - * Subsclasses can invoke this method any time after - * <code>setSubscriber</code> has been invoked. - * @param filter a sync info filter - */ - protected void setSyncInfoFilter(SyncInfoFilter filter) { - collector.setFilter(filter); - } - - /** - * Create and schedule a subscriber refresh job. - * - * @param resources resources to be synchronized - * @param taskName the task name to be shown to the user - * @param site the site in which to run the refresh - * @param listener the listener to handle the refresh workflow - */ - private void internalRefresh(IResource[] resources, String jobName, String taskName, IWorkbenchSite site, IRefreshSubscriberListener listener) { - RefreshSubscriberJob job = new RefreshSubscriberJob(this, jobName, taskName, resources, listener); - job.setUser(true); - Utils.schedule(job, site); - } - - /** - * Return the scope that defines the resources displayed by this participant. - * @return Returns the scope. - */ - public ISynchronizeScope getScope() { - return scope; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoCompareInput.java deleted file mode 100644 index a48d719b3..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoCompareInput.java +++ /dev/null @@ -1,224 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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 java.lang.reflect.InvocationTargetException; - -import org.eclipse.compare.*; -import org.eclipse.compare.structuremergeviewer.DiffNode; -import org.eclipse.compare.structuremergeviewer.IDiffContainer; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.swt.graphics.Image; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.internal.core.Assert; -import org.eclipse.team.internal.ui.*; -import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement; -import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement; -import org.eclipse.team.ui.ISharedImages; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IReusableEditor; -import org.eclipse.ui.progress.UIJob; - -/** - * A {@link SyncInfo} editor input used as input to a two-way or three-way - * compare viewer. It defines methods for accessing the three sides for the - * compare, and a name and image which is used when displaying the three way input - * in an editor. This input can alternatly be used to show compare results in - * a dialog by calling {@link CompareUI#openCompareDialog()}. - * <p> - * Supports saving the local resource that is changed in the editor. - * </p> - * <p> - * Use {@link SynchronizeCompareInput} to display more than one <code>SyncInfo</code> - * in an compare viewer. - * </p> - * @see SyncInfoModelElement - * @since 3.0 - */ -public final class SyncInfoCompareInput extends CompareEditorInput implements IResourceChangeListener { - - private MyDiffNode node; - private String description; - private IResource resource; - private IEditorPart editor; - private Image inputImage; - - private static class MyDiffNode extends SyncInfoModelElement { - public MyDiffNode(IDiffContainer parent, SyncInfo info) { - super(parent, info); - } - public void fireChange() { - super.fireChange(); - } - } - - /** - * Creates a compare editor input based on an existing <code>SyncInfo</code>. - * - * @param description a description of the context of this sync info. This - * is displayed to the user. - * @param sync the <code>SyncInfo</code> used as the base for the compare input. - */ - public SyncInfoCompareInput(String description, SyncInfo sync) { - super(getDefaultCompareConfiguration()); - Assert.isNotNull(sync); - Assert.isNotNull(description); - this.description = description; - this.resource = sync.getLocal(); - this.node = new MyDiffNode(null, sync); - initializeContentChangeListeners(); - } - - private static CompareConfiguration getDefaultCompareConfiguration() { - CompareConfiguration cc = new CompareConfiguration(); - //cc.setProperty(CompareConfiguration.USE_OUTLINE_VIEW, true); - return cc; - } - - private void initializeContentChangeListeners() { - ITypedElement te = node.getLeft(); - if (te instanceof IContentChangeNotifier) { - ((IContentChangeNotifier) te).addContentChangeListener(new IContentChangeListener() { - public void contentChanged(IContentChangeNotifier source) { - try { - saveChanges(new NullProgressMonitor()); - } catch (CoreException e) { - } - } - }); - } - } - - /** - * Note that until the compare editor inputs can be part of the compare editors lifecycle we - * can't register as a listener because there is no dispose() method to remove the listener. - */ - public void resourceChanged(IResourceChangeEvent event) { - IResourceDelta delta = event.getDelta(); - if (delta != null) { - IResourceDelta resourceDelta = delta.findMember(resource.getFullPath()); - if (resourceDelta != null) { - if (editor != null && editor instanceof IReusableEditor) { - UIJob job = new UIJob("") { //$NON-NLS-1$ - public IStatus runInUIThread(IProgressMonitor monitor) { - node.update(node.getSyncInfo()); - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.schedule(); - } - } - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.compare.CompareEditorInput#getTitleImage() - */ - public Image getTitleImage() { - ImageRegistry reg = TeamUIPlugin.getPlugin().getImageRegistry(); - Image image = reg.get(ISharedImages.IMG_SYNC_VIEW); - if (image == null) { - image = getImageDescriptor().createImage(); - reg.put(ISharedImages.IMG_SYNC_VIEW, image); - } - return image; - } - - /* - * (non-Javadoc) - * @see org.eclipse.compare.CompareEditorInput#prepareInput(org.eclipse.core.runtime.IProgressMonitor) - */ - protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - // update the title now that the remote revision number as been fetched - // from the server - setTitle(getTitle()); - Utils.updateLabels(node.getSyncInfo(), getCompareConfiguration()); - try { - node.cacheContents(monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - return node; - } - - /* - * (non-Javadoc) - * @see org.eclipse.compare.CompareEditorInput#getTitle() - */ - public String getTitle() { - return Policy.bind("SyncInfoCompareInput.title", node.getName()); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#getImageDescriptor() - */ - public ImageDescriptor getImageDescriptor() { - return TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_SYNC_VIEW); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#getToolTipText() - */ - public String getToolTipText() { - return Policy.bind("SyncInfoCompareInput.tooltip", description, node.getResource().getFullPath().toString()); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object other) { - if (other == this) - return true; - if (other instanceof SyncInfoCompareInput) { - return getSyncInfo().equals(((SyncInfoCompareInput) other).getSyncInfo()); - } - return false; - } - - /* - * (non-Javadoc) - * @see CompareEditorInput#saveChanges(org.eclipse.core.runtime.IProgressMonitor) - */ - public void saveChanges(IProgressMonitor pm) throws CoreException { - super.saveChanges(pm); - if (node != null) { - try { - commit(pm, node); - } finally { - node.fireChange(); - setDirty(false); - } - } - } - - private static void commit(IProgressMonitor pm, DiffNode node) throws CoreException { - ITypedElement left = node.getLeft(); - if (left instanceof LocalResourceTypedElement) - ((LocalResourceTypedElement) left).commit(pm); - - ITypedElement right = node.getRight(); - if (right instanceof LocalResourceTypedElement) - ((LocalResourceTypedElement) right).commit(pm); - } - - public SyncInfo getSyncInfo() { - return node.getSyncInfo(); - } -}
\ No newline at end of file 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 deleted file mode 100644 index 8c7ca2a8f..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java +++ /dev/null @@ -1,229 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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 java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement; -import org.eclipse.ui.actions.BaseSelectionListenerAction; -import org.eclipse.ui.ide.IDE; - -/** - * This action provides utilities for performing operations on selections that - * are obtained from a view populated by a - * {@link org.eclipse.team.ui.synchronize.viewers.SynchronizeModelProvider}. - * The {@link org.eclipse.team.internal.ui.synchronize.SubscriberParticipantPage} is an example of such a view. - * Subclasses can use this support to filter the selection in order to - * determine action enablement and generate the input for a {@link SynchronizeModelOperation}. - * @see SyncInfo - * @see SyncInfoSet - * @see org.eclipse.team.ui.synchronize.viewers.SynchronizeModelProvider - * @see org.eclipse.team.internal.ui.synchronize.SubscriberParticipantPage - * @see org.eclipse.team.ui.synchronize.SynchronizeModelOperation - * @since 3.0 - */ -public abstract class SynchronizeModelAction extends BaseSelectionListenerAction { - - private ISynchronizePageConfiguration configuration; - - /** - * Create an action with the given text and configuration. By default, - * the action registers for selection change with the selection provider - * from the configuration's site. - * @param text the action's text - * @param configuration the actions synchronize page configuration - */ - protected SynchronizeModelAction(String text, ISynchronizePageConfiguration configuration) { - this(text, configuration, configuration.getSite().getSelectionProvider()); - } - - /** - * Create an action with the given text and configuration. By default, - * the action registers for selection change with the given selection provider. - * @param text the action's text - * @param configuration the actions synchronize page configuration - * @param selectionProvider a selection provider - */ - protected SynchronizeModelAction(String text, ISynchronizePageConfiguration configuration, ISelectionProvider selectionProvider) { - super(text); - this.configuration = configuration; - initialize(configuration, selectionProvider); - } - - /** - * Method invoked from the constructor. - * The default implementation registers the action as a selection change - * listener. Subclasses may override. - * @param configuration the synchronize page configuration - * @param selectionProvider a selection provider - */ - protected void initialize(final ISynchronizePageConfiguration configuration, final ISelectionProvider selectionProvider) { - selectionProvider.addSelectionChangedListener(this); - configuration.getPage().getViewer().getControl().addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - selectionProvider.removeSelectionChangedListener(SynchronizeModelAction.this); - } - }); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.action.Action#run() - */ - public void run() { - if(needsToSaveDirtyEditors()) { - if(!saveAllEditors(confirmSaveOfDirtyEditor())) { - return; - } - } - try { - getSubscriberOperation(configuration, getFilteredDiffElements()).run(); - } catch (InvocationTargetException e) { - handle(e); - } catch (InterruptedException e) { - handle(e); - } - } - - /** - * Return whether dirty editor should be saved before this action is run. - * Default is <code>true</code>. - * @return whether dirty editor should be saved before this action is run - */ - protected boolean needsToSaveDirtyEditors() { - return true; - } - - /** - * Returns whether the user should be prompted to save dirty editors. - * The default is <code>true</code>. - * @return whether the user should be prompted to save dirty editors - */ - protected boolean confirmSaveOfDirtyEditor() { - return true; - } - - /** - * Return the subscriber operation associated with this action. This operation - * will be run when the action is run. Subclass may implement this method and provide - * an operation subclass or may override the <code>run(IAction)</code> method directly - * if they choose not to implement a <code>SynchronizeModelOperation</code>. - * @param configuration the synchronize page configuration for the page - * to which this action is associated - * @param elements the selected diff element for which this action is enabled. - * @return the subscriber operation to be run by this action. - */ - protected abstract SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements); - - /** - * Generic error handling code that uses an error dialog to show the error to the - * user. Subclasses can use this method and/or override it. - * @param e the exception that occurred. - */ - protected void handle(Exception e) { - Utils.handle(e); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection) - */ - protected boolean updateSelection(IStructuredSelection selection) { - super.updateSelection(selection); - return (getFilteredDiffElements().length > 0); - } - - /** - * This method returns all instances of IDiffElement that are in the current - * selection. - * - * @return the selected elements - */ - protected final IDiffElement[] getSelectedDiffElements() { - return Utils.getDiffNodes(getStructuredSelection().toArray()); - } - - /** - * Filter uses to filter the user selection to contain only those - * elements for which this action is enabled. - * Default filter includes all out-of-sync elements in the current - * selection. Subsclasses may override. - * @return a sync info filter which selects all out-of-sync resources. - */ - protected FastSyncInfoFilter getSyncInfoFilter() { - return new FastSyncInfoFilter(); - } - - /** - * Return the selected diff element for which this action is enabled. - * @return the list of selected diff elements for which this action is enabled. - */ - protected final IDiffElement[] getFilteredDiffElements() { - IDiffElement[] elements = getSelectedDiffElements(); - List filtered = new ArrayList(); - for (int i = 0; i < elements.length; i++) { - IDiffElement e = elements[i]; - if (e instanceof SyncInfoModelElement) { - SyncInfo info = ((SyncInfoModelElement) e).getSyncInfo(); - if (info != null && getSyncInfoFilter().select(info)) { - filtered.add(e); - } - } - } - return (IDiffElement[]) filtered.toArray(new IDiffElement[filtered.size()]); - } - - /** - * Set the selection of this action to the given selection - * @param selection the selection - */ - public void selectionChanged(ISelection selection) { - if (selection instanceof IStructuredSelection) { - super.selectionChanged((IStructuredSelection)selection); - } else { - super.selectionChanged(StructuredSelection.EMPTY); - } - - } - - /** - * @return Returns the configuration. - */ - public ISynchronizePageConfiguration getConfiguration() { - return configuration; - } - - /** - * Save all dirty editors in the workbench that are open on files that - * may be affected by this operation. Opens a dialog to prompt the - * user if <code>confirm</code> is true. Return true if successful. - * Return false if the user has cancelled the command. Must be called - * from the UI thread. - * - * @param confirm - * prompt the user if true - * @return boolean false if the operation was cancelled. - */ - public final boolean saveAllEditors(boolean confirm) { - return IDE.saveAllEditors(Utils.getResources(getFilteredDiffElements()), confirm); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelOperation.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelOperation.java deleted file mode 100644 index ab356aa90..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelOperation.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 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 java.util.ArrayList; -import java.util.List; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement; -import org.eclipse.team.ui.TeamOperation; -import org.eclipse.ui.IWorkbenchPart; - -/** - * A subscriber operation provides access to a {@link SyncInfoSet} containing - * the selection from a {@link SynchronizeModelAction}. - * When used in conjuntion with a {@link SynchronizeModelAction}, the selected - * elements in the view will show busy indication if this - * operation is run as a job. - * - * @see SyncInfoSet - * @see SynchronizeModelAction - * @since 3.0 - */ -public abstract class SynchronizeModelOperation extends TeamOperation { - - private IDiffElement[] elements; - - /* - * Helper method for extacting the part safely from a configuration - */ - private static IWorkbenchPart getPart(ISynchronizePageConfiguration configuration) { - if (configuration != null) { - ISynchronizePageSite site = configuration.getSite(); - if (site != null) { - return site.getPart(); - } - } - return null; - } - - /* - * Helper method for extacting the runnable context safely from a configuration - */ - private static IRunnableContext getRunnableContext(ISynchronizePageConfiguration configuration) { - if (configuration != null) { - return configuration.getRunnableContext(); - } - return null; - } - - /** - * Create an operation that will operate on the given diff elements - * that were obtained from a view populated by a - * {@link org.eclipse.team.ui.synchronize.viewers.SynchronizeModelProvider}. - * @param elements - */ - protected SynchronizeModelOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - super(getPart(configuration), getRunnableContext(configuration)); - this.elements = elements; - } - - /** - * Returns a sync info set that contains the {@link SyncInfo} for the - * elements of this operations. - */ - protected SyncInfoSet getSyncInfoSet() { - return makeSyncInfoSetFromSelection(getSyncInfos()); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.JobChangeAdapter#scheduled(org.eclipse.core.runtime.jobs.IJobChangeEvent) - */ - public void scheduled(IJobChangeEvent event) { - super.scheduled(event); - markBusy(elements, true); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.JobChangeAdapter#done(org.eclipse.core.runtime.jobs.IJobChangeEvent) - */ - public void done(IJobChangeEvent event) { - markBusy(elements, false); - super.done(event); - } - - private void markBusy(IDiffElement[] elements, boolean isBusy) { - for (int i = 0; i < elements.length; i++) { - IDiffElement element = elements[i]; - if (element instanceof ISynchronizeModelElement) { - ((ISynchronizeModelElement)element).setPropertyToRoot(ISynchronizeModelElement.BUSY_PROPERTY, isBusy); - } - } - } - - /* - * Return the selected SyncInfo for which this action is enabled. - * @return the selected SyncInfo for which this action is enabled. - */ - private SyncInfo[] getSyncInfos() { - List filtered = new ArrayList(); - for (int i = 0; i < elements.length; i++) { - IDiffElement e = elements[i]; - if (e instanceof SyncInfoModelElement) { - filtered.add(((SyncInfoModelElement)e).getSyncInfo()); - } - } - return (SyncInfo[]) filtered.toArray(new SyncInfo[filtered.size()]); - } - - /* - * Return a sync info set that contains the given sync info - */ - private SyncInfoSet makeSyncInfoSetFromSelection(SyncInfo[] infos) { - return new SyncInfoSet(infos); - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizePageActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizePageActionGroup.java deleted file mode 100644 index b51b04be4..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizePageActionGroup.java +++ /dev/null @@ -1,348 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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 java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.IContributionManager; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.util.ListenerList; -import org.eclipse.jface.util.SafeRunnable; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.actions.ActionGroup; - -/** - * Used to add one or more actions to the context menu, toolbar or view menu - * of an {@link ISynchronizePage}. An action group is added to a synchronize - * page by adding the group to the {@link ISynchronizePageConfiguration} after - * configuration has been created by the page but before the page is created. - * <p> - * The life cycle of an action group is: - * <ul> - * <li>the <code>initialize(ISynchronizePageConfiguration}</code> method is - * invoked before the methods to populate menus. This is done to give clients - * a change to create and initialize the actions of the action group. - * <li>The <code>fillActionBars(IActionBars)</code> method is invoked - * to populate the page's action bars (view menu and toolbar). It is - * possible for the action bars to be missing one or more components - * so clients are expected to check for <code>null</code> when accessing - * the menus from the action bars. - * <li>The <code>fillContextMenu(IMenuManager)</code> method is invoked each time - * the context menu is shown. Before this method is called, the - * action group will be provided with an <code>ActionContext</code> - * containing the view selection. Clients can access the context using - * <code>getContext()</code>. - * <li>The <code>updateActionBars()</code> method is invoked whenever the - * page's selection changes. Before this method is called, the - * action group will be provided with an <code>ActionContext</code> - * containing the view selection. Clients can access the context using - * <code>getContext()</code>. - * <li>The <code>modelChanged(ISynchronizeModelElement)</code> method is - * invoked whenever the model being displayed is changed. This gives clients - * a chance to adjust the input to actions that operate on all visible elements. - * <li>The <code>dispose()</code> method is called when the page is disposed. - * </ul> - * <p> - * TODO: Describe menu configuration and adding actions to groups - * @since 3.0 - */ -public abstract class SynchronizePageActionGroup extends ActionGroup { - - private ISynchronizePageConfiguration configuration; - - private Map menuContributions = new HashMap(); - - private VisibleRootsSelectionProvider visibleRootSelectionProvider; - - /** - * A selection provider whose selection is the root elements - * visible in the page. Selection changed events are sent out - * when the model roots change or their visible children change - */ - private class VisibleRootsSelectionProvider extends SynchronizePageActionGroup implements ISelectionProvider { - - private ListenerList selectionChangedListeners = new ListenerList(); - private ISelection selection; - - protected VisibleRootsSelectionProvider(ISynchronizeModelElement element) { - modelChanged(element); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SynchronizePageActionGroup#modelChanged(org.eclipse.team.ui.synchronize.ISynchronizeModelElement) - */ - public void modelChanged(ISynchronizeModelElement root) { - if (root == null) { - setSelection(StructuredSelection.EMPTY); - } else { - setSelection(new StructuredSelection(root)); - } - } - - /* (non-Javadoc) - * Method declared on ISelectionProvider. - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.add(listener); - } - - /* (non-Javadoc) - * Method declared on ISelectionProvider. - */ - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.remove(listener); - } - - /* (non-Javadoc) - * Method declared on ISelectionProvider. - */ - public ISelection getSelection() { - return selection; - } - - /* (non-Javadoc) - * Method declared on ISelectionProvider. - */ - public void setSelection(ISelection selection) { - this.selection = selection; - selectionChanged(new SelectionChangedEvent(this, getSelection())); - } - - private void selectionChanged(final SelectionChangedEvent event) { - // pass on the notification to listeners - Object[] listeners = selectionChangedListeners.getListeners(); - for (int i = 0; i < listeners.length; ++i) { - final ISelectionChangedListener l = (ISelectionChangedListener)listeners[i]; - Platform.run(new SafeRunnable() { - public void run() { - l.selectionChanged(event); - } - }); - } - } - } - - /** - * Initialize the actions of this contribution. - * This method will be invoked once before any calls are - * made to <code>filleContextMenu</code> or <code>setActionBars</code> - * but after the control for the page has been created. As a result - * of this, the site of the configuration can be accessed. - * Sublcasses may override this method but must invoke - * the overriden method. - * @param configuration the configuration for the part to which - * the contribution is associated - */ - public void initialize(ISynchronizePageConfiguration configuration) { - this.configuration = configuration; - if (visibleRootSelectionProvider != null) { - configuration.addActionContribution(visibleRootSelectionProvider); - } - } - - /** - * This method is invoked whenever the model being displayed in the - * view changes. This includes when the input to the view changes - * and when the children of the input change. The default implementation - * of this method does nothing. Subclasses may override. - * @param root the root of the model being viewed - */ - public void modelChanged(ISynchronizeModelElement root) { - // Do nothing by default - } - - /** - * Dispose of the action group. Subclasses may override but must - * invoke the overriden method. - */ - public void dispose() { - super.dispose(); - if (configuration != null) { - configuration.removeActionContribution(this); - } - } - - /** - * Helper method to find the group of the given id for the page - * associated with the configuration of this action group. - * The id of the returned group will not match that of the - * provided id since the group must be modified to ensure that - * groups are unique accross pages. - * @param menu the menu - * @param groupId the id of the group being searched for - * @return the group for the given id or <code>null</code> - */ - protected IContributionItem findGroup(IContributionManager menu, String groupId) { - if(menu == null) return null; - IContributionItem item = menu.find(((SynchronizePageConfiguration)configuration).getGroupId(groupId)); - if (item == null) { - // Context menus do not change the id - item = menu.find(groupId); - } - return item; - } - - /** - * Helper method to add an action to a group in a menu. The action is only - * added to the menu if the group exists in the menu. Calling this method - * also has no effect if either the menu or action are <code>null</code>. - * @param manager the menu manager - * @param groupId the group to append the action to - * @param action the action to add - * @return <code>true</code> if the group exists and the action was added - * and <code>false</code> if the action was not added - */ - protected boolean appendToGroup(IContributionManager manager, String groupId, IAction action) { - if (manager == null || action == null) return false; - IContributionItem group = findGroup(manager, groupId); - if (group != null) { - manager.appendToGroup(group.getId(), action); - return true; - } - return false; - } - - /** - * Helper method to add a contribution item to a group in a menu. The item is only - * added to the menu if the group exists in the menu. Calling this method - * also has no effect if either the menu or item are <code>null</code>. - * @param manager the menu manager - * @param groupId the group to append the action to - * @param item the item to add - * @return <code>true</code> if the group exists and the action was added - * and <code>false</code> if the action was not added - */ - protected boolean appendToGroup(IContributionManager manager, String groupId, IContributionItem item) { - if (manager == null || item == null) return false; - IContributionItem group = findGroup(manager, groupId); - if (group != null) { - manager.appendToGroup(group.getId(), item); - return true; - } - return false; - } - - /** - * Helper method that can be invoked during initialization to add an - * action to a particular menu (one of P_TOOLBAR_MENU, P_VIEW_MENU, P_CONTEXT_MENU - * from ISynchronizePageConfiguration). The action is added to the given group - * if it is present. Otherwise the action is not added to the menu. - * @param menuId the menu id (one of P_TOOLBAR_MENU, P_VIEW_MENU, P_CONTEXT_MENU - * from ISynchronizePageConfiguration) - * @param groupId the group id in the menu to which the action is to be added - * @param action the action to be added - */ - protected void appendToGroup(String menuId, String groupId, IAction action) { - internalAppendToGroup(menuId, groupId, action); - } - - /** - * Helper method that can be invoked during initialization to add an - * item to a particular menu (one of P_TOOLBAR_MENU, P_VIEW_MENU, P_CONTEXT_MENU - * from ISynchronizePageConfiguration). The item is added to the given group - * if it is present. Otherwise the item is not added to the menu. - * @param menuId the menu id (one of P_TOOLBAR_MENU, P_VIEW_MENU, P_CONTEXT_MENU - * from ISynchronizePageConfiguration) - * @param groupId the group id in the menu to which the item is to be added - * @param item the item to be added - */ - protected void appendToGroup(String menuId, String groupId, IContributionItem item) { - internalAppendToGroup(menuId, groupId, item); - } - - /** - * Return a selection provider whose selection includes all roots - * of the elements - * visible in the page. Selection change events are fired when the - * elements visible in the view change. - * @return a selection provider whgose selection is the roots of all - * elements visible in the page - */ - protected ISelectionProvider getVisibleRootsSelectionProvider() { - if (visibleRootSelectionProvider == null) { - ISynchronizeModelElement root = null; - if (configuration != null) { - root = (ISynchronizeModelElement)configuration.getProperty(SynchronizePageConfiguration.P_MODEL); - } - visibleRootSelectionProvider = new VisibleRootsSelectionProvider(root); - if (configuration != null) { - configuration.addActionContribution(visibleRootSelectionProvider); - } - } - return visibleRootSelectionProvider; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager) - */ - public void fillContextMenu(IMenuManager menu) { - super.fillContextMenu(menu); - fillMenu(menu, ISynchronizePageConfiguration.P_CONTEXT_MENU); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars) - */ - public void fillActionBars(IActionBars actionBars) { - super.fillActionBars(actionBars); - if (actionBars != null) { - fillMenu(actionBars.getMenuManager(), ISynchronizePageConfiguration.P_VIEW_MENU); - fillMenu(actionBars.getToolBarManager(), ISynchronizePageConfiguration.P_TOOLBAR_MENU); - } - } - - private void fillMenu(IContributionManager menu, String menuId) { - Map groups = (Map)menuContributions.get(menuId); - if (menu != null && groups != null) { - for (Iterator iter = groups.keySet().iterator(); iter.hasNext(); ) { - String groupId = (String) iter.next(); - List actions = (List)groups.get(groupId); - if (actions != null) { - for (Iterator iter2 = actions.iterator(); iter2.hasNext();) { - Object element = iter2.next(); - if (element instanceof IAction) { - appendToGroup(menu, groupId, (IAction)element); - } else if (element instanceof IContributionItem) { - appendToGroup(menu, groupId, (IContributionItem)element); - } - } - } - } - } - } - - private void internalAppendToGroup(String menuId, String groupId, Object action) { - Map groups = (Map)menuContributions.get(menuId); - if (groups == null) { - groups = new HashMap(); - menuContributions.put(menuId, groups); - } - List actions = (List)groups.get(groupId); - if (actions == null) { - actions = new ArrayList(); - groups.put(groupId, actions); - } - actions.add(action); - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/WorkingSetScope.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/WorkingSetScope.java deleted file mode 100644 index e438328b5..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/WorkingSetScope.java +++ /dev/null @@ -1,181 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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 java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.IWorkingSetManager; -import org.eclipse.ui.PlatformUI; - -/** - * A synchronize scope whose roots are defined by a working set. - * <p> - * Clients are not expected to subclass this class. - * @since 3.0 - */ -public class WorkingSetScope extends AbstractSynchronizeScope implements IPropertyChangeListener { - - /* - * Constants used to save and restore this scope - */ - /* - * Constants used to save and restore this scope - */ - private final static String CTX_SETS = "workingset_scope_sets"; //$NON-NLS-1$ - private final static String CTX_SET_NAME = "workingset_scope_name"; //$NON-NLS-1$ - - private IWorkingSet[] sets; - - /** - * Create the scope for the subscriber and working set - * @param subscriber the subscriber that defines this scope - * @param set the working set that defines this scope - */ - public WorkingSetScope(IWorkingSet[] sets) { - this.sets = sets; - PlatformUI.getWorkbench().getWorkingSetManager().addPropertyChangeListener(this); - } - - /** - * Create this scope from it's previously saved state - * @param memento - */ - protected WorkingSetScope(IMemento memento) { - super(memento); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.ScopableSubscriberParticipant.SubscriberScope#getName() - */ - public String getName() { - if (sets.length == 0) { - return Policy.bind("WorkingSetScope.0"); //$NON-NLS-1$ - } - StringBuffer name = new StringBuffer(); - for (int i = 0; i < sets.length; i++) { - IWorkingSet set = sets[i]; - name.append(set.getName()); - if (i < sets.length - 1) { - name.append(", "); - } - } - return name.toString(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.ScopableSubscriberParticipant.SubscriberScope#getRoots() - */ - public IResource[] getRoots() { - if (sets.length == 0) { - return null; - } - HashSet roots = new HashSet(); - for (int i = 0; i < sets.length; i++) { - IWorkingSet set = sets[i]; - IResource[] resources = Utils.getResources(set.getElements()); - addNonOverlapping(roots, resources); - } - return (IResource[]) roots.toArray(new IResource[roots.size()]); - } - - private void addNonOverlapping(HashSet roots, IResource[] resources) { - for (int i = 0; i < resources.length; i++) { - IResource newResource = resources[i]; - boolean add = true; - for (Iterator iter = roots.iterator(); iter.hasNext();) { - IResource existingResource = (IResource) iter.next(); - if (existingResource.equals(newResource)) { - // No need to add it since it is already there - add = false; - break; - } - if (existingResource.getFullPath().isPrefixOf(newResource.getFullPath())) { - // No need to add it since a parent is already there - add = false; - break; - } - if (newResource.getFullPath().isPrefixOf(existingResource.getFullPath())) { - // Remove existing and continue - iter.remove(); - } - } - if (add) { - roots.add(newResource); - } - } - - } - - /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty() == IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE) { - IWorkingSet newSet = (IWorkingSet)event.getNewValue(); - for (int i = 0; i < sets.length; i++) { - IWorkingSet set = sets[i]; - if (newSet == set) { - fireRootsChanges(); - return; - } - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.ScopableSubscriberParticipant.SubscriberScope#dispose() - */ - public void dispose() { - super.dispose(); - PlatformUI.getWorkbench().getWorkingSetManager().removePropertyChangeListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeScope#saveState(org.eclipse.ui.IMemento) - */ - public void saveState(IMemento memento) { - super.saveState(memento); - for (int i = 0; i < sets.length; i++) { - IWorkingSet set = sets[i]; - IMemento rootNode = memento.createChild(CTX_SETS); - rootNode.putString(CTX_SET_NAME, set.getName()); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeScope#init(org.eclipse.ui.IMemento) - */ - protected void init(IMemento memento) { - super.init(memento); - IMemento[] rootNodes = memento.getChildren(CTX_SETS); - if(rootNodes != null) { - List sets = new ArrayList(); - for (int i = 0; i < rootNodes.length; i++) { - IMemento rootNode = rootNodes[i]; - String setName = rootNode.getString(CTX_SET_NAME); - IWorkingSet set = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(setName); - if (set != null) { - sets.add(set); - } - } - this.sets = (IWorkingSet[]) sets.toArray(new IWorkingSet[sets.size()]); -} } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/WorkspaceScope.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/WorkspaceScope.java deleted file mode 100644 index 30fabebd3..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/WorkspaceScope.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the 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.core.resources.IResource; -import org.eclipse.team.internal.ui.Policy; - -/** - * A synchronize scope whose roots are the workspace. - * <p> - * Clients are not expected to subclass this class. - * @since 3.0 - */ -public class WorkspaceScope extends AbstractSynchronizeScope { - - /** - * Create the resource scope that indicates that the subscriber roots should be used - */ - public WorkspaceScope() { - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.ScopableSubscriberParticipant.ISynchronizeScope#getName() - */ - public String getName() { - return Policy.bind("WorkspaceScope.0"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.synchronize.ScopableSubscriberParticipant.ISynchronizeScope#getRoots() - */ - public IResource[] getRoots() { - // Return null which indicates to use the subscriber roots - return null; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/package.html b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/package.html deleted file mode 100644 index ae46ea670..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/package.html +++ /dev/null @@ -1,134 +0,0 @@ -<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en"> -<html> -<head> - <meta http-equiv="Content-Type" - content="text/html; charset=iso-8859-1"> - <meta name="Author" content="IBM"> - <title>Package-level Javadoc</title> -</head> -<body> -<p>Contains the team synchronization presentation framework and support -for the Synchronize View.<br> -</p> -<h2>Package Specification</h2> -<p>Contains the team synchronization presentation framework and support -for the Synchronize View. A synchronization framework is a unified -architecture for presenting and manipulating resource synchronization -state. Consider the -synchronization model described by the classes in -<code>org.eclipse.team.core.synchronize</code> as the physical -representation of synchronization state then the classes in this -package allow you to control -how the model is presented to the user. This framework doesn't attempt -to provide common operations for manipulating synchronization state. -Instead it is left up to the framework user to add their own domain -specific operations to the presentation.<br> -</p> -<p>The primary advantages of this synchronization presentation -framework are that it:<br> -</p> -<ul> - <li><span style="font-weight: bold;">Provides a unified -synchronization experience</span> in the workbench. It makes it easier -to present one synchronization story to the user across multiple tools -that synchronize resources. This includes access to the Synchronize -View, the Team Synchronizing Perspective, the global Synchronize -Action, Synchronize dialogs, and compare editors.<br> - </li> - <li><span style="font-weight: bold;">Reduces the effort required to -learn other APIs</span> by eliminating the need to learn many workbench -APIs to enable this rich support.<br> - </li> - <li><span style="font-weight: bold;">Fosters software re-use</span> -by allowing multiple repository providers and other tools to enable -rich integration without the initial cost of learning how to integrate -into Eclipse.<br> - </li> -</ul> -<p>The synchronization presentation framework consists of:<br> -</p> -<ul> - <li><span style="font-weight: bold;">Synchronize View Interfaces</span> -- Represents a set of classes and interfaces -to support a generic synchronize view that can show multiple -synchronize participants.</li> - <li><span style="font-weight: bold;">Viewer Advisors</span> - The -advisors allow decoupling viewer behavior from the viewers presentation -and basically provide the ability to show synchronization information -stored as <code>SyncInfo </code>or in a <code>SyncInfoSet</code> to -be shown in a Viewer.</li> - <li><span style="font-weight: bold;">Compare Inputs</span> - These -are helpers for allowing users to display and edit the resources being -synchronized.</li> - <li><span style="font-weight: bold;">Synchronize action and operation -utilities</span> - Represent helpers for writing actions that are -performed on elements shown in synchronization viewers.<br> - </li> -</ul> -<hr style="width: 100%; height: 2px;"> -<h3>Synchronize View Interfaces<br> -</h3> -<p>These interfaces and classes support a generic Synchronize View that -can show multiple -synchronize participants. The basic model for integrating into the -Synchronize View consists of:<br> -</p> -<ul> - <li>A ISynchronizeManager manages registered synchronize -participants. There can be several instances of the same participant -type.</li> - <li>A ISynchronizeParticipant is a logical representation of a -connection between workspace resources and a remote location used to -shared those resources.</li> - <li>A ISynchronizeView is a page book view of participants.</li> - <li>A ISynchronizeParticipant must create a page that will be -displayed in the ISynchronizeView page book view.</li> - <li>The ISynchronizeView shows a drop-down of all registered -participants and allows switching between them.</li> - <li>A ISynchronizeParticipant can contribute actions to the toolbar, -menus, and view menu.</li> -</ul> -<p>Synchronize participants are declared by extending the <strong>synchronizeParticipants -</strong>extension point. There are two classes of synchronize -participants: <em>static </em>participants will be created when the -synchronize view is created, and <em>dynamic</em> participants that -are created by user code at some other time. A synchronize manager -manages all active synchronize participants, and provides notification -of participants which are added and removed. Participants are displayed -in a page book view. Each participant implementation is reponsible for -creating its page, which provides freedom of -presentation to the synchronize view implementation. A single -participant may be displayed simultaneously in multiple synchronize -views, and in different workbench windows.<br> -</p> -<hr style="width: 100%; height: 2px;"> -<h3>Viewer Advisors</h3> -- StructuredViewerAdvisor: are used to -display the logical structure to the user and define the basics such as -the SynchronizeModelProvider, label provider, and context menus.<br> -<p>- SyncInfoCompareInput: is used to show a comparison between a local -resource and a variant in a compare editor.<br> -- SyncInfoSetCompareInput: is used to showing a set of variants in a -compare editor<br> -</p> -<p>Default implementations are provided and there are many levels of -customizations available.<br> -</p> -<hr style="width: 100%; height: 2px;"> -<h3>Compare Inputs</h3> -These are helpers for allowing users to display and edit resources -being synchronized by integrating with the compare support available in -Eclipse. <br> -<hr style="width: 100%; height: 2px;"> -<h3>Synchronize action and operation utilities</h3> -These are helpers for writing actions that are performed on elements -shown in synchronize viewers.<br> -<hr style="width: 100%; height: 2px;"> -<h3>Related Documentation</h3> -<ul> - <li>Pointer to the ISV docs?</li> - <li>Tutorials?<br> - </li> -</ul> -</body> -</html> |