/** * Retrieves the editor UI. * * @return the editor UI */ public JComponent getUI() { if (_basePanel == null) { createUI(); } return _basePanel; }
private JFileChooser getFileDialogSafe() { if (_fileDialog == null) { _fileDialog = createFileChooserDialog(); } return _fileDialog; }
@Override public void encodeCsv(Writer writer) throws IOException { new TableModelCsvEncoder(this).encodeCsv(writer); } }
setName(label, _label); JComponent scrollPane = createFileArrayComponent(); final JButton addButton = createAddFileButton(); final JButton removeButton = createRemoveFileButton(); setName(buttonPanel, _label); buttonPanel.add(addButton); buttonPanel.add(removeButton); setName(_basePanel, _label); final GridBagConstraints gbc = GridBagUtils.createConstraints(null); gbc.anchor = GridBagConstraints.WEST;
sourceFileEditor.setListener(listener); JButton addFileButton = sourceFileEditor.createAddFileButton(); JButton removeFileButton = sourceFileEditor.createRemoveFileButton(); final TableLayout tableLayout = new TableLayout(1); tableLayout.setTablePadding(4, 4); sourceProductPanel.add(buttonPanel); final JComponent fileArrayComponent = sourceFileEditor.createFileArrayComponent(); tableLayout.setRowWeightY(1, 1.0); sourceProductPanel.add(fileArrayComponent);
private void onAddButton() { _fileDialog = getFileDialogSafe(); final File userInputDir = _parent.getUserInputDir(); final int retVal; _fileDialog.setCurrentDirectory(userInputDir); retVal = _fileDialog.showOpenDialog(_basePanel); if (retVal == JFileChooser.APPROVE_OPTION) { File[] selected = _fileDialog.getSelectedFiles(); _fileList.addAll(Arrays.asList(selected)); _listComponent.setListData(_fileList.toArray()); notifyListener(); _parent.setUserInputDir(_fileDialog.getCurrentDirectory()); } }
/** * Writes the table model content encoded as csv to the given writer. * The separator char is {@code '\t'}. * @param writer * @throws IOException */ @Override public void encodeCsv(Writer writer) throws IOException { CsvWriter csv = new CsvWriter(writer, "\t"); encodeHeadline(csv); encodeData(csv); }
public JComponent createFileArrayComponent() { JScrollPane scrollPane = new JScrollPane(_listComponent); setName(scrollPane, _label); scrollPane.setPreferredSize(_listPreferredSize); return scrollPane; }
private void onRemoveButton() { final Object[] toRemove = _listComponent.getSelectedValues(); for (Object o : toRemove) { _fileList.remove(o); } _listComponent.setListData(_fileList.toArray()); notifyListener(); }
private void notifyListener() { if ((_listener != null)) { _listener.updatedList(_fileList.toArray(new File[_fileList.size()])); } }
private void prepareShowTargetProductSelector() { try { final List<File> files = sourceFileEditor.getFiles(); mosaicModel.setSourceProducts(files.toArray(new File[files.size()])); } catch (IOException ignore) { } }
@Override public void encodeCsv(Writer writer) throws IOException { new TableModelCsvEncoder(this).encodeCsv(writer); }
@Override protected JFileChooser createFileChooserDialog() { final JFileChooser fileChooser = super.createFileChooserDialog(); fileChooser.setDialogTitle("Mosaic - Open Source Product(s)"); return fileChooser; } };
/** * Constructs the object with default values * * @param parent the parent editor * @param label the label for this editor */ public FileArrayEditor(final EditorParent parent, String label) { Guardian.assertNotNullOrEmpty("label", label); _parent = parent; _label = label; _fileList = new ArrayList<File>(); _listComponent = new JList(); setName(_listComponent, _label); }
/** * Sets the list of files to be edited. The list currently held is overwritten. * * @param files <code>List</code> of <code>File</code>s to be set */ public void setFiles(final List<File> files) { Guardian.assertNotNull("files", files); _fileList.clear(); _fileList.addAll(files); _listComponent.setListData(_fileList.toArray()); notifyListener(); }
private String getDataAsText() { final StringWriter writer = new StringWriter(); try { new TableModelCsvEncoder(tableModel).encodeCsv(writer); writer.close(); } catch (IOException ignore) { } return writer.toString(); }
public JButton createRemoveFileButton() { final JButton removeButton = (JButton) ToolButtonFactory.createButton( UIUtils.loadImageIcon("icons/Minus16.gif"), false); setName(removeButton, "removeButton"); removeButton.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { onRemoveButton(); } }); return removeButton; }
@Override protected String getDataAsText() { final StringWriter writer = new StringWriter(); try { new TableModelCsvEncoder(table.getModel()).encodeCsv(writer); writer.close(); } catch (IOException ignore) { } return writer.toString(); }
public JButton createAddFileButton() { final JButton addButton = (JButton) ToolButtonFactory.createButton( UIUtils.loadImageIcon("icons/Plus16.gif"), false); setName(addButton, "addButton"); addButton.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { onAddButton(); } }); return addButton; }