-package org.simantics.db.procore.ui;\r
-\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.simantics.db.DatabaseUserAgent;\r
-import org.simantics.db.exception.InternalException;\r
-import org.simantics.db.procore.ProCoreDriver;\r
-\r
-public final class ProCoreUserAgent implements DatabaseUserAgent {\r
- private static Shell getShell() {\r
- Shell shell = null;\r
- Display d = getDisplay();\r
- if (d == null)\r
- return null;\r
- shell = d.getActiveShell();\r
- if (null == shell) {\r
- Shell[] shells = d.getShells();\r
- if (null != shells && shells.length > 0)\r
- shell = shells[0];\r
- }\r
- return shell;\r
- }\r
- private static Display getDisplay() {\r
- Display d = Display.getCurrent();\r
- if (d == null)\r
- d = Display.getDefault();\r
- return d;\r
- }\r
- @Override\r
- public boolean handleStart(InternalException exception) {\r
- Shell shell = getShell();\r
- if (null == shell)\r
- return false; // no can do\r
- try {\r
- return Auxiliary.handleStart(shell, exception);\r
- } catch (InternalException e) {\r
- return false; // no could do\r
- }\r
- }\r
-\r
- @Override\r
- public String getId() {\r
- return ProCoreDriver.ProCoreDriverName;\r
- }\r
-}\r
+package org.simantics.db.procore.ui;
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.simantics.db.DatabaseUserAgent;
+import org.simantics.db.exception.InternalException;
+import org.simantics.db.procore.ProCoreDriver;
+
+public final class ProCoreUserAgent implements DatabaseUserAgent {
+ private static Shell getShell() {
+ Shell shell = null;
+ Display d = getDisplay();
+ if (d == null)
+ return null;
+ shell = d.getActiveShell();
+ if (null == shell) {
+ Shell[] shells = d.getShells();
+ if (null != shells && shells.length > 0)
+ shell = shells[0];
+ }
+ return shell;
+ }
+ private static Display getDisplay() {
+ Display d = Display.getCurrent();
+ if (d == null)
+ d = Display.getDefault();
+ return d;
+ }
+ @Override
+ public boolean handleStart(InternalException exception) {
+ Shell shell = getShell();
+ if (null == shell)
+ return false; // no can do
+ try {
+ return Auxiliary.handleStart(shell, exception);
+ } catch (InternalException e) {
+ return false; // no could do
+ }
+ }
+
+ @Override
+ public String getId() {
+ return ProCoreDriver.ProCoreDriverName;
+ }
+}