Revision 5bea3b87
Added by Patrick Plitzner about 7 years ago
eu.etaxonomy.taxeditor.workbench/src/eu/etaxonomy/taxeditor/workbench/Activator.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.workbench; |
|
2 |
|
|
3 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
|
4 |
import org.osgi.framework.BundleContext; |
|
5 |
|
|
6 |
/** |
|
7 |
* The activator class controls the plug-in life cycle |
|
8 |
*/ |
|
9 |
public class Activator extends AbstractUIPlugin { |
|
10 |
|
|
11 |
// The plug-in ID |
|
12 |
public static final String PLUGIN_ID = "eu.etaxonomy.taxeditor.workbench"; //$NON-NLS-1$ |
|
13 |
|
|
14 |
// The shared instance |
|
15 |
private static Activator plugin; |
|
16 |
|
|
17 |
/** |
|
18 |
* The constructor |
|
19 |
*/ |
|
20 |
public Activator() { |
|
21 |
} |
|
22 |
|
|
23 |
/* |
|
24 |
* (non-Javadoc) |
|
25 |
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) |
|
26 |
*/ |
|
27 |
public void start(BundleContext context) throws Exception { |
|
28 |
super.start(context); |
|
29 |
plugin = this; |
|
30 |
} |
|
31 |
|
|
32 |
/* |
|
33 |
* (non-Javadoc) |
|
34 |
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) |
|
35 |
*/ |
|
36 |
public void stop(BundleContext context) throws Exception { |
|
37 |
plugin = null; |
|
38 |
super.stop(context); |
|
39 |
} |
|
40 |
|
|
41 |
/** |
|
42 |
* Returns the shared instance |
|
43 |
* |
|
44 |
* @return the shared instance |
|
45 |
*/ |
|
46 |
public static Activator getDefault() { |
|
47 |
return plugin; |
|
48 |
} |
|
49 |
|
|
50 |
} |
eu.etaxonomy.taxeditor.workbench/src/eu/etaxonomy/taxeditor/workbench/OpenExternalAboutPlatformHandler.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.taxeditor.workbench; |
|
11 |
|
|
12 |
import java.net.MalformedURLException; |
|
13 |
import java.net.URL; |
|
14 |
|
|
15 |
import org.apache.log4j.Logger; |
|
16 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
17 |
import org.eclipse.ui.PartInitException; |
|
18 |
import org.eclipse.ui.PlatformUI; |
|
19 |
import org.eclipse.ui.browser.IWorkbenchBrowserSupport; |
|
20 |
|
|
21 |
/** |
|
22 |
* @author p.ciardelli |
|
23 |
* @created 04.09.2009 |
|
24 |
* @version 1.0 |
|
25 |
*/ |
|
26 |
public class OpenExternalAboutPlatformHandler { |
|
27 |
private static final Logger logger = Logger.getLogger(OpenExternalAboutPlatformHandler.class); |
|
28 |
|
|
29 |
|
|
30 |
@Execute |
|
31 |
public Object execute() { |
|
32 |
String url = "http://wp5.e-taxonomy.eu/"; |
|
33 |
|
|
34 |
try { |
|
35 |
PlatformUI.getWorkbench().getBrowserSupport().createBrowser |
|
36 |
(IWorkbenchBrowserSupport.AS_EXTERNAL, "aCustomId", "url", "url").openURL(new URL(url)); |
|
37 |
} catch (PartInitException e) { |
|
38 |
logger.error(e); |
|
39 |
throw new RuntimeException(e); |
|
40 |
} catch (MalformedURLException e) { |
|
41 |
logger.error(e); |
|
42 |
throw new RuntimeException(e); |
|
43 |
} |
|
44 |
|
|
45 |
return null; |
|
46 |
} |
|
47 |
} |
eu.etaxonomy.taxeditor.workbench/src/eu/etaxonomy/taxeditor/workbench/OpenExternalParserHelpHandler.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.taxeditor.workbench; |
|
11 |
|
|
12 |
import java.net.MalformedURLException; |
|
13 |
import java.net.URL; |
|
14 |
|
|
15 |
import org.apache.log4j.Logger; |
|
16 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
17 |
import org.eclipse.ui.PartInitException; |
|
18 |
import org.eclipse.ui.PlatformUI; |
|
19 |
import org.eclipse.ui.browser.IWorkbenchBrowserSupport; |
|
20 |
|
|
21 |
/** |
|
22 |
* <p>OpenExternalParserHelpHandler class.</p> |
|
23 |
* |
|
24 |
* @author p.ciardelli |
|
25 |
* @created 04.09.2009 |
|
26 |
* @version 1.0 |
|
27 |
*/ |
|
28 |
public class OpenExternalParserHelpHandler { |
|
29 |
private static final Logger logger = Logger.getLogger(OpenExternalParserHelpHandler.class); |
|
30 |
|
|
31 |
@Execute |
|
32 |
/** {@inheritDoc} */ |
|
33 |
public Object execute() { |
|
34 |
String url = "http://dev.e-taxonomy.eu/trac/wiki/NameParserDocumentation"; |
|
35 |
|
|
36 |
try { |
|
37 |
PlatformUI.getWorkbench().getBrowserSupport().createBrowser |
|
38 |
(IWorkbenchBrowserSupport.AS_EXTERNAL, "aCustomId", "url", "url").openURL(new URL(url)); |
|
39 |
} catch (PartInitException e) { |
|
40 |
logger.error(e); |
|
41 |
throw new RuntimeException(e); |
|
42 |
} catch (MalformedURLException e) { |
|
43 |
logger.error(e); |
|
44 |
throw new RuntimeException(e); |
|
45 |
} |
|
46 |
|
|
47 |
return null; |
|
48 |
} |
|
49 |
} |
eu.etaxonomy.taxeditor.workbench/src/eu/etaxonomy/taxeditor/workbench/update/InstallNewSoftwareHandler.java | ||
---|---|---|
1 |
/******************************************************************************* |
|
2 |
* Copyright (c) 2008, 2009 IBM Corporation and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* IBM Corporation - initial API and implementation |
|
10 |
*******************************************************************************/ |
|
11 |
package eu.etaxonomy.taxeditor.workbench.update; |
|
12 |
|
|
13 |
import org.eclipse.core.runtime.jobs.Job; |
|
14 |
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob; |
|
15 |
|
|
16 |
/** |
|
17 |
* InstallNewSoftwareHandler invokes the install wizard |
|
18 |
* |
|
19 |
* @since 3.5 |
|
20 |
*/ |
|
21 |
public class InstallNewSoftwareHandler extends PreloadingRepositoryHandler { |
|
22 |
|
|
23 |
/** |
|
24 |
* The constructor. |
|
25 |
*/ |
|
26 |
public InstallNewSoftwareHandler() { |
|
27 |
super(); |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
protected void doExecute(LoadMetadataRepositoryJob job) { |
|
32 |
getProvisioningUI().openInstallWizard(null, null, job); |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
36 |
protected boolean waitForPreload() { |
|
37 |
// If the user cannot see repositories, then we may as well wait |
|
38 |
// for existing repos to load so that content is available. |
|
39 |
// If the user can manipulate the repositories, then we don't wait, |
|
40 |
// because we don't know which ones they want to work with. |
|
41 |
return !getProvisioningUI().getPolicy().getRepositoriesVisible(); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
protected void setLoadJobProperties(Job loadJob) { |
|
46 |
super.setLoadJobProperties(loadJob); |
|
47 |
// If we are doing a background load, we do not wish to authenticate, as the |
|
48 |
// user is unaware that loading was needed |
|
49 |
if (!waitForPreload()) { |
|
50 |
loadJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_AUTHENTICATION_JOB_MARKER, Boolean.toString(true)); |
|
51 |
loadJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_REPOSITORY_EVENTS, Boolean.toString(true)); |
|
52 |
} |
|
53 |
} |
|
54 |
} |
eu.etaxonomy.taxeditor.workbench/src/eu/etaxonomy/taxeditor/workbench/update/PreloadingRepositoryHandler.java | ||
---|---|---|
1 |
/******************************************************************************* |
|
2 |
* Copyright (c) 2008, 2009 IBM Corporation and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* IBM Corporation - initial API and implementation |
|
10 |
*******************************************************************************/ |
|
11 |
package eu.etaxonomy.taxeditor.workbench.update; |
|
12 |
|
|
13 |
import org.eclipse.core.runtime.jobs.IJobChangeEvent; |
|
14 |
import org.eclipse.core.runtime.jobs.Job; |
|
15 |
import org.eclipse.core.runtime.jobs.JobChangeAdapter; |
|
16 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
17 |
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob; |
|
18 |
import org.eclipse.equinox.p2.ui.ProvisioningUI; |
|
19 |
import org.eclipse.swt.widgets.Shell; |
|
20 |
import org.eclipse.ui.PlatformUI; |
|
21 |
|
|
22 |
/** |
|
23 |
* PreloadingRepositoryHandler provides background loading of |
|
24 |
* repositories before executing the provisioning handler. |
|
25 |
* |
|
26 |
* @since 3.5 |
|
27 |
*/ |
|
28 |
abstract class PreloadingRepositoryHandler{ |
|
29 |
|
|
30 |
/** |
|
31 |
* The constructor. |
|
32 |
*/ |
|
33 |
public PreloadingRepositoryHandler() { |
|
34 |
// constructor |
|
35 |
} |
|
36 |
|
|
37 |
/** |
|
38 |
* Execute the command. |
|
39 |
*/ |
|
40 |
@Execute |
|
41 |
public Object execute() { |
|
42 |
doExecuteAndLoad(); |
|
43 |
return null; |
|
44 |
} |
|
45 |
|
|
46 |
private void doExecuteAndLoad() { |
|
47 |
if (preloadRepositories()) { |
|
48 |
//cancel any load that is already running |
|
49 |
Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY); |
|
50 |
final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(getProvisioningUI()); |
|
51 |
setLoadJobProperties(loadJob); |
|
52 |
if (waitForPreload()) { |
|
53 |
loadJob.addJobChangeListener(new JobChangeAdapter() { |
|
54 |
@Override |
|
55 |
public void done(IJobChangeEvent event) { |
|
56 |
if (PlatformUI.isWorkbenchRunning()) { |
|
57 |
if (event.getResult().isOK()) { |
|
58 |
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { |
|
59 |
@Override |
|
60 |
public void run() { |
|
61 |
doExecute(loadJob); |
|
62 |
} |
|
63 |
}); |
|
64 |
} |
|
65 |
} |
|
66 |
} |
|
67 |
}); |
|
68 |
loadJob.setUser(true); |
|
69 |
loadJob.schedule(); |
|
70 |
|
|
71 |
} else { |
|
72 |
loadJob.setSystem(true); |
|
73 |
loadJob.setUser(false); |
|
74 |
loadJob.schedule(); |
|
75 |
doExecute(null); |
|
76 |
} |
|
77 |
} else { |
|
78 |
doExecute(null); |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
protected abstract void doExecute(LoadMetadataRepositoryJob job); |
|
83 |
|
|
84 |
protected boolean preloadRepositories() { |
|
85 |
return true; |
|
86 |
} |
|
87 |
|
|
88 |
protected boolean waitForPreload() { |
|
89 |
return true; |
|
90 |
} |
|
91 |
|
|
92 |
protected void setLoadJobProperties(Job loadJob) { |
|
93 |
loadJob.setProperty(LoadMetadataRepositoryJob.ACCUMULATE_LOAD_ERRORS, Boolean.toString(true)); |
|
94 |
} |
|
95 |
|
|
96 |
protected ProvisioningUI getProvisioningUI() { |
|
97 |
return ProvisioningUI.getDefaultUI(); |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Return a shell appropriate for parenting dialogs of this handler. |
|
102 |
* @return a Shell |
|
103 |
*/ |
|
104 |
protected Shell getShell() { |
|
105 |
return PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(); |
|
106 |
} |
|
107 |
} |
eu.etaxonomy.taxeditor.workbench/src/eu/etaxonomy/taxeditor/workbench/update/UpdateHandler.java | ||
---|---|---|
1 |
/******************************************************************************* |
|
2 |
* Copyright (c) 2007, 2009 IBM Corporation and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* IBM Corporation - initial API and implementation |
|
10 |
*******************************************************************************/ |
|
11 |
package eu.etaxonomy.taxeditor.workbench.update; |
|
12 |
|
|
13 |
import org.eclipse.equinox.internal.p2.ui.dialogs.UpdateSingleIUWizard; |
|
14 |
import org.eclipse.equinox.p2.operations.RepositoryTracker; |
|
15 |
import org.eclipse.equinox.p2.operations.UpdateOperation; |
|
16 |
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob; |
|
17 |
import org.eclipse.jface.wizard.WizardDialog; |
|
18 |
|
|
19 |
/** |
|
20 |
* UpdateHandler invokes the check for updates UI |
|
21 |
* |
|
22 |
* @since 3.4 |
|
23 |
*/ |
|
24 |
public class UpdateHandler extends PreloadingRepositoryHandler { |
|
25 |
|
|
26 |
boolean hasNoRepos = false; |
|
27 |
|
|
28 |
@Override |
|
29 |
protected void doExecute(LoadMetadataRepositoryJob job) { |
|
30 |
if (hasNoRepos) { |
|
31 |
return; |
|
32 |
} |
|
33 |
UpdateOperation operation = getProvisioningUI().getUpdateOperation(null, null); |
|
34 |
|
|
35 |
|
|
36 |
// check for updates |
|
37 |
operation.resolveModal(null); |
|
38 |
if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) { |
|
39 |
if (UpdateSingleIUWizard.validFor(operation)) { |
|
40 |
// Special case for only updating a single root |
|
41 |
UpdateSingleIUWizard wizard = new UpdateSingleIUWizard(getProvisioningUI(), operation); |
|
42 |
WizardDialog dialog = new WizardDialog(getShell(), wizard); |
|
43 |
dialog.create(); |
|
44 |
dialog.open(); |
|
45 |
} else { |
|
46 |
// Open the normal version of the update wizard |
|
47 |
getProvisioningUI().openUpdateWizard(false, operation, job); |
|
48 |
} |
|
49 |
} |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
protected boolean preloadRepositories() { |
|
54 |
hasNoRepos = false; |
|
55 |
RepositoryTracker repoMan = getProvisioningUI().getRepositoryTracker(); |
|
56 |
if (repoMan.getKnownRepositories(getProvisioningUI().getSession()).length == 0) { |
|
57 |
hasNoRepos = true; |
|
58 |
return false; |
|
59 |
} |
|
60 |
return super.preloadRepositories(); |
|
61 |
} |
|
62 |
} |
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/Activator.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.workbench; |
|
2 |
|
|
3 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
|
4 |
import org.osgi.framework.BundleContext; |
|
5 |
|
|
6 |
/** |
|
7 |
* The activator class controls the plug-in life cycle |
|
8 |
*/ |
|
9 |
public class Activator extends AbstractUIPlugin { |
|
10 |
|
|
11 |
// The plug-in ID |
|
12 |
public static final String PLUGIN_ID = "eu.etaxonomy.taxeditor.workbench"; //$NON-NLS-1$ |
|
13 |
|
|
14 |
// The shared instance |
|
15 |
private static Activator plugin; |
|
16 |
|
|
17 |
/** |
|
18 |
* The constructor |
|
19 |
*/ |
|
20 |
public Activator() { |
|
21 |
} |
|
22 |
|
|
23 |
/* |
|
24 |
* (non-Javadoc) |
|
25 |
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) |
|
26 |
*/ |
|
27 |
public void start(BundleContext context) throws Exception { |
|
28 |
super.start(context); |
|
29 |
plugin = this; |
|
30 |
} |
|
31 |
|
|
32 |
/* |
|
33 |
* (non-Javadoc) |
|
34 |
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) |
|
35 |
*/ |
|
36 |
public void stop(BundleContext context) throws Exception { |
|
37 |
plugin = null; |
|
38 |
super.stop(context); |
|
39 |
} |
|
40 |
|
|
41 |
/** |
|
42 |
* Returns the shared instance |
|
43 |
* |
|
44 |
* @return the shared instance |
|
45 |
*/ |
|
46 |
public static Activator getDefault() { |
|
47 |
return plugin; |
|
48 |
} |
|
49 |
|
|
50 |
} |
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/OpenExternalAboutPlatformHandler.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.taxeditor.workbench; |
|
11 |
|
|
12 |
import java.net.MalformedURLException; |
|
13 |
import java.net.URL; |
|
14 |
|
|
15 |
import org.apache.log4j.Logger; |
|
16 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
17 |
import org.eclipse.ui.PartInitException; |
|
18 |
import org.eclipse.ui.PlatformUI; |
|
19 |
import org.eclipse.ui.browser.IWorkbenchBrowserSupport; |
|
20 |
|
|
21 |
/** |
|
22 |
* @author p.ciardelli |
|
23 |
* @created 04.09.2009 |
|
24 |
* @version 1.0 |
|
25 |
*/ |
|
26 |
public class OpenExternalAboutPlatformHandler { |
|
27 |
private static final Logger logger = Logger.getLogger(OpenExternalAboutPlatformHandler.class); |
|
28 |
|
|
29 |
|
|
30 |
@Execute |
|
31 |
public Object execute() { |
|
32 |
String url = "http://wp5.e-taxonomy.eu/"; |
|
33 |
|
|
34 |
try { |
|
35 |
PlatformUI.getWorkbench().getBrowserSupport().createBrowser |
|
36 |
(IWorkbenchBrowserSupport.AS_EXTERNAL, "aCustomId", "url", "url").openURL(new URL(url)); |
|
37 |
} catch (PartInitException e) { |
|
38 |
logger.error(e); |
|
39 |
throw new RuntimeException(e); |
|
40 |
} catch (MalformedURLException e) { |
|
41 |
logger.error(e); |
|
42 |
throw new RuntimeException(e); |
|
43 |
} |
|
44 |
|
|
45 |
return null; |
|
46 |
} |
|
47 |
} |
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/OpenExternalParserHelpHandler.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.taxeditor.workbench; |
|
11 |
|
|
12 |
import java.net.MalformedURLException; |
|
13 |
import java.net.URL; |
|
14 |
|
|
15 |
import org.apache.log4j.Logger; |
|
16 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
17 |
import org.eclipse.ui.PartInitException; |
|
18 |
import org.eclipse.ui.PlatformUI; |
|
19 |
import org.eclipse.ui.browser.IWorkbenchBrowserSupport; |
|
20 |
|
|
21 |
/** |
|
22 |
* <p>OpenExternalParserHelpHandler class.</p> |
|
23 |
* |
|
24 |
* @author p.ciardelli |
|
25 |
* @created 04.09.2009 |
|
26 |
* @version 1.0 |
|
27 |
*/ |
|
28 |
public class OpenExternalParserHelpHandler { |
|
29 |
private static final Logger logger = Logger.getLogger(OpenExternalParserHelpHandler.class); |
|
30 |
|
|
31 |
@Execute |
|
32 |
/** {@inheritDoc} */ |
|
33 |
public Object execute() { |
|
34 |
String url = "http://dev.e-taxonomy.eu/trac/wiki/NameParserDocumentation"; |
|
35 |
|
|
36 |
try { |
|
37 |
PlatformUI.getWorkbench().getBrowserSupport().createBrowser |
|
38 |
(IWorkbenchBrowserSupport.AS_EXTERNAL, "aCustomId", "url", "url").openURL(new URL(url)); |
|
39 |
} catch (PartInitException e) { |
|
40 |
logger.error(e); |
|
41 |
throw new RuntimeException(e); |
|
42 |
} catch (MalformedURLException e) { |
|
43 |
logger.error(e); |
|
44 |
throw new RuntimeException(e); |
|
45 |
} |
|
46 |
|
|
47 |
return null; |
|
48 |
} |
|
49 |
} |
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/update/InstallNewSoftwareHandler.java | ||
---|---|---|
1 |
/******************************************************************************* |
|
2 |
* Copyright (c) 2008, 2009 IBM Corporation and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* IBM Corporation - initial API and implementation |
|
10 |
*******************************************************************************/ |
|
11 |
package eu.etaxonomy.taxeditor.workbench.update; |
|
12 |
|
|
13 |
import org.eclipse.core.runtime.jobs.Job; |
|
14 |
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob; |
|
15 |
|
|
16 |
/** |
|
17 |
* InstallNewSoftwareHandler invokes the install wizard |
|
18 |
* |
|
19 |
* @since 3.5 |
|
20 |
*/ |
|
21 |
public class InstallNewSoftwareHandler extends PreloadingRepositoryHandler { |
|
22 |
|
|
23 |
/** |
|
24 |
* The constructor. |
|
25 |
*/ |
|
26 |
public InstallNewSoftwareHandler() { |
|
27 |
super(); |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
protected void doExecute(LoadMetadataRepositoryJob job) { |
|
32 |
getProvisioningUI().openInstallWizard(null, null, job); |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
36 |
protected boolean waitForPreload() { |
|
37 |
// If the user cannot see repositories, then we may as well wait |
|
38 |
// for existing repos to load so that content is available. |
|
39 |
// If the user can manipulate the repositories, then we don't wait, |
|
40 |
// because we don't know which ones they want to work with. |
|
41 |
return !getProvisioningUI().getPolicy().getRepositoriesVisible(); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
protected void setLoadJobProperties(Job loadJob) { |
|
46 |
super.setLoadJobProperties(loadJob); |
|
47 |
// If we are doing a background load, we do not wish to authenticate, as the |
|
48 |
// user is unaware that loading was needed |
|
49 |
if (!waitForPreload()) { |
|
50 |
loadJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_AUTHENTICATION_JOB_MARKER, Boolean.toString(true)); |
|
51 |
loadJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_REPOSITORY_EVENTS, Boolean.toString(true)); |
|
52 |
} |
|
53 |
} |
|
54 |
} |
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/update/PreloadingRepositoryHandler.java | ||
---|---|---|
1 |
/******************************************************************************* |
|
2 |
* Copyright (c) 2008, 2009 IBM Corporation and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* IBM Corporation - initial API and implementation |
|
10 |
*******************************************************************************/ |
|
11 |
package eu.etaxonomy.taxeditor.workbench.update; |
|
12 |
|
|
13 |
import org.eclipse.core.runtime.jobs.IJobChangeEvent; |
|
14 |
import org.eclipse.core.runtime.jobs.Job; |
|
15 |
import org.eclipse.core.runtime.jobs.JobChangeAdapter; |
|
16 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
17 |
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob; |
|
18 |
import org.eclipse.equinox.p2.ui.ProvisioningUI; |
|
19 |
import org.eclipse.swt.widgets.Shell; |
|
20 |
import org.eclipse.ui.PlatformUI; |
|
21 |
|
|
22 |
/** |
|
23 |
* PreloadingRepositoryHandler provides background loading of |
|
24 |
* repositories before executing the provisioning handler. |
|
25 |
* |
|
26 |
* @since 3.5 |
|
27 |
*/ |
|
28 |
abstract class PreloadingRepositoryHandler{ |
|
29 |
|
|
30 |
/** |
|
31 |
* The constructor. |
|
32 |
*/ |
|
33 |
public PreloadingRepositoryHandler() { |
|
34 |
// constructor |
|
35 |
} |
|
36 |
|
|
37 |
/** |
|
38 |
* Execute the command. |
|
39 |
*/ |
|
40 |
@Execute |
|
41 |
public Object execute() { |
|
42 |
doExecuteAndLoad(); |
|
43 |
return null; |
|
44 |
} |
|
45 |
|
|
46 |
private void doExecuteAndLoad() { |
|
47 |
if (preloadRepositories()) { |
|
48 |
//cancel any load that is already running |
|
49 |
Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY); |
|
50 |
final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(getProvisioningUI()); |
|
51 |
setLoadJobProperties(loadJob); |
|
52 |
if (waitForPreload()) { |
|
53 |
loadJob.addJobChangeListener(new JobChangeAdapter() { |
|
54 |
@Override |
|
55 |
public void done(IJobChangeEvent event) { |
|
56 |
if (PlatformUI.isWorkbenchRunning()) { |
|
57 |
if (event.getResult().isOK()) { |
|
58 |
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { |
|
59 |
@Override |
|
60 |
public void run() { |
|
61 |
doExecute(loadJob); |
|
62 |
} |
|
63 |
}); |
|
64 |
} |
|
65 |
} |
|
66 |
} |
|
67 |
}); |
|
68 |
loadJob.setUser(true); |
|
69 |
loadJob.schedule(); |
|
70 |
|
|
71 |
} else { |
|
72 |
loadJob.setSystem(true); |
|
73 |
loadJob.setUser(false); |
|
74 |
loadJob.schedule(); |
|
75 |
doExecute(null); |
|
76 |
} |
|
77 |
} else { |
|
78 |
doExecute(null); |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
protected abstract void doExecute(LoadMetadataRepositoryJob job); |
|
83 |
|
|
84 |
protected boolean preloadRepositories() { |
|
85 |
return true; |
|
86 |
} |
|
87 |
|
|
88 |
protected boolean waitForPreload() { |
|
89 |
return true; |
|
90 |
} |
|
91 |
|
|
92 |
protected void setLoadJobProperties(Job loadJob) { |
|
93 |
loadJob.setProperty(LoadMetadataRepositoryJob.ACCUMULATE_LOAD_ERRORS, Boolean.toString(true)); |
|
94 |
} |
|
95 |
|
|
96 |
protected ProvisioningUI getProvisioningUI() { |
|
97 |
return ProvisioningUI.getDefaultUI(); |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Return a shell appropriate for parenting dialogs of this handler. |
|
102 |
* @return a Shell |
|
103 |
*/ |
|
104 |
protected Shell getShell() { |
|
105 |
return PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(); |
|
106 |
} |
|
107 |
} |
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/update/UpdateHandler.java | ||
---|---|---|
1 |
/******************************************************************************* |
|
2 |
* Copyright (c) 2007, 2009 IBM Corporation and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* IBM Corporation - initial API and implementation |
|
10 |
*******************************************************************************/ |
|
11 |
package eu.etaxonomy.taxeditor.workbench.update; |
|
12 |
|
|
13 |
import org.eclipse.equinox.internal.p2.ui.dialogs.UpdateSingleIUWizard; |
|
14 |
import org.eclipse.equinox.p2.operations.RepositoryTracker; |
|
15 |
import org.eclipse.equinox.p2.operations.UpdateOperation; |
|
16 |
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob; |
|
17 |
import org.eclipse.jface.wizard.WizardDialog; |
|
18 |
|
|
19 |
/** |
|
20 |
* UpdateHandler invokes the check for updates UI |
|
21 |
* |
|
22 |
* @since 3.4 |
|
23 |
*/ |
|
24 |
public class UpdateHandler extends PreloadingRepositoryHandler { |
|
25 |
|
|
26 |
boolean hasNoRepos = false; |
|
27 |
|
|
28 |
@Override |
|
29 |
protected void doExecute(LoadMetadataRepositoryJob job) { |
|
30 |
if (hasNoRepos) { |
|
31 |
return; |
|
32 |
} |
|
33 |
UpdateOperation operation = getProvisioningUI().getUpdateOperation(null, null); |
|
34 |
|
|
35 |
|
|
36 |
// check for updates |
|
37 |
operation.resolveModal(null); |
|
38 |
if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) { |
|
39 |
if (UpdateSingleIUWizard.validFor(operation)) { |
|
40 |
// Special case for only updating a single root |
|
41 |
UpdateSingleIUWizard wizard = new UpdateSingleIUWizard(getProvisioningUI(), operation); |
|
42 |
WizardDialog dialog = new WizardDialog(getShell(), wizard); |
|
43 |
dialog.create(); |
|
44 |
dialog.open(); |
|
45 |
} else { |
|
46 |
// Open the normal version of the update wizard |
|
47 |
getProvisioningUI().openUpdateWizard(false, operation, job); |
|
48 |
} |
|
49 |
} |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
protected boolean preloadRepositories() { |
|
54 |
hasNoRepos = false; |
|
55 |
RepositoryTracker repoMan = getProvisioningUI().getRepositoryTracker(); |
|
56 |
if (repoMan.getKnownRepositories(getProvisioningUI().getSession()).length == 0) { |
|
57 |
hasNoRepos = true; |
|
58 |
return false; |
|
59 |
} |
|
60 |
return super.preloadRepositories(); |
|
61 |
} |
|
62 |
} |
Also available in: Unified diff
ref #6566 Refactor src folder to src/main/java