ref #6566 Sort main menu
[taxeditor.git] / 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 }