X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.db.procore.ui%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fprocore%2Fui%2Finternal%2FUI.java;h=00cca9311329ff43eaf8afe4ae0835d69139a0d4;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=74fd9cd65f6db8af7ff5a14813cf2672b9831165;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.procore.ui/src/org/simantics/db/procore/ui/internal/UI.java b/bundles/org.simantics.db.procore.ui/src/org/simantics/db/procore/ui/internal/UI.java index 74fd9cd65..00cca9311 100644 --- a/bundles/org.simantics.db.procore.ui/src/org/simantics/db/procore/ui/internal/UI.java +++ b/bundles/org.simantics.db.procore.ui/src/org/simantics/db/procore/ui/internal/UI.java @@ -1,70 +1,70 @@ -package org.simantics.db.procore.ui.internal; - -import java.io.File; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.simantics.db.common.utils.Logger; -import org.simantics.db.exception.InternalException; -import org.simantics.db.server.DatabaseCorruptedException; -import org.simantics.db.server.DatabaseLastExitException; -import org.simantics.db.server.DatabaseProtocolException; -import org.simantics.db.server.DatabaseStartException; -import org.simantics.db.server.DatabaseVersionException; -import org.simantics.db.server.GuardFileVersionException; -import org.simantics.db.server.ProCoreException; - -public class UI { - public static boolean delete(Shell shell, File folder) { - return HandlerUtil.delete(shell, folder, "Database Delete", null); - } - public static boolean purge(Shell shell, File folder) { - return HandlerUtil.purge(shell, folder, "Database Purge", null); - } - public static boolean handleStart(Shell shell, InternalException e) throws ProCoreException { - if (!(e instanceof ProCoreException)) - return false; // Can not fix this exception. - ProCoreException pce = (ProCoreException)e; - Handler handler = getStart(pce); - assert(null != handler); - return handler.start(shell, pce); - } - public static Display getDisplay() { - Display d = Display.getCurrent(); - if (d == null) - d = Display.getDefault(); - return d; - } - static Map startHandlers = new HashMap(); - static { - startHandlers.put(GuardFileVersionException.getHandlerId(), new GuardFileVersionHandler()); - startHandlers.put(DatabaseCorruptedException.getHandlerId(), new DatabaseCorruptedHandler()); - startHandlers.put(DatabaseStartException.getHandlerId(), new DatabaseStartHandler()); - startHandlers.put(DatabaseVersionException.getHandlerId(), new DatabaseVersionHandler()); - startHandlers.put(DatabaseLastExitException.getHandlerId(), new DatabaseLastExitHandler()); - startHandlers.put(DatabaseProtocolException.getHandlerId(), new DatabaseProtocolHandler()); - } - private static long getId(E pe) { - long id = 0; - try { - Method m = pe.getClass().getMethod("getHandlerId"); - Object value = m.invoke(null); - id = (long)value; - } catch (RuntimeException e) { - Logger.defaultLogError(e); - } catch (Exception e) { - Logger.defaultLogError(e); - } - return id; - } - private static Handler getStart(E e) { - Handler h = startHandlers.get(getId(e)); - if (null == h) - return new DefaultHandler(); - else - return h; - } -} +package org.simantics.db.procore.ui.internal; + +import java.io.File; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.simantics.db.common.utils.Logger; +import org.simantics.db.exception.InternalException; +import org.simantics.db.server.DatabaseCorruptedException; +import org.simantics.db.server.DatabaseLastExitException; +import org.simantics.db.server.DatabaseProtocolException; +import org.simantics.db.server.DatabaseStartException; +import org.simantics.db.server.DatabaseVersionException; +import org.simantics.db.server.GuardFileVersionException; +import org.simantics.db.server.ProCoreException; + +public class UI { + public static boolean delete(Shell shell, File folder) { + return HandlerUtil.delete(shell, folder, "Database Delete", null); + } + public static boolean purge(Shell shell, File folder) { + return HandlerUtil.purge(shell, folder, "Database Purge", null); + } + public static boolean handleStart(Shell shell, InternalException e) throws ProCoreException { + if (!(e instanceof ProCoreException)) + return false; // Can not fix this exception. + ProCoreException pce = (ProCoreException)e; + Handler handler = getStart(pce); + assert(null != handler); + return handler.start(shell, pce); + } + public static Display getDisplay() { + Display d = Display.getCurrent(); + if (d == null) + d = Display.getDefault(); + return d; + } + static Map startHandlers = new HashMap(); + static { + startHandlers.put(GuardFileVersionException.getHandlerId(), new GuardFileVersionHandler()); + startHandlers.put(DatabaseCorruptedException.getHandlerId(), new DatabaseCorruptedHandler()); + startHandlers.put(DatabaseStartException.getHandlerId(), new DatabaseStartHandler()); + startHandlers.put(DatabaseVersionException.getHandlerId(), new DatabaseVersionHandler()); + startHandlers.put(DatabaseLastExitException.getHandlerId(), new DatabaseLastExitHandler()); + startHandlers.put(DatabaseProtocolException.getHandlerId(), new DatabaseProtocolHandler()); + } + private static long getId(E pe) { + long id = 0; + try { + Method m = pe.getClass().getMethod("getHandlerId"); + Object value = m.invoke(null); + id = (long)value; + } catch (RuntimeException e) { + Logger.defaultLogError(e); + } catch (Exception e) { + Logger.defaultLogError(e); + } + return id; + } + private static Handler getStart(E e) { + Handler h = startHandlers.get(getId(e)); + if (null == h) + return new DefaultHandler(); + else + return h; + } +}