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 130101 Details for
Bug 266476
[Viewers] Use new mechanism to switch to text compare while comparing binary content
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposal v02 (more radical)
266476_20090327b.txt (text/plain), 14.16 KB, created by
Szymon Brandys
on 2009-03-27 09:04:31 EDT
(
hide
)
Description:
Proposal v02 (more radical)
Filename:
MIME Type:
Creator:
Szymon Brandys
Created:
2009-03-27 09:04:31 EDT
Size:
14.16 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.compare >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.107 >diff -u -r1.107 CompareEditorInput.java >--- compare/org/eclipse/compare/CompareEditorInput.java 27 Feb 2009 14:47:13 -0000 1.107 >+++ compare/org/eclipse/compare/CompareEditorInput.java 27 Mar 2009 13:04:25 -0000 >@@ -12,9 +12,7 @@ > > import java.lang.reflect.InvocationTargetException; > import java.util.ArrayList; >-import java.util.HashSet; > import java.util.ResourceBundle; >-import java.util.Set; > > import org.eclipse.compare.contentmergeviewer.IFlushable; > import org.eclipse.compare.internal.BinaryCompareViewer; >@@ -24,7 +22,6 @@ > import org.eclipse.compare.internal.CompareMessages; > import org.eclipse.compare.internal.ComparePreferencePage; > import org.eclipse.compare.internal.CompareUIPlugin; >-import org.eclipse.compare.internal.ICompareAsText; > import org.eclipse.compare.internal.ICompareUIConstants; > import org.eclipse.compare.internal.OutlineViewerCreator; > import org.eclipse.compare.internal.Utilities; >@@ -204,7 +201,6 @@ > > private String fHelpContextId; > private InternalOutlineViewerCreator fOutlineView; >- private ICompareAsText fCompareAsText; > private ViewerDescriptor vd; > > private class InternalOutlineViewerCreator extends OutlineViewerCreator { >@@ -238,12 +234,6 @@ > return null; > } > } >- >- private class CompareAsText implements ICompareAsText { >- public void compareAsText(Object input) { >- internalCompareAsText(input); >- } >- } > > /** > * Creates a <code>CompareEditorInput</code> which is initialized with the given >@@ -276,20 +266,6 @@ > fContainer = configuration.getContainer(); > configuration.setContainer(this); > } >- >- /* package */ void internalCompareAsText(Object input) { >- Set set = (Set)getCompareConfiguration().getProperty(ICompareAsText.PROP_TEXT_INPUTS); >- if (set == null) { >- set = new HashSet(); >- getCompareConfiguration().setProperty(ICompareAsText.PROP_TEXT_INPUTS, set); >- } >- set.add(input); >- if (fContentInputPane.getInput().equals(input)) { >- // We need to null the input and then reset it so we get the text merge viewer >- fContentInputPane.setInput(null); >- fContentInputPane.setInput(input); >- } >- } > > private boolean structureCompareOnSingleClick() { > return fStructureCompareOnSingleClick; >@@ -323,11 +299,6 @@ > return fOutlineView; > } > } >- if (adapter == ICompareAsText.class) { >- if (fCompareAsText == null) >- fCompareAsText = new CompareAsText(); >- return fCompareAsText; >- } > if (adapter == IFindReplaceTarget.class) { > if (fContentInputPane != null) { > Viewer v = fContentInputPane.getViewer(); >Index: compare/org/eclipse/compare/internal/ICompareAsText.java >=================================================================== >RCS file: compare/org/eclipse/compare/internal/ICompareAsText.java >diff -N compare/org/eclipse/compare/internal/ICompareAsText.java >--- compare/org/eclipse/compare/internal/ICompareAsText.java 27 Mar 2007 16:05:49 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,22 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 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; >- >-public interface ICompareAsText { >- >- /** >- * Property key for the set of test inputs (instance of Set) >- */ >- public static final String PROP_TEXT_INPUTS = "org.eclipse.compare.TextInputs"; //$NON-NLS-1$ >- >- public void compareAsText(Object input); >- >-} >Index: compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties,v >retrieving revision 1.10 >diff -u -r1.10 BinaryCompareViewerResources.properties >--- compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties 22 May 2007 20:19:52 -0000 1.10 >+++ compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties 27 Mar 2009 13:04:25 -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 >@@ -20,4 +20,4 @@ > addedMessage= Added Resource > deletedMessage= Removed Resource > errorMessage= Internal Error >-compareAsText= Compare as Text >+compareAsText= Switch to Text Compare using the drop down menu above >Index: compare/org/eclipse/compare/internal/BinaryCompareViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java,v >retrieving revision 1.24 >diff -u -r1.24 BinaryCompareViewer.java >--- compare/org/eclipse/compare/internal/BinaryCompareViewer.java 4 Feb 2009 10:42:38 -0000 1.24 >+++ compare/org/eclipse/compare/internal/BinaryCompareViewer.java 27 Mar 2009 13:04:25 -0000 >@@ -10,20 +10,25 @@ > *******************************************************************************/ > package org.eclipse.compare.internal; > >-import java.io.*; >+import java.io.IOException; >+import java.io.InputStream; > import java.util.ResourceBundle; >-import com.ibm.icu.text.MessageFormat; > >+import org.eclipse.compare.CompareConfiguration; >+import org.eclipse.compare.CompareEditorInput; >+import org.eclipse.compare.CompareUI; >+import org.eclipse.compare.IStreamContentAccessor; >+import org.eclipse.compare.ITypedElement; >+import org.eclipse.compare.structuremergeviewer.ICompareInput; >+import org.eclipse.core.runtime.CoreException; > import org.eclipse.swt.SWT; >-import org.eclipse.swt.custom.BusyIndicator; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.events.SelectionListener; > import org.eclipse.swt.layout.RowLayout; >-import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Label; > import org.eclipse.ui.PlatformUI; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.compare.*; >-import org.eclipse.compare.structuremergeviewer.ICompareInput; >+ >+import com.ibm.icu.text.MessageFormat; > > /** > * A simple compare viewer for binary files. >@@ -31,17 +36,15 @@ > */ > public class BinaryCompareViewer extends AbstractViewer { > >- private static final String BUNDLE_NAME= "org.eclipse.compare.internal.BinaryCompareViewerResources"; //$NON-NLS-1$ >- >- private static final int EOF= -1; >+ private static final String BUNDLE_NAME = "org.eclipse.compare.internal.BinaryCompareViewerResources"; //$NON-NLS-1$ >+ >+ private static final int EOF = -1; > private ICompareInput fInput; > private ResourceBundle fBundle; > private boolean fLeftIsLocal; > > private Composite fComposite; > private Label fMessage; >- private Button fTextButton; >- > > public BinaryCompareViewer(Composite parent, final CompareConfiguration cc) { > >@@ -59,36 +62,13 @@ > > fLeftIsLocal= Utilities.getBoolean(cc, "LEFT_IS_LOCAL", false); //$NON-NLS-1$ > >- if (canShowAsText(cc)) { >- fTextButton = new Button(fComposite, SWT.PUSH); >- fTextButton.setText(Utilities.getString(fBundle, "compareAsText")); //$NON-NLS-1$ >- fTextButton.addSelectionListener(new SelectionListener() { >- public void widgetSelected(SelectionEvent e) { >- BusyIndicator.showWhile(Display.getCurrent(), new Runnable() { >- public void run() { >- handleShowAsText(cc); >- } >- }); >- } >- public void widgetDefaultSelected(SelectionEvent e) { >- // Do nothing >- } >- }); >- fTextButton.setEnabled(false); >+ if (cc != null && cc.getContainer() instanceof CompareEditorInput) { >+ Label compareAsTextLabel = new Label(fComposite, SWT.WRAP); >+ compareAsTextLabel >+ .setText(Utilities.getString(fBundle, "compareAsText")); //$NON-NLS-1$ > } > } > >- private boolean canShowAsText(CompareConfiguration cc) { >- if (cc == null) >- return false; >- return Utilities.getAdapter(cc.getContainer(), ICompareAsText.class) != null; >- } >- >- protected void handleShowAsText(CompareConfiguration cc) { >- ICompareAsText comparer = (ICompareAsText)Utilities.getAdapter(cc.getContainer(), ICompareAsText.class); >- comparer.compareAsText(getInput()); >- } >- > public Control getControl() { > return fComposite; > } >@@ -96,7 +76,7 @@ > public void setInput(Object input) { > if (fComposite != null && input instanceof ICompareInput) { > fInput= (ICompareInput) input; >- >+ > InputStream left= null; > InputStream right= null; > >@@ -142,8 +122,6 @@ > } > if (message != null) > fMessage.setText(message); >- if (fTextButton != null) >- fTextButton.setEnabled(true); > fComposite.layout(); > } > } >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.76 >diff -u -r1.76 CompareUIPlugin.java >--- compare/org/eclipse/compare/internal/CompareUIPlugin.java 25 Mar 2009 11:07:06 -0000 1.76 >+++ compare/org/eclipse/compare/internal/CompareUIPlugin.java 27 Mar 2009 13:04:26 -0000 >@@ -74,7 +74,6 @@ > import org.eclipse.ui.plugin.AbstractUIPlugin; > import org.osgi.framework.BundleContext; > >- > /** > * The Compare UI plug-in defines the entry point to initiate a configurable > * compare operation on arbitrary resources. The result of the compare >@@ -859,10 +858,7 @@ > > ICompareInput input= (ICompareInput) in; > >- IContentType ctype= getCommonType(input); >- if (isCompareAsText(input, cc)) { >- ctype = Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT); >- } >+ IContentType ctype = getCommonType(input); > if (ctype != null) { > initializeRegistries(); > List list = fContentMergeViewers.searchAll(ctype); >@@ -896,23 +892,26 @@ > if (list != null) > result.addAll(list); > } >- >+ > // fallback > String leftType= guessType(input.getLeft()); > String rightType= guessType(input.getRight()); > > if (leftType != null || rightType != null) { >- boolean right_text= rightType != null && ITypedElement.TEXT_TYPE.equals(rightType); >- boolean left_text= leftType != null && ITypedElement.TEXT_TYPE.equals(leftType); >- if ((leftType == null && right_text) || (left_text && rightType == null) || (left_text && right_text)) >- type= ITypedElement.TEXT_TYPE; >- else >- type= BINARY_TYPE; >- >+ boolean right_text = rightType != null >+ && ITypedElement.TEXT_TYPE.equals(rightType); >+ boolean left_text = leftType != null >+ && ITypedElement.TEXT_TYPE.equals(leftType); > initializeRegistries(); >- List list = fContentMergeViewers.searchAll(type); >+ if (!right_text || !left_text) { >+ List list = fContentMergeViewers.searchAll(BINARY_TYPE); >+ if (list != null) >+ result.addAll(list); >+ } >+ List list = fContentMergeViewers.searchAll(ITypedElement.TEXT_TYPE); > if (list != null) > result.addAll(list); >+ > return (ViewerDescriptor[]) result.toArray(new ViewerDescriptor[0]); > } > return null; >@@ -936,13 +935,6 @@ > ViewerDescriptor[] descriptors = findContentViewerDescriptor(oldViewer, in, cc); > return getViewer(descriptors != null ? descriptors[0] : null, oldViewer, parent, cc); > } >- >- private boolean isCompareAsText(ICompareInput input, CompareConfiguration cc) { >- Set set = (Set)cc.getProperty(ICompareAsText.PROP_TEXT_INPUTS); >- if (set == null) >- return false; >- return set.contains(input); >- } > > private static Viewer getViewer(Object descriptor, Viewer oldViewer, Composite parent, CompareConfiguration cc) { > if (descriptor instanceof IViewerDescriptor) >@@ -1299,9 +1291,6 @@ > > String findContentTypeNameOrType(ICompareInput input, ViewerDescriptor vd, CompareConfiguration cc) { > IContentType ctype= getCommonType(input); >- if (isCompareAsText(input, cc)) { >- ctype = Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT); >- } > if (ctype != null) { > initializeRegistries(); > List list = fContentMergeViewers.searchAll(ctype); >@@ -1343,15 +1332,18 @@ > String rightType= guessType(input.getRight()); > > if (leftType != null || rightType != null) { >- boolean right_text= rightType != null && ITypedElement.TEXT_TYPE.equals(rightType); >- boolean left_text= leftType != null && ITypedElement.TEXT_TYPE.equals(leftType); >- if ((leftType == null && right_text) || (left_text && rightType == null) || (left_text && right_text)) >- type= ITypedElement.TEXT_TYPE; >- else >- type= BINARY_TYPE; >- >+ boolean right_text = rightType != null >+ && ITypedElement.TEXT_TYPE.equals(rightType); >+ boolean left_text = leftType != null >+ && ITypedElement.TEXT_TYPE.equals(leftType); > initializeRegistries(); >- List list = fContentMergeViewers.searchAll(type); >+ if (!left_text || !right_text) { >+ List list = fContentMergeViewers.searchAll(BINARY_TYPE); >+ if (list != null) >+ if (list.contains(vd)) >+ return type; >+ } >+ List list = fContentMergeViewers.searchAll(ITypedElement.TEXT_TYPE); > if (list != null) > if (list.contains(vd)) > return type;
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 266476
:
130094
| 130101