本文整理汇总了Java中com.trollworks.toolkit.ui.widget.StdFileDialog类的典型用法代码示例。如果您正苦于以下问题:Java StdFileDialog类的具体用法?Java StdFileDialog怎么用?Java StdFileDialog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StdFileDialog类属于com.trollworks.toolkit.ui.widget包,在下文中一共展示了StdFileDialog类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import com.trollworks.toolkit.ui.widget.StdFileDialog; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent event) {
Object source = event.getSource();
if (source == mPNGResolutionCombo) {
Preferences.getInstance().setValue(MODULE, PNG_RESOLUTION_KEY, DPI[mPNGResolutionCombo.getSelectedIndex()]);
} else if (source == mTextTemplatePicker) {
File file = StdFileDialog.showOpenDialog(this, SELECT_TEXT_TEMPLATE);
if (file != null) {
mTextTemplatePath.setText(PathUtils.getFullPath(file));
}
} else if (source == mGurpsCalculatorLink && Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().browse(new URI(GURPS_CALCULATOR_URL));
} catch (Exception exception) {
WindowUtils.showError(this, MessageFormat.format(UNABLE_TO_OPEN_URL, GURPS_CALCULATOR_URL));
}
}
adjustResetButton();
}
示例2: choosePortrait
import com.trollworks.toolkit.ui.widget.StdFileDialog; //导入依赖的package包/类
public static File choosePortrait() {
List<FileNameExtensionFilter> filters = new ArrayList<>();
filters.add(new FileNameExtensionFilter(ALL_READABLE_IMAGE_FILES, FileType.PNG_EXTENSION, FileType.JPEG_EXTENSION, "jpeg", FileType.GIF_EXTENSION)); //$NON-NLS-1$
filters.add(FileType.getPngFilter());
filters.add(FileType.getJpegFilter());
filters.add(FileType.getGifFilter());
return StdFileDialog.showOpenDialog(null, SELECT_PORTRAIT, filters);
}
示例3: saveAs
import com.trollworks.toolkit.ui.widget.StdFileDialog; //导入依赖的package包/类
/**
* Allows the user to save the file under another name.
*
* @param saveable The {@link Saveable} to work on.
* @return The file(s) actually written to. May be empty.
*/
public static File[] saveAs(Saveable saveable) {
if (saveable == null) {
return new File[0];
}
String path = saveable.getPreferredSavePath();
File result = StdFileDialog.choose(UIUtilities.getComponentForDialog(saveable), false, SAVE_AS, PathUtils.getParent(path), PathUtils.getLeafName(path), saveable.getAllowedExtensions());
File[] files = result != null ? saveable.saveTo(result) : new File[0];
for (File file : files) {
RecentFilesMenu.addRecent(file);
}
return files;
}
示例4: saveAs
import com.trollworks.toolkit.ui.widget.StdFileDialog; //导入依赖的package包/类
/**
* Allows the user to save the file under another name.
*
* @param saveable The {@link Saveable} to work on.
* @return The file(s) actually written to.
*/
public File[] saveAs(Saveable saveable) {
if (saveable == null) {
return new File[0];
}
String path = saveable.getPreferredSavePath();
File result = StdFileDialog.choose(saveable instanceof Component ? (Component) saveable : null, false, (String) getValue(NAME), PathUtils.getParent(path), PathUtils.getLeafName(path), mExtension);
return result != null ? saveable.saveTo(result) : new File[0];
}
示例5: open
import com.trollworks.toolkit.ui.widget.StdFileDialog; //导入依赖的package包/类
/** @param file The file to open. */
public static void open(File file) {
if (file != null) {
try {
String name = file.getName();
FileProxy proxy = AppWindow.findFileProxy(file);
if (proxy == null) {
for (FileType type : FileType.getOpenable()) {
if (name.matches(StdFileDialog.createExtensionMatcher(type.getExtension()))) {
proxy = type.getFileProxyCreator().create(file);
break;
}
}
} else {
proxy.toFrontAndFocus();
}
if (proxy != null) {
RecentFilesMenu.addRecent(file);
} else {
throw new IOException("Unknown file extension"); //$NON-NLS-1$
}
} catch (Exception exception) {
Log.error(exception);
StdFileDialog.showCannotOpenMsg(getFocusOwner(), file.getName(), exception);
}
}
}
示例6: openReference
import com.trollworks.toolkit.ui.widget.StdFileDialog; //导入依赖的package包/类
public static void openReference(String reference, String highlight) {
int i = reference.length() - 1;
while (i >= 0) {
char ch = reference.charAt(i);
if (ch >= '0' && ch <= '9') {
i--;
} else {
i++;
break;
}
}
if (i > 0) {
String id = reference.substring(0, i);
try {
int page = Integer.parseInt(reference.substring(i));
PdfRef ref = PdfRef.lookup(id, true);
if (ref == null) {
File file = StdFileDialog.showOpenDialog(getFocusOwner(), String.format(LOCATE_PDF, id), new FileNameExtensionFilter(PDF_FILE, FileType.PDF_EXTENSION));
if (file != null) {
ref = new PdfRef(id, file, 0);
ref.save();
}
}
if (ref != null) {
Path path = ref.getFile().toPath();
LibraryExplorerDockable library = LibraryExplorerDockable.get();
PdfDockable dockable = (PdfDockable) library.getDockableFor(path);
if (dockable != null) {
dockable.goToPage(ref, page, highlight);
dockable.getDockContainer().setCurrentDockable(dockable);
} else {
dockable = new PdfDockable(ref, page, highlight);
library.dockPdf(dockable);
library.open(path);
}
}
} catch (NumberFormatException nfex) {
// Ignore
}
}
}
示例7: open
import com.trollworks.toolkit.ui.widget.StdFileDialog; //导入依赖的package包/类
public FileProxy open(Path path) {
// See if it is already open
FileProxy proxy = (FileProxy) getDockableFor(path);
if (proxy == null) {
// If it wasn't, load it and put it into the dock
try {
switch (PathUtils.getExtension(path)) {
case AdvantageList.EXTENSION:
proxy = openAdvantageList(path);
break;
case EquipmentList.EXTENSION:
proxy = openEquipmentList(path);
break;
case SkillList.EXTENSION:
proxy = openSkillList(path);
break;
case SpellList.EXTENSION:
proxy = openSpellList(path);
break;
case LibraryFile.EXTENSION:
proxy = openLibrary(path);
break;
case GURPSCharacter.EXTENSION:
proxy = dockSheet(new SheetDockable(new GURPSCharacter(path.toFile())));
break;
case Template.EXTENSION:
proxy = dockTemplate(new TemplateDockable(new Template(path.toFile())));
break;
case FileType.PDF_EXTENSION:
proxy = dockPdf(new PdfDockable(new PdfRef(null, path.toFile(), 0), 1, null));
break;
default:
break;
}
} catch (Throwable throwable) {
StdFileDialog.showCannotOpenMsg(this, PathUtils.getLeafName(path, true), throwable);
proxy = null;
}
} else {
Dockable dockable = (Dockable) proxy;
dockable.getDockContainer().setCurrentDockable(dockable);
}
if (proxy != null) {
File file = proxy.getBackingFile();
if (file != null) {
RecentFilesMenu.addRecent(file);
}
}
return proxy;
}