Skip to content

Commit 0226ac4

Browse files
eclipse-platform-botHeikoKlare
authored andcommitted
Perform clean code of ua/org.eclipse.help.ui
1 parent a4b95da commit 0226ac4

File tree

62 files changed

+1014
-608
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1014
-608
lines changed

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/RootScopePage.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,18 @@ private void updateEnableState(boolean enabled) {
172172
boolean first = disabledStates.isEmpty();
173173
for (int i = 0; i < children.length; i++) {
174174
Control child = children[i];
175-
if (child == masterButton)
175+
if (child == masterButton) {
176176
continue;
177+
}
177178
if (!enabled) {
178179
disabledStates.put(child, Boolean.valueOf(child.isEnabled()));
179180
child.setEnabled(false);
180181
} else {
181182
Boolean savedState = disabledStates.get(child);
182-
if (!first)
183+
if (!first) {
183184
child.setEnabled(savedState != null ? savedState
184185
.booleanValue() : true);
186+
}
185187
}
186188
}
187189
}

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/LaunchURL.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ public void setInitializationData(IConfigurationElement config,
7373
if (data != null && data instanceof Hashtable) {
7474
url = ((Hashtable<String, String>) data).get("url"); //$NON-NLS-1$
7575
}
76-
if (url == null || url.length() == 0)
76+
if (url == null || url.length() == 0) {
7777
url = config.getAttribute("url"); //$NON-NLS-1$
78+
}
7879
}
7980

