Skip to content

Commit 4f7c19e

Browse files
eclipse-platform-botHeikoKlare
authored andcommitted
Perform clean code of ua/org.eclipse.help.base
1 parent 5c8d318 commit 4f7c19e

File tree

71 files changed

+1441
-848
lines changed

Some content is hidden

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

71 files changed

+1441
-848
lines changed

ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/BaseHelpSystem.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ public static synchronized IBrowser getHelpBrowser(boolean forceExternal) {
127127
}
128128

129129
public static synchronized HelpDisplay getHelpDisplay() {
130-
if (getInstance().helpDisplay == null)
130+
if (getInstance().helpDisplay == null) {
131131
getInstance().helpDisplay = new HelpDisplay();
132+
}
132133
return getInstance().helpDisplay;
133134
}
134135

@@ -195,15 +196,16 @@ public static boolean ensureWebappRunning() {
195196
public static URL resolve(String href, boolean documentOnly) {
196197
String url = null;
197198
if (href == null || href.contains("://") //$NON-NLS-1$
198-
|| isFileProtocol(href))
199+
|| isFileProtocol(href)) {
199200
url = href;
200-
else {
201+
} else {
201202
BaseHelpSystem.ensureWebappRunning();
202203
String base = getBase(documentOnly);
203-
if (href.startsWith("/")) //$NON-NLS-1$
204+
if (href.startsWith("/")) { //$NON-NLS-1$
204205
url = base + href;
205-
else
206+
} else {
206207
url = base + "/" + href; //$NON-NLS-1$
208+
}
207209
}
208210
try {
209211
return new URL(url);
@@ -325,8 +327,9 @@ public static void runLiveHelp(String pluginID, String className, String arg) {
325327
Object o = c.getDeclaredConstructor().newInstance();
326328
//Runnable runnable = null;
327329
if (o instanceof ILiveHelpAction helpExt) {
328-
if (arg != null)
330+
if (arg != null) {
329331
helpExt.setInitializationString(arg);
332+
}
330333
Thread runnableLiveHelp = new Thread(helpExt);
331334
runnableLiveHelp.setDaemon(true);
332335
runnableLiveHelp.start();

ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/BookmarkManager.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ public String getLabel() {
7575

7676
@Override
7777
public boolean equals(Object obj) {
78-
if (this == obj)
78+
if (this == obj) {
7979
return true;
80-
if ((obj == null) || (getClass() != obj.getClass()))
80+
}
81+
if ((obj == null) || (getClass() != obj.getClass())) {
8182
return false;
83+
}
8284
Bookmark other = (Bookmark) obj;
8385
return Objects.equals(href, other.href) && Objects.equals(label, other.label);
8486
}
@@ -125,14 +127,16 @@ public void addBookmark(String bookmarkURL, String title) {
125127
// separate the url and title by vertical bar
126128

127129
// check for duplicates
128-
if (bookmarks.contains("," + encode(bookmarkURL) + "|")) //$NON-NLS-1$ //$NON-NLS-2$
130+
if (bookmarks.contains("," + encode(bookmarkURL) + "|")) { //$NON-NLS-1$ //$NON-NLS-2$
129131
return;
132+
}
130133
bookmarks = bookmarks
131134
+ "," + encode(bookmarkURL) + "|" + encode(title); //$NON-NLS-1$ //$NON-NLS-2$
132135
saveBookmarks(bookmarks);
133136
Bookmark bookmark = new Bookmark(title, bookmarkURL);
134-
if (this.bookmarks!=null)
137+
if (this.bookmarks!=null) {
135138
this.bookmarks.add(bookmark);
139+
}
136140
setChanged();
137141
notifyObservers(new BookmarkEvent(ADD, bookmark));
138142
}
@@ -153,22 +157,25 @@ public void removeBookmark(Bookmark bookmark) {
153157
String bookmarks = readBookmarks();
154158
String removeString = "," + encode(bookmarkURL) + "|" + encode(title); //$NON-NLS-1$ //$NON-NLS-2$
155159
int i = bookmarks.indexOf(removeString);
156-
if (i == -1)
160+
if (i == -1) {
157161
return;
162+
}
158163
bookmarks = bookmarks.substring(0, i)
159164
+ bookmarks.substring(i + removeString.length());
160165
saveBookmarks(bookmarks);
161-
if (this.bookmarks!=null)
166+
if (this.bookmarks!=null) {
162167
this.bookmarks.remove(bookmark);
168+
}
163169
setChanged();
164170
notifyObservers(new BookmarkEvent(REMOVE, bookmark));
165171
}
166172
}
167173

168174
public void removeAllBookmarks() {
169175
saveBookmarks(""); //$NON-NLS-1$
170-
if (bookmarks!=null)
176+
if (bookmarks!=null) {
171177
bookmarks.clear();
178+
}
172179
setChanged();
173180
notifyObservers(new BookmarkEvent(REMOVE_ALL, null));
174181
}

ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/HelpDisplay.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ public void displayHelpResource(String href, boolean forceExternal) {
119119
*/
120120
public void displayHelp(IContext context, IHelpResource topic,
121121
boolean forceExternal) {
122-
if (context == null || topic == null || topic.getHref() == null)
122+
if (context == null || topic == null || topic.getHref() == null) {
123123
return;
124+
}
124125
String topicURL = getTopicURL(topic.getHref());
125126
displayHelpResource(topicURL, false);
126127
/*
@@ -156,8 +157,9 @@ public void displayHelp(IContext context, IHelpResource topic,
156157
*/
157158
public void displaySearch(String searchQuery, String topic,
158159
boolean forceExternal) {
159-
if (searchQuery == null || topic == null)
160+
if (searchQuery == null || topic == null) {
160161
return;
162+
}
161163
if (getNoframesURL(topic) == null) {
162164
String url = "tab=search&" //$NON-NLS-1$
163165
+ searchQuery + "&topic=" //$NON-NLS-1$
@@ -229,10 +231,12 @@ private static String getFramesetURL() {
229231
}
230232

231233
private String getTopicURL(String topic) {
232-
if (topic == null)
234+
if (topic == null) {
233235
return null;
234-
if (topic.startsWith("../")) //$NON-NLS-1$
236+
}
237+
if (topic.startsWith("../")) { //$NON-NLS-1$
235238
topic = topic.substring(2);
239+
}
236240
/*
237241
* if (topic.startsWith("/")) { String base = "http://" +
238242
* AppServer.getHost() + ":" + AppServer.getPort(); base +=
@@ -285,8 +289,9 @@ private static void createHelpDisplay() {
285289
// We need to pick up the non-default configuration
286290
IConfigurationElement[] elements = extensions[0]
287291
.getConfigurationElements();
288-
if (elements.length == 0)
292+
if (elements.length == 0) {
289293
return;
294+
}
290295
IConfigurationElement displayElement = elements[0];
291296
// Instantiate the help display
292297
try {

ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/IndexToolApplication.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ private void preindex(String outputDir, Locale locale) throws Exception {
8282
if (locale.getCountry().length() > 0) {
8383
d = new File(d, locale.getCountry());
8484
}
85-
if (!d.exists())
85+
if (!d.exists()) {
8686
d.mkdirs();
87+
}
8788

8889
try (ZipOutputStream zout = new ZipOutputStream(new FileOutputStream(new File(d, "doc_index.zip")))) { //$NON-NLS-1$
8990
zipDirectory(indexPath, zout, null);
@@ -123,8 +124,9 @@ private static void zipDirectory(File dir, ZipOutputStream zout, String base)
123124
throws IOException {
124125
byte buffer[] = new byte[8192];
125126
String[] files = dir.list();
126-
if (files == null || files.length == 0)
127+
if (files == null || files.length == 0) {
127128
return;
129+
}
128130
for (String file : files) {
129131
String path;
130132
if (base == null) {
@@ -133,15 +135,16 @@ private static void zipDirectory(File dir, ZipOutputStream zout, String base)
133135
path = base + "/" + file; //$NON-NLS-1$
134136
}
135137
File f = new File(dir, file);
136-
if (f.isDirectory())
138+
if (f.isDirectory()) {
137139
zipDirectory(f, zout, path);
138-
else {
140+
} else {
139141
ZipEntry zentry = new ZipEntry(path);
140142
zout.putNextEntry(zentry);
141143
try (FileInputStream inputStream = new FileInputStream(f)) {
142144
int len;
143-
while ((len = inputStream.read(buffer)) != -1)
145+
while ((len = inputStream.read(buffer)) != -1) {
144146
zout.write(buffer, 0, len);
147+
}
145148
}
146149
zout.flush();
147150
zout.closeEntry();

ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/DefaultPreferenceFileHandler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ public DefaultPreferenceFileHandler() {
5858

5959

6060
// The size of any of the array elements should equal the number of remote infocenters
61-
if (this.nameEntries == null)
61+
if (this.nameEntries == null) {
6262
this.numEntries = 0;
63-
else
63+
} else {
6464
this.numEntries = this.nameEntries.length;
65+
}
6566

6667
}
6768

ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/PreferenceFileHandler.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,28 @@ public PreferenceFileHandler() {
8080

8181

8282
// The size of any of the array elements should equal the number of remote infocenters
83-
if (this.nameEntries == null)
83+
if (this.nameEntries == null) {
8484
this.numEntries = 0;
85-
else
85+
} else {
8686
this.numEntries = this.nameEntries.length;
87+
}
8788
}
8889

8990
protected String[] getValues(String preferenceEntry, String appendString) {
9091

91-
if (numHostEntries==0) //preference equals ""
92+
if (numHostEntries==0) { //preference equals ""
9293
return new String[0];//NEW
94+
}
9395

9496
// Split the string and return an array of Strings
9597
String [] currEntries;
9698
String [] updatedArray=null;
9799

98-
if(!preferenceEntry.isEmpty())
100+
if(!preferenceEntry.isEmpty()) {
99101
currEntries=preferenceEntry.split(PREFERENCE_ENTRY_DELIMITER);
100-
else
102+
} else {
101103
currEntries = new String[0];
104+
}
102105

103106
if(currEntries.length!=numHostEntries) //Current Entry not equals to Hosts
104107
{

ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteContentLocator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ public static void addContentPage(String contributorID, String InfoCenterUrl) {
3535

3636
public static String getUrlForContent(String contributorID) {
3737

38-
if (InfoCenterMap == null)
38+
if (InfoCenterMap == null) {
3939
return null;
40+
}
4041

4142
Object key = InfoCenterMap.get(contributorID);
4243
return (String)key;

ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteHelp.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ public static void removePreferenceChangeListener(IPreferenceChangeListener list
5858
*/
5959
public static void notifyPreferenceChange() {
6060
if (listeners != null) {
61-
for (IPreferenceChangeListener listener : listeners)
61+
for (IPreferenceChangeListener listener : listeners) {
6262
listener.preferenceChange(null);
63+
}
6364
}
6465
}
6566

@@ -75,10 +76,11 @@ public static URL getURL(int ic, String pathSuffix) throws MalformedURLException
7576
} catch (NumberFormatException e) {
7677
throw new MalformedURLException();
7778
}
78-
if(protocol.equalsIgnoreCase(PROTOCOL_HTTPS))
79+
if(protocol.equalsIgnoreCase(PROTOCOL_HTTPS)) {
7980
url = HttpsUtility.getHttpsURL(protocol,host,port,path);
80-
else
81+
} else {
8182
url = new URL(PROTOCOL_HTTP, host, port, path);
83+
}
8284

8385
return url;
8486
}

ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteIC.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,27 @@ public void setPort(String port) {
102102

103103
@Override
104104
public boolean equals(Object anotherObject)throws ClassCastException {
105-
if (!(anotherObject instanceof RemoteIC))
105+
if (!(anotherObject instanceof RemoteIC)) {
106106
return false;
107-
if ( !(((RemoteIC) anotherObject).getName().equals(this.getName())))
107+
}
108+
if ( !(((RemoteIC) anotherObject).getName().equals(this.getName()))) {
108109
return false;
109-
if ( !(((RemoteIC) anotherObject).getHost().equals(this.getHost())))
110+
}
111+
if ( !(((RemoteIC) anotherObject).getHost().equals(this.getHost()))) {
110112
return false;
111-
if ( !(((RemoteIC) anotherObject).getPath().equals(this.getPath())))
113+
}
114+
if ( !(((RemoteIC) anotherObject).getPath().equals(this.getPath()))) {
112115
return false;
113-
if ( !(((RemoteIC) anotherObject).getProtocol().equals(this.getProtocol())))
116+
}
117+
if ( !(((RemoteIC) anotherObject).getProtocol().equals(this.getProtocol()))) {
114118
return false;
115-
if ( !(((RemoteIC) anotherObject).getPort().equals(this.getPort())))
119+
}
120+
if ( !(((RemoteIC) anotherObject).getPort().equals(this.getPort()))) {
116121
return false;
117-
if ( !(((RemoteIC) anotherObject).isEnabled()==this.isEnabled()))
122+
}
123+
if ( !(((RemoteIC) anotherObject).isEnabled()==this.isEnabled())) {
118124
return false;
125+
}
119126

120127
//if we made it here, the the objects are the same
121128
return true;

ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteStatusData.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@ public class RemoteStatusData {
3939
public static boolean isAnyRemoteHelpUnavailable()
4040
{
4141
ArrayList<URL> sites = getRemoteSites();
42-
if (sites.isEmpty())
42+
if (sites.isEmpty()) {
4343
return false;
44+
}
4445

45-
for (int s=0;s<sites.size();s++)
46-
if (!isConnected(sites.get(s)))
46+
for (int s=0;s<sites.size();s++) {
47+
if (!isConnected(sites.get(s))) {
4748
return true;
49+
}
50+
}
4851

4952
return false;
5053
}
@@ -61,9 +64,11 @@ public static ArrayList<URL> checkSitesConnectivity(ArrayList<URL> sites)
6164
{
6265
ArrayList<URL> badSites = new ArrayList<>();
6366

64-
for (int i=0;i<sites.size();i++)
65-
if (!isConnected(sites.get(i)))
67+
for (int i=0;i<sites.size();i++) {
68+
if (!isConnected(sites.get(i))) {
6669
badSites.add(sites.get(i));
70+
}
71+
}
6772

6873
return badSites;
6974
}
@@ -97,8 +102,9 @@ public static ArrayList<URL> getRemoteSites()
97102
Platform.getPreferencesService().getBoolean(
98103
HelpBasePlugin.PLUGIN_ID, IHelpBaseConstants.P_KEY_REMOTE_HELP_ON, false,null);
99104

100-
if (!remoteHelpEnabled)
105+
if (!remoteHelpEnabled) {
101106
return sites;
107+
}
102108

103109
String hosts[] = Platform.getPreferencesService().getString(
104110
HelpBasePlugin.PLUGIN_ID, IHelpBaseConstants.P_KEY_REMOTE_HELP_HOST, "", null).split(","); //$NON-NLS-1$ //$NON-NLS-2$
@@ -174,8 +180,9 @@ public boolean isExpired()
174180
public boolean isConnected(URL url) throws CoreException
175181
{
176182
Boolean b = cache.get(url);
177-
if (b==null)
183+
if (b==null) {
178184
throw new CoreException(new Status(IStatus.ERROR,HelpBasePlugin.PLUGIN_ID,"Cache Unavailable")); //$NON-NLS-1$
185+
}
179186

180187
return b.booleanValue();
181188
}

0 commit comments

Comments
 (0)