public ProductSetPanel(final AppContext theAppContext, final String title, final FileTableModel fileModel) { this(theAppContext, title, new FileTable(fileModel), false, false); }
@Override public String getToolTipText(MouseEvent e) { String tip = null; java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); int colIndex = columnAtPoint(p); try { tip = getValueAt(rowIndex, colIndex).toString(); } catch (RuntimeException e1) { //catch null pointer exception if mouse is over an empty line } return tip; }
public FileTable(FileTableModel fileModel, Dimension dim) { if (fileModel == null) { fileModel = new FileModel(); } this.fileModel = fileModel; this.setModel(fileModel); setPreferredScrollableViewportSize(dim); fileModel.setColumnWidths(getColumnModel()); setColumnSelectionAllowed(true); setDropMode(DropMode.ON); setDragEnabled(true); setComponentPopupMenu(createTablePopup()); setTransferHandler(new ProductSetTransferHandler(fileModel)); }
public File[] getSelectedFiles() { return productSetTable.getModel().getFilesAt(productSetTable.getSelectedRows()); }
public void actionPerformed(final ActionEvent e) { final int rowCount = productSetTable.getFileCount(); if (rowCount == 1) { tableModel.clear(); return; } final int[] selRows = table.getSelectedRows(); final java.util.List<File> filesToRemove = new ArrayList<>(selRows.length); for (int row : selRows) { filesToRemove.add(tableModel.getFileAt(row)); } for (File file : filesToRemove) { int index = tableModel.getIndexOf(file); tableModel.removeFile(index); } } });
public Object getValueAt(final int r, final int c) { return table.getModel().getValueAt(r, c); }
public File[] getFileList() { return table.getFileList(); }
private void updateComponents() { final int rowCount = productSetTable.getFileCount(); final boolean enableButtons = (rowCount > 0); if (dbQueryButton != null) dbQueryButton.setEnabled(enableButtons); if (removeButton != null) removeButton.setEnabled(enableButtons); if (moveTopButton != null) moveTopButton.setEnabled(rowCount > 1); if (moveUpButton != null) moveUpButton.setEnabled(rowCount > 1); if (moveDownButton != null) moveDownButton.setEnabled(rowCount > 1); if (moveBottomButton != null) moveBottomButton.setEnabled(rowCount > 1); if (refreshButton != null) refreshButton.setEnabled(rowCount > 1); if (clearButton != null) clearButton.setEnabled(enableButtons); if (addAllOpenButton != null) { addAllOpenButton.setEnabled(SnapApp.getDefault().getProductManager().getProducts().length > 0); } String cntMsg; if (rowCount == 1) { cntMsg = rowCount + " Product"; } else { cntMsg = rowCount + " Products"; } countLabel.setText(cntMsg); }
public void actionPerformed(final ActionEvent e) { final int[] selRows = table.getSelectedRows(); final java.util.List<File> filesToMove = new ArrayList<>(selRows.length); for (int row : selRows) { filesToMove.add(tableModel.getFileAt(row)); } int pos = 0; for (File file : filesToMove) { int index = tableModel.getIndexOf(file); if (index > 0 && movement.equals(MOVE.TOP)) { tableModel.move(index, pos++); } else if (index > 0 && movement.equals(MOVE.UP)) { tableModel.move(index, index - 1); } else if (index < tableModel.getRowCount() && movement.equals(MOVE.DOWN)) { tableModel.move(index, index + 1); } else if (index < tableModel.getRowCount() && movement.equals(MOVE.BOTTOM)) { tableModel.move(index, tableModel.getRowCount()-1); } } } }
public File[] getSelectedFiles() { return table.getModel().getFilesAt(table.getSelectedRows()); }
public Object getValueAt(final int r, final int c) { return productSetTable.getModel().getValueAt(r, c); }
public File[] getFileList() { return productSetTable.getFileList(); }
public ProductSetPanel(final AppContext theAppContext, final String title) { this(theAppContext, title, new FileTable(), false, false); }
private JPanel createButtonPanel(final FileTable table) { final FileTableModel tableModel = table.getModel();
@Override public void updateParameters() { final File[] fileList = productSetTable.getFileList(); if (fileList.length == 0) return; final String[] fList = new String[fileList.length]; for (int i = 0; i < fileList.length; ++i) { if (fileList[i].getName().isEmpty()) fList[i] = ""; else fList[i] = fileList[i].getAbsolutePath(); } paramMap.put("fileList", fList); }
mainPanel.add(progressPanel, BorderLayout.SOUTH); productSetPanel = new ProductSetPanel(appContext, null, new FileTable(), true, true); tabbedPane.add("I/O Parameters", productSetPanel);
public ProductSetPanel(final AppContext theAppContext, final String title, final FileTable fileTable, final boolean incTrgProduct, final boolean incButtonPanel) { super(new BorderLayout()); this.appContext = theAppContext; this.productSetTable = fileTable; setBorderTitle(title); final JPanel productSetContent = createComponent(productSetTable); if (incButtonPanel) { buttonPanel = createButtonPanel(productSetTable); productSetContent.add(buttonPanel, BorderLayout.EAST); } this.add(productSetContent, BorderLayout.CENTER); if (incTrgProduct) { targetProductSelector = new TargetFolderSelector(); final String homeDirPath = SystemUtils.getUserHomeDir().getPath(); final String saveDir = SnapApp.getDefault().getPreferences().get(SaveProductAsAction.PREFERENCES_KEY_LAST_PRODUCT_DIR, homeDirPath); targetProductSelector.getModel().setProductDir(new File(saveDir)); targetProductSelector.getOpenInAppCheckBox().setText("Open in " + theAppContext.getApplicationName()); targetProductSelector.getOpenInAppCheckBox().setVisible(false); this.add(targetProductSelector.createPanel(), BorderLayout.SOUTH); } else { targetProductSelector = null; } fileTable.getModel().addTableModelListener(this); updateComponents(); }
public GraphProductSetPanel(final AppContext theAppContext, final TimeSeriesSettingsDlg settingsDlg, final GraphData graphData, final boolean addDeleteButton) { super(theAppContext, graphData.getTitle(), new FileTable(new FileModel(), new Dimension(500, 250)), false, true); this.title = graphData.getTitle(); this.settingsDlg = settingsDlg; colorCombo.setSelectedColor(graphData.getColor()); getButtonPanel().add(colorCombo); getButtonPanel().add(createRenameButton(this)); getButtonPanel().add(addDeleteButton ? createDeleteButton(this) : new JLabel(" ")); }
private void createPanel() { final JPanel textPanel = createTextPanel("Instructions", getInstructions()); this.add(textPanel, BorderLayout.NORTH); // productSetPanel = new ProductSetPanel(SnapApp.getDefault().getAppContext(), null, new FileTable(), false, true); productSetPanel = new ProductSetPanel(SnapApp.getDefault().getAppContext(), null, new FileTable(), true, true); this.add(productSetPanel, BorderLayout.CENTER); } }