X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.document.ui%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fui%2Factions%2FAddDocumentAction.java;fp=bundles%2Forg.simantics.document.ui%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fui%2Factions%2FAddDocumentAction.java;h=c6c4e64a736e29853bf6b2ecb3152cddaeb81e7e;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=4feebab35c247164115b14d4aea2bf8155c9f973;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddDocumentAction.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddDocumentAction.java index 4feebab35..c6c4e64a7 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddDocumentAction.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddDocumentAction.java @@ -1,66 +1,66 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.document.ui.actions; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.adapter.ActionFactory; -import org.simantics.document.DocumentResource; -import org.simantics.document.ui.graphfile.DocumentVersionUtils; -import org.simantics.document.ui.graphfile.FileDocumentUtil; - -/** - * Abstract base class for adding documents. - * - * If import target is an document, a new version of a document is created. - * - * Document version creation has two modes: - * FLAT: new version is added to the same library as the old document. - * TREE: new version replaces the old document in the library, and old document is moved under the new document. - * - * - * @author Marko Luukkainen - * - */ -public abstract class AddDocumentAction implements ActionFactory { - - - - - private Resource relation; - - public AddDocumentAction(ReadGraph graph, String relationUri) throws DatabaseException { - relation = graph.getResource(relationUri); - } - - - protected Resource getRelation() { - return relation; - } - - protected void linkDocument(WriteGraph graph, Resource target, Resource newDocument) throws DatabaseException{ - DocumentResource doc = DocumentResource.getInstance(graph); - - if (graph.isInstanceOf(target, doc.Document)) { - // adding a new revision - DocumentVersionUtils.createNewVersion(graph, target, newDocument, relation); - - - } else { - graph.claim(target, relation, newDocument); - FileDocumentUtil.createUniqueName(graph, newDocument); - } - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 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.document.ui.actions; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.adapter.ActionFactory; +import org.simantics.document.DocumentResource; +import org.simantics.document.ui.graphfile.DocumentVersionUtils; +import org.simantics.document.ui.graphfile.FileDocumentUtil; + +/** + * Abstract base class for adding documents. + * + * If import target is an document, a new version of a document is created. + * + * Document version creation has two modes: + * FLAT: new version is added to the same library as the old document. + * TREE: new version replaces the old document in the library, and old document is moved under the new document. + * + * + * @author Marko Luukkainen + * + */ +public abstract class AddDocumentAction implements ActionFactory { + + + + + private Resource relation; + + public AddDocumentAction(ReadGraph graph, String relationUri) throws DatabaseException { + relation = graph.getResource(relationUri); + } + + + protected Resource getRelation() { + return relation; + } + + protected void linkDocument(WriteGraph graph, Resource target, Resource newDocument) throws DatabaseException{ + DocumentResource doc = DocumentResource.getInstance(graph); + + if (graph.isInstanceOf(target, doc.Document)) { + // adding a new revision + DocumentVersionUtils.createNewVersion(graph, target, newDocument, relation); + + + } else { + graph.claim(target, relation, newDocument); + FileDocumentUtil.createUniqueName(graph, newDocument); + } + } + +}