Skip to content

Commit c4ef4c4

Browse files
committed
Replace dialog messages with popups
1 parent 0eec07b commit c4ef4c4

File tree

7 files changed

+39
-39
lines changed

7 files changed

+39
-39
lines changed

src/de/fraunhofer/iem/mois/assist/actions/ExportAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void actionPerformed(AnActionEvent anActionEvent) {
4141
}
4242

4343
JSONWriter exportFile = new JSONWriter();
44-
44+
//TODO deal with exception
4545
try {
4646
exportFile.writeToJsonFile(JSONFileLoader.getMethods(), filePath);
4747
} catch (IOException e) {

src/de/fraunhofer/iem/mois/assist/actions/LaunchMoisAction.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,20 @@ public void actionPerformed(AnActionEvent anActionEvent) {
3333
//Export changes to configuration files
3434
JSONWriter exportFile = new JSONWriter();
3535

36-
/* try {
36+
try {
3737
exportFile.writeToJsonFile(JSONFileLoader.getMethods(), JSONFileLoader.getConfigurationFile(true));
3838
} catch (IOException e) {
3939
e.printStackTrace();
40-
}*/
40+
}
4141

4242
//Launch Dialog
43-
Window activeWindow = FocusManager.getCurrentManager().getActiveWindow();
43+
MoisLauncherDialog dialog = new MoisLauncherDialog(project, true);
44+
dialog.show();
4445

45-
MoisLauncherDialog dialog = new MoisLauncherDialog(activeWindow, project, true);
46-
dialog.pack();
47-
dialog.setLocationRelativeTo(null);
48-
dialog.setVisible(true);
46+
if (dialog.getExitCode()==DialogWrapper.OK_EXIT_CODE) {
4947

50-
if (dialog.isConfirmed()) {
48+
MoisProcessBuilder processBuilder = new MoisProcessBuilder(project, dialog.getParameters());
49+
processBuilder.start();
5150

5251
MoisNotifier publisher = messageBus.syncPublisher(MoisNotifier.START_MOIS_PROCESS_TOPIC);
5352
publisher.launchMois(null);
@@ -58,7 +57,9 @@ public void actionPerformed(AnActionEvent anActionEvent) {
5857
public void update(AnActionEvent event) {
5958

6059
//Disable/Enable action button
61-
if (JSONFileLoader.isFileSelected())
60+
if (JSONFileLoader.isReloading() || !JSONFileLoader.isFileSelected())
61+
event.getPresentation().setEnabled(false);
62+
else
6263
event.getPresentation().setEnabled(true);
6364
}
6465
}

src/de/fraunhofer/iem/mois/assist/actions/MoisProcessBuilder.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
/**
1818
* Creates process to run MOIS.
19+
*
1920
* @author Oshando Johnson
2021
*/
2122

@@ -24,11 +25,11 @@
2425
public class MoisProcessBuilder extends Thread {
2526

2627
private static HashMap<String, String> parameters;
27-
private AnActionEvent anActionEvent;
28+
private Project project;
2829

29-
MoisProcessBuilder(AnActionEvent actionEvent, HashMap<String, String> param) {
30+
MoisProcessBuilder(Project project, HashMap<String, String> param) {
3031

31-
anActionEvent = actionEvent;
32+
this.project = project;
3233
parameters = param;
3334
}
3435

@@ -57,15 +58,14 @@ public void run() {
5758
processBuilder.redirectErrorStream(true);
5859
processBuilder.redirectOutput(ProcessBuilder.Redirect.appendTo(logFile));
5960

60-
String completionTimestamp = getCurrentTimestamp("HH:mm");
61-
String message = Constants.NOTIFICATION_END_MOIS_SUCCESS + completionTimestamp;
61+
String message;
6262

6363
try {
6464
Process moisProcess = processBuilder.start();
6565
int result = moisProcess.waitFor();
6666

6767
if (result == 0)
68-
message = Constants.NOTIFICATION_END_MOIS_SUCCESS + completionTimestamp;
68+
message = Constants.NOTIFICATION_END_MOIS_SUCCESS;
6969
else
7070
message = Constants.NOTIFICATION_END_MOIS_FAIL;
7171

@@ -76,13 +76,10 @@ public void run() {
7676
}
7777

7878
HashMap<String, String> results = new HashMap<String, String>();
79-
results.put(Constants.MOIS_OUTPUT_FILE, parameters.get(Constants.MOIS_OUTPUT_DIR) + File.separator + currentTimestamp + Constants.OUTPUT_JSON_SUFFIX);
79+
results.put(Constants.MOIS_OUTPUT_FILE, parameters.get(Constants.MOIS_OUTPUT_DIR) + File.separator + "json" + File.separator + Constants.OUTPUT_JSON_SUFFIX);
8080
results.put(Constants.MOIS_OUTPUT_LOG, parameters.get(Constants.MOIS_OUTPUT_DIR) + File.separator + currentTimestamp + Constants.MOIS_LOG_SUFFIX);
8181
results.put(Constants.MOIS_OUTPUT_MESSAGE, message);
8282

83-
anActionEvent.getPresentation().setEnabled(true);
84-
85-
final Project project = anActionEvent.getRequiredData(CommonDataKeys.PROJECT);
8683
MessageBus messageBus = project.getMessageBus();
8784
MoisNotifier publisher = messageBus.syncPublisher(MoisNotifier.END_MOIS_PROCESS_TOPIC);
8885
publisher.launchMois(results);

src/de/fraunhofer/iem/mois/assist/actions/method/MethodPropertiesAction.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,8 @@ public void actionPerformed(AnActionEvent anActionEvent) {
5353
method = PsiTraversal.getMethodAtOffset(anActionEvent, false);
5454

5555
if (method != null) {
56-
MethodPropertiesDialog detailsDialog = new MethodPropertiesDialog(method);
57-
detailsDialog.setTitle(Constants.TITLE_METHOD_PROPERTIES);
58-
detailsDialog.pack();
59-
detailsDialog.setSize(550, 350);
60-
detailsDialog.setLocationRelativeTo(null);
61-
detailsDialog.setVisible(true);
56+
MethodPropertiesDialog detailsDialog = new MethodPropertiesDialog(project, method);
57+
detailsDialog.show();
6258
} else {
6359
final Editor editor = anActionEvent.getRequiredData(CommonDataKeys.EDITOR);
6460
JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(Constants.METHOD_NOT_FOUND, MessageType.INFO, null)

src/de/fraunhofer/iem/mois/assist/actions/method/UpdateMethodAction.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,7 @@ public void actionPerformed(AnActionEvent anActionEvent) {
2828
final Project project = anActionEvent.getProject();
2929

3030
MethodDialog dialog = new MethodDialog(method, project, JSONFileLoader.getCategories());
31-
32-
if (method.isNewMethod())
33-
dialog.setTitle(Constants.TITLE_ADD_METHOD);
34-
else
35-
dialog.setTitle(Constants.TITLE_UPDATE_METHOD);
36-
37-
dialog.pack();
38-
dialog.setSize(550, 350);
39-
dialog.setLocationRelativeTo(null);
40-
dialog.setVisible(true);
31+
dialog.show();
4132
}
4233

4334
@Override

src/de/fraunhofer/iem/mois/assist/data/JSONFileLoader.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ public class JSONFileLoader {
1616
static public final int NEW_METHOD = 0;
1717
static public final int EXISTING_METHOD = 1;
1818

19+
20+
21+
static private boolean reloadingMois = false;
22+
1923
//Get configuration file location
2024
public static void setConfigurationFile(String path) {
2125

@@ -150,4 +154,12 @@ private static boolean inProject(String classname, Project project) {
150154
//psiClass.getAllMethods()[0].
151155
return psiClass != null;
152156
}
157+
158+
public static boolean isReloading() {
159+
return reloadingMois;
160+
}
161+
162+
public static void setReloading(boolean reloadingMois) {
163+
JSONFileLoader.reloadingMois = reloadingMois;
164+
}
153165
}

src/de/fraunhofer/iem/mois/assist/data/JSONFileParser.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package de.fraunhofer.iem.mois.assist.data;
22

3-
import com.intellij.openapi.ui.Messages;
3+
import com.intellij.notification.Notification;
4+
import com.intellij.notification.NotificationType;
5+
import com.intellij.notification.Notifications;
46
import de.fraunhofer.iem.mois.Parser;
57
import de.fraunhofer.iem.mois.assist.util.Constants;
8+
import de.fraunhofer.iem.mois.data.Method;
69

710
import java.util.HashMap;
811

@@ -29,13 +32,13 @@ public HashMap<String, MethodWrapper> parseJSONFileMap() {
2932
Parser parser = new Parser(null);
3033

3134
try {
32-
for (de.fraunhofer.iem.mois.data.Method method : parser.parseFile(congFilePath)) {
35+
for (Method method : parser.parseFile(congFilePath)) {
3336

3437
MethodWrapper methodWrapper = new MethodWrapper(method);
3538
methods.put(methodWrapper.getSignature(true),methodWrapper );
3639
}
3740
} catch (Exception e) {
38-
Messages.showWarningDialog(Constants.FILE_LOAD_ERROR, "File Load Error");
41+
Notifications.Bus.notify(new Notification("AssistMois", "File Load Error", Constants.FILE_LOAD_ERROR, NotificationType.ERROR));
3942
}
4043

4144
return methods;

0 commit comments

Comments
 (0)