Skip to content

Commit 1a4de98

Browse files
eclipse-pde-botlaeubi
authored andcommitted
Perform clean code of ds/org.eclipse.pde.ds.ui
1 parent 95a8287 commit 1a4de98

26 files changed

+294
-162
lines changed

ds/org.eclipse.pde.ds.ui/src/org/eclipse/pde/internal/ds/ui/Activator.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,15 @@ public static void logException(Throwable e, final String title,
112112
e = ((InvocationTargetException) e).getTargetException();
113113
}
114114
IStatus status = null;
115-
if (e instanceof CoreException)
115+
if (e instanceof CoreException) {
116116
status = ((CoreException) e).getStatus();
117-
else {
118-
if (message == null)
117+
} else {
118+
if (message == null) {
119119
message = e.getMessage();
120-
if (message == null)
120+
}
121+
if (message == null) {
121122
message = e.toString();
123+
}
122124
status = Status.error(message, e);
123125
}
124126
ResourcesPlugin.getPlugin().getLog().log(status);

ds/org.eclipse.pde.ds.ui/src/org/eclipse/pde/internal/ds/ui/SWTUtil.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ public class SWTUtil {
4747
public static Display getStandardDisplay() {
4848
Display display;
4949
display = Display.getCurrent();
50-
if (display == null)
50+
if (display == null) {
5151
display = Display.getDefault();
52+
}
5253
return display;
5354
}
5455

@@ -59,18 +60,24 @@ public static Display getStandardDisplay() {
5960
* @return the shell for the given widget
6061
*/
6162
public static Shell getShell(Widget widget) {
62-
if (widget instanceof Control)
63+
if (widget instanceof Control) {
6364
return ((Control) widget).getShell();
64-
if (widget instanceof Caret)
65+
}
66+
if (widget instanceof Caret) {
6567
return ((Caret) widget).getParent().getShell();
66-
if (widget instanceof DragSource)
68+
}
69+
if (widget instanceof DragSource) {
6770
return ((DragSource) widget).getControl().getShell();
68-
if (widget instanceof DropTarget)
71+
}
72+
if (widget instanceof DropTarget) {
6973
return ((DropTarget) widget).getControl().getShell();
70-
if (widget instanceof Menu)
74+
}
75+
if (widget instanceof Menu) {
7176
return ((Menu) widget).getParent().getShell();
72-
if (widget instanceof ScrollBar)
77+
}
78+
if (widget instanceof ScrollBar) {
7379
return ((ScrollBar) widget).getParent().getShell();
80+
}
7481

7582
return null;
7683
}
@@ -79,8 +86,9 @@ public static Shell getShell(Widget widget) {
7986
* Returns a width hint for a button control.
8087
*/
8188
public static int getButtonWidthHint(Button button) {
82-
if (button.getFont().equals(JFaceResources.getDefaultFont()))
89+
if (button.getFont().equals(JFaceResources.getDefaultFont())) {
8390
button.setFont(JFaceResources.getDialogFont());
91+
}
8492
PixelConverter converter = new PixelConverter(button);
8593
int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
8694
return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);

ds/org.eclipse.pde.ds.ui/src/org/eclipse/pde/internal/ds/ui/SharedImages.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ public static Image getImage(String key, int flags) {
7070
if ((flags & F_DYNAMIC) != 0) {
7171
Image o = Activator.getDefault().getImageRegistry().get(
7272
key + OVR_DYNAMIC);
73-
if (o != null)
73+
if (o != null) {
7474
return o;
75+
}
7576
Image i = new DecorationOverlayIcon(image, SharedImages
7677
.getImageDescriptor(OVR_DYNAMIC),
7778
IDecoration.TOP_RIGHT)

ds/org.eclipse.pde.ds.ui/src/org/eclipse/pde/internal/ds/ui/editor/DSHyperlinkDetector.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,18 @@ public DSHyperlinkDetector(PDESourcePage page) {
4545
@Override
4646
protected IHyperlink[] detectAttributeHyperlink(IDocumentAttributeNode attr) {
4747
String attrValue = attr.getAttributeValue();
48-
if (attrValue.length() == 0)
48+
if (attrValue.length() == 0) {
4949
return null;
50+
}
5051

5152
if (!(attr.getEnclosingElement() instanceof IDSObject)) {
5253
return null;
5354
}
5455
IDSObject node = (IDSObject) attr.getEnclosingElement();
5556

56-
if (node == null || !node.getModel().isEditable())
57+
if (node == null || !node.getModel().isEditable()) {
5758
return null;
59+
}
5860

5961
IRegion linkRegion = new Region(attr.getValueOffset(), attr
6062
.getValueLength());
@@ -96,8 +98,9 @@ protected IHyperlink[] detectAttributeHyperlink(IDocumentAttributeNode attr) {
9698
// declarations?
9799
}
98100

99-
if (link[0] != null)
101+
if (link[0] != null) {
100102
return link;
103+
}
101104

102105
return null;
103106
}

ds/org.eclipse.pde.ds.ui/src/org/eclipse/pde/internal/ds/ui/editor/DSLabelProvider.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ public String getText(Object obj) {
3535
return getObjectText((IDSObject) obj);
3636
}
3737

38-
if (obj instanceof IFormPage)
38+
if (obj instanceof IFormPage) {
3939
return ((IFormPage) obj).getTitle();
40+
}
4041

4142
return super.getText(obj);
4243
}
@@ -49,8 +50,9 @@ public String getObjectText(IDSObject obj) {
4950
if (obj.getType() == IDSConstants.TYPE_REFERENCE) {
5051
IDSReference reference = (IDSReference) obj;
5152
if (reference.getName() == null
52-
|| reference.getName().length() == 0)
53+
|| reference.getName().length() == 0) {
5354
return reference.getReferenceInterface();
55+
}
5456
}
5557
return obj.getName();
5658
}
@@ -62,9 +64,10 @@ public Image getImage(Object obj) {
6264
}
6365

6466
// TODO consider changing this
65-
if (obj instanceof IFormPage)
67+
if (obj instanceof IFormPage) {
6668
return PDEPlugin.getDefault().getLabelProvider().get(
6769
PDEPluginImages.DESC_PAGE_OBJ);
70+
}
6871

6972
return super.getImage(obj);
7073
}
@@ -83,9 +86,10 @@ private Image getObjectImage(IDSObject obj) {
8386
int flags = 0;
8487

8588
if (reference == null || reference.getReferencePolicy() == null
86-
|| reference.getReferenceCardinality() == null)
89+
|| reference.getReferenceCardinality() == null) {
8790
return SharedImages
8891
.getImage(SharedImages.DESC_REFERENCE, flags);
92+
}
8993

9094
if (reference.getReferencePolicy().equals(
9195
IDSConstants.VALUE_REFERENCE_POLICY_DYNAMIC)) {

ds/org.eclipse.pde.ds.ui/src/org/eclipse/pde/internal/ds/ui/editor/DSSourcePage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,9 @@ protected void setPartName(String partName) {
126126
@SuppressWarnings("unchecked")
127127
@Override
128128
public <T> T getAdapter(Class<T> adapter) {
129-
if (IHyperlinkDetector.class.equals(adapter))
129+
if (IHyperlinkDetector.class.equals(adapter)) {
130130
return (T) new DSHyperlinkDetector(this);
131+
}
131132
return super.getAdapter(adapter);
132133
}
133134

ds/org.eclipse.pde.ds.ui/src/org/eclipse/pde/internal/ds/ui/editor/DSSourceViewerConfiguration.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,18 @@ public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
6060

6161
@Override
6262
public void dispose() {
63-
if (fContentAssistProcessor != null)
63+
if (fContentAssistProcessor != null) {
6464
fContentAssistProcessor.dispose();
65+
}
6566
super.dispose();
6667
}
6768

6869
@Override
6970
public ITextHover getTextHover(ISourceViewer sourceViewer,
7071
String contentType) {
71-
if (fTextHover == null && fSourcePage != null)
72+
if (fTextHover == null && fSourcePage != null) {
7273
fTextHover = new DSTextHover(fSourcePage);
74+
}
7375
return fTextHover;
7476
}
7577

ds/org.eclipse.pde.ds.ui/src/org/eclipse/pde/internal/ds/ui/editor/DSTextHover.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,23 @@ public DSTextHover(PDESourcePage sourcePage) {
3737
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
3838
int offset = hoverRegion.getOffset();
3939
IDocumentRange range = fSourcePage.getRangeElement(offset, true);
40-
if (range instanceof IDocumentTextNode)
40+
if (range instanceof IDocumentTextNode) {
4141
return checkTranslatedValue((IDocumentTextNode) range);
42-
if (!(range instanceof IDSObject))
42+
}
43+
if (!(range instanceof IDSObject)) {
4344
return null;
45+
}
4446

4547
return ((IDSObject) range).getName();
4648

4749
}
4850

4951
private String checkTranslatedValue(IDocumentTextNode node) {
5052
String value = node.getText();
51-
if (value.startsWith("%")) //$NON-NLS-1$
53+
if (value.startsWith("%")) { //$NON-NLS-1$
5254
return ((IPluginObject) node.getEnclosingElement())
53-
.getResourceString(value);
55+
.getResourceString(value);
56+
}
5457

5558
return null;
5659
}

ds/org.eclipse.pde.ds.ui/src/org/eclipse/pde/internal/ds/ui/editor/DSTypeSelectionExtension.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ public DSTypeSelectionExtension(IDSModel model) {
5858
@Override
5959
public ITypeInfoFilterExtension getFilterExtension() {
6060
IDSService service = fModel.getDSComponent().getService();
61-
if (service != null)
61+
if (service != null) {
6262
return new TypeInfoFilterExtension(service.getProvidedServices());
63+
}
6364
return null;
6465
}
6566

ds/org.eclipse.pde.ds.ui/src/org/eclipse/pde/internal/ds/ui/editor/FormEntryAdapter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,18 @@ public void browseButtonSelected(FormEntry entry) {
5959

6060
@Override
6161
public void linkEntered(HyperlinkEvent e) {
62-
if (actionBars == null)
62+
if (actionBars == null) {
6363
return;
64+
}
6465
IStatusLineManager mng = actionBars.getStatusLineManager();
6566
mng.setMessage(e.getLabel());
6667
}
6768

6869
@Override
6970
public void linkExited(HyperlinkEvent e) {
70-
if (actionBars == null)
71+
if (actionBars == null) {
7172
return;
73+
}
7274
IStatusLineManager mng = actionBars.getStatusLineManager();
7375
mng.setMessage(null);
7476
}

0 commit comments

Comments
 (0)