1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.browsing.ui.graph.impl;
\r
14 import org.simantics.db.RequestProcessor;
\r
15 import org.simantics.db.Resource;
\r
16 import org.simantics.db.WriteGraph;
\r
17 import org.simantics.db.common.request.WriteRequest;
\r
18 import org.simantics.db.exception.DatabaseException;
\r
19 import org.simantics.utils.datastructures.Callback;
\r
20 import org.simantics.utils.ui.ErrorLogger;
\r
25 * <li>{@link #createModifierInput(String)} - constructs an input for
\r
26 * {@link org.simantics.db.layer0.adapter.Modifier#modify(WriteGraph, Object)}
\r
27 * from the specified label given by the user.
\r
28 * <li>{@link #doModify(WriteGraph, String)} - perform the requested
\r
29 * modification into the graph.</li>
\r
33 * See {@link AbstractStringModifier} for more information.
\r
36 * @author Tuukka Lehtonen
\r
38 * @param <T> the input class of the used
\r
39 * {@link org.simantics.db.layer0.adapter.Modifier}
\r
41 public class GraphFactoryStringModifier extends AbstractFactoryStringModifier {
\r
47 public GraphFactoryStringModifier(Resource subject, Resource predicate, Resource object, RequestProcessor processor) {
\r
48 super(subject, predicate, object, processor);
\r
52 public final void doModify(final String label) {
\r
53 session.asyncRequest(new WriteRequest() {
\r
55 public void perform(WriteGraph graph) throws DatabaseException {
\r
56 doModifyWithFactory(graph, label);
\r
58 }, new Callback<DatabaseException>() {
\r
60 public void run(DatabaseException parameter) {
\r
61 if (parameter != null)
\r
62 ErrorLogger.defaultLogError(parameter);
\r
67 public void doModifyWithFactory(WriteGraph graph, String label) throws DatabaseException {
\r
68 if (getModifierFactory() != null)
\r
69 getModifier().modify(graph, label);
\r
71 doModify(graph, label);
\r
74 public void doModify(WriteGraph graph, String label) throws DatabaseException {
\r
75 getModifier().modify(graph, label);
\r