本文整理匯總了Java中com.trollworks.toolkit.utility.Platform類的典型用法代碼示例。如果您正苦於以下問題:Java Platform類的具體用法?Java Platform怎麽用?Java Platform使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Platform類屬於com.trollworks.toolkit.utility包,在下文中一共展示了Platform類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: configureApplication
import com.trollworks.toolkit.utility.Platform; //導入依賴的package包/類
@Override
public void configureApplication(CmdLine cmdLine) {
if (Platform.isWindows()) {
Map<String, String> map = new HashMap<>();
for (FileType fileType : FileType.getAll()) {
if (fileType.shouldRegisterAppForOpening()) {
map.put(fileType.getExtension(), fileType.getDescription());
}
}
Path home = App.getHomePath();
WindowsRegistry.register("GCS", map, home.resolve("gcs"), home.resolve("support")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
UpdateChecker.check("gcs", WEB_SITE + "/versions.txt", WEB_SITE); //$NON-NLS-1$ //$NON-NLS-2$
ListCollectionThread.get();
StdMenuBar.configure(new FileMenuProvider(), new EditMenuProvider(), new ItemMenuProvider(), new HelpMenuProvider());
OutputPreferences.initialize(); // Must come before SheetPreferences.initialize()
SheetPreferences.initialize();
PreferencesWindow.addCategory(SheetPreferences::new);
PreferencesWindow.addCategory(OutputPreferences::new);
PreferencesWindow.addCategory(FontPreferences::new);
PreferencesWindow.addCategory(MenuKeyPreferences::new);
PreferencesWindow.addCategory(ReferenceLookupPreferences::new);
}
示例2: createMenu
import com.trollworks.toolkit.utility.Platform; //導入依賴的package包/類
@Override
public JMenu createMenu() {
JMenu menu = new JMenu(HELP);
menu.setName(NAME);
if (!Platform.isMacintosh()) {
menu.add(new JMenuItem(AboutCommand.INSTANCE));
menu.addSeparator();
}
menu.add(new JMenuItem(UpdateCommand.INSTANCE));
menu.addSeparator();
menu.add(new JMenuItem(new OpenURICommand(RELEASE_NOTES, GCSApp.WEB_SITE + "/release_notes.html"))); //$NON-NLS-1$
menu.add(new JMenuItem(new OpenURICommand(LICENSE, App.getHomePath().resolve("license.html").toUri()))); //$NON-NLS-1$
menu.addSeparator();
menu.add(new JMenuItem(new OpenURICommand(WEB_SITE, GCSApp.WEB_SITE)));
menu.add(new JMenuItem(new OpenURICommand(MAILING_LISTS, GCSApp.WEB_SITE + "/mailing_lists.html"))); //$NON-NLS-1$
menu.add(new JMenuItem(new OpenURICommand(FEATURE_REQUESTS, "https://gurpscharactersheet.atlassian.net/issues/?filter=10000"))); //$NON-NLS-1$
menu.add(new JMenuItem(new OpenURICommand(BUG_REPORTS, "https://gurpscharactersheet.atlassian.net/issues/?filter=10001"))); //$NON-NLS-1$
DynamicMenuEnabler.add(menu);
return menu;
}
示例3: getModifiableCommands
import com.trollworks.toolkit.utility.Platform; //導入依賴的package包/類
@Override
public Set<Command> getModifiableCommands() {
Set<Command> cmds = new HashSet<>();
cmds.add(NewCharacterSheetCommand.INSTANCE);
cmds.add(NewCharacterTemplateCommand.INSTANCE);
cmds.add(NewAdvantagesLibraryCommand.INSTANCE);
cmds.add(NewEquipmentLibraryCommand.INSTANCE);
cmds.add(NewNoteLibraryCommand.INSTANCE);
cmds.add(NewSkillsLibraryCommand.INSTANCE);
cmds.add(NewSpellsLibraryCommand.INSTANCE);
cmds.add(OpenCommand.INSTANCE);
cmds.add(CloseCommand.INSTANCE);
cmds.add(SaveCommand.INSTANCE);
cmds.add(SaveAsCommand.INSTANCE);
cmds.add(ExportToGurpsCalculatorCommand.INSTANCE);
cmds.add(PageSetupCommand.INSTANCE);
cmds.add(PrintCommand.INSTANCE);
if (!Platform.isMacintosh()) {
cmds.add(QuitCommand.INSTANCE);
}
return cmds;
}
示例4: addRecent
import com.trollworks.toolkit.utility.Platform; //導入依賴的package包/類
/** @param file The {@link File} to add to the recents list. */
public static void addRecent(File file) {
String extension = PathUtils.getExtension(file.getName());
if (Platform.isMacintosh() || Platform.isWindows()) {
extension = extension.toLowerCase();
}
for (String allowed : FileType.getOpenableExtensions()) {
if (allowed.equals(extension)) {
if (file.canRead()) {
file = PathUtils.getFile(PathUtils.getFullPath(file));
RECENTS.remove(file);
RECENTS.add(0, file);
if (RECENTS.size() > MAX_RECENTS) {
RECENTS.remove(MAX_RECENTS);
}
}
break;
}
}
}
示例5: createMenu
import com.trollworks.toolkit.utility.Platform; //導入依賴的package包/類
@Override
public JMenu createMenu() {
JMenu menu = new JMenu("Edit"); //$NON-NLS-1$
menu.add(new DynamicMenuItem(UndoCommand.INSTANCE));
menu.add(new DynamicMenuItem(RedoCommand.INSTANCE));
menu.addSeparator();
menu.add(new DynamicMenuItem(CutCommand.INSTANCE));
menu.add(new DynamicMenuItem(CopyCommand.INSTANCE));
menu.add(new DynamicMenuItem(PasteCommand.INSTANCE));
menu.add(new DynamicMenuItem(DuplicateCommand.INSTANCE));
menu.add(new DynamicMenuItem(DeleteCommand.INSTANCE));
menu.add(new DynamicMenuItem(SelectAllCommand.INSTANCE));
if (!Platform.isMacintosh()) {
menu.addSeparator();
menu.add(new DynamicMenuItem(PreferencesCommand.INSTANCE));
}
DynamicMenuEnabler.add(menu);
return menu;
}
示例6: finalStartup
import com.trollworks.toolkit.utility.Platform; //導入依賴的package包/類
@Override
public void finalStartup() {
super.finalStartup();
setDefaultMenuBar(new StdMenuBar());
if (Platform.isMacintosh() && App.getHomePath().toString().toLowerCase().contains("/apptranslocation/")) { //$NON-NLS-1$
WindowUtils.showError(null, Text.wrapToCharacterCount(TRANSLOCATION_INSTRUCTIONS, 60) + XATTR_CMD);
}
}
示例7: getModifiableCommands
import com.trollworks.toolkit.utility.Platform; //導入依賴的package包/類
@Override
public Set<Command> getModifiableCommands() {
Set<Command> cmds = new HashSet<>();
cmds.add(UndoCommand.INSTANCE);
cmds.add(RedoCommand.INSTANCE);
cmds.add(CutCommand.INSTANCE);
cmds.add(CopyCommand.INSTANCE);
cmds.add(PasteCommand.INSTANCE);
cmds.add(DuplicateCommand.INSTANCE);
cmds.add(DeleteCommand.INSTANCE);
cmds.add(SelectAllCommand.INSTANCE);
cmds.add(IncrementCommand.INSTANCE);
cmds.add(DecrementCommand.INSTANCE);
cmds.add(SkillLevelIncrementCommand.INSTANCE);
cmds.add(SkillLevelDecrementCommand.INSTANCE);
cmds.add(TechLevelIncrementCommand.INSTANCE);
cmds.add(TechLevelDecrementCommand.INSTANCE);
cmds.add(RotateStateCommand.INSTANCE);
cmds.add(JumpToSearchCommand.INSTANCE);
cmds.add(RandomizeDescriptionCommand.INSTANCE);
cmds.add(RandomizeNameCommand.FEMALE_INSTANCE);
cmds.add(RandomizeNameCommand.MALE_INSTANCE);
cmds.add(AddNaturalPunchCommand.INSTANCE);
cmds.add(AddNaturalKickCommand.INSTANCE);
cmds.add(AddNaturalKickWithBootsCommand.INSTANCE);
cmds.add(SwapDefaultsCommand.INSTANCE);
if (!Platform.isMacintosh()) {
cmds.add(PreferencesCommand.INSTANCE);
}
return cmds;
}
示例8: createMenu
import com.trollworks.toolkit.utility.Platform; //導入依賴的package包/類
@Override
public JMenu createMenu() {
JMenu menu = new JMenu(EDIT);
menu.setName(NAME);
menu.add(new DynamicMenuItem(UndoCommand.INSTANCE));
menu.add(new DynamicMenuItem(RedoCommand.INSTANCE));
menu.addSeparator();
menu.add(new DynamicMenuItem(CutCommand.INSTANCE));
menu.add(new DynamicMenuItem(CopyCommand.INSTANCE));
menu.add(new DynamicMenuItem(PasteCommand.INSTANCE));
menu.add(new DynamicMenuItem(DuplicateCommand.INSTANCE));
menu.add(new DynamicMenuItem(DeleteCommand.INSTANCE));
menu.add(new DynamicMenuItem(SelectAllCommand.INSTANCE));
menu.addSeparator();
menu.add(new DynamicMenuItem(IncrementCommand.INSTANCE));
menu.add(new DynamicMenuItem(DecrementCommand.INSTANCE));
menu.add(new DynamicMenuItem(SkillLevelIncrementCommand.INSTANCE));
menu.add(new DynamicMenuItem(SkillLevelDecrementCommand.INSTANCE));
menu.add(new DynamicMenuItem(TechLevelIncrementCommand.INSTANCE));
menu.add(new DynamicMenuItem(TechLevelDecrementCommand.INSTANCE));
menu.add(new DynamicMenuItem(RotateStateCommand.INSTANCE));
menu.add(new DynamicMenuItem(SwapDefaultsCommand.INSTANCE));
menu.addSeparator();
menu.add(new DynamicMenuItem(JumpToSearchCommand.INSTANCE));
menu.addSeparator();
menu.add(new DynamicMenuItem(RandomizeDescriptionCommand.INSTANCE));
menu.add(new DynamicMenuItem(RandomizeNameCommand.FEMALE_INSTANCE));
menu.add(new DynamicMenuItem(RandomizeNameCommand.MALE_INSTANCE));
menu.addSeparator();
menu.add(new DynamicCheckBoxMenuItem(AddNaturalPunchCommand.INSTANCE));
menu.add(new DynamicCheckBoxMenuItem(AddNaturalKickCommand.INSTANCE));
menu.add(new DynamicCheckBoxMenuItem(AddNaturalKickWithBootsCommand.INSTANCE));
menu.addSeparator();
if (!Platform.isMacintosh()) {
menu.add(new DynamicMenuItem(PreferencesCommand.INSTANCE));
}
menu.add(createLanguageMenu());
DynamicMenuEnabler.add(menu);
return menu;
}
示例9: createMenu
import com.trollworks.toolkit.utility.Platform; //導入依賴的package包/類
@Override
public JMenu createMenu() {
JMenu menu = new JMenu(FILE);
menu.setName(NAME);
menu.add(new DynamicMenuItem(NewCharacterSheetCommand.INSTANCE));
menu.add(new DynamicMenuItem(NewCharacterTemplateCommand.INSTANCE));
menu.add(new DynamicMenuItem(NewAdvantagesLibraryCommand.INSTANCE));
menu.add(new DynamicMenuItem(NewEquipmentLibraryCommand.INSTANCE));
menu.add(new DynamicMenuItem(NewNoteLibraryCommand.INSTANCE));
menu.add(new DynamicMenuItem(NewSkillsLibraryCommand.INSTANCE));
menu.add(new DynamicMenuItem(NewSpellsLibraryCommand.INSTANCE));
menu.addSeparator();
menu.add(new DynamicMenuItem(OpenCommand.INSTANCE));
menu.add(new RecentFilesMenu());
menu.add(new DynamicMenuItem(CloseCommand.INSTANCE));
menu.addSeparator();
menu.add(new DynamicMenuItem(SaveCommand.INSTANCE));
menu.add(new DynamicMenuItem(SaveAsCommand.INSTANCE));
menu.add(new DynamicMenuItem(ExportToGurpsCalculatorCommand.INSTANCE));
menu.addSeparator();
menu.add(new DynamicMenuItem(PageSetupCommand.INSTANCE));
menu.add(new DynamicMenuItem(PrintCommand.INSTANCE));
if (!Platform.isMacintosh()) {
menu.addSeparator();
menu.add(new DynamicMenuItem(QuitCommand.INSTANCE));
}
DynamicMenuEnabler.add(menu);
return menu;
}
示例10: PageField
import com.trollworks.toolkit.utility.Platform; //導入依賴的package包/類
/**
* Creates a new text input field.
*
* @param sheet The sheet to listen to.
* @param consumedType The field to listen to.
* @param alignment The alignment of the field.
* @param editable Whether or not the user can edit this field.
* @param tooltip The tooltip to set.
*/
public PageField(CharacterSheet sheet, String consumedType, int alignment, boolean editable, String tooltip) {
super(getFormatterFactoryForType(consumedType), sheet.getCharacter().getValueForID(consumedType));
if (Platform.isLinux()) {
// I override the UI here since the GTK UI on Linux has no way to turn off the border
// around text fields.
setUI(new BasicTextFieldUI());
}
mSheet = sheet;
mConsumedType = consumedType;
setFont(sheet.getScale().scale(UIManager.getFont(GCSFonts.KEY_FIELD)));
setBorder(null);
setOpaque(false);
// Just setting opaque to false isn't enough for some reason, so I'm also setting the
// background color to a 100% transparent value.
setBackground(new Color(255, 255, 255, 0));
setHorizontalAlignment(alignment);
setEditable(editable);
setEnabled(editable);
setForeground(editable ? Color.BLACK : Color.GRAY);
if (tooltip != null) {
setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
if (tooltip.indexOf("{") != -1) { //$NON-NLS-1$
mCustomToolTip = tooltip;
}
}
mSheet.getCharacter().addTarget(this, mConsumedType);
addPropertyChangeListener("value", this); //$NON-NLS-1$
addActionListener(this);
setFocusLostBehavior(COMMIT_OR_REVERT);
// Reset the selection colors back to what is standard for text fields.
// This is necessary, since (at least on the Mac) JFormattedTextField
// has the wrong values by default.
setCaretColor(UIManager.getColor("TextField.caretForeground")); //$NON-NLS-1$
setSelectionColor(UIManager.getColor("TextField.selectionBackground")); //$NON-NLS-1$
setSelectedTextColor(UIManager.getColor("TextField.selectionForeground")); //$NON-NLS-1$
setDisabledTextColor(UIManager.getColor("TextField.inactiveForeground")); //$NON-NLS-1$
}
示例11: getMaximumWindowBounds
import com.trollworks.toolkit.utility.Platform; //導入依賴的package包/類
/**
* Determines the screen that most contains the specified global bounds and returns the maximum
* size a window can be on that screen.
*
* @param bounds The global bounds to use when determining the maximum bounds for a window.
* @return The maximum bounds that fits on a screen.
*/
public static Rectangle getMaximumWindowBounds(Rectangle bounds) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = getPreferredScreenDevice(bounds);
if (gd == ge.getDefaultScreenDevice()) {
bounds = ge.getMaximumWindowBounds();
// The Mac (and now Windows as of Java 5) already return the correct
// value... try to fix it up for the other platforms. This doesn't
// currently work, either, since the other platforms seem to always
// return empty insets.
if (!Platform.isMacintosh() && !Platform.isWindows()) {
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gd.getDefaultConfiguration());
// Since this is failing to do the right thing anyway, we're going
// to try and come up with some reasonable limitations...
if (insets.top == 0 && insets.bottom == 0) {
insets.bottom = 48;
}
bounds.x += insets.left;
bounds.y += insets.top;
bounds.width -= insets.left + insets.right;
bounds.height -= insets.top + insets.bottom;
}
return bounds;
}
return gd.getDefaultConfiguration().getBounds();
}
示例12: forceAppToFront
import com.trollworks.toolkit.utility.Platform; //導入依賴的package包/類
/** Attempts to force the app to the front. */
public static void forceAppToFront() {
if (Platform.isMacintosh()) {
Application.getApplication().requestForeground(true);
} else if (OK_TO_USE_FULLSCREEN_TRICK) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
AppWindow window = new AppWindow();
window.setUndecorated(true);
window.getContentPane().setBackground(new Color(0, 0, 0, 0));
gd.setFullScreenWindow(window);
gd.setFullScreenWindow(null);
window.dispose();
}
}
示例13: App
import com.trollworks.toolkit.utility.Platform; //導入依賴的package包/類
/** Creates a new {@link App}. */
protected App() {
if (Platform.isMacintosh()) {
Application app = Application.getApplication();
app.setAboutHandler(AboutCommand.INSTANCE);
app.setPreferencesHandler(PreferencesCommand.INSTANCE);
app.setOpenFileHandler(OpenCommand.INSTANCE);
app.setPrintFileHandler(PrintCommand.INSTANCE);
app.setQuitHandler(QuitCommand.INSTANCE);
app.setQuitStrategy(QuitStrategy.SYSTEM_EXIT_0);
app.disableSuddenTermination();
}
}
示例14: getKeyStrokeDisplay
import com.trollworks.toolkit.utility.Platform; //導入依賴的package包/類
/**
* @param ks The {@link KeyStroke} to use.
* @return The text that represents the {@link KeyStroke}.
*/
public static String getKeyStrokeDisplay(KeyStroke ks) {
StringBuilder buffer = new StringBuilder();
if (ks != null) {
int modifiers = ks.getModifiers();
if (modifiers > 0) {
String modifierText = KeyEvent.getKeyModifiersText(modifiers);
if (Platform.isMacintosh()) {
buffer.append(modifierText.replaceAll("\\+", "")); //$NON-NLS-1$ //$NON-NLS-2$
} else {
buffer.append(modifierText);
String delimiter = UIManager.getString("MenuItem.acceleratorDelimiter"); //$NON-NLS-1$
if (delimiter == null) {
delimiter = "+"; //$NON-NLS-1$
}
buffer.append(delimiter);
}
}
int keyCode = ks.getKeyCode();
if (keyCode != 0) {
buffer.append(KeyEvent.getKeyText(keyCode));
} else {
buffer.append(ks.getKeyChar());
}
}
return buffer.toString();
}
示例15: createExtensionMatcher
import com.trollworks.toolkit.utility.Platform; //導入依賴的package包/類
/**
* Convenience for creating a regular expression that will match a file extension. This takes
* care of turning on case-insensitivity for those platforms that need it.
*
* @param extension A file name extension.
* @return The regular expression that will match the specified file name extension.
*/
public static String createExtensionMatcher(String extension) {
StringBuilder builder = new StringBuilder();
if (Platform.isMacintosh() || Platform.isWindows()) {
builder.append("(?i)"); //$NON-NLS-1$
}
builder.append("^.*\\"); //$NON-NLS-1$
if (!extension.startsWith(".")) { //$NON-NLS-1$
builder.append('.');
}
builder.append(extension);
builder.append('$');
return builder.toString();
}