2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.slc
.client
.ui
.dist
.editors
;
18 import javax
.jcr
.Node
;
19 import javax
.jcr
.RepositoryException
;
20 import javax
.jcr
.Session
;
22 import org
.argeo
.ArgeoException
;
23 import org
.argeo
.jcr
.JcrUtils
;
24 import org
.argeo
.slc
.SlcException
;
25 import org
.argeo
.slc
.client
.ui
.dist
.DistPlugin
;
26 import org
.argeo
.slc
.jcr
.SlcNames
;
27 import org
.argeo
.slc
.repo
.RepoService
;
28 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
29 import org
.eclipse
.ui
.IEditorInput
;
30 import org
.eclipse
.ui
.IEditorSite
;
31 import org
.eclipse
.ui
.PartInitException
;
32 import org
.eclipse
.ui
.forms
.editor
.FormEditor
;
35 * Base editor to manage an artifact in a multiple repository environment
37 public class ArtifactVersionEditor
extends FormEditor
implements SlcNames
{
38 // private final static Log log =
39 // LogFactory.getLog(ArtifactEditor.class);
40 public final static String ID
= DistPlugin
.ID
+ ".artifactVersionEditor";
42 /* DEPENDENCY INJECTION */
43 private RepoService repoService
;
46 private Session businessSession
;
47 private Node artifact
;
49 private ModuleEditorInput editorInput
;
52 public void init(IEditorSite site
, IEditorInput input
)
53 throws PartInitException
{
54 editorInput
= (ModuleEditorInput
) input
;
55 businessSession
= repoService
.getRemoteSession(
56 editorInput
.getRepoNodePath(), editorInput
.getUri(),
57 editorInput
.getWorkspaceName());
59 artifact
= businessSession
.getNode(editorInput
.getModulePath());
60 } catch (RepositoryException e
) {
61 throw new PartInitException(
62 "Unable to initialise editor for artifact "
63 + editorInput
.getModulePath() + " in workspace "
64 + editorInput
.getWorkspaceName(), e
);
66 super.init(site
, input
);
69 /** Override to provide a specific part name */
70 protected String
getFormattedName() {
72 String partName
= null;
73 if (artifact
.hasProperty(SLC_ARTIFACT_ID
))
74 partName
= artifact
.getProperty(SLC_ARTIFACT_ID
).getString();
76 partName
= artifact
.getName();
78 if (partName
.length() > 10) {
79 partName
= "..." + partName
.substring(partName
.length() - 10);
82 } catch (RepositoryException re
) {
83 throw new SlcException(
84 "unable to get slc:artifactId Property for node "
90 protected void addPages() {
91 setPartName(getFormattedName());
94 addPage(new BundleDetailPage(this, "Details ", artifact
));
95 addPage(new BundleDependencyPage(this, "Dependencies ", artifact
));
96 addPage(new BundleRawPage(this, "Raw Meta-Data ", artifact
));
97 } catch (PartInitException e
) {
98 throw new ArgeoException("Cannot add distribution editor pages", e
);
104 public void doSave(IProgressMonitor arg0
) {
108 public void dispose() {
109 JcrUtils
.logoutQuietly(businessSession
);
114 public void doSaveAs() {
118 public boolean isSaveAsAllowed() {
122 protected RepoService
getRepoService() {
126 protected Node
getArtifact() {
130 /* DEPENDENCY INJECTION */
131 public void setRepoService(RepoService repoService
) {
132 this.repoService
= repoService
;