本文整理汇总了Java中org.openide.filesystems.FileChooserBuilder类的典型用法代码示例。如果您正苦于以下问题:Java FileChooserBuilder类的具体用法?Java FileChooserBuilder怎么用?Java FileChooserBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileChooserBuilder类属于org.openide.filesystems包,在下文中一共展示了FileChooserBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: chooseRoots
import org.openide.filesystems.FileChooserBuilder; //导入依赖的package包/类
/**
* Open file chooser to choose search roots.
*/
private FileObject[] chooseRoots() {
FileChooserBuilder chooserBuilder =
new FileChooserBuilder(SearchScopeBrowse.class);
chooserBuilder.setTitle(UiUtils.getText(
"LBL_ScopeBrowseFileChooserTitle")); //NOI18N
chooserBuilder.setApproveText(UiUtils.getText(
"LBL_ScopeBrowseFileChooserApprove")); //NOI18N
File[] files = chooserBuilder.showMultiOpenDialog();
if (files == null) {
files = new File[0];
}
List<File> existingFiles = selectExistingFiles(files);
FileObject[] fileObjects = new FileObject[existingFiles.size()];
for (int i = 0; i < existingFiles.size(); i++) {
fileObjects[i] = FileUtil.toFileObject(existingFiles.get(i));
}
if (fileObjects.length > 0) {
roots = fileObjects;
}
return fileObjects;
}
示例2: saveToFile
import org.openide.filesystems.FileChooserBuilder; //导入依赖的package包/类
private void saveToFile() {
final File file = new FileChooserBuilder(AttachmentsPanel.class)
.setFilesOnly(true).showSaveDialog();
if (file != null) {
String progressFormat = NbBundle.getMessage(
SaveAttachmentAction.class,
"Attachment.saveToFile.progress"); //NOI18N
String progressMessage = MessageFormat.format(progressFormat, getFilename());
final ProgressHandle handle = ProgressHandleFactory.createHandle(progressMessage);
handle.start();
handle.switchToIndeterminate();
Support.getInstance().getParallelRP().post(new Runnable() {
@Override
public void run() {
try {
getAttachmentData(file);
} catch (IOException ioex) {
LOG.log(Level.INFO, ioex.getMessage(), ioex);
} finally {
handle.finish();
}
}
});
}
}
示例3: actionPerformed
import org.openide.filesystems.FileChooserBuilder; //导入依赖的package包/类
@Override
@NbBundle.Messages("DLG_SaveToFile=Save to File")
public void actionPerformed(ActionEvent e) {
// Save
FileChooserBuilder fchb = new FileChooserBuilder(BigStringCustomEditor.class);
fchb.setTitle(Bundle.DLG_SaveToFile());
final File f = fchb.showSaveDialog();
if (f != null) {
new RequestProcessor(BigStringCustomEditor.class).post(new Runnable() {
@Override
public void run() {
save(f);
}
});
}
}
示例4: save
import org.openide.filesystems.FileChooserBuilder; //导入依赖的package包/类
@Override
public void save() throws IOException {
FileChooserBuilder fchb = new FileChooserBuilder(ScreenshotComponent.class);
String[] writerFileSuffixes = ImageIO.getWriterFileSuffixes();
fchb.setFileFilter(new FileNameExtensionFilter(Bundle.CTL_ImageFiles(), writerFileSuffixes));
File file = fchb.showSaveDialog();
if (file != null) {
if (file.exists()) {
NotifyDescriptor nd = new NotifyDescriptor.Confirmation(Bundle.MSG_Overwrite(file.getName()), toString());
Object doOverwrite = DialogDisplayer.getDefault().notify(nd);
if (!NotifyDescriptor.YES_OPTION.equals(doOverwrite)) {
return ;
}
}
canvas.save(file);
}
}
示例5: buildContextButtonActionPerformed
import org.openide.filesystems.FileChooserBuilder; //导入依赖的package包/类
private void buildContextButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buildContextButtonActionPerformed
FileChooserBuilder builder = FileChooserBuilder.create(fileSystem);
JFileChooser fileChooser = builder.createFileChooser();
fileChooser.setApproveButtonText(NbBundle.getMessage(BuildContextVisual.class, "BuildContextVisual.fileChooser.button")); // NOI18M
fileChooser.setDialogTitle(NbBundle.getMessage(BuildContextVisual.class, "BuildContextVisual.fileChooser.dialogTitle")); // NOI18M
fileChooser.setFileSelectionMode(0);
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
String buildText = UiUtils.getValue(buildContextTextField);
if (buildText != null) {
fileChooser.setSelectedFile(new File(buildText));
}
if (fileChooser.showOpenDialog(SwingUtilities.getWindowAncestor(this)) == JFileChooser.APPROVE_OPTION) {
buildContextTextField.setText(fileChooser.getSelectedFile().getAbsolutePath());
}
}
示例6: setSelectedItem
import org.openide.filesystems.FileChooserBuilder; //导入依赖的package包/类
public void setSelectedItem(Object item) {
String oldSelectedItem = selectedItem;
selectedItem = (String) item;
if (names.indexOf(item) != -1) {
if (types.get(names.indexOf(selectedItem)).equals(
SuiteInstallerProjectProperties.LICENSE_TYPE_CUSTOM)) {
File home = FileUtil.toFile(suiteProject.getProjectDirectory());
File licenseFile = new FileChooserBuilder("installer-license-dir").setTitle(NbBundle.getMessage(LicenseComboBoxModel.class, "InstallerPanel_License.FileChooser.Title")).
setDefaultWorkingDirectory(home).setFilesOnly(true).showOpenDialog();
if (licenseFile != null) {
names.add(licenseFile.getAbsolutePath());
types.add(SuiteInstallerProjectProperties.LICENSE_TYPE_FILE);
selectedItem = names.get(names.size() - 1);
} else {
selectedItem = oldSelectedItem;
}
}
selectedItemFromList = true;
} else {
selectedItemFromList = false;
}
fireContentsChanged(-1);
}
示例7: prepareFileChooser
import org.openide.filesystems.FileChooserBuilder; //导入依赖的package包/类
/**
* Creates and initializes a file chooser.
*
* @return the initialized file chooser
*/
protected JFileChooser prepareFileChooser() {
FileChooserBuilder fcb = new FileChooserBuilder(OpenFileAction.class);
fcb.setSelectionApprover(new OpenFileSelectionApprover());
fcb.setFilesOnly(true);
fcb.addDefaultFileFilters();
for (OpenFileDialogFilter filter :
Lookup.getDefault().lookupAll(OpenFileDialogFilter.class)) {
fcb.addFileFilter(filter);
}
JFileChooser chooser = fcb.createFileChooser();
chooser.setMultiSelectionEnabled(true);
chooser.getCurrentDirectory().listFiles(); //preload
chooser.setCurrentDirectory(getCurrentDirectory());
if (currentFileFilter != null) {
for (FileFilter ff : chooser.getChoosableFileFilters()) {
if (currentFileFilter.equals(ff.getDescription())) {
chooser.setFileFilter(ff);
break;
}
}
}
HelpCtx.setHelpIDString(chooser, getHelpCtx().getHelpID());
return chooser;
}
示例8: jButton1ActionPerformed
import org.openide.filesystems.FileChooserBuilder; //导入依赖的package包/类
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
FileChooserBuilder builder = new FileChooserBuilder(AndroidSdkTool.class);
builder.setTitle("Please select Android SDK Folder");
builder.setDirectoriesOnly(true);
File file = builder.showOpenDialog();
if (file != null) {
FileObject folder = FileUtil.toFileObject(file);
if (folder.getFileObject("tools") == null) {
Message msg = new NotifyDescriptor.Message(
"Not a valid SDK folder!",
NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notifyLater(msg);
} else {
String name = file.getPath();
jTextField1.setText(name);
}
}
}
示例9: jButton1ActionPerformed
import org.openide.filesystems.FileChooserBuilder; //导入依赖的package包/类
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// File path = new File(jTextField1.getText());
// if (path.isDirectory()) {
FileChooserBuilder builder = new FileChooserBuilder(this.getClass());
builder.setDirectoriesOnly(true);
builder.setTitle("Select Project Folder");
File file = builder.showOpenDialog();
if (file != null) {
try {
jTextField1.setText(file.getAbsolutePath() + File.separator + jTextField2.getText());
} catch (Exception e) {
}
}
// }
}
示例10: jButton2ActionPerformed
import org.openide.filesystems.FileChooserBuilder; //导入依赖的package包/类
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
String pathName = jTextField1.getText();
File path = new File(pathName);
if (path.isDirectory()) {
FileChooserBuilder builder = new FileChooserBuilder(getClass());
builder.setDefaultWorkingDirectory(path);
builder.setDirectoriesOnly(true);
builder.setTitle("Select Assets Folder");
File file = builder.showOpenDialog();
if (file != null) {
file = FileUtil.normalizeFile(file);
try {
jTextField2.setText(file.getAbsolutePath().substring(pathName.length(), file.getAbsolutePath().length()));
panel.fireChangeEvent();
} catch (Exception e) {
}
}
}
}
示例11: buttonLoadActionPerformed
import org.openide.filesystems.FileChooserBuilder; //导入依赖的package包/类
private void buttonLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonLoadActionPerformed
final File home = new File(System.getProperty("user.home")); //NOI18N
final File toOpen = new FileChooserBuilder("user-home-dir"). //NOI18N
setTitle(java.util.ResourceBundle.getBundle("com/igormaznitsa/nbmindmap/i18n/Bundle").getString("PlainTextEditor.buttonLoadActionPerformed.title")).
addFileFilter(TEXT_FILE_FILTER).setFileFilter(TEXT_FILE_FILTER).
setFilesOnly(true).
setDefaultWorkingDirectory(home).
showOpenDialog();
if (toOpen != null) {
try {
final String text = FileUtils.readFileToString(toOpen, "UTF-8"); //NOI18N
setText(text);
}
catch (Exception ex) {
LOGGER.error("Error during text file loading", ex); //NOI18N
NbUtils.msgError(null, java.util.ResourceBundle.getBundle("com/igormaznitsa/nbmindmap/i18n/Bundle").getString("PlainTextEditor.buttonLoadActionPerformed.msgError"));
}
}
}
示例12: buttonSaveActionPerformed
import org.openide.filesystems.FileChooserBuilder; //导入依赖的package包/类
private void buttonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSaveActionPerformed
final File home = new File(System.getProperty("user.home")); //NOI18N
final File toSave = new FileChooserBuilder("user-home-dir").
setTitle(java.util.ResourceBundle.getBundle("com/igormaznitsa/nbmindmap/i18n/Bundle").getString("PlainTextEditor.buttonSaveActionPerformed.saveTitle")).
addFileFilter(TEXT_FILE_FILTER).setFileFilter(TEXT_FILE_FILTER).
setFilesOnly(true).
setDefaultWorkingDirectory(home).
showSaveDialog();
if (toSave != null) {
try {
final String text = getText();
FileUtils.writeStringToFile(toSave, text, "UTF-8"); //NOI18N
}
catch (Exception ex) {
LOGGER.error("Error during text file saving", ex); //NOI18N
NbUtils.msgError(null, java.util.ResourceBundle.getBundle("com/igormaznitsa/nbmindmap/i18n/Bundle").getString("PlainTextEditor.buttonSaveActionPerformed.msgError"));
}
}
}
示例13: actionPerformed
import org.openide.filesystems.FileChooserBuilder; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
EGTaskDataObjectDataObject dto = CentralLookup.getDefLookup().lookup(EGTaskDataObjectDataObject.class);
File toLoad = new FileChooserBuilder("Create_CVS_FILE")
.setTitle("Create cvs file")
.setDefaultWorkingDirectory(new File(System.getProperty("user.home")))
.setApproveText("ok")
.setDirectoriesOnly(false)
.setFilesOnly(true)
.setAcceptAllFileFilterUsed(false)
.addFileFilter(new FileNameExtensionFilter("CVS File", "csv","CSV"))
.showSaveDialog();
if(toLoad != null) {
if(!(toLoad.getName().contains(".csv") || toLoad.getName().contains(".CSV"))) {
StringBuilder sb = new StringBuilder(toLoad.getAbsolutePath());
sb.append(".csv");
toLoad = new File(sb.toString());
}
File basefile = FileUtil.toFile(dto.getPrimaryFile());
text.setText(transformFilePaths.relativize(basefile.getAbsolutePath(), toLoad.getAbsolutePath()));
}
}
示例14: actionPerformed
import org.openide.filesystems.FileChooserBuilder; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
File home = new File(System.getProperty("user.home"));
File toLoad = new FileChooserBuilder(" 'Instance/Schema' XML File")
.setTitle("Choose File")
.setDefaultWorkingDirectory(home)
.setApproveText("OK")
.setAcceptAllFileFilterUsed(false)
.addFileFilter(new FileNameExtensionFilter("XML import file", "xml","XML"))
.showOpenDialog();
if(toLoad==null){
return;
}
FileObject fo = FileUtil.toFileObject(toLoad);
if(fo.isFolder()){
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message("Select 'file.xml' no folder", NotifyDescriptor.INFORMATION_MESSAGE));
return;
}
field.setText(fo.getPath());
}
示例15: actionPerformed
import org.openide.filesystems.FileChooserBuilder; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
File home = new File(System.getProperty("user.home"));
File toLoad = new FileChooserBuilder("EGTAK_CONF_FILE")
.setTitle("Load File")
.setDefaultWorkingDirectory(home)
.setApproveText("Load")
.setFilesOnly(true)
.setAcceptAllFileFilterUsed(false)
.addFileFilter(new FileNameExtensionFilter("XML Configuration", "xml","XML"))
.showOpenDialog();
if(toLoad==null){
return;
}
FileObject fo = FileUtil.toFileObject(toLoad);
if(fo.isFolder()){
DialogDisplayer.getDefault().notify(myNotify("Select xml file no a folder"));
return;
}
if(!controlFile(fo))return;
ILoadEGTask load = Lookup.getDefault().lookup(ILoadEGTask.class);
load.load(fo);
}