Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 126973 Details for
Bug 201116
[Viewers] Compare will silently discard additional contentMergeViewers associated with the same file extension
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch v04
clipboard.txt (text/plain), 44.58 KB, created by
Tomasz Zarna
on 2009-02-27 07:41:14 EST
(
hide
)
Description:
Patch v04
Filename:
MIME Type:
Creator:
Tomasz Zarna
Created:
2009-02-27 07:41:14 EST
Size:
44.58 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.compare >Index: compare/org/eclipse/compare/internal/CompareMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java,v >retrieving revision 1.20 >diff -u -r1.20 CompareMessages.java >--- compare/org/eclipse/compare/internal/CompareMessages.java 10 Oct 2008 14:55:31 -0000 1.20 >+++ compare/org/eclipse/compare/internal/CompareMessages.java 27 Feb 2009 12:29:11 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -129,6 +129,8 @@ > public static String CompareWithOtherResourceDialog_externalFolderRadioButton; > public static String CompareWithOtherResourceDialog_workspaceMainButton; > public static String CompareWithOtherResourceDialog_workspaceRadioButton; >+ public static String CompareContentViewerSwitchingPane_defaultViewer; >+ public static String CompareContentViewerSwitchingPane_switchButtonTooltip; > > static { > NLS.initializeMessages(BUNDLE_NAME, CompareMessages.class); >Index: compare/org/eclipse/compare/internal/ViewerDescriptor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java,v >retrieving revision 1.14 >diff -u -r1.14 ViewerDescriptor.java >--- compare/org/eclipse/compare/internal/ViewerDescriptor.java 22 May 2007 20:19:52 -0000 1.14 >+++ compare/org/eclipse/compare/internal/ViewerDescriptor.java 27 Feb 2009 12:29:11 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,13 +10,12 @@ > *******************************************************************************/ > package org.eclipse.compare.internal; > >-import org.eclipse.swt.widgets.Composite; >- >+import org.eclipse.compare.CompareConfiguration; >+import org.eclipse.compare.IViewerCreator; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IConfigurationElement; >-import org.eclipse.compare.*; >- > import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.swt.widgets.Composite; > > /** > * Creates <code>Viewer</code>s from an <code>IConfigurationElement</code>. >@@ -25,6 +24,7 @@ > > private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$ > private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$ >+ private final static String LABEL_ATTRIBUTE = "label"; //$NON-NLS-1$ > > private IConfigurationElement fConfiguration; > private IViewerCreator fViewerCreator; >@@ -69,4 +69,8 @@ > public String getExtension() { > return fConfiguration.getAttribute(EXTENSIONS_ATTRIBUTE); > } >+ >+ String getLabel() { >+ return fConfiguration.getAttribute(LABEL_ATTRIBUTE); >+ } > } >Index: compare/org/eclipse/compare/internal/CompareMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties,v >retrieving revision 1.31 >diff -u -r1.31 CompareMessages.properties >--- compare/org/eclipse/compare/internal/CompareMessages.properties 10 Oct 2008 14:55:31 -0000 1.31 >+++ compare/org/eclipse/compare/internal/CompareMessages.properties 27 Feb 2009 12:29:11 -0000 >@@ -1,5 +1,5 @@ > ############################################################################### >-# Copyright (c) 2000, 2008 IBM Corporation and others. >+# Copyright (c) 2000, 2009 IBM Corporation and others. > # All rights reserved. This program and the accompanying materials > # are made available under the terms of the Eclipse Public License v1.0 > # which accompanies this distribution, and is available at >@@ -141,3 +141,6 @@ > CompareWithOtherResourceDialog_externalFolderRadioButton=External folder > CompareWithOtherResourceDialog_workspaceMainButton=Browse... > CompareWithOtherResourceDialog_workspaceRadioButton=Workspace >+ >+CompareContentViewerSwitchingPane_defaultViewer=Default >+CompareContentViewerSwitchingPane_switchButtonTooltip=Switch >Index: compare/org/eclipse/compare/internal/CompareUIPlugin.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java,v >retrieving revision 1.73 >diff -u -r1.73 CompareUIPlugin.java >--- compare/org/eclipse/compare/internal/CompareUIPlugin.java 10 Oct 2008 09:44:04 -0000 1.73 >+++ compare/org/eclipse/compare/internal/CompareUIPlugin.java 27 Feb 2009 12:29:11 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -20,6 +20,7 @@ > import java.util.HashSet; > import java.util.Hashtable; > import java.util.Iterator; >+import java.util.LinkedHashSet; > import java.util.List; > import java.util.Map; > import java.util.ResourceBundle; >@@ -92,73 +93,89 @@ > > static class CompareRegistry { > >- private final static String ID_ATTRIBUTE= "id"; //$NON-NLS-1$ >- private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$ >- private final static String CONTENT_TYPE_ID_ATTRIBUTE= "contentTypeId"; //$NON-NLS-1$ >- >- private HashMap fIdMap; // maps ids to data >- private HashMap fExtensionMap; // maps extensions to data >- private HashMap fContentTypeBindings; // maps content type bindings to data >- >- >- void register(IConfigurationElement element, Object data) { >- String id= element.getAttribute(ID_ATTRIBUTE); >- if (id != null) { >- if (fIdMap == null) >- fIdMap= new HashMap(); >- fIdMap.put(id, data); >- } >- >- String types= element.getAttribute(EXTENSIONS_ATTRIBUTE); >- if (types != null) { >- if (fExtensionMap == null) >- fExtensionMap= new HashMap(); >- StringTokenizer tokenizer= new StringTokenizer(types, ","); //$NON-NLS-1$ >- while (tokenizer.hasMoreElements()) { >- String extension= tokenizer.nextToken().trim(); >- fExtensionMap.put(normalizeCase(extension), data); >- } >- } >- } >- >- void createBinding(IConfigurationElement element, String idAttributeName) { >- String type= element.getAttribute(CONTENT_TYPE_ID_ATTRIBUTE); >- String id= element.getAttribute(idAttributeName); >- if (id == null) >- logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.targetIdAttributeMissing", idAttributeName)); //$NON-NLS-1$ >- if (type != null && id != null && fIdMap != null) { >- Object o= fIdMap.get(id); >- if (o != null) { >- IContentType ct= fgContentTypeManager.getContentType(type); >- if (ct != null) { >- if (fContentTypeBindings == null) >- fContentTypeBindings= new HashMap(); >- fContentTypeBindings.put(ct, o); >- } else { >- logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.contentTypeNotFound", type)); //$NON-NLS-1$ >- } >- } else { >- logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.targetNotFound", id)); //$NON-NLS-1$ >- } >- } >- } >- >- Object search(IContentType type) { >- if (fContentTypeBindings != null) { >- for (; type != null; type= type.getBaseType()) { >- Object data= fContentTypeBindings.get(type); >- if (data != null) >- return data; >- } >- } >- return null; >- } >+ private final static String ID_ATTRIBUTE= "id"; //$NON-NLS-1$ >+ private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$ >+ private final static String CONTENT_TYPE_ID_ATTRIBUTE= "contentTypeId"; //$NON-NLS-1$ >+ >+ private HashMap fIdMap; // maps ids to data >+ private HashMap fExtensionMap; // multimap: maps extensions to list of data >+ private HashMap fContentTypeBindings; // multimap: maps content type bindings to list of data >+ >+ >+ void register(IConfigurationElement element, Object data) { >+ String id= element.getAttribute(ID_ATTRIBUTE); >+ if (id != null) { >+ if (fIdMap == null) >+ fIdMap= new HashMap(); >+ fIdMap.put(id, data); >+ } >+ >+ String types= element.getAttribute(EXTENSIONS_ATTRIBUTE); >+ if (types != null) { >+ if (fExtensionMap == null) >+ fExtensionMap= new HashMap(); >+ StringTokenizer tokenizer= new StringTokenizer(types, ","); //$NON-NLS-1$ >+ while (tokenizer.hasMoreElements()) { >+ String extension= tokenizer.nextToken().trim(); >+ List l = (List) fExtensionMap.get(normalizeCase(extension)); >+ if (l == null) >+ fExtensionMap.put(normalizeCase(extension), l = new ArrayList()); >+ l.add(data); >+ } >+ } >+ } >+ >+ void createBinding(IConfigurationElement element, String idAttributeName) { >+ String type= element.getAttribute(CONTENT_TYPE_ID_ATTRIBUTE); >+ String id= element.getAttribute(idAttributeName); >+ if (id == null) >+ logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.targetIdAttributeMissing", idAttributeName)); //$NON-NLS-1$ >+ if (type != null && id != null && fIdMap != null) { >+ Object o= fIdMap.get(id); >+ if (o != null) { >+ IContentType ct= fgContentTypeManager.getContentType(type); >+ if (ct != null) { >+ if (fContentTypeBindings == null) >+ fContentTypeBindings= new HashMap(); >+ List l = (List) fContentTypeBindings.get(ct); >+ if (l == null) >+ fContentTypeBindings.put(ct, l = new ArrayList()); >+ l.add(o); >+ } else { >+ logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.contentTypeNotFound", type)); //$NON-NLS-1$ >+ } >+ } else { >+ logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.targetNotFound", id)); //$NON-NLS-1$ >+ } >+ } >+ } >+ >+ Object search(IContentType type) { >+ List list = searchAll(type); >+ return list != null ? list.get(0) : null; >+ } > >- Object search(String extension) { >- if (fExtensionMap != null) >- return fExtensionMap.get(normalizeCase(extension)); >- return null; >- } >+ List searchAll(IContentType type) { >+ if (fContentTypeBindings != null) { >+ for (; type != null; type= type.getBaseType()) { >+ List data= (List) fContentTypeBindings.get(type); >+ if (data != null) >+ return data; >+ } >+ } >+ return null; >+ } >+ >+ Object search(String extension) { >+ List list = searchAll(extension); >+ return list != null ? list.get(0) : null; >+ } >+ >+ List searchAll(String extension) { >+ if (fExtensionMap != null) >+ return (List) fExtensionMap.get(normalizeCase(extension)); >+ return null; >+ } > } > > /** Status code describing an internal error */ >@@ -171,19 +188,19 @@ > private static final String BINARY_TYPE= "binary"; //$NON-NLS-1$ > > private static final String STREAM_MERGER_EXTENSION_POINT= "streamMergers"; //$NON-NLS-1$ >- private static final String STREAM_MERGER= "streamMerger"; //$NON-NLS-1$ >- private static final String STREAM_MERGER_ID_ATTRIBUTE= "streamMergerId"; //$NON-NLS-1$ >+ private static final String STREAM_MERGER= "streamMerger"; //$NON-NLS-1$ >+ private static final String STREAM_MERGER_ID_ATTRIBUTE= "streamMergerId"; //$NON-NLS-1$ > private static final String STRUCTURE_CREATOR_EXTENSION_POINT= "structureCreators"; //$NON-NLS-1$ >- private static final String STRUCTURE_CREATOR= "structureCreator"; //$NON-NLS-1$ >- private static final String STRUCTURE_CREATOR_ID_ATTRIBUTE= "structureCreatorId"; //$NON-NLS-1$ >- >+ private static final String STRUCTURE_CREATOR= "structureCreator"; //$NON-NLS-1$ >+ private static final String STRUCTURE_CREATOR_ID_ATTRIBUTE= "structureCreatorId"; //$NON-NLS-1$ >+ > private static final String VIEWER_TAG= "viewer"; //$NON-NLS-1$ > private static final String STRUCTURE_MERGE_VIEWER_EXTENSION_POINT= "structureMergeViewers"; //$NON-NLS-1$ >- private static final String STRUCTURE_MERGE_VIEWER_ID_ATTRIBUTE= "structureMergeViewerId"; //$NON-NLS-1$ >+ private static final String STRUCTURE_MERGE_VIEWER_ID_ATTRIBUTE= "structureMergeViewerId"; //$NON-NLS-1$ > private static final String CONTENT_MERGE_VIEWER_EXTENSION_POINT= "contentMergeViewers"; //$NON-NLS-1$ >- private static final String CONTENT_MERGE_VIEWER_ID_ATTRIBUTE= "contentMergeViewerId"; //$NON-NLS-1$ >+ private static final String CONTENT_MERGE_VIEWER_ID_ATTRIBUTE= "contentMergeViewerId"; //$NON-NLS-1$ > private static final String CONTENT_VIEWER_EXTENSION_POINT= "contentViewers"; //$NON-NLS-1$ >- private static final String CONTENT_VIEWER_ID_ATTRIBUTE= "contentViewerId"; //$NON-NLS-1$ >+ private static final String CONTENT_VIEWER_ID_ATTRIBUTE= "contentViewerId"; //$NON-NLS-1$ > > private static final String CONTENT_TYPE_BINDING= "contentTypeBinding"; //$NON-NLS-1$ > >@@ -223,7 +240,7 @@ > private Map fStructureViewerAliases; > private CompareFilter fFilter; > private IPropertyChangeListener fPropertyChangeListener; >- >+ > /** > * Creates the <code>CompareUIPlugin</code> object and registers all > * structure creators, content merge viewers, and structure merge viewers >@@ -807,21 +824,8 @@ > return null; > } > >- /** >- * Returns a content compare viewer based on an old viewer and an input object. >- * If the old viewer is suitable for showing the input the old viewer >- * is returned. Otherwise the input's type is used to find a viewer descriptor in the registry >- * which in turn is used to create a content compare viewer under the given parent composite. >- * If no viewer descriptor can be found <code>null</code> is returned. >- * >- * @param oldViewer a new viewer is only created if this old viewer cannot show the given input >- * @param in the input object for which to find a content viewer >- * @param parent the SWT parent composite under which the new viewer is created >- * @param cc a configuration which is passed to a newly created viewer >- * @return the compare viewer which is suitable for the given input object or <code>null</code> >- */ >- public Viewer findContentViewer(Viewer oldViewer, Object in, Composite parent, CompareConfiguration cc) { >- >+ public Set/*<ViewerDescriptor>*/ findContentViewerDescriptor(Viewer oldViewer, Object in, CompareConfiguration cc) { >+ Set result = new LinkedHashSet(); > if (in instanceof IStreamContentAccessor) { > String type= ITypedElement.TEXT_TYPE; > >@@ -831,9 +835,9 @@ > IContentType ct= getContentType(tin); > if (ct != null) { > initializeRegistries(); >- Viewer viewer= getViewer(fContentViewers.search(ct), oldViewer, parent, cc); >- if (viewer != null) >- return viewer; >+ List list = fContentViewers.searchAll(ct); >+ if (list != null) >+ result.addAll(list); > } > > String ty= tin.getType(); >@@ -842,18 +846,18 @@ > } > > initializeRegistries(); >- Viewer viewer= getViewer(fContentViewers.search(type), oldViewer, parent, cc); >- if (viewer != null) >- return viewer; >+ List list = fContentViewers.searchAll(type); >+ if (list != null) >+ result.addAll(list); > // fallback >- return new SimpleTextViewer(parent); >+ result.add(fContentViewers.search(Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT))); >+ return result; > } > > if (!(in instanceof ICompareInput)) > return null; >- >- ICompareInput input= (ICompareInput) in; > >+ ICompareInput input= (ICompareInput) in; > > IContentType ctype= getCommonType(input); > if (isCompareAsText(input, cc)) { >@@ -861,9 +865,9 @@ > } > if (ctype != null) { > initializeRegistries(); >- Viewer viewer= getViewer(fContentMergeViewers.search(ctype), oldViewer, parent, cc); >- if (viewer != null) >- return viewer; >+ List list = fContentMergeViewers.searchAll(ctype); >+ if (list != null) >+ result.addAll(list); > } > > String[] types= getTypes(input); >@@ -888,9 +892,9 @@ > > if (type != null) { > initializeRegistries(); >- Viewer viewer= getViewer(fContentMergeViewers.search(type), oldViewer, parent, cc); >- if (viewer != null) >- return viewer; >+ List list = fContentMergeViewers.searchAll(type); >+ if (list != null) >+ result.addAll(list); > } > > // fallback >@@ -906,13 +910,31 @@ > type= BINARY_TYPE; > > initializeRegistries(); >- IViewerDescriptor vd= (IViewerDescriptor) fContentMergeViewers.search(type); >- if (vd != null) >- return vd.createViewer(oldViewer, parent, cc); >+ List list = fContentMergeViewers.searchAll(type); >+ if (list != null) >+ result.addAll(list); >+ return result; > } > return null; > } > >+ /** >+ * Returns a content compare viewer based on an old viewer and an input object. >+ * If the old viewer is suitable for showing the input the old viewer >+ * is returned. Otherwise the input's type is used to find a viewer descriptor in the registry >+ * which in turn is used to create a content compare viewer under the given parent composite. >+ * If no viewer descriptor can be found <code>null</code> is returned. >+ * >+ * @param oldViewer a new viewer is only created if this old viewer cannot show the given input >+ * @param in the input object for which to find a content viewer >+ * @param parent the SWT parent composite under which the new viewer is created >+ * @param cc a configuration which is passed to a newly created viewer >+ * @return the compare viewer which is suitable for the given input object or <code>null</code> >+ */ >+ public Viewer findContentViewer(Viewer oldViewer, Object in, Composite parent, CompareConfiguration cc) { >+ return getViewer(findContentViewerDescriptor(oldViewer, in, cc).toArray()[0], oldViewer, parent, cc); >+ } >+ > private boolean isCompareAsText(ICompareInput input, CompareConfiguration cc) { > Set set = (Set)cc.getProperty(ICompareAsText.PROP_TEXT_INPUTS); > if (set == null) >Index: compare/org/eclipse/compare/CompareViewerSwitchingPane.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java,v >retrieving revision 1.32 >diff -u -r1.32 CompareViewerSwitchingPane.java >--- compare/org/eclipse/compare/CompareViewerSwitchingPane.java 4 Feb 2009 10:47:50 -0000 1.32 >+++ compare/org/eclipse/compare/CompareViewerSwitchingPane.java 27 Feb 2009 12:29:10 -0000 >@@ -216,6 +216,17 @@ > return true; > return false; > } >+ >+ /** >+ * @param input the input >+ * @return true, if the input is considered as changed >+ * @noreference This method is not intended to be referenced by clients. >+ * @nooverride This method is not intended to be re-implemented or extended >+ * by clients. >+ */ >+ protected boolean inputChanged(Object input) { >+ return getInput() != input; >+ } > > /** > * Sets the input object of this pane. >@@ -233,10 +244,10 @@ > */ > public void setInput(Object input) { > >- if (getInput() == input) >+ if (!inputChanged(input)) > return; >- >- boolean hadFocus= hasFocus2(); >+ >+ boolean hadFocus = hasFocus2(); > > super.setInput(input); > >Index: compare/org/eclipse/compare/CompareEditorInput.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java,v >retrieving revision 1.105 >diff -u -r1.105 CompareEditorInput.java >--- compare/org/eclipse/compare/CompareEditorInput.java 23 Jan 2009 15:58:06 -0000 1.105 >+++ compare/org/eclipse/compare/CompareEditorInput.java 27 Feb 2009 12:29:10 -0000 >@@ -19,6 +19,7 @@ > import org.eclipse.compare.contentmergeviewer.IFlushable; > import org.eclipse.compare.internal.BinaryCompareViewer; > import org.eclipse.compare.internal.ChangePropertyAction; >+import org.eclipse.compare.internal.CompareContentViewerSwitchingPane; > import org.eclipse.compare.internal.CompareEditorInputNavigator; > import org.eclipse.compare.internal.CompareMessages; > import org.eclipse.compare.internal.ComparePreferencePage; >@@ -27,6 +28,7 @@ > import org.eclipse.compare.internal.ICompareUIConstants; > import org.eclipse.compare.internal.OutlineViewerCreator; > import org.eclipse.compare.internal.Utilities; >+import org.eclipse.compare.internal.ViewerDescriptor; > import org.eclipse.compare.structuremergeviewer.DiffTreeViewer; > import org.eclipse.compare.structuremergeviewer.ICompareInput; > import org.eclipse.compare.structuremergeviewer.ICompareInputChangeListener; >@@ -144,7 +146,7 @@ > public abstract class CompareEditorInput implements IEditorInput, IPropertyChangeNotifier, IRunnableWithProgress, ICompareContainer { > > private static final boolean DEBUG= false; >- >+ > /** > * The name of the "dirty" property (value <code>"DIRTY_STATE"</code>). > */ >@@ -203,6 +205,7 @@ > private String fHelpContextId; > private InternalOutlineViewerCreator fOutlineView; > private ICompareAsText fCompareAsText; >+ private ViewerDescriptor vd; > > private class InternalOutlineViewerCreator extends OutlineViewerCreator { > private OutlineViewerCreator getWrappedCreator() { >@@ -552,13 +555,8 @@ > > Control outline= createOutlineContents(fComposite, SWT.HORIZONTAL); > >- fContentInputPane= new CompareViewerSwitchingPane(fComposite, SWT.BORDER | SWT.FLAT) { >- protected Viewer getViewer(Viewer oldViewer, Object input) { >- if (input instanceof ICompareInput) >- return findContentViewer(oldViewer, (ICompareInput)input, this); >- return null; >- } >- }; >+ fContentInputPane= new CompareContentViewerSwitchingPane(fComposite, SWT.BORDER | SWT.FLAT, this); >+ > if (fFocusPane == null) > fFocusPane= fContentInputPane; > if (outline != null) >@@ -926,8 +924,10 @@ > */ > public Viewer findContentViewer(Viewer oldViewer, ICompareInput input, Composite parent) { > >- Viewer newViewer= CompareUI.findContentViewer(oldViewer, input, parent, fCompareConfiguration); >- >+ Viewer newViewer = vd != null ? vd.createViewer(oldViewer, parent, >+ fCompareConfiguration) : CompareUI.findContentViewer(oldViewer, >+ input, parent, fCompareConfiguration); >+ > boolean isNewViewer= newViewer != oldViewer; > if (DEBUG) System.out.println("CompareEditorInput.findContentViewer: " + isNewViewer); //$NON-NLS-1$ > >@@ -949,6 +949,27 @@ > } > > /** >+ * @param vd >+ * the viewer descriptor >+ * @noreference This method is not intended to be referenced by clients. >+ * @nooverride This method is not intended to be re-implemented or extended >+ * by clients. >+ */ >+ public void setViewerDescriptor(ViewerDescriptor vd) { >+ this.vd = vd; >+ } >+ >+ /** >+ * @return the viewer descriptor set for the input >+ * @noreference This method is not intended to be referenced by clients. >+ * @nooverride This method is not intended to be re-implemented or extended >+ * by clients. >+ */ >+ public ViewerDescriptor getViewerDescriptor() { >+ return this.vd; >+ } >+ >+ /** > * Returns <code>true</code> if there are unsaved changes. > * The value returned is the value of the <code>DIRTY_STATE</code> property of this input object. > >Index: compare/org/eclipse/compare/CompareViewerPane.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java,v >retrieving revision 1.25 >diff -u -r1.25 CompareViewerPane.java >--- compare/org/eclipse/compare/CompareViewerPane.java 5 Apr 2007 14:48:38 -0000 1.25 >+++ compare/org/eclipse/compare/CompareViewerPane.java 27 Feb 2009 12:29:10 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,17 +10,34 @@ > *******************************************************************************/ > package org.eclipse.compare; > >-import org.eclipse.core.runtime.*; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.ListenerList; >+import org.eclipse.core.runtime.Platform; > import org.eclipse.jface.action.ToolBarManager; >-import org.eclipse.jface.viewers.*; >+import org.eclipse.jface.viewers.DoubleClickEvent; >+import org.eclipse.jface.viewers.IDoubleClickListener; >+import org.eclipse.jface.viewers.IOpenListener; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.ISelectionProvider; >+import org.eclipse.jface.viewers.OpenEvent; >+import org.eclipse.jface.viewers.SelectionChangedEvent; > import org.eclipse.swt.SWT; >-import org.eclipse.swt.accessibility.*; >+import org.eclipse.swt.accessibility.ACC; >+import org.eclipse.swt.accessibility.AccessibleAdapter; >+import org.eclipse.swt.accessibility.AccessibleEvent; > import org.eclipse.swt.custom.CLabel; > import org.eclipse.swt.custom.ViewForm; >-import org.eclipse.swt.events.*; >+import org.eclipse.swt.events.DisposeEvent; >+import org.eclipse.swt.events.DisposeListener; >+import org.eclipse.swt.events.MouseAdapter; >+import org.eclipse.swt.events.MouseEvent; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; >-import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.ToolBar; >+import org.eclipse.swt.widgets.ToolItem; > > /** > * A <code>CompareViewerPane</code> is a convenience class which installs a >@@ -63,12 +80,8 @@ > marginWidth= 0; > marginHeight= 0; > >- CLabel label= new CLabel(this, SWT.NONE) { >- public Point computeSize(int wHint, int hHint, boolean changed) { >- return super.computeSize(wHint, Math.max(24, hHint), changed); >- } >- }; >- setTopLeft(label); >+ Control topLeft = createTopLeft(this); >+ setTopLeft(topLeft); > > MouseAdapter ml= new MouseAdapter() { > public void mouseDoubleClick(MouseEvent e) { >@@ -82,7 +95,7 @@ > }; > > addMouseListener(ml); >- label.addMouseListener(ml); >+ getTopLeft().addMouseListener(ml); > > addDisposeListener(new DisposeListener() { > public void widgetDisposed(DisposeEvent e) { >@@ -98,6 +111,24 @@ > } > > /** >+ * @param parent >+ * a widget which will be the parent of the control (cannot be >+ * null) >+ * @return the control to be placed in the top left corner of the pane >+ * @noreference This method is not intended to be referenced by clients. >+ * @nooverride This method is not intended to be re-implemented or extended >+ * by clients. >+ */ >+ protected Control createTopLeft(Composite parent) { >+ CLabel label = new CLabel(this, SWT.NONE) { >+ public Point computeSize(int wHint, int hHint, boolean changed) { >+ return super.computeSize(wHint, Math.max(24, hHint), changed); >+ } >+ }; >+ return label; >+ } >+ >+ /** > * Set the pane's title text. > * The value <code>null</code> clears it. > * >Index: schema/contentMergeViewers.exsd >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentMergeViewers.exsd,v >retrieving revision 1.18 >diff -u -r1.18 contentMergeViewers.exsd >--- schema/contentMergeViewers.exsd 24 Sep 2008 17:14:44 -0000 1.18 >+++ schema/contentMergeViewers.exsd 27 Feb 2009 12:29:11 -0000 >@@ -2,9 +2,9 @@ > <!-- Schema file written by PDE --> > <schema targetNamespace="org.eclipse.compare" xmlns="http://www.w3.org/2001/XMLSchema"> > <annotation> >- <appinfo> >+ <appInfo> > <meta.schema plugin="org.eclipse.compare" id="contentMergeViewers" name="ContentMerge Viewers"/> >- </appinfo> >+ </appInfo> > <documentation> > This extension point allows a plug-in to register compare/merge > viewers for specific content types. The viewer is expected to >@@ -17,9 +17,9 @@ > > <element name="extension"> > <annotation> >- <appinfo> >+ <appInfo> > <meta.element /> >- </appinfo> >+ </appInfo> > </annotation> > <complexType> > <sequence> >@@ -45,9 +45,9 @@ > <documentation> > an optional name of the extension instance > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute translatable="true"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > </complexType> >@@ -68,9 +68,9 @@ > a fully qualified name of a class that implements a factory for the > content merge viewer and implements <samp>org.eclipse.compare.IViewerCreator</samp> > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute kind="java" basedOn=":org.eclipse.compare.IViewerCreator"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > <attribute name="extensions" type="string"> >@@ -80,6 +80,16 @@ > </documentation> > </annotation> > </attribute> >+ <attribute name="label" type="string"> >+ <annotation> >+ <documentation> >+ a translatable label that will be used in the UI for this viewer >+ </documentation> >+ <appInfo> >+ <meta.attribute translatable="true"/> >+ </appInfo> >+ </annotation> >+ </attribute> > </complexType> > </element> > >@@ -95,9 +105,9 @@ > <documentation> > The id of a content type defined using the <code>org.eclipse.core.contenttype.contentTypes</code> extension point. > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > <attribute name="contentMergeViewerId" type="string" use="required"> >@@ -105,18 +115,18 @@ > <documentation> > The id of a merge viewer defined using the <code>viewer</code> element of this extension point (i.e. <code>org.eclipse.compare.contentMergeViewers</code>) > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute kind="identifier" basedOn="org.eclipse.compare.contentMergeViewers/viewer/@id"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > </complexType> > </element> > > <annotation> >- <appinfo> >+ <appInfo> > <meta.section type="examples"/> >- </appinfo> >+ </appInfo> > <documentation> > The following is an example of a compare/merge viewer > for text files (extension "txt"): >@@ -135,9 +145,9 @@ > </annotation> > > <annotation> >- <appinfo> >+ <appInfo> > <meta.section type="apiInfo"/> >- </appinfo> >+ </appInfo> > <documentation> > The contributed class must implement <code>org.eclipse.compare.IViewerCreator</code> > </documentation> >@@ -145,20 +155,20 @@ > > > <annotation> >- <appinfo> >+ <appInfo> > <meta.section type="implementation"/> >- </appinfo> >+ </appInfo> > <documentation> > The Compare UI plugin defines content viewers for text, binary contents, and images. > </documentation> > </annotation> > > <annotation> >- <appinfo> >+ <appInfo> > <meta.section type="copyright"/> >- </appinfo> >+ </appInfo> > <documentation> >- Copyright (c) 2000, 2008 IBM Corporation and others.<br> >+ Copyright (c) 2000, 2009 IBM Corporation and others.<br> > All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> > </documentation> > </annotation> >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml,v >retrieving revision 1.68 >diff -u -r1.68 plugin.xml >--- plugin.xml 25 Aug 2008 12:35:11 -0000 1.68 >+++ plugin.xml 27 Feb 2009 12:29:10 -0000 >@@ -307,19 +307,22 @@ > <extension > point="org.eclipse.compare.contentMergeViewers"> > <viewer >- extensions="class,exe,dll,binary,zip,jar" > class="org.eclipse.compare.internal.BinaryCompareViewerCreator" >- id="org.eclipse.compare.BinaryCompareViewerCreator"> >+ extensions="class,exe,dll,binary,zip,jar" >+ id="org.eclipse.compare.BinaryCompareViewerCreator" >+ label="%BinaryCompare.label"> > </viewer> > <viewer >- extensions="txt" > class="org.eclipse.compare.internal.TextMergeViewerCreator" >- id="org.eclipse.compare.TextMergeViewerCreator"> >+ extensions="txt" >+ id="org.eclipse.compare.TextMergeViewerCreator" >+ label="%TextCompare.label"> > </viewer> > <viewer >- extensions="gif,jpg,jpeg,png,bmp,ico,tif,tiff" > class="org.eclipse.compare.internal.ImageMergeViewerCreator" >- id="org.eclipse.compare.ImageMergeViewerCreator"> >+ extensions="gif,jpg,jpeg,png,bmp,ico,tif,tiff" >+ id="org.eclipse.compare.ImageMergeViewerCreator" >+ label="%ImageCompare.label"> > </viewer> > <contentTypeBinding > contentTypeId="org.eclipse.core.runtime.text" >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties,v >retrieving revision 1.93 >diff -u -r1.93 plugin.properties >--- plugin.properties 19 Aug 2008 14:45:06 -0000 1.93 >+++ plugin.properties 27 Feb 2009 12:29:10 -0000 >@@ -1,5 +1,5 @@ > ############################################################################### >-# Copyright (c) 2000, 2008 IBM Corporation and others. >+# Copyright (c) 2000, 2009 IBM Corporation and others. > # All rights reserved. This program and the accompanying materials > # are made available under the terms of the Eclipse Public License v1.0 > # which accompanies this distribution, and is available at >@@ -224,3 +224,7 @@ > > context.description = Comparing in an Editor > context.name = Comparing in an Editor >+ >+BinaryCompare.label=Binary Compare >+TextCompare.label=Text Compare >+ImageCompare.label=Image Compare >Index: compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java >=================================================================== >RCS file: compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java >diff -N compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,226 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.compare.internal; >+ >+import java.util.Set; >+ >+import org.eclipse.compare.CompareConfiguration; >+import org.eclipse.compare.CompareEditorInput; >+import org.eclipse.compare.CompareViewerSwitchingPane; >+import org.eclipse.compare.Splitter; >+import org.eclipse.compare.structuremergeviewer.ICompareInput; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.CLabel; >+import org.eclipse.swt.events.MouseListener; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.layout.RowLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Menu; >+import org.eclipse.swt.widgets.MenuItem; >+import org.eclipse.swt.widgets.ToolBar; >+import org.eclipse.swt.widgets.ToolItem; >+import org.eclipse.ui.PlatformUI; >+ >+public class CompareContentViewerSwitchingPane extends >+ CompareViewerSwitchingPane { >+ >+ private CompareEditorInput fCompareEditorInput; >+ >+ private ViewerDescriptor fSelectedViewerDescriptor; >+ >+ private ToolBar toolBar; >+ >+ private Menu menu; >+ >+ public CompareContentViewerSwitchingPane(Splitter parent, int style, >+ CompareEditorInput cei) { >+ super(parent, style); >+ fCompareEditorInput = cei; >+ } >+ >+ private CompareConfiguration getCompareConfiguration() { >+ return fCompareEditorInput.getCompareConfiguration(); >+ } >+ >+ protected Viewer getViewer(Viewer oldViewer, Object input) { >+ if (fSelectedViewerDescriptor != null) { >+ Set viewers = CompareUIPlugin.getDefault().findContentViewerDescriptor( >+ oldViewer, input, getCompareConfiguration()); >+ if (viewers.contains(fSelectedViewerDescriptor)) { >+ // use selected viewer only when appropriate for the new input >+ fCompareEditorInput >+ .setViewerDescriptor(fSelectedViewerDescriptor); >+ Viewer viewer = fCompareEditorInput.findContentViewer( >+ oldViewer, (ICompareInput) input, this); >+ return viewer; >+ } >+ } >+ if (input instanceof ICompareInput) { >+ fCompareEditorInput.setViewerDescriptor(null); >+ Viewer viewer = fCompareEditorInput.findContentViewer(oldViewer, >+ (ICompareInput) input, this); >+ fCompareEditorInput.setViewerDescriptor(fSelectedViewerDescriptor); >+ return viewer; >+ } >+ return null; >+ } >+ >+ protected Control createTopLeft(Composite p) { >+ final Composite composite = new Composite(p, SWT.NONE) { >+ public Point computeSize(int wHint, int hHint, boolean changed) { >+ return super.computeSize(wHint, Math.max(24, hHint), changed); >+ } >+ }; >+ >+ RowLayout layout = new RowLayout(); >+ layout.marginTop = 0; >+ composite.setLayout(layout); >+ >+ CLabel cl = new CLabel(composite, SWT.NONE); >+ cl.setText(null); >+ >+ toolBar = new ToolBar(composite, SWT.FLAT); >+ toolBar.setVisible(false); // hide by default >+ final ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH, 0); >+ toolItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage( >+ /* IWorkbenchGraphicConstants */"IMG_LCL_VIEW_MENU")); //$NON-NLS-1$ >+ toolItem >+ .setToolTipText(CompareMessages.CompareContentViewerSwitchingPane_switchButtonTooltip); >+ toolItem.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ Rectangle bounds = toolItem.getBounds(); >+ Point topLeft = new Point(bounds.x, bounds.y + bounds.height); >+ topLeft = toolBar.toDisplay(topLeft); >+ menu.setLocation(topLeft.x, topLeft.y); >+ menu.setVisible(true); >+ } >+ }); >+ return composite; >+ } >+ >+ protected boolean inputChanged(Object input) { >+ return getInput() != input >+ || fCompareEditorInput.getViewerDescriptor() != fSelectedViewerDescriptor; >+ } >+ >+ public void setInput(Object input) { >+ super.setInput(input); >+ Set/* <ViewerDescriptor> */data = CompareUIPlugin.getDefault() >+ .findContentViewerDescriptor(getViewer(), input, >+ getCompareConfiguration()); >+ updateMenu(data); >+ } >+ >+ private void updateMenu(Set data) { >+ if (data != null && data.size() > 1) { >+ ViewerDescriptor[] fViewerDescriptors = (ViewerDescriptor[]) data >+ .toArray(new ViewerDescriptor[0]); >+ >+ // dispose the old menu, if exists >+ if (menu != null) >+ menu.dispose(); >+ >+ menu = new Menu(getShell(), SWT.POP_UP); >+ >+ // add default >+ String label = fViewerDescriptors[0].getLabel(); >+ if (label == null || label.equals("")) { //$NON-NLS-1$ >+ label = CompareMessages.CompareContentViewerSwitchingPane_defaultViewer; >+ } >+ MenuItem defaultItem = new MenuItem(menu, SWT.RADIO); >+ defaultItem.setText(label); >+ defaultItem >+ .addSelectionListener(createSelectionListener(fViewerDescriptors[0])); >+ menu.setDefaultItem(defaultItem); >+ defaultItem.setSelection(fViewerDescriptors[0] == fSelectedViewerDescriptor); >+ >+ // add others >+ for (int j = 1; j < fViewerDescriptors.length; j++) { >+ final ViewerDescriptor vdi = fViewerDescriptors[j]; >+ label = vdi.getLabel(); >+ if (label != null && !label.equals("")) { //$NON-NLS-1$ >+ MenuItem item = new MenuItem(menu, SWT.RADIO); >+ item.setText(label); >+ item.addSelectionListener(createSelectionListener(vdi)); >+ item >+ .setSelection(fViewerDescriptors[j] == fSelectedViewerDescriptor); >+ } >+ } >+ toolBar.setVisible(true); >+ } else { >+ toolBar.setVisible(false); >+ } >+ } >+ >+ private SelectionListener createSelectionListener(final ViewerDescriptor vd) { >+ return new SelectionListener() { >+ public void widgetSelected(SelectionEvent e) { >+ MenuItem mi = (MenuItem) e.widget; >+ if (mi.getSelection()) { >+ Viewer oldViewer = getViewer(); >+ fSelectedViewerDescriptor = vd; >+ CompareContentViewerSwitchingPane.this.setInput(oldViewer >+ .getInput()); >+ } >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ // nothing to do >+ } >+ }; >+ } >+ >+ public void setText(String label) { >+ Composite c = (Composite) getTopLeft(); >+ Control[] children = c.getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ if (children[i] instanceof CLabel) { >+ CLabel cl = (CLabel) children[i]; >+ if (cl != null && !cl.isDisposed()) { >+ cl.setText(label); >+ c.layout(); >+ } >+ return; >+ } >+ } >+ } >+ >+ public void setImage(Image image) { >+ Composite c = (Composite) getTopLeft(); >+ Control[] children = c.getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ if (children[i] instanceof CLabel) { >+ CLabel cl = (CLabel) children[i]; >+ if (cl != null && !cl.isDisposed()) >+ cl.setImage(image); >+ return; >+ } >+ } >+ } >+ >+ public void addMouseListener(MouseListener listener) { >+ Composite c = (Composite) getTopLeft(); >+ Control[] children = c.getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ if (children[i] instanceof CLabel) { >+ CLabel cl = (CLabel) children[i]; >+ cl.addMouseListener(listener); >+ } >+ } >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 201116
:
77774
|
77776
|
77777
|
125139
|
125140
|
126971
| 126973