X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.procore.ui%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fprocore%2Fui%2FProCoreUserAgent.java;fp=bundles%2Forg.simantics.db.procore.ui%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fprocore%2Fui%2FProCoreUserAgent.java;h=9b0438042adf439991a5ffb939a2458563cedb12;hp=dc93b2f9d9a45918a546a42383fa396523104422;hb=2531cdf245f42bce854d43f4d49a23983c79db96;hpb=857dbc869796d772864327ce02f19dc252b159fc diff --git a/bundles/org.simantics.db.procore.ui/src/org/simantics/db/procore/ui/ProCoreUserAgent.java b/bundles/org.simantics.db.procore.ui/src/org/simantics/db/procore/ui/ProCoreUserAgent.java index dc93b2f9d..9b0438042 100644 --- a/bundles/org.simantics.db.procore.ui/src/org/simantics/db/procore/ui/ProCoreUserAgent.java +++ b/bundles/org.simantics.db.procore.ui/src/org/simantics/db/procore/ui/ProCoreUserAgent.java @@ -2,58 +2,44 @@ package org.simantics.db.procore.ui; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; 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(IWorkbench workbench) { - IWorkbenchWindow wbw = workbench.getActiveWorkbenchWindow(); - Shell shell = null; - if (null != wbw) { - shell = wbw.getShell(); - } else { - 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 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; + Display d = Display.getCurrent(); + if (d == null) + d = Display.getDefault(); + return d; } - private IWorkbench workbench; - public ProCoreUserAgent(IWorkbench workbench) { - this.workbench = workbench; - } - private Shell getShell() { - return getShell(workbench); - } - @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; - } -} \ No newline at end of file + @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; + } +}