use of org.openide.util.NbBundle.Messages in project netbeans-rcp-lite by outersky.
the class InternalSampler method saveSnapshot.
@Override
@Messages("SelfSamplerAction_SavedFile=Snapshot was saved to {0}")
protected void saveSnapshot(byte[] arr) throws IOException {
// save snapshot
File outFile = File.createTempFile(SAMPLER_NAME, SamplesOutputStream.FILE_EXT);
File userDir = Places.getUserDirectory();
File gestures = null;
SelfSampleVFS fs;
outFile = FileUtil.normalizeFile(outFile);
writeToFile(outFile, arr);
if (userDir != null) {
// NOI18N
gestures = new File(new File(new File(userDir, "var"), "log"), "uigestures");
}
if (gestures != null && gestures.exists()) {
// NOI18N
fs = new SelfSampleVFS(new String[] { FILE_NAME, SAMPLER_NAME + ".log" }, new File[] { outFile, gestures });
} else {
fs = new SelfSampleVFS(new String[] { FILE_NAME }, new File[] { outFile });
}
// open snapshot
FileObject fo = fs.findResource(FILE_NAME);
// test for DefaultDataObject
if (UNKNOW_MIME_TYPE.equals(fo.getMIMEType())) {
String msg = SelfSamplerAction_SavedFile(outFile.getAbsolutePath());
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(msg));
} else {
DataObject dobj = DataObject.find(fo);
dobj.getLookup().lookup(Openable.class).open();
}
}
use of org.openide.util.NbBundle.Messages in project netbeans-rcp-lite by outersky.
the class TemplatesPanel method doNewFolder.
@Messages("TXT_TemplatesPanel_NewFolderName=New Folder")
private static DataFolder doNewFolder(Node[] nodes) {
DataFolder df = null;
// new folder
DataFolder pref = getTargetFolder(nodes);
if (pref == null) {
pref = DataFolder.findFolder(getTemplatesRoot());
assert pref != null : "DataFolder found for FO " + getTemplatesRoot();
}
// #161963: Create new DataFolder if DataFolder with given name already exists
String baseName = TXT_TemplatesPanel_NewFolderName();
String name = baseName;
DataObject[] arr = pref.getChildren();
boolean exists = true;
int counter = 0;
while (exists) {
exists = false;
for (int i = 0; i < arr.length; i++) {
if (name.equals(arr[i].getName())) {
counter++;
name = baseName + " " + counter;
exists = true;
break;
}
}
}
try {
df = DataFolder.create(pref, name);
assert df != null : "New subfolder found in folder " + pref;
} catch (IOException ioe) {
Logger.getLogger(TemplatesPanel.class.getName()).log(Level.WARNING, null, ioe);
}
return df;
}
use of org.openide.util.NbBundle.Messages in project netbeans-rcp-lite by outersky.
the class TemplatesPanel method showRename.
@Messages("RenameTemplatePanel.title.text=Rename Template")
private static void showRename(TemplateNode n) {
String name = n.getFileName();
String displayName = n.getDisplayName();
FileObject fo = n.getLookup().lookup(FileObject.class);
RenameTemplatePanel editPanel = new RenameTemplatePanel(isUserFile(fo));
if (LICENSES_FOLDER.equals(fo.getParent().getPath())) {
editPanel.setIsLicense(true);
}
editPanel.setOtherFileNames(getOtherFileNames(n));
String title = RenameTemplatePanel_title_text();
DialogDescriptor dd = new DialogDescriptor(editPanel, title);
editPanel.setDescriptor(dd);
editPanel.setFileName(name);
editPanel.setFileDisplayName(displayName);
Object res = DialogDisplayer.getDefault().notify(dd);
if (DialogDescriptor.OK_OPTION.equals(res)) {
name = editPanel.getFileName();
displayName = editPanel.getFileDisplayName();
n.setFileName(name);
try {
fo.setAttribute(TEMPLATE_DISPLAY_NAME_ATTRIBUTE, displayName);
fo.setAttribute(TEMPLATE_LOCALIZING_BUNDLE_ATTRIBUTE, null);
} catch (IOException ex) {
Logger.getLogger(TemplatesPanel.class.getName()).log(Level.WARNING, null, ex);
}
n.setDisplayName(displayName);
}
}
use of org.openide.util.NbBundle.Messages in project netbeans-rcp-lite by outersky.
the class TemplatesPanel method doAdd.
@Messages({ "LBL_TemplatesPanel_JFileChooser_Title=Add Existing Template", "BTN_TemplatesPanel_JFileChooser_AddButtonName=Add", "# {0} - file name", "MSG_TemplatesPanel_Nonexistent_File=File ''{0}''\ndoes not exist, please specify an existing file." })
private static void doAdd(final Node[] nodes) {
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle(LBL_TemplatesPanel_JFileChooser_Title());
chooser.setApproveButtonText(BTN_TemplatesPanel_JFileChooser_AddButtonName());
chooser.setFileHidingEnabled(false);
chooser.setMultiSelectionEnabled(false);
int result = chooser.showOpenDialog(null);
if (JFileChooser.APPROVE_OPTION == result) {
final File f = chooser.getSelectedFile();
assert f != null;
if (!f.isFile()) {
NotifyDescriptor.Message msg = new NotifyDescriptor.Message(MSG_TemplatesPanel_Nonexistent_File(f));
DialogDisplayer.getDefault().notify(msg);
} else {
rp.post(new Runnable() {
@Override
public void run() {
DataObject template = createTemplateFromFile(f, getTargetFolder(nodes));
final Node node = getTemplateNode(template.getPrimaryFile());
if (node != null) {
try {
manager.setSelectedNodes(new Node[] { node });
} catch (PropertyVetoException ex) {
}
}
}
});
}
}
}
Aggregations