Example #1
0
 public static void setDelayedParsing(final boolean delayedParsing) {
   final Preferences pref = Preferences.userNodeForPackage(GameRunner2.class);
   pref.putBoolean(DELAYED_PARSING, delayedParsing);
   try {
     pref.sync();
   } catch (final BackingStoreException e) {
     e.printStackTrace();
   }
 }
Example #2
0
 public static void resetPreferences() {
   try {
     Base.preferences.removeNode();
     Base.preferences.flush();
     preferences = Preferences.userNodeForPackage(Base.class);
   } catch (BackingStoreException bse) {
     bse.printStackTrace();
   }
 }
Example #3
0
 public static void setDefaultLookAndFeel(final String lookAndFeelClassName) {
   final Preferences pref = Preferences.userNodeForPackage(GameRunner2.class);
   pref.put(LOOK_AND_FEEL_PREF, lookAndFeelClassName);
   try {
     pref.sync();
   } catch (final BackingStoreException e) {
     e.printStackTrace();
   }
 }
 private static void saveModel(GuiQuickstartDataModel model) {
   Preferences preferences = Preferences.userNodeForPackage(GuiBootstrapMain.class);
   updatePreferences(preferences, "transitDataBundlePath", model.getTransitDataBundlePath());
   updatePreferences(preferences, "gtfsPath", model.getGtfsPath());
   updatePreferences(preferences, "tripUpdatesUrl", model.getTripUpdatesUrl());
   updatePreferences(preferences, "vehiclePositionsUrl", model.getVehiclePositionsUrl());
   updatePreferences(preferences, "alertsUrl", model.getAlertsUrl());
   try {
     preferences.sync();
   } catch (BackingStoreException e) {
     e.printStackTrace();
   }
 }
 /** Calling this method will write all preferences into the preference store. */
 public void flush() {
   if (getBoolean("memoryStickMode")) {
     try {
       exportPreferences("jabref.xml");
     } catch (IOException e) {
       Globals.logger(
           "Could not save preferences for memory stick mode: " + e.getLocalizedMessage());
     }
   }
   try {
     prefs.flush();
   } catch (BackingStoreException ex) {
     ex.printStackTrace();
   }
 }
