X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.swt%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fswt%2Fcontentassist%2FGraphContentAssistModifier.java;h=1fbf5b7f158aed1de8a97adeb43ae955369e98f4;hb=HEAD;hp=66f4147865a752c307812af51de49e34d42ab3cd;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/contentassist/GraphContentAssistModifier.java b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/contentassist/GraphContentAssistModifier.java index 66f414786..1fbf5b7f1 100644 --- a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/contentassist/GraphContentAssistModifier.java +++ b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/contentassist/GraphContentAssistModifier.java @@ -1,77 +1,77 @@ -/******************************************************************************* - * Copyright (c) 2007, 2012 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.browsing.ui.swt.contentassist; - -import org.simantics.browsing.ui.common.modifiers.Enumeration; -import org.simantics.db.Session; -import org.simantics.db.WriteGraph; -import org.simantics.db.common.request.WriteRequest; -import org.simantics.db.exception.DatabaseException; -import org.simantics.utils.ObjectUtils; - -/** - * @author Tuukka Lehtonen - */ -public abstract class GraphContentAssistModifier extends AbstractContentAssistModifier { - - protected final Session session; - - public GraphContentAssistModifier(Session session, Enumeration enumeration, T value) { - super(enumeration, value); - if (session == null) - throw new NullPointerException("null session"); - this.session = session; - } - - @Override - protected void modifyWithValue(final T oldEnumObject, final String enumObject) { - if (ObjectUtils.objectEquals(oldEnumObject, enumObject)) - return; - - try { - session.getSession().syncRequest(new WriteRequest() { - @Override - public void perform(WriteGraph graph) throws DatabaseException { -// System.out.println("old enum object: " + oldEnumObject); -// System.out.println("enum object: " + enumObject); - modifyWithObject(graph, oldEnumObject, enumObject); - } - }); - } catch (DatabaseException e) { - handleException(e); - } - } - - /** - * Implement this modifier to perform database modifications. - * - * @param graph - * @param oldEnumObject - * @param enumObject - */ - protected abstract void modifyWithObject(WriteGraph graph, T oldEnumObject, String enumObject) throws DatabaseException; - - /** - * Client overridable handler for possible exceptions that may occur while - * performing the database modifications. - * - *

- * This default implementation merely forwards the exception as a runtime - * exception. - * - * @param e - */ - protected void handleException(DatabaseException e) { - throw new RuntimeException(e); - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2012 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.browsing.ui.swt.contentassist; + +import org.simantics.browsing.ui.common.modifiers.Enumeration; +import org.simantics.db.Session; +import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.WriteRequest; +import org.simantics.db.exception.DatabaseException; +import org.simantics.utils.ObjectUtils; + +/** + * @author Tuukka Lehtonen + */ +public abstract class GraphContentAssistModifier extends AbstractContentAssistModifier { + + protected final Session session; + + public GraphContentAssistModifier(Session session, Enumeration enumeration, T value) { + super(enumeration, value); + if (session == null) + throw new NullPointerException("null session"); + this.session = session; + } + + @Override + protected void modifyWithValue(final T oldEnumObject, final String enumObject) { + if (ObjectUtils.objectEquals(oldEnumObject, enumObject)) + return; + + try { + session.getSession().syncRequest(new WriteRequest() { + @Override + public void perform(WriteGraph graph) throws DatabaseException { +// System.out.println("old enum object: " + oldEnumObject); +// System.out.println("enum object: " + enumObject); + modifyWithObject(graph, oldEnumObject, enumObject); + } + }); + } catch (DatabaseException e) { + handleException(e); + } + } + + /** + * Implement this modifier to perform database modifications. + * + * @param graph + * @param oldEnumObject + * @param enumObject + */ + protected abstract void modifyWithObject(WriteGraph graph, T oldEnumObject, String enumObject) throws DatabaseException; + + /** + * Client overridable handler for possible exceptions that may occur while + * performing the database modifications. + * + *

+ * This default implementation merely forwards the exception as a runtime + * exception. + * + * @param e + */ + protected void handleException(DatabaseException e) { + throw new RuntimeException(e); + } + +}