8081
@Override

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/CloseHelpTrayHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
4141
Shell shell = Display.getCurrent().getActiveShell();
4242
if (shell != null && !shell.isDisposed()) {
4343
Object shellData = shell.getData();
44-
if (shellData instanceof TrayDialog) {
45-
TrayDialog trayDialog = (TrayDialog)shellData;
44+
if (shellData instanceof TrayDialog trayDialog) {
4645
if (trayDialog.getTray() instanceof HelpTray) {
4746
trayDialog.closeTray();
4847
}

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/ContextHelpDialog.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@ public synchronized void close() {
192192
}
193193
if (shell != null) {
194194
shell.close();
195-
if (!shell.isDisposed())
195+
if (!shell.isDisposed()) {
196196
shell.dispose();
197+
}
197198
shell = null;
198199
}
199200
} catch (Throwable ex) {
@@ -296,8 +297,9 @@ private Control createLink(Composite parent, IHelpResource topic) {
296297

297298
private Control createLinksArea(Composite parent) {
298299
IHelpResource[] relatedTopics = context.getRelatedTopics();
299-
if (relatedTopics == null)
300+
if (relatedTopics == null) {
300301
return null;
302+
}
301303
// Create control
302304
Composite composite = new Composite(parent, SWT.NONE);
303305
initAccessible(composite);

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/DefaultHelpUI.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,9 @@ private static HelpView getHelpView() {
267267
private static void setIntroStandby() {
268268
IIntroManager introMng = PlatformUI.getWorkbench().getIntroManager();
269269
IIntroPart intro = introMng.getIntro();
270-
if (intro != null && !introMng.isIntroStandby(intro))
270+
if (intro != null && !introMng.isIntroStandby(intro)) {
271271
introMng.setIntroStandby(intro, true);
272+
}
272273
}
273274

274275
private void warnNoOpenPerspective(IWorkbenchWindow window) {
@@ -307,8 +308,9 @@ public void displayContext(IContext context, int x, int y) {
307308
}
308309

309310
void displayContext(IContext context, int x, int y, boolean noInfopop) {
310-
if (context == null)
311+
if (context == null) {
311312
return;
313+
}
312314
boolean winfopop = Platform.getPreferencesService().getBoolean
313315
(HelpBasePlugin.PLUGIN_ID, IHelpBaseConstants.P_KEY_WINDOW_INFOPOP, false, null);
314316
boolean dinfopop = Platform.getPreferencesService().getBoolean
@@ -328,12 +330,13 @@ void displayContext(IContext context, int x, int y, boolean noInfopop) {
328330
IWorkbenchPart activePart = page.getActivePart();
329331
Control c = window.getShell().getDisplay().getFocusControl();
330332
IContextProvider adapter = activePart.getAdapter(IContextProvider.class);
331-
if (adapter != null)
333+
if (adapter != null) {
332334
context = adapter
333335
.getContext(c); /*
334336
* If the context help has no description text and exactly one
335337
* topic, go straight to the topic and skip context help.
336338
*/
339+
}
337340
Objects.requireNonNull(context, "context must not be null when displaying help content"); //$NON-NLS-1$
338341
String contextText = context.getText();
339342
IHelpResource[] topics = context.getRelatedTopics();
@@ -472,8 +475,9 @@ private boolean useExternalBrowser(String url) {
472475
if (!Constants.OS_WIN32.equalsIgnoreCase(Platform.getOS())) {
473476
Display display = Display.getCurrent();
474477
if (display != null) {
475-
if (insideModalParent(display))
478+
if (insideModalParent(display)) {
476479
return true;
480+
}
477481
}
478482
}
479483

@@ -494,8 +498,9 @@ private boolean insideModalParent(Display display) {
494498

495499
public static boolean isDisplayModal(Shell activeShell) {
496500
while (activeShell != null) {
497-
if ((activeShell.getStyle() & (SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL | SWT.SYSTEM_MODAL)) > 0)
501+
if ((activeShell.getStyle() & (SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL | SWT.SYSTEM_MODAL)) > 0) {
498502
return true;
503+
}
499504
activeShell = (Shell) activeShell.getParent();
500505
}
501506
return false;

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HelpActivitySupport.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ public ActivityDescriptor() {
6262

6363
private void load() {
6464
IConfigurationElement [] elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.help.base.activitySupport");//$NON-NLS-1$
65-
if (elements.length==1 && elements[0].getName().equals("support")) //$NON-NLS-1$
65+
if (elements.length==1 && elements[0].getName().equals("support")) { //$NON-NLS-1$
6666
config = elements[0];
67-
else if (elements.length>0) {
67+
} else if (elements.length>0) {
6868
IProduct product = Platform.getProduct();
69-
if (product==null) return;
69+
if (product==null) {
70+
return;
71+
}
7072
String productId = product.getId();
7173
for (int i=0; i<elements.length; i++) {
7274
IConfigurationElement element = elements[i];
@@ -82,11 +84,13 @@ private IConfigurationElement getChild(String name) {
8284
return children.length==1?children[0]:null;
8385
}
8486
public String getShowAllMessage() {
85-
if (config==null)
87+
if (config==null) {
8688
return null;
89+
}
8790
IConfigurationElement child = getChild("showAllMessage"); //$NON-NLS-1$
88-
if (child!=null)
91+
if (child!=null) {
8992
return child.getValue();
93+
}
9094
return null;
9195
}
9296
public boolean needsLiveHelp(boolean embedded) {
@@ -108,9 +112,9 @@ public String getDocumentMessage(boolean embedded) {
108112
buffer.append(getActivityEditorValue(pluginId, className, embedded));
109113
buffer.append(value.substring(loc+15));
110114
documentMessage = buffer.toString();
111-
}
112-
else
115+
} else {
113116
documentMessage = value;
117+
}
114118
}
115119
}
116120
return documentMessage;

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HelpUIEventLoop.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ public class HelpUIEventLoop {
3434
*/
3535
public static void run() {
3636
try {
37-
if (display == null)
37+
if (display == null) {
3838
display = Display.getCurrent();
39-
if (display == null)
39+
}
40+
if (display == null) {
4041
display = new Display();
42+
}
4143
} finally {
4244
started = true;
4345
}
@@ -61,11 +63,12 @@ public static void run() {
6163

6264
public static void wakeup() {
6365
Display d = display;
64-
if (d != null)
66+
if (d != null) {
6567
try {
6668
d.wake();
6769
} catch (Exception e) {
6870
}
71+
}
6972
}
7073

7174
/**

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HelpUIPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ public void start(BundleContext context) throws Exception {
7171
DEBUG_INFOPOP = "true".equalsIgnoreCase(Platform.getDebugOption(PLUGIN_ID + "/debug/infopop")); //$NON-NLS-1$ //$NON-NLS-2$
7272
}
7373

74-
if (BaseHelpSystem.getMode() == BaseHelpSystem.MODE_WORKBENCH)
74+
if (BaseHelpSystem.getMode() == BaseHelpSystem.MODE_WORKBENCH) {
7575
// UI may get activated during standalone
7676
BaseHelpSystem.setDefaultErrorUtil(new ErrorUtil());
77+
}
7778

7879
if (BaseHelpSystem.getMode() == BaseHelpSystem.MODE_WORKBENCH) {
7980
// This is workbench scenario. Set activity support of base help to

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HelpUIResources.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ public static ImageDescriptor getImageDescriptor(String bundleId, String name) {
7676
ImageDescriptor desc = registry.getDescriptor(name);
7777
if (desc==null) {
7878
Bundle bundle = Platform.getBundle(bundleId);
79-
if (bundle==null) return null;
79+
if (bundle==null) {
80+
return null;
81+
}
8082
URL url = FileLocator.find(bundle, IPath.fromOSString(name), null);
8183
desc = ImageDescriptor.createFromURL(url);
8284
registry.put(name, desc);
@@ -89,7 +91,9 @@ public static ImageDescriptor getIconImageDescriptor(String bundleId, String pat
8991
ImageDescriptor desc = registry.getDescriptor(key);
9092
if (desc==null) {
9193
Bundle bundle = Platform.getBundle(bundleId);
92-
if (bundle == null) return null;
94+
if (bundle == null) {
95+
return null;
96+
}
9397
URL url = FileLocator.find(bundle, IPath.fromOSString(path), null);
9498
desc = ImageDescriptor.createFromURL(url);
9599
registry.put(key, desc);
@@ -158,12 +162,15 @@ private static void initializeTocIcons(){
158162
String contributorID = iconElem.getContributor().getName();
159163

160164
for (int k=0; k < attrs.length; k++){
161-
if(attrs[k].equals(OPEN_ICON_PATH))
165+
if(attrs[k].equals(OPEN_ICON_PATH)) {
162166
HelpUIResources.getIconImageDescriptor(contributorID, iconElem.getAttribute(OPEN_ICON_PATH), iconElem.getAttribute(TOC_ICON_ID) + OPEN);
163-
if(attrs[k].equals(CLOSED_ICON_PATH))
167+
}
168+
if(attrs[k].equals(CLOSED_ICON_PATH)) {
164169
HelpUIResources.getIconImageDescriptor(contributorID, iconElem.getAttribute(CLOSED_ICON_PATH), iconElem.getAttribute(TOC_ICON_ID) + CLOSED);
165-
if(attrs[k].equals(LEAF_ICON_PATH))
170+
}
171+
if(attrs[k].equals(LEAF_ICON_PATH)) {
166172
HelpUIResources.getIconImageDescriptor(contributorID, iconElem.getAttribute(LEAF_ICON_PATH), iconElem.getAttribute(TOC_ICON_ID) + LEAF);
173+
}
167174
}
168175

169176
}

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HyperlinkHandler.java

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,43 +103,54 @@ public void mouseDoubleClick(MouseEvent e) {
103103

104104
@Override
105105
public void mouseDown(MouseEvent e) {
106-
if (e.button == 1)
106+
if (e.button == 1) {
107107
return;
108+
}
108109
lastLink = (Control) e.widget;
109110
}
110111

111112
@Override
112113
public void mouseEnter(MouseEvent e) {
113114
Control control = (Control) e.widget;
114115

115-
if (isHyperlinkCursorUsed())
116+
if (isHyperlinkCursorUsed()) {
116117
control.setCursor(hyperlinkCursor);
117-
if (activeBackground != null)
118+
}
119+
if (activeBackground != null) {
118120
control.setBackground(activeBackground);
119-
if (activeForeground != null)
121+
}
122+
if (activeForeground != null) {
120123
control.setForeground(activeForeground);
121-
if (hyperlinkUnderlineMode == UNDERLINE_ROLLOVER)
124+
}
125+
if (hyperlinkUnderlineMode == UNDERLINE_ROLLOVER) {
122126
underline(control, true);
127+
}
123128
IHyperlinkListener action = getLinkListener(control);
124-
if (action != null)
129+
if (action != null) {
125130
action.linkEntered(control);
131+
}
126132
}
127133

128134
@Override
129135
public void mouseExit(MouseEvent e) {
130136
Control control = (Control) e.widget;
131137

132-
if (isHyperlinkCursorUsed())
138+
if (isHyperlinkCursorUsed()) {
133139
control.setCursor(null);
134-
if (hyperlinkUnderlineMode == UNDERLINE_ROLLOVER)
140+
}
141+
if (hyperlinkUnderlineMode == UNDERLINE_ROLLOVER) {
135142
underline(control, false);
136-
if (background != null)
143+
}
144+
if (background != null) {
137145
control.setBackground(background);
138-
if (foreground != null)
146+
}
147+
if (foreground != null) {
139148
control.setForeground(foreground);
149+
}
140150
IHyperlinkListener action = getLinkListener(control);
141-
if (action != null)
151+
if (action != null) {
142152
action.linkExited(control);
153+
}
143154
}
144155

145156
@Override
@@ -148,24 +159,27 @@ public void mouseHover(MouseEvent e) {
148159

149160
@Override
150161
public void mouseUp(MouseEvent e) {
151-
if (e.button != 1)
162+
if (e.button != 1) {
152163
return;
164+
}
153165
IHyperlinkListener action = getLinkListener((Control) e.widget);
154166

155167
if (action != null) {
156168
Control c = (Control) e.widget;
157169
c.setCursor(busyCursor);
158170
action.linkActivated(c);
159-
if (!c.isDisposed())
171+
if (!c.isDisposed()) {
160172
c.setCursor(isHyperlinkCursorUsed() ? hyperlinkCursor : null);
173+
}
161174
}
162175
}
163176

164177
@Override
165178
public void paintControl(PaintEvent e) {
166179
Control control = (Control) e.widget;
167-
if (hyperlinkUnderlineMode == UNDERLINE_ALWAYS)
180+
if (hyperlinkUnderlineMode == UNDERLINE_ALWAYS) {
168181
HyperlinkHandler.underline(control, true);
182+
}
169183
}
170184
/**
171185
* @param control
@@ -174,22 +188,26 @@ public void paintControl(PaintEvent e) {
174188
* org.eclipse.help.ui.internal.IHyperlinkListener
175189
*/
176190
public void registerHyperlink(Control control, IHyperlinkListener listener) {
177-
if (background != null)
191+
if (background != null) {
178192
control.setBackground(background);
179-
if (foreground != null)
193+
}
194+
if (foreground != null) {
180195
control.setForeground(foreground);
196+
}
181197
control.addMouseListener(this);
182198
control.addMouseTrackListener(this);
183199
control.addListener(SWT.DefaultSelection, this);
184200

185-
if (hyperlinkUnderlineMode == UNDERLINE_ALWAYS)
201+
if (hyperlinkUnderlineMode == UNDERLINE_ALWAYS) {
186202
control.addPaintListener(this);
203+
}
187204
hyperlinkListeners.put(control, listener);
188205
removeDisposedLinks();
189206
}
190207
public IHyperlinkListener getLinkListener(Control c) {
191-
if (c instanceof Label)
208+
if (c instanceof Label) {
192209
c = c.getParent();
210+
}
193211
return hyperlinkListeners.get(c);
194212
}
195213

@@ -257,8 +275,9 @@ public void setHyperlinkUnderlineMode(int newHyperlinkUnderlineMode) {
257275
*/
258276
public static void underline(Control control, boolean inside) {
259277

260-
if (control instanceof HyperlinkLabel)
278+
if (control instanceof HyperlinkLabel) {
261279
control = ((HyperlinkLabel) control).getLabel();
280+
}
262281

263282
Composite parent = control.getParent();
264283
Rectangle bounds = control.getBounds();

0 commit comments

Comments
 (0)