Cosmetics.
Change-Id: Ifea81e9b9736810150c4fb3d17723e6702d76833
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 5c39790..7c12041 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 @@
fLeg = leg;
if (fElement instanceof IEncodedStreamContentAccessor) {
try {
- fEncoding = ((IEncodedStreamContentAccessor)fElement).getCharset();
+ fEncoding = ((IEncodedStreamContentAccessor) fElement).getCharset();
} catch (CoreException e) {
// silently ignored
}
@@ -677,8 +677,8 @@
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 @@
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 @@
this.fViewer.addNewRange(fLeg, input, range);
}
} else if (parent instanceof IDocument) {
- newDocument= ((IDocumentRange)fElement).getDocument();
+ newDocument= ((IDocumentRange) fElement).getDocument();
}
}
@@ -1113,7 +1113,7 @@
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 @@
}
@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 @@
// 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 @@
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 @@
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 @@
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 @@
// 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) {
+ || ci.getLeft() instanceof IDocumentRange
+ || ci.getRight() instanceof IDocumentRange) {
+ if (left instanceof IDocumentRange)
+ leftRange= ((IDocumentRange) left).getRange();
+ if (right instanceof IDocumentRange)
+ rightRange= ((IDocumentRange) right).getRange();
- 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();
+ ancestor= ci.getAncestor();
+ left= getCompareConfiguration().isMirrored() ? ci.getRight() : ci.getLeft();
+ right= getCompareConfiguration().isMirrored() ? ci.getLeft() : ci.getRight();
}
}
}
@@ -5169,7 +5168,7 @@
Control center= getCenterControl();
if (center instanceof BufferedCanvas)
- ((BufferedCanvas)center).repaint();
+ ((BufferedCanvas) center).repaint();
if (fRightCanvas != null)
fRightCanvas.repaint();
@@ -5425,13 +5424,13 @@
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 9ee4117..829c1f3 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 @@
/**
*/
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 @@
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 @@
@Override
protected void updateContent(Object ancestor, Object left, Object right) {
-
setInput(fAncestor, ancestor);
fLeftImage= left;
@@ -78,41 +75,42 @@
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 @@
@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 @@
}
}
}
-