1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.modeling.ui.modelBrowser.model;
14 import java.util.Collection;
15 import java.util.Collections;
17 import org.eclipse.core.runtime.IAdaptable;
18 import org.eclipse.jface.resource.ImageDescriptor;
19 import org.simantics.browsing.ui.common.node.IDeletable;
20 import org.simantics.browsing.ui.common.node.IModifiable;
21 import org.simantics.browsing.ui.content.Labeler.Modifier;
22 import org.simantics.browsing.ui.graph.impl.LabelerUtil;
23 import org.simantics.databoard.Bindings;
24 import org.simantics.db.ReadGraph;
25 import org.simantics.db.Resource;
26 import org.simantics.db.Session;
27 import org.simantics.db.WriteGraph;
28 import org.simantics.db.common.primitiverequest.RelatedValue;
29 import org.simantics.db.common.request.WriteRequest;
30 import org.simantics.db.exception.DatabaseException;
31 import org.simantics.layer0.Layer0;
32 import org.simantics.modeling.ui.Activator;
38 * @Deprecated Use org.simantics.image instead
41 public class Image extends Node implements IAdaptable, IDeletable, IModifiable {
43 public Image(Resource image) {
48 public String getLabel(ReadGraph g) throws DatabaseException {
49 String name = LabelerUtil.safeStringRepresentation(g, resource);
54 public Collection<?> getChildren(ReadGraph g) {
55 return Collections.emptyList();
59 public ImageDescriptor getImage(ReadGraph g) {
60 return Activator.IMAGE_ICON;
64 public Modifier getModifier(final Session session, String columnId) {
65 return new Modifier() {
68 public String getValue() {
69 // TODO: rename the workspace directory containing the data
71 Layer0 b = Layer0.getInstance(session);
72 return session.syncRequest(new RelatedValue<String>(resource, b.HasName, Bindings.STRING));
73 } catch (DatabaseException e) {
80 public String isValid(String label) {
85 public void modify(final String label) {
86 session.asyncRequest(new WriteRequest() {
89 public void perform(WriteGraph g) throws DatabaseException {
90 Layer0 b = Layer0.getInstance(g);
91 g.claimLiteral(resource, b.HasName, label);