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
.jcr
.JcrUtils
;
23 import org
.argeo
.slc
.SlcException
;
24 import org
.argeo
.slc
.client
.ui
.dist
.DistPlugin
;
25 import org
.argeo
.slc
.jcr
.SlcNames
;
26 import org
.argeo
.slc
.repo
.RepoService
;
27 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
28 import org
.eclipse
.ui
.IEditorInput
;
29 import org
.eclipse
.ui
.IEditorSite
;
30 import org
.eclipse
.ui
.PartInitException
;
31 import org
.eclipse
.ui
.forms
.editor
.FormEditor
;
33 /** Artifact editor in a multiple repository environment */
34 public class ArtifactVersionEditor
extends FormEditor
implements SlcNames
{
35 private static final long serialVersionUID
= 1109872666962757000L;
37 public final static String ID
= DistPlugin
.PLUGIN_ID
+ ".artifactVersionEditor";
39 /* DEPENDENCY INJECTION */
40 private RepoService repoService
;
43 private Session businessSession
;
44 private Node artifact
;
46 private ModuleEditorInput editorInput
;
49 public void init(IEditorSite site
, IEditorInput input
)
50 throws PartInitException
{
51 editorInput
= (ModuleEditorInput
) input
;
52 businessSession
= repoService
.getRemoteSession(
53 editorInput
.getRepoNodePath(), editorInput
.getUri(),
54 editorInput
.getWorkspaceName());
56 artifact
= businessSession
.getNode(editorInput
.getModulePath());
57 } catch (RepositoryException e
) {
58 throw new PartInitException(
59 "Unable to initialise editor for artifact "
60 + editorInput
.getModulePath() + " in workspace "
61 + editorInput
.getWorkspaceName(), e
);
63 super.init(site
, input
);
66 /** Override to provide a specific part name */
67 protected String
getFormattedName() {
69 String partName
= null;
70 if (artifact
.hasProperty(SLC_ARTIFACT_ID
))
71 partName
= artifact
.getProperty(SLC_ARTIFACT_ID
).getString();
73 partName
= artifact
.getName();
75 if (partName
.length() > 10) {
76 partName
= "..." + partName
.substring(partName
.length() - 10);
79 } catch (RepositoryException re
) {
80 throw new SlcException(
81 "unable to get slc:artifactId Property for node "
87 protected void addPages() {
88 setPartName(getFormattedName());
91 addPage(new BundleDetailPage(this, "Details ", artifact
));
92 addPage(new BundleDependencyPage(this, "Dependencies ", artifact
));
93 addPage(new BundleRawPage(this, "Raw Meta-Data ", artifact
));
94 } catch (PartInitException e
) {
95 throw new SlcException("Cannot add distribution editor pages", e
);
101 public void doSave(IProgressMonitor arg0
) {
105 public void dispose() {
106 JcrUtils
.logoutQuietly(businessSession
);
111 public void doSaveAs() {
115 public boolean isSaveAsAllowed() {
119 protected RepoService
getRepoService() {
123 protected Node
getArtifact() {
127 /* DEPENDENCY INJECTION */
128 public void setRepoService(RepoService repoService
) {
129 this.repoService
= repoService
;