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.RepositoryException;
import javax.jcr.Session;
import javax.jcr.observation.Event;
-import javax.jcr.observation.ObservationManager;
import javax.jcr.query.QueryManager;
import javax.jcr.query.QueryResult;
import javax.jcr.query.qom.Constraint;
import javax.jcr.query.qom.Selector;
import javax.jcr.query.qom.StaticOperand;
-import org.argeo.ArgeoException;
import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
import org.argeo.eclipse.ui.utils.CommandUtils;
import org.argeo.jcr.JcrUtils;
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.MarkAsRelevantCategory;
+import org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard;
+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.argeo.slc.repo.RepoConstants;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
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;
private final static String FILTER_HELP_MSG = "Enter filter criterion separated by a space";
// Observes changes
- private final static String[] observedTypes = { SlcTypes.SLC_GROUP_BASE };
- private CategoryObserver categoriesObserver;
+ // private final static String[] observedTypes = { SlcTypes.SLC_GROUP_BASE
+ // };
+ // private CategoryObserver categoriesObserver;
public WkspCategoryBaseListPage(FormEditor formEditor, String title,
Session session) {
tableCmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
createTableViewer(tableCmp);
- categoriesObserver = new CategoryObserver(viewer.getTable()
- .getDisplay());
- try {
- ObservationManager observationManager = session.getWorkspace()
- .getObservationManager();
- // FIXME Will not be notified if empty result is deleted
- observationManager.addEventListener(categoriesObserver,
- Event.PROPERTY_CHANGED, "/", true, null, observedTypes,
- false);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot register listeners", e);
- }
+ // categoriesObserver = new CategoryObserver(viewer.getTable()
+ // .getDisplay());
+ // try {
+ // ObservationManager observationManager = session.getWorkspace()
+ // .getObservationManager();
+ // // FIXME Will not be notified if empty result is deleted
+ // observationManager.addEventListener(categoriesObserver,
+ // Event.PROPERTY_CHANGED, "/", true, null, observedTypes,
+ // false);
+ // } catch (RepositoryException e) {
+ // throw new SlcException("Cannot register listeners", e);
+ // }
refresh();
}
// Version
col = new TableViewerColumn(viewer, SWT.NONE);
col.getColumn().setWidth(80);
- col.getColumn().setText("Relevant");
+ col.getColumn().setText("Has binaries");
col.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
try {
- return ((Node) element)
- .isNodeType(SlcTypes.SLC_RELEVANT_CATEGORY) ? "Yes"
+ Node currNode = (Node) element;
+
+ return currNode.hasNode(RepoConstants.BINARIES_ARTIFACT_ID) ? "Yes"
: "No";
} catch (RepositoryException e) {
throw new SlcException("unable to check type of node "
.getFirstElement();
Node currSelected = (Node) firstElement;
- boolean isRelevant = false;
- try {
- isRelevant = currSelected
- .isNodeType(SlcTypes.SLC_RELEVANT_CATEGORY);
- boolean canEdit = currSelected
- .canAddMixin(SlcTypes.SLC_RELEVANT_CATEGORY);
+ DistWkspEditorInput input = (DistWkspEditorInput) getEditorInput();
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(OpenGenerateBinariesWizard.PARAM_REPO_NODE_PATH,
+ input.getRepoNodePath());
+ try {
+ params.put(OpenGenerateBinariesWizard.PARAM_MODULE_PATH,
+ currSelected.getPath());
} catch (RepositoryException e) {
- throw new SlcException("unable to check type of node "
- + firstElement, e);
- }
- // Add
- if (isRelevant) {// Remove
- CommandUtils.refreshCommand(menuManager, window,
- MarkAsRelevantCategory.ID,
- MarkAsRelevantCategory.DEFAULT_REMOVE_LABEL,
- MarkAsRelevantCategory.DEFAULT_REMOVE_ICON, true);
- } else {
- CommandUtils.refreshCommand(menuManager, window,
- MarkAsRelevantCategory.ID,
- MarkAsRelevantCategory.DEFAULT_LABEL,
- MarkAsRelevantCategory.DEFAULT_ICON, true);
+ throw new SlcException("Unable to get path for " + currSelected, e);
}
+ params.put(OpenGenerateBinariesWizard.PARAM_WORKSPACE_NAME,
+ input.getWorkspaceName());
+
+ CommandUtils.refreshParametrizedCommand(menuManager, window,
+ OpenGenerateBinariesWizard.ID,
+ OpenGenerateBinariesWizard.DEFAULT_LABEL,
+ OpenGenerateBinariesWizard.DEFAULT_ICON, true, params);
+
+ // boolean isRelevant = false;
+ // try {
+ // isRelevant = currSelected.isNodeType(SlcTypes.SLC_CATEGORY);
+ // boolean canEdit = currSelected.canAddMixin(SlcTypes.SLC_CATEGORY);
+ //
+ // } catch (RepositoryException e) {
+ // throw new SlcException("unable to check type of node "
+ // + firstElement, e);
+ // }
+ // // Add
+ // if (isRelevant) {// Remove
+ // CommandUtils.refreshCommand(menuManager, window,
+ // MarkAsRelevantCategory.ID,
+ // MarkAsRelevantCategory.DEFAULT_REMOVE_LABEL,
+ // MarkAsRelevantCategory.DEFAULT_REMOVE_ICON, true);
+ // } else {
+ // CommandUtils.refreshCommand(menuManager, window,
+ // MarkAsRelevantCategory.ID,
+ // MarkAsRelevantCategory.DEFAULT_LABEL,
+ // MarkAsRelevantCategory.DEFAULT_ICON, true);
+ // }
}
private SelectionAdapter getSelectionAdapter(final int index) {
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);
+ if (obj instanceof Node) {
+ Node node = (Node) obj;
+ try {
+ if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
+ DistWkspEditorInput dwip = (DistWkspEditorInput) 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);
}
- } 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);
+
}
}
}