use of org.openide.NotifyDescriptor in project blue by kunstmusik.
the class BlueProjectManager method save.
public void save() {
if (getCurrentProject().getDataFile() != null) {
try (PrintWriter out = new PrintWriter(new FileWriter(getCurrentProject().getDataFile()))) {
out.print(getCurrentProject().getData().saveAsXML().toString());
out.flush();
} catch (IOException ioe) {
NotifyDescriptor descriptor = new NotifyDescriptor.Message("Could not save file:\n\n" + ioe.getLocalizedMessage(), NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(descriptor);
} catch (Exception e) {
e.printStackTrace();
}
StatusDisplayer.getDefault().setStatusText("File saved: " + getCurrentProject().getDataFile().getName());
} else {
saveAs();
}
}
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) {
Exceptions.printStackTrace(ew);
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) {
Exceptions.printStackTrace(ex);
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 netbeans-mmd-plugin by raydac.
the class NbUtils method msgConfirmYesNoCancel.
@Nullable
public static Boolean msgConfirmYesNoCancel(@Nullable Component parentComponent, @Nonnull final String title, @Nonnull final String query) {
final NotifyDescriptor desc = new NotifyDescriptor.Confirmation(query, title, NotifyDescriptor.YES_NO_CANCEL_OPTION);
final Object obj = DialogDisplayer.getDefault().notify(desc);
if (NotifyDescriptor.CANCEL_OPTION.equals(obj)) {
return null;
}
return NotifyDescriptor.YES_OPTION.equals(obj);
}
Aggregations