org.argeo.slc.runtime,
org.argeo.slc.services,
org.argeo.slc.services.impl
+Export-Package: org.argeo.slc.client.rcp
sequence="CTRL+R">
</key>
</extension>
- <extension
- id="product"
- point="org.eclipse.core.runtime.products">
- <product
- application="org.argeo.slc.client.rcp.application"
- name="SLC">
- <property
- name="windowImages"
- value="icons/argeo-icon-256.png">
- </property>
- <property
- name="appName"
- value="SLC">
- </property>
- </product>
- </extension>
</plugin>
+++ /dev/null
-package org.argeo.slc.client.rcp;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.application.ActionBarAdvisor;
-import org.eclipse.ui.application.IActionBarConfigurer;
-
-/**
- * An action bar advisor is responsible for creating, adding, and disposing of
- * the actions added to a workbench window. Each window will be populated with
- * new actions.
- */
-public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
-
- // Actions - important to allocate these only in makeActions, and then use
- // them in the fill methods. This ensures that the actions aren't recreated
- // when fillActionBars is called with FILL_PROXY.
-
- public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
- super(configurer);
- }
-
- protected void makeActions(final IWorkbenchWindow window) {
- // Creates the actions and registers them.
- // Registering is needed to ensure that key bindings work.
- // The corresponding commands keybindings are defined in the plugin.xml
- // file.
- // Registering also provides automatic disposal of the actions when
- // the window is closed.
- }
-
- protected void fillMenuBar(IMenuManager menuBar) {
- }
-
-}
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.part.EditorInputTransfer;
-/**
- * Set here initial default size of the UI
- *
- * @author bsinou
- *
- */
+/** Set here initial default size of the UI */
public class SlcSecureWorkbenchWindowAdvisor extends
SecureWorkbenchWindowAdvisor {
super(configurer, username);
}
- // public ActionBarAdvisor createActionBarAdvisor(
- // IActionBarConfigurer configurer) {
- // return new ApplicationActionBarAdvisor(configurer);
- // }
-
-
-
public void postWindowOpen() {
initTray();
}
-
-
@Override
public void preWindowOpen() {
- getWindowConfigurer().addEditorAreaTransfer(EditorInputTransfer.getInstance());
- getWindowConfigurer().configureEditorAreaDropListener(new DropTargetAdapter() {
-
- @Override
- public void dragEnter(DropTargetEvent event) {
- System.out.println("DROP enter!!! " + event);
- }
+ getWindowConfigurer().addEditorAreaTransfer(
+ EditorInputTransfer.getInstance());
+ getWindowConfigurer().configureEditorAreaDropListener(
+ new DropTargetAdapter() {
+
+ @Override
+ public void dragEnter(DropTargetEvent event) {
+ System.out.println("DROP enter!!! " + event);
+ }
- @Override
- public void dragLeave(DropTargetEvent event) {
- System.out.println("DROP leave!!! " + event);
- }
+ @Override
+ public void dragLeave(DropTargetEvent event) {
+ System.out.println("DROP leave!!! " + event);
+ }
- public void drop(DropTargetEvent event) {
- System.out.println("DROP drop!!! " + event);
+ public void drop(DropTargetEvent event) {
+ System.out.println("DROP drop!!! " + event);
- }
+ }
- @Override
- public void dropAccept(DropTargetEvent event) {
- System.out.println("DROP accept!!! " + event);
- super.dropAccept(event);
- }
+ @Override
+ public void dropAccept(DropTargetEvent event) {
+ System.out.println("DROP accept!!! " + event);
+ super.dropAccept(event);
+ }
- });
+ });
super.preWindowOpen();
}
+++ /dev/null
-package org.argeo.slc.client.rcp.commands;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-public class ExitHandler extends AbstractHandler {
-
- // TODO: Could be implemented using default RCP commands.
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- HandlerUtil.getActiveWorkbenchWindow(event).close();
- return null;
- }
-
-}
id="org.argeo.slc.client.ui.jcrExecutionModulesView"
class="org.argeo.eclipse.spring.SpringExtensionFactory"
icon="icons/execution_module.gif"
- name="Execution Modules"
+ name="Execution"
restorable="true">
</view>
<view
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
+import java.util.Iterator;
import java.util.List;
import javax.jcr.Node;
Arrays.sort(sorted, new ViewComparator());
return sorted;
}
+
+ @Override
+ protected List<Node> filterChildren(List<Node> children)
+ throws RepositoryException {
+ for (Iterator<Node> it = children.iterator(); it.hasNext();) {
+ Node node = it.next();
+ if (node.getName().equals(SLC_EXECUTION_SPECS))
+ it.remove();
+ }
+ return super.filterChildren(children);
+ }
}
static class ViewComparator implements Comparator<Object> {
import org.argeo.slc.jcr.SlcTypes;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
public void createPartControl(Composite parent) {
Table table = createTable(parent);
viewer = new TableViewer(table);
- viewer.setLabelProvider(new LabelProvider());
- viewer.setContentProvider(new ContentProvider());
+ viewer.setLabelProvider(createLabelProvider());
+ viewer.setContentProvider(new ViewContentProvider());
viewer.setInput(getViewSite());
viewer.addDoubleClickListener(new ViewDoubleClickListener());
observationManager.addEventListener(resultsObserver,
Event.NODE_ADDED | Event.NODE_REMOVED
| Event.PROPERTY_CHANGED,
- SlcJcrConstants.RESULTS_BASE_PATH, true, null, null,
- false);
+ SlcJcrConstants.RESULTS_BASE_PATH, true, null, null, false);
} catch (RepositoryException e) {
throw new SlcException("Cannot register listeners", e);
}
protected Table createTable(Composite parent) {
int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
| SWT.FULL_SELECTION;
- // does not function with RAP, commented for the time being
+ // does not work with RAP, commented for the time being
// | SWT.HIDE_SELECTION;
Table table = new Table(parent, style);
return table;
}
+ /*
+ * METHODS TO BE OVERRIDDEN
+ */
+ protected IBaseLabelProvider createLabelProvider() {
+ return new ViewLabelProvider();
+ }
+
+ protected void processDoubleClick(DoubleClickEvent evt) {
+ Object obj = ((IStructuredSelection) evt.getSelection())
+ .getFirstElement();
+ try {
+ if (obj instanceof Node) {
+ Node node = (Node) obj;
+ if (node.isNodeType(SlcTypes.SLC_PROCESS)) {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ activePage.openEditor(
+ new ProcessEditorInput(node.getPath()),
+ ProcessEditor.ID);
+ }
+ }
+ } catch (Exception e) {
+ throw new SlcException("Cannot open " + obj, e);
+ }
+ }
+
public void setFocus() {
viewer.getControl().setFocus();
}
super.dispose();
}
- class ContentProvider implements IStructuredContentProvider {
+ class ViewContentProvider implements IStructuredContentProvider {
public Object[] getElements(Object inputElement) {
try {
}
- class LabelProvider extends ColumnLabelProvider implements
+ class ViewLabelProvider extends ColumnLabelProvider implements
ITableLabelProvider {
public Image getColumnImage(Object obj, int columnIndex) {
return null;
try {
Node node = (Node) obj;
- if(node.hasProperty(SLC_COMPLETED)){
+ if (node.hasProperty(SLC_COMPLETED)) {
// TODO
}
return null;
class ViewDoubleClickListener implements IDoubleClickListener {
public void doubleClick(DoubleClickEvent evt) {
- Object obj = ((IStructuredSelection) evt.getSelection())
- .getFirstElement();
- try {
- if (obj instanceof Node) {
- Node node = (Node) obj;
- if (node.isNodeType(SlcTypes.SLC_PROCESS)) {
- IWorkbenchPage activePage = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
- activePage.openEditor(
- new ProcessEditorInput(node.getPath()),
- ProcessEditor.ID);
- }
- }
- } catch (Exception e) {
- throw new SlcException("Cannot open " + obj, e);
- }
+ processDoubleClick(evt);
}
}
// result
public final static String SLC_SUCCESS = "slc:success";
public final static String SLC_MESSAGE = "slc:message";
+ public final static String SLC_TAG = "slc:tag";
public final static String SLC_ERROR_MESSAGE = "slc:errorMessage";
}
public final static String SLC_RESULT = "slc:result";
public final static String SLC_CHECK = "slc:check";
+ public final static String SLC_PROPERTY = "slc:property";
}
import java.util.Map;
import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
import org.argeo.slc.core.attachment.Attachment;
+import org.argeo.slc.core.structure.SimpleSElement;
import org.argeo.slc.core.structure.tree.TreeSPath;
import org.argeo.slc.core.test.tree.TreeTestResult;
import org.argeo.slc.core.test.tree.TreeTestResultListener;
}
// create part node
// TODO find a better name
- String partNodeName = Long.toString(System.currentTimeMillis());
+ SimpleSElement element = null;
+ if (testResult.getElements().containsKey(currentPath)) {
+ element = (SimpleSElement) testResult.getElements().get(
+ currentPath);
+ }
+
+ String elementLabel = element != null && element.getLabel() != null
+ && !element.getLabel().trim().equals("") ? element
+ .getLabel() : null;
+ String partNodeName = elementLabel != null ? JcrUtils
+ .replaceInvalidChars(elementLabel, '_') : Long
+ .toString(System.currentTimeMillis());
+
Node resultPartNode = partParentNode.addNode(partNodeName,
SlcTypes.SLC_CHECK);
resultPartNode.setProperty(SLC_SUCCESS,
testResultPart.getStatus() == TestStatus.PASSED);
+ if (elementLabel != null)
+ resultPartNode.setProperty(Property.JCR_TITLE, elementLabel);
if (testResultPart.getMessage() != null)
resultPartNode.setProperty(SLC_MESSAGE,
testResultPart.getMessage());
resultPartNode.setProperty(SLC_ERROR_MESSAGE,
testResultPart.getExceptionMessage());
// JcrUtils.debug(resultPartNode);
-
+
JcrUtils.updateLastModified(resultNode);
-
+
+ if (element != null) {
+ element = (SimpleSElement) testResult.getElements().get(
+ currentPath);
+ if (log.isTraceEnabled())
+ log.trace(" Path= " + currentPath + ", part="
+ + testResultPart.getMessage());
+ for (Map.Entry<String, String> tag : element.getTags()
+ .entrySet()) {
+ String tagNodeName = JcrUtils.replaceInvalidChars(
+ tag.getKey(), '_');
+ // log.debug("key=" + tag.getKey() + ", tagNodeName="
+ // + tagNodeName);
+ Node tagNode = resultPartNode.addNode(tagNodeName,
+ SlcTypes.SLC_PROPERTY);
+ tagNode.setProperty(SLC_NAME, tag.getKey());
+ tagNode.setProperty(SLC_VALUE, tag.getValue());
+ }
+ }
+
session.save();
} catch (RepositoryException e) {
JcrUtils.discardQuietly(session);
this.session = session;
}
+ /**
+ * Creates and populates a {@link TreeTestResult} from the related result
+ * node. Meant to simplify migration of legacy applications. This is no
+ * stable API.
+ */
+ public static TreeTestResult nodeToTreeTestResult(Node resultNode) {
+ try {
+ String resultPath = resultNode.getPath();
+ TreeTestResult ttr = new TreeTestResult();
+ // base properties
+ ttr.setUuid(resultNode.getProperty(SLC_UUID).getString());
+ if (resultNode.hasProperty(SLC_COMPLETED))
+ ttr.setCloseDate(resultNode.getProperty(SLC_COMPLETED)
+ .getDate().getTime());
+ // attributes
+ for (PropertyIterator pit = resultNode.getProperties(); pit
+ .hasNext();) {
+ Property p = pit.nextProperty();
+ if (p.getName().indexOf(':') < 0) {
+ ttr.getAttributes().put(p.getName(), p.getString());
+ }
+ }
+
+ QueryManager qm = resultNode.getSession().getWorkspace()
+ .getQueryManager();
+ String statement = "SELECT * FROM [" + SlcTypes.SLC_CHECK
+ + "] WHERE ISDESCENDANTNODE(['" + resultPath + "'])";
+ NodeIterator nit = qm.createQuery(statement, Query.JCR_SQL2)
+ .execute().getNodes();
+ while (nit.hasNext()) {
+ Node checkNode = nit.nextNode();
+ String relPath = checkNode.getPath().substring(
+ resultPath.length());
+ TreeSPath tsp = new TreeSPath(relPath);
+
+ // TODO result part
+
+ // element
+ SimpleSElement elem = new SimpleSElement();
+ if (checkNode.hasProperty(Property.JCR_TITLE))
+ elem.setLabel(checkNode.getProperty(Property.JCR_TITLE)
+ .getString());
+ else
+ elem.setLabel("");// some legacy code expect it to be set
+ for (NodeIterator tagIt = checkNode.getNodes(); tagIt.hasNext();) {
+ Node tagNode = tagIt.nextNode();
+ elem.getTags().put(
+ tagNode.getProperty(SLC_NAME).getString(),
+ tagNode.getProperty(SLC_VALUE).getString());
+ }
+ ttr.getElements().put(tsp, elem);
+ }
+ return ttr;
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot generate tree test result from "
+ + resultNode, e);
+ }
+ }
}
- slc:uuid (STRING) ! m
- slc:completed (DATE)
-[slc:check] > nt:unstructured, mix:created
+[slc:check] > nt:unstructured
// true for PASSED, false for FAILED or ERROR
- slc:success (BOOLEAN) ! m
- slc:message (STRING)
// ERROR if set, the check could not be performed because of an unexpected exception
- slc:errorMessage (STRING)
++ * (slc:property) *
+[slc:property] > nt:unstructured
+- slc:name (STRING) ! m
+- slc:value (STRING) m