Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/LoadScriptPage.java')
-rw-r--r--plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/LoadScriptPage.java230
1 files changed, 116 insertions, 114 deletions
diff --git a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/LoadScriptPage.java b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/LoadScriptPage.java
index cb7c0ebd974..272954fe84a 100644
--- a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/LoadScriptPage.java
+++ b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/LoadScriptPage.java
@@ -38,119 +38,121 @@ import org.xml.sax.SAXException;
public class LoadScriptPage implements ILoadConfig, ScriptPageConstants {
- private final ScriptPage scriptPage;
- private final ScriptTableViewer scriptTableViewer;
- private final Vector<ScriptTask> scriptTasks;
-
- public LoadScriptPage(ScriptPage tmPage) {
- this.scriptPage = tmPage;
- this.scriptTableViewer = scriptPage.getScriptTableViewer();
- scriptTasks = new Vector<ScriptTask>();
- }
-
- public void loadConfiguration(final File toProcess) throws Exception {
-
- Job job = new Job(String.format("Loading Script Run List [%s]", toProcess.getName())) {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- Document doc;
- try {
- doc = Jaxp.readXmlDocument(toProcess);
- parseConfig(doc);
-
- Displays.pendInDisplayThread(new Runnable() {
- @Override
- public void run() {
- scriptTableViewer.loadTasksFromList(scriptTasks);
- scriptTableViewer.refresh();
- debug(toProcess.getAbsolutePath());
- }
- });
- } catch (ParserConfigurationException ex) {
- OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
- } catch (SAXException ex) {
- OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
- } catch (IOException ex) {
- OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
- }
-
- return Status.OK_STATUS;
- }
-
- };
- job.schedule();
- }
-
- private void debug(String val) {
- OseeLog.log(TestManagerPlugin.class, Level.INFO, "Loaded From: " + val);
- }
-
- private void parseConfig(Document doc) {
- NodeList nl = doc.getElementsByTagName(ScriptPageConstants.SCRIPTPAGE_CONFIG);
-
- for (int i = 0; i < nl.getLength(); i++) {
- Element element = (Element) nl.item(i);
- parseMiscellaneousInfo(element);
- parseScriptEntries(element);
- }
- }
-
- private void parseMiscellaneousInfo(Element element) {
- // Iterator iterator = node.getDescendants(new RegExElementFilter(
- // Pattern.compile(ScriptPageConstants.SERVICES_ENTRY)));
- // while (iterator.hasNext()) {
- // Element child = (Element) iterator.next();
- // TODO load miscellaneous information to page
- // }
- }
-
- private class LoadScriptHelper implements Runnable {
- private boolean stopLoading = false;
- private final String path;
-
- public LoadScriptHelper(String path) {
- this.path = path;
- }
-
- public void run() {
- if (!MessageDialog.openQuestion(
- Displays.getActiveShell(),
- "Script not found",
- "The script " + path + " was not found in this workspace. Do you want to continue loading from the script list file. ")) {
- stopLoading = true;
- }
- }
-
- public boolean stop() {
- return stopLoading;
- }
- }
-
- private void parseScriptEntries(Element element) {
- NodeList nl = element.getElementsByTagName(ScriptPageConstants.SCRIPT_ENTRY);
- String alternatePath = scriptPage.getTestManager().getAlternateOutputDir();
- for (int i = 0; i < nl.getLength(); i++) {
- Element child = (Element) nl.item(i);
- final String path = Jaxp.getChildText(child, ScriptPageConstants.RAW_FILENAME_FIELD);
- String runnable = Jaxp.getChildText(child, ScriptPageConstants.RUNNABLE_FIELD);
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path));
- if (file.exists()) {
- try {
- ScriptTask task = new ScriptTask(file.getLocation().toString(), alternatePath);
- task.setRun(Boolean.parseBoolean(runnable));
- scriptTasks.add(task);
- } catch (NullPointerException e) {
- e.printStackTrace();
- }
- } else {
- LoadScriptHelper helper = new LoadScriptHelper(path);
- Displays.pendInDisplayThread(helper);
- if (helper.stop()) {
- break;
- }
- }
- }
- }
+ private final ScriptPage scriptPage;
+ private final ScriptTableViewer scriptTableViewer;
+ private final Vector<ScriptTask> scriptTasks;
+
+ public LoadScriptPage(ScriptPage tmPage) {
+ this.scriptPage = tmPage;
+ this.scriptTableViewer = scriptPage.getScriptTableViewer();
+ scriptTasks = new Vector<ScriptTask>();
+ }
+
+ @Override
+ public void loadConfiguration(final File toProcess) throws Exception {
+
+ Job job = new Job(String.format("Loading Script Run List [%s]", toProcess.getName())) {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ Document doc;
+ try {
+ doc = Jaxp.readXmlDocument(toProcess);
+ parseConfig(doc);
+
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ scriptTableViewer.loadTasksFromList(scriptTasks);
+ scriptTableViewer.refresh();
+ debug(toProcess.getAbsolutePath());
+ }
+ });
+ } catch (ParserConfigurationException ex) {
+ OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
+ } catch (SAXException ex) {
+ OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
+ } catch (IOException ex) {
+ OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ };
+ job.schedule();
+ }
+
+ private void debug(String val) {
+ OseeLog.log(TestManagerPlugin.class, Level.INFO, "Loaded From: " + val);
+ }
+
+ private void parseConfig(Document doc) {
+ NodeList nl = doc.getElementsByTagName(ScriptPageConstants.SCRIPTPAGE_CONFIG);
+
+ for (int i = 0; i < nl.getLength(); i++) {
+ Element element = (Element) nl.item(i);
+ parseMiscellaneousInfo(element);
+ parseScriptEntries(element);
+ }
+ }
+
+ private void parseMiscellaneousInfo(Element element) {
+ // Iterator iterator = node.getDescendants(new RegExElementFilter(
+ // Pattern.compile(ScriptPageConstants.SERVICES_ENTRY)));
+ // while (iterator.hasNext()) {
+ // Element child = (Element) iterator.next();
+ // TODO load miscellaneous information to page
+ // }
+ }
+
+ private class LoadScriptHelper implements Runnable {
+ private boolean stopLoading = false;
+ private final String path;
+
+ public LoadScriptHelper(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public void run() {
+ if (!MessageDialog.openQuestion(
+ Displays.getActiveShell(),
+ "Script not found",
+ "The script " + path + " was not found in this workspace. Do you want to continue loading from the script list file. ")) {
+ stopLoading = true;
+ }
+ }
+
+ public boolean stop() {
+ return stopLoading;
+ }
+ }
+
+ private void parseScriptEntries(Element element) {
+ NodeList nl = element.getElementsByTagName(ScriptPageConstants.SCRIPT_ENTRY);
+ String alternatePath = scriptPage.getTestManager().getAlternateOutputDir();
+ for (int i = 0; i < nl.getLength(); i++) {
+ Element child = (Element) nl.item(i);
+ final String path = Jaxp.getChildText(child, ScriptPageConstants.RAW_FILENAME_FIELD);
+ String runnable = Jaxp.getChildText(child, ScriptPageConstants.RUNNABLE_FIELD);
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path));
+ if (file.exists()) {
+ try {
+ ScriptTask task = new ScriptTask(file.getLocation().toString(), alternatePath);
+ task.setRun(Boolean.parseBoolean(runnable));
+ scriptTasks.add(task);
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ }
+ } else {
+ LoadScriptHelper helper = new LoadScriptHelper(path);
+ Displays.pendInDisplayThread(helper);
+ if (helper.stop()) {
+ break;
+ }
+ }
+ }
+ }
}

Back to the top