Skip to content

Commit

Permalink
EXM-44893 Pass through the actions manager.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexJitianu committed Feb 25, 2020
1 parent 87ea279 commit 309338b
Show file tree
Hide file tree
Showing 3 changed files with 336 additions and 326 deletions.
76 changes: 43 additions & 33 deletions src/main/java/com/oxygenxml/xspec/XSpecResultPresenter.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
package com.oxygenxml.xspec;

import java.net.URL;

/**
* Presents the HTML resulted from executing an XSpec scenario.
*
* @author alex_jitianu
*/
public interface XSpecResultPresenter {
/**
* If it already presents the results of an XSpec execution
* then it will return the URL of the executed XSpec.
*
* @return The XSpec that was executed and its results are currently presented.
*/
URL getXspec();

/**
* Loads the results from executing an XSpec file.
*
* @param resultHTML The result.
*/
void loadContent(String resultHTML);

/**
* Loads the results from executing an XSpec file.
*
* @param xspec The executed XSpec.
* @param results The results in a HTML format.
*/
public void load(URL xspecURL, URL resultHTML);
}
package com.oxygenxml.xspec;

import java.net.URL;

import com.oxygenxml.xspec.saxon.GenerateIDExtensionFunction;

/**
* Presents the HTML resulted from executing an XSpec scenario.
*
* @author alex_jitianu
*/
public interface XSpecResultPresenter {
/**
* If it already presents the results of an XSpec execution
* then it will return the URL of the executed XSpec.
*
* @return The XSpec that was executed and its results are currently presented.
*/
URL getXspec();

/**
* Loads the results from executing an XSpec file.
*
* @param resultHTML The result.
*/
void loadContent(String resultHTML);

/**
* Loads the results from executing an XSpec file.
*
* @param xspec The executed XSpec.
* @param results The results in a HTML format.
*/
public void load(URL xspecURL, URL resultHTML);

/**
* Executes a given scenario.
*
* @param scenarioId Name of the scenario to execute. Usually something generated with
* {@link GenerateIDExtensionFunction}
*/
public void runScenario(String scenarioId);
}
33 changes: 33 additions & 0 deletions src/main/java/com/oxygenxml/xspec/XSpecResultsView.java
Original file line number Diff line number Diff line change
Expand Up @@ -441,4 +441,37 @@ public void transformationFinished(boolean success) {
public void runXSpec() {
runAction.actionPerformed(null);
}

@Override
public void runScenario(String scenarioId) {
try {
WSEditor xspecToExecute = getEditorAccess(xspec);

// We only need to execute this scenario.
resolver.setTemplateNames(scenarioId);

enableButtons(false);
// Step 3. Run the scenario
XSpecUtil.runScenario(
xspecToExecute,
(StandalonePluginWorkspace) pluginWorkspace,
this,
createTransformationFeedback());
} catch (OperationCanceledException e1) {
// The user canceled the operation.
enableButtons(true);
}
}


private WSEditor getEditorAccess(URL toOpen) {
WSEditor e = pluginWorkspace.getEditorAccess(toOpen, PluginWorkspace.MAIN_EDITING_AREA);
if (e == null) {
// Just in case the file is no longer opened.
pluginWorkspace.open(toOpen);

e = pluginWorkspace.getEditorAccess(toOpen, PluginWorkspace.MAIN_EDITING_AREA);
}
return e;
}
}
Loading

0 comments on commit 309338b

Please sign in to comment.