Skip to content

Commit 1c9013b

Browse files
committed
Update messages, dialogs and labels
1 parent c136e28 commit 1c9013b

16 files changed

+105
-66
lines changed

swan_assist/src/main/java/de/fraunhofer/iem/swan/assist/actions/RunSwanAnalysisAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import de.fraunhofer.iem.swan.assist.comm.SwanNotifier;
1717
import de.fraunhofer.iem.swan.assist.data.JSONFileLoader;
1818
import de.fraunhofer.iem.swan.assist.data.TrainingFileManager;
19-
import de.fraunhofer.iem.swan.assist.ui.dialog.PluginSettingsDialog;
19+
import de.fraunhofer.iem.swan.assist.ui.dialog.RunAnalysisDialog;
2020
import de.fraunhofer.iem.swan.assist.util.Constants;
2121
import de.fraunhofer.iem.swan.data.Method;
2222

@@ -65,7 +65,7 @@ public void actionPerformed(AnActionEvent anActionEvent) {
6565
}
6666

6767
//Launch Dialog
68-
PluginSettingsDialog dialog = new PluginSettingsDialog(project, true);
68+
RunAnalysisDialog dialog = new RunAnalysisDialog(project, true);
6969
dialog.show();
7070

7171
if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {

swan_assist/src/main/java/de/fraunhofer/iem/swan/assist/actions/method/DeleteMethodAction.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public class DeleteMethodAction extends AnAction {
3636
* Initializes the action
3737
*/
3838
public DeleteMethodAction() {
39-
super("Delete");
4039
deleteMethod = null;
4140
}
4241

@@ -45,7 +44,7 @@ public DeleteMethodAction() {
4544
* @param method that will be deleted
4645
*/
4746
public DeleteMethodAction(MethodWrapper method) {
48-
super("Delete");
47+
super("Delete Classification");
4948
deleteMethod = method;
5049
}
5150

swan_assist/src/main/java/de/fraunhofer/iem/swan/assist/actions/method/MethodPropertiesAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public MethodPropertiesAction() {
3939
* @param method The properties of this method will be loaded.
4040
*/
4141
public MethodPropertiesAction(MethodWrapper method) {
42-
super("Properties");
42+
super("Classification Properties");
4343
this.method = method;
4444
}
4545

swan_assist/src/main/java/de/fraunhofer/iem/swan/assist/actions/method/RestoreMethodAction.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ public class RestoreMethodAction extends AnAction {
3434
* Initializes action
3535
*/
3636
public RestoreMethodAction() {
37+
3738
}
3839

3940
/**
4041
* Initializes action using method.
4142
* @param method Method that will be restored.
4243
*/
4344
public RestoreMethodAction(MethodWrapper method) {
44-
super("Restore");
45+
46+
super("Restore Classification");
4547
this.method = method;
4648
}
4749

swan_assist/src/main/java/de/fraunhofer/iem/swan/assist/actions/method/UpdateMethodAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class UpdateMethodAction extends AnAction {
3030
* @param method Method that should be updated or added.
3131
*/
3232
public UpdateMethodAction(MethodWrapper method) {
33-
super("Update");
33+
super("Re-Classify Method");
3434
this.method = method;
3535
}
3636

swan_assist/src/main/java/de/fraunhofer/iem/swan/assist/data/JSONFileLoader.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
public class JSONFileLoader {
2626

27-
static private HashMap<String, MethodWrapper> methods;
27+
static private HashMap<String, MethodWrapper> methods= new HashMap<>();
2828
static private String congFile = "";
2929
static public final int NEW_METHOD = 0;
3030
static public final int EXISTING_METHOD = 1;
@@ -149,11 +149,16 @@ public static ArrayList<MethodWrapper> getMethods(ArrayList<Pair<String, String>
149149
}
150150
}
151151

152-
public static HashMap<String, ArrayList<MethodWrapper>> getMethodsForTree(ArrayList<Pair<String, String>> filters, String currentFile, Project project) {
152+
public static TreeMap<String, ArrayList<MethodWrapper>> getMethodsForTree(ArrayList<Pair<String, String>> filters, String currentFile, Project project) {
153153

154154
ArrayList<MethodWrapper> methods = getMethods(filters, currentFile, project);
155155

156-
HashMap<String, ArrayList<MethodWrapper>> methodMap = new HashMap();
156+
TreeMap<String, ArrayList<MethodWrapper>> methodMap = new TreeMap<>(new Comparator<String>() {
157+
@Override
158+
public int compare(String class1, String class2) {
159+
return Formatter.trimProperty(class1).toLowerCase().compareTo(Formatter.trimProperty(class2).toLowerCase());
160+
}
161+
});
157162

158163
for (MethodWrapper method : methods) {
159164

swan_assist/src/main/java/de/fraunhofer/iem/swan/assist/data/MethodWrapper.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import de.fraunhofer.iem.swan.data.Category;
1212
import org.apache.commons.lang3.StringUtils;
1313
import de.fraunhofer.iem.swan.data.Method;
14+
import org.jetbrains.annotations.NotNull;
15+
1416
import java.util.*;
1517

1618
/**
@@ -255,7 +257,14 @@ public void setUpdateOperation(String updateOperation) {
255257
* @return Message for editor marker
256258
*/
257259
public String getMarkerMessage() {
258-
return "This is a potential " + StringUtils.join(getTypesList(true), ", ") + " method of sensitive information relevant for " + StringUtils.join(getCWEList(), ", ");
260+
261+
String message = "<html><i>Potential</i> <b>" + StringUtils.join(getTypesList(true), ", ") + "</b> method";
262+
263+
if(getCWEList().size()>0)
264+
message += " of sensitive information relevant for <b>" + StringUtils.join(getCWEList(), ", ")+"</b";
265+
266+
message+=".</html>";
267+
return message;
259268
}
260269

261270
/**

swan_assist/src/main/java/de/fraunhofer/iem/swan/assist/data/PropertiesManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import com.intellij.ide.util.PropertiesComponent;
1111
import com.intellij.openapi.project.Project;
1212
import com.intellij.openapi.ui.DialogWrapper;
13-
import de.fraunhofer.iem.swan.assist.ui.dialog.PluginSettingsDialog;
13+
import de.fraunhofer.iem.swan.assist.ui.dialog.RunAnalysisDialog;
1414

1515
import java.io.File;
1616
import java.util.HashMap;
@@ -45,7 +45,7 @@ public static String setProjectOutputPath(Project project){
4545
private static void showSettingsDialog(Project project) {
4646

4747
//Launch SWAN Properties Dialog
48-
PluginSettingsDialog dialog = new PluginSettingsDialog(project, true);
48+
RunAnalysisDialog dialog = new RunAnalysisDialog(project, true);
4949
dialog.show();
5050

5151
if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {

swan_assist/src/main/java/de/fraunhofer/iem/swan/assist/ui/CategoryRenderer.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,23 @@ public class CategoryRenderer extends JLabel implements ListCellRenderer<Categor
2424
@Override
2525
public Component getListCellRendererComponent(JList<? extends Category> list, Category category, int index, boolean isSelected, boolean cellHasFocus) {
2626

27+
String HIGHLIGHT_COLOR = "gray";
28+
2729
if (isSelected) {
2830
setBackground(new JBColor(new Color(9, 80, 208), new Color(9, 80, 208)));
2931
setForeground(JBColor.white);
32+
HIGHLIGHT_COLOR = "white";
3033
} else {
3134
setBackground(JBColor.WHITE);
3235
setForeground(JBColor.BLACK);
3336
}
3437

38+
3539
if (category.isCwe()) {
3640

3741
ResourceBundle resourceBundle = ResourceBundle.getBundle("dialog_messages");
3842

39-
setText("<html>" + Formatter.toTitleCase(category.toString()) + " <font color='gray'>" + resourceBundle.getString(category.toString() + ".Name") + "</font></html>");
43+
setText("<html>" + Formatter.toTitleCase(category.toString()) + " <font color='" + HIGHLIGHT_COLOR + "'>" + resourceBundle.getString(category.toString() + ".Name") + "</font></html>");
4044
setToolTipText("<html>" + "<b>" + Formatter.toTitleCase(category.toString()) + "</b> " + resourceBundle.getString(category.toString() + ".FullName") + "</html>");
4145
} else {
4246
setText(Formatter.toTitleCase(category.toString()));

swan_assist/src/main/java/de/fraunhofer/iem/swan/assist/ui/MethodListTree.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import javax.swing.tree.TreePath;
5656
import java.awt.event.MouseAdapter;
5757
import java.awt.event.MouseEvent;
58+
import java.text.DecimalFormat;
5859
import java.util.*;
5960

6061
/**
@@ -138,7 +139,6 @@ public void mouseClicked(MouseEvent e) {
138139
if (methodSignature.contains("<init>"))
139140
methodSignature = Formatter.trimProperty(method.getClassName(false));
140141

141-
142142
boolean methodFound = false;
143143

144144
for (PsiFile file : files) {
@@ -184,9 +184,9 @@ public void run(@NotNull ProgressIndicator progressIndicator) {
184184

185185
ApplicationManager.getApplication().runReadAction(new Runnable() {
186186
public void run() {
187+
187188
JSONFileLoader.setConfigurationFile(fileName, project);
188189
JSONFileLoader.loadInitialFile();
189-
190190
}
191191
});
192192
}
@@ -210,7 +210,6 @@ public void run(@NotNull ProgressIndicator progressIndicator) {
210210
ApplicationManager.getApplication().runReadAction(new Runnable() {
211211
public void run() {
212212
JSONFileLoader.loadUpdatedFile(fileName, project);
213-
loadMethods();
214213
}
215214
});
216215
}
@@ -509,11 +508,14 @@ private void loadMethods() {
509508

510509
if (methods.size() > 0) {
511510

512-
DefaultMutableTreeNode root = new DefaultMutableTreeNode("<html><b>Methods</b> <font color='gray'>[<i>" + JSONFileLoader.getConfigurationFile(false) + "</i>]</font></html>");
511+
DefaultMutableTreeNode root = new DefaultMutableTreeNode("<html><b>Classified Methods</b> <font color='gray'>[<i>" + JSONFileLoader.getConfigurationFile(false) + "</i>]</font></html>");
513512

513+
int methodCount = 0;
514+
int totalMethods = 0;
514515
for (String classname : methods.keySet()) {
515516

516-
DefaultMutableTreeNode classNode = new DefaultMutableTreeNode(new Pair<>(classname, methods.get(classname).size()));
517+
methodCount = methods.get(classname).size();
518+
totalMethods += methodCount;
517519

518520
for (MethodWrapper method : methods.get(classname)) {
519521

@@ -522,6 +524,11 @@ private void loadMethods() {
522524
}
523525
}
524526

527+
String pattern = "###,###";
528+
DecimalFormat decimalFormat = new DecimalFormat(pattern);
529+
530+
root.setUserObject("<html><b>Classified Methods</b> <font color='gray'>(" + decimalFormat.format(totalMethods) + " in "+ decimalFormat.format(methods.size())+" classes)</font></html>");
531+
525532
treeModel.setRoot(root);
526533
TREE_EXPANDED = false;
527534
} else {

0 commit comments

Comments
 (0)