Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifications to show assurance cases in Eclipse Views #169

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tools/rack/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,29 @@
<version>${version.javafx}</version>
<classifier>win</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>${version.javafx}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>${version.javafx}</version>
<classifier>linux</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>${version.javafx}</version>
<classifier>mac</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>${version.javafx}</version>
<classifier>win</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions tools/rack/rack.plugin/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ Bundle-ClassPath: .,
lib/javafx-media-mac.jar,
lib/javafx-media-win.jar,
lib/javafx-media.jar,
lib/javafx-swing.jar,
lib/javafx-swing-linux.jar,
lib/javafx-swing-mac.jar,
lib/javafx-swing-win.jar,
lib/javafx-web-linux.jar,
lib/javafx-web-mac.jar,
lib/javafx-web-win.jar,
Expand Down
4 changes: 4 additions & 0 deletions tools/rack/rack.plugin/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ bin.includes = .,\
lib/javafx-media-mac.jar,\
lib/javafx-media-win.jar,\
lib/javafx-media.jar,\
lib/javafx-swing.jar,\
lib/javafx-swing-linux.jar,\
lib/javafx-swing-mac.jar,\
lib/javafx-swing-win.jar,\
lib/javafx-web-linux.jar,\
lib/javafx-web-mac.jar,\
lib/javafx-web-win.jar,\
Expand Down
5 changes: 5 additions & 0 deletions tools/rack/rack.plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@
id="rackplugin.views.AssuranceCaseTree" inject="true"
name="Assurance Case GSN">
</view>
<view category="rackplugin"
class="com.ge.research.rack.views.AssuranceGoalView"
id="rackplugin.views.AssuranceGoalView" inject="true"
name="Assurance Goals">
</view>
<view category="rackplugin"
class="com.ge.research.rack.views.NodegroupColumnView"
id="rackplugin.views.ManageCSVColumns" inject="true"
Expand Down
19 changes: 19 additions & 0 deletions tools/rack/rack.plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,25 @@
<artifactId>javafx-media</artifactId>
<classifier>win</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<classifier>linux</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<classifier>mac</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<classifier>win</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
*/
package com.ge.research.rack;

import com.ge.research.rack.views.AssuranceCaseTree;
import com.ge.research.rack.views.RackPreferencePage;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
Expand All @@ -40,8 +42,13 @@ public class AutoGsnButtonHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// Launch the AutoGsnMainView
JavaFXAppLaunchManager.autoGsnMainViewLaunch();

