Permalink
Browse files

done with initial pass of linking and displaying original locations a…

…long with volume information.

using a custom read-only EFS filestore implementation called OriginalsWrapperStore
  • Loading branch information...
gregjan committed Jul 4, 2012
1 parent fa41b1a commit a933f6452667afbb94c51100fc35e1eded7653f8
Showing with 684 additions and 370 deletions.
  1. +1 −1 workbench_plugin/META-INF/MANIFEST.MF
  2. +16 −8 workbench_plugin/plugin.xml
  3. +1 −1 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/CaptureJob.java
  4. +0 −66 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalFoldersProjectElement.java
  5. +23 −47 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsContentProvider.java
  6. +28 −4 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsLabelProvider.java
  7. +12 −48 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsLinkJob.java
  8. +0 −8 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/PickOriginalLocationsPage.java
  9. +2 −3 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/RescanOriginalsHandler.java
  10. +8 −15 workbench_plugin/src/main/java/unc/lib/cdr/workbench/commands/OpenSystemEditorTempCopyHandler.java
  11. +99 −0 workbench_plugin/src/main/java/unc/lib/cdr/workbench/originals/Original.java
  12. +8 −7 ...r/workbench/{readonly/ReadOnlyWrapperFileSystem.java → originals/OriginalsWrapperFileSystem.java}
  13. +99 −24 ...unc/lib/cdr/workbench/{readonly/ReadOnlyWrapperStore.java → originals/OriginalsWrapperStore.java}
  14. +12 −32 workbench_plugin/src/main/java/unc/lib/cdr/workbench/{readonly → originals}/VolumeUtil.java
  15. +70 −36 workbench_plugin/src/main/java/unc/lib/cdr/workbench/project/MetsProjectNature.java
  16. +12 −11 workbench_plugin/src/main/java/unc/lib/cdr/workbench/project/ProjectEMFSession.java
  17. +27 −0 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/HasOriginalFilter.java
  18. +27 −0 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/HasStagedFileFilter.java
  19. +51 −28 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/LabelImageFactory.java
  20. +14 −11 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/OriginalFingerprintSection.java
  21. +9 −5 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/OriginalResourcePropertySheetSection.java
  22. +165 −0 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/OriginalVolumeSection.java
  23. +0 −15 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/PropertySheetPropertySection.java
