Skip to content
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...
1 parent fa41b1a commit a933f6452667afbb94c51100fc35e1eded7653f8 @gregjan gregjan committed
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
View
2 workbench_plugin/META-INF/MANIFEST.MF
@@ -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
View
24 workbench_plugin/plugin.xml
@@ -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,7 +1552,7 @@
<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>
@@ -1557,18 +1560,16 @@
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>
View
2 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/CaptureJob.java
@@ -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());
View
66 ...nch_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalFoldersProjectElement.java
@@ -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;
- }
-
-}
View
70 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsContentProvider.java
@@ -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,19 +28,21 @@
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;
@@ -46,7 +50,6 @@
*
*/
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();
- }
- }
- });
- }
-
}
View
32 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsLabelProvider.java
@@ -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);
}
View
60 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/OriginalsLinkJob.java
@@ -35,14 +35,12 @@
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.activities.WorkbenchActivityHelper;
-import org.eclipse.ui.internal.WorkbenchPlugin;
import unc.lib.cdr.workbench.IResourceConstants;
+import unc.lib.cdr.workbench.originals.Original;
+import unc.lib.cdr.workbench.originals.OriginalsWrapperFileSystem;
+import unc.lib.cdr.workbench.originals.VolumeUtil;
import unc.lib.cdr.workbench.project.MetsProjectNature;
-import unc.lib.cdr.workbench.readonly.ReadOnlyWrapperFileSystem;
-import unc.lib.cdr.workbench.readonly.VolumeUtil;
/**
* @author Gregory Jansen
@@ -53,7 +51,6 @@
List<URI> locations = null;
String name = null;
IProject project = null;
- List<IResource> links = new ArrayList<IResource>();
private boolean prestaged;
private URI prestagedBase;
@@ -66,10 +63,6 @@
this.prestagedBase = prestagedBase;
}
- public List<IResource> getLinks() {
- return this.links;
- }
-
/*
* (non-Javadoc)
*
@@ -83,12 +76,11 @@ protected IStatus run(IProgressMonitor monitor) {
IStatus result = null;
System.out.println("starting link");
monitor.beginTask("Linking to originals ...", this.locations.size());
- IFolder originalsFolder = this.project.getFolder(MetsProjectNature.ORIGINALS_FOLDER_NAME);
+ MetsProjectNature n = MetsProjectNature.get(project);
try {
for (URI location : locations) {
- IFileStore fs = ReadOnlyWrapperFileSystem.wrapStore(location);
+ IFileStore fs = OriginalsWrapperFileSystem.wrapStore(location, this.project);
boolean isDir = fs.fetchInfo().isDirectory();
-
String linkName = null;
IPath path = new Path(fs.toURI().getPath());
if (path != null && path.segments().length > 0 && path.lastSegment().trim().length() > 0) {
@@ -98,37 +90,9 @@ protected IStatus run(IProgressMonitor monitor) {
} else {
linkName = "ROOT";
}
- IResource link = null;
- if (isDir) {
- link = originalsFolder.getFolder(linkName);
- } else {
- link = originalsFolder.getFile(linkName);
- }
- if (link.exists() && link.getLocationURI().equals(fs.toURI())) {
- // already linked to this original folder, continue
- continue;
- }
- if (link.exists()) {
- for (int suffix = 1; link.exists(); suffix++) {
- if (isDir) {
- link = originalsFolder.getFolder(linkName + "_" + suffix);
- } else {
- link = originalsFolder.getFile(linkName + "_" + suffix);
- }
- }
- }
- monitor.subTask("Linking " + location);
- if (isDir) {
- ((IFolder) link).createLink(fs.toURI(), IFolder.ALLOW_MISSING_LOCAL | IFolder.BACKGROUND_REFRESH,
- new SubProgressMonitor(monitor, 1));
- } else {
- ((IFile) link).createLink(fs.toURI(), IFolder.ALLOW_MISSING_LOCAL | IFolder.BACKGROUND_REFRESH,
- new SubProgressMonitor(monitor, 1));
- }
- IMarker marker = link.createMarker(IResourceConstants.MARKER_ORIGINALFILESET);
- marker.setAttribute("type", location.getScheme());
- VolumeUtil.isVolumeRemovable(link);
- VolumeUtil.recordVolumeFingerprint(link);
+ //VolumeUtil.isVolumeRemovable(link);
+ //VolumeUtil.recordVolumeFingerprint(link);
+ 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
@@ -136,17 +100,17 @@ protected IStatus run(IProgressMonitor monitor) {
.removeLastSegments(1);
String myprestagestr = prestagedBase.toString();
if (subPath.segmentCount() > 0) {
- URI myprestage = prestagedBase;
+ myprestage = prestagedBase;
for (String s : subPath.segments()) {
myprestage = URIUtil.append(myprestage, s);
}
myprestagestr = myprestage.toString() + "/";
}
- marker.setAttribute(IResourceConstants.MARKER_ORIGINALFILESET_PRESTAGEDBASE_ATT, myprestagestr);
}
- this.links.add(link);
+ // TODO recalc prestage base URI and name?
+ Original original = new Original(location, this.project, myprestage, null);
+ n.addOriginal(original);
}
- project.getWorkspace().save(false, monitor);
monitor.done();
return Status.OK_STATUS;
} catch (CoreException e) {
View
8 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/PickOriginalLocationsPage.java
@@ -20,7 +20,6 @@
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
-import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -29,7 +28,6 @@
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.filesystem.provider.FileStore;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -64,7 +62,6 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.internal.Workbench;
import org.osgi.service.prefs.BackingStoreException;
import unc.lib.cdr.workbench.rcp.Activator;
@@ -592,11 +589,6 @@ private void initialPopulateProjectField() {
if (p.isOpen()) {
projectCombo.select(openProjects.indexOf(p.getName()));
}
- } else if (OriginalFoldersProjectElement.class.isInstance(selection.getFirstElement())) {
- OriginalFoldersProjectElement o = (OriginalFoldersProjectElement) selection.getFirstElement();
- if (o.getProject().isOpen()) {
- projectCombo.select(openProjects.indexOf(o.getProject().getName()));
- }
} else {
projectCombo.select(0);
}
View
5 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/RescanOriginalsHandler.java
@@ -29,12 +29,11 @@
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
+ // TODO how to refresh file store originals
IStructuredSelection select = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
Object sel = select.getFirstElement();
IResource target = null;
- if (sel instanceof OriginalFoldersProjectElement) {
- target = ((OriginalFoldersProjectElement) sel).getProject();
- } else if (sel instanceof IResource) {
+ if (sel instanceof IResource) {
target = (IResource) sel;
}
try {
View
23 ..._plugin/src/main/java/unc/lib/cdr/workbench/commands/OpenSystemEditorTempCopyHandler.java
@@ -11,7 +11,6 @@
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -23,6 +22,7 @@
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.ide.IDE;
+import unc.lib.cdr.workbench.originals.OriginalsWrapperStore;
import unc.lib.cdr.workbench.project.MetsProjectNature;
public class OpenSystemEditorTempCopyHandler extends AbstractHandler implements IHandler {
@@ -33,17 +33,13 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
if (selection instanceof IStructuredSelection) {
for (Iterator it = ((IStructuredSelection) selection).iterator(); it.hasNext();) {
Object element = it.next();
- if (element instanceof IFile) {
- IFile file = null;
- file = (IFile) element;
+ if (element instanceof IFileStore) {
+ IFileStore file = (IFileStore) element;
openTempCopy(file, event);
} else if(element instanceof DivType) {
DivType d = (DivType)element;
- IResource r = MetsProjectNature.getOriginal(d);
- IFile f = r.getProject().getFile(r.getProjectRelativePath());
- if(f != null) {
- openTempCopy(f, event);
- }
+ OriginalsWrapperStore r = MetsProjectNature.getOriginal(d);
+ openTempCopy(r, event);
}
}
}
@@ -55,8 +51,8 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
* @param event
* @throws ExecutionException
*/
- private void openTempCopy(IFile file, ExecutionEvent event) throws ExecutionException {
- IPath origPath = file.getFullPath();
+ private void openTempCopy(IFileStore file, ExecutionEvent event) throws ExecutionException {
+ IPath origPath = new Path(file.toURI().getPath());
String tmpdir = System.getProperty("java.io.tmpdir");
IPath temppath = new Path(tmpdir).append(origPath.removeLastSegments(1));
temppath = temppath.append(
@@ -65,12 +61,9 @@ private void openTempCopy(IFile file, ExecutionEvent event) throws ExecutionExce
origPath.getFileExtension());
IFileStore tempStore = EFS.getLocalFileSystem().getStore(temppath);
if(!tempStore.fetchInfo().exists()) {
- // copy to temp
- IFileStore origStore;
try {
- origStore = EFS.getStore(file.getRawLocationURI());
tempStore.getParent().mkdir(EFS.NONE, new NullProgressMonitor());
- origStore.copy(tempStore, EFS.OVERWRITE, new NullProgressMonitor());
+ file.copy(tempStore, EFS.OVERWRITE, new NullProgressMonitor());
} catch (CoreException e) {
e.printStackTrace();
throw new ExecutionException("Cannot copy file to temporary location: "+e.getMessage());
View
99 workbench_plugin/src/main/java/unc/lib/cdr/workbench/originals/Original.java
@@ -0,0 +1,99 @@
+package unc.lib.cdr.workbench.originals;
+
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.FileStore;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.ui.IWorkbench;
+
+public class Original implements java.io.Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3465833912924570340L;
+
+ private URI base;
+ private transient IProject project;
+ private String projectName;
+ private int volumeHash;
+ private String name;
+ private transient OriginalsWrapperStore store = null;
+ private URI prestageBase;
+
+ public Original(URI base, IProject project, URI prestageBase, String name) {
+ this.base = base;
+ this.project = project;
+ this.projectName = project.getName();
+ this.prestageBase = prestageBase;
+ this.name = name;
+ init();
+ try {
+ this.volumeHash = VolumeUtil.makeVolumeFingerprint(base);
+ if(this.name == null) {
+ Path path = Paths.get(base);
+ String volumeName = null;
+ try {
+ FileStore fs = Files.getFileStore(path);
+ volumeName = fs.name();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ this.name = volumeName == null ? this.store.getName() : this.store.getName()+" on "+volumeName;
+ }
+ } catch (CoreException e) {
+ throw new Error(e);
+ }
+ }
+
+ private void init() {
+ try {
+ this.store = (OriginalsWrapperStore) OriginalsWrapperFileSystem.wrapStore(base, this.project);
+ this.project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ } catch (CoreException e) {
+ throw new Error(e);
+ }
+ }
+
+ public IProject getProject() {
+ if(project == null) init();
+ return project;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public URI getPrestageBase() {
+ return prestageBase;
+ }
+
+ public void setPrestageBase(URI prestageBase) {
+ this.prestageBase = prestageBase;
+ }
+
+ public URI getBase() {
+ return base;
+ }
+
+ public int getVolumeHash() {
+ return volumeHash;
+ }
+
+ public OriginalsWrapperStore getStore() {
+ if(this.store == null) init();
+ return store;
+ }
+
+}
View
15 ...h/readonly/ReadOnlyWrapperFileSystem.java → ...originals/OriginalsWrapperFileSystem.java
@@ -1,4 +1,4 @@
-package unc.lib.cdr.workbench.readonly;
+package unc.lib.cdr.workbench.originals;
import java.net.URI;
@@ -6,29 +6,30 @@
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.filesystem.provider.FileSystem;
import org.eclipse.core.internal.filesystem.NullFileSystem;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import unc.lib.cdr.workbench.rcp.Activator;
-public class ReadOnlyWrapperFileSystem extends FileSystem {
- private static ReadOnlyWrapperFileSystem __instance = new ReadOnlyWrapperFileSystem();
+public class OriginalsWrapperFileSystem extends FileSystem {
+ private static OriginalsWrapperFileSystem __instance = new OriginalsWrapperFileSystem();
- public ReadOnlyWrapperFileSystem() {
+ public OriginalsWrapperFileSystem() {
}
@Override
public IFileStore getStore(URI uri) {
try {
- return new ReadOnlyWrapperStore(uri);
+ return new OriginalsWrapperStore(uri, null);
} catch (CoreException e) {
Activator.getDefault().getLog().log(e.getStatus());
return NullFileSystem.getInstance().getStore(uri);
}
}
- public static IFileStore wrapStore(URI uri) throws CoreException {
+ public static IFileStore wrapStore(URI uri, IProject project) throws CoreException {
IFileStore wrapped = EFS.getStore(uri);
- return new ReadOnlyWrapperStore(wrapped);
+ return new OriginalsWrapperStore(wrapped, project);
}
}
View
123 ...kbench/readonly/ReadOnlyWrapperStore.java → ...ench/originals/OriginalsWrapperStore.java
@@ -1,4 +1,9 @@
-package unc.lib.cdr.workbench.readonly;
+package unc.lib.cdr.workbench.originals;
+
+import gov.loc.mets.DivType;
+import gov.loc.mets.FLocatType;
+import gov.loc.mets.FileType;
+import gov.loc.mets.util.METSConstants;
import java.io.File;
import java.io.InputStream;
@@ -10,47 +15,111 @@
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.filesystem.IFileSystem;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Status;
+import unc.lib.cdr.workbench.project.MetsProjectNature;
import unc.lib.cdr.workbench.rcp.Activator;
-public class ReadOnlyWrapperStore implements IFileStore {
+public class OriginalsWrapperStore implements IFileStore {
+ private static final String FILETYPE_PREFIX = "f_";
+ private static final String DIVTYPE_PREFIX = "d_";
private static final String protectedMessage = "Operation cancelled. This file under read only protection within the workbench.";
public static final String SCHEME_PREFIX = "ro+";
protected URI uri = null;
+ private IProject project = null;
protected IFileStore wrapped = null;
- public ReadOnlyWrapperStore(URI uri) throws CoreException {
+ public IFileStore getWrapped() {
+ return wrapped;
+ }
+
+ protected int volumeHash = -1;
+
+ public OriginalsWrapperStore(URI uri, IProject project) throws CoreException {
+ this.project = project;
this.uri = uri;
- if(!uri.getScheme().startsWith(SCHEME_PREFIX)) {
- throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID, "Read only wrapper stores must start with: "+SCHEME_PREFIX+" "+uri));
+ if (!uri.getScheme().startsWith(SCHEME_PREFIX)) {
+ throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID,
+ "Read only wrapper stores must start with: " + SCHEME_PREFIX + " " + uri));
}
String test = uri.getRawSchemeSpecificPart();
- //Activator.getDefault().getLog().log(new Status(Status.INFO, Activator.PLUGIN_ID, "trying a read only wrapped store: "+uri+ " wraps "+test));
URI wrappedUri = null;
try {
- wrappedUri = new URI(uri.getScheme().substring(3)+":"+test);
- } catch(URISyntaxException e) {
- throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID, "Cannot use read only wrapper on uri: "+uri, e));
+ wrappedUri = new URI(uri.getScheme().substring(3) + ":" + test);
+ } catch (URISyntaxException e) {
+ throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID, "Cannot use read only wrapper on uri: "
+ + uri, e));
}
this.wrapped = EFS.getStore(wrappedUri);
+ this.volumeHash = VolumeUtil.makeVolumeFingerprint(wrappedUri);
}
- public ReadOnlyWrapperStore(IFileStore iFileStore) throws CoreException {
+ public OriginalsWrapperStore(IFileStore iFileStore, IProject project) throws CoreException {
this.wrapped = iFileStore;
+ this.project = project;
try {
URI wrappedUri = this.wrapped.toURI();
- this.uri = new URI(SCHEME_PREFIX+wrappedUri.getScheme()+":"+wrappedUri.getRawSchemeSpecificPart());
+ this.uri = new URI(SCHEME_PREFIX + wrappedUri.getScheme() + ":" + wrappedUri.getRawSchemeSpecificPart());
} catch (URISyntaxException e) {
throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID, "Cannot wrap store in read only", e));
- } catch(NullPointerException e) {
+ } catch (NullPointerException e) {
throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID, "Cannot wrap store in read only", e));
}
}
+ public FileType getMetsFileType() {
+ try {
+ return (FileType) MetsProjectNature.get(project).getMetsResource().getEObject(getFileID());
+ } catch (NullPointerException e) {
+ return null;
+ }
+ }
+
+ private String getFileID() {
+ return new StringBuilder().append(FILETYPE_PREFIX).append(this.hashCode()).toString();
+ }
+
+ private String getDivID() {
+ return new StringBuilder().append(DIVTYPE_PREFIX).append(this.hashCode()).toString();
+ }
+
+ public FLocatType getStagingLocatorType() {
+ try {
+ MetsProjectNature n = MetsProjectNature.get(project);
+ FileType ft = (FileType) n.getMetsResource().getEObject(getFileID());
+ for (FLocatType loc : ft.getFLocat()) {
+ if (METSConstants.FLocat_USE_STAGE.equals(loc.getUSE())) {
+ return loc;
+ }
+ }
+ } catch (NullPointerException e) {
+ }
+ return null;
+ }
+
+ public DivType getMetsDivType() {
+ try {
+ MetsProjectNature n = MetsProjectNature.get(project);
+ return (DivType) n.getMetsResource().getEObject(getDivID());
+ } catch (NullPointerException e) {
+ return null;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return this.uri.hashCode() ^ this.volumeHash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return (obj instanceof OriginalsWrapperStore && obj != null && obj.hashCode() == this.hashCode());
+ }
+
@Override
public Object getAdapter(Class adapter) {
return this.wrapped.getAdapter(adapter);
@@ -71,9 +140,9 @@ public Object getAdapter(Class adapter) {
public IFileStore[] childStores(int options, IProgressMonitor monitor) throws CoreException {
// wraps these in read only
IFileStore[] wrappedResult = wrapped.childStores(options, monitor);
- IFileStore[] result = new ReadOnlyWrapperStore[wrappedResult.length];
- for(int i = 0; i < wrappedResult.length; i++) {
- result[i] = new ReadOnlyWrapperStore(wrappedResult[i]);
+ IFileStore[] result = new OriginalsWrapperStore[wrappedResult.length];
+ for (int i = 0; i < wrappedResult.length; i++) {
+ result[i] = new OriginalsWrapperStore(wrappedResult[i], project);
}
return result;
}
@@ -101,7 +170,7 @@ public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreExc
@Override
public IFileStore getChild(IPath path) {
try {
- return new ReadOnlyWrapperStore(this.wrapped.getChild(path));
+ return new OriginalsWrapperStore(this.wrapped.getChild(path), project);
} catch (CoreException e) {
throw new Error("Unexpected exception", e);
}
@@ -110,7 +179,7 @@ public IFileStore getChild(IPath path) {
@Override
public IFileStore getFileStore(IPath path) {
try {
- return new ReadOnlyWrapperStore(this.wrapped.getFileStore(path));
+ return new OriginalsWrapperStore(this.wrapped.getFileStore(path), project);
} catch (CoreException e) {
throw new Error("Unexpected exception", e);
}
@@ -119,7 +188,7 @@ public IFileStore getFileStore(IPath path) {
@Override
public IFileStore getChild(String name) {
try {
- return new ReadOnlyWrapperStore(this.wrapped.getChild(name));
+ return new OriginalsWrapperStore(this.wrapped.getChild(name), project);
} catch (CoreException e) {
throw new Error("Unexpected exception", e);
}
@@ -129,7 +198,7 @@ public IFileStore getChild(String name) {
public IFileSystem getFileSystem() {
try {
return EFS.getFileSystem(uri.getScheme());
- } catch(CoreException e) {
+ } catch (CoreException e) {
Activator.getDefault().getLog().log(e.getStatus());
throw new Error("Unexpected error", e);
}
@@ -137,7 +206,7 @@ public IFileSystem getFileSystem() {
@Override
public String toString() {
- return new StringBuilder().append("read only: "+wrapped.toString()).toString();
+ return new StringBuilder().append("read only: " + wrapped.toString()).toString();
}
@Override
@@ -149,17 +218,23 @@ public String getName() {
public IFileStore getParent() {
try {
IFileStore wrappedParent = this.wrapped.getParent();
- if(wrappedParent == null) return null;
- return new ReadOnlyWrapperStore(this.wrapped.getParent());
+ if (wrappedParent == null)
+ return null;
+ return new OriginalsWrapperStore(this.wrapped.getParent(), project);
} catch (CoreException e) {
throw new Error("Unexpected exception", e);
}
}
+ public IProject getProject() {
+ return project;
+ }
+
@Override
public boolean isParentOf(IFileStore other) {
- if(ReadOnlyWrapperFileSystem.class.isInstance(other.getFileSystem()) && ReadOnlyWrapperStore.class.isInstance(other)) {
- ReadOnlyWrapperStore o = (ReadOnlyWrapperStore)other;
+ if (OriginalsWrapperFileSystem.class.isInstance(other.getFileSystem())
+ && OriginalsWrapperStore.class.isInstance(other)) {
+ OriginalsWrapperStore o = (OriginalsWrapperStore) other;
return wrapped.isParentOf(o.wrapped);
}
return false;
View
44 ...ib/cdr/workbench/readonly/VolumeUtil.java → ...b/cdr/workbench/originals/VolumeUtil.java
@@ -1,9 +1,9 @@
-package unc.lib.cdr.workbench.readonly;
+package unc.lib.cdr.workbench.originals;
import java.io.File;
import java.io.IOException;
+import java.net.URI;
import java.nio.file.FileStore;
-import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.LinkOption;
import java.nio.file.Path;
@@ -13,7 +13,6 @@
import java.util.HashSet;
import java.util.Set;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.QualifiedName;
@@ -29,24 +28,12 @@
//removableFileStoreTypes.add("");
}
- public static boolean isVolumeRemovable(IResource r) throws CoreException {
- FileStore fs = getFileStore(r);
+ public static boolean isVolumeRemovable(URI uri) throws CoreException {
+ FileStore fs = getFileStore(uri);
String type = fs.type();
System.err.println("Is this a removable? type="+type);
return removableFileStoreTypes.contains(type);
}
-
- public static void recordVolumeFingerprint(IResource resource) throws CoreException {
- long fp = makeVolumeFingerprint(resource);
- System.err.println("recording fingerprint: "+fp);
- resource.setPersistentProperty(VOLUME_FINGERPRINT, String.valueOf(fp));
- }
-
- public static boolean isSameVolume(IResource resource) throws CoreException {
- long fp = makeVolumeFingerprint(resource);
- String prop = resource.getPersistentProperty(VOLUME_FINGERPRINT);
- return (String.valueOf(fp).equals(prop));
- }
/**
* Computes a fingerprint for the volume (FileStore) containing this resource based on the names and dates in the root directory.
@@ -59,10 +46,10 @@ public static boolean isSameVolume(IResource resource) throws CoreException {
* @param resource
* a resource
*/
- public static long makeVolumeFingerprint(IResource resource) throws CoreException {
- FileStore fstore = getFileStore(resource);
+ public static int makeVolumeFingerprint(URI uri) throws CoreException {
+ FileStore fstore = getFileStore(uri);
try {
- Path path = getPath(resource);
+ Path path = Paths.get(uri);
Path volumeRoot = findTopResourceInVolume(fstore, path);
System.err.println("Found volume root: " + volumeRoot);
long oldestFileCreation = -1;
@@ -84,22 +71,16 @@ public static long makeVolumeFingerprint(IResource resource) throws CoreExceptio
BasicFileAttributes basic = v.readAttributes();
System.err.println("Found volume root file key: "+basic.fileKey());
System.err.println("Found volume root create time: "+basic.creationTime());
- long result = name.hashCode() ^ basic.fileKey().hashCode() ^ basic.creationTime().toMillis() ^ oldestFileCreation;
+ int result = name.hashCode() ^ basic.fileKey().hashCode() ^ (int)basic.creationTime().toMillis() ^ (int)oldestFileCreation;
return result;
} else {
- return name.hashCode() ^ oldestFileCreation;
+ return name.hashCode() ^ (int)oldestFileCreation;
}
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "IO Exception while making unique volume key", e));
}
}
- private static Path getPath(IResource dirty) {
- Path result = null;
- result = Paths.get(dirty.getLocation().toOSString());
- return result;
- }
-
private static Path findTopResourceInVolume(FileStore fstore, Path path) throws IOException {
Path parent = path.getParent();
if (parent == null) {
@@ -114,12 +95,11 @@ private static Path findTopResourceInVolume(FileStore fstore, Path path) throws
}
}
- public static FileStore getFileStore(IResource resource) throws CoreException {
- Path path = getPath(resource);
+ public static FileStore getFileStore(URI uri) throws CoreException {
+ Path path = Paths.get(uri);
System.err.println(path.toUri());
try {
- FileSystem fs = FileSystems.getDefault();
- FileStore fstore = fs.provider().getFileStore(path);
+ FileStore fstore = path.getFileSystem().provider().getFileStore(path);
return fstore;
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unexpected I/O error", e));
View
106 workbench_plugin/src/main/java/unc/lib/cdr/workbench/project/MetsProjectNature.java
@@ -18,11 +18,14 @@
import gov.loc.mets.DivType;
import gov.loc.mets.DocumentRoot;
import gov.loc.mets.MetsType1;
-import gov.loc.mets.util.METSConstants;
-import gov.loc.mets.util.METSUtils;
import gov.loc.mods.mods.presentation.URIFragmentEditorInput;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.eclipse.core.filesystem.EFS;
@@ -39,7 +42,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.emf.common.command.CommandStack;
@@ -53,7 +55,9 @@
import org.slf4j.LoggerFactory;
import unc.lib.cdr.workbench.arrange.ArrangementProjectElement;
-import unc.lib.cdr.workbench.capture.OriginalFoldersProjectElement;
+import unc.lib.cdr.workbench.originals.Original;
+import unc.lib.cdr.workbench.originals.OriginalsWrapperFileSystem;
+import unc.lib.cdr.workbench.originals.OriginalsWrapperStore;
import unc.lib.cdr.workbench.rcp.Activator;
import unc.lib.cdr.workbench.stage.StagedFilesProjectElement;
@@ -66,17 +70,19 @@
public static final String NATURE_ID = "cdr_producer.projectNature";
public static final QualifiedName EMF_SESSION_KEY = new QualifiedName(NATURE_ID, "cdr_producer.projectEMFSession");
public static final QualifiedName EDITING_DOMAIN_KEY = new QualifiedName(NATURE_ID, "cdr_producer.editingDomain");
- //public static final QualifiedName INITIAL_AUTOSTAGE_KEY = new QualifiedName(NATURE_ID, "cdr_producer.init_autostage");
+ // public static final QualifiedName INITIAL_AUTOSTAGE_KEY = new QualifiedName(NATURE_ID,
+ // "cdr_producer.init_autostage");
public static final String STAGING_BUILDER_ID = "unc.lib.cdr.workbench.builders.StageBuilder";
public static final String CROSSWALKS_BUILDER_ID = "unc.lib.cdr.workbench.builders.CrosswalksBuilder";
private static final String STAGING_BASE_URI_KEY = "cdr_producer.stagingBaseURI";
+ private static final String ORIGINALS_KEY = "cdr_producer.originals";
private IProject project = null;
private ICustomProjectElement[] elements = null;
private ArrangementProjectElement arrangementElement = null;
- private OriginalFoldersProjectElement originalsElement = null;
private StagedFilesProjectElement stagedFilesElement = null;
+ private ArrayList<Original> originals = null;
public StagedFilesProjectElement getStagedFilesElement() {
if (stagedFilesElement == null) {
@@ -85,13 +91,6 @@ public StagedFilesProjectElement getStagedFilesElement() {
return stagedFilesElement;
}
- public OriginalFoldersProjectElement getOriginalsElement() {
- if (originalsElement == null) {
- this.originalsElement = new OriginalFoldersProjectElement(this);
- }
- return originalsElement;
- }
-
public ArrangementProjectElement getArrangementElement() {
if (this.arrangementElement == null) {
this.arrangementElement = new ArrangementProjectElement(this);
@@ -104,7 +103,7 @@ public MetsProjectNature() {
public ICustomProjectElement[] getProjectElements() {
if (this.elements == null) {
- this.elements = new ICustomProjectElement[] { getOriginalsElement(),
+ this.elements = new ICustomProjectElement[] {
/* getArrangementElement(), */getStagedFilesElement() };
}
return this.elements;
@@ -200,6 +199,51 @@ public void setProject(IProject project) {
log.error("Problem setting up EMF session", e);
}
}
+ this.loadOriginals();
+ }
+
+ private void loadOriginals() {
+ IEclipsePreferences projectNode = new ProjectScope(project).getNode(Activator.PLUGIN_ID);
+ byte[] s = projectNode.getByteArray(ORIGINALS_KEY, null);
+ if (s == null) {
+ this.originals = new ArrayList<Original>();
+ } else {
+ try {
+ ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(s));
+ this.originals = (ArrayList<Original>) in.readObject();
+ log.debug("loaded originals: "+this.originals.size());
+ } catch (Exception e) {
+ throw new Error("Cannot deserialize originals for project", e);
+ }
+ }
+ }
+
+ private void saveOriginals() {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ ObjectOutputStream out = new ObjectOutputStream(baos);
+ out.writeObject(this.originals);
+ } catch (Exception e) {
+ throw new Error("Cannot serialize project originals", e);
+ }
+ IEclipsePreferences projectNode = new ProjectScope(project).getNode(Activator.PLUGIN_ID);
+ projectNode.putByteArray(ORIGINALS_KEY, baos.toByteArray());
+ log.debug("wrote originals to preferences");
+ try {
+ projectNode.flush();
+ } catch (BackingStoreException e) {
+ throw new Error(e);
+ }
+ }
+
+ public void addOriginal(Original o) {
+ this.originals.add(o);
+ log.debug("adding original at: "+o.getBase().toString());
+ this.saveOriginals();
+ }
+
+ public List<Original> getOriginals() {
+ return Collections.unmodifiableList(this.originals);
}
public static IProject getProjectForMetsEObject(EObject object) {
@@ -246,9 +290,9 @@ public static EditingDomain getEditingDomain(EObject object) {
return result;
}
- public IFolder getOriginalsFolder() {
- return this.getProject().getFolder(ORIGINALS_FOLDER_NAME);
- }
+ //public IFolder getOriginalsFolder() {
+ //return this.getProject().getFolder(ORIGINALS_FOLDER_NAME);
+ //}
public static boolean getAutomaticStaging(IProject project) {
boolean result = false;
@@ -270,23 +314,13 @@ public static void setAutomaticStaging(boolean auto, IProject project) {
* @param div
* @return the IResource of the original
*/
- public static IResource getOriginal(DivType div) {
+ public static OriginalsWrapperStore getOriginal(DivType div) {
if (div.getCONTENTIDS().size() > 0) {
for (String contentid : div.getCONTENTIDS()) {
try {
java.net.URI originalLoc = new java.net.URI(contentid);
- IResource[] rs = null;
- if (METSUtils.isContainer(div)) {
- rs = ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(originalLoc);
- } else if (METSConstants.Div_File.equals(div.getTYPE())) {
- rs = ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(originalLoc);
- }
IProject project = MetsProjectNature.getProjectForMetsEObject(div);
- for (IResource r : rs) {
- if (project.equals(r.getProject())) {
- return r;
- }
- }
+ return (OriginalsWrapperStore)OriginalsWrapperFileSystem.wrapStore(originalLoc, project);
} catch (Exception ignored) {
}
}
@@ -311,13 +345,13 @@ public static MetsProjectNature get(IProject prog) {
* @param stageURI
*/
public static void setStagingBase(java.net.URI stageURI, IProject project) {
- IEclipsePreferences projectNode = new ProjectScope(project).getNode(Activator.PLUGIN_ID);
- projectNode.put(STAGING_BASE_URI_KEY, stageURI.toString());
- try {
- projectNode.flush();
- } catch (BackingStoreException e) {
- throw new Error(e);
- }
+ IEclipsePreferences projectNode = new ProjectScope(project).getNode(Activator.PLUGIN_ID);
+ projectNode.put(STAGING_BASE_URI_KEY, stageURI.toString());
+ try {
+ projectNode.flush();
+ } catch (BackingStoreException e) {
+ throw new Error(e);
+ }
}
public java.net.URI getStagingBase() {
View
23 workbench_plugin/src/main/java/unc/lib/cdr/workbench/project/ProjectEMFSession.java
@@ -15,10 +15,6 @@
*/
package unc.lib.cdr.workbench.project;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
import edu.unc.lib.schemas.acl.provider.AclItemProviderAdapterFactory;
import gov.loc.mets.DocumentRoot;
import gov.loc.mets.MetsPackage;
@@ -27,40 +23,43 @@
import gov.loc.mets.util.MetsResourceFactoryImpl;
import gov.loc.mods.mods.provider.MODSItemProviderAdapterFactory;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.command.CommandStack;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.Resource.Diagnostic;
+import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.BasicExtendedMetaData;
import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
-import org.eclipse.ui.ide.ResourceUtil;
+import org.eclipse.ui.IWorkbench;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3._1999.xlink.provider.XlinkItemProviderAdapterFactory;
-import unc.lib.cdr.workbench.IResourceConstants;
import unc.lib.cdr.workbench.rcp.Activator;
/**
@@ -113,6 +112,8 @@ private void load() {
IFile old = getOldMetsFile();
if (!f.toFile().exists() && old.exists()) {
try {
+
+ System.out.println("moving "+old.getLocation()+" to "+f);
old.move(f, true, new NullProgressMonitor());
} catch (CoreException e) {
throw new Error(e);
@@ -151,8 +152,8 @@ private void load() {
}
public IPath getMetsFile() {
- IPath working = this.project.getLocation();
- return working.append(METS_PATH);
+ ProjectScope scope = new ProjectScope(this.project);
+ return scope.getLocation().append(METS_PATH).makeRelativeTo(this.project.getLocation());
}
public IFile getOldMetsFile() {
View
27 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/HasOriginalFilter.java
@@ -0,0 +1,27 @@
+package unc.lib.cdr.workbench.views;
+
+import gov.loc.mets.DivType;
+
+import org.eclipse.jface.viewers.IFilter;
+
+import unc.lib.cdr.workbench.originals.Original;
+import unc.lib.cdr.workbench.originals.OriginalsWrapperStore;
+import unc.lib.cdr.workbench.project.MetsProjectNature;
+
+public class HasOriginalFilter implements IFilter {
+
+ @Override
+ public boolean select(Object toTest) {
+ if(toTest instanceof OriginalsWrapperStore) {
+ return true;
+ } else if (toTest instanceof DivType) {
+ DivType d = (DivType) toTest;
+ OriginalsWrapperStore s = MetsProjectNature.getOriginal(d);
+ return s != null;
+ } else if(toTest instanceof Original) {
+ return true;
+ }
+ return false;
+ }
+
+}
View
27 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/HasStagedFileFilter.java
@@ -0,0 +1,27 @@
+package unc.lib.cdr.workbench.views;
+
+import gov.loc.mets.DivType;
+
+import org.eclipse.jface.viewers.IFilter;
+
+import unc.lib.cdr.workbench.originals.Original;
+import unc.lib.cdr.workbench.originals.OriginalsWrapperStore;
+import unc.lib.cdr.workbench.project.MetsProjectNature;
+
+public class HasStagedFileFilter implements IFilter {
+
+ @Override
+ public boolean select(Object toTest) {
+ OriginalsWrapperStore original = null;
+ if(toTest instanceof OriginalsWrapperStore) {
+ original = (OriginalsWrapperStore)toTest;
+ } else if (toTest instanceof DivType) {
+ DivType d = (DivType) toTest;
+ original = MetsProjectNature.getOriginal(d);
+ } else if(toTest instanceof Original) {
+ original = ((Original)toTest).getStore();
+ }
+ return original.getStagingLocatorType() != null;
+ }
+
+}
View
79 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/LabelImageFactory.java
@@ -27,60 +27,62 @@
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.Display;
import unc.lib.cdr.workbench.arrange.ArrangementProjectElement;
import unc.lib.cdr.workbench.arrange.DivLinkBucket;
-import unc.lib.cdr.workbench.capture.OriginalFoldersProjectElement;
+import unc.lib.cdr.workbench.originals.Original;
import unc.lib.cdr.workbench.project.ICustomProjectElement;
import unc.lib.cdr.workbench.rcp.Activator;
import unc.lib.cdr.workbench.stage.StagedFilesProjectElement;
/**
* @author Gregory Jansen
- *
+ *
*/
public class LabelImageFactory {
public static String iconPath = "icons/";
private static final int DEFAULT_ICON_SIZE = 24;
+
public static enum Size {
- ORIGINAL(0,0),
- DEFAULT_ICON(DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
+ ORIGINAL(0, 0), DEFAULT_ICON(DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
int width;
int height;
+
Size(int width, int height) {
this.width = width;
this.height = height;
}
}
+
public static enum Icon {
- OpenProject("24px-Crystal_Clear_app_ark.png", Size.DEFAULT_ICON),
- ClosedProject("24px-Crystal_Clear_app_kthememgr.png", Size.DEFAULT_ICON),
- HardDisk("24px-Crystal_Clear_app_harddrive.png", Size.DEFAULT_ICON),
- Folder("24px-Crystal_Clear_filesystem_folder_grey.png", Size.DEFAULT_ICON),
- File("24px-Crystal_Clear_action_filenew.png", Size.DEFAULT_ICON),
- Collection("24px-Crystal_Clear_app_file-manager.png", Size.DEFAULT_ICON),
- AggregateWork("24px-Crystal_Clear_filesystem_folder_txt.png", Size.DEFAULT_ICON),
- ArrangementEl("edtsrclkup_co.gif", Size.ORIGINAL),
- CrosswalkEl("filter_tsk.gif", Size.ORIGINAL),
- OriginalsEl("access_restriction_attrib.gif", Size.ORIGINAL),
- StageEl("var_cntnt_prvdr.gif", Size.ORIGINAL),
- CaptureDecor("waiting_ovr.gif", Size.ORIGINAL),
- StagedDecor("version_controlled.gif", Size.ORIGINAL),
- UserEditedDecor("write_obj.gif", Size.ORIGINAL),
- CrosswalkedDecor("crosswalk_decor.gif", Size.ORIGINAL),
- ACLDecor("key_sm.gif", Size.ORIGINAL),
- CrosswalkedRecord("property_obj.gif", Size.ORIGINAL),
- LinkedObject("link_obj.gif", Size.ORIGINAL);
+ OpenProject("24px-Crystal_Clear_app_ark.png", Size.DEFAULT_ICON), ClosedProject(
+ "24px-Crystal_Clear_app_kthememgr.png", Size.DEFAULT_ICON), HardDisk(
+ "24px-Crystal_Clear_app_harddrive.png", Size.DEFAULT_ICON), Folder(
+ "24px-Crystal_Clear_filesystem_folder_grey.png", Size.DEFAULT_ICON), File(
+ "24px-Crystal_Clear_action_filenew.png", Size.DEFAULT_ICON), Collection(
+ "24px-Crystal_Clear_app_file-manager.png", Size.DEFAULT_ICON), AggregateWork(
+ "24px-Crystal_Clear_filesystem_folder_txt.png", Size.DEFAULT_ICON), ArrangementEl("edtsrclkup_co.gif",
+ Size.ORIGINAL), CrosswalkEl("filter_tsk.gif", Size.ORIGINAL), OriginalsEl("access_restriction_attrib.gif",
+ Size.ORIGINAL), StageEl("var_cntnt_prvdr.gif", Size.ORIGINAL), CaptureDecor("waiting_ovr.gif",
+ Size.ORIGINAL), StagedDecor("version_controlled.gif", Size.ORIGINAL), UserEditedDecor("write_obj.gif",
+ Size.ORIGINAL), CrosswalkedDecor("crosswalk_decor.gif", Size.ORIGINAL), ACLDecor("key_sm.gif",
+ Size.ORIGINAL), CrosswalkedRecord("property_obj.gif", Size.ORIGINAL), LinkedObject("link_obj.gif",
+ Size.ORIGINAL);
Size size = Size.ORIGINAL;
String imageFile = null;
+
Icon(String imageFile, Size size) {
this.imageFile = imageFile;
this.size = size;
}
+
public Image getImage() {
return LabelImageFactory.getImage(this);
}
+
public ImageDescriptor getImageDescriptor() {
return LabelImageFactory.getImageDescriptor(this);
}
@@ -99,19 +101,19 @@ public static Icon getIconForObject(Object o) {
} else if (o instanceof ICustomProjectElement) {
if (o instanceof ArrangementProjectElement) {
result = Icon.ArrangementEl;
- } else if (o instanceof OriginalFoldersProjectElement) {
- result = Icon.OriginalsEl;
} else if (o instanceof StagedFilesProjectElement) {
result = Icon.StageEl;
}
} else if (o instanceof DivLinkBucket) {
result = Icon.LinkedObject;
} else if (IFileStore.class.isInstance(o)) {
- if(((IFileStore)o).fetchInfo().isDirectory()) {
+ if (((IFileStore) o).fetchInfo().isDirectory()) {
result = Icon.Folder;
} else {
result = Icon.File;
}
+ } else if (Original.class.isInstance(o)) {
+ result = Icon.OriginalsEl;
}
return result;
}
@@ -123,7 +125,7 @@ public static ImageDescriptor getImageDescriptorForObject(Object o) {
public static ImageDescriptor getImageDescriptor(Icon i) {
ImageDescriptor result = registry.getDescriptor(i.name());
- if(result == null) {
+ if (result == null) {
register(i);
result = registry.getDescriptor(i.name());
}
@@ -132,7 +134,7 @@ public static ImageDescriptor getImageDescriptor(Icon i) {
public static Image getImage(Icon i) {
Image result = registry.get(i.name());
- if(result == null) {
+ if (result == null) {
register(i);
result = registry.get(i.name());
}
@@ -141,6 +143,7 @@ public static Image getImage(Icon i) {
/**
* Registers the given icon.
+ *
* @param i
*/
private static void register(Icon i) {
@@ -149,7 +152,7 @@ private static void register(Icon i) {
d = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, iconPath + i.imageFile);
if (d != null) {
result = d.createImage();
- if(i.size != Size.ORIGINAL) {
+ if (i.size != Size.ORIGINAL) {
result = new Image(Display.getDefault(), result.getImageData().scaledTo(i.size.width, i.size.height));
}
registry.put(i.name(), result);
@@ -204,4 +207,24 @@ private static Icon getIconForResource(IResource o) {
}
return result;
}
+
+ /**
+ * @param o
+ * @return
+ */
+ public static Image getImageForExtension(String ext) {
+ Image image = registry.get(ext);
+ if (image != null)
+ return image;
+
+ Program program = Program.findProgram(ext);
+ ImageData imageData = (program == null ? null : program.getImageData());
+ if (imageData != null) {
+ image = new Image(Display.getCurrent(), imageData);
+ registry.put(ext, image);
+ } else {
+ image = getImage(Icon.File);
+ }
+ return image;
+ }
}
View
25 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/OriginalFingerprintSection.java
@@ -22,6 +22,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import unc.lib.cdr.workbench.originals.OriginalsWrapperStore;
import unc.lib.cdr.workbench.project.MetsProjectNature;
public class OriginalFingerprintSection extends AbstractPropertySection {
@@ -29,7 +30,7 @@
@SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(OriginalFingerprintSection.class);
- private DivType div = null;
+ private FileType fileType = null;
Text checksumText = null;
Text checksumTypeText = null;
Text stagedLocationText = null;
@@ -42,9 +43,14 @@
public void setInput(IWorkbenchPart part, ISelection s) {
super.setInput(part, s);
Assert.isTrue(s instanceof IStructuredSelection);
- Object divO = ((IStructuredSelection) s).getFirstElement();
- Assert.isTrue(divO instanceof DivType);
- this.div = (DivType) divO;
+ Object o = ((IStructuredSelection) s).getFirstElement();
+ if(o instanceof DivType) {
+ DivType div = (DivType)o;
+ fileType = (FileType)div.eResource().getEObject(div.getFptr().get(0).getFILEID());
+ } else if(o instanceof OriginalsWrapperStore) {
+ fileType = ((OriginalsWrapperStore)o).getMetsFileType();
+ }
+ Assert.isTrue(fileType != null);
}
@Override
@@ -91,18 +97,15 @@ public void createControls(Composite parent, TabbedPropertySheetPage aTabbedProp
@Override
public void refresh() {
- // LOG.debug("div: "+div);
- MetsType mets = MetsProjectNature.getNatureForMetsObject(div).getMets();
- FileType file = (FileType)mets.eResource().getEObject(div.getFptr().get(0).getFILEID());
- if (file.getCHECKSUM() != null) {
- checksumText.setText(file.getCHECKSUM());
- checksumTypeText.setText(file.getCHECKSUMTYPE().getName());
+ if (fileType.getCHECKSUM() != null) {
+ checksumText.setText(fileType.getCHECKSUM());
+ checksumTypeText.setText(fileType.getCHECKSUMTYPE().getName());
} else {
checksumText.setText("unknown");
checksumTypeText.setText("n/a");
}
FLocatType l = null;
- for(FLocatType test : file.getFLocat()) {
+ for(FLocatType test : fileType.getFLocat()) {
if(METSConstants.FLocat_USE_STAGE.equals(test.getUSE())) {
l = test;
}
View
14 ...lugin/src/main/java/unc/lib/cdr/workbench/views/OriginalResourcePropertySheetSection.java
@@ -6,7 +6,6 @@
import java.util.Iterator;
import java.util.List;
-import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.events.ControlAdapter;
@@ -23,6 +22,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import unc.lib.cdr.workbench.originals.Original;
+import unc.lib.cdr.workbench.originals.OriginalsWrapperStore;
import unc.lib.cdr.workbench.project.MetsProjectNature;
public class OriginalResourcePropertySheetSection extends AbstractPropertySection {
@@ -75,15 +76,18 @@ public void controlResized(ControlEvent e) {
public void setInput(IWorkbenchPart part, ISelection selection) {
// LOG.debug("setInput called: " + selection + selection.getClass());
ISelection pageSelect = null;
- IResource original = null;
+ OriginalsWrapperStore original = null;
IStructuredSelection s = (IStructuredSelection) selection;
if (s.getFirstElement() instanceof DivType) {
DivType d = (DivType) s.getFirstElement();
original = MetsProjectNature.getOriginal(d);
- pageSelect = new ListSelection(Collections.singletonList(original));
- page.selectionChanged(part, pageSelect);
+ } else if(s.getFirstElement() instanceof Original) {
+ original = ((Original)s.getFirstElement()).getStore();
+ } else if(s.getFirstElement() instanceof OriginalsWrapperStore) {
+ original = (OriginalsWrapperStore)s.getFirstElement();
}
- // LOG.debug("get original: " + original);
+ pageSelect = new ListSelection(Collections.singletonList(original));
+ page.selectionChanged(part, pageSelect);
}
/**
View
165 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/OriginalVolumeSection.java
@@ -0,0 +1,165 @@
+package unc.lib.cdr.workbench.views;
+
+import java.io.IOException;
+import java.nio.file.FileStore;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.text.NumberFormat;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import unc.lib.cdr.workbench.originals.Original;
+import unc.lib.cdr.workbench.originals.OriginalsWrapperStore;
+import unc.lib.cdr.workbench.originals.VolumeUtil;
+
+public class OriginalVolumeSection extends AbstractPropertySection {
+
+ @SuppressWarnings("unused")
+ private static final Logger LOG = LoggerFactory.getLogger(OriginalVolumeSection.class);
+
+ private OriginalsWrapperStore original = null;
+
+ Text nameText = null;
+ Text typeText = null;
+ Text usedSpaceText = null;
+ Text hashText = null;
+ Group composite = null;
+
+ public OriginalVolumeSection() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @see org.eclipse.ui.views.properties.tabbed.ISection#setInput(org.eclipse.ui.IWorkbenchPart,
+ * org.eclipse.jface.viewers.ISelection)
+ */
+ @Override
+ public void setInput(IWorkbenchPart part, ISelection s) {
+ super.setInput(part, s);
+ Assert.isTrue(s instanceof IStructuredSelection);
+ Object fs = ((IStructuredSelection) s).getFirstElement();
+ if(fs instanceof OriginalsWrapperStore) {
+ this.original = (OriginalsWrapperStore) fs;
+ } else if(fs instanceof Original) {
+ this.original = ((Original)fs).getStore();
+ }
+ }
+
+ @Override
+ public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ super.createControls(parent, aTabbedPropertySheetPage);
+ Composite outer = getWidgetFactory().createFlatFormComposite(parent);
+ outer.setLayout(new GridLayout());
+ composite = getWidgetFactory().createGroup(outer, "Volume Information");
+ composite.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false));
+ FormLayout layout = new FormLayout();
+ composite.setLayout(layout);
+
+ FormData data;
+
+ int secondTab = 50;
+
+ CLabel l1 = getWidgetFactory().createCLabel(composite, "Name");
+ data = new FormData();
+ data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE);
+ data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
+ l1.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(secondTab, ITabbedPropertyConstants.HSPACE);
+ data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
+ nameText = getWidgetFactory().createText(composite, "", SWT.READ_ONLY);
+ nameText.setLayoutData(data);
+
+ CLabel l2 = getWidgetFactory().createCLabel(composite, "Type");
+ data = new FormData();
+ data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE);
+ data.top = new FormAttachment(l1, ITabbedPropertyConstants.VSPACE);
+ l2.setLayoutData(data);
+
+ typeText = getWidgetFactory().createText(composite, "", SWT.READ_ONLY);
+ data = new FormData();
+ data.left = new FormAttachment(secondTab, ITabbedPropertyConstants.HSPACE);
+ data.top = new FormAttachment(l1, ITabbedPropertyConstants.VSPACE);
+ typeText.setLayoutData(data);
+
+ CLabel sl = getWidgetFactory().createCLabel(composite, "Used Space");
+ data = new FormData();
+ data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE);
+ data.top = new FormAttachment(l2, ITabbedPropertyConstants.VSPACE);
+ sl.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(secondTab, ITabbedPropertyConstants.HSPACE);
+ data.top = new FormAttachment(l2, ITabbedPropertyConstants.VSPACE);
+ usedSpaceText = getWidgetFactory().createText(composite, "", SWT.READ_ONLY);
+ usedSpaceText.setLayoutData(data);
+
+ CLabel hl = getWidgetFactory().createCLabel(composite, "Hash Key");
+ data = new FormData();
+ data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE);
+ data.top = new FormAttachment(sl, ITabbedPropertyConstants.VSPACE);
+ hl.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(secondTab, ITabbedPropertyConstants.HSPACE);
+ data.top = new FormAttachment(sl, ITabbedPropertyConstants.VSPACE);
+ hashText = getWidgetFactory().createText(composite, "", SWT.READ_ONLY);
+ hashText.setLayoutData(data);
+
+ nameText.pack();
+ typeText.pack();
+ usedSpaceText.pack();
+ hashText.pack();
+ }
+
+ @Override
+ public void refresh() {
+ try {
+ FileStore fs = Files.getFileStore(Paths.get(this.original.getWrapped().toURI()));
+ nameText.setText(fs.name());
+ typeText.setText(fs.type());
+ NumberFormat f = NumberFormat.getInstance();
+ usedSpaceText.setText( f.format( (fs.getTotalSpace() - fs.getUnallocatedSpace())/1024 )+ " kilobytes" );
+ try {
+ hashText.setText(String.valueOf(VolumeUtil.makeVolumeFingerprint(this.original.getWrapped().toURI())));
+ } catch(CoreException e) {
+ e.printStackTrace();
+ }
+ nameText.pack();
+ typeText.pack();
+ usedSpaceText.pack();
+ hashText.pack();
+ composite.pack();
+ } catch(IOException e) {
+ throw new Error(e);
+ }
+ }
+
+ /**
+ * @see org.eclipse.ui.views.properties.tabbed.ISection#shouldUseExtraSpace()
+ */
+ @Override
+ public boolean shouldUseExtraSpace() {
+ return false;
+ }
+}
View
15 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/PropertySheetPropertySection.java
@@ -72,21 +72,6 @@ public void controlResized(ControlEvent e) {
public void setInput(IWorkbenchPart part, ISelection selection) {
LOG.debug("setInput called: " + selection + selection.getClass());
IStructuredSelection s = (IStructuredSelection) selection;
- // if (s.getFirstElement() instanceof DivType) {
- // DivType d = (DivType) s.getFirstElement();
- // MdSecType userModsSection = null;
- // if (d.getDMDID() != null) {
- // for (String id : d.getDMDID()) {
- // MdSecType md = (MdSecType) d.eResource().getEObject(id);
- // if (METSConstants.MD_STATUS_USER_EDITED.equals(md.getSTATUS())) {
- // userModsSection = md;
- // break;
- // }
- // }
- // s = new StructuredSelection(userModsSection.getMdWrap().getXmlData().getAny().toArray()[0]);
- // LOG.debug("overriding selection to : "+s);
- // }
- // }
super.setInput(part, s);
page.selectionChanged(part, s);
}

0 comments on commit a933f64

Please sign in to comment.
Something went wrong with that request. Please try again.