// MessageDialog.openInformation(null, "", "Mode " +
// RackPreferencePage.getJavaFxPreference());
if (RackPreferencePage.getJavaFxPreference()) {
JavaFXAppLaunchManager.autoGsnMainViewLaunch();
} else {
AssuranceCaseTree.showView();
}
return null;
}
}
344 changes: 184 additions & 160 deletions tools/rack/rack.plugin/src/com/ge/research/rack/RunWorkflowHandler.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.ge.research.rack.autoGsn.structures.InstanceData;
import com.ge.research.rack.autoGsn.structures.MultiClassPackets.GoalIdAndClass;
import com.ge.research.rack.autoGsn.viewManagers.AutoGsnViewsManager;
import java.awt.Desktop;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
Expand Down Expand Up @@ -116,10 +117,7 @@ public static ImageView getNodeImage(GsnNode node) {
URL imgUrl = FileLocator.find(bundle, new Path(imagePath), null);
imgUrl = FileLocator.toFileURL(imgUrl);

// the imgURL starts with "file:/", so stripping it here
String imgUrlStr = imgUrl.toString().substring("file:/".length());

// System.out.println(imgUrl.toString());
String imgUrlStr = imgUrl.getFile();

ImageView icon = new ImageView(new Image(new FileInputStream(new File(imgUrlStr))));

Expand Down Expand Up @@ -250,16 +248,57 @@ public static void createArtifactsFromSelectedGsnNodes(
*
* @param url
*/
public static void openUrlInDefaultApp(String url) {
System.out.println("Trying to open generated GSN svg file in default app!");
public static void openUrlInDefaultApp(String path) {
// System.out.println("Trying to open generated GSN svg file in default app! " + path);
try {
AutoGsnViewsManager.hostServices.showDocument(url);
if (AutoGsnViewsManager.hostServices != null) {
// Running a javafx application
AutoGsnViewsManager.hostServices.showDocument(path);
} else {
// Using Eclipse views
if (Desktop.isDesktopSupported()
&& Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
// Desktop.getDesktop().browse(new java.net.URI("data:image/svg+xml,/" +
// url.replace("//","/")));

open(path);
}
}
} catch (Exception e) {
System.out.println("ERROR: Failed to open generated GSN svg file in default app!");
System.out.println(
"ERROR: Failed to open generated GSN svg file in default app! " + path);
e.printStackTrace();
}
}

private static void open(final String path) throws java.net.MalformedURLException {
var url = new java.net.URL("file:" + path);
org.eclipse.swt.widgets.Display.getDefault().asyncExec(() -> internalOpen(url, true));
}

private static void internalOpen(final URL url, final boolean useExternalBrowser) {
org.eclipse.swt.custom.BusyIndicator.showWhile(
null,
() -> {
URL helpSystemUrl =
org.eclipse.ui.PlatformUI.getWorkbench()
.getHelpSystem()
.resolve(url.toExternalForm(), true);
try {
var browserSupport =
org.eclipse.ui.PlatformUI.getWorkbench().getBrowserSupport();
org.eclipse.ui.browser.IWebBrowser browser;
if (useExternalBrowser) {
browser = browserSupport.getExternalBrowser();
} else {
browser = browserSupport.createBrowser(null);
}
browser.openURL(helpSystemUrl);
} catch (org.eclipse.ui.PartInitException ex) {
}
});
}

/**
* Takes a List<GoalIdAndClass> and returns all unique class ids
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static String createGsnSvg(GsnNode gsn, String tempDir, String outDir, St
GraphVizUtils.generateGraphUsingGraphviz(dotFilePath, graphDestination);
// GraphVizUtils.generateGraphUsingDot(dotFilePath, graphDestination);

System.out.println("Info: Written GSN to svg");
// System.out.println("Info: Written GSN to svg");

// // Delete the dot files
// GsnFileUtils.delFilesWithExt("dot", outDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static List<String> getPropertyRangeURIs(
*/
public static String getClassURI(JSONObject ontInfo, String classId) {

System.out.println("Finding URI of class " + classId);
// System.out.println("Finding URI of class " + classId);

JSONArray subClassSuperClassList = (JSONArray) ontInfo.get("subClassSuperClassList");
var subClassSuperClassListIter = subClassSuperClassList.iterator();
Expand Down Expand Up @@ -179,8 +179,6 @@ public static String getClassURI(JSONObject ontInfo, String classId) {

public static String getSuperClassId(JSONObject ontInfo, String classId) {

System.out.println("Finding Superclass of class " + classId);

JSONArray subClassSuperClassList = (JSONArray) ontInfo.get("subClassSuperClassList");
var subClassSuperClassListIter = subClassSuperClassList.iterator();

Expand All @@ -194,7 +192,7 @@ public static String getSuperClassId(JSONObject ontInfo, String classId) {
String rowSuperClassId = rowSuperInfo.split("\\:")[1];

if (rowSubClassId.equals(classId)) {
System.out.println(rowSuperClassId);
// System.out.println(rowSuperClassId);
return rowSuperClassId;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public static String binaryConnectionQuery(
try {

String templateString = QueryTemplates.getBinary();

// replace placeholders in template string
templateString = templateString.replace("SPARQLCONN_NAME_PH", sparqlConnName);
templateString = templateString.replace("MODEL_URL_PH", modelUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.ge.research.rack.autoGsn.viewManagers.AutoGsnViewsManager;
import com.ge.research.rack.autoGsn.viewManagers.GsnTreeViewManager;
import com.ge.research.rack.report.utils.ReportViewUtils;
import com.ge.research.rack.views.RackPreferencePage;
import java.util.ArrayList;
import java.util.List;
import javafx.event.ActionEvent;
Expand All @@ -65,12 +66,19 @@
import javafx.scene.layout.CornerRadii;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import org.eclipse.jface.dialogs.MessageDialog;

/**
* @author Saswata Paul
*/
public class AutoGsnUnifiedDrillGoalViewHandler {

static AutoGsnUnifiedDrillGoalViewHandler self;

public AutoGsnUnifiedDrillGoalViewHandler() {
self = this;
}

// -------- Local variables to store data

// All relevant GSN for this traverse instance
Expand Down Expand Up @@ -165,7 +173,7 @@ private TreeItemAndBoolean<Label> populateTreeViewGsnCascadeWithExpansion(
// if this is the currentgoal, expand it by default
// System.out.println(node.getNodeId() + " ------- " + currentGoalId);
if (node.getNodeId().equalsIgnoreCase(currentGoalId)) {
System.out.println("expanded");
// System.out.println("expanded");
elementItem.setExpanded(true);
myExpFlag = true;
}
Expand All @@ -186,7 +194,7 @@ private TreeItemAndBoolean<Label> populateTreeViewGsnCascadeWithExpansion(
{
if (childReturned.getExpandFlag()) {
someChildExpanded = true;
System.out.println(node.getNodeId() + " somechild expanded");
// System.out.println(node.getNodeId() + " somechild expanded");
}
}
}
Expand All @@ -196,7 +204,7 @@ private TreeItemAndBoolean<Label> populateTreeViewGsnCascadeWithExpansion(
if (someChildExpanded) {
myExpFlag = true;
elementItem.setExpanded(true);
System.out.println(node.getNodeId() + " expanded");
// System.out.println(node.getNodeId() + " expanded");
}
}
}
Expand Down Expand Up @@ -255,15 +263,19 @@ private void findParentId(GsnNode node, String childId) {
* <p>TODO: BAD CODE. CHANGE LATER
*/
private void decidePreviousGoalId() {
if (rootGsn == null) {
MessageDialog.openInformation(null, "", "rootGsn is null");
return;
}
// find and assign parent strategy to previousGoalId
findParentId(rootGsn, currentGoalId);

System.out.println("1 " + previousGoalId);
// System.out.println("1 " + previousGoalId);

// find and assign grandparent goal to previousGoalId
findParentId(rootGsn, previousGoalId);

System.out.println("2 " + previousGoalId);
// System.out.println("2 " + previousGoalId);
}

/** Show/hide previous goal button */
Expand Down Expand Up @@ -342,6 +354,7 @@ private void populateSubGoals(String key) {
* @param goalId
*/
private void populateFields(String goalId) {
var previousGoalId = currentGoalId;

// only goalIds starting with "G-" will warrant action
if (goalId.startsWith("G-")) {
Expand All @@ -353,9 +366,9 @@ private void populateFields(String goalId) {
// taken, we must check once if a goal node was actually returned
if (goalNode != null) {
// update previousgoalId if the level change was downstream (level x to x+1)
System.out.println("gl" + goalNode.getNodeLevel() + " cl " + currentGoalLevel);
// System.out.println("gl" + goalNode.getNodeLevel() + " cl " + currentGoalLevel);
if (goalNode.getNodeLevel() > currentGoalLevel) {
System.out.println("updated previous");
// System.out.println("updated previous");
previousGoalId = currentGoalId;
}

Expand Down Expand Up @@ -429,7 +442,8 @@ private void populateFields(String goalId) {
// decide previous goal button
showOrHidePreviousBtn();

} else {
} else if (!currentGoalId.equals(
previousGoalId)) { // This test prevents an infinite loop
// TODO
// Currently, if the selection in listview does not do anything,
// then the item is highlighted in blue, meking it illegible
Expand All @@ -451,6 +465,10 @@ public void prepareView(int initialLevel, String goalId, GsnNode mainGsn) {
rootNodeId = goalId;
currentGoalId = goalId;

if (mainGsn == null) {
MessageDialog.openInformation(null, "", "MainGSN is null");
}

// get and store the root gsn
rootGsn = mainGsn;

Expand Down Expand Up @@ -538,7 +556,12 @@ private void comboPassFailAction(ActionEvent event) throws Exception {
@FXML
private void btnHomeAction(ActionEvent event) throws Exception {

// Set the stage with the other fxml
AutoGsnViewsManager.setNewFxmlToStage("resources/fxml/autoGsn/AutoGsnUnifiedMainView.fxml");
if (RackPreferencePage.getJavaFxPreference()) {
// Set the stage with the other fxml
AutoGsnViewsManager.setNewFxmlToStage(
"resources/fxml/autoGsn/AutoGsnUnifiedMainView.fxml");
} else {
com.ge.research.rack.views.AssuranceCaseTree.showView();
}
}
}
Loading
Loading