diff options
author | Alexander Kurtakov | 2013-08-27 11:27:06 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2013-08-28 08:49:30 +0000 |
commit | 7e09454df097c2b224db9d27a91d9b1a957f241b (patch) | |
tree | f464278b6f02cd96a2601bd8b0939b4aab3d7640 /libhover | |
parent | e4ceea85090973ab589bc7a1fcb7241b8069417b (diff) | |
download | org.eclipse.linuxtools-7e09454df097c2b224db9d27a91d9b1a957f241b.tar.gz org.eclipse.linuxtools-7e09454df097c2b224db9d27a91d9b1a957f241b.tar.xz org.eclipse.linuxtools-7e09454df097c2b224db9d27a91d9b1a957f241b.zip |
libhover: Extract startup job as named inner class.
Change-Id: Ica15d0d0d65b1e5afb3c7b47e45c8fdf048f28a6
Reviewed-on: https://git.eclipse.org/r/15882
Tested-by: Hudson CI
Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
IP-Clean: Alexander Kurtakov <akurtako@redhat.com>
Tested-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'libhover')
-rw-r--r-- | libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/src/org/eclipse/linuxtools/internal/cdt/libhover/devhelp/DevHelpPlugin.java | 111 |
1 files changed, 58 insertions, 53 deletions
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/src/org/eclipse/linuxtools/internal/cdt/libhover/devhelp/DevHelpPlugin.java b/libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/src/org/eclipse/linuxtools/internal/cdt/libhover/devhelp/DevHelpPlugin.java index 49f1070364..bf86030f4c 100644 --- a/libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/src/org/eclipse/linuxtools/internal/cdt/libhover/devhelp/DevHelpPlugin.java +++ b/libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/src/org/eclipse/linuxtools/internal/cdt/libhover/devhelp/DevHelpPlugin.java @@ -40,14 +40,14 @@ public class DevHelpPlugin extends AbstractUIPlugin implements IStartup { // The plug-in ID public static final String PLUGIN_ID = "org.eclipse.linuxtools.cdt.libhover.devhelp"; //$NON-NLS-1$ - private final static String REGENERATE_MSG = "Libhover.Devhelp.Regenerate.msg"; //$NON-NLS-1$ + private static final String REGENERATE_MSG = "Libhover.Devhelp.Regenerate.msg"; //$NON-NLS-1$ // The shared instance private static DevHelpPlugin plugin; /* * (non-Javadoc) - * + * * @see * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext * ) @@ -56,61 +56,13 @@ public class DevHelpPlugin extends AbstractUIPlugin implements IStartup { public void start(BundleContext context) throws Exception { super.start(context); plugin = this; - loadDevhelp(); - } - - private void loadDevhelp() { - Job k = new Job(LibHoverMessages.getString(REGENERATE_MSG)) { - - @Override - protected IStatus run(IProgressMonitor monitor) { - IPreferenceStore ps = DevHelpPlugin.getDefault() - .getPreferenceStore(); - ParseDevHelp.DevHelpParser p = new ParseDevHelp.DevHelpParser( - ps.getString(PreferenceConstants.DEVHELP_DIRECTORY)); - LibHoverInfo hover = p.parse(monitor); - // Update the devhelp library info if it is on library list - Collection<LibHoverLibrary> libs = LibHover.getLibraries(); - for (LibHoverLibrary l : libs) { - if (l.getName().equals("devhelp")) { //$NON-NLS-1$ - l.setHoverinfo(hover); - break; - } - } - try { - // Now, output the LibHoverInfo for caching later - IPath location = LibhoverPlugin.getDefault() - .getStateLocation().append("C"); //$NON-NLS-1$ - File ldir = new File(location.toOSString()); - ldir.mkdir(); - location = location.append("devhelp.libhover"); //$NON-NLS-1$ - FileOutputStream f = new FileOutputStream( - location.toOSString()); - ObjectOutputStream out = new ObjectOutputStream(f); - out.writeObject(hover); - out.close(); - monitor.done(); - } catch (FileNotFoundException e) { - monitor.done(); - return new Status(IStatus.ERROR, DevHelpPlugin.PLUGIN_ID, - e.getLocalizedMessage(), e); - } catch (IOException e) { - monitor.done(); - return new Status(IStatus.ERROR, DevHelpPlugin.PLUGIN_ID, - e.getLocalizedMessage(), e); - } - - return Status.OK_STATUS; - } - - }; + Job k = new DevhelpStartupJob(LibHoverMessages.getString(REGENERATE_MSG)) ; k.schedule(); - } /* * (non-Javadoc) - * + * * @see * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext * ) @@ -123,7 +75,7 @@ public class DevHelpPlugin extends AbstractUIPlugin implements IStartup { /** * Returns the shared instance - * + * * @return the shared instance */ public static DevHelpPlugin getDefault() { @@ -136,4 +88,57 @@ public class DevHelpPlugin extends AbstractUIPlugin implements IStartup { // directory } + /** + * Job used to load devhelp data on startup. + * + */ + private static class DevhelpStartupJob extends Job { + + public DevhelpStartupJob(String name) { + super(name); + } + + @Override + protected IStatus run(IProgressMonitor monitor) { + IPreferenceStore ps = DevHelpPlugin.getDefault() + .getPreferenceStore(); + ParseDevHelp.DevHelpParser p = new ParseDevHelp.DevHelpParser( + ps.getString(PreferenceConstants.DEVHELP_DIRECTORY)); + LibHoverInfo hover = p.parse(monitor); + // Update the devhelp library info if it is on library list + Collection<LibHoverLibrary> libs = LibHover.getLibraries(); + for (LibHoverLibrary l : libs) { + if (l.getName().equals("devhelp")) { //$NON-NLS-1$ + l.setHoverinfo(hover); + break; + } + } + try { + // Now, output the LibHoverInfo for caching later + IPath location = LibhoverPlugin.getDefault() + .getStateLocation().append("C"); //$NON-NLS-1$ + File ldir = new File(location.toOSString()); + ldir.mkdir(); + location = location.append("devhelp.libhover"); //$NON-NLS-1$ + FileOutputStream f = new FileOutputStream( + location.toOSString()); + ObjectOutputStream out = new ObjectOutputStream(f); + out.writeObject(hover); + out.close(); + monitor.done(); + } catch (FileNotFoundException e) { + monitor.done(); + return new Status(IStatus.ERROR, DevHelpPlugin.PLUGIN_ID, + e.getLocalizedMessage(), e); + } catch (IOException e) { + monitor.done(); + return new Status(IStatus.ERROR, DevHelpPlugin.PLUGIN_ID, + e.getLocalizedMessage(), e); + } + + return Status.OK_STATUS; + } + + }; + }
\ No newline at end of file |