use of org.openide.loaders.SaveAsCapable in project netbeans-rcp-lite by outersky.
the class SaveAsAction method actionPerformed.
public void actionPerformed(ActionEvent e) {
refreshListeners();
Collection<? extends SaveAsCapable> inst = lkpInfo.allInstances();
if (inst.size() > 0) {
SaveAsCapable saveAs = inst.iterator().next();
File newFile = getNewFileName();
if (null != newFile) {
// create target folder if necessary
FileObject newFolder = null;
try {
File targetFolder = newFile.getParentFile();
if (null == targetFolder)
throw new IOException(newFile.getAbsolutePath());
newFolder = FileUtil.createFolder(targetFolder);
} catch (IOException ioE) {
NotifyDescriptor error = new NotifyDescriptor(// NOI18N
NbBundle.getMessage(DataObject.class, "MSG_CannotCreateTargetFolder"), // NOI18N
NbBundle.getMessage(DataObject.class, "LBL_SaveAsTitle"), NotifyDescriptor.DEFAULT_OPTION, NotifyDescriptor.ERROR_MESSAGE, new Object[] { NotifyDescriptor.OK_OPTION }, NotifyDescriptor.OK_OPTION);
DialogDisplayer.getDefault().notify(error);
return;
}
try {
saveAs.saveAs(newFolder, newFile.getName());
} catch (IOException ioE) {
Exceptions.attachLocalizedMessage(ioE, // NOI18N
NbBundle.getMessage(// NOI18N
DataObject.class, // NOI18N
"MSG_SaveAsFailed", newFile.getName(), ioE.getLocalizedMessage()));
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ioE);
}
}
}
}
use of org.openide.loaders.SaveAsCapable in project constellation by constellation-app.
the class SaveAsAction method actionPerformed.
@Override
public void actionPerformed(final ActionEvent e) {
refreshListeners();
final Collection<? extends SaveAsCapable> inst = lkpInfo.allInstances();
if (!inst.isEmpty()) {
final SaveAsCapable saveAs = inst.iterator().next();
final File newFile = getNewFileName();
if (newFile != null) {
try {
saveAs.saveAs(FileUtil.toFileObject(newFile.getParentFile()), newFile.getName());
// take a screenshot in a separate thread in parrallel
new Thread(() -> RecentGraphScreenshotUtilities.takeScreenshot(newFile.getName()), "Take Graph Screenshot").start();
} catch (final IOException ioE) {
Exceptions.attachLocalizedMessage(ioE, Bundle.MSG_SaveAsFailed(newFile.getName(), ioE.getLocalizedMessage()));
LOGGER.log(Level.SEVERE, null, ioE);
}
isSaved = true;
}
}
}
use of org.openide.loaders.SaveAsCapable in project constellation by constellation-app.
the class SaveAsAction method refreshEnabled.
private void refreshEnabled() {
if (lkpInfo == null) {
// The thing we want to listen for the presence or absence of
// on the global selection
Lookup.Template<SaveAsCapable> tpl = new Lookup.Template<>(SaveAsCapable.class);
lkpInfo = context.lookup(tpl);
}
TopComponent tc = TopComponent.getRegistry().getActivated();
boolean isEditorWindowActivated = tc != null && WindowManager.getDefault().isEditorTopComponent(tc);
setEnabled(lkpInfo != null && !lkpInfo.allItems().isEmpty() && isEditorWindowActivated);
isDirty = false;
}
use of org.openide.loaders.SaveAsCapable in project netbeans-rcp-lite by outersky.
the class SaveAsAction method refreshEnabled.
private void refreshEnabled() {
if (lkpInfo == null) {
// The thing we want to listen for the presence or absence of
// on the global selection
Lookup.Template<SaveAsCapable> tpl = new Lookup.Template<SaveAsCapable>(SaveAsCapable.class);
lkpInfo = context.lookup(tpl);
}
TopComponent tc = TopComponent.getRegistry().getActivated();
boolean isEditorWindowActivated = null != tc && WindowManager.getDefault().isEditorTopComponent(tc);
setEnabled(null != lkpInfo && lkpInfo.allItems().size() != 0 && isEditorWindowActivated);
isDirty = false;
}
Aggregations