move countFilesSelected() up from RunAnalyseHandlerBase to RunAnalyseHandler
diff --git a/tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/actions/RunAnalyseHandler.java b/tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/actions/RunAnalyseHandler.java
index 3426ddd..eebec0e 100644
--- a/tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/actions/RunAnalyseHandler.java
+++ b/tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/actions/RunAnalyseHandler.java
@@ -11,8 +11,15 @@
package org.eclipse.ptp.pldt.common.actions;
+import java.util.Iterator;
+
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -74,4 +81,56 @@
}
+ /**
+ * Counts the number of files in the selection (leaf nodes only - Files -
+ * not the directories/containers) <br>
+ * Note that this makes no distinction about what type of files.
+ *
+ * @return number of files
+ */
+ @SuppressWarnings("unchecked")
+ protected int countFilesSelected() {
+ int count = 0;
+ // Get elements of a possible multiple selection
+ Iterator iter = this.selection.iterator();
+ while (iter.hasNext()) {
+ Object obj = (Object) iter.next();
+ // It can be a Project, Folder, File, etc...
+ if (obj instanceof IAdaptable) {
+ final IResource res = (IResource) ((IAdaptable) obj)
+ .getAdapter(IResource.class);
+ count = count + countFiles(res);
+ }
+ }
+ // System.out.println("number of files: " + count);
+ return count;
+ }
+
+ /**
+ * Count the number of files in this resource (file or container).
+ *
+ * @param res
+ * @return
+ */
+ protected int countFiles(IResource res) {
+ if (res instanceof IFile) {
+ return 1;
+ } else if (res instanceof IContainer) {
+ int count = 0;
+
+ try {
+ IResource[] kids = ((IContainer) res).members();
+ for (int i = 0; i < kids.length; i++) {
+ IResource child = kids[i];
+ count = count + countFiles(child);
+ }
+ return count;
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return 0;
+ }
+
}
\ No newline at end of file
diff --git a/tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/actions/RunAnalyseHandlerBase.java b/tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/actions/RunAnalyseHandlerBase.java
index ccf69d7..3460856 100644
--- a/tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/actions/RunAnalyseHandlerBase.java
+++ b/tools/pldt/org.eclipse.ptp.pldt.common/src/org/eclipse/ptp/pldt/common/actions/RunAnalyseHandlerBase.java
@@ -21,7 +21,6 @@
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -282,58 +281,6 @@
return foundError;
}
- /**
- * Counts the number of files in the selection (leaf nodes only - Files -
- * not the directories/containers) <br>
- * Note that this makes no distinction about what type of files.
- *
- * @return number of files
- */
- @SuppressWarnings("unchecked")
- protected int countFilesSelected() {
- int count = 0;
- // Get elements of a possible multiple selection
- Iterator iter = this.selection.iterator();
- while (iter.hasNext()) {
- Object obj = (Object) iter.next();
- // It can be a Project, Folder, File, etc...
- if (obj instanceof IAdaptable) {
- final IResource res = (IResource) ((IAdaptable) obj)
- .getAdapter(IResource.class);
- count = count + countFiles(res);
- }
- }
- // System.out.println("number of files: " + count);
- return count;
- }
-
- /**
- * Count the number of files in this resource (file or container).
- *
- * @param res
- * @return
- */
- protected int countFiles(IResource res) {
- if (res instanceof IFile) {
- return 1;
- } else if (res instanceof IContainer) {
- int count = 0;
-
- try {
- IResource[] kids = ((IContainer) res).members();
- for (int i = 0; i < kids.length; i++) {
- IResource child = kids[i];
- count = count + countFiles(child);
- }
- return count;
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- return 0;
- }
-
abstract protected void activateArtifactView();
/**