Permalink
Browse files

staging works

prestaged originals also work
volumes attached indicators work
volume details work
ready to add icons for specific drive types
  • Loading branch information...
1 parent 3816411 commit cf0d39f0c78363a9002e690f716b3ef71461bee6 @gregjan gregjan committed Jul 10, 2012
Showing with 489 additions and 473 deletions.
  1. +1 −1 etc/mets.xsd
  2. BIN workbench_plugin/icons/ejected1.gif
  3. +21 −14 workbench_plugin/plugin.xml
  4. +1 −1 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/CaptureJob.java
  5. +1 −1 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsContentProvider.java
  6. +38 −74 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsDecorator.java
  7. +4 −7 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsLabelProvider.java
  8. +42 −12 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsLinkJob.java
  9. +51 −4 workbench_plugin/src/main/java/unc/lib/cdr/workbench/originals/OriginalFileStore.java
  10. +102 −39 workbench_plugin/src/main/java/unc/lib/cdr/workbench/originals/OriginalStub.java
  11. +56 −51 workbench_plugin/src/main/java/unc/lib/cdr/workbench/originals/VolumeUtil.java
  12. +8 −5 workbench_plugin/src/main/java/unc/lib/cdr/workbench/project/MetsProjectNature.java
  13. +3 −3 workbench_plugin/src/main/java/unc/lib/cdr/workbench/project/ProjectEMFSession.java
  14. +27 −31 workbench_plugin/src/main/java/unc/lib/cdr/workbench/stage/StageBuilder.java
  15. +17 −73 workbench_plugin/src/main/java/unc/lib/cdr/workbench/stage/StagingJob.java
  16. +25 −102 workbench_plugin/src/main/java/unc/lib/cdr/workbench/stage/StagingUtils.java
  17. +0 −3 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/HasStagedFileFilter.java
  18. +46 −14 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/LabelImageFactory.java
  19. +0 −2 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/OriginalResourcePropertySheetSection.java
  20. +46 −36 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/OriginalVolumeSection.java
