Beispiel #1
0
 private boolean selectInputFile(File file) {
   if (!file.exists() || sipModel.getDataSetModel().isEmpty()) return false;
   String spec = sipModel.getDataSetModel().getDataSet().getSpec();
   boolean doImport =
       sipModel
           .getFeedback()
           .confirm(
               "Verify your choice",
               String.format(
                   "<html>Import this file<br><br>"
                       + "<pre><strong>%s</strong></pre><br>"
                       + "into data set '<strong>%s</strong>'?<br>",
                   file.getAbsolutePath(),
                   spec // todo: could snag description and things from facts, if they were
                   // hardcoded
                   ));
   if (doImport) {
     setEnabled(false);
     sipModel.importSource(
         file,
         new Swing() {
           @Override
           public void run() {
             setEnabled(true);
           }
         });
     return true;
   }
   return false;
 }
Beispiel #2
0
 public ImportAction(JDesktopPane parent, SipModel sipModel) {
   super("Import new source data");
   putValue(Action.SMALL_ICON, SwingHelper.ICON_IMPORT);
   putValue(
       Action.ACCELERATOR_KEY,
       KeyStroke.getKeyStroke(
           KeyEvent.VK_I, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
   this.parent = parent;
   this.sipModel = sipModel;
   this.dialog =
       new JDialog(
           SwingUtilities.getWindowAncestor(parent),
           "Input Source",
           Dialog.ModalityType.APPLICATION_MODAL);
   setEnabled(false);
   prepareDialog();
   prepareChooser(sipModel);
   sipModel
       .getDataSetModel()
       .addListener(
           new DataSetModel.SwingListener() {
             @Override
             public void stateChanged(DataSetModel model, DataSetState state) {
               setEnabled(state != ABSENT);
             }
           });
 }