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; }
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); } }); }
public InputFrame(SipModel sipModel) { super(Which.INPUT, sipModel, "Input"); sipModel.addParseListener( new SipModel.ParseListener() { @Override public void updatedRecord(MetadataRecord metadataRecord) { exec(new RecordSetter(metadataRecord)); } }); recordTree = new JTree(EMPTY_MODEL) { @Override public String getToolTipText(MouseEvent evt) { TreePath treePath = recordTree.getPathForLocation(evt.getX(), evt.getY()); return treePath != null ? ((GroovyTreeNode) treePath.getLastPathComponent()).toolTip : ""; } }; recordTree.setToolTipText("Input Record"); recordTree.setCellRenderer(new Renderer()); recordTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); recordTree.setTransferHandler(new TreeTransferHandler()); filterField.addActionListener(rewind); }
private void prepareChooser(SipModel sipModel) { File directory = new File(sipModel.getPreferences().get(RECENT_DIR, System.getProperty("user.home"))); chooser.setCurrentDirectory(directory); chooser.setFileFilter( new FileFilter() { @Override public boolean accept(File file) { return file.isFile() && (file.getName().endsWith(".xml") || file.getName().endsWith(".xml.gz") || file.getName().endsWith(".xml.zip") || file.getName().endsWith(".csv")); } @Override public String getDescription() { return "Files ending with .xml, .xml.gz, .xml.zip, or .csv"; } }); chooser.setMultiSelectionEnabled(false); }