Permalink
Browse files

added warning if you try to export before all files are staged.

removed some unused old code
removed some system.out statements
  • Loading branch information...
1 parent b86bf60 commit 806b33809a10a2284d4bbc81f969d3f2d3adb947 @gregjan gregjan committed Apr 23, 2012
@@ -52,7 +52,7 @@ public URIFragmentEditorInput(String projectName, String fragmentID, String name
this.fragmentID = fragmentID;
this.name = name;
- System.out.println("constructed from parts: " + toString());
+ //System.out.println("constructed from parts: " + toString());
}
@Override
@@ -173,9 +173,6 @@ private void createInheritContent(Composite parent, FormToolkit toolkit) {
s1.setLayoutData(gd);
inheritFlag = toolkit.createButton(s1, "Yes, groups may retain roles granted above this level.", SWT.CHECK); //$NON-NLS-1$
- for(IItemPropertyDescriptor d : acleditor.itemDelegator.getPropertyDescriptors(model)) {
- System.out.println(d);
- }
inheritFlag.setSelection(model.isInherit());
inheritFlag.addSelectionListener(new SelectionAdapter() {
@Override
@@ -18,6 +18,7 @@
import java.io.File;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
@@ -35,6 +36,8 @@
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Widget;
+import unc.lib.cdr.workbench.stage.StagingUtils;
+
/**
* @author Gregory Jansen
*
@@ -245,6 +248,16 @@ private void updatePageCompletion() {
this.setPageComplete(false);
return;
}
+ try {
+ int unstaged = StagingUtils.countUnstaged(project);
+ if(unstaged > 0) {
+ this.setErrorMessage("There are still "+unstaged+" files queued for staging. All captured files must be staged prior to export.");
+ this.setPageComplete(false);
+ return;
+ }
+ } catch(CoreException e) {
+ e.printStackTrace();
+ }
if(getDestinationValue() == null || "".equals(getDestinationValue().trim())) {
this.setErrorMessage("You must select a file location for the export.");
this.setPageComplete(false);
@@ -1,70 +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.stage;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarkerDelta;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author Gregory Jansen
- *
- */
-public class StageBuildDeltaVisitor implements IResourceDeltaVisitor {
- private static final Logger log = LoggerFactory.getLogger(StageBuildDeltaVisitor.class);
- IProgressMonitor monitor = null;
-
- public StageBuildDeltaVisitor(IProgressMonitor monitor) {
- log.debug("created");
- this.monitor = monitor;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core .resources.IResourceDelta)
- */
- @Override
- public boolean visit(IResourceDelta delta) throws CoreException {
- if (this.monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- IResource r = delta.getResource();
- if (r instanceof IContainer) {
- return true;
- } else if (r instanceof IFile) {
- IMarkerDelta[] md = delta.getMarkerDeltas();
- for (IMarkerDelta d : md) {
- // TODO implement staging and audit code for delta..
- // if (IResourceConstants.MARKER_TO_STAGE.equals(d.getType())) {
- // if (IResourceDelta.REMOVED != d.getKind()) {
- // StagingUtils.stage((IFile) r, new SubProgressMonitor(monitor, 1));
- // }
- // }
- }
- }
- return false;
- }
-
-}
@@ -1,74 +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.stage;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import unc.lib.cdr.workbench.IResourceConstants;
-
-/**
- * @author Gregory Jansen
- *
- */
-public class StageBuildVisitor implements IResourceVisitor {
- private static final Logger log = LoggerFactory.getLogger(StageBuildVisitor.class);
- IProgressMonitor monitor = null;
- boolean audit = false;
-
- public StageBuildVisitor(boolean audit, IProgressMonitor monitor) {
- log.debug("created");
- this.monitor = monitor;
- this.audit = audit;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.resources.IResourceVisitor#visit(org.eclipse.core.resources .IResource)
- */
- @Override
- public boolean visit(IResource r) throws CoreException {
- if (this.monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- if (r instanceof IContainer) {
- return true;
- } else if (r instanceof IFile) {
- // is it already staged?
- IMarker[] captured = r.findMarkers(IResourceConstants.MARKER_CAPTURED, false, IResource.DEPTH_ZERO);
- IMarker[] staged = r.findMarkers(IResourceConstants.MARKER_STAGED, false, IResource.DEPTH_ZERO);
- if (captured.length > 0) {
- if (staged.length == 0) {
- StagingUtils.stage((IFile) r, new SubProgressMonitor(monitor, 1));
- } else {
- StagingUtils.audit((IFile) r, new SubProgressMonitor(monitor, 1));
- }
- }
- }
- return false;
- }
-
-}
@@ -31,13 +31,16 @@
import java.net.URISyntaxException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.commons.codec.binary.Hex;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IFile;
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;
@@ -63,6 +66,23 @@
private static final Logger log = LoggerFactory.getLogger(StagingUtils.class);
private static final int chunkSize = 8192;
+
+ public static int countUnstaged(IProject project) throws CoreException {
+ int result = 0;
+ IMarker[] captured = project.findMarkers(IResourceConstants.MARKER_CAPTURED, false, IResource.DEPTH_INFINITE);
+ List<IFile> toStage = new ArrayList<IFile>();
+ for (IMarker m : captured) {
+ if (m.getResource() instanceof IFile) {
+ IMarker[] staged = m.getResource().findMarkers(IResourceConstants.MARKER_STAGED, false,
+ IResource.DEPTH_ZERO);
+ if (staged.length <= 0) {
+ result++;
+ }
+ }
+ }
+ return result;
+ }
+
/**
* @param r
*/

0 comments on commit 806b338

Please sign in to comment.