Example #6
0
 private void sendText() {
   String text = textField.getText().trim();
   String voice = (String) speechComboBox.getSelectedItem();
   if (text != null && !text.isEmpty()) {
     prefs.put("roboy_voice", voice);
     try {
       prefs.flush();
     } catch (BackingStoreException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
     if (model.sendText(text, voice)) {
       // btnSpeech.setEnabled(false);
       // textField.setEnabled(false);
     }
   }
 }
 public void saveAll() {
   for (DynamiPrefs p : prefsPages) {
     p.prefs().write(storedPreferences);
   }
   try {
     try (FileOutputStream output =
         new FileOutputStream(new File(PrefsConstants.PREFS_FILE_PATH))) {
       storedPreferences.exportNode(output);
     }
     //			Preferences.userRoot().exportNode();
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   } catch (BackingStoreException e) {
     e.printStackTrace();
   }
 }
Example #8
0
 public static void setProxy(
     final String proxyHost, final String proxyPort, final ProxyChoice proxyChoice) {
   final Preferences pref = Preferences.userNodeForPackage(GameRunner2.class);
   final ProxyChoice choice;
   if (proxyChoice != null) {
     choice = proxyChoice;
     pref.put(PROXY_CHOICE, proxyChoice.toString());
   } else {
     choice = ProxyChoice.valueOf(pref.get(PROXY_CHOICE, ProxyChoice.NONE.toString()));
   }
   if (proxyHost != null && proxyHost.trim().length() > 0) {
     pref.put(PROXY_HOST, proxyHost); // user pref, not system properties
     if (choice == ProxyChoice.USE_USER_PREFERENCES) System.setProperty(HTTP_PROXYHOST, proxyHost);
   }
   if (proxyPort != null && proxyPort.trim().length() > 0) {
     try {
       Integer.parseInt(proxyPort);
       pref.put(PROXY_PORT, proxyPort); // user pref, not system properties
       if (choice == ProxyChoice.USE_USER_PREFERENCES)
         System.setProperty(HTTP_PROXYPORT, proxyPort);
     } catch (final NumberFormatException nfe) {
       nfe.printStackTrace();
     }
   }
   if (choice == ProxyChoice.NONE) {
     System.clearProperty(HTTP_PROXYHOST);
     System.clearProperty(HTTP_PROXYPORT);
   } else if (choice == ProxyChoice.USE_SYSTEM_SETTINGS) {
     setToUseSystemProxies();
   }
   if (proxyHost != null || proxyPort != null || proxyChoice != null) {
     try {
       pref.flush();
       pref.sync();
     } catch (final BackingStoreException e) {
       e.printStackTrace();
     }
   }
   /*System.out.println(System.getProperty(HTTP_PROXYHOST));
   System.out.println(System.getProperty(HTTP_PROXYPORT));*/
 }
Example #9
0
  /** Create the application. */
  public Wow() {
    initialize();
    // ArrayList<BufferedImage> images = new ArrayList<BufferedImage>();
    coreWallet = new CoreWallet();
    fileChooser = new JFileChooser();
    FileNameExtensionFilter filter =
        new FileNameExtensionFilter("Wow DOGE Wallet Files", "dogewallet");
    fileChooser.addChoosableFileFilter(filter);
    addressesListModel = new AddressesListModel();
    listAddresses.setModel(addressesListModel); // new DefaultListModel());
    transactionsTableModel = new TransactionsTableModel();
    tableTransactions.setModel(transactionsTableModel);
    tableTransactions.setDefaultRenderer(Object.class, new TransactionsTableCellRenderer());
    addressBookTableModel = new AddressBookTableModel(coreWallet.getPreferences());
    tableAddressBook.setModel(addressBookTableModel);
    try {
      addressBookTableModel.getAddressBook().load();
    } catch (IOException e1) {
      e1.printStackTrace();
      JOptionPane.showMessageDialog(
          frmWow,
          e1.getMessage(),
          "Error during Reading Address Book Data",
          JOptionPane.ERROR_MESSAGE);
    } catch (ClassNotFoundException e1) {
      e1.printStackTrace();
      JOptionPane.showMessageDialog(
          frmWow, e1.getMessage(), "Error in Reading Address Book Data", JOptionPane.ERROR_MESSAGE);
    } catch (BackingStoreException e1) {
      e1.printStackTrace();
      JOptionPane.showMessageDialog(
          frmWow,
          e1.getMessage(),
          "Error within Reading Address Book Data",
          JOptionPane.ERROR_MESSAGE);
    }

    JMenuBar menuBar = new JMenuBar();
    frmWow.setJMenuBar(menuBar);

    mnFile = new JMenu("File");
    mnFile.setMnemonic('F');
    menuBar.add(mnFile);

    JMenuItem mntmNew = new JMenuItem("New Wallet");
    mntmNew.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            DialogNew d = new DialogNew();
            d.setLocationRelativeTo(frmWow);
            if (d.showDialog()) {
              try {
                coreWallet.open(new File(d.getFolder(), d.getWalletFileName()));
                mnRecent.addFileToFileHistory(
                    new File(d.getFolder(), d.getWalletFileName()).getAbsolutePath());
                mnRecent.storeToPreferences();
              } catch (IOException e) {
                JOptionPane.showMessageDialog(
                    frmWow, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
              } catch (Exception e) {
                JOptionPane.showMessageDialog(
                    frmWow, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
              }
            }
          }
        });
    mntmNew.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.META_MASK));
    mntmNew.setMnemonic(KeyEvent.VK_N);
    mnFile.add(mntmNew);

    JMenuItem mntmOpen = new JMenuItem("Open Wallet...");
    mntmOpen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            int returnVal = fileChooser.showOpenDialog(frmWow);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
              try {
                File file = fileChooser.getSelectedFile();
                coreWallet.open(file);
                mnRecent.addFileToFileHistory(file.getAbsolutePath());
                mnRecent.storeToPreferences();
              } catch (IOException e) {
                JOptionPane.showMessageDialog(
                    frmWow, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
              } catch (Exception e) {
                JOptionPane.showMessageDialog(
                    frmWow, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
              }
            }
          }
        });
    mntmOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.META_MASK));
    mnFile.add(mntmOpen);

    JMenuItem mntmSaveAs = new JMenuItem("Save As...");
    mntmSaveAs.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            int returnVal = fileChooser.showSaveDialog(frmWow);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
              try {
                File file = fileChooser.getSelectedFile();
                String file_name = file.toString();
                if (!file_name.endsWith(".dogewallet")) file_name += ".dogewallet";
                file = new File(file_name);
                File temp =
                    new File(file.getParentFile().getAbsolutePath(), "TEMP" + file.getName());
                coreWallet.saveToFile(temp, file);
              } catch (IOException e) {
                JOptionPane.showMessageDialog(
                    frmWow, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
              }
            }
          }
        });
    // coreWallet = new CoreWallet();

    mnRecent =
        new RecentFilesMenu("Open Recent Wallet", coreWallet.getPreferences().node("Recent")) {
          @Override
          protected Action createOpenAction(String fileFullPath) {
            return new OpenAction(this, fileFullPath);
          }
        };
    mnFile.add(mnRecent);
    mntmSaveAs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.META_MASK));
    mnFile.add(mntmSaveAs);

    JMenu mnHelp = new JMenu("Help");
    menuBar.add(mnHelp);

    JMenuItem mntmHelp = new JMenuItem("Wow - Doge Wallet Help");
    mnHelp.add(mntmHelp);

    JMenuItem mntmAbout = new JMenuItem("About Wow - Doge Wallet");
    mntmAbout.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            DialogAbout d = new DialogAbout();
            d.setLocationRelativeTo(frmWow);
            d.showDialog();
          }
        });
    mnHelp.add(mntmAbout);

    tableAddressBook.setDefaultRenderer(Object.class, new AddressBookTableCellRenderer());

    (new Thread(this)).start();
  }
