Skip to content

Commit 93b96cb

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of ua/org.eclipse.help.webapp
1 parent cf54e17 commit 93b96cb

Some content is hidden

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

52 files changed

+522
-275
lines changed

ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/StatusProducer.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ public InputStream getInputStream(String pluginID, String href, Locale locale) {
8181

8282
if (!href.equalsIgnoreCase(MissingContentManager.REMOTE_STATUS_HREF) &&
8383
!href.equalsIgnoreCase(MissingContentManager.MISSING_TOPIC_HREF) &&
84-
!href.equalsIgnoreCase(MissingContentManager.REMOTE_STATUS_HELP_VIEW_HREF))
84+
!href.equalsIgnoreCase(MissingContentManager.REMOTE_STATUS_HELP_VIEW_HREF)) {
8585
return null;
86+
}
8687

8788
StringBuilder pageBuffer = new StringBuilder();
8889

@@ -159,8 +160,9 @@ public InputStream getInputStream(String pluginID, String href, Locale locale) {
159160
addCloseLink(locale, pageBuffer);
160161
}
161162

162-
if (href.equalsIgnoreCase(MissingContentManager.MISSING_TOPIC_HREF))
163+
if (href.equalsIgnoreCase(MissingContentManager.MISSING_TOPIC_HREF)) {
163164
pageBuffer.append(tab(3)+"<p>"+WebappResources.getString("topicUnavailable",locale)+"</p>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
165+
}
164166

165167
// Write potential causes, based on some or
166168
// all sites failing.
@@ -169,8 +171,9 @@ public InputStream getInputStream(String pluginID, String href, Locale locale) {
169171
pageBuffer.append(tab(3)+"<ul>\n"); //$NON-NLS-1$
170172
pageBuffer.append(tab(4)+"<li>"+WebappResources.getString("serversCouldBeDown",locale)+"</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
171173
pageBuffer.append(tab(4)+"<li>"+WebappResources.getString("mayNeedProxy",locale)+"</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
172-
if (allFailed)
174+
if (allFailed) {
173175
pageBuffer.append(tab(4)+"<li>"+WebappResources.getString("networkCouldBeDown",locale)+"</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
176+
}
174177
pageBuffer.append(tab(3)+"</ul>\n"); //$NON-NLS-1$
175178

176179

@@ -182,21 +185,23 @@ public InputStream getInputStream(String pluginID, String href, Locale locale) {
182185
pageBuffer.append(tab(3)+"<ul>\n"); //$NON-NLS-1$
183186
for (int r=0;r<remoteSites.size();r++)
184187
{
185-
if (!badSites.contains(remoteSites.get(r)))
188+
if (!badSites.contains(remoteSites.get(r))) {
186189
pageBuffer.append(tab(4)+"<li>"+makeAnchor(remoteSites.get(r)+INDEX,remoteSites.get(r)+INDEX,"",true)+"</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
190+
}
187191
}
188192
pageBuffer.append(tab(3)+"</ul>\n"); //$NON-NLS-1$
189-
}
190-
else
193+
} else {
191194
pageBuffer.append(tab(3)+WebappResources.getString("noRemoteSitesAvailable", locale)+"</br>\n"); //$NON-NLS-1$ //$NON-NLS-2$
195+
}
192196

193197
if (!badSites.isEmpty())
194198
{
195199
pageBuffer.append(tab(3)+"<h2>"+WebappResources.getString("sitesWithoutConnectivity", locale)+"</h2>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
196200
pageBuffer.append(tab(3)+"<ul>\n"); //$NON-NLS-1$
197201

198-
for (int b=0;b<badSites.size();b++)
202+
for (int b=0;b<badSites.size();b++) {
199203
pageBuffer.append(tab(4)+ "<li>"+badSites.get(b)+INDEX+"</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$
204+
}
200205

201206
pageBuffer.append(tab(3)+ "</ul>\n"); //$NON-NLS-1$
202207
}
@@ -362,10 +367,11 @@ private String getBeginHtmlBody(boolean addBanner)
362367
{
363368
String body = tab(1);
364369

365-
if (ProductPreferences.isRTL())
370+
if (ProductPreferences.isRTL()) {
366371
body += "<body dir=\"rtl\">"; //$NON-NLS-1$
367-
else
372+
} else {
368373
body += "<body>"; //$NON-NLS-1$
374+
}
369375
body += '\n';
370376
if (addBanner) {
371377
body += tab(2) + "<div id=\"banner\"><img src=\"PLUGINS_ROOT/org.eclipse.help.base/doc/help_banner.jpg\" alt=\"Help banner\" width=\"1600\" height=\"36\"></div>\n"; //$NON-NLS-1$
@@ -394,8 +400,9 @@ private String getActiveLink(Locale locale)
394400
private String makeAnchor(String url,String title,String style,boolean newWindow)
395401
{
396402
String target=""; //$NON-NLS-1$
397-
if (newWindow)
403+
if (newWindow) {
398404
target = "target=\"_blank\" "; //$NON-NLS-1$
405+
}
399406

400407
return "<a "+style+" "+target+"href=\""+url+"\">"+title+"</a>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
401408
}
@@ -406,8 +413,9 @@ private String makeAnchor(String url,String title,String style,boolean newWindow
406413
private static String tab(int count)
407414
{
408415
String tabs = ""; //$NON-NLS-1$
409-
for (int i=0;i<count;i++)
416+
for (int i=0;i<count;i++) {
410417
tabs+=TAB;
418+
}
411419
return tabs;
412420
}
413421

ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ public static String getString(String name, Locale locale, String[] args) {
109109
* @return ResourceBundle or null if not found
110110
*/
111111
private static ResourceBundle getBundle(Locale locale) {
112-
if (locale == null)
112+
if (locale == null) {
113113
locale = getDefaultLocale();
114+
}
114115

115116
// check cache
116117
ResourceBundle bundle = resourceBundleTable
@@ -158,12 +159,14 @@ private static ResourceBundle getResourceBundle(String key) {
158159
ResourceBundle bundle;
159160

160161
Bundle hostBundle = Platform.getBundle(FrameworkUtil.getBundle(HelpWebappPlugin.class).getSymbolicName());
161-
if (hostBundle == null)
162+
if (hostBundle == null) {
162163
return null;
164+
}
163165

164166
URL url = hostBundle.getResource("org/eclipse/help/internal/webapp/WebappResources" + key + ".properties"); //$NON-NLS-1$//$NON-NLS-2$
165-
if (url == null)
167+
if (url == null) {
166168
return null;
169+
}
167170

168171
try (InputStream in= url.openStream()) {
169172
bundle= new PropertyResourceBundle(in);
@@ -176,18 +179,20 @@ private static ResourceBundle getResourceBundle(String key) {
176179
private static Locale getDefaultLocale() {
177180
String nl = Platform.getNL();
178181
// sanity test
179-
if (nl == null)
182+
if (nl == null) {
180183
return Locale.getDefault();
184+
}
181185

182186
// break the string into tokens to get the Locale object
183187
StringTokenizer locales = new StringTokenizer(nl, "_"); //$NON-NLS-1$
184-
if (locales.countTokens() == 1)
188+
if (locales.countTokens() == 1) {
185189
return Locale.of(locales.nextToken(), ""); //$NON-NLS-1$
186-
else if (locales.countTokens() == 2)
190+
} else if (locales.countTokens() == 2) {
187191
return Locale.of(locales.nextToken(), locales.nextToken());
188-
else if (locales.countTokens() == 3)
192+
} else if (locales.countTokens() == 3) {
189193
return Locale.of(locales.nextToken(), locales.nextToken(), locales.nextToken());
190-
else
194+
} else {
191195
return Locale.getDefault();
196+
}
192197
}
193198
}

ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/ActivitiesData.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ public boolean isActivityFiltering() {
5757
* @return "hidden", "off", or "on"
5858
*/
5959
public String getButtonState() {
60-
if (!HelpBasePlugin.getActivitySupport().isUserCanToggleFiltering())
60+
if (!HelpBasePlugin.getActivitySupport().isUserCanToggleFiltering()) {
6161
return "hidden"; //$NON-NLS-1$
62-
else if (HelpBasePlugin.getActivitySupport().isFilteringEnabled())
62+
} else if (HelpBasePlugin.getActivitySupport().isFilteringEnabled()) {
6363
return "off"; //$NON-NLS-1$
64-
else
64+
} else {
6565
return "on"; //$NON-NLS-1$
66+
}
6667
}
6768
}

ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/BookmarksData.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,14 @@ public Topic[] getBookmarks() {
9797

9898
private int getOperation() {
9999
String op = request.getParameter("operation"); //$NON-NLS-1$
100-
if ("add".equals(op)) //$NON-NLS-1$
100+
if ("add".equals(op)) { //$NON-NLS-1$
101101
return ADD;
102-
else if ("remove".equals(op)) //$NON-NLS-1$
102+
} else if ("remove".equals(op)) { //$NON-NLS-1$
103103
return REMOVE;
104-
else if ("removeAll".equals(op)) //$NON-NLS-1$
104+
} else if ("removeAll".equals(op)) { //$NON-NLS-1$
105105
return REMOVE_ALL;
106-
else
106+
} else {
107107
return NONE;
108+
}
108109
}
109110
}

ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/IconFinder.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ private static String getIconAltText(String IconKey) {
6060
}
6161

6262
private static String getEntry(String IconKey) {
63-
if (IconPathMap == null)
63+
if (IconPathMap == null) {
6464
return null;
65+
}
6566
Object key = IconPathMap.get(IconKey);
6667
return (String) key;
6768
}
@@ -139,14 +140,18 @@ private static void initializeTocIcons() {
139140
String contributorID = iconElem.getContributor().getName();
140141

141142
for (String attr : attrs) {
142-
if (attr.equals(OPEN_ICON_PATH))
143+
if (attr.equals(OPEN_ICON_PATH)) {
143144
IconFinder.setIconImagePath(contributorID, iconElem.getAttribute(OPEN_ICON_PATH),iconElem.getAttribute(TOC_ICON_ID) + OPEN);
144-
if (attr.equals(CLOSED_ICON_PATH))
145+
}
146+
if (attr.equals(CLOSED_ICON_PATH)) {
145147
IconFinder.setIconImagePath(contributorID,iconElem.getAttribute(CLOSED_ICON_PATH),iconElem.getAttribute(TOC_ICON_ID)+ CLOSED);
146-
if (attr.equals(LEAF_ICON_PATH))
148+
}
149+
if (attr.equals(LEAF_ICON_PATH)) {
147150
IconFinder.setIconImagePath(contributorID, iconElem.getAttribute(LEAF_ICON_PATH),iconElem.getAttribute(TOC_ICON_ID) + LEAF);
148-
if (attr.equals(ICON_ALT_TEXT))
151+
}
152+
if (attr.equals(ICON_ALT_TEXT)) {
149153
IconFinder.setIconAltText(iconElem.getAttribute(ICON_ALT_TEXT),iconElem.getAttribute(TOC_ICON_ID) + ALT);
154+
}
150155
}
151156
}
152157
}

ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/IndexData.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,14 @@ private void generateEntry(IIndexEntry entry, int level) throws IOException {
120120
boolean singleTopic = topics.length == 1;
121121

122122
out.write("<li>"); //$NON-NLS-1$
123-
if (usePlusMinus) generatePlusImage(multipleTopics);
123+
if (usePlusMinus) {
124+
generatePlusImage(multipleTopics);
125+
}
124126
generateAnchor(singleTopic, entry, level);
125127
if (multipleTopics || subentries.length > 0) {
126-
if (multipleTopics) generateTopicList(entry);
128+
if (multipleTopics) {
129+
generateTopicList(entry);
130+
}
127131
generateSubentries(entry, level + 1);
128132
}
129133
out.write("</li>\n"); //$NON-NLS-1$

ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/LayoutData.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ public LayoutData(ServletContext context, HttpServletRequest request,
5454
qs = qs.replaceFirst("^token=[a-z0-9-]{36}", ""); //$NON-NLS-1$ //$NON-NLS-2$
5555
qs = qs.replaceFirst("&token=[a-z0-9-]{36}", ""); //$NON-NLS-1$ //$NON-NLS-2$
5656
}
57-
if (qs != null && qs.length() > 0)
57+
if (qs != null && qs.length() > 0) {
5858
query = "?" + qs; //$NON-NLS-1$
59+
}
5960
}
6061

6162
public String getQuery() {
@@ -147,8 +148,9 @@ public String getContentURL() {
147148
* Return array of length 0 if no views
148149
*/
149150
public AbstractView[] getViews() {
150-
if (views != null)
151+
if (views != null) {
151152
return views;
153+
}
152154

153155
View tocview = new View("toc", //$NON-NLS-1$
154156
"", //$NON-NLS-1$
@@ -159,14 +161,16 @@ public AbstractView[] getViews() {
159161
preferences.getImagesDirectory() + "/search_results_view.svg", 'R', false); //$NON-NLS-1$
160162
View bookmarksview = null;
161163

162-
if (preferences.isIndexView())
164+
if (preferences.isIndexView()) {
163165
indexview = new View("index", //$NON-NLS-1$
164166
"", //$NON-NLS-1$
165167
preferences.getImagesDirectory() + "/index_view.svg", 'I', false); //$NON-NLS-1$
166-
if (preferences.isBookmarksView())
168+
}
169+
if (preferences.isBookmarksView()) {
167170
bookmarksview = new View("bookmarks", //$NON-NLS-1$
168171
"", //$NON-NLS-1$
169172
preferences.getImagesDirectory() + "/bookmarks_view.svg", (char)0, false); //$NON-NLS-1$
173+
}
170174

171175
ArrayList<AbstractView> viewList = new ArrayList<>();
172176
viewList.add(tocview);
@@ -212,9 +216,11 @@ public String getVisibleView() {
212216
public AbstractView getCurrentView() {
213217
String name = request.getParameter("view"); //$NON-NLS-1$
214218
views = getViews();
215-
for (AbstractView view : views)
216-
if (view.getName().equals(name))
219+
for (AbstractView view : views) {
220+
if (view.getName().equals(name)) {
217221
return view;
222+
}
223+
}
218224
return null;
219225
}
220226

ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,9 @@ private int generateToc(ITopic topic, String sectionId, int tocGenerated, Writer
275275
if (href != null && href.length() > 0) {
276276
tocGenerated++;
277277
//If the link points to an anchor, use the anchor ID instead of using the section ID
278-
if (href.contains("#")) //$NON-NLS-1$
278+
if (href.contains("#")) { //$NON-NLS-1$
279279
hrefContent = sectionId + ". " + "<a href=\"" + getAnchor(href) + "\">" + topic.getLabel() + "</a>\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
280+
}
280281
}
281282

282283
out.write(hrefContent);
@@ -420,8 +421,9 @@ private String getContent(String href, String locale) {
420421
catch (IOException e) {
421422
}
422423
try {
423-
if (rawInput != null)
424+
if (rawInput != null) {
424425
rawInput.close();
426+
}
425427
}
426428
catch (Exception e) {}
427429
}

ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/RequestScope.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ public static void setScopeFromRequest(HttpServletRequest request, HttpServletRe
126126
// AbstractHelpScope scope = ScopeRegistry.getInstance().parseScopePhrases(phrases);
127127
for (int p=0;p<phrases.length;p++)
128128
{
129-
if (!(phrases[p].startsWith("(") && !phrases[p].startsWith("("))) //$NON-NLS-1$ //$NON-NLS-2$
129+
if (!(phrases[p].startsWith("(") && !phrases[p].startsWith("("))) { //$NON-NLS-1$ //$NON-NLS-2$
130130
phrases[p] = '('+phrases[p]+')';
131+
}
131132
scopeStr+=phrases[p];
132-
if (p<phrases.length-1)
133+
if (p<phrases.length-1) {
133134
scopeStr+=ScopeRegistry.SCOPE_AND;
135+
}
134136
}
135137
}
136138
CookieUtil.deleteObsoleteCookies(request, response);

0 commit comments

Comments
 (0)