diff options
author | Jean Michel-Lemieux | 2003-10-29 18:59:31 +0000 |
---|---|---|
committer | Jean Michel-Lemieux | 2003-10-29 18:59:31 +0000 |
commit | 5f51e1fc45c41e4307334075213d569546ea9969 (patch) | |
tree | 1551805921fbf2fd65bca4b4d427391c4194fdae | |
parent | 8941beb62da837d4d1b1ec15ec7c78b7b22b248c (diff) | |
download | eclipse.platform.team-SynchronizeViewPageBook20031009.tar.gz eclipse.platform.team-SynchronizeViewPageBook20031009.tar.xz eclipse.platform.team-SynchronizeViewPageBook20031009.zip |
*** empty log message ***SynchronizeViewPageBook20031009
24 files changed, 381 insertions, 902 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ISaveContext.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ISaveContext.java deleted file mode 100644 index c0c88a2ff..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ISaveContext.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.core; - -import java.util.Map; - -public interface ISaveContext { - public String getAttribute(String name); - - public void putInteger(String key, int n); - - public void putFloat(String key, float n); - - public void putString(String key, String n); - - public void putBoolean(String key, boolean n); - - public int getInteger(String key); - - public float getFloat(String key); - - public String getString(String key); - - public boolean getBoolean(String key); - - public String[] getAttributeNames(); - - public ISaveContext[] getChildren(); - - public String getName(); - - public String getValue(); - - public void setAttributes(Map map); - - public void setChildren(ISaveContext[] items); - - public void putChild(ISaveContext child); - - public void setName(String string); - - public void setValue(String string); - - public void addAttribute(String key, String value); - - public ISaveContext createChild(String name, String value); -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/TeamSubscriberFactory.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/TeamSubscriberFactory.java deleted file mode 100644 index 5b0217fde..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/TeamSubscriberFactory.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.core.subscribers; - -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.core.SaveContext; - -/** - * A subscriber factory is responsible for saving and restoring subscribers. Implementations must - * provide a public no-arg constructor. - * - * Example extension point for registering a subscriber factory: - * - * <extension point="org.eclipse.team.core.subscriber"> - * <subscriber class="org.eclipse.team.internal.webdav.DavSubscriberFactory"/> - *</extension> - * - * @see org.eclipse.team.core.subscribers.TeamSubscriber - */ -abstract public class TeamSubscriberFactory { - - /** - * A subscriber factory id identifies the factory type and the type of it's subscribers. Subscribers - * created via a specific factory should return a qualified name from TeamSubscriber#getID() that - * matches the id of their factory. - * <p> - * For example, a WebDav subscriber factory would have "org.eclipse.team.webdav.subscriber" as - * its id. Subsequent WebDav subscribers must construct their id based on this qualifier. - * - * @return the factory's id - */ - abstract public String getID(); - - /** - * Called to save the state of the given subscriber. The saved state should contain enough - * information so that a subcriber can be recreated from the returned <code>SaveContext</code>. - * A subscriber that doesn't have information to the saved should return <code>null</code>. - * <p> - * This may be called during workspace snapshot or at shutdown. - * </p> - * - * @return a save context containing the state of this subscriber - * @throws TeamException if there was a problem creating the save context. - */ - abstract public SaveContext saveSubscriber(TeamSubscriber subscriber) throws TeamException; - - /** - * Called to restore a subscriber with <code>id</code> from a given <code>SaveContext</code>. This is - * used to restore subscribers between workbench sessions. - * - * @return a subscriber instance - * @throws TeamException if there was a problem restoring from the save context. - */ - abstract public TeamSubscriber restoreSubscriber(QualifiedName id, SaveContext saveContext) throws TeamException; -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultFileModificationValidator.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultFileModificationValidator.java index b932844b7..82bf0d998 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultFileModificationValidator.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultFileModificationValidator.java @@ -22,10 +22,9 @@ public class DefaultFileModificationValidator implements IFileModificationValida private static final Status OK = Team.OK_STATUS; private IStatus getDefaultStatus(IFile file) { -// return file.isReadOnly() -// ? new Status(Status.ERROR, TeamPlugin.ID, IResourceStatus.READ_ONLY_LOCAL, Policy.bind("FileModificationValidator.fileIsReadOnly", file.getFullPath().toString()), null) //$NON-NLS-1$ -// : OK; - return OK; + return file.isReadOnly() + ? new Status(Status.ERROR, TeamPlugin.ID, IResourceStatus.READ_ONLY_LOCAL, Policy.bind("FileModificationValidator.fileIsReadOnly", file.getFullPath().toString()), null) //$NON-NLS-1$ + : OK; } /** diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/SaveContext.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/SaveContext.java deleted file mode 100644 index 56d8172b7..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/SaveContext.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.core; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.team.core.ISaveContext; - -/** - * Something (as a mark of visible sign) left by a material thing formely present but now - * lost or unknown. - * - * TODO: API doc if this class is to remain. Ideally it should replaced by a core mechanism which - * allows persisting somewhat like IMemento. - */ -public class SaveContext implements ISaveContext { - - private String name; - - private String value; - - private Map attributes; - - private List children = new ArrayList(2); - - public SaveContext() {} - - public SaveContext(String name, String value) { - setName(name); - setValue(value); - } - - public String getAttribute(String name) { - if(attributes == null) { - return null; - } - return (String)attributes.get(name); - } - - public void putInteger(String key, int n) { - addAttribute(key, String.valueOf(n)); - } - - public void putFloat(String key, float n) { - addAttribute(key, String.valueOf(n)); - } - - public void putString(String key, String n) { - addAttribute(key, n); - } - - public void putBoolean(String key, boolean n) { - addAttribute(key, String.valueOf(n)); - } - - public int getInteger(String key) { - String f = getAttribute(key); - if(f != null) { - return new Integer(f).intValue(); - } - return 0; - } - - public float getFloat(String key) { - String f = getAttribute(key); - if(f != null) { - return new Float(f).floatValue(); - } - return 0; - } - - public String getString(String key) { - return getAttribute(key); - } - - public boolean getBoolean(String key) { - String bool = getAttribute(key); - if(bool != null) { - return bool.equals("true") ? true : false; //$NON-NLS-1$ - } - return true; - } - - public String[] getAttributeNames() { - if(attributes == null) { - return new String[0]; - } - return (String[])attributes.keySet().toArray(new String[attributes.keySet().size()]); - } - - public ISaveContext[] getChildren() { - return (SaveContext[]) children.toArray(new SaveContext[children.size()]); - } - - public String getName() { - return name; - } - - public String getValue() { - return value; - } - - public void setAttributes(Map map) { - attributes = map; - } - - public void setChildren(ISaveContext[] items) { - children = new ArrayList(Arrays.asList(items)); - } - - public void putChild(ISaveContext child) { - children.add(child); - } - - public void setName(String string) { - name = string; - } - - public void setValue(String string) { - value = string; - } - - public void addAttribute(String key, String value) { - if(attributes == null) { - attributes = new HashMap(); - } - attributes.put(key, value); - } - - public String toString() { - return getName() + " ->" + attributes.toString(); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.ISaveContext#createChild(java.lang.String, java.lang.String) - */ - public ISaveContext createChild(String name, String value) { - return new SaveContext(name, value); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/SaveContextXMLContentHandler.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/SaveContextXMLContentHandler.java deleted file mode 100644 index 66f9785ec..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/SaveContextXMLContentHandler.java +++ /dev/null @@ -1,100 +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.core; - -import java.util.Stack; - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -/** - * SaveContextXMLContentHandler - */ -public class SaveContextXMLContentHandler extends DefaultHandler { - - private StringBuffer buffer = new StringBuffer(); - private Stack contextStack = new Stack(); - private SaveContext last; - - public SaveContextXMLContentHandler() { - } - - /** - * @see ContentHandler#characters(char[], int, int) - */ - public void characters(char[] chars, int startIndex, int length) throws SAXException { - buffer.append(chars, startIndex, length); - } - - /** - * @see ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String) - */ - public void endElement(String namespaceURI, String localName, String qName) throws SAXException { - SaveContext ctx = (SaveContext)contextStack.peek(); - String elementName = getElementName(namespaceURI, localName, qName); - if (!elementName.equals(ctx.getName())) { - // keep going - } else { - last = (SaveContext)contextStack.pop(); - if(! contextStack.isEmpty()) { - SaveContext parent = (SaveContext)contextStack.peek(); - parent.putChild(ctx); - } - } - } - - /** - * @see ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) - */ - public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { - SaveContext context = new SaveContext(); - String elementName = getElementName(namespaceURI, localName, qName); - context.setName(elementName); - for (int i = 0; i < atts.getLength(); i++) { - String attrName = getAttributeName(atts, i); - String attrValue = atts.getValue(i); - context.putString(attrName, attrValue); - } - // empty buffer - buffer = new StringBuffer(); - contextStack.push(context); - } - - public SaveContext getSaveContext() { - return last; - } - - /* - * Couldn't figure out from the SAX API exactly when localName vs. qName is used. - * However, the XML for subscribers 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; - } - } - - /* - * See getElementName() reasoning for why this method is needed. - */ - private String getAttributeName(Attributes atts, int i) { - String localName = atts.getLocalName(i); - if (localName != null && localName.length() > 0) { - return localName; - } else { - return atts.getQName(i); - } - } -} diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/SaveContextXMLWriter.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/SaveContextXMLWriter.java deleted file mode 100644 index 039f42981..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/SaveContextXMLWriter.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.core; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Status; -import org.eclipse.team.core.ISaveContext; -import org.eclipse.team.core.TeamException; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -public class SaveContextXMLWriter extends PrintWriter { - protected int tab; - - /* constants */ - protected static final String XML_VERSION = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; //$NON-NLS-1$ - - public SaveContextXMLWriter(OutputStream output) throws UnsupportedEncodingException { - super(new OutputStreamWriter(output, "UTF8")); //$NON-NLS-1$ - tab = 0; - println(XML_VERSION); - } - public void endTag(String name) { - tab--; - printTag('/' + name, null); - } - public void printSimpleTag(String name, Object value) { - if (value != null) { - printTag(name, null, true, false); - print(getEscaped(String.valueOf(value))); - printTag('/' + name, null, false, true); - } - } - public void printTabulation() { - for (int i = 0; i < tab; i++) - super.print('\t'); - } - private void printTag(String name, HashMap parameters) { - printTag(name, parameters, true, true); - } - private void printTag(String name, HashMap parameters, boolean tab, boolean newLine) { - printTag(name, parameters, tab, newLine, false); - } - private void printTag(String name, HashMap parameters, boolean tab, boolean newLine, boolean end) { - StringBuffer sb = new StringBuffer(); - sb.append("<"); //$NON-NLS-1$ - sb.append(name); - if (parameters != null) - for (Enumeration enum = Collections.enumeration(parameters.keySet()); enum.hasMoreElements();) { - sb.append(" "); //$NON-NLS-1$ - String key = (String) enum.nextElement(); - sb.append(key); - sb.append("=\""); //$NON-NLS-1$ - sb.append(getEscaped(String.valueOf(parameters.get(key)))); - sb.append("\""); //$NON-NLS-1$ - } - if (end) - sb.append('/'); - sb.append(">"); //$NON-NLS-1$ - if (tab) - printTabulation(); - if (newLine) - println(sb.toString()); - else - print(sb.toString()); - } - public void startTag(String name, HashMap parameters) { - startTag(name, parameters, true); - } - public void startTag(String name, HashMap parameters, boolean newLine) { - printTag(name, parameters, true, newLine); - tab++; - } - public void startAndEndTag(String name, HashMap parameters, boolean newLine) { - printTag(name, parameters, true, true, true); - } - private static void appendEscapedChar(StringBuffer buffer, char c) { - String replacement = getReplacement(c); - if (replacement != null) { - buffer.append('&'); - buffer.append(replacement); - buffer.append(';'); - } else { - buffer.append(c); - } - } - public static String getEscaped(String s) { - StringBuffer result = new StringBuffer(s.length() + 10); - for (int i = 0; i < s.length(); ++i) - appendEscapedChar(result, s.charAt(i)); - return result.toString(); - } - private static String getReplacement(char c) { - // Encode special XML characters into the equivalent character references. - // These five are defined by default for all XML documents. - switch (c) { - case '<' : - return "lt"; //$NON-NLS-1$ - case '>' : - return "gt"; //$NON-NLS-1$ - case '"' : - return "quot"; //$NON-NLS-1$ - case '\'' : - return "apos"; //$NON-NLS-1$ - case '&' : - return "amp"; //$NON-NLS-1$ - } - return null; - } - public void write(ISaveContext item) { - - // start tag for this element - String name = item.getName(); - String value = item.getValue(); - String[] attributeNames = item.getAttributeNames(); - HashMap attributes = new HashMap(attributeNames.length); - for (int i = 0; i < attributeNames.length; i++) { - String attrName = attributeNames[i]; - attributes.put(attrName, item.getAttribute(attrName)); - } - startTag(name, attributes); - - // write out child elements - ISaveContext[] children = item.getChildren(); - if(children != null) { - for (int i = 0; i < children.length; i++) { - ISaveContext child = children[i]; - write(child); - } - } - - // value - if(value != null) { - println(value); - } - - // end tag for this element - endTag(name); - } - - static public void writeXMLPluginMetaFile(Plugin plugin, String filename, SaveContext element) throws TeamException { - IPath pluginStateLocation = plugin.getStateLocation(); - File tempFile = pluginStateLocation.append(filename + ".tmp").toFile(); //$NON-NLS-1$ - File stateFile = pluginStateLocation.append(filename).toFile(); - try { - SaveContextXMLWriter writer = new SaveContextXMLWriter(new BufferedOutputStream(new FileOutputStream(tempFile))); - try { - writer.write(element); - } finally { - writer.close(); - } - if (stateFile.exists()) { - stateFile.delete(); - } - boolean renamed = tempFile.renameTo(stateFile); - if (!renamed) { - throw new TeamException(new Status(Status.ERROR, TeamPlugin.ID, TeamException.UNABLE, Policy.bind("RepositoryManager.rename", tempFile.getAbsolutePath()), null)); //$NON-NLS-1$ - } - } catch (IOException e) { - throw new TeamException(new Status(Status.ERROR, TeamPlugin.ID, TeamException.UNABLE, Policy.bind("RepositoryManager.save",stateFile.getAbsolutePath()), e)); //$NON-NLS-1$ - } - } - - static public void deleteXMLPluginMetaFile(Plugin plugin, String filename) { - IPath pluginStateLocation = plugin.getStateLocation(); - File stateFile = pluginStateLocation.append(filename).toFile(); - if (stateFile.exists()) { - stateFile.delete(); - } - } - - static public SaveContext readXMLPluginMetaFile(Plugin plugin, String filename) throws TeamException { - BufferedInputStream is = null; - try { - IPath pluginStateLocation = plugin.getStateLocation(); - File file = pluginStateLocation.append(filename).toFile(); //$NON-NLS-1$ - if (file.exists()) { - is = new BufferedInputStream(new FileInputStream(file)); - SAXParserFactory factory = SAXParserFactory.newInstance(); - SAXParser parser = factory.newSAXParser(); - SaveContextXMLContentHandler handler = new SaveContextXMLContentHandler(); - parser.parse(new InputSource(is), handler); - return handler.getSaveContext(); - } - return null; - } catch (SAXException ex) { - throw new TeamException(Policy.bind("RepositoryManager.ioException"), ex); //$NON-NLS-1$ - } catch (IOException e) { - throw new TeamException(Policy.bind("RepositoryManager.ioException"), e); //$NON-NLS-1$ - } catch (ParserConfigurationException e) { - throw new TeamException(Policy.bind("RepositoryManager.ioException"), e); //$NON-NLS-1$ - } finally { - if(is != null) { - try { - is.close(); - } catch (IOException e1) { - throw new TeamException(Policy.bind("RepositoryManager.ioException"), e1); //$NON-NLS-1$ - } - } - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java index dc41ef954..7039863ee 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java @@ -10,17 +10,31 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.core; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.team.core.*; -import org.eclipse.team.core.ISaveContext; -import org.eclipse.team.core.subscribers.*; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IResourceDeltaVisitor; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.team.core.RepositoryProvider; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.core.subscribers.ContentComparisonCriteria; +import org.eclipse.team.core.subscribers.ITeamResourceChangeListener; +import org.eclipse.team.core.subscribers.RemoteBytesSynchronizer; +import org.eclipse.team.core.subscribers.RemoteSynchronizer; +import org.eclipse.team.core.subscribers.SyncInfo; +import org.eclipse.team.core.subscribers.TeamDelta; import org.eclipse.team.core.sync.IRemoteResource; import org.eclipse.team.internal.ccvs.core.syncinfo.MergedSynchronizer; import org.eclipse.team.internal.ccvs.core.syncinfo.RemoteTagSynchronizer; -import org.eclipse.team.internal.core.SaveContext; /** * A CVSMergeSubscriber is responsible for maintaining the remote trees for a merge into @@ -158,58 +172,7 @@ public class CVSMergeSubscriber extends CVSSyncTreeSubscriber implements IResour public boolean isSupervised(IResource resource) throws TeamException { return getBaseSynchronizer().hasRemote(resource) || getRemoteSynchronizer().hasRemote(resource); } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.TeamSubscriber#saveState(org.eclipse.team.internal.core.SaveContext) - */ - public void saveState(ISaveContext state) { - // start and end tags - state.putString("startTag", start.getName()); //$NON-NLS-1$ - state.putInteger("startTagType", start.getType()); //$NON-NLS-1$ - state.putString("endTag", end.getName()); //$NON-NLS-1$ - state.putInteger("endTagType", end.getType()); //$NON-NLS-1$ - - // resources roots - SaveContext[] ctxRoots = new SaveContext[roots.size()]; - int i = 0; - for (Iterator it = roots.iterator(); it.hasNext(); i++) { - IResource element = (IResource) it.next(); - ctxRoots[i] = new SaveContext(); - ctxRoots[i].setName("resource"); //$NON-NLS-1$ - ctxRoots[i].putString("fullpath", element.getFullPath().toString()); //$NON-NLS-1$ - } - state.setChildren(ctxRoots); - } - - public static CVSMergeSubscriber restore(QualifiedName id, ISaveContext saveContext) throws CVSException { - String name = saveContext.getName(); - CVSTag start = new CVSTag(saveContext.getString("startTag"), saveContext.getInteger("startTagType")); //$NON-NLS-1$ //$NON-NLS-2$ - CVSTag end = new CVSTag(saveContext.getString("endTag"), saveContext.getInteger("endTagType")); //$NON-NLS-1$ //$NON-NLS-2$ - - ISaveContext[] ctxRoots = saveContext.getChildren(); - if(ctxRoots == null || ctxRoots.length == 0) { - throw new CVSException(Policy.bind("CVSMergeSubscriber.19", id.toString())); //$NON-NLS-1$ - } - - List resources = new ArrayList(); - for (int i = 0; i < ctxRoots.length; i++) { - ISaveContext context = ctxRoots[i]; - IPath path = new Path(context.getString("fullpath")); //$NON-NLS-1$ - IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path, true /* include phantoms */); - if(resource != null) { - resources.add(resource); - } else { - // log that a resource previously in the merge set is no longer in the workspace - CVSProviderPlugin.log(CVSStatus.INFO, Policy.bind("CVSMergeSubscriber.21", path.toString()), null); //$NON-NLS-1$ - } - } - if(resources.isEmpty()) { - throw new CVSException(Policy.bind("CVSMergeSubscriber.22", id.toString())); //$NON-NLS-1$ - } - IResource[] roots = (IResource[]) resources.toArray(new IResource[resources.size()]); - return new CVSMergeSubscriber(id, roots, start, end); - } - + public CVSTag getStartTag() { return start; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties index 8cfaeafba..2c0dd5574 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties @@ -1042,3 +1042,8 @@ action.SynchronizeViewUpdate.tooltip=Update All Incoming Changes action.SynchronizeViewUpdate.description=Update All Incoming Changes action.SynchronizeViewUpdate.image=checkout_action.gif +MergeSynchronizeParticipant.8=Missing id initializing cvs merge participant +MergeSynchronizeParticipant.9=Unable to initialize cvs merge subscriber +MergeSynchronizeParticipant.10=Missing root nodes in cvs merge subscriber memento: {0} +MergeSynchronizeParticipant.11=Root resource in cvs merge subscriber is no longer in workspace, ignoring: {0} +MergeSynchronizeParticipant.12=Missing root resources for cvs merge subscriber: {0} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java index 0e124a527..410e4586c 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java @@ -10,24 +10,33 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.subscriber; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.team.core.ISaveContext; +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.*; import org.eclipse.team.core.subscribers.TeamSubscriber; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSMergeSubscriber; +import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; +import org.eclipse.team.internal.ccvs.ui.Policy; import org.eclipse.team.internal.ui.synchronize.sets.SubscriberInput; import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.ISynchronizeView; -import org.eclipse.team.ui.synchronize.TeamSubscriberParticipant; +import org.eclipse.team.ui.synchronize.*; +import org.eclipse.ui.IMemento; import org.eclipse.ui.PartInitException; import org.eclipse.ui.part.IPageBookViewPage; public class MergeSynchronizeParticipant extends TeamSubscriberParticipant { - private final static String CTX_QUALIFIER = "qualifier"; - private final static String CTX_LOCALNAME = "localname"; + private final static String CTX_QUALIFIER = "qualifier"; //$NON-NLS-1$ + private final static String CTX_LOCALNAME = "localname"; //$NON-NLS-1$ + private final static String CTX_ROOT = "root"; //$NON-NLS-1$ + private final static String CTX_ROOT_PATH = "root_resource"; //$NON-NLS-1$ + private final static String CTX_START_TAG = "start_tag"; //$NON-NLS-1$ + private final static String CTX_START_TAG_TYPE = "start_tag_type"; //$NON-NLS-1$ + private final static String CTX_END_TAG = "end_tag"; //$NON-NLS-1$ + private final static String CTX_END_TAG_TYPE = "end_tag_type"; //$NON-NLS-1$ public MergeSynchronizeParticipant() { super(); @@ -38,8 +47,6 @@ public class MergeSynchronizeParticipant extends TeamSubscriberParticipant { setSubscriber(subscriber); } - - /* (non-Javadoc) * @see org.eclipse.team.ui.sync.TeamSubscriberParticipant#setSubscriber(org.eclipse.team.core.subscribers.TeamSubscriber) */ @@ -47,7 +54,8 @@ public class MergeSynchronizeParticipant extends TeamSubscriberParticipant { super.setSubscriber(subscriber); String id = CVSMergeSubscriber.QUALIFIED_NAME; try { - setInitializationData(TeamUI.getSynchronizeManager().getParticipantDescriptor(id).getConfigurationElement(), id, null); + ISynchronizeParticipantDescriptor descriptor = TeamUI.getSynchronizeManager().getParticipantDescriptor(id); + setInitializationData(descriptor); } catch (CoreException e) { CVSUIPlugin.log(e); } @@ -56,29 +64,29 @@ public class MergeSynchronizeParticipant extends TeamSubscriberParticipant { /* (non-Javadoc) * @see org.eclipse.team.ui.sync.ISynchronizeParticipant#init(org.eclipse.team.ui.sync.ISynchronizeView, org.eclipse.team.core.ISaveContext) */ - public void restoreState(ISaveContext context) throws PartInitException { - String qualifier = context.getAttribute(CTX_QUALIFIER); - String localname = context.getAttribute(CTX_LOCALNAME); + public void restoreState(IMemento context) throws PartInitException { + String qualifier = context.getString(CTX_QUALIFIER); + String localname = context.getString(CTX_LOCALNAME); if(qualifier == null || localname == null) { - throw new PartInitException("Missing id initializing cvs merge participant"); + throw new PartInitException(Policy.bind("MergeSynchronizeParticipant.8")); //$NON-NLS-1$ } try { - setSubscriber(CVSMergeSubscriber.restore(new QualifiedName(qualifier, localname), context)); + setSubscriber(read(new QualifiedName(qualifier, localname), context)); } catch (CVSException e) { - throw new PartInitException("Unable to initialize cvs merge subscriber", e); + throw new PartInitException(Policy.bind("MergeSynchronizeParticipant.9"), e); //$NON-NLS-1$ } } /* (non-Javadoc) * @see org.eclipse.team.ui.sync.ISynchronizeParticipant#saveState(org.eclipse.team.core.ISaveContext) */ - public void saveState(ISaveContext context) { + public void saveState(IMemento context) { SubscriberInput input = getInput(); CVSMergeSubscriber s = (CVSMergeSubscriber)input.getSubscriber(); QualifiedName sId = s.getId(); - context.addAttribute(CTX_QUALIFIER, sId.getQualifier()); - context.addAttribute(CTX_LOCALNAME, sId.getLocalName()); - s.saveState(context); + context.putString(CTX_QUALIFIER, sId.getQualifier()); + context.putString(CTX_LOCALNAME, sId.getLocalName()); + write(s, context); } /* (non-Javadoc) @@ -102,4 +110,53 @@ public class MergeSynchronizeParticipant extends TeamSubscriberParticipant { public String getName() { return ((CVSMergeSubscriber)getInput().getSubscriber()).getName(); } + + /* (non-Javadoc) + * @see org.eclipse.team.core.subscribers.TeamSubscriber#saveState(org.eclipse.team.internal.core.SaveContext) + */ + private void write(CVSMergeSubscriber s, IMemento memento) { + // start and end tags + CVSTag start = s.getStartTag(); + CVSTag end = s.getEndTag(); + memento.putString(CTX_START_TAG, start.getName()); + memento.putInteger(CTX_START_TAG_TYPE, start.getType()); + memento.putString(CTX_END_TAG, end.getName()); + memento.putInteger(CTX_END_TAG_TYPE, end.getType()); + + // resource roots + IResource[] roots = s.roots(); + for (int i = 0; i < roots.length; i++) { + IResource resource = roots[i]; + IMemento rootNode = memento.createChild(CTX_ROOT); + rootNode.putString(CTX_ROOT_PATH, resource.getFullPath().toString()); + } + } + + private CVSMergeSubscriber read(QualifiedName id, IMemento memento) throws CVSException { + CVSTag start = new CVSTag(memento.getString(CTX_START_TAG), memento.getInteger(CTX_START_TAG_TYPE).intValue()); //$NON-NLS-1$ //$NON-NLS-2$ + CVSTag end = new CVSTag(memento.getString(CTX_END_TAG), memento.getInteger(CTX_END_TAG_TYPE).intValue()); //$NON-NLS-1$ //$NON-NLS-2$ + + IMemento[] rootNodes = memento.getChildren(CTX_ROOT); + if(rootNodes == null || rootNodes.length == 0) { + throw new CVSException(Policy.bind("MergeSynchronizeParticipant.10",id.toString())); //$NON-NLS-1$ + } + + 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); + } else { + // log that a resource previously in the merge set is no longer in the workspace + CVSProviderPlugin.log(CVSStatus.INFO, Policy.bind("MergeSynchronizeParticipant.11", resource.getFullPath().toString()), null); //$NON-NLS-1$ + } + } + if(resources.isEmpty()) { + throw new CVSException(Policy.bind("MergeSynchronizeParticipant.12", id.toString())); //$NON-NLS-1$ + } + IResource[] roots = (IResource[]) resources.toArray(new IResource[resources.size()]); + return new CVSMergeSubscriber(id, roots, start, end); + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java index 627a05251..1d1dbc1ed 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java @@ -10,11 +10,11 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.subscriber; -import org.eclipse.team.core.ISaveContext; import org.eclipse.team.core.subscribers.TeamSubscriber; import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; import org.eclipse.team.ui.synchronize.ISynchronizeView; import org.eclipse.team.ui.synchronize.TeamSubscriberParticipant; +import org.eclipse.ui.IMemento; import org.eclipse.ui.PartInitException; import org.eclipse.ui.part.IPageBookViewPage; @@ -25,7 +25,7 @@ public class WorkspaceSynchronizeParticipant extends TeamSubscriberParticipant { /* (non-Javadoc) * @see org.eclipse.team.ui.sync.ISynchronizeParticipant#init(org.eclipse.team.ui.sync.ISynchronizeView, org.eclipse.team.core.ISaveContext) */ - public void restoreState(ISaveContext context) throws PartInitException { + public void restoreState(IMemento memento) throws PartInitException { TeamSubscriber subscriber = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(); setSubscriber(subscriber); } @@ -33,7 +33,7 @@ public class WorkspaceSynchronizeParticipant extends TeamSubscriberParticipant { /* (non-Javadoc) * @see org.eclipse.team.ui.sync.ISynchronizeParticipant#saveState(org.eclipse.team.core.ISaveContext) */ - public void saveState(ISaveContext context) { + public void saveState(IMemento memento) { // no state to save } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties index 7eb2a75f6..2f3233776 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties @@ -458,3 +458,4 @@ SyncViewerPreferencePage.19=Show all synchronization information in a resource\' TeamSubscriberParticipantPage.7=Resource TeamSubscriberParticipantPage.8=In Folder TeamSubscriberSyncPage.labelWithSyncKind={0} {1} +AbstractSynchronizeParticipant.4=Cannot initialize participant. Wrong descriptor type diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/ISynchronizeParticipantDescriptor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/ISynchronizeParticipantDescriptor.java deleted file mode 100644 index 0cf403a99..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/ISynchronizeParticipantDescriptor.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.registry; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.jface.resource.ImageDescriptor; - -public interface ISynchronizeParticipantDescriptor { - public String getDescription(); - public String getId(); - public String getType(); - public ImageDescriptor getImageDescriptor(); - public boolean isStatic(); - public IConfigurationElement getConfigurationElement(); -}
\ 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 index 7e9755c15..a722b3468 100644 --- 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 @@ -15,6 +15,7 @@ import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.team.ui.synchronize.*; import org.eclipse.ui.IViewPart; import org.eclipse.ui.internal.WorkbenchImages; import org.eclipse.ui.internal.WorkbenchPlugin; 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 index cba004925..cbf4cb7ca 100644 --- 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 @@ -10,19 +10,49 @@ *******************************************************************************/ package org.eclipse.team.internal.ui.synchronize; -import java.util.*; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; +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.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.ISafeRunnable; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; import org.eclipse.jface.util.ListenerList; -import org.eclipse.team.core.ISaveContext; import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.core.SaveContext; -import org.eclipse.team.internal.core.SaveContextXMLWriter; -import org.eclipse.team.internal.ui.*; -import org.eclipse.team.internal.ui.registry.*; +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.registry.SynchronizeParticipantDescriptor; +import org.eclipse.team.internal.ui.registry.SynchronizeParticipantRegistry; import org.eclipse.team.ui.ITeamUIConstants; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.*; +import org.eclipse.team.ui.synchronize.ISynchronizeManager; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor; +import org.eclipse.team.ui.synchronize.ISynchronizeParticipantListener; +import org.eclipse.team.ui.synchronize.ISynchronizeView; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.WorkbenchException; +import org.eclipse.ui.XMLMemento; /** * Manages the registered synchronize participants. It handles notification @@ -262,7 +292,7 @@ public class SynchronizeManager implements ISynchronizeManager { participantRegistry.readRegistry(Platform.getPluginRegistry(), TeamUIPlugin.ID, ITeamUIConstants.PT_SYNCPARTICIPANTS); // Instantiate and register any dynamic participants saved from a previous session. - restoreDynamicParticipants(); + restoreSavedParticipants(); // Instantiate and register any static participant that has not already been created. initializeStaticParticipants(); @@ -276,7 +306,7 @@ public class SynchronizeManager implements ISynchronizeManager { List participants = new ArrayList(); for (int i = 0; i < desc.length; i++) { SynchronizeParticipantDescriptor descriptor = desc[i]; - if(descriptor.isStatic()) { + if(descriptor.isStatic() && ! synchronizeParticipants.containsKey(descriptor.getId())) { participants.add(createParticipant(null, descriptor)); } } @@ -284,76 +314,79 @@ public class SynchronizeManager implements ISynchronizeManager { addSynchronizeParticipants((ISynchronizeParticipant[]) participants.toArray(new ISynchronizeParticipant[participants.size()])); } } - + /** * Restores participants that have been saved between sessions. */ - private void restoreDynamicParticipants() throws TeamException, CoreException { - ISaveContext root = SaveContextXMLWriter.readXMLPluginMetaFile(TeamUIPlugin.getPlugin(), FILENAME); - if(root != null && root.getName().equals(CTX_PARTICIPANTS)) { - List participants = new ArrayList(); - ISaveContext[] contexts = root.getChildren(); - for (int i = 0; i < contexts.length; i++) { - ISaveContext context = contexts[i]; - if(context.getName().equals(CTX_PARTICIPANT)) { - String id = context.getAttribute(CTX_ID); - SynchronizeParticipantDescriptor desc = participantRegistry.find(id); - if(desc != null) { - IConfigurationElement cfgElement = desc.getConfigurationElement(); - participants.add(createParticipant(context, desc)); - } else { - TeamUIPlugin.log(new Status(IStatus.ERROR, TeamUIPlugin.ID, 1, Policy.bind("SynchronizeManager.9", id), null)); //$NON-NLS-1$ - } - } - } - if(! participants.isEmpty()) { - addSynchronizeParticipants((ISynchronizeParticipant[]) participants.toArray(new ISynchronizeParticipant[participants.size()])); + private void restoreSavedParticipants() throws TeamException, CoreException { + File file = getStateFile(); + Reader reader; + try { + reader = new BufferedReader(new FileReader(file)); + } catch (FileNotFoundException e) { + return; + } + List participants = new ArrayList(); + 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); + SynchronizeParticipantDescriptor desc = participantRegistry.find(id); + if(desc != null) { + IConfigurationElement cfgElement = desc.getConfigurationElement(); + participants.add(createParticipant(memento2.getChild(CTX_PARTICIPANT_DATA), desc)); + } else { + TeamUIPlugin.log(new Status(IStatus.ERROR, TeamUIPlugin.ID, 1, Policy.bind("SynchronizeManager.9", id), null)); //$NON-NLS-1$ } } + if(! participants.isEmpty()) { + addSynchronizeParticipants((ISynchronizeParticipant[]) participants.toArray(new ISynchronizeParticipant[participants.size()])); + } } /** * Creates a participant instance with the given id from the participant description */ - private ISynchronizeParticipant createParticipant(ISaveContext context, SynchronizeParticipantDescriptor desc) throws CoreException { + private ISynchronizeParticipant createParticipant(IMemento memento, SynchronizeParticipantDescriptor desc) throws CoreException { ISynchronizeParticipant participant = (ISynchronizeParticipant)TeamUIPlugin.createExtension(desc.getConfigurationElement(), SynchronizeParticipantDescriptor.ATT_CLASS); participant.setInitializationData(desc.getConfigurationElement(), null, null); - participant.restoreState(context); + participant.restoreState(memento); return participant; } - + /** * Saves a file containing the list of participant ids that are registered with this * manager. Each participant is also given the chance to save it's state. */ private void saveState() { - ISaveContext root = new SaveContext(); - root.setName(CTX_PARTICIPANTS); + XMLMemento xmlMemento = XMLMemento.createWriteRoot(CTX_PARTICIPANTS); List children = new ArrayList(); + for (Iterator it = synchronizeParticipants.keySet().iterator(); it.hasNext();) { + String id = (String) it.next(); + List participants = (List)synchronizeParticipants.get(id); + for (Iterator it2 = participants.iterator(); it2.hasNext(); ) { + ISynchronizeParticipant participant = (ISynchronizeParticipant) it2.next(); + IMemento participantNode = xmlMemento.createChild(CTX_PARTICIPANT); + participantNode.putString(CTX_ID, participant.getId()); + participant.saveState(participantNode.createChild(CTX_PARTICIPANT_DATA)); + } + } try { - for (Iterator it = synchronizeParticipants.keySet().iterator(); it.hasNext();) { - String id = (String) it.next(); - SynchronizeParticipantDescriptor desc = participantRegistry.find(id); - if(desc == null) { - TeamUIPlugin.log(new Status(IStatus.ERROR, TeamUIPlugin.ID, 1, Policy.bind("SynchronizeManager.9", id), null)); //$NON-NLS-1$ - } - if(! desc.isStatic()) { - List participants = (List)synchronizeParticipants.get(id); - for (Iterator it2 = participants.iterator(); it2.hasNext(); ) { - ISynchronizeParticipant participant = (ISynchronizeParticipant) it2.next(); - ISaveContext item = new SaveContext(); - item.setName(CTX_PARTICIPANT); - item.addAttribute(CTX_ID, participant.getId()); - participant.saveState(item); - children.add(item); - } - } + Writer writer = new BufferedWriter(new FileWriter(getStateFile())); + try { + xmlMemento.save(writer); + } finally { + writer.close(); } - root.setChildren((SaveContext[])children.toArray(new SaveContext[children.size()])); - SaveContextXMLWriter.writeXMLPluginMetaFile(TeamUIPlugin.getPlugin(), FILENAME, (SaveContext)root); - } catch (TeamException e) { + } 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$ } /* (non-Javadoc) 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 index 4c0bb76f2..d7a467d3c 100644 --- 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 @@ -10,15 +10,13 @@ *******************************************************************************/ 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.Platform; +import org.eclipse.core.runtime.*; 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.util.*; 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.registry.SynchronizeParticipantDescriptor; import org.eclipse.team.ui.TeamImages; import org.eclipse.team.ui.TeamUI; @@ -208,7 +206,7 @@ public abstract class AbstractSynchronizeParticipant implements ISynchronizePart configElement = config; // Id - fId = config.getAttribute("id"); + fId = config.getAttribute("id"); //$NON-NLS-1$ // Title. fName = config.getAttribute("name"); //$NON-NLS-1$ @@ -222,6 +220,14 @@ public abstract class AbstractSynchronizeParticipant implements ISynchronizePart 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 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 index 42a340f86..2d710f149 100644 --- 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 @@ -10,21 +10,18 @@ *******************************************************************************/ package org.eclipse.team.ui.synchronize; -import org.eclipse.team.internal.ui.registry.ISynchronizeParticipantDescriptor; import org.eclipse.ui.IWorkbenchPage; /** * Manages synchronization view participants. Clients can programatically add - * or remove participants via this manager. Whereas static participants - * defined in a plugin.xml file are added automatically by the manager. + * or remove participants via this manager. * <p> * Clients are not intended to implement this interface. * </p> * @see ISynchronizeParticipant * @since 3.0 */ -public interface ISynchronizeManager { - +public interface ISynchronizeManager { /** * Registers the given listener for participant notifications. Has * no effect if an identical listener is already registered. @@ -74,10 +71,11 @@ public interface ISynchronizeManager { public ISynchronizeView showSynchronizeViewInActivePage(IWorkbenchPage page); /** - * Returns the registered synchronize participants with the given id. + * Returns the registered synchronize participants with the given id. It is + * possible to have multiple instances of the same participant type. * * @return the registered synchronize participants with the given id, or - * <code>null</code> if one with that id is not registered. + * <code>null</code> if none with that id is not registered. */ public ISynchronizeParticipant[] find(String id); 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 index dece9c852..cee64e79d 100644 --- 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 @@ -13,7 +13,7 @@ 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.team.core.ISaveContext; +import org.eclipse.ui.IMemento; import org.eclipse.ui.PartInitException; import org.eclipse.ui.part.IPageBookViewPage; @@ -22,20 +22,21 @@ import org.eclipse.ui.part.IPageBookViewPage; * resources and a remote location that is used to share those resources. The * Synchronize View displays synchronize participants. * <p> - * Clients may implement this interface. + * A participant must create a page that will be displayed in the + * ISynchronizeView page book view. Clients may implement this interface. * </p> * @see ISynchronizeView * @see ISynchronizeManager - * * @since 3.0 */ public interface ISynchronizeParticipant extends IExecutableExtension { /** - * Returns the unique id that identified the <i>type <i>of this - * synchronize participant. + * 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. + * @return the unique id that identified the <i>type</i> of this + * synchronize participant. */ public String getId(); @@ -51,7 +52,7 @@ public interface ISynchronizeParticipant extends IExecutableExtension { * if none. * * @return an image descriptor for this synchronize participant, or <code>null</code> - * if none + * if none */ public ImageDescriptor getImageDescriptor(); @@ -60,36 +61,35 @@ public interface ISynchronizeParticipant extends IExecutableExtension { * page is displayed for this synchronize participant in the given * synchronize view. * - * @param view - * the view in which the page is to be created + * @param view the view in which the page is to be created * @return a page book view page representation of this synchronize - * participant + * participant */ public IPageBookViewPage createPage(ISynchronizeView view); /** - * Initializes this participant with the given synchronize view. The - * instance id is passed to the participant. + * 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 * synchronize view construction. It marks the start of the views's * lifecycle. Clients must not call this method. - * </p> - * - * @param view - * the synchronize view reconstructing this participant - * @param saveContext - * the ISynchronizeParticipant state or null if there is no - * previous saved state - * @exception PartInitException - * if this participant was not initialized successfully + * </p> + * @param view the synchronize view reconstructing this participant + * @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 restoreState(ISaveContext context) throws PartInitException; + public void restoreState(IMemento memento) throws PartInitException; /** - * Saves the participants object state. + * Saves the participants object state within the memento. This state + * will be available when the participant is restored. + * @param memento a memento to receive the object state */ - public void saveState(ISaveContext context); + public void saveState(IMemento memento); /** * Adds a listener for changes to properties of this synchronize @@ -102,14 +102,11 @@ public interface ISynchronizeParticipant extends IExecutableExtension { * 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> + * </ul></p> * <p> * Clients may define additional properties as required. * </p> - * - * @param listener - * a property change listener + * @param listener a property change listener */ public void addPropertyChangeListener(IPropertyChangeListener listener); @@ -117,8 +114,7 @@ public interface ISynchronizeParticipant extends IExecutableExtension { * 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 + * @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 new file mode 100644 index 000000000..1eed9ba6d --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipantDescriptor.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * 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> + * This interface is not intended to be implemented by clients. + * </p> + * @see ISynchronizeManager#getParticipantDescriptor(String) + * @since 3.0 + */ +public interface ISynchronizeParticipantDescriptor { + /** + * 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 <code>true</code> if the participant is static and + * <code>false</code> otherwise. Static participants are created + * automatically by the synchronize manager at startup whereas + * not static participants are created by client code and registered + * with the manager. + * + * @return <code>true</code> if the participant is static and + * <code>false</code> otherwise + */ + public boolean isStatic(); +}
\ 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 index 4a443899f..6dde603ae 100644 --- 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 @@ -18,8 +18,7 @@ package org.eclipse.team.ui.synchronize; * </p> * @since 3.0 */ -public interface ISynchronizeParticipantListener { - +public interface ISynchronizeParticipantListener { /** * Notification the given participants have been added to the synchronize * manager. 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 index 86c384eb7..fc080bcdf 100644 --- 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 @@ -29,7 +29,6 @@ import org.eclipse.ui.IViewPart; * @since 3.0 */ public interface ISynchronizeView extends IViewPart { - /** * The id for this view */ diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipant.java index b7fe48f06..475c812bc 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipant.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipant.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * 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.resources.IResource; diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantLabelProvider.java index 225b09cd2..7659ecb1d 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantLabelProvider.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantLabelProvider.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * 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.HashMap; @@ -29,8 +39,10 @@ import org.eclipse.ui.model.WorkbenchLabelProvider; /** * Provides basic labels for the subscriber participant synchronize view * page. This class provides a facility for subclasses to define annotations - * on the labels and icons of adaptable objects. + * on the labels and icons of adaptable objects by overriding + * <code>decorateText()</code> and <code>decorateImage</code>. * + * @see TeamSubscriberParticipantPage#getLabelProvider() * @since 3.0 */ public class TeamSubscriberParticipantLabelProvider extends LabelProvider implements ITableLabelProvider { diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantPage.java index e23480b3c..cd105654b 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantPage.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantPage.java @@ -1,79 +1,53 @@ +/******************************************************************************* + * 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.Iterator; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; +import org.eclipse.jface.action.*; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.AbstractTreeViewer; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -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.IStructuredSelection; -import org.eclipse.jface.viewers.OpenEvent; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.*; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionListener; 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.swt.widgets.Menu; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.*; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.subscribers.SyncInfo; -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.*; import org.eclipse.team.internal.ui.jobs.JobBusyCursor; -import org.eclipse.team.internal.ui.synchronize.actions.ComparisonCriteriaActionGroup; -import org.eclipse.team.internal.ui.synchronize.actions.INavigableControl; -import org.eclipse.team.internal.ui.synchronize.actions.NavigateAction; -import org.eclipse.team.internal.ui.synchronize.actions.OpenWithActionGroup; -import org.eclipse.team.internal.ui.synchronize.actions.RefactorActionGroup; -import org.eclipse.team.internal.ui.synchronize.actions.RefreshAction; -import org.eclipse.team.internal.ui.synchronize.actions.StatusLineContributionGroup; -import org.eclipse.team.internal.ui.synchronize.actions.SyncViewerShowPreferencesAction; -import org.eclipse.team.internal.ui.synchronize.actions.ToggleViewLayoutAction; -import org.eclipse.team.internal.ui.synchronize.actions.WorkingSetFilterActionGroup; +import org.eclipse.team.internal.ui.synchronize.actions.*; import org.eclipse.team.internal.ui.synchronize.sets.SubscriberInput; -import org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider; -import org.eclipse.team.internal.ui.synchronize.views.SyncSetTableContentProvider; -import org.eclipse.team.internal.ui.synchronize.views.SyncTableViewer; -import org.eclipse.team.internal.ui.synchronize.views.SyncTreeViewer; -import org.eclipse.team.internal.ui.synchronize.views.SyncViewerSorter; -import org.eclipse.team.internal.ui.synchronize.views.SyncViewerTableSorter; +import org.eclipse.team.internal.ui.synchronize.views.*; import org.eclipse.team.ui.synchronize.actions.SubscriberAction; import org.eclipse.team.ui.synchronize.actions.SyncInfoFilter; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.IPageBookViewPage; -import org.eclipse.ui.part.IPageSite; -import org.eclipse.ui.part.IShowInSource; -import org.eclipse.ui.part.ShowInContext; +import org.eclipse.ui.*; +import org.eclipse.ui.part.*; import org.eclipse.ui.views.navigator.ResourceSorter; +/** + * A synchronize view page that works with participants that are subclasses of + * {@link TeamSubscriberParticipant}. 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 control. + * </p> + * @since 3.0 + */ public class TeamSubscriberParticipantPage implements IPageBookViewPage, IPropertyChangeListener { // The viewer that is shown in the view. Currently this can be either a table or tree viewer. private StructuredViewer viewer; @@ -212,7 +186,7 @@ public class TeamSubscriberParticipantPage implements IPageBookViewPage, IProper } } - protected void setContextMenu(IMenuManager manager) { + private void setContextMenu(IMenuManager manager) { openWithActions.fillContextMenu(manager); refactorActions.fillContextMenu(manager); manager.add(new Separator()); @@ -246,10 +220,10 @@ public class TeamSubscriberParticipantPage implements IPageBookViewPage, IProper /** * Adds the listeners to the viewer. */ - protected void initializeListeners() { + private void initializeListeners() { viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { - ; + updateStatusLine((IStructuredSelection)event.getSelection()); } }); viewer.addDoubleClickListener(new IDoubleClickListener() { @@ -264,7 +238,7 @@ public class TeamSubscriberParticipantPage implements IPageBookViewPage, IProper }); } - protected void createViewer(Composite parent) { + private void createViewer(Composite parent) { //tbMgr.createControl(parent); switch(layout) { case TeamSubscriberParticipant.TREE_LAYOUT: @@ -286,7 +260,7 @@ public class TeamSubscriberParticipantPage implements IPageBookViewPage, IProper return new TeamSubscriberParticipantLabelProvider(); } - protected void createTreeViewerPartControl(Composite parent) { + private void createTreeViewerPartControl(Composite parent) { GridData data = new GridData(GridData.FILL_BOTH); viewer = new SyncTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); viewer.setLabelProvider(getLabelProvider()); @@ -294,7 +268,7 @@ public class TeamSubscriberParticipantPage implements IPageBookViewPage, IProper ((TreeViewer)viewer).getTree().setLayoutData(data); } - protected void createTableViewerPartControl(Composite parent) { + private void createTableViewerPartControl(Composite parent) { // Create the table Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION); table.setHeaderVisible(true); @@ -322,7 +296,7 @@ public class TeamSubscriberParticipantPage implements IPageBookViewPage, IProper /** * Creates the columns for the sync viewer table. */ - protected void createColumns(Table table, TableLayout layout, TableViewer viewer) { + private void createColumns(Table table, TableLayout layout, TableViewer viewer) { SelectionListener headerListener = SyncViewerTableSorter.getColumnListener(viewer); // revision TableColumn col = new TableColumn(table, SWT.NONE); @@ -339,7 +313,7 @@ public class TeamSubscriberParticipantPage implements IPageBookViewPage, IProper layout.addColumnData(new ColumnWeightData(50, true)); } - protected void disposeChildren(Composite parent) { + private void disposeChildren(Composite parent) { // Null out the control of the busy cursor while we are switching viewers busyCursor.setControl(null); Control[] children = parent.getChildren(); @@ -349,18 +323,7 @@ public class TeamSubscriberParticipantPage implements IPageBookViewPage, IProper } } - /** - * Handles a selection changed event from the viewer. Updates the status line and the action - * bars, and links to editor (if option enabled). - * - * @param event the selection event - */ - protected void handleSelectionChanged(SelectionChangedEvent event) { - final IStructuredSelection sel = (IStructuredSelection) event.getSelection(); - updateStatusLine(sel); - } - - protected void handleOpen(OpenEvent event) { + private void handleOpen(OpenEvent event) { openWithActions.openInCompareEditor(); } /** @@ -370,7 +333,7 @@ public class TeamSubscriberParticipantPage implements IPageBookViewPage, IProper * @param event the double-click event * @since 2.0 */ - protected void handleDoubleClick(DoubleClickEvent event) { + private void handleDoubleClick(DoubleClickEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); Object element = selection.getFirstElement(); // Double-clicking should expand/collapse containers @@ -439,9 +402,9 @@ public class TeamSubscriberParticipantPage implements IPageBookViewPage, IProper * * @param selection the current selection */ - protected void updateStatusLine(IStructuredSelection selection) { + private void updateStatusLine(IStructuredSelection selection) { String msg = getStatusLineMessage(selection); - //getSite().getActionBars().getStatusLineManager().setMessage(msg); + getSite().getActionBars().getStatusLineManager().setMessage(msg); } /** @@ -451,7 +414,7 @@ public class TeamSubscriberParticipantPage implements IPageBookViewPage, IProper * @return the status line message * @since 2.0 */ - protected String getStatusLineMessage(IStructuredSelection selection) { + private String getStatusLineMessage(IStructuredSelection selection) { if (selection.size() == 1) { IResource resource = getResource(selection.getFirstElement()); if (resource == null) { @@ -515,7 +478,7 @@ public class TeamSubscriberParticipantPage implements IPageBookViewPage, IProper } } - protected void updateViewMenu(IActionBars actionBars) { + private void updateViewMenu(IActionBars actionBars) { IMenuManager menu = actionBars.getMenuManager(); menu.removeAll(); MenuManager layoutMenu = new MenuManager(Policy.bind("action.layout.label")); //$NON-NLS-1$ 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 index e5ecb1c6a..6112f4106 100644 --- 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 @@ -15,7 +15,8 @@ with the Eclipse Synchronize View.</p> the common functionality for synchronize participants. The basic model for the Synchronize View APIs is the following:</p> <ul> - <li>A ISynchronizeManager manages registered synchronize participants.</li> + <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> @@ -53,7 +54,7 @@ with the Eclipse Synchronize View.</p> implementations for init(QualifiedName), saveState(), and optionally createPage().</li> <li>To add actions to the context menu of the participant page you must create a viewerContribution in your plugin.xml with the targetID field equal to that - of the qualifier part of the participant's id. For example: + of the qualifier part of the participant's type id. For example: <pre><viewerContribution id="org.eclipse.myteamplugin.syncparticipant.actions" targetID="org.eclipse.myteamplugin.syncparticipant"</pre> </li> |