View
@@ -653,7 +653,7 @@ to clarify the differences between the ORDER, ORDERLABEL, and LABEL attributes f
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
- <xsd:attribute name="FILEID" type="xsd:IDREF" use="optional">
+ <xsd:attribute name="FILEID" type="xsd:IDREF" use="optional" ecore:name="file" ecore:reference="fileType" ecore:opposite="fptr">
<xsd:annotation>
<xsd:documentation xml:lang="en">FILEID (IDREF/O): An optional attribute that provides the XML ID identifying the &lt;file&gt; element that links to and/or contains the digital content represented by the &lt;fptr&gt;. A &lt;fptr&gt; element should only have a FILEID attribute value if it does not have a child &lt;area&gt;, &lt;par&gt; or &lt;seq&gt; element. If it has a child element, then the responsibility for pointing to the relevant content falls to this child element or its descendants.
</xsd:documentation>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -232,16 +232,14 @@
<iterate
ifEmpty="false"
operator="and">
- <and>
- <or>
- <instanceof
- value="org.eclipse.core.resources.IFile">
- </instanceof>
- <instanceof
- value="org.eclipse.core.resources.IFolder">
- </instanceof>
- </or>
- </and>
+ <or>
+ <instanceof
+ value="org.eclipse.core.resources.IFile">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.core.resources.IFolder">
+ </instanceof>
+ </or>
</iterate>
</with>
</activeWhen>
@@ -533,9 +531,15 @@
style="push">
<visibleWhen
checkEnabled="false">
- <instanceof
- value="gov.loc.mets.DivType">
- </instanceof>
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ ifEmpty="false">
+ <instanceof
+ value="gov.loc.mets.DivType">
+ </instanceof>
+ </iterate>
+ </with>
</visibleWhen>
</command>
<command
@@ -1297,7 +1301,7 @@
<decorator
class="unc.lib.cdr.workbench.capture.OriginalsDecorator"
id="cdr-workbench.decoratorCaptured"
- label="Captured File Decorators"
+ label="Originals Decorator"
lightweight="true"
location="BOTTOM_RIGHT"
state="true">
@@ -1309,6 +1313,9 @@
<objectClass
name="gov.loc.mets.DivType">
</objectClass>
+ <objectClass
+ name="unc.lib.cdr.workbench.originals.OriginalStub">
+ </objectClass>
</or>
</enablement>
</decorator>
@@ -266,7 +266,7 @@ private void emfAdd(DivType d, DivType child) {
*/
private void makeOrLinkParent(OriginalFileStore original, DivType div) throws CoreException {
DivType parent = null;
- if (original.getOriginalStub().getStore().equals(original)) {
+ if (original.getOriginalStub().getStores().contains(original)) {
parent = this.bag;
} else {
parent = ((OriginalFileStore)original.getParent()).getMetsDivType();
@@ -70,7 +70,7 @@ public OriginalsContentProvider() {
}
} else if(parent instanceof OriginalStub) {
OriginalStub original = (OriginalStub)parent;
- results.add(original.getStore());
+ results.addAll(original.getStores());
} else if (parent instanceof IFileStore) {
IFileStore f = (IFileStore) parent;
for (IFileStore r : f.childStores(0, new NullProgressMonitor())) {
@@ -22,28 +22,22 @@
import gov.loc.mets.util.METSConstants;
import gov.loc.mets.util.METSUtils;
+import java.net.URI;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.eclipse.core.resources.IMarkerDelta;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ILightweightLabelDecorator;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import unc.lib.cdr.workbench.IResourceConstants;
import unc.lib.cdr.workbench.originals.OriginalFileStore;
-import unc.lib.cdr.workbench.project.MetsProjectNature;
+import unc.lib.cdr.workbench.originals.OriginalStub;
import unc.lib.cdr.workbench.views.LabelImageFactory.Icon;
public class OriginalsDecorator implements ILightweightLabelDecorator {
@@ -78,12 +72,24 @@ public void removeListener(ILabelProviderListener listener) {
@Override
public void decorate(Object element, IDecoration decoration) {
+ if (element instanceof OriginalStub) {
+ decorateOriginalStub((OriginalStub) element, decoration);
+ return;
+ }
OriginalFileStore r = null;
boolean isDiv = false;
// added/captured, queued/staged BR
List<String> labels = new ArrayList<String>();
if (element instanceof OriginalFileStore) {
r = (OriginalFileStore) element;
+ // add prefix of "../" to these when not under volume root
+ if (r.getWrapped().getParent() != null) {
+ if (r.getOriginalStub().getStores().contains(r)) {
+ if (!r.getOriginalStub().getVolumeRootStore().getWrapped().equals(r.getWrapped().getParent())) {
+ decoration.addPrefix(".../");
+ }
+ }
+ }
} else if (element instanceof DivType) {
isDiv = true;
DivType d = (DivType) element;
@@ -128,16 +134,10 @@ public void decorate(Object element, IDecoration decoration) {
labels.add("captured");
}
}
- // TODO make a separate decorator for the Originals object
- // if (!isDiv && r.getParent().equals(r.getProject().getFolder(MetsProjectNature.ORIGINALS_FOLDER_NAME))) {
- // IMarker[] m = r.findMarkers(IResourceConstants.MARKER_ORIGINALFILESET, false, IResource.DEPTH_ZERO);
- // if (m.length > 0) {
- // Object base = m[0].getAttribute("prestagedBase");
- // if (base != null) {
- // labels.add("prestaged => " + base);
- // }
- // }
- // }
+ URI prestage = r.getOriginalStub().getPrestageBase(r.getWrapped().toURI());
+ if (prestage != null) {
+ labels.add("pre-staged=>" + prestage.toString());
+ }
if (r.getStagingLocatorType() != null) {
// captured file (original or the div)
overlay = Icon.StagedDecor.getImageDescriptor();
@@ -169,60 +169,24 @@ public void decorate(Object element, IDecoration decoration) {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org
- * .eclipse.core.resources.IResourceChangeEvent)
- */
-// @Override
-// public void resourceChanged(IResourceChangeEvent event) {
-// // TODO how to update on changes with file store objects
-// Set<Object> changes = new HashSet<Object>();
-// IMarkerDelta[] captures = event.findMarkerDeltas(IResourceConstants.MARKER_CAPTURED, false);
-// IMarkerDelta[] stages = event.findMarkerDeltas(IResourceConstants.MARKER_STAGED, false);
-// for (IMarkerDelta d : captures) {
-// if (d.getResource().getProject().isOpen()) {
-// changes.add(d.getResource());
-// try {
-// MetsProjectNature n = (MetsProjectNature) d.getResource().getProject()
-// .getNature(MetsProjectNature.NATURE_ID);
-// String divID = IResourceConstants.getDivID(d.getResource());
-// if (n != null && n.getMetsResource() != null && divID != null) {
-// Object div = n.getMetsResource().getEObject(divID);
-// if (div != null) {
-// changes.add(div);
-// }
-// }
-// } catch (CoreException e1) {
-// e1.printStackTrace();
-// }
-// }
-// }
-// for (IMarkerDelta d : stages) {
-// if (d.getResource().getProject().isOpen()) {
-// changes.add(d.getResource());
-// try {
-// MetsProjectNature n = (MetsProjectNature) d.getResource().getProject()
-// .getNature(MetsProjectNature.NATURE_ID);
-// String divID = IResourceConstants.getDivID(d.getResource());
-// if (n != null && n.getMetsResource() != null && divID != null) {
-// Object div = n.getMetsResource().getEObject(divID);
-// if (div != null) {
-// changes.add(div);
-// }
-// }
-// } catch (CoreException e1) {
-// e1.printStackTrace();
-// }
-// }
-// }
-// if (changes.size() > 0) {
-// LabelProviderChangedEvent e = new LabelProviderChangedEvent(this, changes.toArray());
-// for (ILabelProviderListener l : listeners) {
-// l.labelProviderChanged(e);
-// }
-// }
-// }
-
+ private void decorateOriginalStub(OriginalStub stub, IDecoration decoration) {
+ decoration.addPrefix("Originals on ");
+ List<String> labels = new ArrayList<String>();
+ // ejected overlay for detached disks
+ if (!stub.isAttached()) {
+ decoration.addOverlay(Icon.EjectedDecore.getImageDescriptor(), IDecoration.TOP_RIGHT);
+ }
+ labels.add(stub.getVolumeType());
+ if (labels.size() > 0) {
+ // decoration.setForegroundColor(org.eclipse.swt.graphics.);
+ StringBuilder sb = new StringBuilder();
+ sb.append(" [");
+ sb.append(labels.remove(0));
+ for (String label : labels) {
+ sb.append(" ").append(label);
+ }
+ sb.append("]");
+ decoration.addSuffix(sb.toString());
+ }
+ }
}
@@ -15,11 +15,7 @@
*/
package unc.lib.cdr.workbench.capture;
-import java.io.File;
-
-import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
@@ -132,7 +128,9 @@ public Image getImage(Object element) {
}
}
} else if(element instanceof OriginalStub) {
- return LabelImageFactory.getImage(Icon.OriginalsEl);
+ // distinctive disk type images
+ OriginalStub stub = (OriginalStub)element;
+ return LabelImageFactory.getDiskImage(stub.getVolumeType());
}
return provider.getImage(element);
}
@@ -146,8 +144,7 @@ public Image getImage(Object element) {
public String getText(Object element) {
if(element instanceof OriginalStub) {
OriginalStub o = (OriginalStub)element;
- if(o.getName() != null) return o.getName();
- return o.getStore().getName();
+ return o.getName();
} else if(element instanceof IFileStore) {
return ((IFileStore)element).getName();
}
@@ -15,31 +15,29 @@
*/
package unc.lib.cdr.workbench.capture;
+import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.core.runtime.jobs.Job;
-import unc.lib.cdr.workbench.IResourceConstants;
import unc.lib.cdr.workbench.originals.OriginalStub;
-import unc.lib.cdr.workbench.originals.OriginalsFileSystem;
import unc.lib.cdr.workbench.originals.VolumeUtil;
import unc.lib.cdr.workbench.project.MetsProjectNature;
@@ -78,26 +76,58 @@ protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask("Linking to originals ...", this.locations.size());
MetsProjectNature n = MetsProjectNature.get(project);
try {
+ Set<URI> volumes = new HashSet<URI>();
+ Map<URI, Map<URI, URI>> volumeToPrestageLocations = new HashMap<URI, Map<URI, URI>>();
+ Map<URI, List<URI>> volumeToLocations = new HashMap<URI, List<URI>>();
for (URI location : locations) {
+ System.out.println("location: "+location);
IFileStore fs = EFS.getStore(location);
+ URI volume = null;
+ try {
+ volume = VolumeUtil.getTopResourceInVolume(location);
+ System.out.println("top resource in volume: "+volume);
+ } catch(IOException e) {
+ throw new Error(e);
+ }
+ volumes.add(volume);
+ if(volumeToLocations.get(volume) == null) {
+ volumeToLocations.put(volume, new ArrayList<URI>());
+ }
+ volumeToLocations.get(volume).add(location);
+
URI myprestage = null;
if (this.prestaged && this.prestagedBase != null && this.baselocation != null) {
// calculate staging base for each original location
IPath basePath = new Path(this.baselocation.getPath()); // base path for all locations
- IPath subPath = new Path(fs.toURI().getPath()).makeRelativeTo(basePath.removeLastSegments(1))
- .removeLastSegments(1);
+ IPath subPath = new Path(fs.toURI().getPath()).makeRelativeTo(basePath.removeLastSegments(1));
String myprestagestr = prestagedBase.toString();
if (subPath.segmentCount() > 0) {
myprestage = prestagedBase;
for (String s : subPath.segments()) {
myprestage = URIUtil.append(myprestage, s);
}
- myprestagestr = myprestage.toString() + "/";
+ if(volumeToPrestageLocations.get(volume) == null) {
+ volumeToPrestageLocations.put(volume, new HashMap<URI, URI>());
+ }
+ volumeToPrestageLocations.get(volume).put(location, myprestage);
}
}
- OriginalStub original = new OriginalStub(location, this.project, myprestage, null);
- n.addOriginal(original);
}
+ for(URI volumeRoot : volumes) {
+ OriginalStub existingStub = null;
+ for(OriginalStub s :n.getOriginals()) {
+ if(s.getVolumeRoot().equals(volumeRoot)) {
+ existingStub = s;
+ }
+ }
+ if(existingStub != null) {
+ existingStub.addLocations(volumeToLocations.get(volumeRoot), volumeToPrestageLocations.get(volumeRoot));
+ } else {
+ OriginalStub original = new OriginalStub(volumeRoot, volumeToLocations.get(volumeRoot), volumeToPrestageLocations.get(volumeRoot), this.project);
+ n.addOriginal(original);
+ }
+ }
+ n.save();
monitor.done();
return Status.OK_STATUS;
} catch (CoreException e) {
Oops, something went wrong.

0 comments on commit cf0d39f

Please sign in to comment.