]> git.argeo.org Git - gpl/argeo-slc.git/blob - plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistributionEditor.java
Rough protection against too long workspaces name (causes trouble with PostgreSQL)
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui.dist / src / main / java / org / argeo / slc / client / ui / dist / editors / DistributionEditor.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16 package org.argeo.slc.client.ui.dist.editors;
17
18 import javax.jcr.RepositoryException;
19 import javax.jcr.Session;
20
21 import org.argeo.ArgeoException;
22 import org.argeo.jcr.JcrUtils;
23 import org.argeo.slc.client.ui.dist.DistPlugin;
24 import org.argeo.slc.jcr.SlcNames;
25 import org.eclipse.core.runtime.IProgressMonitor;
26 import org.eclipse.ui.IEditorInput;
27 import org.eclipse.ui.IEditorSite;
28 import org.eclipse.ui.PartInitException;
29 import org.eclipse.ui.forms.editor.FormEditor;
30
31 /**
32 * Editor to browse, analyze and modify an OSGi distribution
33 */
34 public class DistributionEditor extends FormEditor implements SlcNames {
35 // private final static Log log =
36 // LogFactory.getLog(DistributionEditor.class);
37 public final static String ID = DistPlugin.ID + ".distributionEditor";
38
39 private Session session;
40
41 @Override
42 public void init(IEditorSite site, IEditorInput input)
43 throws PartInitException {
44 DistributionEditorInput dei = (DistributionEditorInput) input;
45 try {
46 session = dei.getRepository().login(dei.getCredentials(),
47 dei.getWorkspaceName());
48 } catch (RepositoryException e) {
49 throw new PartInitException("Cannot log to workspace "
50 + dei.getWorkspaceName(), e);
51 }
52 setPartName(dei.getWorkspaceName());
53 super.init(site, input);
54 }
55
56 @Override
57 protected void addPages() {
58 try {
59 addPage(new DistributionOverviewPage(this, "Overview", session));
60 addPage(new ArtifactsBrowserPage(this, "Browser", session));
61 } catch (PartInitException e) {
62 throw new ArgeoException("Cannot add distribution editor pages", e);
63 }
64 }
65
66 @Override
67 public void doSave(IProgressMonitor arg0) {
68 }
69
70 @Override
71 public void dispose() {
72 JcrUtils.logoutQuietly(session);
73 super.dispose();
74 }
75
76 @Override
77 public void doSaveAs() {
78 }
79
80 @Override
81 public boolean isSaveAsAllowed() {
82 return false;
83 }
84
85 }