<bean id="normalizeDistribution"
class="org.argeo.slc.client.ui.dist.commands.NormalizeDistribution">
<property name="repositoryFactory" ref="repositoryFactory" />
+ <property name="keyring" ref="keyring" />
<property name="nodeRepository" ref="nodeRepository" />
+ </bean>
+
+ <bean id="openModuleEditor" class="org.argeo.slc.client.ui.dist.commands.OpenModuleEditor"
+ scope="prototype">
+ <property name="repositoryFactory" ref="repositoryFactory" />
<property name="keyring" ref="keyring" />
+ <property name="localRepository" ref="nodeRepository" />
</bean>
<!-- REPOSITORY MANAGEMENT -->
<property name="session" ref="slcSession" />
</bean>
- <bean id="distributionWorkspaceEditor"
- class="org.argeo.slc.client.ui.dist.editors.DistributionWorkspaceEditor"
+ <bean id="distWorkspaceEditor"
+ class="org.argeo.slc.client.ui.dist.editors.DistWorkspaceEditor"
+ scope="prototype">
+ <property name="repositoryFactory" ref="repositoryFactory" />
+ <property name="keyring" ref="keyring" />
+ <property name="localRepository" ref="nodeRepository" />
+ </bean>
+
+ <bean id="artifactVersionEditor"
+ class="org.argeo.slc.client.ui.dist.editors.ArtifactVersionEditor"
+ scope="prototype">
+ <property name="repositoryFactory" ref="repositoryFactory" />
+ <property name="keyring" ref="keyring" />
+ <property name="localRepository" ref="nodeRepository" />
+ </bean>
+ <bean id="modularDistVersionEditor"
+ class="org.argeo.slc.client.ui.dist.editors.ModularDistVersionEditor"
scope="prototype">
<property name="repositoryFactory" ref="repositoryFactory" />
<property name="keyring" ref="keyring" />
default="false">
</editor>
<editor
- class="org.argeo.slc.client.ui.dist.editors.DistributionEditor"
- id="org.argeo.slc.client.ui.dist.distributionEditor"
- name="Distribution editor"
- icon="icons/distribution_perspective.gif"
+ class="org.argeo.eclipse.spring.SpringExtensionFactory"
+ id="org.argeo.slc.client.ui.dist.artifactVersionEditor"
+ name="Artifact Version Editor"
+ icon="icons/artifactVersionBase.gif"
+ default="false">
+ </editor>
+ <editor
+ class="org.argeo.eclipse.spring.SpringExtensionFactory"
+ id="org.argeo.slc.client.ui.dist.modularDistVersionEditor"
+ name="Modular Distribution Version Editor"
+ icon="icons/modularDistributionVersion.gif"
default="false">
</editor>
<editor
class="org.argeo.eclipse.spring.SpringExtensionFactory"
- id="org.argeo.slc.client.ui.dist.distributionWorkspaceEditor"
+ id="org.argeo.slc.client.ui.dist.distWorkspaceEditor"
name="Distribution workspace editor"
icon="icons/distribution_perspective.gif"
default="false">
</commandParameter>
</command>
+ <command
+ id="org.argeo.slc.client.ui.dist.openModuleEditor"
+ defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+ name="Open Workspace Editor">
+ <commandParameter
+ id="param.repoNodePath"
+ name="Repo node path">
+ </commandParameter>
+ <commandParameter
+ id="param.repoUri"
+ name="Repo URI">
+ </commandParameter>
+ <commandParameter
+ id="param.workspaceName"
+ name="Workspace name">
+ </commandParameter>
+ <commandParameter
+ id="param.modulePath"
+ name="Module path name">
+ </commandParameter>
+ </command>
+
<!-- Repository Management -->
<command
id="org.argeo.slc.client.ui.dist.registerRepository"
+ session.getWorkspace().getName(),
expectedCount.intValue());
NormalizingTraverser tiv = new NormalizingTraverser(monitor);
- Node artifactBaseNode =session.getNode(artifactBasePath);
+ Node artifactBaseNode = session.getNode(artifactBasePath);
artifactBaseNode.accept(tiv);
} catch (Exception e) {
+ log.error("Error normalizing workspace "
+ + session.getWorkspace().getName() + ": "
+ + e.getMessage());
+ if (log.isErrorEnabled())
+ e.printStackTrace();
return new Status(IStatus.ERROR, DistPlugin.ID,
"Cannot normalize distribution "
+ session.getWorkspace().getName(), e);
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.editors.ArtifactEditor;
+import org.argeo.slc.client.ui.dist.editors.ArtifactVersionEditor;
+import org.argeo.slc.client.ui.dist.editors.ModularDistVersionEditor;
import org.argeo.slc.client.ui.dist.editors.ModuleEditorInput;
-import org.argeo.slc.client.ui.dist.editors.DistributionEditor;
import org.argeo.slc.jcr.SlcTypes;
import org.argeo.slc.repo.RepoUtils;
import org.argeo.util.security.Keyring;
// relevant repository
public final static String PARAM_REPO_URI = "param.repoUri";
public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
- public final static String PARAM_ARTIFACT_PATH = "param.artifactPath";
+ public final static String PARAM_MODULE_PATH = "param.modulePath";
/* DEPENDENCY INJECTION */
private Repository localRepository;
String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
String repoUri = event.getParameter(PARAM_REPO_URI);
String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
- String artifactPath = event.getParameter(PARAM_ARTIFACT_PATH);
+ String modulePath = event.getParameter(PARAM_MODULE_PATH);
Session localSession = null;
Session businessSession = null;
Node repoNode = null;
try {
- if (repoNodePath != null && repoUri == null) {
- try {
- localSession = localRepository.login();
- if (repoNodePath != null
- && localSession.nodeExists(repoNodePath))
- repoNode = localSession.getNode(repoNodePath);
-
- businessSession = RepoUtils.getCorrespondingSession(
- repositoryFactory, keyring, repoNode, repoUri,
- workspaceName);
- repoUri = repoNode.getProperty(ArgeoNames.ARGEO_URI)
- .getString();
-
- } catch (RepositoryException e) {
- throw new SlcException("Cannot log to workspace "
- + workspaceName + " for repo defined in "
- + repoNodePath, e);
- } finally {
- JcrUtils.logoutQuietly(localSession);
- }
-
+ try {
+ localSession = localRepository.login();
+ if (repoNodePath != null
+ && localSession.nodeExists(repoNodePath))
+ repoNode = localSession.getNode(repoNodePath);
+
+ businessSession = RepoUtils.getCorrespondingSession(
+ repositoryFactory, keyring, repoNode, repoUri,
+ workspaceName);
+ repoUri = repoNode.getProperty(ArgeoNames.ARGEO_URI)
+ .getString();
+
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot log to workspace "
+ + workspaceName + " for repo defined in "
+ + repoNodePath, e);
+ } finally {
+ JcrUtils.logoutQuietly(localSession);
}
ModuleEditorInput wei = new ModuleEditorInput(repoNodePath,
- repoUri, workspaceName, artifactPath);
- Node artifact = businessSession.getNode(artifactPath);
+ repoUri, workspaceName, modulePath);
+ Node artifact = businessSession.getNode(modulePath);
// Choose correct editor based on the artifact mixin
if (artifact.isNodeType(SlcTypes.SLC_MODULAR_DISTRIBUTION))
HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
- .openEditor(wei, DistributionEditor.ID);
+ .openEditor(wei, ModularDistVersionEditor.ID);
else
HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
- .openEditor(wei, ArtifactEditor.ID);
+ .openEditor(wei, ArtifactVersionEditor.ID);
} catch (RepositoryException e) {
throw new SlcException("Unexpected error while "
+ "getting repoNode info for repoNode at path "
+ "opening editor for workspace " + workspaceName
+ " with URI " + repoUri + " and repoNode at path "
+ repoNodePath, e);
+ } finally {
+ JcrUtils.logoutQuietly(businessSession);
}
return null;
}
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.editors.DistributionWorkspaceEditor;
-import org.argeo.slc.client.ui.dist.editors.WorkspaceEditorInput;
+import org.argeo.slc.client.ui.dist.editors.DistWorkspaceEditor;
+import org.argeo.slc.client.ui.dist.editors.DistWkspEditorInput;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
Session defaultSession = null;
if (repoNodePath != null && repoUri == null) {
try {
-
defaultSession = localRepository.login();
if (defaultSession.nodeExists(repoNodePath)) {
Node repoNode = defaultSession.getNode(repoNodePath);
}
} catch (RepositoryException e) {
throw new SlcException("Unexpected error while "
- + "getting repoNode info for repoNode at path "
+ + "getting repoNode at path "
+ repoNodePath, e);
} finally {
JcrUtils.logoutQuietly(defaultSession);
}
}
- WorkspaceEditorInput wei = new WorkspaceEditorInput(repoNodePath,
+ DistWkspEditorInput wei = new DistWkspEditorInput(repoNodePath,
repoUri, workspaceName);
try {
HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
- .openEditor(wei, DistributionWorkspaceEditor.ID);
+ .openEditor(wei, DistWorkspaceEditor.ID);
} catch (PartInitException e) {
throw new SlcException("Unexpected error while "
+ "opening editor for workspace " + workspaceName
import org.argeo.slc.client.ui.dist.DistPlugin;
import org.argeo.slc.client.ui.dist.editors.DistributionEditor;
-import org.argeo.slc.client.ui.dist.editors.DistributionOverviewPage;
+import org.argeo.slc.client.ui.dist.editors.DistWkspSearchPage;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
if (activePart instanceof DistributionEditor) {
IFormPage ifp = ((DistributionEditor) activePart)
.getActivePageInstance();
- if (ifp instanceof DistributionOverviewPage)
- ((DistributionOverviewPage) ifp).refresh();
+ if (ifp instanceof DistWkspSearchPage)
+ ((DistWkspSearchPage) ifp).refresh();
}
return null;
}
params.put(OpenModuleEditor.PARAM_REPO_URI, repoElem.getUri());
params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
wkspElem.getWorkspaceName());
- params.put(OpenModuleEditor.PARAM_ARTIFACT_PATH,
+ params.put(OpenModuleEditor.PARAM_MODULE_PATH,
moduleNode.getPath());
CommandUtils.callCommand(OpenModuleEditor.ID, params);
} catch (RepositoryException re) {
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.client.ui.dist.editors;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-
-import org.argeo.ArgeoException;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.jcr.SlcNames;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.util.security.Keyring;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.forms.editor.FormEditor;
-
-/**
- * Base editor to manage an artifact in a multirepository environment
- */
-public class ArtifactEditor extends FormEditor implements SlcNames {
- // private final static Log log =
- // LogFactory.getLog(ArtifactEditor.class);
- public final static String ID = DistPlugin.ID + ".artifactEditor";
-
- private ModuleEditorInput editorInput;
-
- /* DEPENDENCY INJECTION */
- private RepositoryFactory repositoryFactory;
- private Repository localRepository;
- private Keyring keyring;
-
- // Business objects
- private Node repoNode;
- // Session that provides the node in the home of the local repository
- private Session localSession = null;
- // The business Session on an optionally remote repository
- private Session businessSession;
- private Node artifact;
-
- @Override
- public void init(IEditorSite site, IEditorInput input)
- throws PartInitException {
- editorInput = (ModuleEditorInput) input;
- try {
- localSession = localRepository.login();
- if (editorInput.getRepoNodePath() != null
- && localSession.nodeExists(editorInput.getRepoNodePath()))
- repoNode = localSession.getNode(editorInput.getRepoNodePath());
- businessSession = RepoUtils.getCorrespondingSession(
- repositoryFactory, keyring, repoNode, editorInput.getUri(),
- editorInput.getWorkspaceName());
- artifact = businessSession.getNode(editorInput.getModulePath());
- } catch (RepositoryException e) {
- throw new PartInitException(
- "Unable to initialise editor for artifact "
- + editorInput.getModulePath() + " in workspace "
- + editorInput.getWorkspaceName()
- + " of repository " + editorInput.getUri(), e);
- }
- setPartName(editorInput.getWorkspaceName());
- super.init(site, input);
- }
-
- @Override
- protected void addPages() {
- try {
- addPage(new DistributionOverviewPage(this, "Overview",
- businessSession));
- addPage(new ArtifactsBrowserPage(this, "Browser", businessSession));
- } catch (PartInitException e) {
- throw new ArgeoException("Cannot add distribution editor pages", e);
- }
- }
-
- @Override
- public void doSave(IProgressMonitor arg0) {
- }
-
- @Override
- public void dispose() {
- JcrUtils.logoutQuietly(businessSession);
- JcrUtils.logoutQuietly(localSession);
- super.dispose();
- }
-
- @Override
- public void doSaveAs() {
- }
-
- @Override
- public boolean isSaveAsAllowed() {
- return false;
- }
-
- protected Node getRepoNode() {
- return repoNode;
- }
-
- protected Node getArtifact() {
- return artifact;
- }
-
- /* DEPENDENCY INJECTION */
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-
- public void setLocalRepository(Repository localRepository) {
- this.localRepository = localRepository;
- }
-}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.client.ui.dist.editors;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+
+import org.argeo.ArgeoException;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.jcr.SlcNames;
+import org.argeo.slc.repo.RepoUtils;
+import org.argeo.util.security.Keyring;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.editor.FormEditor;
+
+/**
+ * Base editor to manage an artifact in a multiple repository environment
+ */
+public class ArtifactVersionEditor extends FormEditor implements SlcNames {
+ // private final static Log log =
+ // LogFactory.getLog(ArtifactEditor.class);
+ public final static String ID = DistPlugin.ID + ".artifactVersionEditor";
+
+ private ModuleEditorInput editorInput;
+
+ /* DEPENDENCY INJECTION */
+ private RepositoryFactory repositoryFactory;
+ private Repository localRepository;
+ private Keyring keyring;
+
+ // Business objects
+ private Node repoNode;
+ // Session that provides the node in the home of the local repository
+ private Session localSession = null;
+ // The business Session on an optionally remote repository
+ private Session businessSession;
+ private Node artifact;
+
+ @Override
+ public void init(IEditorSite site, IEditorInput input)
+ throws PartInitException {
+ editorInput = (ModuleEditorInput) input;
+ try {
+ localSession = localRepository.login();
+ if (editorInput.getRepoNodePath() != null
+ && localSession.nodeExists(editorInput.getRepoNodePath()))
+ repoNode = localSession.getNode(editorInput.getRepoNodePath());
+ businessSession = RepoUtils.getCorrespondingSession(
+ repositoryFactory, keyring, repoNode, editorInput.getUri(),
+ editorInput.getWorkspaceName());
+ artifact = businessSession.getNode(editorInput.getModulePath());
+ } catch (RepositoryException e) {
+ throw new PartInitException(
+ "Unable to initialise editor for artifact "
+ + editorInput.getModulePath() + " in workspace "
+ + editorInput.getWorkspaceName()
+ + " of repository " + editorInput.getUri(), e);
+ }
+ setPartName(getFormattedName());
+ super.init(site, input);
+ }
+
+ /** Override to provide a specific part name */
+ protected String getFormattedName() {
+ try {
+ String partName = artifact.getProperty(SLC_ARTIFACT_ID).getString();
+
+ if (partName.length() > 10) {
+ partName = "..." + partName.substring(partName.length() - 10);
+ }
+ return partName;
+ } catch (RepositoryException re) {
+ throw new SlcException(
+ "unable to get slc:artifactId Property for node "
+ + artifact, re);
+ }
+ }
+
+ @Override
+ protected void addPages() {
+ try {
+ addPage(new BundleDetailsPage(this, "Details ", artifact));
+ addPage(new BundleRawPage(this, "Raw Meta-Data ", artifact));
+ } catch (PartInitException e) {
+ throw new ArgeoException("Cannot add distribution editor pages", e);
+ }
+ }
+
+ @Override
+ public void doSave(IProgressMonitor arg0) {
+ }
+
+ @Override
+ public void dispose() {
+ JcrUtils.logoutQuietly(businessSession);
+ JcrUtils.logoutQuietly(localSession);
+ super.dispose();
+ }
+
+ @Override
+ public void doSaveAs() {
+ }
+
+ @Override
+ public boolean isSaveAsAllowed() {
+ return false;
+ }
+
+ protected Node getRepoNode() {
+ return repoNode;
+ }
+
+ protected Node getArtifact() {
+ return artifact;
+ }
+
+ /* DEPENDENCY INJECTION */
+ public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+ this.repositoryFactory = repositoryFactory;
+ }
+
+ public void setKeyring(Keyring keyring) {
+ this.keyring = keyring;
+ }
+
+ public void setLocalRepository(Repository localRepository) {
+ this.localRepository = localRepository;
+ }
+}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.client.ui.dist.editors;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.qom.Ordering;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-
-import org.argeo.ArgeoException;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.jcr.SlcNames;
-import org.argeo.slc.jcr.SlcTypes;
-import org.argeo.slc.repo.RepoConstants;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * Expose Maven artifacts of a given workspace as a tree. Artifacts are grouped
- * by Maven group.
- */
-public class ArtifactsBrowserPage extends FormPage implements DistConstants,
- RepoConstants {
- // private final static Log log = LogFactory
- // .getLog(ArtifactsBrowserPage.class);
-
- final static String PAGE_ID = "artifactsBrowserPage";
-
- // Business object
- private Session session;
-
- // This page widgets
- private TreeViewer artifactTreeViewer;
-
- public ArtifactsBrowserPage(FormEditor editor, String title, Session session) {
- super(editor, PAGE_ID, title);
- this.session = session;
- }
-
- @Override
- protected void createFormContent(IManagedForm managedForm) {
- try {
- ScrolledForm form = managedForm.getForm();
- Composite parent = form.getBody();
- parent.setLayout(new FillLayout());
- createExportPackageSection(parent);
- getEditor().getSite().setSelectionProvider(artifactTreeViewer);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot create artifact browser page", e);
- }
- }
-
- private NodeIterator listNodes(String nodeType, String orderBy)
- throws RepositoryException {
- QueryManager queryManager = session.getWorkspace().getQueryManager();
- QueryObjectModelFactory factory = queryManager.getQOMFactory();
-
- final String nodeSelector = "nodes";
- Selector source = factory.selector(nodeType, nodeSelector);
-
- Ordering order = factory.ascending(factory.propertyValue(nodeSelector,
- orderBy));
- Ordering[] orderings = { order };
-
- QueryObjectModel query = factory.createQuery(source, null, orderings,
- null);
-
- QueryResult result = query.execute();
-
- return result.getNodes();
- }
-
- /** Export Package Section */
- private void createExportPackageSection(Composite parent)
- throws RepositoryException {
-
- int style = SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL
- | SWT.FULL_SELECTION | SWT.BORDER;
- Tree tree = new Tree(parent, style);
- createColumn(tree, "Artifacts", SWT.LEFT, 300);
- tree.setLinesVisible(true);
- tree.setHeaderVisible(true);
-
- artifactTreeViewer = new TreeViewer(tree);
-
- artifactTreeViewer.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- Node node = (Node) element;
- try {
- if (node.isNodeType(SlcTypes.SLC_GROUP_BASE))
- return JcrUtils.get((Node) element,
- SlcNames.SLC_GROUP_BASE_ID);
- else if (node.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
- return JcrUtils.get((Node) element,
- SlcNames.SLC_ARTIFACT_ID);
- else
- return node.getName();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot browse artifacts", e);
- }
- }
-
- @Override
- public Image getImage(Object element) {
- Node node = (Node) element;
- try {
-
- if (node.isNodeType(SlcTypes.SLC_GROUP_BASE))
- return DistImages.IMG_GROUP_BASE;
- else if (node.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
- return DistImages.IMG_ARTIFACT_BASE;
- else if (node
- .isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE))
- return DistImages.IMG_ARTIFACT_VERSION_BASE;
- else
- return null;
- } catch (RepositoryException e) {
- throw new SlcException("Cannot get images for artifacts", e);
- }
- }
- });
-
- artifactTreeViewer.setContentProvider(new ITreeContentProvider() {
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
- }
-
- public Object[] getElements(Object inputElement) {
- try {
- List<Node> nodes = JcrUtils.nodeIteratorToList(listNodes(
- SlcTypes.SLC_GROUP_BASE, SlcNames.SLC_NAME));
- return nodes.toArray();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot list children Nodes", e);
- }
- }
-
- public Object[] getChildren(Object parentElement) {
- // Only 3 levels for the time being
- try {
- Node pNode = (Node) parentElement;
- if (pNode.isNodeType(SlcTypes.SLC_GROUP_BASE)) {
- return getArtifactBase(pNode,
- SlcTypes.SLC_ARTIFACT_BASE);
- } else if (pNode.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
- return getArtifactBase(pNode,
- SlcTypes.SLC_ARTIFACT_VERSION_BASE);
- }
- return null;
- } catch (RepositoryException e) {
- throw new SlcException("Cannot list children Nodes", e);
- }
- }
-
- // Helper to get children because current version of Jackrabbit is
- // buggy in remote
- private Object[] getArtifactBase(Node parent, String nodeType)
- throws RepositoryException {
- List<Node> nodes = new ArrayList<Node>();
- NodeIterator ni = parent.getNodes();
- while (ni.hasNext()) {
- Node node = ni.nextNode();
- if (node.isNodeType(nodeType))
- nodes.add(node);
- }
- return nodes.toArray();
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public boolean hasChildren(Object element) {
- try {
- Node pNode = (Node) element;
- if (pNode.isNodeType(SlcTypes.SLC_GROUP_BASE)
- || pNode.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
- // might return true even if there is no "valid" child
- return pNode.hasNodes();
- } else
- return false;
- } catch (RepositoryException e) {
- throw new SlcException("Cannot check children Nodes", e);
- }
- }
- });
-
- artifactTreeViewer.addDoubleClickListener(new DoubleClickListener());
-
- artifactTreeViewer.setInput("Initialize");
- }
-
- private class DoubleClickListener implements IDoubleClickListener {
-
- public void doubleClick(DoubleClickEvent event) {
- Object obj = ((IStructuredSelection) event.getSelection())
- .getFirstElement();
- try {
- if (obj instanceof Node) {
- Node node = (Node) obj;
- if (node.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
- // TODO fix using QOM after jcr upgrade
- NodeIterator ni = node.getNodes();
- while (ni.hasNext()) {
- Node curr = ni.nextNode();
- if (curr.isNodeType(SlcTypes.SLC_BUNDLE_ARTIFACT)) {
- GenericBundleEditorInput gaei = new GenericBundleEditorInput(
- curr);
- DistPlugin
- .getDefault()
- .getWorkbench()
- .getActiveWorkbenchWindow()
- .getActivePage()
- .openEditor(gaei,
- GenericBundleEditor.ID);
- }
- }
- }
- }
- } catch (RepositoryException re) {
- throw new ArgeoException(
- "Repository error while getting node info", re);
- } catch (PartInitException pie) {
- throw new ArgeoException(
- "Unexepected exception while opening artifact editor",
- pie);
- }
- }
- }
-
- private static TreeColumn createColumn(Tree parent, String name, int style,
- int width) {
- TreeColumn result = new TreeColumn(parent, style);
- result.setText(name);
- result.setWidth(width);
- result.setMoveable(true);
- result.setResizable(true);
- return result;
- }
-
-}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.client.ui.dist.editors;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.qom.Ordering;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.Selector;
+
+import org.argeo.ArgeoException;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistConstants;
+import org.argeo.slc.client.ui.dist.DistImages;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.jcr.SlcNames;
+import org.argeo.slc.jcr.SlcTypes;
+import org.argeo.slc.repo.RepoConstants;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/**
+ * Expose Maven artifacts of a given workspace as a tree. Artifacts are grouped
+ * by Maven group.
+ */
+public class DistWkspBrowserPage extends FormPage implements DistConstants,
+ RepoConstants {
+ // private final static Log log = LogFactory
+ // .getLog(ArtifactsBrowserPage.class);
+
+ final static String PAGE_ID = "artifactsBrowserPage";
+
+ // Business object
+ private Session session;
+
+ // This page widgets
+ private TreeViewer artifactTreeViewer;
+
+ public DistWkspBrowserPage(FormEditor editor, String title, Session session) {
+ super(editor, PAGE_ID, title);
+ this.session = session;
+ }
+
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ try {
+ ScrolledForm form = managedForm.getForm();
+ Composite parent = form.getBody();
+ parent.setLayout(new FillLayout());
+ createExportPackageSection(parent);
+ getEditor().getSite().setSelectionProvider(artifactTreeViewer);
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot create artifact browser page", e);
+ }
+ }
+
+ private NodeIterator listNodes(String nodeType, String orderBy)
+ throws RepositoryException {
+ QueryManager queryManager = session.getWorkspace().getQueryManager();
+ QueryObjectModelFactory factory = queryManager.getQOMFactory();
+
+ final String nodeSelector = "nodes";
+ Selector source = factory.selector(nodeType, nodeSelector);
+
+ Ordering order = factory.ascending(factory.propertyValue(nodeSelector,
+ orderBy));
+ Ordering[] orderings = { order };
+
+ QueryObjectModel query = factory.createQuery(source, null, orderings,
+ null);
+
+ QueryResult result = query.execute();
+
+ return result.getNodes();
+ }
+
+ /** Export Package Section */
+ private void createExportPackageSection(Composite parent)
+ throws RepositoryException {
+
+ int style = SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL
+ | SWT.FULL_SELECTION | SWT.BORDER;
+ Tree tree = new Tree(parent, style);
+ createColumn(tree, "Artifacts", SWT.LEFT, 300);
+ tree.setLinesVisible(true);
+ tree.setHeaderVisible(true);
+
+ artifactTreeViewer = new TreeViewer(tree);
+
+ artifactTreeViewer.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ Node node = (Node) element;
+ try {
+ if (node.isNodeType(SlcTypes.SLC_GROUP_BASE))
+ return JcrUtils.get((Node) element,
+ SlcNames.SLC_GROUP_BASE_ID);
+ else if (node.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
+ return JcrUtils.get((Node) element,
+ SlcNames.SLC_ARTIFACT_ID);
+ else
+ return node.getName();
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot browse artifacts", e);
+ }
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ Node node = (Node) element;
+ try {
+
+ if (node.isNodeType(SlcTypes.SLC_GROUP_BASE))
+ return DistImages.IMG_GROUP_BASE;
+ else if (node.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
+ return DistImages.IMG_ARTIFACT_BASE;
+ else if (node
+ .isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE))
+ return DistImages.IMG_ARTIFACT_VERSION_BASE;
+ else
+ return null;
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot get images for artifacts", e);
+ }
+ }
+ });
+
+ artifactTreeViewer.setContentProvider(new ITreeContentProvider() {
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput,
+ Object newInput) {
+ }
+
+ public Object[] getElements(Object inputElement) {
+ try {
+ List<Node> nodes = JcrUtils.nodeIteratorToList(listNodes(
+ SlcTypes.SLC_GROUP_BASE, SlcNames.SLC_NAME));
+ return nodes.toArray();
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot list children Nodes", e);
+ }
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ // Only 3 levels for the time being
+ try {
+ Node pNode = (Node) parentElement;
+ if (pNode.isNodeType(SlcTypes.SLC_GROUP_BASE)) {
+ return getArtifactBase(pNode,
+ SlcTypes.SLC_ARTIFACT_BASE);
+ } else if (pNode.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
+ return getArtifactBase(pNode,
+ SlcTypes.SLC_ARTIFACT_VERSION_BASE);
+ }
+ return null;
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot list children Nodes", e);
+ }
+ }
+
+ // Helper to get children because current version of Jackrabbit is
+ // buggy in remote
+ private Object[] getArtifactBase(Node parent, String nodeType)
+ throws RepositoryException {
+ List<Node> nodes = new ArrayList<Node>();
+ NodeIterator ni = parent.getNodes();
+ while (ni.hasNext()) {
+ Node node = ni.nextNode();
+ if (node.isNodeType(nodeType))
+ nodes.add(node);
+ }
+ return nodes.toArray();
+ }
+
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ try {
+ Node pNode = (Node) element;
+ if (pNode.isNodeType(SlcTypes.SLC_GROUP_BASE)
+ || pNode.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
+ // might return true even if there is no "valid" child
+ return pNode.hasNodes();
+ } else
+ return false;
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot check children Nodes", e);
+ }
+ }
+ });
+
+ artifactTreeViewer.addDoubleClickListener(new DoubleClickListener());
+
+ artifactTreeViewer.setInput("Initialize");
+ }
+
+ private class DoubleClickListener implements IDoubleClickListener {
+
+ public void doubleClick(DoubleClickEvent event) {
+ Object obj = ((IStructuredSelection) event.getSelection())
+ .getFirstElement();
+ try {
+ if (obj instanceof Node) {
+ Node node = (Node) obj;
+ if (node.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
+ // TODO fix using QOM after jcr upgrade
+ NodeIterator ni = node.getNodes();
+ while (ni.hasNext()) {
+ Node curr = ni.nextNode();
+ if (curr.isNodeType(SlcTypes.SLC_BUNDLE_ARTIFACT)) {
+ GenericBundleEditorInput gaei = new GenericBundleEditorInput(
+ curr);
+ DistPlugin
+ .getDefault()
+ .getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getActivePage()
+ .openEditor(gaei,
+ GenericBundleEditor.ID);
+ }
+ }
+ }
+ }
+ } catch (RepositoryException re) {
+ throw new ArgeoException(
+ "Repository error while getting node info", re);
+ } catch (PartInitException pie) {
+ throw new ArgeoException(
+ "Unexepected exception while opening artifact editor",
+ pie);
+ }
+ }
+ }
+
+ private static TreeColumn createColumn(Tree parent, String name, int style,
+ int width) {
+ TreeColumn result = new TreeColumn(parent, style);
+ result.setText(name);
+ result.setWidth(width);
+ result.setMoveable(true);
+ result.setResizable(true);
+ return result;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.client.ui.dist.editors;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.jcr.SlcNames;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+/**
+ * An editor input pointing to a distribution workspace
+ */
+public class DistWkspEditorInput implements IEditorInput, SlcNames {
+
+ // Injected
+ // private RepositoryFactory repositoryFactory;
+ // private Keyring keyring;
+ // private Node repoNode;
+ private String repoNodePath;
+ private String uri;
+
+ // Local variables
+ private String workspaceName;
+
+ // public WorkspaceEditorInput(RepositoryFactory repositoryFactory,
+ // Keyring keyring, Repository localRepository, Node repoNode,
+ // String uri) {
+ // // this.repositoryFactory = repositoryFactory;
+ // // this.keyring = keyring;
+ // this.localRepository = localRepository;
+ // // this.repoNode= repoNode;
+ // this.uri = uri;
+ //
+ // }
+
+ /** uri and workspace name cannot be null */
+ public DistWkspEditorInput(String repoNodePath, String uri,
+ String workspaceName) {
+ if (workspaceName == null)
+ throw new SlcException("Workspace name cannot be null");
+ if (uri == null)
+ throw new SlcException("URI for repository cannot be null");
+ this.repoNodePath = repoNodePath;
+ this.workspaceName = workspaceName;
+ this.uri = uri;
+ }
+
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ return null;
+ }
+
+ public boolean exists() {
+ return true;
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return null;
+ }
+
+ // Dummy compulsory methods
+ public String getToolTipText() {
+ return "Editor for workspace " + workspaceName
+ + " in repository of URI " + uri;
+ }
+
+ public String getName() {
+ return workspaceName + "@" + uri;
+ }
+
+ public IPersistableElement getPersistable() {
+ return null;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof DistWkspEditorInput))
+ return false;
+
+ DistWkspEditorInput other = (DistWkspEditorInput) obj;
+
+ if (!workspaceName.equals(other.getWorkspaceName()))
+ return false;
+ if (!uri.equals(other.getUri()))
+ return false;
+
+ if (repoNodePath == null)
+ return other.getRepoNodePath() == null;
+ else
+ return repoNodePath.equals(other.getRepoNodePath());
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public String getWorkspaceName() {
+ return workspaceName;
+ }
+
+ public String getRepoNodePath() {
+ return repoNodePath;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.client.ui.dist.editors;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.qom.Constraint;
+import javax.jcr.query.qom.DynamicOperand;
+import javax.jcr.query.qom.Ordering;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.Selector;
+import javax.jcr.query.qom.StaticOperand;
+
+import org.argeo.ArgeoMonitor;
+import org.argeo.eclipse.ui.EclipseArgeoMonitor;
+import org.argeo.eclipse.ui.utils.CommandUtils;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistConstants;
+import org.argeo.slc.client.ui.dist.DistImages;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.PrivilegedJob;
+import org.argeo.slc.client.ui.dist.commands.DeleteArtifacts;
+import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
+import org.argeo.slc.client.ui.dist.utils.NodeViewerComparator;
+import org.argeo.slc.jcr.SlcNames;
+import org.argeo.slc.jcr.SlcTypes;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/** Show all bundles contained in a given workspace as filter-able table */
+public class DistWkspSearchPage extends FormPage implements SlcNames {
+ // final private static Log log = LogFactory
+ // .getLog(DistributionOverviewPage.class);
+
+ final static String PAGE_ID = "distributionOverviewPage";
+
+ // Business Objects
+ private Session session;
+
+ // This page widgets
+ private DistWorkspaceEditor formEditor;
+ private FormToolkit tk;
+
+ private NodeViewerComparator comparator;
+ private TableViewer viewer;
+
+ private Composite header;
+ private Text artifactTxt;
+ private final static String FILTER_HELP_MSG = "Enter filter criterion separated by a space";
+
+ public DistWkspSearchPage(DistWorkspaceEditor formEditor, String title,
+ Session session) {
+ super(formEditor, PAGE_ID, title);
+ this.formEditor = formEditor;
+ this.session = session;
+ }
+
+ private void asynchronousRefresh() {
+ RefreshJob job = new RefreshJob(artifactTxt.getText(), viewer,
+ getSite().getShell().getDisplay());
+ job.setUser(true);
+ job.schedule();
+ }
+
+ private class RefreshJob extends PrivilegedJob {
+ private TableViewer viewer;
+ private String filter;
+ private Display display;
+
+ public RefreshJob(String filter, TableViewer viewer, Display display) {
+ super("Get bundle list");
+ this.filter = filter;
+ this.viewer = viewer;
+ this.display = display;
+ }
+
+ @Override
+ protected IStatus doRun(IProgressMonitor progressMonitor) {
+ try {
+ ArgeoMonitor monitor = new EclipseArgeoMonitor(progressMonitor);
+ monitor.beginTask("Getting bundle list", -1);
+ final List<Node> result = JcrUtils
+ .nodeIteratorToList(listBundleArtifacts(session, filter));
+
+ display.asyncExec(new Runnable() {
+ public void run() {
+ viewer.setInput(result);
+ }
+ });
+ } catch (Exception e) {
+ return new Status(IStatus.ERROR, DistPlugin.ID,
+ "Cannot get bundle list", e);
+ }
+ return Status.OK_STATUS;
+ }
+ }
+
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ ScrolledForm form = managedForm.getForm();
+ tk = managedForm.getToolkit();
+
+ // Main Layout
+ GridLayout layout = new GridLayout(1, false);
+ Composite body = form.getBody();
+ body.setLayout(layout);
+
+ // Add the filter section
+ createFilterPart(body);
+ // Add the table
+ createTableViewer(body);
+ // viewer.setInput(null);
+ // Add a listener to enable custom resize process
+ form.addControlListener(new ControlListener() {
+ // form.addListener(SWT.RESIZE, new Listener() does not work
+ public void controlResized(ControlEvent e) {
+ refreshLayout();
+ }
+
+ public void controlMoved(ControlEvent e) {
+ }
+ });
+ asynchronousRefresh();
+ }
+
+ /** Build repository request */
+ private NodeIterator listBundleArtifacts(Session session, String filter)
+ throws RepositoryException {
+ QueryManager queryManager = session.getWorkspace().getQueryManager();
+ QueryObjectModelFactory factory = queryManager.getQOMFactory();
+
+ final String bundleArtifactsSelector = "bundleArtifacts";
+ Selector source = factory.selector(SlcTypes.SLC_BUNDLE_ARTIFACT,
+ bundleArtifactsSelector);
+
+ // Create a dynamic operand for each property on which we want to filter
+ DynamicOperand symbNameDO = factory.propertyValue(
+ source.getSelectorName(), SlcNames.SLC_SYMBOLIC_NAME);
+ DynamicOperand versionDO = factory.propertyValue(
+ source.getSelectorName(), SlcNames.SLC_BUNDLE_VERSION);
+ DynamicOperand nameDO = factory.propertyValue(source.getSelectorName(),
+ DistConstants.SLC_BUNDLE_NAME);
+
+ // Default Constraint: no source artifacts
+ Constraint defaultC = factory.not(factory.comparison(
+ symbNameDO,
+ QueryObjectModelFactory.JCR_OPERATOR_LIKE,
+ factory.literal(session.getValueFactory().createValue(
+ "%.source"))));
+
+ // Build constraints based the textArea content
+ if (filter != null && !"".equals(filter.trim())) {
+ // Parse the String
+ String[] strs = filter.trim().split(" ");
+ for (String token : strs) {
+ token = token.replace('*', '%');
+ StaticOperand so = factory.literal(session.getValueFactory()
+ .createValue("%" + token + "%"));
+
+ Constraint currC = factory.comparison(symbNameDO,
+ QueryObjectModelFactory.JCR_OPERATOR_LIKE, so);
+ currC = factory.or(currC, factory.comparison(versionDO,
+ QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
+ currC = factory.or(currC, factory.comparison(nameDO,
+ QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
+
+ defaultC = factory.and(defaultC, currC);
+ }
+ }
+
+ Ordering order = factory.descending(factory.propertyValue(
+ bundleArtifactsSelector, SlcNames.SLC_BUNDLE_VERSION));
+ Ordering order2 = factory.ascending(factory.propertyValue(
+ bundleArtifactsSelector, SlcNames.SLC_SYMBOLIC_NAME));
+ Ordering[] orderings = { order, order2 };
+
+ QueryObjectModel query = factory.createQuery(source, defaultC,
+ orderings, null);
+
+ QueryResult result = query.execute();
+ return result.getNodes();
+
+ }
+
+ private void createFilterPart(Composite parent) {
+ header = tk.createComposite(parent);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
+ layout.horizontalSpacing = 5;
+ header.setLayout(layout);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+ header.setLayoutData(gd);
+
+ // Title: some meta information
+ // label = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
+ // .getProperty(Property.JCR_TITLE).getString() : repoNode
+ // .getName();
+
+ String desc = null;
+ Node repoNode = ((DistWorkspaceEditor) getEditor()).getRepoNode();
+ if (repoNode != null)
+ try {
+ desc = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
+ .getProperty(Property.JCR_TITLE).getString() : repoNode
+ .getName();
+ } catch (RepositoryException e1) {
+ throw new SlcException("Unable to get repository alias ", e1);
+ }
+ desc += " (" + ((DistWkspEditorInput) getEditorInput()).getUri() + ")";
+ Label lbl = tk.createLabel(header, desc, SWT.NONE);
+
+ gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+ gd.horizontalSpan = 2;
+ lbl.setLayoutData(gd);
+
+ // Text Area to filter
+ artifactTxt = tk.createText(header, "", SWT.BORDER | SWT.SINGLE
+ | SWT.SEARCH | SWT.CANCEL);
+ artifactTxt.setMessage(FILTER_HELP_MSG);
+ gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+ gd.grabExcessHorizontalSpace = true;
+ artifactTxt.setLayoutData(gd);
+ artifactTxt.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ if ("".equals(artifactTxt.getText().trim()))
+ asynchronousRefresh();
+ else
+ refreshFilteredList();
+ }
+ });
+
+ Button resetBtn = tk.createButton(header, null, SWT.PUSH);
+ resetBtn.setImage(DistImages.IMG_REPO_READONLY);
+ resetBtn.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ resetFilter();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ }
+
+ private void resetFilter() {
+ artifactTxt.setText("");
+ artifactTxt.setMessage(FILTER_HELP_MSG);
+ }
+
+ private void refreshFilteredList() {
+ List<Node> nodes;
+ try {
+ nodes = JcrUtils.nodeIteratorToList(listBundleArtifacts(session,
+ artifactTxt.getText()));
+ viewer.setInput(nodes);
+ } catch (RepositoryException e) {
+ throw new SlcException("Unable to list bundles", e);
+ }
+ }
+
+ private void createTableViewer(Composite parent) {
+ // helpers to enable sorting by column
+ List<String> propertiesList = new ArrayList<String>();
+ List<Integer> propertyTypesList = new ArrayList<Integer>();
+
+ // Define the TableViewer
+ viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
+ | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+
+ // Name
+ TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
+ col.getColumn().setWidth(300);
+ col.getColumn().setText("Name");
+ col.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ return JcrUtils.get((Node) element,
+ DistConstants.SLC_BUNDLE_NAME);
+ }
+ });
+ col.getColumn().addSelectionListener(getSelectionAdapter(0));
+ propertiesList.add(DistConstants.SLC_BUNDLE_NAME);
+ propertyTypesList.add(PropertyType.STRING);
+
+ // Symbolic name
+ col = new TableViewerColumn(viewer, SWT.V_SCROLL);
+ col.getColumn().setWidth(300);
+ col.getColumn().setText("Symbolic Name");
+ col.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ return JcrUtils.get((Node) element, SLC_SYMBOLIC_NAME);
+ }
+ });
+ col.getColumn().addSelectionListener(getSelectionAdapter(1));
+ propertiesList.add(SLC_SYMBOLIC_NAME);
+ propertyTypesList.add(PropertyType.STRING);
+
+ // Version
+ col = new TableViewerColumn(viewer, SWT.NONE);
+ col.getColumn().setWidth(130);
+ col.getColumn().setText("Version");
+ col.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ return JcrUtils.get((Node) element, SLC_BUNDLE_VERSION);
+ }
+ });
+ col.getColumn().addSelectionListener(getSelectionAdapter(2));
+ propertiesList.add(SLC_BUNDLE_VERSION);
+ propertyTypesList.add(PropertyType.STRING);
+
+ final Table table = viewer.getTable();
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ viewer.setContentProvider(new DistributionsContentProvider());
+ getSite().setSelectionProvider(viewer);
+
+ comparator = new NodeViewerComparator(2,
+ NodeViewerComparator.ASCENDING, propertiesList,
+ propertyTypesList);
+ viewer.setComparator(comparator);
+
+ // Context Menu
+ MenuManager menuManager = new MenuManager();
+ Menu menu = menuManager.createContextMenu(viewer.getTable());
+ menuManager.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ contextMenuAboutToShow(manager);
+ }
+ });
+ viewer.getTable().setMenu(menu);
+ getSite().registerContextMenu(menuManager, viewer);
+
+ // Double click
+ viewer.addDoubleClickListener(new DoubleClickListener());
+ }
+
+ @Override
+ public void setFocus() {
+ viewer.getTable().setFocus();
+ }
+
+ /** force refresh of the artifact list */
+ public void refresh() {
+ asynchronousRefresh();
+ }
+
+ /** Programmatically configure the context menu */
+ protected void contextMenuAboutToShow(IMenuManager menuManager) {
+ IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
+ .getActiveWorkbenchWindow();
+ // Build conditions
+ // Delete selected artifacts
+ CommandUtils.refreshCommand(menuManager, window, DeleteArtifacts.ID,
+ DeleteArtifacts.DEFAULT_LABEL, DeleteArtifacts.DEFAULT_ICON,
+ true);
+ }
+
+ private SelectionAdapter getSelectionAdapter(final int index) {
+ SelectionAdapter selectionAdapter = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Table table = viewer.getTable();
+ comparator.setColumn(index);
+ int dir = table.getSortDirection();
+ if (table.getSortColumn() == table.getColumn(index)) {
+ dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
+ } else {
+ dir = SWT.DOWN;
+ }
+ table.setSortDirection(dir);
+ table.setSortColumn(table.getColumn(index));
+ viewer.refresh();
+ }
+ };
+ return selectionAdapter;
+ }
+
+ /* LOCAL CLASSES */
+ private class DistributionsContentProvider implements
+ IStructuredContentProvider {
+ // we keep a cache of the Nodes in the content provider to be able to
+ // manage long request
+ private List<Node> nodes;
+
+ public void dispose() {
+ }
+
+ // We expect a list of nodes as a new input
+ @SuppressWarnings("unchecked")
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ nodes = (List<Node>) newInput;
+ }
+
+ public Object[] getElements(Object arg0) {
+ return nodes.toArray();
+ }
+ }
+
+ private class DoubleClickListener implements IDoubleClickListener {
+
+ public void doubleClick(DoubleClickEvent event) {
+ Object obj = ((IStructuredSelection) event.getSelection())
+ .getFirstElement();
+ if (obj instanceof Node) {
+ Node node = (Node) obj;
+ try {
+ if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
+ DistWkspEditorInput dwip = (DistWkspEditorInput) formEditor
+ .getEditorInput();
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
+ dwip.getRepoNodePath());
+ params.put(OpenModuleEditor.PARAM_REPO_URI,
+ dwip.getUri());
+ params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
+ dwip.getWorkspaceName());
+ String path = node.getPath();
+ params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
+ CommandUtils.callCommand(OpenModuleEditor.ID, params);
+ }
+ } catch (RepositoryException re) {
+ throw new SlcException("Cannot get path for node " + node
+ + " while setting parameters for "
+ + "command OpenModuleEditor", re);
+ }
+
+ }
+ }
+ }
+
+ /**
+ * UI Trick to put scroll bar on the table rather than on the scrollform
+ */
+ private void refreshLayout() {
+ // Compute desired table size
+ int maxH = getManagedForm().getForm().getSize().y;
+ int maxW = getManagedForm().getForm().getParent().getSize().x;
+ maxH = maxH - header.getSize().y;
+ final Table table = viewer.getTable();
+ GridData gd = new GridData(SWT.LEFT, SWT.TOP, true, true);
+
+ // when table height is less than 200 px, we let the scroll bar on the
+ // scrollForm
+ // FIXME substract some spare space. There is room here for optimization
+ gd.heightHint = Math.max(maxH - 35, 200);
+ gd.widthHint = Math.max(maxW - 35, 200);
+
+ table.setLayoutData(gd);
+ getManagedForm().reflow(true);
+ }
+
+ @Override
+ public void setActive(boolean active) {
+ super.setActive(active);
+ if (active) {
+ refreshLayout();
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.client.ui.dist.editors;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+
+import org.argeo.ArgeoException;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.jcr.SlcNames;
+import org.argeo.slc.repo.RepoUtils;
+import org.argeo.util.security.Keyring;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.editor.FormEditor;
+
+/**
+ * Browse, analyse and modify a workspace containing software distributions
+ */
+public class DistWorkspaceEditor extends FormEditor implements SlcNames {
+ // private final static Log log =
+ // LogFactory.getLog(DistributionEditor.class);
+ public final static String ID = DistPlugin.ID
+ + ".distWorkspaceEditor";
+
+ /* DEPENDENCY INJECTION */
+ private RepositoryFactory repositoryFactory;
+ private Repository localRepository;
+ private Keyring keyring;
+
+ // Business objects
+ private Node repoNode;
+ // Session that provides the node in the home of the local repository
+ private Session localSession = null;
+ // The business Session on optionally remote repository
+ private Session businessSession;
+ private DistWkspEditorInput editorInput;
+
+ @Override
+ public void init(IEditorSite site, IEditorInput input)
+ throws PartInitException {
+ editorInput = (DistWkspEditorInput) input;
+ try {
+ localSession = localRepository.login();
+ if (editorInput.getRepoNodePath() != null
+ && localSession.nodeExists(editorInput.getRepoNodePath()))
+ repoNode = localSession.getNode(editorInput.getRepoNodePath());
+
+ businessSession = RepoUtils.getCorrespondingSession(
+ repositoryFactory, keyring, repoNode, editorInput.getUri(),
+ editorInput.getWorkspaceName());
+ } catch (RepositoryException e) {
+ throw new PartInitException("Cannot log to workspace "
+ + editorInput.getName(), e);
+ }
+ setPartName(editorInput.getWorkspaceName());
+ super.init(site, input);
+ }
+
+ @Override
+ protected void addPages() {
+ try {
+ addPage(new DistWkspSearchPage(this, "Overview",
+ businessSession));
+ addPage(new DistWkspBrowserPage(this, "Browser", businessSession));
+ } catch (PartInitException e) {
+ throw new ArgeoException("Cannot add distribution editor pages", e);
+ }
+ }
+
+ @Override
+ public void doSave(IProgressMonitor arg0) {
+ }
+
+ @Override
+ public void dispose() {
+ JcrUtils.logoutQuietly(businessSession);
+ JcrUtils.logoutQuietly(localSession);
+ super.dispose();
+ }
+
+ @Override
+ public void doSaveAs() {
+ }
+
+ @Override
+ public boolean isSaveAsAllowed() {
+ return false;
+ }
+
+ protected Node getRepoNode() {
+ return repoNode;
+ }
+
+ /* DEPENDENCY INJECTION */
+ public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+ this.repositoryFactory = repositoryFactory;
+ }
+
+ public void setKeyring(Keyring keyring) {
+ this.keyring = keyring;
+ }
+
+ public void setLocalRepository(Repository localRepository) {
+ this.localRepository = localRepository;
+ }
+}
\ No newline at end of file
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import org.argeo.ArgeoException;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.client.ui.dist.DistPlugin;
import org.argeo.slc.jcr.SlcNames;
@Override
protected void addPages() {
- try {
- addPage(new DistributionOverviewPage(this, "Overview", session));
- addPage(new ArtifactsBrowserPage(this, "Browser", session));
- } catch (PartInitException e) {
- throw new ArgeoException("Cannot add distribution editor pages", e);
- }
+ // try {
+ // addPage(new DistWkspSearchPage(this, "Overview", session));
+ // addPage(new DistWkspBrowserPage(this, "Browser", session));
+ // } catch (PartInitException e) {
+ // throw new ArgeoException("Cannot add distribution editor pages", e);
+ // }
}
@Override
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.client.ui.dist.editors;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.qom.Constraint;
-import javax.jcr.query.qom.DynamicOperand;
-import javax.jcr.query.qom.Ordering;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-import javax.jcr.query.qom.StaticOperand;
-
-import org.argeo.ArgeoException;
-import org.argeo.ArgeoMonitor;
-import org.argeo.eclipse.ui.EclipseArgeoMonitor;
-import org.argeo.eclipse.ui.utils.CommandUtils;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.PrivilegedJob;
-import org.argeo.slc.client.ui.dist.commands.DeleteArtifacts;
-import org.argeo.slc.client.ui.dist.utils.NodeViewerComparator;
-import org.argeo.slc.jcr.SlcNames;
-import org.argeo.slc.jcr.SlcTypes;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/** Show all bundles contained in a given workspace as filter-able table */
-public class DistributionOverviewPage extends FormPage implements SlcNames {
- // final private static Log log = LogFactory
- // .getLog(DistributionOverviewPage.class);
-
- final static String PAGE_ID = "distributionOverviewPage";
-
- // Business Objects
- private Session session;
-
- // This page widgets
- private NodeViewerComparator comparator;
- private TableViewer viewer;
- private FormToolkit tk;
- private Composite header;
- private Text artifactTxt;
- private final static String FILTER_HELP_MSG = "Enter filter criterion separated by a space";
-
- public DistributionOverviewPage(FormEditor formEditor, String title,
- Session session) {
- super(formEditor, PAGE_ID, title);
- this.session = session;
- }
-
- private void asynchronousRefresh() {
- RefreshJob job = new RefreshJob(artifactTxt.getText(), viewer,
- getSite().getShell().getDisplay());
- job.setUser(true);
- job.schedule();
- }
-
- private class RefreshJob extends PrivilegedJob {
- private TableViewer viewer;
- private String filter;
- private Display display;
-
- public RefreshJob(String filter, TableViewer viewer, Display display) {
- super("Get bundle list");
- this.filter = filter;
- this.viewer = viewer;
- this.display = display;
- }
-
- @Override
- protected IStatus doRun(IProgressMonitor progressMonitor) {
- try {
- ArgeoMonitor monitor = new EclipseArgeoMonitor(progressMonitor);
- monitor.beginTask("Getting bundle list", -1);
- final List<Node> result = JcrUtils
- .nodeIteratorToList(listBundleArtifacts(session, filter));
-
- display.asyncExec(new Runnable() {
- public void run() {
- viewer.setInput(result);
- }
- });
- } catch (Exception e) {
- return new Status(IStatus.ERROR, DistPlugin.ID,
- "Cannot get bundle list", e);
- }
- return Status.OK_STATUS;
- }
- }
-
- @Override
- protected void createFormContent(IManagedForm managedForm) {
- ScrolledForm form = managedForm.getForm();
- tk = managedForm.getToolkit();
-
- // Main Layout
- GridLayout layout = new GridLayout(1, false);
- Composite body = form.getBody();
- body.setLayout(layout);
-
- // Add the filter section
- createFilterPart(body);
- // Add the table
- createTableViewer(body);
- // viewer.setInput(null);
- // Add a listener to enable custom resize process
- form.addControlListener(new ControlListener() {
- // form.addListener(SWT.RESIZE, new Listener() does not work
- public void controlResized(ControlEvent e) {
- refreshLayout();
- }
-
- public void controlMoved(ControlEvent e) {
- }
- });
- asynchronousRefresh();
- }
-
- /** Build repository request */
- private NodeIterator listBundleArtifacts(Session session, String filter)
- throws RepositoryException {
- QueryManager queryManager = session.getWorkspace().getQueryManager();
- QueryObjectModelFactory factory = queryManager.getQOMFactory();
-
- final String bundleArtifactsSelector = "bundleArtifacts";
- Selector source = factory.selector(SlcTypes.SLC_BUNDLE_ARTIFACT,
- bundleArtifactsSelector);
-
- // Create a dynamic operand for each property on which we want to filter
- DynamicOperand symbNameDO = factory.propertyValue(
- source.getSelectorName(), SlcNames.SLC_SYMBOLIC_NAME);
- DynamicOperand versionDO = factory.propertyValue(
- source.getSelectorName(), SlcNames.SLC_BUNDLE_VERSION);
- DynamicOperand nameDO = factory.propertyValue(source.getSelectorName(),
- DistConstants.SLC_BUNDLE_NAME);
-
- // Default Constraint: no source artifacts
- Constraint defaultC = factory.not(factory.comparison(
- symbNameDO,
- QueryObjectModelFactory.JCR_OPERATOR_LIKE,
- factory.literal(session.getValueFactory().createValue(
- "%.source"))));
-
- // Build constraints based the textArea content
- if (filter != null && !"".equals(filter.trim())) {
- // Parse the String
- String[] strs = filter.trim().split(" ");
- for (String token : strs) {
- token = token.replace('*', '%');
- StaticOperand so = factory.literal(session.getValueFactory()
- .createValue("%" + token + "%"));
-
- Constraint currC = factory.comparison(symbNameDO,
- QueryObjectModelFactory.JCR_OPERATOR_LIKE, so);
- currC = factory.or(currC, factory.comparison(versionDO,
- QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
- currC = factory.or(currC, factory.comparison(nameDO,
- QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
-
- defaultC = factory.and(defaultC, currC);
- }
- }
-
- Ordering order = factory.descending(factory.propertyValue(
- bundleArtifactsSelector, SlcNames.SLC_BUNDLE_VERSION));
- Ordering order2 = factory.ascending(factory.propertyValue(
- bundleArtifactsSelector, SlcNames.SLC_SYMBOLIC_NAME));
- Ordering[] orderings = { order, order2 };
-
- QueryObjectModel query = factory.createQuery(source, defaultC,
- orderings, null);
-
- QueryResult result = query.execute();
- return result.getNodes();
-
- }
-
- private void createFilterPart(Composite parent) {
- header = tk.createComposite(parent);
- GridLayout layout = new GridLayout(2, false);
- layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
- layout.horizontalSpacing = 5;
- header.setLayout(layout);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
- header.setLayoutData(gd);
-
- // Title: some meta information
- // label = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
- // .getProperty(Property.JCR_TITLE).getString() : repoNode
- // .getName();
-
- String desc = null;
- Node repoNode = ((DistributionWorkspaceEditor) getEditor())
- .getRepoNode();
- if (repoNode != null)
- try {
- desc = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
- .getProperty(Property.JCR_TITLE).getString() : repoNode
- .getName();
- } catch (RepositoryException e1) {
- throw new SlcException("Unable to get repository alias ", e1);
- }
- desc += " (" + ((WorkspaceEditorInput) getEditorInput()).getUri() + ")";
- Label lbl = tk.createLabel(header, desc, SWT.NONE);
-
- gd = new GridData(SWT.FILL, SWT.FILL, false, false);
- gd.horizontalSpan = 2;
- lbl.setLayoutData(gd);
-
- // Text Area to filter
- artifactTxt = tk.createText(header, "", SWT.BORDER | SWT.SINGLE
- | SWT.SEARCH | SWT.CANCEL);
- artifactTxt.setMessage(FILTER_HELP_MSG);
- gd = new GridData(SWT.FILL, SWT.FILL, false, false);
- gd.grabExcessHorizontalSpace = true;
- artifactTxt.setLayoutData(gd);
- artifactTxt.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- if ("".equals(artifactTxt.getText().trim()))
- asynchronousRefresh();
- else
- refreshFilteredList();
- }
- });
-
- Button resetBtn = tk.createButton(header, null, SWT.PUSH);
- resetBtn.setImage(DistImages.IMG_REPO_READONLY);
- resetBtn.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- resetFilter();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- }
-
- private void resetFilter() {
- artifactTxt.setText("");
- artifactTxt.setMessage(FILTER_HELP_MSG);
- }
-
- private void refreshFilteredList() {
- List<Node> nodes;
- try {
- nodes = JcrUtils.nodeIteratorToList(listBundleArtifacts(session,
- artifactTxt.getText()));
- viewer.setInput(nodes);
- } catch (RepositoryException e) {
- throw new SlcException("Unable to list bundles", e);
- }
- }
-
- private void createTableViewer(Composite parent) {
- // helpers to enable sorting by column
- List<String> propertiesList = new ArrayList<String>();
- List<Integer> propertyTypesList = new ArrayList<Integer>();
-
- // Define the TableViewer
- viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
- | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
-
- // Name
- TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(300);
- col.getColumn().setText("Name");
- col.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- return JcrUtils.get((Node) element,
- DistConstants.SLC_BUNDLE_NAME);
- }
- });
- col.getColumn().addSelectionListener(getSelectionAdapter(0));
- propertiesList.add(DistConstants.SLC_BUNDLE_NAME);
- propertyTypesList.add(PropertyType.STRING);
-
- // Symbolic name
- col = new TableViewerColumn(viewer, SWT.V_SCROLL);
- col.getColumn().setWidth(300);
- col.getColumn().setText("Symbolic Name");
- col.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- return JcrUtils.get((Node) element, SLC_SYMBOLIC_NAME);
- }
- });
- col.getColumn().addSelectionListener(getSelectionAdapter(1));
- propertiesList.add(SLC_SYMBOLIC_NAME);
- propertyTypesList.add(PropertyType.STRING);
-
- // Version
- col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(130);
- col.getColumn().setText("Version");
- col.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- return JcrUtils.get((Node) element, SLC_BUNDLE_VERSION);
- }
- });
- col.getColumn().addSelectionListener(getSelectionAdapter(2));
- propertiesList.add(SLC_BUNDLE_VERSION);
- propertyTypesList.add(PropertyType.STRING);
-
- final Table table = viewer.getTable();
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- viewer.setContentProvider(new DistributionsContentProvider());
- getSite().setSelectionProvider(viewer);
-
- comparator = new NodeViewerComparator(2,
- NodeViewerComparator.ASCENDING, propertiesList,
- propertyTypesList);
- viewer.setComparator(comparator);
-
- // Context Menu
- MenuManager menuManager = new MenuManager();
- Menu menu = menuManager.createContextMenu(viewer.getTable());
- menuManager.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- contextMenuAboutToShow(manager);
- }
- });
- viewer.getTable().setMenu(menu);
- getSite().registerContextMenu(menuManager, viewer);
-
- // Double click
- viewer.addDoubleClickListener(new DoubleClickListener());
- }
-
- @Override
- public void setFocus() {
- viewer.getTable().setFocus();
- }
-
- /** force refresh of the artifact list */
- public void refresh() {
- asynchronousRefresh();
- }
-
- /** Programmatically configure the context menu */
- protected void contextMenuAboutToShow(IMenuManager menuManager) {
- IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow();
- // Build conditions
- // Delete selected artifacts
- CommandUtils.refreshCommand(menuManager, window, DeleteArtifacts.ID,
- DeleteArtifacts.DEFAULT_LABEL, DeleteArtifacts.DEFAULT_ICON,
- true);
- }
-
- private SelectionAdapter getSelectionAdapter(final int index) {
- SelectionAdapter selectionAdapter = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- Table table = viewer.getTable();
- comparator.setColumn(index);
- int dir = table.getSortDirection();
- if (table.getSortColumn() == table.getColumn(index)) {
- dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
- } else {
- dir = SWT.DOWN;
- }
- table.setSortDirection(dir);
- table.setSortColumn(table.getColumn(index));
- viewer.refresh();
- }
- };
- return selectionAdapter;
- }
-
- /* LOCAL CLASSES */
- private class DistributionsContentProvider implements
- IStructuredContentProvider {
- // we keep a cache of the Nodes in the content provider to be able to
- // manage long request
- private List<Node> nodes;
-
- public void dispose() {
- }
-
- // We expect a list of nodes as a new input
- @SuppressWarnings("unchecked")
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- nodes = (List<Node>) newInput;
- }
-
- public Object[] getElements(Object arg0) {
- return nodes.toArray();
- }
- }
-
- private class DoubleClickListener implements IDoubleClickListener {
-
- public void doubleClick(DoubleClickEvent event) {
- Object obj = ((IStructuredSelection) event.getSelection())
- .getFirstElement();
- try {
- if (obj instanceof Node) {
- Node node = (Node) obj;
- if (node.isNodeType(SlcTypes.SLC_BUNDLE_ARTIFACT)) {
- GenericBundleEditorInput gaei = new GenericBundleEditorInput(
- node);
- DistPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow().getActivePage()
- .openEditor(gaei, GenericBundleEditor.ID);
- }
- }
- } catch (RepositoryException re) {
- throw new ArgeoException(
- "Repository error while getting node info", re);
- } catch (PartInitException pie) {
- throw new ArgeoException(
- "Unexepected exception while opening artifact editor",
- pie);
- }
- }
- }
-
- /**
- * UI Trick to put scroll bar on the table rather than on the scrollform
- */
- private void refreshLayout() {
- // Compute desired table size
- int maxH = getManagedForm().getForm().getSize().y;
- int maxW = getManagedForm().getForm().getParent().getSize().x;
- maxH = maxH - header.getSize().y;
- final Table table = viewer.getTable();
- GridData gd = new GridData(SWT.LEFT, SWT.TOP, true, true);
-
- // when table height is less than 200 px, we let the scroll bar on the
- // scrollForm
- // FIXME substract some spare space. There is room here for optimization
- gd.heightHint = Math.max(maxH - 35, 200);
- gd.widthHint = Math.max(maxW - 35, 200);
-
- table.setLayoutData(gd);
- getManagedForm().reflow(true);
- }
-
- @Override
- public void setActive(boolean active) {
- super.setActive(active);
- if (active) {
- refreshLayout();
- }
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.client.ui.dist.editors;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-
-import org.argeo.ArgeoException;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.jcr.SlcNames;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.util.security.Keyring;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.forms.editor.FormEditor;
-
-/**
- * Browse, analyse and modify a workspace containing software distributions
- */
-public class DistributionWorkspaceEditor extends FormEditor implements SlcNames {
- // private final static Log log =
- // LogFactory.getLog(DistributionEditor.class);
- public final static String ID = DistPlugin.ID
- + ".distributionWorkspaceEditor";
-
- /* DEPENDENCY INJECTION */
- private RepositoryFactory repositoryFactory;
- private Repository localRepository;
- private Keyring keyring;
-
- // Business objects
- private Node repoNode;
- // Session that provides the node in the home of the local repository
- private Session localSession = null;
- // The business Session on optionally remote repository
- private Session businessSession;
- private WorkspaceEditorInput editorInput;
-
- @Override
- public void init(IEditorSite site, IEditorInput input)
- throws PartInitException {
- editorInput = (WorkspaceEditorInput) input;
-
- try {
- localSession = localRepository.login();
- if (editorInput.getRepoNodePath() != null
- && localSession.nodeExists(editorInput.getRepoNodePath()))
- repoNode = localSession.getNode(editorInput.getRepoNodePath());
-
- businessSession = RepoUtils.getCorrespondingSession(
- repositoryFactory, keyring, repoNode, editorInput.getUri(),
- editorInput.getWorkspaceName());
- } catch (RepositoryException e) {
- throw new PartInitException("Cannot log to workspace "
- + editorInput.getName(), e);
- }
- setPartName(editorInput.getWorkspaceName());
- super.init(site, input);
- }
-
- @Override
- protected void addPages() {
- try {
- addPage(new DistributionOverviewPage(this, "Overview",
- businessSession));
- addPage(new ArtifactsBrowserPage(this, "Browser", businessSession));
- } catch (PartInitException e) {
- throw new ArgeoException("Cannot add distribution editor pages", e);
- }
- }
-
- @Override
- public void doSave(IProgressMonitor arg0) {
- }
-
- @Override
- public void dispose() {
- JcrUtils.logoutQuietly(businessSession);
- JcrUtils.logoutQuietly(localSession);
- super.dispose();
- }
-
- @Override
- public void doSaveAs() {
- }
-
- @Override
- public boolean isSaveAsAllowed() {
- return false;
- }
-
- protected Node getRepoNode() {
- return repoNode;
- }
-
- /* DEPENDENCY INJECTION */
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-
- public void setLocalRepository(Repository localRepository) {
- this.localRepository = localRepository;
- }
-}
\ No newline at end of file
/**
* An editor input pointing to a given group base in a distribution workspace
*/
-public class GroupBaseEditorInput extends WorkspaceEditorInput {
+public class GroupBaseEditorInput extends DistWkspEditorInput {
private final String groupBaseId;
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.client.ui.dist.editors;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * Manage a modular distribution version contained in a specific workspace of a
+ * repository
+ */
+public class ModularDistVersionEditor extends ArtifactVersionEditor {
+ // private final static Log log =
+ // LogFactory.getLog(ModularDistVersionEditor.class);
+ public final static String ID = DistPlugin.ID + ".modularDistVersionEditor";
+
+ @Override
+ public void init(IEditorSite site, IEditorInput input)
+ throws PartInitException {
+ super.init(site, input);
+ // setPartName("Editing distrib");
+ }
+
+ @Override
+ protected void addPages() {
+ try {
+ addPage(new ModuleListPage(this, "Modules ", getArtifact()));
+ addPage(new RunInOsgiPage(this, "Run as OSGi ", getArtifact()));
+ super.addPages();
+ } catch (PartInitException e) {
+ throw new SlcException("Cannot add distribution editor pages", e);
+ // } catch (RepositoryException e) {
+ // throw new SlcException("Cannot get artifact session", e);
+ }
+ }
+}
\ No newline at end of file
import org.argeo.eclipse.ui.utils.CommandUtils;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistConstants;
import org.argeo.slc.client.ui.dist.DistImages;
import org.argeo.slc.client.ui.dist.DistPlugin;
import org.argeo.slc.client.ui.dist.commands.DeleteArtifacts;
// Business Objects
private Node modularDistribution;
+ // private Node modularDistributionBase;
// This page widgets
private NodeViewerComparator comparator;
private Text filterTxt;
private final static String FILTER_HELP_MSG = "Enter filter criterion separated by a space";
- private Node moduleParent;
-
public ModuleListPage(FormEditor formEditor, String title,
Node modularDistribution) {
super(formEditor, PAGE_ID, title);
// Name
TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(300);
- col.getColumn().setText("Name");
+ col.getColumn().setWidth(220);
+ col.getColumn().setText("Category");
col.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
- return JcrUtils.get((Node) element,
- DistConstants.SLC_BUNDLE_NAME);
+ return JcrUtils.get((Node) element, SlcNames.SLC_CATEGORY);
}
});
col.getColumn().addSelectionListener(getSelectionAdapter(0));
- propertiesList.add(DistConstants.SLC_BUNDLE_NAME);
+ propertiesList.add(SlcNames.SLC_CATEGORY);
propertyTypesList.add(PropertyType.STRING);
// Symbolic name
- col = new TableViewerColumn(viewer, SWT.V_SCROLL);
- col.getColumn().setWidth(300);
- col.getColumn().setText("Symbolic Name");
+ col = new TableViewerColumn(viewer, SWT.NONE);
+ col.getColumn().setWidth(220);
+ col.getColumn().setText("Name");
col.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
- return JcrUtils.get((Node) element, SLC_SYMBOLIC_NAME);
+ return JcrUtils.get((Node) element, SLC_NAME);
}
});
col.getColumn().addSelectionListener(getSelectionAdapter(1));
- propertiesList.add(SLC_SYMBOLIC_NAME);
+ propertiesList.add(SLC_NAME);
propertyTypesList.add(PropertyType.STRING);
// Version
col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(130);
+ col.getColumn().setWidth(160);
col.getColumn().setText("Version");
col.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
- return JcrUtils.get((Node) element, SLC_BUNDLE_VERSION);
+ return JcrUtils.get((Node) element, SLC_VERSION);
}
});
col.getColumn().addSelectionListener(getSelectionAdapter(2));
- propertiesList.add(SLC_BUNDLE_VERSION);
+ propertiesList.add(SLC_VERSION);
propertyTypesList.add(PropertyType.STRING);
final Table table = viewer.getTable();
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.client.ui.dist.editors;
+
+import javax.jcr.Node;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.jcr.SlcNames;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/**
+ * Enable launch of the current distribution in a separate osgi run time.
+ * Display also a console to interract with the launched runtime
+ */
+public class RunInOsgiPage extends FormPage implements SlcNames {
+
+ final static String PAGE_ID = "RunInOsgiPage";
+
+ // Business Objects
+ private Node modularDistribution;
+
+ // This page widgets
+ private Button launchBtn;
+ private Text consoleTxt;
+
+ private FormToolkit tk;
+
+ public RunInOsgiPage(FormEditor formEditor, String title,
+ Node modularDistribution) {
+ super(formEditor, PAGE_ID, title);
+ this.modularDistribution = modularDistribution;
+ }
+
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ ScrolledForm form = managedForm.getForm();
+ tk = managedForm.getToolkit();
+ // Main Layout
+ Composite body = form.getBody();
+ GridLayout layout = new GridLayout();
+ layout.marginTop = layout.marginWidth = 0;
+ body.setLayout(layout);
+
+ // The header
+ Composite header = tk.createComposite(body);
+ header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ createHeaderPart(header);
+
+ // The console
+ Composite console = tk.createComposite(body);
+ console.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ createConsolePart(console);
+ body.layout();
+ }
+
+ private void createHeaderPart(Composite parent) {
+ GridLayout layout = new GridLayout();
+ parent.setLayout(layout);
+
+ // Text Area to filter
+ launchBtn = tk.createButton(parent, " Launch ", SWT.PUSH);
+ launchBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false));
+
+ launchBtn.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ super.widgetSelected(e);
+ throw new SlcException("Implement this");
+ }
+ });
+ }
+
+ private void createConsolePart(Composite parent) {
+ parent.setLayout(new GridLayout());
+ consoleTxt = tk.createText(parent, "OSGi > ", SWT.MULTI | SWT.WRAP
+ | SWT.BORDER);
+ consoleTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ }
+
+ @Override
+ public void setFocus() {
+ launchBtn.setFocus();
+ }
+}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.client.ui.dist.editors;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.jcr.SlcNames;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-
-/**
- * An editor input pointing to a distribution workspace
- */
-public class WorkspaceEditorInput implements IEditorInput, SlcNames {
-
- // Injected
- // private RepositoryFactory repositoryFactory;
- // private Keyring keyring;
- // private Node repoNode;
- private String repoNodePath;
- private String uri;
-
- // Local variables
- private String workspaceName;
-
- // public WorkspaceEditorInput(RepositoryFactory repositoryFactory,
- // Keyring keyring, Repository localRepository, Node repoNode,
- // String uri) {
- // // this.repositoryFactory = repositoryFactory;
- // // this.keyring = keyring;
- // this.localRepository = localRepository;
- // // this.repoNode= repoNode;
- // this.uri = uri;
- //
- // }
-
- /** uri and workspace name cannot be null */
- public WorkspaceEditorInput(String repoNodePath, String uri,
- String workspaceName) {
- if (workspaceName == null)
- throw new SlcException("Workspace name cannot be null");
- if (uri == null)
- throw new SlcException("URI for repository cannot be null");
- this.repoNodePath = repoNodePath;
- this.workspaceName = workspaceName;
- this.uri = uri;
- }
-
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- return null;
- }
-
- public boolean exists() {
- return true;
- }
-
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- // Dummy compulsory methods
- public String getToolTipText() {
- return "Editor for workspace " + workspaceName
- + " in repository of URI " + uri;
- }
-
- public String getName() {
- return workspaceName + "@" + uri;
- }
-
- public IPersistableElement getPersistable() {
- return null;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof WorkspaceEditorInput))
- return false;
-
- WorkspaceEditorInput other = (WorkspaceEditorInput) obj;
-
- if (!workspaceName.equals(other.getWorkspaceName()))
- return false;
- if (!uri.equals(other.getUri()))
- return false;
-
- if (repoNodePath == null)
- return other.getRepoNodePath() == null;
- else
- return repoNodePath.equals(other.getRepoNodePath());
- }
-
- public String getUri() {
- return uri;
- }
-
- public String getWorkspaceName() {
- return workspaceName;
- }
-
- public String getRepoNodePath() {
- return repoNodePath;
- }
-}
\ No newline at end of file