Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Weinand2002-01-30 18:57:49 +0000
committerAndre Weinand2002-01-30 18:57:49 +0000
commitc95bf5fc013f7feece621ee5a8cd5c44edb0b122 (patch)
tree8e562d4e0ef71b8762bcca91d9c290b0ceda8684 /bundles/org.eclipse.compare/compare/org/eclipse/compare
parent294e187037c8daa2b57c04b5ee53d68f8c825879 (diff)
downloadeclipse.platform.team-c95bf5fc013f7feece621ee5a8cd5c44edb0b122.tar.gz
eclipse.platform.team-c95bf5fc013f7feece621ee5a8cd5c44edb0b122.tar.xz
eclipse.platform.team-c95bf5fc013f7feece621ee5a8cd5c44edb0b122.zip
Accessability featuresv20020130
Diffstat (limited to 'bundles/org.eclipse.compare/compare/org/eclipse/compare')
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java13
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java165
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java9
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java37
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java4
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IStatusLine.java7
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StatusLineContributionItem.java89
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java16
8 files changed, 147 insertions, 193 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
index 0c6eaae2d..d6c702aad 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
@@ -88,6 +88,7 @@ import org.eclipse.compare.structuremergeviewer.*;
*/
public abstract class CompareEditorInput implements IEditorInput, IPropertyChangeNotifier, IRunnableWithProgress {
+ private static final boolean STRUCTURE_COMPARE_ON_SINGLE_CLICK= true;
/**
* The name of the "dirty" property.
*/
@@ -394,6 +395,7 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
}
);
+ /*
fStructureInputPane.addDoubleClickListener(
new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent e) {
@@ -401,6 +403,7 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
}
}
);
+ */
// setup the wiring for second pane
fStructurePane1.addSelectionChangedListener(
@@ -462,7 +465,13 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
fStructurePane1.setInput(null);
} else {
Object input= getElement(selection);
- fContentInputPane.setInput(input);
+ if (STRUCTURE_COMPARE_ON_SINGLE_CLICK) {
+ fStructurePane1.setInput(input);
+ //if (fStructurePane1.isEmpty())
+ fContentInputPane.setInput(input);
+ } else {
+ fContentInputPane.setInput(input);
+ }
fStructurePane2.setInput(null); // clear downstream pane
if (fStructurePane1.getInput() != input)
fStructurePane1.setInput(null);
@@ -472,6 +481,7 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
);
}
+ /*
private void feedDefault1(final ISelection selection) {
BusyIndicator.showWhile(fComposite.getDisplay(),
new Runnable() {
@@ -482,6 +492,7 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
}
);
}
+ */
private void feed2(final ISelection selection) {
BusyIndicator.showWhile(fComposite.getDisplay(),
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
index 0a17565a3..8d16ab24c 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
@@ -62,7 +62,6 @@ import org.eclipse.compare.internal.MergeViewerAction;
import org.eclipse.compare.internal.INavigatable;
import org.eclipse.compare.internal.CompareNavigator;
import org.eclipse.compare.internal.TimeoutContext;
-import org.eclipse.compare.internal.IStatusLine;
import org.eclipse.compare.rangedifferencer.*;
import org.eclipse.compare.structuremergeviewer.Differencer;
@@ -289,11 +288,19 @@ public class TextMergeViewer extends ContentMergeViewer {
String changeType() {
boolean leftEmpty= fLeftPos.length == 0;
boolean rightEmpty= fRightPos.length == 0;
- if (leftEmpty && !rightEmpty)
- return "Addition";
- if (!leftEmpty && rightEmpty)
- return "Deletion";
- return "Change";
+
+ if (fDirection == RangeDifference.LEFT) {
+ if (!leftEmpty && rightEmpty)
+ return "addition";
+ if (leftEmpty && !rightEmpty)
+ return "deletion";
+ } else {
+ if (leftEmpty && !rightEmpty)
+ return "addition";
+ if (!leftEmpty && rightEmpty)
+ return "deletion";
+ }
+ return "change";
}
Image getImage() {
@@ -1104,6 +1111,7 @@ public class TextMergeViewer extends ContentMergeViewer {
private void handleSelectionChanged(MergeSourceViewer tw) {
Point p= tw.getSelectedRange();
Diff d= findDiff(tw, p.x, p.x+p.y);
+ updateStatus(d);
setCurrentDiff(d, false); // don't select or reveal
}
@@ -1138,7 +1146,6 @@ public class TextMergeViewer extends ContentMergeViewer {
IDocument aDoc= null;
IDocument lDoc= fLeft.getDocument();
IDocument rDoc= fRight.getDocument();
-
if (lDoc == null || rDoc == null)
return;
@@ -1185,7 +1192,7 @@ public class TextMergeViewer extends ContentMergeViewer {
fAllDiffs.add(diff);
}
}
-
+
final ResourceBundle bundle= getResourceBundle();
final Object[] result= new Object[1];
@@ -1255,7 +1262,7 @@ public class TextMergeViewer extends ContentMergeViewer {
rDoc, rightStart, rightEnd);
fAllDiffs.add(diff); // remember all range diffs for scrolling
-
+
if (ignoreWhiteSpace) {
if (sancestor != null)
a= extract2(aDoc, sancestor, es.ancestorStart(), es.ancestorLength());
@@ -1265,11 +1272,11 @@ public class TextMergeViewer extends ContentMergeViewer {
if ((a == null || a.trim().length() == 0) && s.trim().length() == 0 && d.trim().length() == 0)
continue;
}
-
+
if (kind != RangeDifference.NOCHANGE && kind != RangeDifference.ANCESTOR) {
fChangeDiffs.add(diff); // here we remember only the real diffs
updateDiffBackground(diff);
-
+
if (s == null)
s= extract2(lDoc, sleft, es.leftStart(), es.leftLength());
if (d == null)
@@ -1408,7 +1415,7 @@ public class TextMergeViewer extends ContentMergeViewer {
/**
* Performs a "smart" token based 3-way diff on the character range specified by the given baseDiff.
- * It is smart because it tries to minimize the number of token diffs by merging them.
+ * It is "smart" because it tries to minimize the number of token diffs by merging them.
*/
private void mergingTokenDiff(Diff baseDiff,
IDocument ancestorDoc, String a,
@@ -1549,37 +1556,123 @@ public class TextMergeViewer extends ContentMergeViewer {
}
private void updateStatus(Diff diff) {
- /*
- IStatusLine status= Utilities.findStatusLine(fComposite);
- if (status != null) {
-// String n= ""; //$NON-NLS-1$
- String s= ""; //$NON-NLS-1$
- if (diff != null) {
- switch(diff.fDirection) {
- case RangeDifference.LEFT:
- s= "left"; //$NON-NLS-1$
- break;
- case RangeDifference.RIGHT:
- s= "right"; //$NON-NLS-1$
- break;
- case RangeDifference.CONFLICT:
- s= "conflicting"; //$NON-NLS-1$
- break;
+
+ IActionBars bars= Utilities.findActionBars(fComposite);
+ if (bars == null)
+ return;
+ IStatusLineManager slm= bars.getStatusLineManager();
+ if (slm == null)
+ return;
+
+ String diffDescription;
+
+ if (diff == null) {
+ diffDescription= ", no diff";
+ } else {
+
+ if (diff.fIsToken) // we don't show special info for token diffs
+ diff= diff.fParent;
+
+ String format= ", {0} #{1} (Left: {2}, Right: {3})";
+ diffDescription= MessageFormat.format(format,
+ new String[] {
+ getDiffType(diff), // 0: diff type
+ getDiffNumber(diff), // 1: diff number
+ getDiffRange(fLeft, diff.fLeftPos), // 2: left start line
+ getDiffRange(fRight, diff.fRightPos) // 3: left end line
}
- s+= diff.changeType();
-// n= "1 of n";
+ );
+ }
+
+ String format= "Left: {0}, Right: {1}{2}";
+ String s= MessageFormat.format(format,
+ new String[] {
+ getCursorPosition(fLeft), // 0: left cursor
+ getCursorPosition(fRight), // 1: right column
+ diffDescription // 2: diff description
}
-
- status.setStatus("Main", s); //$NON-NLS-1$
-// status.setStatus("Right", n); //$NON-NLS-1$
+ );
+
+ slm.setMessage(s);
+ }
+
+ private String getDiffType(Diff diff) {
+ String s= "";
+ switch(diff.fDirection) {
+ case RangeDifference.LEFT:
+ s= "outgoing";
+ break;
+ case RangeDifference.RIGHT:
+ s= "incoming";
+ break;
+ case RangeDifference.CONFLICT:
+ s= "conflicting";
+ break;
}
- */
+ s+= " " + diff.changeType();
+ return s;
}
- private IStatusLine getStatus() {
- return null;
+ private String getDiffNumber(Diff diff) {
+ // find the diff's number
+ int diffNumber= 0;
+ if (fChangeDiffs != null) {
+ Iterator e= fChangeDiffs.iterator();
+ while (e.hasNext()) {
+ Diff d= (Diff) e.next();
+ diffNumber++;
+ if (d == diff)
+ break;
+ }
+ }
+ return Integer.toString(diffNumber);
+ }
+
+ private String getDiffRange(MergeSourceViewer v, Position pos) {
+ Point p= v.getLineRange(pos, new Point(0, 0));
+ int startLine= p.x+1;
+ int endLine= p.x+p.y;
+ if (endLine < startLine)
+ return "before line " + startLine;
+ return startLine + " : " + endLine;
}
+ /**
+ * Returns a description of the cursor position.
+ *
+ * @return a description of the cursor position
+ */
+ private String getCursorPosition(MergeSourceViewer v) {
+ if (v != null) {
+ StyledText styledText= v.getTextWidget();
+
+ IDocument document= v.getDocument();
+ if (document != null) {
+ int offset= v.getVisibleRegion().getOffset();
+ int caret= offset + styledText.getCaretOffset();
+
+ try {
+
+ int line=document.getLineOfOffset(caret);
+
+ int lineOffset= document.getLineOffset(line);
+ int occurrences= 0;
+ for (int i= lineOffset; i < caret; i++)
+ if ('\t' == document.getChar(i))
+ ++ occurrences;
+
+ int tabWidth= styledText.getTabs();
+ int column= caret - lineOffset + (tabWidth -1) * occurrences;
+
+ return ((line + 1) + " : " + (column + 1));
+
+ } catch (BadLocationException x) {
+ }
+ }
+ }
+ return "??";
+ }
+
protected void updateHeader() {
super.updateHeader();
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
index c8cdfdff9..215309b76 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
@@ -30,7 +30,6 @@ public class CompareEditor extends EditorPart implements IPropertyChangeListener
public final static String CONFIRM_SAVE_PROPERTY= "org.eclipse.compare.internal.CONFIRM_SAVE_PROPERTY"; //$NON-NLS-1$
private IActionBars fActionBars;
- private IStatusLine fStatusLine;
public CompareEditor() {
@@ -68,14 +67,6 @@ public class CompareEditor extends EditorPart implements IPropertyChangeListener
fActionBars= actionBars;
}
- public IStatusLine getStatusLine() {
- return fStatusLine;
- }
-
- public void setStatusLine(IStatusLine statusLine) {
- fStatusLine= statusLine;
- }
-
/*
* @see IDesktopPart#createPartControl(Composite)
*/
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java
index 37851a4a9..3fe72b1ff 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java
@@ -6,16 +6,12 @@ package org.eclipse.compare.internal;
import java.util.ResourceBundle;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.action.*;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.*;
import org.eclipse.ui.part.EditorActionBarContributor;
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareEditorInput;
+import org.eclipse.compare.*;
public class CompareEditorContributor extends EditorActionBarContributor {
@@ -25,22 +21,6 @@ public class CompareEditorContributor extends EditorActionBarContributor {
private IgnoreWhiteSpaceAction fIgnoreWhitespace;
private NavigationAction fNext;
private NavigationAction fPrevious;
-// private StatusLineContributionItem fStatusLineContributionItem;
- private IStatusLine fStatusLine=
- new IStatusLine() {
- public void setStatus(String key, String message) {
-
- if ("Main".equals(key)) {
- IStatusLineManager slm= getActionBars().getStatusLineManager();
- if (slm != null)
- slm.setMessage(message);
-// } else {
-// if (fStatusLineContributionItem != null)
-// fStatusLineContributionItem.setText(message);
- }
- }
- };
-
public CompareEditorContributor() {
ResourceBundle bundle= CompareUIPlugin.getResourceBundle();
@@ -59,16 +39,6 @@ public class CompareEditorContributor extends EditorActionBarContributor {
tbm.add(fPrevious);
}
- /*
- * @see EditorActionBarContributor#contributeToStatusLine(IStatusLineManager)
- */
- public void contributeToStatusLine(IStatusLineManager slm) {
- super.contributeToStatusLine(slm);
-// if (fStatusLineContributionItem == null)
-// fStatusLineContributionItem= new StatusLineContributionItem("ID");
-// slm.add(fStatusLineContributionItem);
- }
-
public void setActiveEditor(IEditorPart targetEditor) {
if (fActiveEditorPart == targetEditor)
@@ -88,7 +58,6 @@ public class CompareEditorContributor extends EditorActionBarContributor {
if (targetEditor instanceof CompareEditor) {
CompareEditor editor= (CompareEditor) targetEditor;
editor.setActionBars(getActionBars());
- editor.setStatusLine(fStatusLine);
CompareConfiguration cc= editor.getCompareConfiguration();
fIgnoreWhitespace.setCompareConfiguration(cc);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
index 3919d565d..30ad36cc7 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
@@ -63,7 +63,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
private static final String COMPARE_EDITOR= PLUGIN_ID + ".CompareEditor"; //$NON-NLS-1$
- private static final String STRUCTUREVIEWER_ALIASES_PREFERENCE_NAME= "StructureViewerAliases";
+ private static final String STRUCTUREVIEWER_ALIASES_PREFERENCE_NAME= "StructureViewerAliases"; //$NON-NLS-1$
/** Maps type to icons */
private static Map fgImages= new Hashtable(10);
@@ -747,7 +747,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
String aliases= ps.getString(STRUCTUREVIEWER_ALIASES_PREFERENCE_NAME);
//System.out.println(" <" + aliases + ">");
if (aliases != null && aliases.length() > 0) {
- StringTokenizer st= new StringTokenizer(aliases, " ");
+ StringTokenizer st= new StringTokenizer(aliases, " "); //$NON-NLS-1$
while (st.hasMoreTokens()) {
String pair= st.nextToken();
int pos= pair.indexOf('.');
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IStatusLine.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IStatusLine.java
deleted file mode 100644
index 2442e62a5..000000000
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IStatusLine.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.eclipse.compare.internal;
-
-public interface IStatusLine {
-
- void setStatus(String field, String status);
-
-}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StatusLineContributionItem.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StatusLineContributionItem.java
deleted file mode 100644
index 080d7a2ed..000000000
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StatusLineContributionItem.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package org.eclipse.compare.internal;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.jface.action.ContributionItem;
-
-import org.eclipse.ui.texteditor.IStatusField;
-
-
-/**
- * Contribution item for the status line.
- */
-public class StatusLineContributionItem extends ContributionItem implements IStatusField {
-
-
- static class StatusLineLabel extends CLabel {
-
- private static int INDENT= 3; // left and right margin used in CLabel
-
- private Point fFixedSize;
-
- public StatusLineLabel(Composite parent, int style) {
- super(parent, style);
-
- GC gc= new GC(parent);
- gc.setFont(parent.getFont());
- Point extent= gc.textExtent("MMMMMMMMM");
- gc.dispose();
-
- fFixedSize= new Point(extent.x + INDENT * 2, 10);
- }
-
- public Point computeSize(int wHint, int hHint, boolean changed) {
- return fFixedSize;
- }
- };
-
- private String fText;
- private Image fImage;
- private StatusLineLabel fLabel;
-
- /**
- * Creates a new item with the given id.
- *
- * @param id the item's id
- */
- StatusLineContributionItem(String id) {
- super(id);
- }
-
- /*
- * @see IStatusField#setText
- */
- public void setText(String text) {
- fText= text;
- if (fLabel != null && !fLabel.isDisposed()) {
- fLabel.setText(fText);
- }
- }
-
- /*
- * @see IStatusField#setImage(Image)
- */
- public void setImage(Image image) {
- fImage= image;
- if (fLabel != null && !fLabel.isDisposed()) {
- fLabel.setImage(fImage);
- }
- }
-
- /*
- * @see IContributionItem#fill(Composite)
- */
- public void fill(Composite parent) {
- fLabel= new StatusLineLabel(parent, SWT.SHADOW_IN);
- fLabel.setData(this);
-
- if (fText != null)
- fLabel.setText(fText);
- }
-}
-
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
index 33794e0e8..d750b2097 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
@@ -36,22 +36,8 @@ import org.eclipse.compare.CompareConfiguration;
*/
public class Utilities {
- public static IStatusLine findStatusLine(Control c) {
- while (c != null) {
- Object data= c.getData();
- if (data instanceof CompareEditor)
- return ((CompareEditor)data).getStatusLine();
-
- //if (data instanceof IViewPart)
- // return ((IViewPart)data).getViewSite().getStatusLine();
-
- c= c.getParent();
- }
- return null;
- }
-
public static IActionBars findActionBars(Control c) {
- while (c != null) {
+ while (c != null && !c.isDisposed()) {
Object data= c.getData();
if (data instanceof CompareEditor)
return ((CompareEditor)data).getActionBars();

Back to the top