/*
- * Copyright (C) 2007-2012 Mathieu Baudier
+ * 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.
import javax.jcr.Node;
import javax.jcr.NodeIterator;
+import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.observation.Event;
import org.argeo.eclipse.ui.jcr.NodeElementComparer;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.ClientUiPlugin;
import org.argeo.slc.client.ui.editors.ProcessEditor;
import org.argeo.slc.client.ui.editors.ProcessEditorInput;
-import org.argeo.slc.jcr.SlcJcrConstants;
+import org.argeo.slc.jcr.SlcJcrResultUtils;
import org.argeo.slc.jcr.SlcNames;
import org.argeo.slc.jcr.SlcTypes;
import org.eclipse.jface.viewers.ColumnLabelProvider;
/** Displays results. */
public class JcrResultListView extends ViewPart implements SlcNames {
- public static final String ID = "org.argeo.slc.client.ui.jcrResultListView";
+ public static final String ID = ClientUiPlugin.ID + ".jcrResultListView";
private TableViewer viewer;
try {
ObservationManager observationManager = session.getWorkspace()
.getObservationManager();
- String[] nodeTypes = { SlcTypes.SLC_RESULT };
+ String[] nodeTypes = { SlcTypes.SLC_TEST_RESULT };
// FIXME Will not be notified if empty result is deleted
observationManager.addEventListener(resultsObserver,
Event.PROPERTY_ADDED | Event.NODE_REMOVED,
- SlcJcrConstants.RESULTS_BASE_PATH, true, null, nodeTypes,
- false);
+ SlcJcrResultUtils.getSlcResultsBasePath(session), true,
+ null, nodeTypes, false);
} catch (RepositoryException e) {
throw new SlcException("Cannot register listeners", e);
}
viewer.getControl().setFocus();
}
- @Override
- public void dispose() {
- JcrUtils.unregisterQuietly(session.getWorkspace(), resultsObserver);
- super.dispose();
- }
-
class ViewContentProvider implements IStructuredContentProvider {
public Object[] getElements(Object inputElement) {
try {
// TODO filter, optimize with virtual table, ...
- String sql = "SELECT * from [slc:result] ORDER BY [jcr:lastModified] DESC";
+ String sql = "SELECT * from [" + SlcTypes.SLC_TEST_RESULT
+ + "] ORDER BY [jcr:lastModified] DESC";
Query query = session.getWorkspace().getQueryManager()
.createQuery(sql, Query.JCR_SQL2);
// TODO paging
getLog().trace("Refresh result list");
viewer.refresh();
}
-
}
+ @Deprecated
public void setSession(Session session) {
this.session = session;
}
+ public void dispose() {
+ JcrUtils.unregisterQuietly(session.getWorkspace(), resultsObserver);
+ JcrUtils.logoutQuietly(session);
+ super.dispose();
+ }
+
+ public void setRepository(Repository repository) {
+ try {
+ session = repository.login();
+ } catch (RepositoryException re) {
+ throw new SlcException("Unable to log in Repository " + repository,
+ re);
+ }
+ }
}
\ No newline at end of file