Example #10
0
  public File browse(
      Component parent,
      BrowseType browseType,
      FileType fileType,
      PrefType prefType,
      boolean dirsOnly,
      String startingDir) {
    init(parent);

    try {
      prefs.sync();
    } catch (BackingStoreException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    File selFile = null;
    if (startingDir != null) {
      File f = new File(startingDir);

      if (f.isFile()) //
      startingDir = f.getParent();
      else {
        if (!f.exists()) f.mkdir();

        if (dirsOnly) { // make parent dir the starting dir, if it exists
          startingDir = f.getParent();
          selFile = f;
        }
      }
    }

    String lastDir =
        startingDir != null && startingDir.length() != 0
            ? startingDir
            : prefs.get("file." + browseType.name() + "." + prefType.name(), null);
    if (lastDir == null) {
      if (prefType == PrefType.FontLoad) {
        lastDir = getBestFontPath();
      } else {
        lastDir = System.getProperty("user.home");
      }
    }

    File lastDirFile = new File(lastDir);
    String lastDirFileName = "";
    if (lastDirFile.exists() && lastDirFile.isFile()) lastDirFileName = lastDirFile.getName();

    File file = null;

    if (useJFileChooser) {
      jFileChooser.setFileFilter(fileType.swingFilter);

      jFileChooser.setCurrentDirectory(new File(lastDir));

      if (selFile != null) jFileChooser.setSelectedFile(selFile);

      jFileChooser.setFileSelectionMode(
          dirsOnly ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_ONLY);
      int a =
          browseType == BrowseType.Open
              ? jFileChooser.showOpenDialog(parent)
              : jFileChooser.showSaveDialog(parent);
      if (a == JFileChooser.APPROVE_OPTION) {
        prefs.put(
            "file." + browseType.name(), jFileChooser.getCurrentDirectory().getAbsolutePath());
        file = jFileChooser.getSelectedFile();
      }
    } else {
      System.setProperty("apple.awt.fileDialogForDirectories", Boolean.toString(dirsOnly));

      fileDialog.setAlwaysOnTop(true);
      fileDialog.setFilenameFilter(fileType.awtFilter);
      fileDialog.setDirectory(lastDir);
      fileDialog.setFile(lastDirFileName);
      fileDialog.setMode(browseType == BrowseType.Open ? FileDialog.LOAD : FileDialog.SAVE);
      fileDialog.setVisible(true);
      String res = fileDialog.getFile();
      if (res != null) {
        File ret = new File(fileDialog.getDirectory(), res);
        File dir = ret;
        if (dir.getParentFile() != null && !dir.isDirectory()) dir = dir.getParentFile();
        prefs.put("file." + browseType.name(), dir.getAbsolutePath());
        file = ret;
      }
    }

    if (file != null) {
      try {
        prefs.flush();
      } catch (BackingStoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    return file;
  }