"", null);
inputDialog.open();
String workspaceName = inputDialog.getValue();
+ Session session = null;
try {
- Session session = repository.login();
+ session = repository.login();
session.getWorkspace().createWorkspace(workspaceName);
CommandHelpers.callCommand(RefreshDistributionsView.ID);
} catch (RepositoryException re) {
throw new ArgeoException(
"Unexpected error while creating the new workspace.", re);
+ } finally {
+ if (session != null)
+ session.logout();
}
if (log.isTraceEnabled())
log.debug("WORKSPACE " + workspaceName + " CREATED");
public void setRepository(Repository repository) {
this.repository = repository;
}
-}
+}
\ No newline at end of file
public final static String DEFAULT_ICON_PATH = "icons/removeItem.gif";
public Object execute(ExecutionEvent event) throws ExecutionException {
- String msg = "Your are about to definitively remove these artifacts.\n"
- + "Do you really want to proceed ?";
+ try {
+ IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().getActivePart();
- boolean result = MessageDialog.openConfirm(DistPlugin.getDefault()
- .getWorkbench().getDisplay().getActiveShell(),
- "Confirm deletion", msg);
- if (result) {
- // Session session = null;
- try {
- // session = repository.login();
- IWorkbenchPart activePart = DistPlugin.getDefault()
- .getWorkbench().getActiveWorkbenchWindow()
- .getActivePage().getActivePart();
+ if (activePart instanceof IEditorPart) {
+ ISelection selector = ((IEditorPart) activePart)
+ .getEditorSite().getSelectionProvider().getSelection();
+ if (selector != null
+ && selector instanceof IStructuredSelection) {
+ Iterator<?> it = ((IStructuredSelection) selector)
+ .iterator();
- if (activePart instanceof IEditorPart) {
- ISelection selector = ((IEditorPart) activePart)
- .getEditorSite().getSelectionProvider()
- .getSelection();
- if (selector != null
- && selector instanceof IStructuredSelection) {
- Iterator<?> it = ((IStructuredSelection) selector)
- .iterator();
+ String msg = "Your are about to definitively remove the "
+ + ((IStructuredSelection) selector).size()
+ + " selected artifacts.\n"
+ + "Are you sure you want to proceed ?";
+
+ boolean result = MessageDialog.openConfirm(DistPlugin
+ .getDefault().getWorkbench().getDisplay()
+ .getActiveShell(), "Confirm Delete", msg);
+
+ if (result) {
while (it.hasNext()) {
Node node = (Node) it.next();
// we remove the artifactVersion, that is the parent
node.getSession().save();
}
}
- // session.save();
}
- CommandHelpers.callCommand(RefreshDistributionOverviewPage.ID);
- } catch (RepositoryException re) {
- throw new ArgeoException(
- "Unexpected error while deleting artifacts.", re);
- } finally {
- // if (session != null)
- // session.logout();
}
+ CommandHelpers.callCommand(RefreshDistributionOverviewPage.ID);
+ } catch (RepositoryException re) {
+ throw new ArgeoException(
+ "Unexpected error while deleting artifacts.", re);
}
return null;
}
-}
+}
\ No newline at end of file
package org.argeo.slc.client.ui.dist.commands;
import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import org.argeo.ArgeoException;
import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
private Repository repository;
public Object execute(ExecutionEvent event) throws ExecutionException {
- String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
- String msg = "Your are about to definitively delete this workspace ["
- + workspaceName + "].\n Do you really want to proceed ?";
-
+
MessageDialog.openWarning(DistPlugin.getDefault()
.getWorkbench().getDisplay().getActiveShell(),
"WARNING", "Not yet implemented");
return null;
-
+
+// String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
+// String msg = "Your are about to definitively delete this workspace ["
+// + workspaceName + "].\n Do you really want to proceed ?";
+
// boolean result = MessageDialog.openConfirm(DistPlugin.getDefault()
// .getWorkbench().getDisplay().getActiveShell(),
// "Confirm deletion", msg);
public void setRepository(Repository repository) {
this.repository = repository;
}
-}
+}
\ No newline at end of file
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import javax.jcr.security.Privilege;
import org.argeo.ArgeoException;
import org.argeo.slc.client.ui.dist.DistPlugin;
public void setRepository(Repository repository) {
this.repository = repository;
}
-}
+}
\ No newline at end of file
package org.argeo.slc.client.ui.dist.commands;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
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.eclipse.ui.forms.editor.IFormPage;
/**
- * Force refresh of the DistributionsView
+ * Force refresh of the Distribution overview page of the corresponding editor
*/
public class RefreshDistributionOverviewPage extends AbstractHandler {
- private static final Log log = LogFactory
- .getLog(RefreshDistributionOverviewPage.class);
+ // private static final Log log = LogFactory
+ // .getLog(RefreshDistributionOverviewPage.class);
public final static String ID = DistPlugin.ID
+ ".refreshDistributionOverviewPage";
public final static String DEFAULT_LABEL = "Refresh the distribution overview";
public void doSave(IProgressMonitor arg0) {
}
+ @Override
+ public void dispose() {
+ if (session != null)
+ session.logout();
+ super.dispose();
+ }
+
@Override
public void doSaveAs() {
}
viewer = new TableViewer(form.getBody(), SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
- TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
+ TableViewerColumn col = new TableViewerColumn(viewer, SWT.V_SCROLL);
col.getColumn().setWidth(300);
col.getColumn().setText("Symbolic name");
col.setLabelProvider(new ColumnLabelProvider() {
viewer.setContentProvider(new DistributionsContentProvider());
getSite().setSelectionProvider(viewer);
-
+
viewer.setInput(session);
comparator = new NodeViewerComparator(1,
NodeViewerComparator.DESCENDING, propertiesList,
return null;
}
}
-
}
+ //
+ // private class BoundedLayout extends Layout {
+ // protected Layout delegateLayout;
+ //
+ // protected Method computeSizeMethod;
+ // protected Method layoutMethod;
+ //
+ // protected boolean widthBound;
+ //
+ // public BoundedLayout(Layout delegateLayout, boolean widthBound) {
+ // setDelegateLayout(delegateLayout);
+ // this.widthBound = widthBound;
+ // }
+ //
+ // public Layout getDelegateLayout() {
+ // return delegateLayout;
+ // }
+ //
+ // public void setDelegateLayout(Layout delegateLayout) {
+ // this.delegateLayout = delegateLayout;
+ //
+ // try {
+ // computeSizeMethod = delegateLayout.getClass()
+ // .getDeclaredMethod("computeSize", Composite.class,
+ // int.class, int.class, boolean.class);
+ // computeSizeMethod.setAccessible(true);
+ //
+ // layoutMethod = delegateLayout.getClass().getDeclaredMethod(
+ // "layout", Composite.class, boolean.class);
+ // layoutMethod.setAccessible(true);
+ // } catch (Exception e) {
+ // throw new RuntimeException(e);
+ // }
+ // }
+ //
+ // @Override
+ // protected Point computeSize(Composite composite, int wHint, int hHint,
+ // boolean flushCache) {
+ // // get comp size to make sure we don't let any children exceed it
+ // Point compSize = composite.getSize();
+ //
+ // try {
+ // Point layoutComputedSize = (Point) computeSizeMethod.invoke(
+ // delegateLayout, composite, wHint, hHint, flushCache);
+ //
+ // if (widthBound) {
+ // layoutComputedSize.x = Math.min(compSize.x,
+ // layoutComputedSize.x);
+ // } else {
+ // layoutComputedSize.y = Math.min(compSize.y,
+ // layoutComputedSize.y);
+ // }
+ //
+ // return layoutComputedSize;
+ // } catch (Exception e) {
+ // throw new RuntimeException(e);
+ // }
+ // }
+ //
+ // @Override
+ // protected void layout(Composite composite, boolean flushCache) {
+ // try {
+ // layoutMethod.invoke(delegateLayout, composite, flushCache);
+ // } catch (Exception e) {
+ // throw new RuntimeException(e);
+ // }
+ // }
+ // }
}
\ No newline at end of file
// Get Current selected item :
Object firstElement = ((IStructuredSelection) viewer.getSelection())
.getFirstElement();
- String wsName = null;
+
if (firstElement instanceof TreeParent) {
- wsName = ((TreeParent) firstElement).getName();
- }
+ TreeParent tp = (TreeParent) firstElement;
+ String wsName = tp.getName();
+
+ // Build conditions depending on element type (repo or distribution
+ // for the time being)
+ boolean isDistribElem = false; // , isRepoElem = false;
+
+ // if (tp instanceof RepositoryElem){
+ // isRepoElem = true;
+ // } else
+ if (tp instanceof DistributionElem) {
+ isDistribElem = true;
+ }
- // Build conditions depending on element type (repo or workspace)
-
- // create workspace
- CommandHelpers.refreshCommand(menuManager, window, CreateWorkspace.ID,
- CreateWorkspace.DEFAULT_LABEL,
- CreateWorkspace.DEFAULT_ICON_PATH, true);
-
- // Copy workspace
- Map<String, String> params = new HashMap<String, String>();
- params.put(CopyWorkspace.PARAM_WORKSPACE_NAME, wsName);
- CommandHelpers.refreshParameterizedCommand(menuManager, window,
- CopyWorkspace.ID, CopyWorkspace.DEFAULT_LABEL,
- CopyWorkspace.DEFAULT_ICON_PATH, true, params);
-
- // Delete Workspace
- params = new HashMap<String, String>();
- params.put(DeleteWorkspace.PARAM_WORKSPACE_NAME, wsName);
- CommandHelpers.refreshParameterizedCommand(menuManager, window,
- DeleteWorkspace.ID, DeleteWorkspace.DEFAULT_LABEL,
- DeleteWorkspace.DEFAULT_ICON_PATH, true, params);
-
- // Manage workspace authorizations
- params = new HashMap<String, String>();
- params.put(ManageWorkspaceAuth.PARAM_WORKSPACE_NAME, wsName);
- CommandHelpers.refreshParameterizedCommand(menuManager, window,
- ManageWorkspaceAuth.ID, ManageWorkspaceAuth.DEFAULT_LABEL,
- ManageWorkspaceAuth.DEFAULT_ICON_PATH, true, params);
+ // create workspace
+ CommandHelpers.refreshCommand(menuManager, window,
+ CreateWorkspace.ID, CreateWorkspace.DEFAULT_LABEL,
+ CreateWorkspace.DEFAULT_ICON_PATH, true);
+
+ // Copy workspace
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(CopyWorkspace.PARAM_WORKSPACE_NAME, wsName);
+ CommandHelpers.refreshParameterizedCommand(menuManager, window,
+ CopyWorkspace.ID, CopyWorkspace.DEFAULT_LABEL,
+ CopyWorkspace.DEFAULT_ICON_PATH, isDistribElem, params);
+
+ // Delete Workspace
+ params = new HashMap<String, String>();
+ params.put(DeleteWorkspace.PARAM_WORKSPACE_NAME, wsName);
+ CommandHelpers.refreshParameterizedCommand(menuManager, window,
+ DeleteWorkspace.ID, DeleteWorkspace.DEFAULT_LABEL,
+ DeleteWorkspace.DEFAULT_ICON_PATH, isDistribElem, params);
+
+ // Manage workspace authorizations
+ params = new HashMap<String, String>();
+ params.put(ManageWorkspaceAuth.PARAM_WORKSPACE_NAME, wsName);
+ CommandHelpers.refreshParameterizedCommand(menuManager, window,
+ ManageWorkspaceAuth.ID, ManageWorkspaceAuth.DEFAULT_LABEL,
+ ManageWorkspaceAuth.DEFAULT_ICON_PATH, isDistribElem,
+ params);
+ }
}
private class DistributionsContentProvider extends
}
private static class RepositoryElem extends TreeParent {
- private final Repository repository;
+ // private final Repository repository;
private Session defaultSession;
public RepositoryElem(String name, Repository repository) {
super(name);
- this.repository = repository;
+ // this.repository = repository;
try {
defaultSession = repository.login();
String[] workspaceNames = defaultSession.getWorkspace()
}
}
+ @Override
+ public synchronized void dispose() {
+ if (log.isTraceEnabled())
+ log.trace("Disposing RepositoryElement");
+ if (defaultSession != null)
+ defaultSession.logout();
+ super.dispose();
+ }
}
private static class DistributionElem extends TreeParent {
public Repository getRepository() {
return repository;
}
+ }
+ @Override
+ public void dispose() {
+ super.dispose();
}
private class DistributionsDCL implements IDoubleClickListener {
}
}
}
-
}
-
-}
+}
\ No newline at end of file