Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2017-03-02 20:46:56 +0000
committerSergey Prigogin2017-03-03 18:47:02 +0000
commit61c4c5b37a2f7150139e41adea50f42e8caa19b2 (patch)
treef417720fa4f001ba3c9ad5bd6bfd1e7045382988
parente4281a76e6b2a994e22b3594dee7c59d845adfdc (diff)
downloadeclipse.platform.team-61c4c5b37a2f7150139e41adea50f42e8caa19b2.tar.gz
eclipse.platform.team-61c4c5b37a2f7150139e41adea50f42e8caa19b2.tar.xz
eclipse.platform.team-61c4c5b37a2f7150139e41adea50f42e8caa19b2.zip
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java53
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java65
2 files changed, 57 insertions, 61 deletions
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 5c39790af..7c120419d 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
@@ -558,7 +558,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
fLeg = leg;
if (fElement instanceof IEncodedStreamContentAccessor) {
try {
- fEncoding = ((IEncodedStreamContentAccessor)fElement).getCharset();
+ fEncoding = ((IEncodedStreamContentAccessor) fElement).getCharset();
} catch (CoreException e) {
// silently ignored
}
@@ -677,8 +677,8 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
Position range= null;
if (fElement instanceof IDocumentRange) {
- newDocument= ((IDocumentRange)fElement).getDocument();
- range= ((IDocumentRange)fElement).getRange();
+ newDocument= ((IDocumentRange) fElement).getDocument();
+ range= ((IDocumentRange) fElement).getRange();
connectToSharedDocument();
} else if (fElement instanceof IDocument) {
@@ -700,14 +700,14 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
ITypedElement parent= this.fViewer.getParent(fLeg); // we try to find an insertion position within the deletion's parent
if (parent instanceof IDocumentRange) {
- newDocument= ((IDocumentRange)parent).getDocument();
+ newDocument= ((IDocumentRange) parent).getDocument();
newDocument.addPositionCategory(DIFF_RANGE_CATEGORY);
Object input= this.fViewer.getInput();
range= this.fViewer.getNewRange(fLeg, input);
if (range == null) {
int pos= 0;
if (input instanceof ICompareInput)
- pos= this.fViewer.findInsertionPosition(fLeg, (ICompareInput)input);
+ pos= this.fViewer.findInsertionPosition(fLeg, (ICompareInput) input);
range= new Position(pos, 0);
try {
newDocument.addPosition(DIFF_RANGE_CATEGORY, range);
@@ -721,7 +721,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
this.fViewer.addNewRange(fLeg, input, range);
}
} else if (parent instanceof IDocument) {
- newDocument= ((IDocumentRange)fElement).getDocument();
+ newDocument= ((IDocumentRange) fElement).getDocument();
}
}
@@ -1113,7 +1113,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
if (fElement == null)
return true;
if (fDocumentProvider instanceof IDocumentProviderExtension) {
- IDocumentProviderExtension ext = (IDocumentProviderExtension)fDocumentProvider;
+ IDocumentProviderExtension ext = (IDocumentProviderExtension) fDocumentProvider;
if (ext.isReadOnly(fDocumentKey)) {
try {
ext.validateState(fDocumentKey, getControl().getShell());
@@ -1543,7 +1543,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
}
@Override
public boolean isHunkOnLeft() {
- ITypedElement left = ((ICompareInput)getInput()).getRight();
+ ITypedElement left = ((ICompareInput) getInput()).getRight();
return left != null && Adapters.adapt(left, IHunk.class) != null;
}
@Override
@@ -1851,7 +1851,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
// to get undo for all text files, bugzilla 131895, 33665
if(textViewer instanceof ISourceViewer){
SourceViewerConfiguration configuration= new SourceViewerConfiguration();
- ((ISourceViewer)textViewer).configure(configuration);
+ ((ISourceViewer) textViewer).configure(configuration);
}
}
@@ -2160,7 +2160,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
new Listener() {
@Override
public void handleEvent(Event e) {
- int vpos= ((ScrollBar)e.widget).getSelection();
+ int vpos= ((ScrollBar) e.widget).getSelection();
synchronizedScrollVertical(vpos);
}
}
@@ -2883,7 +2883,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
return doc;
if (input instanceof IDiffElement) {
- IDiffContainer parent= ((IDiffElement)input).getParent();
+ IDiffContainer parent= ((IDiffElement) input).getParent();
return getElementDocument(type, parent);
}
return null;
@@ -2939,7 +2939,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
private ITypedElement getParent(char type) {
Object input= getInput();
if (input instanceof IDiffElement) {
- IDiffContainer parent= ((IDiffElement)input).getParent();
+ IDiffContainer parent= ((IDiffElement) input).getParent();
return Utilities.getLeg(type, parent);
}
return null;
@@ -2963,22 +2963,21 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
// if one side is empty use container
if (FIX_47640 && !emptyInput && (left == null || right == null)) {
if (input instanceof IDiffElement) {
- IDiffContainer parent= ((IDiffElement)input).getParent();
+ IDiffContainer parent= ((IDiffElement) input).getParent();
if (parent instanceof ICompareInput) {
ICompareInput ci= (ICompareInput) parent;
if (ci.getAncestor() instanceof IDocumentRange
- || ci.getLeft() instanceof IDocumentRange
- || ci.getRight() instanceof IDocumentRange) {
-
- if (left instanceof IDocumentRange)
- leftRange= ((IDocumentRange)left).getRange();
- if (right instanceof IDocumentRange)
- rightRange= ((IDocumentRange)right).getRange();
-
- ancestor= ci.getAncestor();
- left= getCompareConfiguration().isMirrored() ? ci.getRight() : ci.getLeft();
- right= getCompareConfiguration().isMirrored() ? ci.getLeft() : ci.getRight();
+ || ci.getLeft() instanceof IDocumentRange
+ || ci.getRight() instanceof IDocumentRange) {
+ if (left instanceof IDocumentRange)
+ leftRange= ((IDocumentRange) left).getRange();
+ if (right instanceof IDocumentRange)
+ rightRange= ((IDocumentRange) right).getRange();
+
+ ancestor= ci.getAncestor();
+ left= getCompareConfiguration().isMirrored() ? ci.getRight() : ci.getLeft();
+ right= getCompareConfiguration().isMirrored() ? ci.getLeft() : ci.getRight();
}
}
}
@@ -5169,7 +5168,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
Control center= getCenterControl();
if (center instanceof BufferedCanvas)
- ((BufferedCanvas)center).repaint();
+ ((BufferedCanvas) center).repaint();
if (fRightCanvas != null)
fRightCanvas.repaint();
@@ -5425,13 +5424,13 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
if (right != null) {
Object element = Adapters.adapt(right, IHunk.class);
if (element instanceof IHunk)
- return ((IHunk)element).getStartPosition();
+ return ((IHunk) element).getStartPosition();
}
ITypedElement left = ((DiffNode) input).getLeft();
if (left != null) {
Object element = Adapters.adapt(left, IHunk.class);
if (element instanceof IHunk)
- return ((IHunk)element).getStartPosition();
+ return ((IHunk) element).getStartPosition();
}
}
return 0;
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java
index 9ee4117ee..829c1f32e 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java
@@ -28,7 +28,6 @@ import org.eclipse.compare.contentmergeviewer.ContentMergeViewer;
/**
*/
public class ImageMergeViewer extends ContentMergeViewer {
-
private static final String BUNDLE_NAME= "org.eclipse.compare.internal.ImageMergeViewerResources"; //$NON-NLS-1$
private Object fLeftImage;
@@ -38,7 +37,6 @@ public class ImageMergeViewer extends ContentMergeViewer {
private ImageCanvas fLeft;
private ImageCanvas fRight;
-
public ImageMergeViewer(Composite parent, int styles, CompareConfiguration mp) {
super(styles, ResourceBundle.getBundle(BUNDLE_NAME), mp);
@@ -51,7 +49,6 @@ public class ImageMergeViewer extends ContentMergeViewer {
@Override
protected void updateContent(Object ancestor, Object left, Object right) {
-
setInput(fAncestor, ancestor);
fLeftImage= left;
@@ -78,41 +75,42 @@ public class ImageMergeViewer extends ContentMergeViewer {
private static void setInput(ImageCanvas canvas, Object input) {
if (canvas != null) {
-
InputStream stream= null;
- if (input instanceof IStreamContentAccessor) {
- IStreamContentAccessor sca= (IStreamContentAccessor) input;
- if (sca != null) {
- try {
- stream= sca.getContents();
- } catch (CoreException ex) {
- // NeedWork
+ try {
+ if (input instanceof IStreamContentAccessor) {
+ IStreamContentAccessor sca= (IStreamContentAccessor) input;
+ if (sca != null) {
+ try {
+ stream= sca.getContents();
+ } catch (CoreException e) {
+ // NeedWork
+ }
}
}
- }
- Image image= null;
- Display display= canvas.getDisplay();
- if (stream != null) {
- try {
- image= new Image(display, stream);
- } catch (SWTException ex) {
- // silently ignored
+ Image image= null;
+ Display display= canvas.getDisplay();
+ if (stream != null) {
+ try {
+ image= new Image(display, stream);
+ } catch (SWTException e) {
+ // silently ignored
+ }
}
- }
-
- canvas.setImage(image);
- if (image != null) {
- canvas.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
- } else {
- canvas.setBackground(null);
- }
- if (stream != null) {
- try {
- stream.close();
- } catch (IOException ex) {
- // silently ignored
+ canvas.setImage(image);
+ if (image != null) {
+ canvas.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+ } else {
+ canvas.setBackground(null);
+ }
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ // silently ignored
+ }
}
}
}
@@ -131,7 +129,7 @@ public class ImageMergeViewer extends ContentMergeViewer {
@Override
protected void handleResizeLeftRight(int x, int y, int width1, int centerWidth, int width2, int height) {
fLeft.setBounds(x, y, width1, height);
- fRight.setBounds(x+width1+centerWidth, y, width2, height);
+ fRight.setBounds(x + width1 + centerWidth, y, width2, height);
}
@Override
@@ -147,4 +145,3 @@ public class ImageMergeViewer extends ContentMergeViewer {
}
}
}
-

Back to the top