use of org.openide.NotifyDescriptor in project gephi by gephi.
the class ProjectControllerUIImpl method closeCurrentProject.
public boolean closeCurrentProject() {
if (controller.getCurrentProject() != null) {
//Save ?
String messageBundle = NbBundle.getMessage(ProjectControllerUIImpl.class, "CloseProject_confirm_message");
String titleBundle = NbBundle.getMessage(ProjectControllerUIImpl.class, "CloseProject_confirm_title");
String saveBundle = NbBundle.getMessage(ProjectControllerUIImpl.class, "CloseProject_confirm_save");
String doNotSaveBundle = NbBundle.getMessage(ProjectControllerUIImpl.class, "CloseProject_confirm_doNotSave");
String cancelBundle = NbBundle.getMessage(ProjectControllerUIImpl.class, "CloseProject_confirm_cancel");
NotifyDescriptor msg = new NotifyDescriptor(messageBundle, titleBundle, NotifyDescriptor.YES_NO_CANCEL_OPTION, NotifyDescriptor.INFORMATION_MESSAGE, new Object[] { saveBundle, doNotSaveBundle, cancelBundle }, saveBundle);
Object result = DialogDisplayer.getDefault().notify(msg);
if (result == saveBundle) {
saveProject();
} else if (result == cancelBundle) {
return false;
}
controller.closeCurrentProject();
//Actions
saveProject = false;
saveAsProject = false;
projectProperties = false;
closeProject = false;
newWorkspace = false;
deleteWorkspace = false;
duplicateWorkspace = false;
renameWorkspace = false;
//Title bar
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = (JFrame) WindowManager.getDefault().getMainWindow();
String title = frame.getTitle();
title = title.substring(0, title.indexOf(" - "));
frame.setTitle(title);
}
});
}
return true;
}
use of org.openide.NotifyDescriptor in project gephi by gephi.
the class CommandLineProcessor method process.
@Override
public void process(Env env, Map values) throws CommandException {
List<String> filenameList = new ArrayList<>();
Object obj = values.get(openOption);
if (obj != null) {
filenameList.addAll(Arrays.asList((String[]) obj));
}
obj = values.get(openOption2);
if (obj != null) {
filenameList.addAll(Arrays.asList((String[]) obj));
}
try {
for (int i = 0; i < filenameList.size(); i++) {
File file = new File(filenameList.get(i));
if (!file.isAbsolute()) {
file = new File(env.getCurrentDirectory(), filenameList.get(i));
}
FileObject fileObject = FileUtil.toFileObject(file);
if (!file.exists()) {
NotifyDescriptor.Message msg = new NotifyDescriptor.Message(NbBundle.getMessage(CommandLineProcessor.class, "CommandLineProcessor.fileNotFound", file.getName()), NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify(msg);
return;
}
if (fileObject.hasExt(GEPHI_EXTENSION)) {
ProjectControllerUI pc = Lookup.getDefault().lookup(ProjectControllerUI.class);
try {
pc.openProject(file);
} catch (Exception ew) {
ew.printStackTrace();
NotifyDescriptor.Message msg = new NotifyDescriptor.Message(NbBundle.getMessage(CommandLineProcessor.class, "CommandLineProcessor.openGephiError"), NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify(msg);
}
return;
} else {
ImportControllerUI importController = Lookup.getDefault().lookup(ImportControllerUI.class);
if (importController.getImportController().isFileSupported(FileUtil.toFile(fileObject))) {
importController.importFile(fileObject);
} else {
NotifyDescriptor.Message msg = new NotifyDescriptor.Message(NbBundle.getMessage(CommandLineProcessor.class, "CommandLineProcessor.fileNotSupported"), NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify(msg);
}
}
}
} catch (OutOfMemoryError ex) {
System.gc();
NotifyDescriptor nd = new NotifyDescriptor.Message(MEMORY_ERROR, NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(nd);
} catch (Exception ex) {
ex.printStackTrace();
NotifyDescriptor nd = new NotifyDescriptor.Message("CommandLineParsing " + ex.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(nd);
}
}
use of org.openide.NotifyDescriptor in project gephi by gephi.
the class MemoryStarvationManager method handleNotification.
@Override
public void handleNotification(Notification n, Object o) {
if (messageDelivered) {
return;
}
CompositeData cd = (CompositeData) n.getUserData();
MemoryNotificationInfo info = MemoryNotificationInfo.from(cd);
suspendThreads();
messageDelivered = true;
//Dialog
if (canIncreaseMemory()) {
String messageBundle = NbBundle.getMessage(MemoryStarvationManager.class, "OutOfMemoryError.canIncreaseMemory.message", getMb(Runtime.getRuntime().maxMemory()) + " mb", getMb(getMaximumXmx()) + " mb");
String titleBundle = NbBundle.getMessage(MemoryStarvationManager.class, "OutOfMemoryError.title");
String increaseAndRestart = NbBundle.getMessage(MemoryStarvationManager.class, "OutOfMemoryError.canIncreaseMemory.button");
String cancelBundle = NbBundle.getMessage(MemoryStarvationManager.class, "OutOfMemoryError.cancel");
NotifyDescriptor msg = new NotifyDescriptor(messageBundle, titleBundle, NotifyDescriptor.YES_NO_CANCEL_OPTION, NotifyDescriptor.ERROR_MESSAGE, new Object[] { increaseAndRestart, cancelBundle }, increaseAndRestart);
if (DialogDisplayer.getDefault().notify(msg) != increaseAndRestart) {
resumeThreads();
return;
}
String xmx = getMb(getMaximumXmx()) + "m";
try {
updateConfiguration(xmx);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
} else {
String messageBundle = NbBundle.getMessage(MemoryStarvationManager.class, "OutOfMemoryError.canIncreaseMemory.message", getMb(Runtime.getRuntime().maxMemory()) + " mb");
String titleBundle = NbBundle.getMessage(MemoryStarvationManager.class, "OutOfMemoryError.title");
String saveAndRestart = NbBundle.getMessage(MemoryStarvationManager.class, "OutOfMemoryError.canIncreaseMemory.button");
String cancelBundle = NbBundle.getMessage(MemoryStarvationManager.class, "OutOfMemoryError.cancel");
NotifyDescriptor msg = new NotifyDescriptor(messageBundle, titleBundle, NotifyDescriptor.YES_NO_CANCEL_OPTION, NotifyDescriptor.ERROR_MESSAGE, new Object[] { saveAndRestart, cancelBundle }, saveAndRestart);
if (DialogDisplayer.getDefault().notify(msg) != saveAndRestart) {
resumeThreads();
return;
}
}
interruptThreads();
freeSomeMemory();
saveProject();
restart();
}
use of org.openide.NotifyDescriptor in project gephi by gephi.
the class Delete method execute.
@Override
public void execute() {
NotifyDescriptor.Confirmation notifyDescriptor = new NotifyDescriptor.Confirmation(NbBundle.getMessage(Delete.class, "GraphContextMenu.Delete.message"), NbBundle.getMessage(Delete.class, "GraphContextMenu.Delete.message.title"), NotifyDescriptor.YES_NO_OPTION);
if (DialogDisplayer.getDefault().notify(notifyDescriptor).equals(NotifyDescriptor.YES_OPTION)) {
GraphElementsController gec = Lookup.getDefault().lookup(GraphElementsController.class);
gec.deleteNodes(nodes);
}
}
use of org.openide.NotifyDescriptor in project ACS by ACS-Community.
the class MainLauncherAction method performAction.
public void performAction() {
if (mainClassName == null) {
NotifyDescriptor usage = new NotifyDescriptor.Message("Main Class not set, use the command line option -J-D" + MAIN_CLASS_OPTION + " to set it");
GPManager.notify(usage);
return;
}
try {
Class mainClass = Class.forName(MAIN_CLASS_OPTION);
Method mainMeth = mainClass.getDeclaredMethod("main", new Class[] { String[].class });
mainMeth.invoke(null, null);
} catch (ClassNotFoundException ex) {
NotifyDescriptor err = new NotifyDescriptor.Message("class not found " + MAIN_CLASS_OPTION);
GPManager.notify(err);
} catch (NoSuchMethodException ex) {
NotifyDescriptor err = new NotifyDescriptor.Message("class " + MAIN_CLASS_OPTION + " has no main(String[]) method");
GPManager.notify(err);
} catch (IllegalAccessException ex) {
NotifyDescriptor err = new NotifyDescriptor.Message("error invoking main on class " + MAIN_CLASS_OPTION);
GPManager.notify(err);
} catch (InvocationTargetException ex) {
// the main method has been executed and thrown an exception
GPManager.notify(GPManager.EXCEPTION, ex);
}
}
Aggregations