diff options
author | Alexander Kurtakov | 2019-07-16 08:33:03 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2019-07-16 08:33:03 +0000 |
commit | cf6cb54248d076dea55f5833d0d4aed913831aca (patch) | |
tree | 290d601c486ebab95542c7e72c3d9551e13a38fc | |
parent | f89247f28aa8cdeaffa29e40a2187b788f118e88 (diff) | |
download | rt.equinox.p2-cf6cb54248d076dea55f5833d0d4aed913831aca.tar.gz rt.equinox.p2-cf6cb54248d076dea55f5833d0d4aed913831aca.tar.xz rt.equinox.p2-cf6cb54248d076dea55f5833d0d4aed913831aca.zip |
Stricter warnings and fixes for them in examples.rcp.cloud.
Change-Id: I73d90c81c93a336417553fb5e2d211f7ccfaad2a
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
12 files changed, 198 insertions, 194 deletions
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/.settings/org.eclipse.jdt.core.prefs index e3d35e847..d07cba60a 100644 --- a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/.settings/org.eclipse.jdt.core.prefs +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/.settings/org.eclipse.jdt.core.prefs @@ -26,9 +26,9 @@ org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore @@ -39,14 +39,14 @@ org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore @@ -68,8 +68,8 @@ org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled @@ -80,7 +80,7 @@ org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore @@ -92,10 +92,10 @@ org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=disabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=disabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java index 202871060..e5c6f3724 100644 --- a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java @@ -17,15 +17,16 @@ public class Activator extends AbstractUIPlugin { // The shared instance private static Activator plugin; - + ServiceRegistration<Policy> policyRegistration; - + /** * The constructor */ public Activator() { } + @Override public void start(BundleContext context) throws Exception { super.start(context); plugin = this; @@ -33,13 +34,14 @@ public class Activator extends AbstractUIPlugin { registerP2Policy(context); } + @Override public void stop(BundleContext context) throws Exception { plugin = null; // XXX unregister the UI policy policyRegistration.unregister(); policyRegistration = null; super.stop(context); - + } /** @@ -52,8 +54,8 @@ public class Activator extends AbstractUIPlugin { } /** - * Returns an image descriptor for the image file at the given - * plug-in relative path + * Returns an image descriptor for the image file at the given plug-in relative + * path * * @param path the path * @return the image descriptor @@ -61,7 +63,7 @@ public class Activator extends AbstractUIPlugin { public static ImageDescriptor getImageDescriptor(String path) { return imageDescriptorFromPlugin(PLUGIN_ID, path); } - + private void registerP2Policy(BundleContext context) { policyRegistration = context.registerService(Policy.class, new CloudPolicy(), null); } diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Application.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Application.java index 463ec52e2..feb9901ae 100644 --- a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Application.java +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Application.java @@ -11,9 +11,7 @@ import org.eclipse.ui.PlatformUI; */ public class Application implements IApplication { - /* (non-Javadoc) - * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) - */ + @Override public Object start(IApplicationContext context) { Display display = PlatformUI.createDisplay(); try { @@ -27,20 +25,15 @@ public class Application implements IApplication { } } - /* (non-Javadoc) - * @see org.eclipse.equinox.app.IApplication#stop() - */ + @Override public void stop() { final IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench == null) return; final Display display = workbench.getDisplay(); - display.syncExec(new Runnable() { - @Override - public void run() { - if (!display.isDisposed()) - workbench.close(); - } + display.syncExec(() -> { + if (!display.isDisposed()) + workbench.close(); }); } } diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationActionBarAdvisor.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationActionBarAdvisor.java index 8064f403c..db33963f5 100644 --- a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationActionBarAdvisor.java +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationActionBarAdvisor.java @@ -18,91 +18,93 @@ import org.eclipse.ui.application.ActionBarAdvisor; import org.eclipse.ui.application.IActionBarConfigurer; /** - * An action bar advisor is responsible for creating, adding, and disposing of the - * actions added to a workbench window. Each window will be populated with + * An action bar advisor is responsible for creating, adding, and disposing of + * the actions added to a workbench window. Each window will be populated with * new actions. */ public class ApplicationActionBarAdvisor extends ActionBarAdvisor { - // Actions - important to allocate these only in makeActions, and then use them - // in the fill methods. This ensures that the actions aren't recreated - // when fillActionBars is called with FILL_PROXY. - private IWorkbenchAction exitAction; - private IWorkbenchAction aboutAction; - private IWorkbenchAction newWindowAction; - // XXX we want to show preferences - private IWorkbenchAction preferencesAction; - private OpenViewAction openViewAction; - private Action messagePopupAction; - - public static final String M_TOOLS = "tools"; - - - public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { - super(configurer); - } - - protected void makeActions(final IWorkbenchWindow window) { - // Creates the actions and registers them. - // Registering is needed to ensure that key bindings work. - // The corresponding commands keybindings are defined in the plugin.xml file. - // Registering also provides automatic disposal of the actions when - // the window is closed. - - exitAction = ActionFactory.QUIT.create(window); - register(exitAction); - - aboutAction = ActionFactory.ABOUT.create(window); - register(aboutAction); - - // XXX we want to show auto update preferences - preferencesAction = ActionFactory.PREFERENCES.create(window); - register(preferencesAction); - - newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window); - register(newWindowAction); - - openViewAction = new OpenViewAction(window, "Open Another Message View", View.ID); - register(openViewAction); - - messagePopupAction = new MessagePopupAction("Open Message", window); - register(messagePopupAction); - } - - protected void fillMenuBar(IMenuManager menuBar) { - MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE); - // XXX add a tools menu - MenuManager toolsMenu = new MenuManager("&Tools", M_TOOLS); - MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP); - - menuBar.add(fileMenu); - menuBar.add(toolsMenu); - // Add a group marker indicating where action set menus will appear. - menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); - menuBar.add(helpMenu); - - // File - fileMenu.add(newWindowAction); - fileMenu.add(new Separator()); - fileMenu.add(messagePopupAction); - fileMenu.add(openViewAction); - fileMenu.add(new Separator()); - fileMenu.add(exitAction); - - // XXX add preferences to tools - toolsMenu.add(preferencesAction); - // XXX add a group for new other tools contributions - toolsMenu.add(new Separator()); - toolsMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); - - // Help - helpMenu.add(aboutAction); - } - - protected void fillCoolBar(ICoolBarManager coolBar) { - IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT); - coolBar.add(new ToolBarContributionItem(toolbar, "main")); - toolbar.add(openViewAction); - toolbar.add(messagePopupAction); - } + // Actions - important to allocate these only in makeActions, and then use them + // in the fill methods. This ensures that the actions aren't recreated + // when fillActionBars is called with FILL_PROXY. + private IWorkbenchAction exitAction; + private IWorkbenchAction aboutAction; + private IWorkbenchAction newWindowAction; + // XXX we want to show preferences + private IWorkbenchAction preferencesAction; + private OpenViewAction openViewAction; + private Action messagePopupAction; + + public static final String M_TOOLS = "tools"; + + public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { + super(configurer); + } + + @Override + protected void makeActions(final IWorkbenchWindow window) { + // Creates the actions and registers them. + // Registering is needed to ensure that key bindings work. + // The corresponding commands keybindings are defined in the plugin.xml file. + // Registering also provides automatic disposal of the actions when + // the window is closed. + + exitAction = ActionFactory.QUIT.create(window); + register(exitAction); + + aboutAction = ActionFactory.ABOUT.create(window); + register(aboutAction); + + // XXX we want to show auto update preferences + preferencesAction = ActionFactory.PREFERENCES.create(window); + register(preferencesAction); + + newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window); + register(newWindowAction); + + openViewAction = new OpenViewAction(window, "Open Another Message View", View.ID); + register(openViewAction); + + messagePopupAction = new MessagePopupAction("Open Message", window); + register(messagePopupAction); + } + + @Override + protected void fillMenuBar(IMenuManager menuBar) { + MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE); + // XXX add a tools menu + MenuManager toolsMenu = new MenuManager("&Tools", M_TOOLS); + MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP); + + menuBar.add(fileMenu); + menuBar.add(toolsMenu); + // Add a group marker indicating where action set menus will appear. + menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + menuBar.add(helpMenu); + + // File + fileMenu.add(newWindowAction); + fileMenu.add(new Separator()); + fileMenu.add(messagePopupAction); + fileMenu.add(openViewAction); + fileMenu.add(new Separator()); + fileMenu.add(exitAction); + + // XXX add preferences to tools + toolsMenu.add(preferencesAction); + // XXX add a group for new other tools contributions + toolsMenu.add(new Separator()); + toolsMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + + // Help + helpMenu.add(aboutAction); + } + + @Override + protected void fillCoolBar(ICoolBarManager coolBar) { + IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT); + coolBar.add(new ToolBarContributionItem(toolbar, "main")); + toolbar.add(openViewAction); + toolbar.add(messagePopupAction); + } } diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationWorkbenchAdvisor.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationWorkbenchAdvisor.java index 717a4fa7c..893d9979e 100644 --- a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationWorkbenchAdvisor.java +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationWorkbenchAdvisor.java @@ -5,17 +5,19 @@ import org.eclipse.ui.application.WorkbenchAdvisor; import org.eclipse.ui.application.WorkbenchWindowAdvisor; /** - * This workbench advisor creates the window advisor, and specifies - * the perspective id for the initial window. + * This workbench advisor creates the window advisor, and specifies the + * perspective id for the initial window. */ public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { - - public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { - return new ApplicationWorkbenchWindowAdvisor(configurer); - } + @Override + public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + return new ApplicationWorkbenchWindowAdvisor(configurer); + } + + @Override public String getInitialWindowPerspectiveId() { return Perspective.ID; - } - + } + } diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationWorkbenchWindowAdvisor.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationWorkbenchWindowAdvisor.java index a71e1b3f2..fc30c6228 100644 --- a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationWorkbenchWindowAdvisor.java +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationWorkbenchWindowAdvisor.java @@ -8,23 +8,25 @@ import org.eclipse.ui.application.WorkbenchWindowAdvisor; public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { - public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { - super(configurer); - } + public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + super(configurer); + } - public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { - return new ApplicationActionBarAdvisor(configurer); - } - - public void preWindowOpen() { - IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); - configurer.setInitialSize(new Point(600, 400)); - configurer.setShowCoolBar(true); - // XXX Set the status line and progress indicator so that update - // information can be shown there - configurer.setShowStatusLine(true); + @Override + public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { + return new ApplicationActionBarAdvisor(configurer); + } + + @Override + public void preWindowOpen() { + IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); + configurer.setInitialSize(new Point(600, 400)); + configurer.setShowCoolBar(true); + // XXX Set the status line and progress indicator so that update + // information can be shown there + configurer.setShowStatusLine(true); configurer.setShowProgressIndicator(true); - } - + } + } diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/MessagePopupAction.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/MessagePopupAction.java index 85324bae0..347a11660 100644 --- a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/MessagePopupAction.java +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/MessagePopupAction.java @@ -4,22 +4,23 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.ui.IWorkbenchWindow; - public class MessagePopupAction extends Action { - private final IWorkbenchWindow window; + private final IWorkbenchWindow window; - MessagePopupAction(String text, IWorkbenchWindow window) { - super(text); - this.window = window; - // The id is used to refer to the action in a menu or toolbar - setId(ICommandIds.CMD_OPEN_MESSAGE); - // Associate the action with a pre-defined command, to allow key bindings. - setActionDefinitionId(ICommandIds.CMD_OPEN_MESSAGE); - setImageDescriptor(org.eclipse.equinox.p2.examples.rcp.cloud.Activator.getImageDescriptor("/icons/sample3.gif")); - } + MessagePopupAction(String text, IWorkbenchWindow window) { + super(text); + this.window = window; + // The id is used to refer to the action in a menu or toolbar + setId(ICommandIds.CMD_OPEN_MESSAGE); + // Associate the action with a pre-defined command, to allow key bindings. + setActionDefinitionId(ICommandIds.CMD_OPEN_MESSAGE); + setImageDescriptor( + org.eclipse.equinox.p2.examples.rcp.cloud.Activator.getImageDescriptor("/icons/sample3.gif")); + } - public void run() { - MessageDialog.openInformation(window.getShell(), "Open", "Open Message Dialog!"); - } + @Override + public void run() { + MessageDialog.openInformation(window.getShell(), "Open", "Open Message Dialog!"); + } }
\ No newline at end of file diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/NavigationView.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/NavigationView.java index bd5538cca..ce4028883 100644 --- a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/NavigationView.java +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/NavigationView.java @@ -2,7 +2,6 @@ package org.eclipse.equinox.p2.examples.rcp.cloud; import java.util.ArrayList; -import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.TreeViewer; @@ -71,7 +70,7 @@ public class NavigationView extends ViewPart { } } - class ViewContentProvider implements IStructuredContentProvider, ITreeContentProvider { + class ViewContentProvider implements ITreeContentProvider { @Override public void inputChanged(Viewer v, Object oldInput, Object newInput) { diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/OpenViewAction.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/OpenViewAction.java index 317e07342..3c732aebd 100644 --- a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/OpenViewAction.java +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/OpenViewAction.java @@ -6,26 +6,27 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; - public class OpenViewAction extends Action { - + private final IWorkbenchWindow window; private int instanceNum = 0; private final String viewId; - + public OpenViewAction(IWorkbenchWindow window, String label, String viewId) { this.window = window; this.viewId = viewId; - setText(label); - // The id is used to refer to the action in a menu or toolbar + setText(label); + // The id is used to refer to the action in a menu or toolbar setId(ICommandIds.CMD_OPEN); - // Associate the action with a pre-defined command, to allow key bindings. + // Associate the action with a pre-defined command, to allow key bindings. setActionDefinitionId(ICommandIds.CMD_OPEN); - setImageDescriptor(org.eclipse.equinox.p2.examples.rcp.cloud.Activator.getImageDescriptor("/icons/sample2.gif")); + setImageDescriptor( + org.eclipse.equinox.p2.examples.rcp.cloud.Activator.getImageDescriptor("/icons/sample2.gif")); } - + + @Override public void run() { - if(window != null) { + if (window != null) { try { window.getActivePage().showView(viewId, Integer.toString(instanceNum++), IWorkbenchPage.VIEW_ACTIVATE); } catch (PartInitException e) { diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Perspective.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Perspective.java index 63299ce7e..caaf4ff75 100644 --- a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Perspective.java +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Perspective.java @@ -11,15 +11,16 @@ public class Perspective implements IPerspectiveFactory { */ public static final String ID = "org.eclipse.equinox.p2.examples.rcp.cloud.perspective"; + @Override public void createInitialLayout(IPageLayout layout) { String editorArea = layout.getEditorArea(); layout.setEditorAreaVisible(false); - - layout.addStandaloneView(NavigationView.ID, false, IPageLayout.LEFT, 0.25f, editorArea); + + layout.addStandaloneView(NavigationView.ID, false, IPageLayout.LEFT, 0.25f, editorArea); IFolderLayout folder = layout.createFolder("messages", IPageLayout.TOP, 0.5f, editorArea); folder.addPlaceholder(View.ID + ":*"); folder.addView(View.ID); - + layout.getViewLayout(NavigationView.ID).setCloseable(false); } } diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/View.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/View.java index d215e5b2c..ce90d6440 100644 --- a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/View.java +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/View.java @@ -17,7 +17,8 @@ import org.eclipse.ui.part.ViewPart; public class View extends ViewPart { public static final String ID = "org.eclipse.equinox.p2.examples.rcp.cloud.view"; - + + @Override public void createPartControl(Composite parent) { Composite top = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); @@ -26,34 +27,37 @@ public class View extends ViewPart { top.setLayout(layout); // top banner Composite banner = new Composite(top, SWT.NONE); - banner.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_BEGINNING, true, false)); + banner.setLayoutData( + new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_BEGINNING, true, false)); layout = new GridLayout(); layout.marginHeight = 5; layout.marginWidth = 10; layout.numColumns = 2; banner.setLayout(layout); - + // setup bold font - Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT); - + Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT); + Label l = new Label(banner, SWT.WRAP); l.setText("Subject:"); l.setFont(boldFont); l = new Label(banner, SWT.WRAP); l.setText("This is a message about the cool Eclipse RCP!"); - + l = new Label(banner, SWT.WRAP); l.setText("From:"); l.setFont(boldFont); - + final Link link = new Link(banner, SWT.NONE); link.setText("<a>nicole@mail.org</a>"); - link.addSelectionListener(new SelectionAdapter() { + link.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { - MessageDialog.openInformation(getSite().getShell(), "Not Implemented", "Imagine the address book or a new message being created now."); - } + MessageDialog.openInformation(getSite().getShell(), "Not Implemented", + "Imagine the address book or a new message being created now."); + } }); - + l = new Label(banner, SWT.WRAP); l.setText("Date:"); l.setFont(boldFont); @@ -61,17 +65,16 @@ public class View extends ViewPart { l.setText("10:34 am"); // message contents Text text = new Text(top, SWT.MULTI | SWT.WRAP); - text.setText("This RCP Application was generated from the PDE Plug-in Project wizard. This sample shows how to:\n"+ - "- add a top-level menu and toolbar with actions\n"+ - "- add keybindings to actions\n" + - "- create views that can't be closed and\n"+ - " multiple instances of the same view\n"+ - "- perspectives with placeholders for new views\n"+ - "- use the default about dialog\n"+ - "- create a product definition\n"); + text.setText( + "This RCP Application was generated from the PDE Plug-in Project wizard. This sample shows how to:\n" + + "- add a top-level menu and toolbar with actions\n" + "- add keybindings to actions\n" + + "- create views that can't be closed and\n" + " multiple instances of the same view\n" + + "- perspectives with placeholders for new views\n" + "- use the default about dialog\n" + + "- create a product definition\n"); text.setLayoutData(new GridData(GridData.FILL_BOTH)); } + @Override public void setFocus() { } } diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreloadingRepositoryHandler.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreloadingRepositoryHandler.java index 6cd63e25a..5a039b53a 100644 --- a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreloadingRepositoryHandler.java +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreloadingRepositoryHandler.java @@ -24,9 +24,9 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; /** - * PreloadingRepositoryHandler provides background loading of - * repositories before executing the provisioning handler. - * + * PreloadingRepositoryHandler provides background loading of repositories + * before executing the provisioning handler. + * * @since 3.5 */ abstract class PreloadingRepositoryHandler extends AbstractHandler { @@ -41,6 +41,7 @@ abstract class PreloadingRepositoryHandler extends AbstractHandler { /** * Execute the command. */ + @Override public Object execute(ExecutionEvent event) { doExecuteAndLoad(); return null; @@ -48,21 +49,17 @@ abstract class PreloadingRepositoryHandler extends AbstractHandler { void doExecuteAndLoad() { if (preloadRepositories()) { - //cancel any load that is already running + // cancel any load that is already running Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY); final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(getProvisioningUI()); setLoadJobProperties(loadJob); if (waitForPreload()) { loadJob.addJobChangeListener(new JobChangeAdapter() { + @Override public void done(IJobChangeEvent event) { if (PlatformUI.isWorkbenchRunning()) if (event.getResult().isOK()) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - doExecute(loadJob); - } - }); + PlatformUI.getWorkbench().getDisplay().asyncExec(() -> doExecute(loadJob)); } } }); @@ -100,6 +97,7 @@ abstract class PreloadingRepositoryHandler extends AbstractHandler { /** * Return a shell appropriate for parenting dialogs of this handler. + * * @return a Shell */ protected Shell getShell() { |