當前位置: 首頁>>代碼示例>>Java>>正文


Java StdFileDialog類代碼示例

本文整理匯總了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();
}
 
開發者ID:richardwilkes,項目名稱:gcs,代碼行數:20,代碼來源:OutputPreferences.java

示例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);
}
 
開發者ID:richardwilkes,項目名稱:gcs,代碼行數:9,代碼來源:SheetPreferences.java

示例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;
}
 
開發者ID:Ayutac,項目名稱:toolkit,代碼行數:19,代碼來源:SaveAsCommand.java

示例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];
}
 
開發者ID:Ayutac,項目名稱:toolkit,代碼行數:15,代碼來源:ExportToCommand.java

示例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);
		}
	}
}
 
開發者ID:Ayutac,項目名稱:toolkit,代碼行數:28,代碼來源:OpenCommand.java

示例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
        }
    }
}
 
開發者ID:richardwilkes,項目名稱:gcs,代碼行數:42,代碼來源:OpenPageReferenceCommand.java

示例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;
}
 
開發者ID:richardwilkes,項目名稱:gcs,代碼行數:51,代碼來源:LibraryExplorerDockable.java


注:本文中的com.trollworks.toolkit.ui.widget.StdFileDialog類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。