1 package eu
.etaxonomy
.taxeditor
;
3 import org
.eclipse
.core
.runtime
.IStatus
;
4 import org
.eclipse
.equinox
.internal
.p2
.core
.helpers
.ServiceHelper
;
5 import org
.eclipse
.equinox
.p2
.core
.IProvisioningAgent
;
6 import org
.eclipse
.equinox
.p2
.operations
.ProvisioningJob
;
7 import org
.eclipse
.equinox
.p2
.operations
.ProvisioningSession
;
8 import org
.eclipse
.equinox
.p2
.operations
.UpdateOperation
;
9 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
10 import org
.eclipse
.swt
.graphics
.Point
;
11 import org
.eclipse
.swt
.widgets
.Shell
;
12 import org
.eclipse
.ui
.PlatformUI
;
13 import org
.eclipse
.ui
.application
.ActionBarAdvisor
;
14 import org
.eclipse
.ui
.application
.IActionBarConfigurer
;
15 import org
.eclipse
.ui
.application
.IWorkbenchWindowConfigurer
;
16 import org
.eclipse
.ui
.application
.WorkbenchWindowAdvisor
;
18 import eu
.etaxonomy
.taxeditor
.dialogs
.LoginDialog
;
19 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
20 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
23 * <p>ApplicationWorkbenchWindowAdvisor class.</p>
28 public class ApplicationWorkbenchWindowAdvisor
extends WorkbenchWindowAdvisor
{
31 * <p>Constructor for ApplicationWorkbenchWindowAdvisor.</p>
33 * @param configurer a {@link org.eclipse.ui.application.IWorkbenchWindowConfigurer} object.
35 public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer
) {
40 public ActionBarAdvisor
createActionBarAdvisor(
41 IActionBarConfigurer configurer
) {
42 return new ApplicationActionBarAdvisor(configurer
);
46 * <p>preWindowOpen</p>
48 public void preWindowOpen() {
49 IWorkbenchWindowConfigurer configurer
= getWindowConfigurer();
50 configurer
.setInitialSize(new Point(963, 637));
51 configurer
.setShowCoolBar(true);
52 configurer
.setShowStatusLine(true);
53 configurer
.setShowPerspectiveBar(true);
54 configurer
.setTitle("EDIT Taxonomic Editor");
55 configurer
.setShowProgressIndicator(true);
59 * <p>postWindowOpen</p>
61 public void postWindowOpen() {
62 PreferencesUtil
.checkNomenclaturalCode();
64 if(PreferencesUtil
.shouldConnectAtStartUp())
71 private int authenticate(){
72 Shell shell
= TaxonomicEditorPlugin
.getDefault().getWorkbench()
73 .getActiveWorkbenchWindow().getShell();
75 LoginDialog loginDialog
= new LoginDialog(shell
);
76 return loginDialog
.open();
79 private void automaticUpdate(){
80 final IProvisioningAgent agent
= (IProvisioningAgent
) ServiceHelper
.getService(TaxonomicEditorPlugin
.bundleContext
,
81 IProvisioningAgent
.SERVICE_NAME
);
83 ApplicationUtil
.error(this.getClass(), "No provisioning agent found. This application is not set up for updates.", null);
87 //StoreUtil.warningDialog("Updates", "Searching for updates");
88 // check for updates before starting up.
89 // If an update is performed, restart. Otherwise log
95 // IRunnableWithProgress runnable = new IRunnableWithProgress() {
96 // public void run(IProgressMonitor monitor)
97 // throws InvocationTargetException, InterruptedException {
99 UpdateOperation operation
= null;
101 ProvisioningSession session
= new ProvisioningSession(agent
);
104 // the default update operation looks for updates to the currently
105 // running profile, using the default profile root marker. To change
106 // which installable units are being updated, use the more detailed
108 operation
= new UpdateOperation(session
);
109 // SubMonitor sub = SubMonitor.convert(monitor,
110 // "Checking for application updates...", 200);
111 IStatus status
= operation
.resolveModal(null);//sub.newChild(100));
113 if (status
.getCode() == UpdateOperation
.STATUS_NOTHING_TO_UPDATE
) {
114 PlatformUI
.getWorkbench().getDisplay()
115 .asyncExec(new Runnable() {
117 MessageDialog
.openInformation(null,
118 "Updates", "No updates were found");
122 if (status
.getSeverity() == IStatus
.CANCEL
){
123 ApplicationUtil
.info(status
);
124 // throw new OperationCanceledException();
127 if (status
.getSeverity() != IStatus
.ERROR
) {
128 // More complex status handling might include showing the user what updates
129 // are available if there are multiples, differentiating patches vs. updates, etc.
130 // In this example, we simply update as suggested by the operation.
131 ProvisioningJob job
= operation
.getProvisioningJob(null);
134 ApplicationUtil
.info(status
);
135 // StoreUtil.warningDialog("Updates", status.toString());
137 // throw new OperationCanceledException();
140 status
= job
.runModal(null);//sub.newChild(100));
141 if (status
.getSeverity() == IStatus
.CANCEL
){
142 ApplicationUtil
.info(status
);
143 // throw new OperationCanceledException();
147 // StoreUtil.warningDialog("Performing update", "");
149 // StoreUtil.warningDialog("Updates", status.toString());
152 ApplicationUtil
.error(this.getClass(), e
);
158 // new ProgressMonitorDialog(null).run(true, true, runnable);
159 // } catch (InvocationTargetException e) {
160 // e.printStackTrace();
161 // } catch (InterruptedException e) {