use of org.apache.netbeans.modules.python4nb.platform.PythonSupport in project python4nb by ebresie.
the class Notifications method notifyRunConfiguration.
// @NbBundle.Messages({
// "Notifications.graalvm.detection.title=GraalVM detected",
// "Notifications.graalvm.detection.description=Set proper node and npm paths?",
// "Notifications.graalvm.detection.done=Proper node and npm paths set.",
// "Notifications.graalvm.detection.noop=Proper node and npm paths already set.",
// })
// public static void notifyGraalVmDetected() {
// NotificationDisplayer.getDefault().notify(
// Bundle.Notifications_graalvm_detection_title(),
// NotificationDisplayer.Priority.LOW.getIcon(),
// Bundle.Notifications_graalvm_detection_description(),
// new ActionListener() {
// @Override
// public void actionPerformed(ActionEvent e) {
// String text;
// if (GraalVmUtils.properPathsSet()) {
// // already done
// text = Bundle.Notifications_graalvm_detection_noop();
// } else {
// PythonOptions.getInstance().setPython(GraalVmUtils.getPython());
// PythonOptions.getInstance().setNpm(GraalVmUtils.getNpm(true));
// text = Bundle.Notifications_graalvm_detection_done();
// }
// StatusDisplayer.getDefault().setStatusText(text);
// }
// },
// NotificationDisplayer.Priority.LOW);
// }
@NbBundle.Messages({ "Notifications.enabled.title=Python support enabled", "# {0} - project name", "Notifications.enabled.description=Enable running project {0} as Python application?", "# {0} - project name", "Notifications.enabled.done=Project {0} will be run as Python application.", "# {0} - project name", "Notifications.enabled.noop=Project {0} already runs as Python application.", "# {0} - project name", "Notifications.enabled.invalid=Python support not enabled in project {0}." })
public static void notifyRunConfiguration(Project project) {
final String projectName = PythonUtils.getProjectDisplayName(project);
final PythonSupport pythonSupport = PythonSupport.forProject(project);
final PythonPreferences preferences = pythonSupport.getPreferences();
assert !preferences.isRunEnabled() : "Python run should not be enabled in " + projectName;
NotificationDisplayer.getDefault().notify(Bundle.Notifications_enabled_title(), NotificationDisplayer.Priority.LOW.getIcon(), Bundle.Notifications_enabled_description(projectName), new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String text;
if (!preferences.isEnabled()) {
// not enabled at all (happens if one clicks in notifications window later)
text = Bundle.Notifications_enabled_invalid(projectName);
} else if (preferences.isRunEnabled()) {
// already done
text = Bundle.Notifications_enabled_noop(projectName);
} else {
pythonSupport.firePropertyChanged(PythonPlatformProvider.PROP_RUN_CONFIGURATION, null, PythonRunPanel.IDENTIFIER);
text = Bundle.Notifications_enabled_done(projectName);
}
StatusDisplayer.getDefault().setStatusText(text);
}
}, NotificationDisplayer.Priority.LOW);
}
Aggregations