@@ -110,10 +110,10 @@ Export-Package: .,
unc.lib.cdr.workbench.capture,
unc.lib.cdr.workbench.commands,
unc.lib.cdr.workbench.describe,
+ unc.lib.cdr.workbench.originals,
unc.lib.cdr.workbench.preferences,
unc.lib.cdr.workbench.project,
unc.lib.cdr.workbench.rcp,
- unc.lib.cdr.workbench.readonly,
unc.lib.cdr.workbench.stage,
unc.lib.cdr.workbench.views,
unc.lib.cdr.workbench.xwalk
@@ -1169,7 +1169,7 @@
appearsBefore="cdr-workbench.arrangementContent"
contentProvider="unc.lib.cdr.workbench.capture.OriginalsContentProvider"
id="cdr-workbench.originalsContent"
- labelProvider="org.eclipse.ui.model.WorkbenchLabelProvider"
+ labelProvider="unc.lib.cdr.workbench.capture.OriginalsLabelProvider"
name="Original Folders"
priority="highest">
<triggerPoints>
@@ -1184,6 +1184,9 @@
<instanceof
value="org.eclipse.core.resources.IResource">
</instanceof>
+ <instanceof
+ value="unc.lib.cdr.workbench.originals.Original">
+ </instanceof>
</or>
</possibleChildren>
</navigatorContent>
@@ -1549,26 +1552,24 @@
<propertySection
class="unc.lib.cdr.workbench.views.OriginalFingerprintSection"
enablesFor="1"
- filter="unc.lib.cdr.workbench.views.DivTypeFileFilter"
+ filter="unc.lib.cdr.workbench.views.HasStagedFileFilter"
id="workbench_plugin.propertySectionOriginalFingerprintSection"
tab="workbench_plugin.propertyTabOriginalProperties">
</propertySection>
<propertySection
afterSection="workbench_plugin.propertySectionOriginalFingerprintSection"
class="unc.lib.cdr.workbench.views.OriginalResourcePropertySheetSection"
enablesFor="1"
- filter="unc.lib.cdr.workbench.views.DivTypeWithOriginalFilter"
+ filter="unc.lib.cdr.workbench.views.HasOriginalFilter"
id="workbench_plugin.propertySectionOriginalProperties"
tab="workbench_plugin.propertyTabOriginalProperties">
</propertySection>
<propertySection
class="org.eclipse.ui.views.properties.tabbed.AdvancedPropertySection"
enablesFor="1"
+ filter="unc.lib.cdr.workbench.views.HasOriginalFilter"
id="workbench_plugin.propertySectionResourceProperties"
tab="workbench_plugin.propertyTabOriginalProperties">
- <input
- type="org.eclipse.core.resources.IResource">
- </input>
</propertySection>
<propertySection
class="unc.lib.cdr.workbench.views.MdSecTypePropertySection"
@@ -1579,6 +1580,13 @@
type="gov.loc.mets.MdSecType">
</input>
</propertySection>
+ <propertySection
+ class="unc.lib.cdr.workbench.views.OriginalVolumeSection"
+ enablesFor="1"
+ filter="unc.lib.cdr.workbench.views.HasOriginalFilter"
+ id="workbench_plugin.propertySectionOriginalVolumeSection"
+ tab="workbench_plugin.propertyTabOriginalProperties">
+ </propertySection>
</propertySections>
</extension>
<extension
@@ -1696,7 +1704,7 @@
<filesystem
scheme="ro+file">
<run
- class="unc.lib.cdr.workbench.readonly.ReadOnlyWrapperFileSystem">
+ class="unc.lib.cdr.workbench.originals.OriginalsWrapperFileSystem">
</run>
</filesystem>
</extension>
@@ -1705,7 +1713,7 @@
<filesystem
scheme="ro+irods">
<run
- class="unc.lib.cdr.workbench.readonly.ReadOnlyWrapperFileSystem">
+ class="unc.lib.cdr.workbench.originals.OriginalsWrapperFileSystem">
</run>
</filesystem>
</extension>
@@ -290,7 +290,7 @@ private FileType findFile(IResource r) throws CoreException {
*/
private void makeOrLinkParent(IResource resource, DivType div) throws CoreException {
DivType parent = null;
- if (mpn.getOriginalsFolder().equals(resource.getParent()) || resource.getParent() == null) {
+ if (resource.getParent() == null) {
parent = this.bag;
} else {
parent = findDiv(resource.getParent());
@@ -1,66 +0,0 @@
-/**
- * Copyright 2010 The University of North Carolina at Chapel Hill
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package unc.lib.cdr.workbench.capture;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.CoreException;
-
-import unc.lib.cdr.workbench.project.AbstractCustomProjectElement;
-import unc.lib.cdr.workbench.project.ICustomProjectElement;
-import unc.lib.cdr.workbench.project.MetsProjectNature;
-
-/**
- * @author Gregory Jansen
- *
- */
-public class OriginalFoldersProjectElement extends AbstractCustomProjectElement implements ICustomProjectElement {
- private static final String label = "Originals";
- private IFolder folder = null;
-
- /**
- * @param n
- */
- public OriginalFoldersProjectElement(MetsProjectNature n) {
- super(n);
- this.folder = n.getOriginalsFolder();
- }
-
- @Override
- public Object[] getChildren() {
- try {
- return folder.members();
- } catch (CoreException e) {
- e.printStackTrace();
- throw new Error("Unexpected", e);
- }
- }
-
- @Override
- public boolean hasChildren() {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see unc.lib.cdr.workbench.project.ICustomProjectElement#getText()
- */
- @Override
- public String getText() {
- return label;
- }
-
-}
@@ -18,6 +18,8 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -26,27 +28,28 @@
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Display;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import unc.lib.cdr.workbench.originals.Original;
import unc.lib.cdr.workbench.project.MetsProjectNature;
/**
* @author Gregory Jansen
*
*/
-public class OriginalsContentProvider implements ITreeContentProvider, IResourceChangeListener {
+public class OriginalsContentProvider implements ITreeContentProvider {
private static final Logger log = LoggerFactory.getLogger(OriginalsContentProvider.class);
Viewer viewer = null;
/**
*
*/
public OriginalsContentProvider() {
- ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
}
/*
@@ -63,14 +66,14 @@ public OriginalsContentProvider() {
IProject p = (IProject) parent;
if (p.isOpen()) {
MetsProjectNature n = (MetsProjectNature) p.getNature(MetsProjectNature.NATURE_ID);
- results.add(n.getOriginalsElement());
+ results.addAll(n.getOriginals());
}
- } else if (parent instanceof OriginalFoldersProjectElement) {
- OriginalFoldersProjectElement e = (OriginalFoldersProjectElement) parent;
- return e.getChildren();
- } else if (parent instanceof IFolder) {
- IFolder f = (IFolder) parent;
- for (IResource r : f.members()) {
+ } else if(parent instanceof Original) {
+ Original original = (Original)parent;
+ results.add(original.getStore());
+ } else if (parent instanceof IFileStore) {
+ IFileStore f = (IFileStore) parent;
+ for (IFileStore r : f.childStores(0, new NullProgressMonitor())) {
results.add(r);
}
}
@@ -88,23 +91,8 @@ public OriginalsContentProvider() {
@Override
public Object getParent(Object element) {
Object result = null;
- if (element instanceof IResource) {
- IResource r = (IResource) element;
- String[] segments = r.getProjectRelativePath().segments();
- if (segments.length == 2) {
- // found an originals folder, return OriginalsProjectElement
- MetsProjectNature n;
- try {
- n = (MetsProjectNature) r.getProject().getNature(MetsProjectNature.NATURE_ID);
- } catch (CoreException e) {
- throw new Error("Unexpected");
- }
- return n.getOriginalsElement();
- } else {
- // should be a resource within an originals folder, use
- // getParent()
- return r.getParent();
- }
+ if (element instanceof IFileStore) {
+ return ((IFileStore)element).getParent();
} else {
return result;
}
@@ -117,10 +105,16 @@ public Object getParent(Object element) {
*/
@Override
public boolean hasChildren(Object element) {
- if (element instanceof IContainer) {
+ if(element instanceof Original) {
return true;
- } else if (element instanceof OriginalFoldersProjectElement) {
- return ((OriginalFoldersProjectElement) element).hasChildren();
+ } else if(element instanceof IFileStore) {
+ IFileStore fs = (IFileStore)element;
+ try {
+ return (fs.fetchInfo().isDirectory() && fs.childNames(EFS.NONE, new NullProgressMonitor()).length > 0);
+ } catch(CoreException e) {
+ e.printStackTrace();
+ return false;
+ }
} else {
return false;
}
@@ -143,7 +137,6 @@ public boolean hasChildren(Object element) {
*/
@Override
public void dispose() {
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
}
/*
@@ -157,21 +150,4 @@ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
this.viewer = viewer;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org
- * .eclipse.core.resources.IResourceChangeEvent)
- */
- @Override
- public void resourceChanged(IResourceChangeEvent event) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- if (!viewer.getControl().isDisposed()) {
- viewer.refresh();
- }
- }
- });
- }
-
}
@@ -15,6 +15,11 @@
*/
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;
@@ -23,7 +28,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import unc.lib.cdr.workbench.originals.Original;
import unc.lib.cdr.workbench.views.LabelImageFactory;
+import unc.lib.cdr.workbench.views.LabelImageFactory.Icon;
/**
* @author Gregory Jansen
@@ -111,8 +118,21 @@ public void removeListener(ILabelProviderListener listener) {
*/
@Override
public Image getImage(Object element) {
- if (element instanceof OriginalFoldersProjectElement) {
- return LabelImageFactory.getImageForObject(element);
+ if(element instanceof IFileStore) {
+ IFileStore fs = (IFileStore)element;
+ String filename = fs.getName();
+ int i = filename.lastIndexOf('.');
+ if(i >= 0) {
+ return LabelImageFactory.getImageForExtension(filename.substring(i));
+ } else {
+ if(fs.fetchInfo().isDirectory()) {
+ return LabelImageFactory.getImage(Icon.Folder);
+ } else {
+ return LabelImageFactory.getImage(Icon.File);
+ }
+ }
+ } else if(element instanceof Original) {
+ return LabelImageFactory.getImage(Icon.OriginalsEl);
}
return provider.getImage(element);
}
@@ -124,8 +144,12 @@ public Image getImage(Object element) {
*/
@Override
public String getText(Object element) {
- if (element instanceof OriginalFoldersProjectElement) {
- return ((OriginalFoldersProjectElement) element).getText();
+ if(element instanceof Original) {
+ Original o = (Original)element;
+ if(o.getName() != null) return o.getName();
+ return o.getStore().getName();
+ } else if(element instanceof IFileStore) {
+ return ((IFileStore)element).getName();
}
return provider.getText(element);
}
Oops, something went wrong.

0 comments on commit a933f64

Please sign in to comment.