1 package org.simantics.db.procore.ui;
\r
3 import org.eclipse.swt.widgets.Display;
\r
4 import org.eclipse.swt.widgets.Shell;
\r
5 import org.eclipse.ui.IWorkbench;
\r
6 import org.eclipse.ui.IWorkbenchWindow;
\r
7 import org.simantics.db.DatabaseUserAgent;
\r
8 import org.simantics.db.exception.InternalException;
\r
9 import org.simantics.db.procore.ProCoreDriver;
\r
11 public final class ProCoreUserAgent implements DatabaseUserAgent {
\r
12 private static Shell getShell(IWorkbench workbench) {
\r
13 IWorkbenchWindow wbw = workbench.getActiveWorkbenchWindow();
\r
16 shell = wbw.getShell();
\r
18 Display d = getDisplay();
\r
21 shell = d.getActiveShell();
\r
22 if (null == shell) {
\r
23 Shell[] shells = d.getShells();
\r
24 if (null != shells && shells.length > 0)
\r
30 private static Display getDisplay() {
\r
31 Display d = Display.getCurrent();
\r
33 d = Display.getDefault();
\r
36 private IWorkbench workbench;
\r
37 public ProCoreUserAgent(IWorkbench workbench) {
\r
38 this.workbench = workbench;
\r
40 private Shell getShell() {
\r
41 return getShell(workbench);
\r
44 public boolean handleStart(InternalException exception) {
\r
45 Shell shell = getShell();
\r
47 return false; // no can do
\r
49 return Auxiliary.handleStart(shell, exception);
\r
50 } catch (InternalException e) {
\r
51 return false; // no could do
\r
56 public String getId() {
\r
57 return ProCoreDriver.ProCoreDriverName;
\r