import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.window.Window;
import org.eclipse.ui.handlers.HandlerUtil;
/**
public class CopyWorkspace extends AbstractHandler {
// private static final Log log = LogFactory.getLog(CopyWorkspace.class);
public final static String ID = DistPlugin.ID + ".copyWorkspace";
- public final static String DEFAULT_LABEL = "Duplicate";
+ public final static String DEFAULT_LABEL = "Duplicate...";
public final static String PARAM_SOURCE_WORKSPACE_NAME = "srcWkspName";
public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
public final static ImageDescriptor DEFAULT_ICON = DistPlugin
.getActiveWorkbenchWindow(event).getShell(),
"New copy of workspace " + wkspName,
"Choose a name for the workspace to create", "", null);
- inputDialog.open();
- String newWorkspaceName = inputDialog.getValue();
- srcSession = repository.login(credentials, wkspName);
+ int result = inputDialog.open();
+ if (result == Window.OK) {
+ String newWorkspaceName = inputDialog.getValue();
+ srcSession = repository.login(credentials, wkspName);
- // Create the workspace
- srcSession.getWorkspace().createWorkspace(newWorkspaceName);
- Node srcRootNode = srcSession.getRootNode();
- // log in the newly created workspace
- newSession = repository.login(credentials, newWorkspaceName);
- Node newRootNode = newSession.getRootNode();
- RepoUtils.copy(srcRootNode, newRootNode);
- newSession.save();
- JcrUtils.addPrivilege(newSession, "/", SlcConstants.ROLE_SLC,
- Privilege.JCR_ALL);
- CommandHelpers.callCommand(RefreshDistributionsView.ID);
+ // Create the workspace
+ srcSession.getWorkspace().createWorkspace(newWorkspaceName);
+ Node srcRootNode = srcSession.getRootNode();
+ // log in the newly created workspace
+ newSession = repository.login(credentials, newWorkspaceName);
+ Node newRootNode = newSession.getRootNode();
+ RepoUtils.copy(srcRootNode, newRootNode);
+ newSession.save();
+ JcrUtils.addPrivilege(newSession, "/", SlcConstants.ROLE_SLC,
+ Privilege.JCR_ALL);
+ CommandHelpers.callCommand(RefreshDistributionsView.ID);
+ }
} catch (RepositoryException re) {
throw new ArgeoException(
"Unexpected error while creating the new workspace.", re);
/**
* Create a new empty workspace in the current repository.
*/
-
public class CreateWorkspace extends AbstractHandler {
private static final Log log = LogFactory.getLog(CreateWorkspace.class);
import org.argeo.slc.jcr.SlcTypes;
import org.argeo.slc.repo.ArtifactIndexer;
import org.argeo.slc.repo.JarFileIndexer;
+import org.argeo.slc.repo.RepoConstants;
import org.argeo.slc.repo.RepoUtils;
import org.argeo.slc.repo.maven.MavenConventionsUtils;
import org.argeo.slc.repo.osgi.NormalizeGroup;
import org.sonatype.aether.artifact.Artifact;
import org.sonatype.aether.util.artifact.DefaultArtifact;
-/** Make sure than Maven and OSGi metadata are consistent */
+/** Legacy - Make sure than Maven and OSGi metadata are consistent */
public class NormalizeDistribution extends AbstractHandler implements SlcNames {
+ private final static Log log = LogFactory
+ .getLog(NormalizeDistribution.class);
+
public final static String ID = DistPlugin.ID + ".normalizeDistribution";
- public final static String DEFAULT_LABEL = "Normalize...";
- // public final static String DEFAULT_ICON_PATH = "icons/normalize.gif";
+ public final static String DEFAULT_LABEL = "Legacy Normalization...";
public final static ImageDescriptor DEFAULT_ICON = DistPlugin
.getImageDescriptor("icons/normalize.gif");
public final static String PARAM_WORKSPACE_NAME = "workspaceName";
public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
- private final static Log log = LogFactory
- .getLog(NormalizeDistribution.class);
-
- private String artifactBasePath = "/";
+ private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
private JarFileIndexer jarFileIndexer = new JarFileIndexer();
private final static Log log = LogFactory.getLog(NormalizeWorkspace.class);
public final static String ID = DistPlugin.ID + ".normalizeWorkspace";
+ public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+ .getImageDescriptor("icons/normalize.gif");
public final static String PARAM_WORKSPACE_NAME = "workspaceName";
public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin
- .getImageDescriptor("icons/normalize.gif");
private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
- private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
- private JarFileIndexer jarFileIndexer = new JarFileIndexer();
- private PdeSourcesIndexer pdeSourceIndexer = new PdeSourcesIndexer(
- artifactIndexer, jarFileIndexer);
-
// DEPENDENCY INJECTION
private RepositoryFactory repositoryFactory;
private Keyring keyring;
private Repository repository;
- public Object execute(ExecutionEvent event) throws ExecutionException {
+ private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
+ private JarFileIndexer jarFileIndexer = new JarFileIndexer();
+ private PdeSourcesIndexer pdeSourceIndexer = new PdeSourcesIndexer(
+ artifactIndexer, jarFileIndexer);
+ public Object execute(ExecutionEvent event) throws ExecutionException {
String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
String wkspName = event.getParameter(PARAM_WORKSPACE_NAME);
try {
String msg = "Your are about to normalize workspace: " + wkspName
+ ".\nThis will index OSGi bundles and Maven artifacts, "
- + "it will also generate pdeSources if needed.\n"
+ + "it will also convert Maven sources to PDE Sources if needed.\n"
+ "Note that no information will be overwritten: "
+ "all existing information are kept."
+ "\n\n Do you really want to proceed ?";
@Override
protected IStatus run(IProgressMonitor progressMonitor) {
-
try {
ArgeoMonitor monitor = new EclipseArgeoMonitor(progressMonitor);
- // normalize artifacts
+ // Normalize artifacts
Query countQuery = session
.getWorkspace()
.getQueryManager()
@Override
protected void leaving(Node node, int level) throws RepositoryException {
}
-
}
/* DEPENDENCY INJECTION */
import org.argeo.ArgeoException;
import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcConstants;
import org.argeo.slc.client.ui.dist.DistPlugin;
import org.argeo.slc.repo.RepoUtils;
import org.argeo.util.security.Keyring;
import org.eclipse.jface.resource.ImageDescriptor;
/**
- * Publish the current workspace by giving REOD_ONLY rights to anonymous.
+ * Publish the current workspace by giving READ_ONLY rights to anonymous.
*/
-
public class PublishWorkspace extends AbstractHandler {
// private static final Log log = LogFactory.getLog(PublishWorkspace.class);
- public final static String ID = DistPlugin.ID + ".publishWorkspace";
- public final static String DEFAULT_LABEL = "Publish workspace";
- // public final static String DEFAULT_ICON_PATH = "icons/publish.gif";
+ public final static String ID = DistPlugin.ID + ".publishWorkspace";
+ public final static String DEFAULT_LABEL = "Make Public";
public final static ImageDescriptor DEFAULT_ICON = DistPlugin
.getImageDescriptor("icons/publish.gif");
private Keyring keyring;
private Repository nodeRepository;
- private String publicRole = "anonymous";
+ private String publicRole = SlcConstants.USER_ANONYMOUS;
public Object execute(ExecutionEvent event) throws ExecutionException {
String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
"Confirm publication", msg);
if (result) {
-
session = repository.login(credentials, workspaceName);
JcrUtils.addPrivilege(session, "/", publicRole,
Privilege.JCR_READ);
session.save();
-
JcrUtils.logoutQuietly(session);
// CommandHelpers.callCommand(RefreshDistributionsView.ID);
}
import org.eclipse.ui.handlers.HandlerUtil;
/**
- * Change visible state of the ArtifactBrower size column
+ * Force the refresh of the artifact browser view
*/
public class RefreshArtifactBrowser extends AbstractHandler {
import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
import org.argeo.slc.jcr.SlcNames;
+import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.ui.part.ViewPart;
/**
- * Browse, manipulate and manage distributions accross multiple repositories
+ * Browse, manipulate and manage distributions across multiple repositories
* (like fetch, merge, publish, etc.).
*/
public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames {
// private final static Log log =
// LogFactory.getLog(DistributionsView.class);
+
public final static String ID = DistPlugin.ID + ".distributionsView";
/* DEPENDENCY INJECTION */
viewer.addDoubleClickListener(new DistTreeDoubleClickListener());
viewer.setComparator(new DistTreeComparator());
- // Enable selection retrieving from outside the view
+ // Enable retrieving current tree selected items from outside the view
getSite().setSelectionProvider(viewer);
- // Drag'n drop
+ // Drag and drop
Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
int operations = DND.DROP_COPY | DND.DROP_MOVE;
viewer.addDragSupport(operations, tt, new ViewDragListener());
(isRepoElem || isDistribGroupElem) && singleElement
&& !isReadOnly, params);
- // publish workspace
- params = new HashMap<String, String>();
- params.put(PublishWorkspace.PARAM_TARGET_REPO_PATH,
- targetRepoPath);
- params.put(PublishWorkspace.PARAM_WORKSPACE_NAME, workspaceName);
- CommandUtils.refreshParametrizedCommand(menuManager, window,
- PublishWorkspace.ID, PublishWorkspace.DEFAULT_LABEL,
- PublishWorkspace.DEFAULT_ICON, isDistribElem
- && singleElement && !isReadOnly, params);
-
// Register a remote repository
CommandUtils.refreshCommand(menuManager, window,
RegisterRepository.ID,
isRepoElem && isHomeRepo && singleElement
&& !isReadOnly, params);
- // Normalize workspace
- params = new HashMap<String, String>();
- params.put(NormalizeDistribution.PARAM_TARGET_REPO_PATH,
- targetRepoPath);
- params.put(NormalizeDistribution.PARAM_WORKSPACE_NAME,
- workspaceName);
- CommandUtils.refreshParametrizedCommand(menuManager, window,
- NormalizeDistribution.ID,
- NormalizeDistribution.DEFAULT_LABEL,
- NormalizeDistribution.DEFAULT_ICON, isDistribElem
- && singleElement && !isReadOnly, params);
-
// Normalize workspace
params = new HashMap<String, String>();
params.put(NormalizeWorkspace.PARAM_TARGET_REPO_PATH,
workspaceName);
CommandUtils.refreshParametrizedCommand(menuManager, window,
- NormalizeWorkspace.ID, "Normalize workspace...",
+ NormalizeWorkspace.ID, "Normalize...",
NormalizeWorkspace.DEFAULT_ICON, isDistribElem
&& singleElement && !isReadOnly, params);
DeleteWorkspace.DEFAULT_ICON, isDistribElem
&& singleElement && !isReadOnly, params);
+ // Advanced submenu
+ MenuManager submenu = new MenuManager("Advanced", DistPlugin.ID
+ + ".advancedSubmenu");
+ IContributionItem ici = menuManager.find(DistPlugin.ID
+ + ".advancedSubmenu");
+ if (ici != null)
+ menuManager.remove(ici);
+
+ // Normalize distribution (Legacy)
+ params = new HashMap<String, String>();
+ params.put(NormalizeDistribution.PARAM_TARGET_REPO_PATH,
+ targetRepoPath);
+ params.put(NormalizeDistribution.PARAM_WORKSPACE_NAME,
+ workspaceName);
+ CommandUtils.refreshParametrizedCommand(submenu, window,
+ NormalizeDistribution.ID,
+ NormalizeDistribution.DEFAULT_LABEL,
+ NormalizeDistribution.DEFAULT_ICON, isDistribElem
+ && singleElement && !isReadOnly, params);
+
+ // publish workspace
+ params = new HashMap<String, String>();
+ params.put(PublishWorkspace.PARAM_TARGET_REPO_PATH,
+ targetRepoPath);
+ params.put(PublishWorkspace.PARAM_WORKSPACE_NAME, workspaceName);
+ CommandUtils.refreshParametrizedCommand(submenu, window,
+ PublishWorkspace.ID, PublishWorkspace.DEFAULT_LABEL,
+ PublishWorkspace.DEFAULT_ICON, isDistribElem
+ && singleElement && !isReadOnly, params);
+
+ if (submenu.getSize() > 0)
+ menuManager.add(submenu);
+
// // Manage workspace authorizations
// params = new HashMap<String, String>();
// params.put(ManageWorkspaceAuth.PARAM_WORKSPACE_NAME, wsName);