diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/RootScopePage.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/RootScopePage.java index f7120da9c58..5ce2cf18739 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/RootScopePage.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/RootScopePage.java @@ -172,16 +172,18 @@ private void updateEnableState(boolean enabled) { boolean first = disabledStates.isEmpty(); for (int i = 0; i < children.length; i++) { Control child = children[i]; - if (child == masterButton) + if (child == masterButton) { continue; + } if (!enabled) { disabledStates.put(child, Boolean.valueOf(child.isEnabled())); child.setEnabled(false); } else { Boolean savedState = disabledStates.get(child); - if (!first) + if (!first) { child.setEnabled(savedState != null ? savedState .booleanValue() : true); + } } } } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/LaunchURL.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/LaunchURL.java index da77ad964ac..b7c1b08408e 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/LaunchURL.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/LaunchURL.java @@ -73,8 +73,9 @@ public void setInitializationData(IConfigurationElement config, if (data != null && data instanceof Hashtable) { url = ((Hashtable) data).get("url"); //$NON-NLS-1$ } - if (url == null || url.length() == 0) + if (url == null || url.length() == 0) { url = config.getAttribute("url"); //$NON-NLS-1$ + } } @Override diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/CloseHelpTrayHandler.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/CloseHelpTrayHandler.java index ee637026795..34de31f463b 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/CloseHelpTrayHandler.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/CloseHelpTrayHandler.java @@ -41,8 +41,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell = Display.getCurrent().getActiveShell(); if (shell != null && !shell.isDisposed()) { Object shellData = shell.getData(); - if (shellData instanceof TrayDialog) { - TrayDialog trayDialog = (TrayDialog)shellData; + if (shellData instanceof TrayDialog trayDialog) { if (trayDialog.getTray() instanceof HelpTray) { trayDialog.closeTray(); } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/ContextHelpDialog.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/ContextHelpDialog.java index 71c352154f3..7851842efe5 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/ContextHelpDialog.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/ContextHelpDialog.java @@ -192,8 +192,9 @@ public synchronized void close() { } if (shell != null) { shell.close(); - if (!shell.isDisposed()) + if (!shell.isDisposed()) { shell.dispose(); + } shell = null; } } catch (Throwable ex) { @@ -296,8 +297,9 @@ private Control createLink(Composite parent, IHelpResource topic) { private Control createLinksArea(Composite parent) { IHelpResource[] relatedTopics = context.getRelatedTopics(); - if (relatedTopics == null) + if (relatedTopics == null) { return null; + } // Create control Composite composite = new Composite(parent, SWT.NONE); initAccessible(composite); diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/DefaultHelpUI.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/DefaultHelpUI.java index 051233b7cb4..165c1c8965b 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/DefaultHelpUI.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/DefaultHelpUI.java @@ -267,8 +267,9 @@ private static HelpView getHelpView() { private static void setIntroStandby() { IIntroManager introMng = PlatformUI.getWorkbench().getIntroManager(); IIntroPart intro = introMng.getIntro(); - if (intro != null && !introMng.isIntroStandby(intro)) + if (intro != null && !introMng.isIntroStandby(intro)) { introMng.setIntroStandby(intro, true); + } } private void warnNoOpenPerspective(IWorkbenchWindow window) { @@ -307,8 +308,9 @@ public void displayContext(IContext context, int x, int y) { } void displayContext(IContext context, int x, int y, boolean noInfopop) { - if (context == null) + if (context == null) { return; + } boolean winfopop = Platform.getPreferencesService().getBoolean (HelpBasePlugin.PLUGIN_ID, IHelpBaseConstants.P_KEY_WINDOW_INFOPOP, false, null); boolean dinfopop = Platform.getPreferencesService().getBoolean @@ -328,12 +330,13 @@ void displayContext(IContext context, int x, int y, boolean noInfopop) { IWorkbenchPart activePart = page.getActivePart(); Control c = window.getShell().getDisplay().getFocusControl(); IContextProvider adapter = activePart.getAdapter(IContextProvider.class); - if (adapter != null) + if (adapter != null) { context = adapter .getContext(c); /* * If the context help has no description text and exactly one * topic, go straight to the topic and skip context help. */ + } Objects.requireNonNull(context, "context must not be null when displaying help content"); //$NON-NLS-1$ String contextText = context.getText(); IHelpResource[] topics = context.getRelatedTopics(); @@ -472,8 +475,9 @@ private boolean useExternalBrowser(String url) { if (!Constants.OS_WIN32.equalsIgnoreCase(Platform.getOS())) { Display display = Display.getCurrent(); if (display != null) { - if (insideModalParent(display)) + if (insideModalParent(display)) { return true; + } } } @@ -494,8 +498,9 @@ private boolean insideModalParent(Display display) { public static boolean isDisplayModal(Shell activeShell) { while (activeShell != null) { - if ((activeShell.getStyle() & (SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL | SWT.SYSTEM_MODAL)) > 0) + if ((activeShell.getStyle() & (SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL | SWT.SYSTEM_MODAL)) > 0) { return true; + } activeShell = (Shell) activeShell.getParent(); } return false; diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HelpActivitySupport.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HelpActivitySupport.java index 42c9c986a5d..bf3e2c21745 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HelpActivitySupport.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HelpActivitySupport.java @@ -62,11 +62,13 @@ public ActivityDescriptor() { private void load() { IConfigurationElement [] elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.help.base.activitySupport");//$NON-NLS-1$ - if (elements.length==1 && elements[0].getName().equals("support")) //$NON-NLS-1$ + if (elements.length==1 && elements[0].getName().equals("support")) { //$NON-NLS-1$ config = elements[0]; - else if (elements.length>0) { + } else if (elements.length>0) { IProduct product = Platform.getProduct(); - if (product==null) return; + if (product==null) { + return; + } String productId = product.getId(); for (int i=0; i i = lines.iterator(); i.hasNext();) + for (Iterator i = lines.iterator(); i.hasNext();) { charCount += i.next().length(); + } return charCount; } @Override public String getLine(int i) { - if ((i >= lines.size()) || (i < 0)) + if ((i >= lines.size()) || (i < 0)) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); + } return lines.get(i); } @Override public int getLineAtOffset(int offset) { - if (offset >= getCharCount()) + if (offset >= getCharCount()) { return getLineCount() - 1; + } int count = 0; int line = -1; while (count <= offset) { @@ -101,8 +106,9 @@ public int getLineAtOffset(int offset) { @Override public int getLineCount() { - if (lines.isEmpty()) + if (lines.isEmpty()) { return 1; + } return lines.size(); } @@ -113,11 +119,13 @@ public String getLineDelimiter() { @Override public int getOffsetAtLine(int line) { - if (lines.isEmpty()) + if (lines.isEmpty()) { return 0; + } int offset = 0; - for (int i = 0; i < line; i++) + for (int i = 0; i < line; i++) { offset += getLine(i).length(); + } return offset; } @@ -125,13 +133,15 @@ public int getOffsetAtLine(int line) { public String getTextRange(int start, int end) { int l1 = getLineAtOffset(start); int l2 = getLineAtOffset(end); - if (l1 == l2) + if (l1 == l2) { return getLine(l1).substring(start - getOffsetAtLine(l1), end - start); + } StringBuilder range = new StringBuilder(getLine(l1).substring( start - getOffsetAtLine(l1))); - for (int i = l1 + 1; i < l2; i++) + for (int i = l1 + 1; i < l2; i++) { range.append(getLine(i)); + } range.append(getLine(l2).substring(0, end - getOffsetAtLine(l2))); return range.toString(); } @@ -148,8 +158,9 @@ public void replaceTextRange(int arg0, int arg1, String arg2) { @Override public void setText(String text) { - if (text == null) + if (text == null) { text = " "; //$NON-NLS-1$ + } processLineBreaks(text); processStyles(text); } @@ -178,21 +189,24 @@ private void processLineBreaks(String text) { lines.add(new String(textChars, start, i - start)); start = i + 1; // if we reached the end, stop - if (start >= textChars.length) + if (start >= textChars.length) { break; + } // see if the next character is an LF ch = textChars[start]; if (ch == SWT.LF) { start++; i++; - if (start >= textChars.length) + if (start >= textChars.length) { break; + } } } else if (ch == SWT.LF) { lines.add(new String(textChars, start, i - start)); start = i + 1; - if (start >= textChars.length) + if (start >= textChars.length) { break; + } } else if (i == textChars.length - 1) { lines.add(new String(textChars, start, i - start + 1)); } @@ -203,8 +217,9 @@ private void processLineBreaks(String text) { String line = lines.get(i); while (line.length() > 0) { int linebreak = getLineBreak(line, gc); - if (linebreak == 0 || linebreak == line.length()) + if (linebreak == 0 || linebreak == line.length()) { break; + } String newline = line.substring(0, linebreak); lines.remove(i); lines.add(i, newline); @@ -257,15 +272,17 @@ private void processStyles(String text) { style.fontStyle = SWT.BOLD; // the index of the starting style in styled text int start = text.indexOf(BOLD_TAG, offset); - if (start == -1) + if (start == -1) { break; + } String prefix = getUnstyledText(text.substring(0, start)); style.start = prefix.length(); // the index of the ending style in styled text offset = start + 1; int end = text.indexOf(BOLD_CLOSE_TAG, offset); - if (end == -1) + if (end == -1) { break; + } prefix = getUnstyledText(text.substring(0, end)); style.length = prefix.length() - style.start; lineStyleRanges.add(style); diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowser.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowser.java index 9bf2bc93cd9..0cac5837220 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowser.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowser.java @@ -80,10 +80,11 @@ public class EmbeddedBrowser { */ public EmbeddedBrowser() { int style = SWT.SHELL_TRIM; - if (ProductPreferences.isRTL()) + if (ProductPreferences.isRTL()) { style |= SWT.RIGHT_TO_LEFT; - else + } else { style |= SWT.LEFT_TO_RIGHT; + } shell = new Shell(style); initializeShell(shell); shell.addControlListener(new ControlListener() { @@ -140,8 +141,9 @@ public void controlResized(ControlEvent e) { y = shell.getLocation().y; } setSafeBounds(shell, x, y, w, h); - if (Platform.getPreferencesService().getBoolean(HelpUIPlugin.PLUGIN_ID, BROWSER_MAXIMIZED, false, null)) + if (Platform.getPreferencesService().getBoolean(HelpUIPlugin.PLUGIN_ID, BROWSER_MAXIMIZED, false, null)) { shell.setMaximized(true); + } shell.addControlListener(new ControlListener() { @Override @@ -195,13 +197,15 @@ public void changing(LocationEvent e) { public EmbeddedBrowser(WindowEvent event, Shell parent) { if (parent == null){ int style = SWT.SHELL_TRIM; - if (ProductPreferences.isRTL()) + if (ProductPreferences.isRTL()) { style |= SWT.RIGHT_TO_LEFT; - else + } else { style |= SWT.LEFT_TO_RIGHT; + } shell = new Shell(style); - } else + } else { shell = new Shell(parent, SWT.PRIMARY_MODAL | SWT.DIALOG_TRIM | SWT.RESIZE); + } initializeShell(shell); Browser browser = new Browser(shell, SWT.NONE); browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); @@ -239,8 +243,9 @@ private void addResetNeedModalLocationListener(Browser browser) { private static void initializeShell(Shell s) { s.setText(initialTitle); final Image[] shellImages = createImages(); - if (shellImages != null) + if (shellImages != null) { s.setImages(shellImages); + } GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; @@ -279,8 +284,9 @@ public void hide(WindowEvent event) { public void show(WindowEvent event) { Browser browser = (Browser) event.widget; Shell shell = browser.getShell(); - if (event.location != null) + if (event.location != null) { shell.setLocation(event.location); + } if (event.size != null) { Point size = event.size; shell.setSize(shell.computeSize(size.x, size.y)); @@ -335,8 +341,9 @@ private void initializeStatusBar(Browser browser) { @Override public void changing(LocationEvent event) { - if (event.location == null || event.location.startsWith("javascript:")) //$NON-NLS-1$ + if (event.location == null || event.location.startsWith("javascript:")) { //$NON-NLS-1$ return; + } changingLocationHolder.set(event.location); } @@ -352,8 +359,9 @@ public void changed(LocationEvent event) { } }); browser.addProgressListener(ProgressListener.changedAdapter(event -> { - if (event.total <= 0 || changingLocationHolder.get() == null) + if (event.total <= 0 || changingLocationHolder.get() == null) { return; + } statusBarProgress.setMaximum(event.total); statusBarProgress.setSelection(Math.min(event.current, event.total)); if (event.current < event.total) { @@ -489,8 +497,9 @@ private static String[] getProductImageURLs() { * Closes the browser. */ public void close() { - if (!shell.isDisposed()) + if (!shell.isDisposed()) { shell.dispose(); + } } private static void setSafeBounds(Shell s, int x, int y, int width, int height) { diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowserFactory.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowserFactory.java index ef25e980eb8..2ef9e41966d 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowserFactory.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowserFactory.java @@ -88,8 +88,9 @@ private boolean test() { } catch (Exception e) { // Browser not implemented } - if (sh != null && !sh.isDisposed()) + if (sh != null && !sh.isDisposed()) { sh.dispose(); + } } return available; } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/handlers/OpenBundleResourceHandler.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/handlers/OpenBundleResourceHandler.java index 9166bf7f084..9650d0fa1c8 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/handlers/OpenBundleResourceHandler.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/handlers/OpenBundleResourceHandler.java @@ -44,8 +44,9 @@ public Object execute(ExecutionEvent event) throws ExecutionException { url = null; } else { try { - if(pluginPath.startsWith("/")) //$NON-NLS-1$ + if(pluginPath.startsWith("/")) { //$NON-NLS-1$ pluginPath = pluginPath.substring(1); + } url = new URL(Platform.getInstanceLocation().getURL().toString()+pluginId+"/"+pluginPath); //$NON-NLS-1$ workspaceFile = new File(url.getFile()); if(!workspaceFile.exists()) diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/HelpPreferencePage.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/HelpPreferencePage.java index 090126b251a..47ccdabcb7a 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/HelpPreferencePage.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/HelpPreferencePage.java @@ -211,8 +211,9 @@ private IPreferenceNode getPreferenceNode(String pageId) { .getElements(PreferenceManager.PRE_ORDER).iterator(); while (iterator.hasNext()) { IPreferenceNode next = iterator.next(); - if (next.getId().equals(pageId)) + if (next.getId().equals(pageId)) { return next; + } } return null; } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/IC.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/IC.java index 1b8618a467b..fd8be22f219 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/IC.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/IC.java @@ -43,8 +43,9 @@ public IC(String name,String href,boolean enabled) throws MalformedURLException public void setHref(String href) throws MalformedURLException { - if (href.startsWith(":")) //$NON-NLS-1$ + if (href.startsWith(":")) { //$NON-NLS-1$ href = "http"+href; //$NON-NLS-1$ + } setHref(new URL(href)); } @@ -57,20 +58,22 @@ public void setHref(URL url) this.port = url.getPort(); if (port==-1) { - if (protocol.equals("http")) //$NON-NLS-1$ + if (protocol.equals("http")) { //$NON-NLS-1$ port = 80; - else if (protocol.equals("https")) //$NON-NLS-1$ + } else if (protocol.equals("https")) { //$NON-NLS-1$ port = 443; + } } } public String getHref() { String portString = ":"+port; //$NON-NLS-1$ - if (port==80 && protocol.equals("http")) //$NON-NLS-1$ + if (port==80 && protocol.equals("http")) { //$NON-NLS-1$ portString = ""; //$NON-NLS-1$ - else if (port==443 && protocol.equals("https")) //$NON-NLS-1$ + } else if (port==443 && protocol.equals("https")) { //$NON-NLS-1$ portString = ""; //$NON-NLS-1$ + } return protocol+"://"+host+portString+path; //$NON-NLS-1$ } @@ -139,10 +142,9 @@ public String toString() @Override public boolean equals(Object o) { - if (!(o instanceof IC)) + if (!(o instanceof IC candidate)) { return false; - - IC candidate = (IC)o; + } if (getName().equals(candidate.getName()) && getPath().equals(candidate.getPath()) @@ -153,11 +155,13 @@ && getProtocol().equals(candidate.getProtocol())) InetAddress host1 = InetAddress.getByName(getHost()); InetAddress host2 = InetAddress.getByName(candidate.getHost()); - if (host1.getHostAddress().equals(host2.getHostAddress())) + if (host1.getHostAddress().equals(host2.getHostAddress())) { return true; + } } catch (UnknownHostException e) { - if (getHost().equals(candidate.getHost())) + if (getHost().equals(candidate.getHost())) { return true; + } } } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/ICButtons.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/ICButtons.java index 90796c2561b..cfd9c2a42d3 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/ICButtons.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/ICButtons.java @@ -93,29 +93,32 @@ public Button createPushButton(Composite parent, String buttonText) { public void widgetSelected(SelectionEvent e) { if (e.getSource() instanceof Button) { - if (e.getSource()==addIC) + if (e.getSource()==addIC) { addIC(); - else if (e.getSource()==editIC) + } else if (e.getSource()==editIC) { editIC(); - else if (e.getSource()==removeIC) + } else if (e.getSource()==removeIC) { removeIC(); - else if (e.getSource()==testIC) + } else if (e.getSource()==testIC) { testIC(); - else if (e.getSource()==enableIC) + } else if (e.getSource()==enableIC) { enableIC(); - else if (e.getSource()==moveUp) + } else if (e.getSource()==moveUp) { move(-1); - else if (e.getSource()==moveDown) + } else if (e.getSource()==moveDown) { move(1); + } } - else if (e.getSource() instanceof Table) + else if (e.getSource() instanceof Table) { updateButtonStates(); + } } @Override public void widgetDefaultSelected(SelectionEvent e) { - if (e.getSource() instanceof Table) + if (e.getSource() instanceof Table) { editIC(); + } } public void addIC() @@ -131,8 +134,9 @@ public void editIC() { IStructuredSelection selection = (IStructuredSelection)page.getTable().getSelection(); IC ic = (IC)selection.getFirstElement(); - if (ic==null) + if (ic==null) { return; + } ICDialog dialog = new ICDialog(page.getShell(),ic); @@ -161,8 +165,9 @@ public void removeIC() if (shouldRemove) { - for (int i=0;i getICs() { public void setICs(List ics) { List oldICs = getICs(); - for (int o=0;o ics = ICPreferences.getICs(); - for (int i=0;i 0) + if (i > 0) { buf.append(InfoCenterSearchScopeFactory.TOC_SEPARATOR); + } buf.append(elements[i].getHref()); } store.setValue(getKey(InfoCenterSearchScopeFactory.P_TOCS), buf.toString()); @@ -139,8 +142,9 @@ protected int createScopeContents(Composite parent) { @Override public void widgetSelected(SelectionEvent e) { - if (searchAll.getSelection()) + if (searchAll.getSelection()) { tree.getTree().setEnabled(false); + } } }); @@ -155,8 +159,9 @@ public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) { if (searchSelected.getSelection()) { tree.getTree().setEnabled(true); - if (tocStale) + if (tocStale) { updateTocs(); + } } } }); @@ -199,9 +204,10 @@ public void treeCollapsed(TreeExpansionEvent event) { @Override public void treeExpanded(TreeExpansionEvent event) { final Object element = event.getElement(); - if (!tree.getGrayed(element)) + if (!tree.getGrayed(element)) { BusyIndicator.showWhile(getShell().getDisplay(), () -> setSubtreeChecked(element, tree.getChecked(element), false)); + } } }); @@ -314,8 +320,9 @@ private void initializeControls() { if (url.length() == 0) { url = (String) getEngineDescriptor().getParameters().get( InfoCenterSearchScopeFactory.P_URL); - if (url == null) + if (url == null) { url = ""; //$NON-NLS-1$ + } } urlText.setText(url); //busyLoadTocs(url); @@ -335,8 +342,9 @@ private void initializeControls() { tree.setCheckedElements(elements); for (int i = 0; i < elements.length; i++) { Object element = elements[i]; - if (isExpandable(element)) + if (isExpandable(element)) { setSubtreeChecked(element, true, true); + } updateParentState(element, true); } }); @@ -352,8 +360,9 @@ private void updateTocs() { tree.setCheckedElements(elements); for (int i = 0; i < elements.length; i++) { Object element = elements[i]; - if (isExpandable(element)) + if (isExpandable(element)) { setSubtreeChecked(element, true, true); + } updateParentState(element, true); } }); @@ -374,12 +383,14 @@ boolean isExpandable(Object element) { } void updateParentState(Object child, boolean baseChildState) { - if (child == null) + if (child == null) { return; + } Object parent = treeContentProvider.getParent(child); - if (parent == null) + if (parent == null) { return; + } boolean allSameState = true; Object[] children = null; @@ -408,10 +419,12 @@ void setSubtreeChecked(Object parent, boolean state, if (state) { tree.setChecked(element, true); tree.setGrayed(element, false); - } else + } else { tree.setGrayChecked(element, false); - if (isExpandable(element)) + } + if (isExpandable(element)) { setSubtreeChecked(element, state, checkExpandedState); + } } } @@ -420,10 +433,11 @@ private void findCheckedElements(java.util.List checkedResources, Object parent) { Object[] children = treeContentProvider.getChildren(parent); for (int i = 0; i < children.length; i++) { - if (tree.getGrayed(children[i])) + if (tree.getGrayed(children[i])) { findCheckedElements(checkedResources, children[i]); - else if (tree.getChecked(children[i])) + } else if (tree.getChecked(children[i])) { checkedResources.add(children[i]); + } } } @@ -432,9 +446,10 @@ void handleCheckStateChange(final CheckStateChangedEvent event) { Object element = event.getElement(); boolean state = event.getChecked(); tree.setGrayed(element, false); - if (isExpandable(element)) + if (isExpandable(element)) { setSubtreeChecked(element, state, state); // only check subtree if state is set to true + } updateParentState(element, state); // validateInput(); @@ -450,9 +465,10 @@ public void updateWorkingSet() { @Override public boolean performOk() { IPreferenceStore store = getPreferenceStore(); - if (getEngineDescriptor().isUserDefined()) + if (getEngineDescriptor().isUserDefined()) { store.setValue(getKey(InfoCenterSearchScopeFactory.P_URL), urlText .getText()); + } updateWorkingSet(); workingSet.store(store); store.setValue(getKey(InfoCenterSearchScopeFactory.P_SEARCH_SELECTED), diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/InfoCenterSearchScopeFactory.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/InfoCenterSearchScopeFactory.java index 7b0e93b8ec1..6c1b5bacb27 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/InfoCenterSearchScopeFactory.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/InfoCenterSearchScopeFactory.java @@ -47,8 +47,9 @@ public ISearchScope createSearchScope(IPreferenceStore store, String engineId, String toc = stok.nextToken(); list.add(toc); } - if (list.size()>0) + if (list.size()>0) { tocs = list.toArray(new String[list.size()]); + } } } return new InfoCenter.Scope(url, searchSelected, tocs); @@ -58,7 +59,9 @@ private String getProperty(String key, IPreferenceStore store, String engineId, Dictionary parameters) { // try the store first String value = store.getString(engineId+"."+key); //$NON-NLS-1$ - if (value!=null && value.length()>0) return value; + if (value!=null && value.length()>0) { + return value; + } // try the parameters return (String) parameters.get(key); } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/LocalHelpPage.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/LocalHelpPage.java index 9cccedaa56d..5d2eb26f981 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/LocalHelpPage.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/LocalHelpPage.java @@ -71,9 +71,10 @@ public class LocalHelpPage extends RootScopePage { @Override public void init(IEngineDescriptor ed, String scopeSetName) { super.init(ed, scopeSetName); - if (scopeSetName != null) + if (scopeSetName != null) { workingSet = BaseHelpSystem.getWorkingSetManager().getWorkingSet( scopeSetName); + } } /** @@ -121,10 +122,11 @@ public void widgetSelected(SelectionEvent e) { } }); - if (workingSet == null) + if (workingSet == null) { searchAll.setSelection(true); - else + } else { searchSelected.setSelection(true); + } Label contentLabel = new Label(parent, SWT.WRAP); contentLabel.setFont(font); @@ -189,10 +191,11 @@ public void treeCollapsed(TreeExpansionEvent event) { @Override public void treeExpanded(TreeExpansionEvent event) { final Object element = event.getElement(); - if (!contentTree.getGrayed(element)) + if (!contentTree.getGrayed(element)) { BusyIndicator.showWhile(getShell().getDisplay(), () -> setSubtreeChecked(element, contentTree.getChecked(element), false, contentTree, contentTreeContentProvider)); + } } }); contentTree.getTree().setEnabled(workingSet != null); @@ -238,10 +241,11 @@ public void treeCollapsed(TreeExpansionEvent event) { @Override public void treeExpanded(TreeExpansionEvent event) { final Object element = event.getElement(); - if (!criteriaTree.getGrayed(element)) + if (!criteriaTree.getGrayed(element)) { BusyIndicator.showWhile(getShell().getDisplay(), () -> setSubtreeChecked(element, criteriaTree.getChecked(element), false, criteriaTree, criteriaTreeContentProvider)); + } } }); criteriaTree.getTree().setEnabled(workingSet != null); @@ -249,8 +253,9 @@ public void treeExpanded(TreeExpansionEvent event) { private void initializeCheckedState() { - if (workingSet == null) + if (workingSet == null) { return; + } BusyIndicator.showWhile(getShell().getDisplay(), () -> { initializeContentTree(); @@ -266,12 +271,14 @@ boolean isExpandable(Object element, ITreeContentProvider contentProvider) { void updateParentState(Object child, boolean baseChildState, CheckboxTreeViewer tree, ITreeContentProvider contentProvider) { - if (child == null) + if (child == null) { return; + } Object parent = contentProvider.getParent(child); - if (parent == null) + if (parent == null) { return; + } boolean allSameState = true; Object[] children = null; @@ -301,10 +308,12 @@ void setSubtreeChecked(Object parent, boolean state, if (state) { tree.setChecked(element, true); tree.setGrayed(element, false); - } else + } else { tree.setGrayChecked(element, false); - if (isExpandable(element, contentProvider)) + } + if (isExpandable(element, contentProvider)) { setSubtreeChecked(element, state, checkExpandedState, tree, contentProvider); + } } } @@ -313,10 +322,11 @@ private void findCheckedElements(java.util.List checkedResources, Object parent, CheckboxTreeViewer tree, ITreeContentProvider contentProvider) { Object[] children = contentProvider.getChildren(parent); for (int i = 0; i < children.length; i++) { - if (tree.getGrayed(children[i])) + if (tree.getGrayed(children[i])) { findCheckedElements(checkedResources, children[i], tree, contentProvider); - else if (tree.getChecked(children[i])) + } else if (tree.getChecked(children[i])) { checkedResources.add(children[i]); + } } } @@ -348,9 +358,10 @@ void handleCheckStateChange(final CheckStateChangedEvent event, Object element = event.getElement(); boolean state = event.getChecked(); tree.setGrayed(element, false); - if (isExpandable(element, contentProvider)) + if (isExpandable(element, contentProvider)) { setSubtreeChecked(element, state, state, tree, contentProvider); // only check subtree if state is set to true + } updateParentState(element, state, tree, contentProvider); // validateInput(); @@ -383,12 +394,13 @@ public WorkingSet getWorkingSet() { @Override public boolean performOk() { - if (searchSelected.getSelection()) + if (searchSelected.getSelection()) { BaseHelpSystem.getWorkingSetManager() .addWorkingSet(getWorkingSet()); - else + } else { BaseHelpSystem.getWorkingSetManager().removeWorkingSet( getWorkingSet()); + } getPreferenceStore().setValue( getKey(LocalSearchScopeFactory.P_WORKING_SET), @@ -408,8 +420,9 @@ protected void initializeContentTree() { contentTree.setCheckedElements(elements); for (int i = 0; i < elements.length; i++) { Object element = elements[i]; - if (isExpandable(element, contentTreeContentProvider)) + if (isExpandable(element, contentTreeContentProvider)) { setSubtreeChecked(element, true, true, contentTree, contentTreeContentProvider); + } updateParentState(element, true, contentTree, contentTreeContentProvider); } } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/LocalSearchScopeFactory.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/LocalSearchScopeFactory.java index 9cf6b996108..1db228df2d7 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/LocalSearchScopeFactory.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/LocalSearchScopeFactory.java @@ -34,8 +34,9 @@ public ISearchScope createSearchScope(IPreferenceStore store, String engineId, Dictionary parameters) { String name = store.getString(engineId+"."+P_WORKING_SET); //$NON-NLS-1$ WorkingSet workingSet = null; - if (name != null) + if (name != null) { workingSet = BaseHelpSystem.getWorkingSetManager().getWorkingSet(name); + } boolean capabilityFiltering = store.getBoolean(engineId+"."+P_CAPABILITY_FILTERING); //$NON-NLS-1$ return new LocalHelpScope(workingSet, capabilityFiltering); } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/WebSearchPage.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/WebSearchPage.java index 6261eabfafa..8745a9805c1 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/WebSearchPage.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/WebSearchPage.java @@ -68,10 +68,11 @@ protected void initializeDefaults(IPreferenceStore store) { super.initializeDefaults(store); String template = (String) getEngineDescriptor().getParameters().get( WebSearchScopeFactory.P_URL); - if (template != null) + if (template != null) { store .setDefault(getStoreKey(WebSearchScopeFactory.P_URL), template); + } } @Override diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/WebSearchScopeFactory.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/WebSearchScopeFactory.java index 863e1db5d9d..21ba0b66f05 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/WebSearchScopeFactory.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/WebSearchScopeFactory.java @@ -37,7 +37,9 @@ private String getProperty(IPreferenceStore store, String engineId, Dictionary parameters) { // try the store first String value = store.getString(engineId+"."+P_URL); //$NON-NLS-1$ - if (value!=null && value.length()>0) return value; + if (value!=null && value.length()>0) { + return value; + } // try the parameters return (String)parameters.get(P_URL); } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/AllTopicsPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/AllTopicsPart.java index d38279e5ca9..5b45f7a002a 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/AllTopicsPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/AllTopicsPart.java @@ -48,12 +48,15 @@ class TopicsProvider implements ITreeContentProvider { @Override public Object[] getChildren(Object parentElement) { - if (parentElement == AllTopicsPart.this) + if (parentElement == AllTopicsPart.this) { return HelpSystem.getTocs(); - if (parentElement instanceof IToc) + } + if (parentElement instanceof IToc) { return ((IToc) parentElement).getTopics(); - if (parentElement instanceof ITopic) + } + if (parentElement instanceof ITopic) { return ((ITopic) parentElement).getSubtopics(); + } return new Object[0]; } @@ -91,8 +94,9 @@ class TopicsLabelProvider extends LabelProvider { @Override public String getText(Object obj) { - if (obj instanceof IHelpResource) + if (obj instanceof IHelpResource) { return ((IHelpResource) obj).getLabel(); + } return super.getText(obj); } @@ -100,16 +104,14 @@ public String getText(Object obj) { public Image getImage(Object obj) { boolean expanded = treeViewer.getExpandedState(obj); boolean expandable = treeViewer.isExpandable(obj); - if (obj instanceof Toc){ - Toc toc = (Toc) obj; + if (obj instanceof Toc toc){ Image icon = HelpUIResources.getImageFromId(toc.getIcon(), expanded, !expandable); if (icon != null) { return icon; } } - if (obj instanceof Topic) { - Topic topic = (Topic) obj; + if (obj instanceof Topic topic) { Image icon = HelpUIResources.getImageFromId(topic.getIcon(), expanded, !expandable); if (icon != null) { return icon; @@ -121,11 +123,11 @@ public Image getImage(Object obj) { : IHelpUIConstants.IMAGE_TOC_CLOSED; return HelpUIResources.getImage(key); } - if (obj instanceof ITopic) { + if (obj instanceof ITopic topic) { if (expandable) { - ITopic topic = (ITopic) obj; - if (topic.getHref() != null) + if (topic.getHref() != null) { return containerWithTopicImage; + } } String key = expandable ? IHelpUIConstants.IMAGE_CONTAINER : IHelpUIConstants.IMAGE_FILE_F1TOPIC; @@ -161,8 +163,9 @@ private boolean isNotEmpty(ITopic topic) { private boolean isNotEmpty(ITopic[] topics) { for (ITopic topic : topics) { - if (isNotEmpty(topic)) + if (isNotEmpty(topic)) { return true; + } } return false; } @@ -195,8 +198,9 @@ public void treeExpanded(TreeExpansionEvent event) { @Override public void init(ReusableHelpPart parent, String id, IMemento memento) { super.init(parent, id, memento); - if (parent.isFilteredByRoles()) + if (parent.isFilteredByRoles()) { treeViewer.addFilter(parent.getRoleFilter()); + } treeViewer.addFilter(parent.getUAFilter()); treeViewer.addFilter(new EmptyContainerFilter()); } @@ -218,18 +222,20 @@ public void dispose() { @Override protected void doOpen(Object obj) { - if (!(obj instanceof IHelpResource)) + if (!(obj instanceof IHelpResource res)) { return; - IHelpResource res = (IHelpResource) obj; + } if (res instanceof IToc || (res instanceof ITopic && ((ITopic) obj).getSubtopics().length > 0 && res - .getHref() == null)) + .getHref() == null)) { treeViewer.setExpandedState(obj, !treeViewer.getExpandedState(res)); - if (res instanceof IToc) + } + if (res instanceof IToc) { postUpdate(res); - else if (res.getHref() != null) + } else if (res.getHref() != null) { parent.showURL(res.getHref()); + } } @Override @@ -261,10 +267,11 @@ protected boolean canAddBookmarks() { @Override public void toggleRoleFilter() { - if (parent.isFilteredByRoles()) + if (parent.isFilteredByRoles()) { treeViewer.addFilter(parent.getRoleFilter()); - else + } else { treeViewer.removeFilter(parent.getRoleFilter()); + } } @Override diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BookmarksPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BookmarksPart.java index b2070686221..921ec733c14 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BookmarksPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BookmarksPart.java @@ -47,10 +47,12 @@ class BookmarksProvider implements ITreeContentProvider { @Override public Object[] getChildren(Object parentElement) { - if (parentElement == BookmarksPart.this) + if (parentElement == BookmarksPart.this) { return new Object[] { BaseHelpSystem.getBookmarkManager() }; - if (parentElement instanceof BookmarkManager) + } + if (parentElement instanceof BookmarkManager) { return ((BookmarkManager) parentElement).getBookmarks(); + } return new Object[0]; } @@ -82,21 +84,25 @@ class BookmarksLabelProvider extends LabelProvider { @Override public String getText(Object obj) { - if (obj instanceof BookmarkManager) + if (obj instanceof BookmarkManager) { return Messages.BookmarksPart_savedTopics; - if (obj instanceof IHelpResource) + } + if (obj instanceof IHelpResource) { return ((IHelpResource) obj).getLabel(); + } return super.getText(obj); } @Override public Image getImage(Object obj) { - if (obj instanceof BookmarkManager) + if (obj instanceof BookmarkManager) { return HelpUIResources .getImage(IHelpUIConstants.IMAGE_BOOKMARKS); - if (obj instanceof IHelpResource) + } + if (obj instanceof IHelpResource) { return HelpUIResources .getImage(IHelpUIConstants.IMAGE_BOOKMARK); + } return super.getImage(obj); } } @@ -123,8 +129,7 @@ protected void configureTreeViewer() { @Override public void run() { Object obj = treeViewer.getStructuredSelection().getFirstElement(); - if (obj instanceof BookmarkManager.Bookmark) { - BookmarkManager.Bookmark b = (BookmarkManager.Bookmark)obj; + if (obj instanceof BookmarkManager.Bookmark b) { BaseHelpSystem.getBookmarkManager().removeBookmark(b); } } @@ -149,8 +154,9 @@ public boolean fillContextMenu(IMenuManager manager) { canDeleteAll = count>0; if (canDelete(selection)) { - if (value) + if (value) { manager.add(new Separator()); + } manager.add(deleteAction); value=true; } @@ -167,8 +173,9 @@ public void run() { manager.add(action); value=true; } - if (value) + if (value) { manager.add(new Separator()); + } return value; } @@ -181,10 +188,10 @@ private boolean canDelete(IStructuredSelection ssel) { protected void doOpen(Object obj) { if (obj instanceof BookmarkManager) { treeViewer.setExpandedState(obj, !treeViewer.getExpandedState(obj)); - } else if (obj instanceof IHelpResource) { - IHelpResource res = (IHelpResource) obj; - if (res.getHref() != null) + } else if (obj instanceof IHelpResource res) { + if (res.getHref() != null) { parent.showURL(res.getHref()); + } } } @@ -212,8 +219,9 @@ private void asyncUpdate(Observable o, Object arg) { @Override public IAction getGlobalAction(String id) { - if (id.equals(ActionFactory.DELETE.getId())) + if (id.equals(ActionFactory.DELETE.getId())) { return deleteAction; + } return super.getGlobalAction(id); } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BrowserPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BrowserPart.java index ebaeb934c5b..f8da1106fe4 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BrowserPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BrowserPart.java @@ -102,8 +102,9 @@ public BrowserPart(final Composite parent, FormToolkit toolkit, @Override public void changing(LocationEvent event) { - if (redirectLink(event.location)) + if (redirectLink(event.location)) { event.doit = false; + } if (!event.doit && event.location != null && event.location.startsWith("https://")) { //$NON-NLS-1$ try { @@ -129,8 +130,9 @@ public void changed(LocationEvent event) { @Override public void changed(ProgressEvent e) { - if (e.current == e.total) + if (e.current == e.total) { return; + } if (lastProgress == -1) { lastProgress = 0; @@ -145,8 +147,9 @@ public void changed(ProgressEvent e) { monitor = null; return; } - if (monitor != null) + if (monitor != null) { monitor.worked(e.current - lastProgress); + } lastProgress = e.current; } @@ -169,13 +172,16 @@ public void completed(ProgressEvent e) { } }); browser.addStatusTextListener(event -> { - if (processQuery(event.text)) + if (processQuery(event.text)) { return; + } IStatusLineManager statusLine = BrowserPart.this.parent.getStatusLineManager(); - if (statusLine != null) + if (statusLine != null) { statusLine.setMessage(event.text); - if (event.text.contains("://")) //$NON-NLS-1$ + } + if (event.text.contains("://")) { //$NON-NLS-1$ statusURL = event.text; + } }); browser.addOpenWindowListener(event -> { if (statusURL != null) { @@ -255,7 +261,9 @@ public void run() { IScopeContext instanceScope = InstanceScope.INSTANCE; IEclipsePreferences prefs = instanceScope.getNode(HelpBasePlugin.PLUGIN_ID); prefs.putBoolean(HIGHLIGHT_ON, highlightAction.isChecked()); - if (browser.getUrl().contains("resultof")) browser.execute("setHighlight(" +highlightAction.isChecked()+");"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + if (browser.getUrl().contains("resultof")) { //$NON-NLS-1$ + browser.execute("setHighlight(" +highlightAction.isChecked()+");"); //$NON-NLS-1$ //$NON-NLS-2$ + } } }; highlightAction.setChecked(highlight); @@ -328,8 +336,9 @@ public void init(ReusableHelpPart parent, String id, IMemento memento) { this.id = id; if (memento != null) { String href = memento.getString("BrowserPart.url"); //$NON-NLS-1$ - if (href != null) + if (href != null) { showURL(BaseHelpSystem.resolve(href, "/help/ntopic").toString()); //$NON-NLS-1$ + } } } @@ -352,8 +361,9 @@ public void setVisible(boolean visible) { @Override public void setFocus() { - if (browser != null) + if (browser != null) { browser.setFocus(); + } } public void showURL(String url) { @@ -424,8 +434,9 @@ private void processLiveAction(String url) { query = u.getQuery(); } catch (MalformedURLException mue) { } - if (query == null) + if (query == null) { return; + } StringTokenizer st = new StringTokenizer(query, "=&"); //$NON-NLS-1$ if (st.countTokens() < 6) { return; @@ -436,8 +447,9 @@ private void processLiveAction(String url) { String className = URLCoder.decode(st.nextToken()); st.nextToken(); String arg = URLCoder.decode(st.nextToken()); - if (pluginId == null || className == null || arg == null) + if (pluginId == null || className == null || arg == null) { return; + } BaseHelpSystem.runLiveHelp(pluginId, className, arg); } @@ -453,8 +465,9 @@ public boolean hasFocusControl(Control control) { @Override public IAction getGlobalAction(String id) { - if (id.equals(ActionFactory.PRINT.getId())) + if (id.equals(ActionFactory.PRINT.getId())) { return printAction; + } return null; } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/Chevron.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/Chevron.java index be7e7840f2d..88b13132a03 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/Chevron.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/Chevron.java @@ -43,18 +43,20 @@ public Chevron(Composite parent, int style) { @Override protected void paintHyperlink(GC gc) { - if (hover && getHoverDecorationColor() != null) + if (hover && getHoverDecorationColor() != null) { gc.setForeground(getHoverDecorationColor()); - else if (getDecorationColor() != null) + } else if (getDecorationColor() != null) { gc.setForeground(getDecorationColor()); + } int[][] data; Rectangle carea = getClientArea(); int x = (carea.width - innerWidth) /2; int y = (carea.height - innerHeight) / 2; - if (isExpanded()) + if (isExpanded()) { data = translate(onLines, x, y); - else + } else { data = translate(offLines, x, y); + } for (int i=0; i 0) { title = NLS.bind(Messages.ContextHelpPart_aboutP, searchTerms[0]); } } - if (title==null) + if (title==null) { title = Messages.ContextHelpPart_about; + } getSection().setText(EscapeUtils.escapeForLabel(title)); } @@ -412,11 +416,12 @@ private void updateDynamicHelp() { private String buildSearchExpression(String[] searchTerms) { StringBuilder buff = new StringBuilder(); - for (int i = 0; i < searchTerms.length; i++) { - if (buff.length() > 0) + for (String searchTerm : searchTerms) { + if (buff.length() > 0) { buff.append(" OR "); //$NON-NLS-1$ + } buff.append('"'); - buff.append(searchTerms[i]); + buff.append(searchTerm); buff.append('"'); } return buff.length() > 0 ? buff.toString().trim() : null; @@ -427,7 +432,9 @@ private static class SearchTerms { private final List terms = new ArrayList<>(); private final Set termSet = new HashSet<>(); public void add(String term) { - if (term == null ) return; + if (term == null ) { + return; + } String lowerCaseTerm = term.toLowerCase(); // Do not allow duplicates if (!termSet.contains(lowerCaseTerm)) { @@ -447,17 +454,15 @@ public String[] toArray() { private String[] computeSearchTerms(Control c) { // Search the control and all ancestors until we find a composite // which we can get a search term from - Composite container = c instanceof Composite ? (Composite)c : c.getParent(); + Composite container = c instanceof Composite composite ? composite : c.getParent(); SearchTerms searchTerms = new SearchTerms(); while (container != null) { Object data = container.getData(); - if (data instanceof IWizardContainer) { - IWizardContainer wc = (IWizardContainer) data; + if (data instanceof IWizardContainer wc) { searchTerms.add(wc.getCurrentPage().getTitle()); searchTerms.add(wc.getCurrentPage().getWizard().getWindowTitle()); break; - } else if (data instanceof IWorkbenchWindow) { - IWorkbenchWindow window = (IWorkbenchWindow) data; + } else if (data instanceof IWorkbenchWindow window) { IWorkbenchPage page = window.getActivePage(); if (page != null) { IWorkbenchPart part = lastPart; @@ -483,8 +488,7 @@ private String[] computeSearchTerms(Control c) { */ } break; - } else if (data instanceof Window) { - Window w = (Window) data; + } else if (data instanceof Window w) { if (w instanceof IPageChangeProvider) { Object page = ((IPageChangeProvider) w).getSelectedPage(); String pageName = getPageName(c, page); @@ -501,17 +505,20 @@ private String[] computeSearchTerms(Control c) { } private String getPageName(Control focusControl, Object page) { - if (page instanceof IDialogPage) + if (page instanceof IDialogPage) { return ((IDialogPage) page).getTitle(); - if (focusControl == null) + } + if (focusControl == null) { return null; + } Composite parent = focusControl.getParent(); while (parent != null) { if (parent instanceof TabFolder) { TabItem[] selection = ((TabFolder) parent).getSelection(); - if (selection.length == 1) + if (selection.length == 1) { return stripMnemonic(selection[0].getText()); + } } else if (parent instanceof CTabFolder) { CTabItem selection = ((CTabFolder) parent).getSelection(); return stripMnemonic(selection.getText()); @@ -523,8 +530,9 @@ private String getPageName(Control focusControl, Object page) { private String stripMnemonic(String name) { int loc = name.indexOf('&'); - if (loc!= -1) + if (loc!= -1) { return name.substring(0, loc)+name.substring(loc+1); + } return name; } @@ -548,8 +556,9 @@ public static IContext findHelpContext(Control c) { Control node = c; do { contextId = (String) node.getData(HELP_KEY); - if (contextId != null) + if (contextId != null) { break; + } node = node.getParent(); } while (node != null); if (contextId != null) { @@ -573,8 +582,8 @@ private String formatHelpContext(IContext context) { String category = new String(); if (commands != null && commands.length > 0) { - for (int i=0;i"); //$NON-NLS-1$ sbuf.append(""); //$NON-NLS-1$ - sbuf.append(EscapeUtils.escapeSpecialChars(commands[i].getLabel())); + sbuf.append(EscapeUtils.escapeSpecialChars(command.getLabel())); sbuf.append(""); //$NON-NLS-1$ sbuf.append(""); //$NON-NLS-1$ } @@ -598,8 +607,7 @@ private String formatHelpContext(IContext context) { sorter.sort(null, links); } if (links != null && links.length > 0) { - for (int i = 0; i < links.length; i++) { - IHelpResource link = links[i]; + for (IHelpResource link : links) { if (!UAContentFilter.isFiltered(link, HelpEvaluationContext.getContext())) { String cat = null; if (context instanceof IContext2) { @@ -656,8 +664,9 @@ private String formatHelpContext(IContext context) { } private void addCategory(StringBuilder sbuf, String category) { - if (category == null) + if (category == null) { category = Messages.ContextHelpPart_seeAlso; + } sbuf.append("

"); //$NON-NLS-1$ @@ -667,10 +676,11 @@ private void addCategory(StringBuilder sbuf, String category) { private String getTopicCategory(String href, String locale) { IToc[] tocs = HelpPlugin.getTocManager().getTocs(locale); - for (int i = 0; i < tocs.length; i++) { - ITopic topic = tocs[i].getTopic(href); - if (topic != null) - return tocs[i].getLabel(); + for (IToc toc : tocs) { + ITopic topic = toc.getTopic(href); + if (topic != null) { + return toc.getLabel(); + } } return null; } @@ -701,8 +711,7 @@ private String decodeContextBoldTags(IContext context) { @Override public boolean setFormInput(Object input) { - if (input instanceof ContextHelpProviderInput) { - ContextHelpProviderInput chinput = (ContextHelpProviderInput) input; + if (input instanceof ContextHelpProviderInput chinput) { handleActivation(chinput.getProvider(), chinput.getContext(), chinput.getControl(), chinput.getPart(), chinput.isExplicitRequest()); return true; @@ -712,8 +721,9 @@ public boolean setFormInput(Object input) { @Override public void setFocus() { - if (text != null) + if (text != null) { text.setFocus(); + } } @Override @@ -728,8 +738,9 @@ public boolean hasFocusControl(Control control) { @Override public IAction getGlobalAction(String id) { - if (id.equals(ActionFactory.COPY.getId())) + if (id.equals(ActionFactory.COPY.getId())) { return parent.getCopyAction(); + } return null; } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpSorter.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpSorter.java index 9672f7c65e3..beb84afee39 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpSorter.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpSorter.java @@ -47,10 +47,9 @@ public int compare(Viewer viewer, Object e1, Object e2) { if (!(e2 instanceof IHelpResource)) { return -1; } - if (!(e1 instanceof IHelpResource)) { + if (!(e1 instanceof IHelpResource r1)) { return 1; } - IHelpResource r1 = (IHelpResource) e1; IHelpResource r2 = (IHelpResource) e2; String c1 = context.getCategory(r1); String c2 = context.getCategory(r2); diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/DynamicHelpPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/DynamicHelpPart.java index 29f25b93e6a..5a57cf27c9a 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/DynamicHelpPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/DynamicHelpPart.java @@ -141,8 +141,9 @@ public void linkActivated(HyperlinkEvent e) { clearResults(); } else if (href.equals(MORE_HREF)) { doMore(); - } else + } else { doOpenLink(e.getHref()); + } } @Override @@ -169,8 +170,9 @@ public void dispose() { @Override public void setFocus() { - if (searchResults!=null) + if (searchResults!=null) { searchResults.setFocus(); + } } @Override @@ -213,12 +215,14 @@ void clearResults() { } public void startSearch(String newPhrase, IContext excludeContext) { - if (phrase!=null && phrase.equals(newPhrase)) + if (phrase!=null && phrase.equals(newPhrase)) { return; + } this.phrase = newPhrase; this.context = excludeContext; - if (getSection().isExpanded()) + if (getSection().isExpanded()) { startInPlaceSearch(phrase, excludeContext); + } } private void startInPlaceSearch(final String phrase, @@ -291,8 +295,9 @@ void scheduleSearch(Job job) { private void updateResults(final String phrase, final IContext excludeContext, final StringBuilder buffer, final SearchHit[] hits) { - if (getSection().isDisposed()) + if (getSection().isDisposed()) { return; + } getSection().getDisplay().asyncExec(() -> doUpdateResults(phrase, excludeContext, buffer, hits)); } @@ -315,12 +320,15 @@ private void doUpdateResults(String phrase, IContext excludeContext, StringBuild for (int i = 0; i < hits.length; i++) { SearchHit hit = hits[i]; - if (hit.canOpen()) // Do not list Welcome/Cheatsheets etc. + if (hit.canOpen()) { // Do not list Welcome/Cheatsheets etc. continue; - if (isExcluded(hit.getHref(), excludedTopics)) + } + if (isExcluded(hit.getHref(), excludedTopics)) { continue; - if (i==SHORT_COUNT) + } + if (i==SHORT_COUNT) { break; + } buff.append("

  • "); //$NON-NLS-1$ @@ -349,23 +357,30 @@ private void doUpdateResults(String phrase, IContext excludeContext, StringBuild buff.append("

    "); //$NON-NLS-1$ } buff.append(""); //$NON-NLS-1$ - if (!searchResults.isDisposed()) + if (!searchResults.isDisposed()) { searchResults.setText(buff.toString(), true, false); + } } else - if (!searchResults.isDisposed()) + if (!searchResults.isDisposed()) { searchResults.setText(NLS.bind(Messages.SearchResultsPart_noHits, phrase) , false, false); - if (!searchResults.isDisposed()) + } + if (!searchResults.isDisposed()) { getManagedForm().reflow(true); + } } private boolean isExcluded(String href, IHelpResource [] excludedTopics) { - if (excludedTopics==null) return false; + if (excludedTopics==null) { + return false; + } for (int i=0; i 0) + if (phrase!=null && phrase.length() > 0) { startInPlaceSearch(phrase, context); + } } @Override diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineDescriptor.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineDescriptor.java index f6c82086865..d3bc5f12732 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineDescriptor.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineDescriptor.java @@ -76,36 +76,43 @@ public IConfigurationElement getConfig() { @Override public String getLabel() { - if (label != null) + if (label != null) { return label; + } String clabel = null; - if (config != null) + if (config != null) { clabel = config.getAttribute(IHelpUIConstants.ATT_LABEL); - if (clabel == null) + } + if (clabel == null) { clabel = etdesc.getLabel(); + } return clabel; } @Override public String getId() { - if (id != null) + if (id != null) { return id; + } return config.getAttribute(IHelpUIConstants.ATT_ID); } @Override public String getEngineTypeId() { - if (etdesc != null) + if (etdesc != null) { return etdesc.getId(); + } return config.getAttribute(IHelpUIConstants.ATT_ENGINE_TYPE_ID); } public boolean isEnabled() { - if (userDefined) + if (userDefined) { return true; + } String aenabled = config.getAttribute(IHelpUIConstants.ATT_ENABLED); - if (aenabled != null) + if (aenabled != null) { return aenabled.equals("true"); //$NON-NLS-1$ + } return false; } @@ -115,17 +122,20 @@ public Image getIconImage() { @Override public String getDescription() { - if (desc != null) + if (desc != null) { return desc; + } String cdesc = null; if (config != null) { IConfigurationElement[] children = config .getChildren(IHelpUIConstants.TAG_DESC); - if (children.length == 1) + if (children.length == 1) { cdesc = children[0].getValue(); + } } - if (cdesc == null) + if (cdesc == null) { return etdesc.getDescription(); + } return cdesc; } @@ -148,8 +158,9 @@ public RootScopePage createRootPage(String scopeSetName) { @Override public Dictionary getParameters() { - if (parameters != null) + if (parameters != null) { return parameters; + } parameters = new Hashtable<>(); parameters.put(P_MASTER, isEnabled() ? Boolean.TRUE : Boolean.FALSE); if (config != null) { @@ -158,8 +169,9 @@ public Dictionary getParameters() { IConfigurationElement param = params[i]; String name = param.getAttribute(IHelpUIConstants.ATT_NAME); String value = param.getAttribute(IHelpUIConstants.ATT_VALUE); - if (name != null && value != null) + if (name != null && value != null) { parameters.put(name, value); + } } } return parameters; @@ -184,8 +196,9 @@ void setId(String id) { public void setLabel(String label) { if (isUserDefined()) { this.label = label; - if (manager!=null) + if (manager!=null) { manager.notifyPropertyChange(this); + } } } @@ -193,8 +206,9 @@ public void setLabel(String label) { public void setDescription(String desc) { if (isUserDefined()) { this.desc = desc; - if (manager!=null) + if (manager!=null) { manager.notifyPropertyChange(this); + } } } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineDescriptorManager.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineDescriptorManager.java index 6485dd9190d..6782f0e079e 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineDescriptorManager.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineDescriptorManager.java @@ -96,8 +96,9 @@ public EngineDescriptor[] getDescriptors() { public EngineDescriptor findEngine(String engineId) { for (EngineDescriptor desc : descriptors) { - if (desc.getId().equals(engineId)) + if (desc.getId().equals(engineId)) { return desc; + } } return null; } @@ -202,7 +203,9 @@ public void load(Reader r) { */ public void load(String fileName) throws IOException { File file = new File(fileName); - if (!file.exists()) return; + if (!file.exists()) { + return; + } FileInputStream stream = new FileInputStream(file); try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) { load(reader); @@ -224,8 +227,9 @@ private void loadUserEntry(Node node) { EngineTypeDescriptor etdesc = findEngineType(engineTypeId); String label = getAttribute(node, ATT_LABEL); String desc = getDescription(node); - if (etdesc == null) + if (etdesc == null) { return; + } edesc.setEngineType(etdesc); edesc.setUserDefined(true); edesc.setId(id); @@ -238,7 +242,9 @@ public String computeNewId(String typeId) { ArrayList used = new ArrayList<>(); for (int i=0; i used) { for (Integer iv : used) { - if (iv.intValue()==value) + if (iv.intValue()==value) { return true; + } } return false; } @@ -298,14 +305,16 @@ private void save(PrintWriter writer, EngineDescriptor desc) { private String getAttribute(Node node, String name) { Node att = node.getAttributes().getNamedItem(name); - if (att!=null) + if (att!=null) { return att.getNodeValue(); + } return null; } private void saveAttribute(PrintWriter writer, String indent, String name, String value) { - if (value==null) + if (value==null) { return; + } writer.print(indent); writer.print(name); writer.print("=\""); //$NON-NLS-1$ @@ -313,8 +322,9 @@ private void saveAttribute(PrintWriter writer, String indent, String name, Strin writer.println("\""); //$NON-NLS-1$ } private void saveDescription(PrintWriter writer, String indent, String desc) { - if (desc==null) + if (desc==null) { return; + } writer.print(indent); writer.println(""); //$NON-NLS-1$ writer.println(desc); @@ -323,11 +333,13 @@ private void saveDescription(PrintWriter writer, String indent, String desc) { } private EngineTypeDescriptor findEngineType(String id) { - if (id == null) + if (id == null) { return null; + } for (EngineTypeDescriptor etd : engineTypes) { - if (etd.getId().equals(id)) + if (etd.getId().equals(id)) { return etd; + } } return null; } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineResultSection.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineResultSection.java index 01350d6fa24..e64b9ef0bdb 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineResultSection.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineResultSection.java @@ -133,8 +133,9 @@ public Control createControl(Composite parent, final FormToolkit toolkit) { @Override public void expansionStateChanging(ExpansionEvent e) { - if (needsUpdating) + if (needsUpdating) { asyncUpdateResults(true, false); + } } }); return section; @@ -172,8 +173,9 @@ public void linkActivated(HyperlinkEvent e) { doBookmark(e.getLabel(), shref); } else if (shref.startsWith(CAT_HEADING_PREFIX)) { part.doCategoryLink(shref.substring(CAT_HEADING_PREFIX.length())); - } else + } else { part.doOpenLink(e.getHref()); + } } @Override @@ -248,8 +250,9 @@ public synchronized void error(IStatus status) { } public synchronized void completed() { - if (hits.isEmpty() && !searchResults.isDisposed()) + if (hits.isEmpty() && !searchResults.isDisposed()) { asyncUpdateResults(false, false); + } } public synchronized void canceling() { @@ -293,14 +296,16 @@ private ISearchEngineResult[] getResults() { list = new ArrayList<>(); for (int i = 0; i < hits.size(); i++) { ISearchEngineResult hit = hits.get(i); - if (HelpBasePlugin.getActivitySupport().isEnabled(hit.getHref())) + if (HelpBasePlugin.getActivitySupport().isEnabled(hit.getHref())) { list.add(hit); + } } } } ISearchEngineResult[] results = list.toArray(new ISearchEngineResult[list.size()]); - if (part.getShowCategories()) + if (part.getShowCategories()) { sorter.sort(null, results); + } return results; } @@ -387,8 +392,9 @@ void updateResults(boolean reflow) { else { id = registerHitIcon(iconURL); } - if (id != null) + if (id != null) { imageId = id; + } } } @@ -400,15 +406,15 @@ void updateResults(boolean reflow) { buff.append("\">"); //$NON-NLS-1$ buff.append(""); //$NON-NLS-1$ } - if (errorStatus != null) + if (errorStatus != null) { updateErrorStatus(buff); + } updateNavigation(results.length); buff.append(""); //$NON-NLS-1$ searchResults.setText(buff.toString(), true, false); section.layout(); - if (reflow) + if (reflow) { part.reflow(); + } } /** @@ -495,8 +503,9 @@ private void updateErrorStatus(StringBuilder buff) { buff.append(""); //$NON-NLS-1$ buff.append("
    "); //$NON-NLS-1$ Throwable t = errorStatus.getException(); - if (t != null && t.getMessage() != null) + if (t != null && t.getMessage() != null) { buff.append(EscapeUtils.escapeSpecialChars(t.getMessage())); + } buff.append("
  • "); //$NON-NLS-1$ } @@ -573,13 +582,13 @@ private void updateSectionTitle(int size) { } else { section.setTextClient(null); } - if (size == 1) + if (size == 1) { section.setText(NLS.bind(Messages.EngineResultSection_sectionTitle_hit, desc.getLabel(), "" //$NON-NLS-1$ + hits.size())); - else if (size <= HITS_PER_PAGE) + } else if (size <= HITS_PER_PAGE) { section.setText(NLS.bind(Messages.EngineResultSection_sectionTitle_hits, desc.getLabel(), "" + hits.size())); //$NON-NLS-1$ - else { + } else { int from = (resultOffset + 1); int to = (resultOffset + HITS_PER_PAGE); to = Math.min(to, size); @@ -604,8 +613,7 @@ public void dispose() { private void recursiveSetMenu(Control control, Menu menu) { control.setMenu(menu); - if (control instanceof Composite) { - Composite parent = (Composite) control; + if (control instanceof Composite parent) { Control[] children = parent.getChildren(); for (Control child : children) { recursiveSetMenu(child, menu); diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeDescriptor.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeDescriptor.java index 808ad314ddb..e3623f656e8 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeDescriptor.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeDescriptor.java @@ -54,8 +54,9 @@ public String getId() { } public Image getIconImage() { - if (image!=null) + if (image!=null) { return image; + } String icon = config.getAttribute(IHelpUIConstants.ATT_ICON); if (icon!=null) { String bundleId = config.getContributor().getName(); @@ -69,8 +70,9 @@ public Image getIconImage() { public String getDescription() { String desc = null; IConfigurationElement [] children = config.getChildren(IHelpUIConstants.TAG_DESC); - if (children.length==1) + if (children.length==1) { desc = children[0].getValue(); + } return desc; } @@ -78,17 +80,17 @@ public ImageDescriptor getImageDescriptor() { ImageDescriptor desc=null; String icon = config.getAttribute(IHelpUIConstants.ATT_ICON); String bundleId = config.getContributor().getName(); - if (icon!=null) + if (icon!=null) { desc = HelpUIResources.getImageDescriptor(bundleId, icon); - else + } else { desc = HelpUIResources.getImageDescriptor(bundleId, IHelpUIConstants.IMAGE_HELP_SEARCH); + } return desc; } public RootScopePage createRootPage(String scopeSetName) { try { Object obj = config.createExecutableExtension(IHelpUIConstants.ATT_PAGE_CLASS); - if (obj instanceof RootScopePage) { - RootScopePage page = (RootScopePage)obj; + if (obj instanceof RootScopePage page) { return page; } return null; @@ -102,8 +104,9 @@ public ISearchEngine createEngine() { if (eclass!=null) { try { Object obj = config.createExecutableExtension(IHelpUIConstants.ATT_CLASS); - if (obj instanceof ISearchEngine) + if (obj instanceof ISearchEngine) { return (ISearchEngine)obj; + } } catch (CoreException e) { ILog.of(getClass()).error("Engine " + eclass + " cannot be instantiated", null); //$NON-NLS-1$ //$NON-NLS-2$ @@ -129,8 +132,9 @@ public ISearchScope createSearchScope(IPreferenceStore store, String engineId, } } } - if (factory!=null) + if (factory!=null) { return factory.createSearchScope(store, engineId, parameters); + } return null; } } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/FederatedSearchSorter.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/FederatedSearchSorter.java index 615b2c2068f..366dcc0df32 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/FederatedSearchSorter.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/FederatedSearchSorter.java @@ -25,13 +25,13 @@ public FederatedSearchSorter() { @Override public int category(Object element) { - if (element instanceof ISearchEngineResult) { - ISearchEngineResult r = (ISearchEngineResult)element; + if (element instanceof ISearchEngineResult r) { IHelpResource c = r.getCategory(); if (c!=null) { String label = c.getLabel(); - if (label.length()==0) + if (label.length()==0) { return 10; + } return 5; } } @@ -44,8 +44,9 @@ public int compare(Viewer viewer, Object e1, Object e2) { int cat1 = category(e1); int cat2 = category(e2); - if (cat1 != cat2) + if (cat1 != cat2) { return cat1 - cat2; + } try { ISearchEngineResult r1 = (ISearchEngineResult) e1; ISearchEngineResult r2 = (ISearchEngineResult) e2; @@ -53,7 +54,9 @@ public int compare(Viewer viewer, Object e1, Object e2) { IHelpResource c2 = r2.getCategory(); if (c1!=null && c2!=null) { int cat = super.compare(viewer, c1.getLabel(), c2.getLabel()); - if (cat!=0) return cat; + if (cat!=0) { + return cat; + } } float rank1 = ((ISearchEngineResult) e1).getScore(); float rank2 = ((ISearchEngineResult) e2).getScore(); diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HelpTray.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HelpTray.java index 56113d7340f..d6437329ae3 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HelpTray.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HelpTray.java @@ -241,8 +241,7 @@ public void pageChanged(PageChangedEvent event) { c = ((IDialogPage) page).getControl(); } else { c = shell.getDisplay().getFocusControl(); - if (c instanceof TabFolder) { - TabFolder folder = (TabFolder) c; + if (c instanceof TabFolder folder) { TabItem[] selection = folder.getSelection(); if (selection.length == 1) { c = selection[0].getControl(); diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HelpView.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HelpView.java index ac0ccdb562e..3e4980eda82 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HelpView.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HelpView.java @@ -68,14 +68,17 @@ public void createPartControl(Composite parent) { reusableHelpPart.showPage(getFirstPage()); PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.eclipse.help.ui.helpView"); //$NON-NLS-1$ IWorkbenchWindow window = getSite().getPage().getWorkbenchWindow(); - if (window == null) + if (window == null) { return; + } IWorkbenchPage page = window.getActivePage(); - if (page == null) + if (page == null) { return; + } IWorkbenchPartReference aref = page.getActivePartReference(); - if (aref != null) + if (aref != null) { handlePartActivation(aref); + } } @Override @@ -100,8 +103,9 @@ public void dispose() { @Override public void init(IViewSite site, IMemento memento) throws PartInitException { - if (memento!=null) + if (memento!=null) { this.firstPageId = memento.getString("pageId"); //$NON-NLS-1$ + } init(site); reusableHelpPart = new ReusableHelpPart(site.getWorkbenchWindow(), getHelpPartStyle()); @@ -117,19 +121,23 @@ public void init(IViewSite site, IMemento memento) throws PartInitException { public void saveState(IMemento memento) { if (reusableHelpPart!=null && memento!=null) { String pageId = reusableHelpPart.getCurrentPageId(); - if (pageId!=null) + if (pageId!=null) { memento.putString("pageId", pageId); //$NON-NLS-1$ + } reusableHelpPart.saveState(memento); } } private void handlePartActivation(IWorkbenchPartReference ref) { - if (reusableHelpPart == null) + if (reusableHelpPart == null) { return; - if (!visible || !reusableHelpPart.isMonitoringContextHelp()) + } + if (!visible || !reusableHelpPart.isMonitoringContextHelp()) { return; - if (isThisPart(ref)) + } + if (isThisPart(ref)) { return; + } IWorkbenchPart part = ref.getPart(false); Display display = part.getSite().getShell().getDisplay(); Control c = display.getFocusControl(); @@ -144,10 +152,12 @@ private void handlePartActivation(IWorkbenchPartReference ref) { // context help changes with selections installSelectionListener(part); } - } else + } else { reusableHelpPart.update(part, c); - if (part instanceof IPageChangeProvider) + } + if (part instanceof IPageChangeProvider) { installPageListener(part); + } } else { if (HelpPlugin.DEBUG_CONTEXT) { if (c == null) { @@ -161,14 +171,16 @@ private void handlePartActivation(IWorkbenchPartReference ref) { } private void installPageListener(IWorkbenchPart part) { - if (part instanceof IPageChangeProvider) + if (part instanceof IPageChangeProvider) { ((IPageChangeProvider)part).addPageChangedListener(this); + } monitoredPart = part; } private void uninstallPageListener(IWorkbenchPart part) { - if (part instanceof IPageChangeProvider) + if (part instanceof IPageChangeProvider) { ((IPageChangeProvider)part).removePageChangedListener(this); + } monitoredPart = null; } @@ -185,11 +197,12 @@ private void installSelectionListener(IWorkbenchPart part) { private void uninstallSelectionListener(IWorkbenchPart part) { ISelectionProvider provider = part.getSite().getSelectionProvider(); - if (provider instanceof IPostSelectionProvider) + if (provider instanceof IPostSelectionProvider) { ((IPostSelectionProvider) provider) .removePostSelectionChangedListener(this); - else if (provider != null) + } else if (provider != null) { provider.removeSelectionChangedListener(this); + } monitoredPart = null; } @@ -206,10 +219,11 @@ private void updateActivePart() { if (isValid(c) && visible) { IContextProvider provider = monitoredPart.getAdapter(IContextProvider.class); - if (provider != null) + if (provider != null) { reusableHelpPart.update(provider, null, monitoredPart, c, false); - else + } else { reusableHelpPart.update(monitoredPart, c); + } } } @@ -285,8 +299,9 @@ private void hook(boolean doHook, IWorkbenchPartReference partref) { IWorkbenchWindow window = partref.getPage().getWorkbenchWindow(); IPartService service = window.getPartService(); IWorkbenchPartReference aref = service.getActivePartReference(); - if (aref != null) + if (aref != null) { handlePartActivation(aref); + } } else { if (monitoredPart != null) { uninstallSelectionListener(monitoredPart); @@ -297,14 +312,16 @@ private void hook(boolean doHook, IWorkbenchPartReference partref) { @Override public void selectionChanged(SelectionChangedEvent event) { - if (!visible) + if (!visible) { return; + } getSite().getShell().getDisplay().asyncExec(this::updateActivePart); } protected String getFirstPage() { - if (firstPageId!=null) + if (firstPageId!=null) { return firstPageId; + } return IHelpUIConstants.HV_CONTEXT_HELP_PAGE; } @@ -321,8 +338,9 @@ public void displayContext(IContext context, IWorkbenchPart part, reusableHelpPart.showPage(IHelpUIConstants.HV_CONTEXT_HELP_PAGE); // check if there is a dynamic version IContextProvider provider = null; - if (part!=null) + if (part!=null) { provider = part.getAdapter(IContextProvider.class); + } reusableHelpPart.update(provider, context, part, control, true); } @@ -338,34 +356,40 @@ protected int getHelpPartStyle() { @Override public void setFocus() { - if (reusableHelpPart != null) + if (reusableHelpPart != null) { reusableHelpPart.setFocus(); + } } public void startSearch(String phrase) { - if (reusableHelpPart != null) + if (reusableHelpPart != null) { reusableHelpPart.startSearch(phrase); + } } public void showIndex() { - if (reusableHelpPart != null) + if (reusableHelpPart != null) { reusableHelpPart.showPage(IHelpUIConstants.HV_INDEX_PAGE, true); + } } public void showHelp(String href) { - if (reusableHelpPart != null) + if (reusableHelpPart != null) { reusableHelpPart.showURL(href); + } } public void showDynamicHelp(IWorkbenchPart part, Control c) { - if (reusableHelpPart != null) + if (reusableHelpPart != null) { reusableHelpPart.showDynamicHelp(part, c); + } } @Override public void pageChanged(PageChangedEvent event) { - if (!visible) + if (!visible) { return; + } updateActivePart(); } } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HistoryScopeSet.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HistoryScopeSet.java index 64632e43d98..adea0ce4016 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HistoryScopeSet.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HistoryScopeSet.java @@ -25,8 +25,9 @@ public HistoryScopeSet(String expression) { public HistoryScopeSet(String name, String expression) { super(name); - if (expression!=null) + if (expression!=null) { setExpression(expression); + } } public HistoryScopeSet(HistoryScopeSet set) { diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HyperlinkTreePart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HyperlinkTreePart.java index 5e3656e329c..facae4ca2f3 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HyperlinkTreePart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HyperlinkTreePart.java @@ -144,8 +144,9 @@ public HyperlinkTreePart(Composite parent, final FormToolkit toolkit, @Override public void mouseUp(MouseEvent e) { long eventTime = e.time & 0xFFFFFFFFL; - if ((eventTime - lastTime <= e.display.getDoubleClickTime()) || (e.button != 1)) + if ((eventTime - lastTime <= e.display.getDoubleClickTime()) || (e.button != 1)) { return; + } lastTime = eventTime; Point p = new Point(e.x, e.y); TreeItem item = treeViewer.getTree().getItem(p); @@ -160,8 +161,9 @@ public void mouseUp(MouseEvent e) { treeViewer.getTree().addPaintListener(e -> { validateLastItem(); - if (lastItem == null) + if (lastItem == null) { return; + } Rectangle bounds = lastItem.getBounds(); boolean selected = false; TreeItem[] items = lastItem.getParent().getSelection(); @@ -171,10 +173,11 @@ public void mouseUp(MouseEvent e) { break; } } - if (selected) + if (selected) { e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT)); - else + } else { e.gc.setForeground(toolkit.getHyperlinkGroup().getActiveForeground()); + } FontMetrics fm = e.gc.getFontMetrics(); int height = fm.getHeight(); int lineY = bounds.y + height; @@ -205,22 +208,25 @@ public void mouseExit(MouseEvent e) { repaintItem(lastItem); updateStatus(null); lastItem = null; - } else + } else { return; + } } Object obj = item.getData(); treeViewer.getTree().setCursor(handCursor); IStructuredSelection ssel = treeViewer.getStructuredSelection(); - if (ssel.getFirstElement() == obj) + if (ssel.getFirstElement() == obj) { item.setForeground(e.display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT)); - else + } else { item.setForeground(toolkit.getHyperlinkGroup().getActiveForeground()); + } lastItem = item; repaintItem(lastItem); - if (obj instanceof IHelpResource) + if (obj instanceof IHelpResource) { updateStatus((IHelpResource) obj); - else + } else { updateStatus(null); + } return; } else if (lastItem != null) { lastItem.setForeground(null); @@ -291,8 +297,9 @@ public String getId() { @Override public void setVisible(boolean visible) { getControl().setVisible(visible); - if (visible) + if (visible) { treeViewer.refresh(); + } } private void doOpenSelection(IStructuredSelection sel) { @@ -306,19 +313,20 @@ protected void handleSelectionChanged(IStructuredSelection sel) { Object obj = sel.getFirstElement(); if (lastItem != null && !lastItem.isDisposed()) { Object lastObj = lastItem.getData(); - if (lastObj==obj) + if (lastObj==obj) { lastItem.setForeground(getControl().getDisplay() .getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT)); - else + } else { lastItem.setForeground(parent.getForm().getToolkit().getHyperlinkGroup() .getActiveForeground()); + } repaintItem(lastItem); } - if (obj instanceof IHelpResource) { - IHelpResource res = (IHelpResource) obj; + if (obj instanceof IHelpResource res) { updateStatus(res, false); - } else + } else { updateStatus(null, false); + } } private void updateStatus(IHelpResource res) { @@ -329,8 +337,9 @@ private void updateStatus(IHelpResource res, boolean defaultToSelection) { if (defaultToSelection && res == null) { IStructuredSelection ssel = treeViewer.getStructuredSelection(); Object obj = ssel.getFirstElement(); - if (obj instanceof IHelpResource) + if (obj instanceof IHelpResource) { res = (IHelpResource) obj; + } } if (res != null) { String label = res.getLabel(); @@ -369,14 +378,16 @@ public boolean hasFocusControl(Control focusControl) { @Override public void setFocus() { - if (treeViewer != null) + if (treeViewer != null) { treeViewer.getTree().setFocus(); + } } @Override public IAction getGlobalAction(String id) { - if (id.equals(ActionFactory.COPY.getId())) + if (id.equals(ActionFactory.COPY.getId())) { return parent.getCopyAction(); + } return null; } @@ -385,8 +396,9 @@ public void stop() { } private void validateLastItem() { - if (lastItem != null && lastItem.isDisposed()) + if (lastItem != null && lastItem.isDisposed()) { lastItem = null; + } } @Override diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/IndexPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/IndexPart.java index 30ec6309791..8ae5fbbb0ca 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/IndexPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/IndexPart.java @@ -83,12 +83,13 @@ class IndexLabelProvider extends LabelProvider { @Override public String getText(Object obj) { - if (obj instanceof IIndexEntry) + if (obj instanceof IIndexEntry) { return ((IIndexEntry) obj).getKeyword(); - if (obj instanceof IHelpResource) + } + if (obj instanceof IHelpResource) { return ((IHelpResource) obj).getLabel(); - if (obj instanceof IndexSee) { - IndexSee see = (IndexSee) obj; + } + if (obj instanceof IndexSee see) { return getSeeString(see); } return super.getText(obj); @@ -129,19 +130,22 @@ private boolean isEnabled(IIndexEntry entry) { if (!UAContentFilter.isFiltered(entry, HelpEvaluationContext.getContext())) { IHelpResource[] topics = entry.getTopics(); for (int i = 0; i < topics.length; i++) { - if (isEnabled(topics[i])) + if (isEnabled(topics[i])) { return true; + } } IIndexEntry[] subentries = entry.getSubentries(); for (int i = 0; i < subentries.length; i++) { - if (isEnabled(subentries[i])) + if (isEnabled(subentries[i])) { return true; + } } if (entry instanceof IIndexEntry2) { IIndexSee[] sees = ((IIndexEntry2)entry).getSees(); for (int i = 0; i < sees.length; i++) { - if (isEnabled(sees[i])) + if (isEnabled(sees[i])) { return true; + } } } } @@ -171,16 +175,16 @@ protected void configureTreeViewer() { @Override public void init(ReusableHelpPart parent, String id, IMemento memento) { super.init(parent, id, memento); - if (parent.isFilteredByRoles()) + if (parent.isFilteredByRoles()) { treeViewer.addFilter(roleFilter); + } } @Override protected void doOpen(Object obj) { if (obj instanceof IHelpResource) { parent.showURL(((IHelpResource) obj).getHref()); - } else if (obj instanceof IIndexEntry) { - IIndexEntry entry = (IIndexEntry) obj; + } else if (obj instanceof IIndexEntry entry) { if (getChildren(entry).length > 0) { treeViewer.setExpandedState(obj, !treeViewer.getExpandedState(obj)); } @@ -188,8 +192,7 @@ protected void doOpen(Object obj) { if (topics.length == 1) { parent.showURL(topics[0].getHref()); } - } else if (obj instanceof IIndexSee) { - IIndexSee see = (IIndexSee)obj; + } else if (obj instanceof IIndexSee see) { IIndexEntry[] entrys = IndexUtils.findSeeTargets(HelpSystem.getIndex(), see, 0); for (int i = 0; i < entrys.length; i++) { treeViewer.setExpandedState(entrys[i], true); @@ -209,10 +212,11 @@ public void saveState(IMemento memento) { @Override public void toggleRoleFilter() { - if (parent.isFilteredByRoles()) + if (parent.isFilteredByRoles()) { treeViewer.addFilter(roleFilter); - else + } else { treeViewer.removeFilter(roleFilter); + } } private Object[] getChildren(IIndexEntry entry) { @@ -227,7 +231,7 @@ private Object[] getChildren(IIndexEntry entry) { */ IHelpResource[] topics = entry.getTopics(); IIndexEntry[] subentries = entry.getSubentries(); - IIndexSee[] sees = entry instanceof IIndexEntry2 ? ((IIndexEntry2)entry).getSees() : + IIndexSee[] sees = entry instanceof IIndexEntry2 i ? i.getSees() : new IIndexSee[0]; if (topics.length <= 1 && subentries.length == 0 && sees.length == 0) { diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/IndexTypeinPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/IndexTypeinPart.java index 32c9d5e2cd8..f8c66f54d13 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/IndexTypeinPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/IndexTypeinPart.java @@ -111,7 +111,9 @@ public void widgetSelected(SelectionEvent e) { protected void doUp() { checkTree(); - if (indexTree == null) return; + if (indexTree == null) { + return; + } int index = 0; TreeItem[] items = indexTree.getSelection(); @@ -130,7 +132,9 @@ protected void doUp() { protected void doDown() { checkTree(); - if (indexTree == null) return; + if (indexTree == null) { + return; + } int index = 0; TreeItem[] items = indexTree.getSelection(); @@ -149,7 +153,9 @@ protected void doDown() { protected void doNavigate(String text) { checkTree(); - if (rootItems == null) return; + if (rootItems == null) { + return; + } int index = searchPattern(text); if (index != -1 && index != currentIndex) { @@ -159,13 +165,19 @@ protected void doNavigate(String text) { } private void checkTree() { - if (rootItems != null) return; + if (rootItems != null) { + return; + } indexPart = (IndexPart)parent.findPart(HV_INDEX); - if (indexPart == null) return; + if (indexPart == null) { + return; + } indexTree = indexPart.getTreeWidget(); - if (indexTree == null) return; + if (indexTree == null) { + return; + } int itemCount = indexTree.getItemCount(); if (itemCount == 0) { @@ -219,10 +231,14 @@ int compare(String keyword, String pattern) { protected void doOpen() { checkTree(); - if (indexTree == null) return; + if (indexTree == null) { + return; + } TreeItem items[] = indexTree.getSelection(); - if (items.length == 0) return; + if (items.length == 0) { + return; + } Object obj = items[0].getData(); if (obj != null) { diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/RelatedTopicsPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/RelatedTopicsPart.java index dea044ab375..53f3b82c6e8 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/RelatedTopicsPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/RelatedTopicsPart.java @@ -170,8 +170,9 @@ public boolean hasFocusControl(Control control) { @Override public boolean fillContextMenu(IMenuManager manager) { Control focusControl = mform.getForm().getDisplay().getFocusControl(); - if (contextHelpPart.hasFocusControl(focusControl) || dynamicHelpPart == null) + if (contextHelpPart.hasFocusControl(focusControl) || dynamicHelpPart == null) { return contextHelpPart.fillContextMenu(manager); + } return dynamicHelpPart.fillContextMenu(manager); } @@ -220,8 +221,9 @@ public void saveState(IMemento memento) { @Override public void setFocus() { - if (contextHelpPart!=null) + if (contextHelpPart!=null) { contextHelpPart.setFocus(); + } } public static boolean isUseDynamicHelp() { diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/RenameDialog.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/RenameDialog.java index 72bbbbeb382..cec4ba174cc 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/RenameDialog.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/RenameDialog.java @@ -63,8 +63,9 @@ public RenameDialog(Shell shell, boolean isCaseSensitive, String[] names, String this.isCaseSensitive = isCaseSensitive; initialize(); if (names!=null){ - for (int i = 0; i tabList = new ArrayList<>(); for (int i = 0; i < partRecs.size(); i++) { PartRec rec = partRecs.get(i); @@ -527,15 +538,17 @@ public void setVisible(boolean visible) { } } } - if (pageAction != null) + if (pageAction != null) { pageAction.setChecked(visible); + } } if (bars != null) { - if (visible) + if (visible) { bars.activate(); - else + } else { bars.deactivate(); + } if (this.updateActionBars) { bars.updateActionBars(); @@ -552,11 +565,13 @@ public void setVisible(boolean visible) { } private void hookGlobalAction(String id, IHelpPart part) { - if (bars == null) + if (bars == null) { return; + } IAction action = part.getGlobalAction(id); - if (action != null) + if (action != null) { bars.setGlobalActionHandler(id, action); + } } private void createRecPart(PartRec rec) throws SWTError { @@ -569,8 +584,9 @@ private void createRecPart(PartRec rec) throws SWTError { public IHelpPart findPart(String id) { for (int i = 0; i < partRecs.size(); i++) { PartRec rec = partRecs.get(i); - if (rec.id.equals(id)) + if (rec.id.equals(id)) { return rec.part; + } } return null; } @@ -605,8 +621,9 @@ public int computeMinimumWidth(Composite parent, boolean changed) { @Override protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { - if (currentPage == null) + if (currentPage == null) { return new Point(0, 0); + } PartRec[] parts = currentPage.getParts(); int hmargin = currentPage.getHorizontalMargin(); int innerWhint = wHint != SWT.DEFAULT ? wHint - 2 * hmargin : wHint; @@ -620,8 +637,9 @@ protected Point computeSize(Composite composite, int wHint, int hHint, result.x = Math.max(result.x, size.x); result.y += size.y; } - if (i < parts.length - 1) + if (i < parts.length - 1) { result.y += currentPage.getVerticalSpacing(); + } } result.x += hmargin * 2; result.y += bmargin; @@ -630,8 +648,9 @@ protected Point computeSize(Composite composite, int wHint, int hHint, @Override protected void layout(Composite composite, boolean flushCache) { - if (currentPage == null) + if (currentPage == null) { return; + } Rectangle clientArea = composite.getClientArea(); @@ -649,18 +668,21 @@ protected void layout(Composite composite, boolean flushCache) { Control c = partRec.part.getControl(); Point size = c.computeSize(innerWidth, SWT.DEFAULT, false); fixedSizes[index++] = size; - if (!partRec.grabVertical) + if (!partRec.grabVertical) { fixedHeight += size.y; + } } - if (i < parts.length - 1) + if (i < parts.length - 1) { fixedHeight += currentPage.getVerticalSpacing(); + } } fixedHeight += bmargin; int flexHeight = clientArea.height - fixedHeight; int flexPortion = 0; - if (currentPage.getNumberOfFlexibleParts() > 0) + if (currentPage.getNumberOfFlexibleParts() > 0) { flexPortion = flexHeight / currentPage.getNumberOfFlexibleParts(); + } int usedFlexHeight = 0; int y = 0; @@ -672,22 +694,24 @@ protected void layout(Composite composite, boolean flushCache) { if (partRec.flexible) { int height; - if (++nflexParts == currentPage.getNumberOfFlexibleParts()) + if (++nflexParts == currentPage.getNumberOfFlexibleParts()) { height = flexHeight - usedFlexHeight; - else { + } else { height = flexPortion; usedFlexHeight += height; } c.setBounds(0, y, clientArea.width, height); } else { Point fixedSize = fixedSizes[index++]; - if (fixedSize.y < flexHeight && partRec.grabVertical) + if (fixedSize.y < flexHeight && partRec.grabVertical) { c.setBounds(hmargin, y, innerWidth, flexHeight); - else + } else { c.setBounds(hmargin, y, innerWidth, fixedSize.y); + } } - if (i < parts.length - 1) + if (i < parts.length - 1) { y += c.getSize().y + currentPage.getVerticalSpacing(); + } } } } @@ -699,8 +723,9 @@ public boolean select(Viewer viewer, Object parentElement, Object element) { IHelpResource res = (IHelpResource) element; String href = res.getHref(); - if (href == null) + if (href == null) { return true; + } return HelpBasePlugin.getActivitySupport().isEnabled(href); } } @@ -933,8 +958,9 @@ protected void busyRun() { bookmarkAction.setText(Messages.ReusableHelpPart_bookmarkAction_label); bookmarkAction.setImageDescriptor(HelpUIResources .getImageDescriptor(IHelpUIConstants.IMAGE_ADD_BOOKMARK)); - if (actionBars != null && actionBars.getMenuManager() != null) + if (actionBars != null && actionBars.getMenuManager() != null) { contributeToDropDownMenu(actionBars.getMenuManager()); + } linkWithSelection = new Action() { @Override @@ -1005,14 +1031,16 @@ private void doBack() { part.stop(); } HistoryEntry entry = history.prev(); - if (entry != null) + if (entry != null) { executeHistoryEntry(entry); + } } private void doNext() { HistoryEntry entry = history.next(); - if (entry != null) + if (entry != null) { executeHistoryEntry(entry); + } } private void executeHistoryEntry(HistoryEntry entry) { @@ -1044,8 +1072,9 @@ public void createControl(Composite parent, FormToolkit toolkit) { public HelpPartPage showPage(String id) { String currentPageId = currentPage == null ? null : currentPage.getId(); - if (id.equals(currentPageId)) + if (id.equals(currentPageId)) { return currentPage; + } // If navigating away from the browser page clear // its contents if (IHelpUIConstants.HV_BROWSER_PAGE.equals(currentPageId)) { @@ -1064,16 +1093,18 @@ public HelpPartPage showPage(String id) { public HelpPartPage showPage(String id, boolean setFocus) { HelpPartPage page = this.showPage(id); - if (page != null && setFocus) + if (page != null && setFocus) { page.setFocus(); + } return page; } public void startSearch(String phrase) { showPage(IHelpUIConstants.HV_FSEARCH_PAGE, true); SearchPart part = (SearchPart) findPart(IHelpUIConstants.HV_FSEARCH); - if (part != null && phrase != null) + if (part != null && phrase != null) { part.startSearch(phrase); + } } public void showDynamicHelp(IWorkbenchPart wpart, Control c) { @@ -1085,8 +1116,9 @@ public void showDynamicHelp(IWorkbenchPart wpart, Control c) { } private boolean flipPages(HelpPartPage oldPage, HelpPartPage newPage) { - if (!newPage.canOpen()) + if (!newPage.canOpen()) { return false; + } if (oldPage != null) { oldPage.stop(); oldPage.updateActionBars = false; @@ -1107,8 +1139,9 @@ private boolean flipPages(HelpPartPage oldPage, HelpPartPage newPage) { toolBarManager.update(true); currentPage = newPage; - if (mform.isStale()) + if (mform.isStale()) { mform.refresh(); + } mform.getForm().getBody().layout(true); mform.reflow(true); if (!newPage.getId().equals(IHelpUIConstants.HV_BROWSER_PAGE)) { @@ -1194,10 +1227,11 @@ public void dispose() { * @see org.eclipse.ui.internal.intro.impl.parts.IStandbyContentPart#setFocus() */ public void setFocus() { - if (currentPage != null) + if (currentPage != null) { currentPage.setFocus(); - else + } else { mform.setFocus(); + } } public void update(IWorkbenchPart part, Control control) { @@ -1233,8 +1267,9 @@ private IHelpPart createPart(String id, IToolBarManager tbm, IMenuManager menuMa Composite parent = mform.getForm().getBody(); part = findPart(id); - if (part != null) + if (part != null) { return part; + } if (id.equals(HV_TOPIC_TREE)) { part = new AllTopicsPart(parent, mform.getToolkit(), tbm); @@ -1307,8 +1342,9 @@ public void showURL(final String url) { } public void showURL(String url, boolean replace) { - if (url == null) + if (url == null) { return; + } if (url.startsWith("nw:")) { //$NON-NLS-1$ replace = false; url = url.substring(3); @@ -1318,16 +1354,18 @@ else if (url.startsWith("open:")) { //$NON-NLS-1$ int qloc = url.indexOf('?'); String engineId = url.substring(col+1, qloc); EngineDescriptor desc = getEngineManager().findEngine(engineId); - if (desc==null) + if (desc==null) { return; + } HashMap args = new HashMap<>(); HelpURLConnection.parseQuery(url.substring(qloc+1), args); ((ISearchEngine2)desc.getEngine()).open((String)args.get("id")); //$NON-NLS-1$ return; } if (replace) { - if (openInternalBrowser(url)) + if (openInternalBrowser(url)) { return; + } } showExternalURL(url); } @@ -1358,9 +1396,9 @@ private boolean openInternalBrowser(String url) { } public void showExternalURL(String url) { - if (isHelpResource(url)) + if (isHelpResource(url)) { PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(url); - else { + } else { try { String aurl = BaseHelpSystem.resolve(url, true).toString(); /* @@ -1379,20 +1417,23 @@ public void showExternalURL(String url) { } public IHelpPart findPart(String id) { - if (mform == null) + if (mform == null) { return null; + } IFormPart[] parts = mform.getParts(); for (int i = 0; i < parts.length; i++) { IHelpPart part = (IHelpPart) parts[i]; - if (part.getId().equals(id)) + if (part.getId().equals(id)) { return part; + } } return null; } public boolean isHelpResource(String url) { - if (url == null || !url.contains("://")) //$NON-NLS-1$ + if (url == null || !url.contains("://")) { //$NON-NLS-1$ return true; + } return false; } @@ -1407,8 +1448,9 @@ private void contextMenuAboutToShow(IMenuManager manager) { break; } } - if (hasContext) + if (hasContext) { manager.add(new Separator()); + } manager.add(backAction); manager.add(nextAction); manager.add(new Separator()); @@ -1426,8 +1468,9 @@ private void contributeToDropDownMenu(IMenuManager manager) { private void addPageAction(IMenuManager manager, final String pageId) { // String cid = getCurrentPageId(); HelpPartPage page = findPage(pageId); - if (page == null) + if (page == null) { return; + } Action action = new Action(pageId, IAction.AS_CHECK_BOX) { @Override @@ -1438,9 +1481,10 @@ public void run() { }; action.setText(page.getText()); String iconId = page.getIconId(); - if (iconId != null) + if (iconId != null) { action.setImageDescriptor(HelpUIResources .getImageDescriptor(iconId)); + } manager.add(action); page.pageAction = action; } @@ -1489,8 +1533,9 @@ void unhookFormText(FormText text) { } boolean fillFormContextMenu(FormText text, IMenuManager manager) { - if (fillOpenActions(text, manager)) + if (fillOpenActions(text, manager)) { manager.add(new Separator()); + } manager.add(copyAction); copyAction.setTarget(text); if (text.getSelectedLinkHref() != null) { @@ -1506,15 +1551,14 @@ IAction getCopyAction() { } private String getHref(Object target) { - if (target instanceof ISelectionProvider) { - ISelectionProvider provider = (ISelectionProvider) target; + if (target instanceof ISelectionProvider provider) { IStructuredSelection ssel = (IStructuredSelection) provider .getSelection(); Object obj = ssel.getFirstElement(); - if (obj instanceof IToc) + if (obj instanceof IToc) { return null; - if (obj instanceof IHelpResource) { - IHelpResource res = (IHelpResource) obj; + } + if (obj instanceof IHelpResource res) { return res.getHref(); } if (obj instanceof IIndexEntry) { @@ -1523,33 +1567,32 @@ private String getHref(Object target) { * it represents the topic by itself */ IHelpResource[] topics = ((IIndexEntry) obj).getTopics(); - if (topics.length == 1) + if (topics.length == 1) { return topics[0].getHref(); + } return null; } - } else if (target instanceof FormText) { - FormText text = (FormText) target; + } else if (target instanceof FormText text) { Object href = text.getSelectedLinkHref(); - if (href != null) + if (href != null) { return href.toString(); + } } return null; } private IHelpResource getResource(Object target) { - if (target instanceof ISelectionProvider) { - ISelectionProvider provider = (ISelectionProvider) target; + if (target instanceof ISelectionProvider provider) { IStructuredSelection ssel = (IStructuredSelection) provider .getSelection(); Object obj = ssel.getFirstElement(); if (obj instanceof ITopic) { return (ITopic) obj; - } else if (obj instanceof IIndexEntry) { + } else if (obj instanceof IIndexEntry entry) { /* * if index entry has single topic * it represents the topic by itself */ - IIndexEntry entry = (IIndexEntry) obj; IHelpResource[] topics = entry.getTopics(); if (topics.length == 1) { final String href = topics[0].getHref(); @@ -1571,8 +1614,7 @@ public String getLabel() { } else if (obj instanceof IHelpResource) { return (IHelpResource) obj; } - } else if (target instanceof FormText) { - FormText text = (FormText) target; + } else if (target instanceof FormText text) { String rawHref = text.getSelectedLinkHref().toString(); final String href = rawHref.startsWith("open") ? rawHref : //$NON-NLS-1$ LinkUtil.stripParams(text.getSelectedLinkHref().toString()); @@ -1612,14 +1654,16 @@ private void doBookmark(Object target) { private void doOpen(Object target, boolean replace) { String href = getHref(target); - if (href != null) + if (href != null) { showURL(href, replace); + } } private void doOpenInHelp(Object target) { String href = getHref(target); - if (href != null) + if (href != null) { showURL(href, false); + } } /** @@ -1664,8 +1708,9 @@ void handleLinkEntered(HyperlinkEvent e) { if (mng != null) { String label = e.getLabel(); String href = (String) e.getHref(); - if (href != null && href.startsWith("__")) //$NON-NLS-1$ + if (href != null && href.startsWith("__")) { //$NON-NLS-1$ href = null; + } if (href != null) { href = URLDecoder.decode(href, StandardCharsets.UTF_8); // Next line unnecessary following fix for Bug 78746 @@ -1675,33 +1720,37 @@ void handleLinkEntered(HyperlinkEvent e) { String message = NLS.bind(Messages.ReusableHelpPart_status, label, href); mng.setMessage(message); - } else if (label != null) + } else if (label != null) { mng.setMessage(label); - else + } else { mng.setMessage(href); + } } } private IStatusLineManager getRoot(IStatusLineManager mng) { while (mng != null) { - if (mng instanceof SubStatusLineManager) { - SubStatusLineManager smng = (SubStatusLineManager) mng; + if (mng instanceof SubStatusLineManager smng) { IContributionManager parent = smng.getParent(); - if (parent == null) + if (parent == null) { return smng; - if (!(parent instanceof IStatusLineManager)) + } + if (!(parent instanceof IStatusLineManager)) { return smng; + } mng = (IStatusLineManager) parent; - } else + } else { break; + } } return mng; } void handleLinkExited(HyperlinkEvent e) { IStatusLineManager mng = getRoot(getStatusLineManager()); - if (mng != null) + if (mng != null) { mng.setMessage(null); + } } @@ -1745,8 +1794,9 @@ public void saveState(IMemento memento) { private String getShowAllMessage() { String message = HelpBasePlugin.getActivitySupport() .getShowAllMessage(); - if (message == null) + if (message == null) { return Messages.AskShowAll_message; + } StringBuilder buff = new StringBuilder(); int state = STATE_START; @@ -1754,18 +1804,21 @@ private String getShowAllMessage() { char c = message.charAt(i); switch (state) { case STATE_START: - if (c == '<') + if (c == '<') { state = STATE_LT; - else + } else { buff.append(c); + } break; case STATE_LT: - if (c == 'b' || c == 'B') + if (c == 'b' || c == 'B') { state = STATE_LT_B; + } break; case STATE_LT_B: - if (c == 'r' || c == 'R') + if (c == 'r' || c == 'R') { state = STATE_LT_BR; + } break; case STATE_LT_BR: if (c == '>') { diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPartHistory.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPartHistory.java index 5aab95f776d..7b823bbc203 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPartHistory.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPartHistory.java @@ -38,8 +38,9 @@ public void addEntry(HistoryEntry entry) { } } queue.add(entry); - if (queue.size()>CAPACITY) + if (queue.size()>CAPACITY) { queue.removeFirst(); + } cursor = queue.size()-1; } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceDialog.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceDialog.java index b8764ce3a4b..735bb4e640e 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceDialog.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceDialog.java @@ -114,8 +114,7 @@ protected void buttonPressed(int buttonId) { private void treeSelectionChanged(Object obj) { boolean removable = false; - if (obj instanceof ScopePreferenceManager.EnginePreferenceNode) { - ScopePreferenceManager.EnginePreferenceNode node = (ScopePreferenceManager.EnginePreferenceNode)obj; + if (obj instanceof ScopePreferenceManager.EnginePreferenceNode node) { EngineDescriptor desc = node.getDescriptor(); removable = desc.isUserDefined(); } @@ -143,8 +142,7 @@ private void doNew() { private void doDelete() { Object obj = getTreeViewer().getStructuredSelection().getFirstElement(); - if (obj instanceof ScopePreferenceManager.EnginePreferenceNode) { - ScopePreferenceManager.EnginePreferenceNode node = (ScopePreferenceManager.EnginePreferenceNode)obj; + if (obj instanceof ScopePreferenceManager.EnginePreferenceNode node) { EngineDescriptor desc = node.getDescriptor(); //ScopePreferenceManager mng = (ScopePreferenceManager)getPreferenceManager(); getTreeViewer().remove(node); @@ -153,8 +151,9 @@ private void doDelete() { } private void scheduleOperation(int action, EngineDescriptor desc) { - if (pendingOperations==null) + if (pendingOperations==null) { pendingOperations = new ArrayList<>(); + } pendingOperations.add(new PendingOperation(action, desc)); } @@ -165,10 +164,11 @@ protected void okPressed() { // process pending operations for (int i=0; i0); + } preferenceStore.save(); needsSaving = false; } @@ -182,8 +185,9 @@ public void save() { public boolean getEngineEnabled(EngineDescriptor desc) { IPreferenceStore store = getPreferenceStore(); String key = getMasterKey(desc.getId()); - if (store.contains(key)) + if (store.contains(key)) { return store.getBoolean(key); + } store.setValue(key, desc.isEnabled()); return desc.isEnabled(); } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetDialog.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetDialog.java index 60a1be8ef0e..c4481b91e7f 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetDialog.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetDialog.java @@ -190,8 +190,9 @@ private class ScopeLabelProvider extends LabelProvider { @Override public String getText(Object obj) { String name = findNewName((ScopeSet)obj); - if (name!=null) + if (name!=null) { return name; + } return ((ScopeSet)obj).getName(); } private String findNewName(ScopeSet set) { @@ -306,8 +307,9 @@ private void createEditingButtons(Composite composite) { } public ScopeSet getActiveSet() { - if (result!=null && result.length>0) + if (result!=null && result.length>0) { return (ScopeSet)result[0]; + } return null; } @@ -434,10 +436,11 @@ private void doRename() { String oldName = rop!=null?rop.newName:set.getName(); String newName = getNewName(oldName, true); if (newName!=null) { - if (rop!=null) + if (rop!=null) { rop.newName = newName; - else + } else { scheduleOperation(new RenameOperation(set, newName)); + } viewer.update(set, null); updateButtons(); } @@ -477,8 +480,9 @@ private void doRemove() { } private void scheduleOperation(PendingOperation op) { - if (operations==null) + if (operations==null) { operations = new ArrayList<>(); + } operations.add(op); } @@ -496,8 +500,9 @@ private PendingOperation findOperation(ScopeSet set, Class type) { for (int i=0; i result = new ArrayList<>(); for (int i = 0; i < sets.size(); i++) { ScopeSet set = sets.get(i); - if (set.isImplicit() == implicit) + if (set.isImplicit() == implicit) { result.add(set); - if (!implicit && set.isImplicit() && activeSet==set) + } + if (!implicit && set.isImplicit() && activeSet==set) { result.add(set); + } } return result.toArray(new ScopeSet[result.size()]); } @@ -124,8 +129,9 @@ private void loadScopeSets() { if (loc != -1) { ScopeSet set = new ScopeSet(name.substring(0, loc)); sets.add(set); - if (set.isDefault()) + if (set.isDefault()) { defSet = set; + } continue; } loc = name.lastIndexOf(HistoryScopeSet.EXT); @@ -162,8 +168,9 @@ public ScopeSet getActiveSet() { if (activeSet == null) { return sets.get(0); } - if (!activeSet.isImplicit()) + if (!activeSet.isImplicit()) { lastExplicitSet = activeSet; + } } return activeSet; } @@ -174,11 +181,12 @@ public ScopeSet findSet(String name) { public HistoryScopeSet findSearchSet(String expression) { for (ScopeSet set : sets) { - if (!set.isImplicit() || !(set instanceof HistoryScopeSet)) + if (!set.isImplicit() || !(set instanceof HistoryScopeSet sset)) { continue; - HistoryScopeSet sset = (HistoryScopeSet) set; - if (sset.getExpression().equals(expression)) + } + if (sset.getExpression().equals(expression)) { return sset; + } } return null; } @@ -187,13 +195,16 @@ public ScopeSet findSet(String name, boolean implicit) { ScopeSet defaultSet = null; for (ScopeSet set : sets) { if (name != null && set.isImplicit() == implicit) { - if (set.getName().equals(name)) + if (set.getName().equals(name)) { return set; - } else if (set.isDefault()) + } + } else if (set.isDefault()) { defaultSet = set; + } } - if (!implicit) + if (!implicit) { return defaultSet; + } return null; } } \ No newline at end of file diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchPart.java index 7f543d7333b..f3982603899 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchPart.java @@ -77,8 +77,9 @@ public void update(Observable arg0, Object arg1) { scopeSetLink.setText(set.getName()); scopeSetManager.setActiveSet(set); scopeSection.layout(); - if (parent != null) + if (parent != null) { parent.reflow(); + } } } @@ -158,8 +159,9 @@ public void done(IJobChangeEvent event) { if (searchJobs.length == 0) { // search finished searchInProgress = false; - if (container.isDisposed()) + if (container.isDisposed()) { return; + } container.getDisplay().asyncExec(this); SearchResultsPart results = (SearchResultsPart) parent .findPart(IHelpUIConstants.HV_FSEARCH_RESULT); @@ -187,12 +189,14 @@ public void sleeping(IJobChangeEvent event) { @Override public void run() { searchWordCombo.getControl().setEnabled(!searchInProgress); - if (!searchInProgress) + if (!searchInProgress) { goButton.setEnabled(true); - if (searchInProgress) + } + if (searchInProgress) { goButton.setText(Messages.SearchPart_stop); - else + } else { goButton.setText(Messages.SearchPart_go); + } parent.getForm().getForm().setBusy(searchInProgress); goButton.getParent().layout(); } @@ -390,18 +394,17 @@ private void setActiveScopeSet(ScopeSet set) { scopeSetManager.setActiveSet(set); updateMasters(set); scopeSection.layout(); - if (parent != null) + if (parent != null) { parent.reflow(); + } } private void updateMasters(ScopeSet set) { Control[] children = ((Composite) scopeSection.getClient()).getChildren(); for (Control child : children) { - if (child instanceof Button) { - Button master = (Button) child; + if (child instanceof Button master) { Object data = master.getData(); - if (data != null && data instanceof EngineDescriptor) { - EngineDescriptor ed = (EngineDescriptor) data; + if (data != null && data instanceof EngineDescriptor ed) { master.setSelection(set.getEngineEnabled(ed)); } } @@ -471,8 +474,9 @@ private void removeEngine(EngineDescriptor desc) { reflowNeeded = true; } } - if (reflowNeeded) + if (reflowNeeded) { parent.reflow(); + } } private void updateEngine(EngineDescriptor desc) { @@ -491,8 +495,9 @@ private void updateEngine(EngineDescriptor desc) { break; } } - if (reflowNeeded) + if (reflowNeeded) { parent.reflow(); + } } public void startSearch(String text) { @@ -523,23 +528,26 @@ private void updateSearchCombo(HistoryScopeSet current) { // items.add(current.getExpression()); for (int i = sets.length - 1; i >= 0; i--) { HistoryScopeSet sset = (HistoryScopeSet) sets[i]; - if (current != null && sset == current) + if (current != null && sset == current) { continue; - if (sets.length - i > COMBO_HISTORY_SIZE) + } + if (sets.length - i > COMBO_HISTORY_SIZE) { toDelete.add(sset); + } items.add(sset.getExpression()); } for (HistoryScopeSet sset : toDelete) { scopeSetManager.remove(sset); } - if (items.size() > 0) + if (items.size() > 0) { searchWordCombo.setItems(items.toArray(new String[items.size()])); + } } private void handleButtonPressed() { - if (searchWordCombo.getControl().isEnabled()) + if (searchWordCombo.getControl().isEnabled()) { doSearch(searchWordCombo.getText()); - else { + } else { goButton.setEnabled(false); stop(); } @@ -553,15 +561,17 @@ private void doSearch(String text, boolean fromHistory) { ScopeSet set = scopeSetManager.getActiveSet(); if (!fromHistory && set instanceof HistoryScopeSet) { String setExpression = ((HistoryScopeSet) set).getExpression(); - if (setExpression.equals(text)) + if (setExpression.equals(text)) { fromHistory = true; + } } if (!fromHistory) { storeSearchHistory(text); boolean switchedSet = scopeSetManager.restoreLastExplicitSet(); set = scopeSetManager.getActiveSet(); - if (switchedSet) + if (switchedSet) { setActiveScopeSet(set); + } } ArrayList entries = new ArrayList<>(); final SearchResultsPart results = (SearchResultsPart) parent @@ -625,8 +635,9 @@ public void error(IStatus status) { eds.add(ed); } } - if (entries.isEmpty()) + if (entries.isEmpty()) { return; + } FederatedSearchEntry[] array = entries.toArray(new FederatedSearchEntry[entries.size()]); if (scopeSection.isExpanded()) { scopeSection.setExpanded(false); @@ -668,8 +679,9 @@ private void doChangeScopeSet() { @Override public void dispose() { ScopeSet activeSet = scopeSetManager.getActiveSet(); - if (activeSet != null) + if (activeSet != null) { activeSet.save(); + } if (engineObserver != null) { parent.getEngineManager().deleteObserver(engineObserver); engineObserver = null; @@ -696,16 +708,18 @@ public void init(ReusableHelpPart parent, String id, IMemento memento) { loadEngines(filteringGroup, parent.getForm().getToolkit()); createAdvancedLink(filteringGroup, parent.getForm().getToolkit()); parent.hookFormText(searchWordText); - if (memento != null) + if (memento != null) { restorePart(memento); + } } private void restorePart(IMemento memento) { String setName = memento.getString("activeSet"); //$NON-NLS-1$ if (setName != null) { ScopeSet sset = scopeSetManager.findSet(setName); - if (sset != null) + if (sset != null) { scopeSetManager.setActiveSet(sset); + } } String expression = memento.getString("expression"); //$NON-NLS-1$ if (expression != null && expression.length() > 0) { @@ -753,8 +767,9 @@ public void setFocus() { @Override public IAction getGlobalAction(String id) { - if (id.equals(ActionFactory.COPY.getId())) + if (id.equals(ActionFactory.COPY.getId())) { return parent.getCopyAction(); + } return null; } @@ -778,8 +793,9 @@ public void refilter() { @Override public void saveState(IMemento memento) { ScopeSet sset = scopeSetManager.getActiveSet(); - if (sset != null) + if (sset != null) { memento.putString("activeSet", sset.getName()); //$NON-NLS-1$ + } memento.putString("expression", searchWordCombo.getText()); //$NON-NLS-1$ } } diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchResultsPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchResultsPart.java index 12b7a925b1a..354549101e3 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchResultsPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchResultsPart.java @@ -234,13 +234,15 @@ void startNewSearch(String phrase, ArrayList eds) { //separator.setVisible(true); // locate local help engine and add it first EngineDescriptor localHelp = findLocalHelp(eds); - if (localHelp!=null) + if (localHelp!=null) { add(localHelp); + } // add engines other than local help for (int i = 0; i < eds.size(); i++) { EngineDescriptor ed = eds.get(i); - if (ed==localHelp) + if (ed==localHelp) { continue; + } add(ed); } reflow(); @@ -249,8 +251,9 @@ void startNewSearch(String phrase, ArrayList eds) { private EngineDescriptor findLocalHelp(ArrayList eds) { for (int i=0; i SeeAlsoPart.this.helpPart.showPage((String) e.getHref(), true)); } }; - if ((helpPart.getStyle() & ReusableHelpPart.ALL_TOPICS) != 0) + if ((helpPart.getStyle() & ReusableHelpPart.ALL_TOPICS) != 0) { addPageLink(container, toolkit, Messages.SeeAlsoPart_allTopics, IHelpUIConstants.HV_ALL_TOPICS_PAGE, IHelpUIConstants.IMAGE_ALL_TOPICS, listener); + } if ((helpPart.getStyle() & ReusableHelpPart.SEARCH) != 0) { addPageLink(container, toolkit, Messages.SeeAlsoPart_search, IHelpUIConstants.HV_FSEARCH_PAGE, IHelpUIConstants.IMAGE_HELP_SEARCH, listener); @@ -125,8 +126,9 @@ public void linkActivated(final HyperlinkEvent e) { private void addPageLink(Composite container, FormToolkit toolkit, String text, String id, String imgRef, IHyperlinkListener listener) { String cid = helpPart.getCurrentPageId(); - if (cid!=null && cid.equals(id)) + if (cid!=null && cid.equals(id)) { return; + } ImageHyperlink link = new ImageHyperlink(container, SWT.WRAP|toolkit.getOrientation()); toolkit.adapt(link, true, true); link.setImage(HelpUIResources.getImage(imgRef)); @@ -170,8 +172,9 @@ public String getId() { @Override public void setVisible(boolean visible) { container.setVisible(visible); - if (visible) + if (visible) { markStale(); + } } @Override @@ -194,8 +197,9 @@ public boolean hasFocusControl(Control control) { @Override public IAction getGlobalAction(String id) { - if (id.equals(ActionFactory.COPY.getId())) + if (id.equals(ActionFactory.COPY.getId())) { return helpPart.getCopyAction(); + } return null; } @@ -205,8 +209,9 @@ public void stop() { @Override public void refresh() { - if (linkContainer!=null && helpPart.getCurrentPageId()!=null) + if (linkContainer!=null && helpPart.getCurrentPageId()!=null) { updateLinks(helpPart.getCurrentPageId()); + } super.refresh(); } @@ -224,7 +229,8 @@ public void saveState(IMemento memento) { @Override public void setFocus() { - if (linkContainer!=null) + if (linkContainer!=null) { linkContainer.setFocus(); + } } }