private void tableSelectionChanged() { if (selectedDownload != null) selectedDownload.deleteObserver(DownloadGUI.this); if (!clearing && table.getSelectedRow() > -1) { selectedDownload = tableModel.getDownload(table.getSelectedRow()); selectedDownload.addObserver(DownloadGUI.this); updateButtons(); } }
private void checkSelection(boolean isFixedTable) { int fixedSelectedIndex = fixedTable.getSelectedRow(); int selectedIndex = table.getSelectedRow(); if (fixedSelectedIndex != selectedIndex) { if (isFixedTable) { table.setRowSelectionInterval(fixedSelectedIndex, fixedSelectedIndex); } else { fixedTable.setRowSelectionInterval(selectedIndex, selectedIndex); } } }
public void valueChanged(ListSelectionEvent e) { if (table.getSelectedRow() == -1) { // Clear the messageTextArea since there is none packet selected messageTextArea.setText(null); } else { // Set the detail of the packet in the messageTextArea messageTextArea.setText((String) table.getModel().getValueAt(table.getSelectedRow(), 0)); // Scroll up to the top messageTextArea.setCaretPosition(0); } }
public void secureDelete() { int rw = tblItems.getSelectedRow(); if (rw == -1) { JOptionPane.showMessageDialog(frm, "No item selected", "Error", JOptionPane.ERROR_MESSAGE); return; } int idx = tblItems.convertRowIndexToModel(rw); if (JOptionPane.showConfirmDialog( frm, "Delete " + store.plainName(idx) + "?", "Confirm Delete", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) return; File del = store.delete(idx); store.fireTableDataChanged(); if (del != null) { if (del.delete()) { // successful needsSave = true; } else { System.err.println("Delete " + del.getAbsolutePath() + " failed"); } } updateStatus(); }
private void flag() { Set<Transaction.FraudStatus> permittedFlags = EnumSet.allOf(Transaction.FraudStatus.class); if (controller.getCurrentUser().getRole() != User.Role.AUDITOR) { permittedFlags.remove(Transaction.FraudStatus.REVERSED); } Transaction.FraudStatus status = (Transaction.FraudStatus) JOptionPane.showInputDialog( this, "Flag as:", "Flag", JOptionPane.QUESTION_MESSAGE, null, permittedFlags.toArray(), Transaction.FraudStatus.NOT_FLAGGED); if (status == null) { return; } try { Transaction transaction = account.getHistory().get(historyTable.getSelectedRow()); transaction.setFraudStatus(status, account); update(); } catch (InvalidInputException iix) { controller.handleException(this, iix); } catch (InsufficientFundsException ifx) { controller.handleException(this, ifx); } }
@Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int rowNum = table.getSelectedRow(); if (rowNum >= 0) { // get table model PeptideSpeciesPSMTableModel pepTableModel = (PeptideSpeciesPSMTableModel) table.getModel(); // get spectrum reference column int identColNum = pepTableModel.getColumnIndex(PeptideTableHeader.IDENTIFICATION_ID.getHeader()); int peptideColNum = pepTableModel.getColumnIndex(PeptideTableHeader.PEPTIDE_ID.getHeader()); // get spectrum id int modelRowIndex = table.convertRowIndexToModel(rowNum); Comparable identId = (Comparable) pepTableModel.getValueAt(modelRowIndex, identColNum); Comparable peptideId = (Comparable) pepTableModel.getValueAt(modelRowIndex, peptideColNum); logger.debug( "Peptide table selection: Protein id: " + identId + " Peptide Id: " + peptideId); // fire a background task to retrieve peptide if (peptideId != null && identId != null) { // publish the event to local event bus EventService eventBus = ContainerEventServiceFinder.getEventService(PeptidePSMPane.this); eventBus.publish(new PSMEvent(PeptidePSMPane.this, controller, identId, peptideId)); } } } }
/** Observer method to update the insuranceCompanyTable */ public void updateTable() { tableData.update( model.getInsuranceCompanies(), model.getSortingStrategy()); // Populate the table // Check if InsuranceCompany map is empty if (model.getInsuranceCompanies().size() > 0) { selectRow(); int selectedCompanyId = Integer.valueOf( (String) insuranceCompaniesTable.getValueAt(insuranceCompaniesTable.getSelectedRow(), 0)); controller.selectInsuranceCompany(selectedCompanyId); recordEdited = -1; // Reset the recordEdited field } else { // If all records are deleted, clear the edit panel companyIdTextField.setText(""); companyNameTextField.setText(""); urlTextField.setText(""); generalDescriptionTextField.setText(""); insuranceTypesTextField.setText(""); telephoneTextField.setText(""); percentageTextField.setText(""); } }
private void actionClear() { clearing = true; tableModel.clearDownload(table.getSelectedRow()); clearing = false; selectedDownload = null; updateButtons(); }
@Override protected void updateButtons() { final CommonActionsPanel p = getActionsPanel(); if (p != null) { boolean someElementSelected; if (myTable.isEnabled()) { final int index = myTable.getSelectedRow(); final int size = myTable.getModel().getRowCount(); someElementSelected = 0 <= index && index < size; if (someElementSelected) { final boolean downEnable = myTable.getSelectionModel().getMaxSelectionIndex() < size - 1; final boolean upEnable = myTable.getSelectionModel().getMinSelectionIndex() > 0; final boolean editEnabled = myTable.getSelectedRowCount() == 1; p.setEnabled(CommonActionsPanel.Buttons.EDIT, editEnabled); p.setEnabled(CommonActionsPanel.Buttons.UP, upEnable); p.setEnabled(CommonActionsPanel.Buttons.DOWN, downEnable); } else { p.setEnabled(CommonActionsPanel.Buttons.EDIT, false); p.setEnabled(CommonActionsPanel.Buttons.UP, false); p.setEnabled(CommonActionsPanel.Buttons.DOWN, false); } p.setEnabled( CommonActionsPanel.Buttons.ADD, myProducer == null || myProducer.canCreateElement()); } else { someElementSelected = false; p.setEnabled(CommonActionsPanel.Buttons.ADD, false); p.setEnabled(CommonActionsPanel.Buttons.EDIT, false); p.setEnabled(CommonActionsPanel.Buttons.UP, false); p.setEnabled(CommonActionsPanel.Buttons.DOWN, false); } p.setEnabled(CommonActionsPanel.Buttons.REMOVE, someElementSelected); updateExtraElementActions(someElementSelected); } }
@SuppressWarnings("unchecked") private Object initDynamicDefinitionComponent() { final String selectedPrimitiveFormName = _dotDefinitionDialogFrame.getSelectedPrimitiveForm(); final DOTProperty currentProperty = _dotDefinitionDialogFrame.getSelectedProperty(); PrimitiveFormPropertyPair pfpPair = new PrimitiveFormPropertyPair(selectedPrimitiveFormName, currentProperty); final JTable workWithThisTable = _dynamicTables.get(pfpPair); int selectedRow = workWithThisTable.getSelectedRow(); if (selectedRow == -1) { if (workWithThisTable.getModel().getRowCount() > 0) { selectedRow = 0; } else { return null; } } selectedRow = workWithThisTable.convertRowIndexToModel(selectedRow); final TableModel model = workWithThisTable.getModel(); DynamicDOTItemManager dynamicDOTItemManager = (DynamicDOTItemManager) model; final DisplayObjectTypeItemWithInterval dotItemWithInterval = dynamicDOTItemManager.get(selectedRow); _dynamicDefinitionComponent.fillComponents(dotItemWithInterval); return dotItemWithInterval.getItem().getPropertyValue(); }
public void editSelection() { int selRow = dataTable.getSelectedRow(); if (selRow >= 0) { InputFile inputFile = document.getInputFiles().get(selRow); editSettings(inputFile); } }
/** Removes the room that is currently selected. */ void removeSelectedRoom() { ChatRoomWrapper chatRoomWrapper = chatRoomsTableModel.getValueAt(chatRoomList.getSelectedRow()); ConferenceChatManager conferenceManager = GuiActivator.getUIService().getConferenceChatManager(); conferenceManager.removeChatRoom(chatRoomWrapper); }
public void setOptions(BeautiOptions options) { this.options = options; resetPanel(); settingOptions = true; int selRow = partitionTable.getSelectedRow(); partitionTableModel.fireTableDataChanged(); if (options.getDataPartitions().size() > 0) { if (selRow < 0) { selRow = 0; } partitionTable.getSelectionModel().setSelectionInterval(selRow, selRow); setCurrentPartition(options.getDataPartitions().get(selRow)); } AncestralStatesOptionsPanel panel = optionsPanels.get(currentPartition); if (panel != null) { panel.setupPanel(); } settingOptions = false; validate(); repaint(); }
public void popuniSaPodacima(long idSelektiranogKlijenta) { // Isprazni tabelu dostava //obracuniJTable.setModel(new ObracuniTableModel()); // Uzmi sve klijente iz baze Baza baza = Baza.getBaza(); List<Klijent> sviKlijenti = baza.dajSve(Klijent.class); // izfiltriraj one klijente koji su obrisani ukloniObrisaneKlijenteIz(sviKlijenti); // Napravi jComboBoxItem-ove sa svim klijentima List<JComboBoxItem> sviKlijentiJComboBoxItemi = new ArrayList<JComboBoxItem>(); for (Klijent k : sviKlijenti) { sviKlijentiJComboBoxItemi.add(new JComboBoxItem(k.getId(), k.getIme())); } // Popuni obracunZaJComboBox sa JComboBoxItem-ovima GuiUtilities.popuniJComboBoxSa(sviKlijentiJComboBoxItemi, obracunZaJComboBox, idSelektiranogKlijenta); // Popuni tabelu obracuni sa obracunima za klijenta koji ima idSelektiranogKlijenta Klijent selektiraniKlijent = baza.dajPoId(Klijent.class, idSelektiranogKlijenta); popuniObracuniJTableSaPodacimaOKlijentu(selektiraniKlijent); // Oznaci prvi red u tabeli za dostave if (obracuniJTable.getRowCount() > 0) { ListSelectionModel selectionModel = obracuniJTable.getSelectionModel(); selectionModel.setSelectionInterval(0, 0); // Uzmi oznaceni obracun iz tabele Racun Racun oznaceniRacun = ((ObracuniTableModel) obracuniJTable.getModel()).getRacuniZaKlijenta() .get(obracuniJTable.getSelectedRow()); } // Refreshati panel osvjeziJPanel(); }
/** 删除 */ private void processDeleteEvent() { int index = timeTable.getSelectedRow(); if (index == -1) return; JTimeTableModel model = (JTimeTableModel) timeTable.getModel(); if (index < model.timeList.size()) model.timeList.removeElementAt(index); timeTable.updateUI(); }
public void tblDiario_mouseClicked(MouseEvent e) { this.setCursor(AppInstance.waitCursor); Object[] row = (Object[]) this.modelDiarioVentasDeContado1.data.get(tblDiario.getSelectedRow()); frmDatosVenta.idVenta = Integer.parseInt(row[0].toString()); frmDatosVenta.ponerDatosVenta(); frmDatosVenta.setVisible(true); this.setCursor(AppInstance.defCursor); }
/** Creates and displays the main GUI This GUI has the list and the main * buttons */ public void showGUI() { final JScrollPane scrollPane = new JScrollPane(); table = new JTable( new DefaultTableModel( new Object[][] {}, new String[] {"Username", "Password", "Pin", "Reward"})); AccountManager.loadAccounts(); if (AccountManager.hasAccounts()) { for (Account account : AccountManager.getAccounts()) { ((DefaultTableModel) table.getModel()) .addRow( new Object[] { account.getUsername(), account.getReward(), account.getPin(), account.getReward() }); } } final JToolBar bar = new JToolBar(); bar.setMargin(new Insets(1, 1, 1, 1)); bar.setFloatable(false); removeButton = new JButton("Remove"); final JButton newButton = new JButton("Add"); final JButton doneButton = new JButton("Save"); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.getSelectionModel().addListSelectionListener(new TableSelectionListener()); table.setShowGrid(true); final TableColumnModel cm = table.getColumnModel(); cm.getColumn(cm.getColumnIndex("Password")).setCellRenderer(new PasswordCellRenderer()); cm.getColumn(cm.getColumnIndex("Password")).setCellEditor(new PasswordCellEditor()); cm.getColumn(cm.getColumnIndex("Pin")).setCellRenderer(new PasswordCellRenderer()); cm.getColumn(cm.getColumnIndex("Pin")).setCellEditor(new PasswordCellEditor()); cm.getColumn(cm.getColumnIndex("Reward")).setCellEditor(new RandomRewardEditor()); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setViewportView(table); add(scrollPane, BorderLayout.CENTER); newButton.setFocusable(false); newButton.setToolTipText(newButton.getText()); newButton.setText("+"); bar.add(newButton); removeButton.setFocusable(false); removeButton.setToolTipText(removeButton.getText()); removeButton.setText("-"); bar.add(removeButton); bar.add(Box.createHorizontalGlue()); doneButton.setToolTipText(doneButton.getText()); bar.add(doneButton); newButton.addActionListener(this); removeButton.addActionListener(this); doneButton.addActionListener(this); add(bar, BorderLayout.SOUTH); final int row = table.getSelectedRow(); removeButton.setEnabled(row >= 0 && row < table.getRowCount()); table.clearSelection(); doneButton.requestFocus(); setPreferredSize(new Dimension(600, 300)); pack(); setLocationRelativeTo(getOwner()); setResizable(false); }
private void addRow() { if (table.getSelectedRow() != -1) { // inserts row below the selected one else bottom int numRow = table.getRowCount(); dtm.insertRow(numRow + 1, ",".split(",")); } else { dtm.addRow(",".split(",")); } }
public void valueChanged(ListSelectionEvent e) { int baris = tabel.getSelectedRow(); System.out.println("Baris " + baris + "dipilih"); if (baris > -1) { Mahasiswa x = data.get(baris); System.out.println("NPM: " + x.getNpm()); } }
private void rebuildPopup( @NotNull final UsageViewImpl usageView, @NotNull final List<Usage> usages, @NotNull List<UsageNode> nodes, @NotNull final JTable table, @NotNull final JBPopup popup, @NotNull final UsageViewPresentation presentation, @NotNull final RelativePoint popupPosition, boolean findUsagesInProgress) { ApplicationManager.getApplication().assertIsDispatchThread(); boolean shouldShowMoreSeparator = usages.contains(MORE_USAGES_SEPARATOR); if (shouldShowMoreSeparator) { nodes.add(MORE_USAGES_SEPARATOR_NODE); } String title = presentation.getTabText(); String fullTitle = getFullTitle( usages, title, shouldShowMoreSeparator, nodes.size() - (shouldShowMoreSeparator ? 1 : 0), findUsagesInProgress); ((AbstractPopup) popup).setCaption(fullTitle); List<UsageNode> data = collectData(usages, nodes, usageView, presentation); MyModel tableModel = setTableModel(table, usageView, data); List<UsageNode> existingData = tableModel.getItems(); int row = table.getSelectedRow(); int newSelection = updateModel(tableModel, existingData, data, row == -1 ? 0 : row); if (newSelection < 0 || newSelection >= tableModel.getRowCount()) { TableScrollingUtil.ensureSelectionExists(table); newSelection = table.getSelectedRow(); } else { table.getSelectionModel().setSelectionInterval(newSelection, newSelection); } TableScrollingUtil.ensureIndexIsVisible(table, newSelection, 0); setSizeAndDimensions(table, popup, popupPosition, data); }
private void parametersSelectionChanged() { int selRow = parametersTable.getSelectedRow(); if (selRow >= 0) { removeParameterAction.setEnabled(true); } if (dependentParameterList.size() <= 0) { removeParameterAction.setEnabled(false); } }
private ToolAdapterOperatorDescriptor requestSelection() { ToolAdapterOperatorDescriptor selected = null; int selectedRow = operatorsTable.getSelectedRow(); if (selectedRow >= 0) { selected = ((OperatorsTableModel) operatorsTable.getModel()).getObjectAt(selectedRow); } else { SnapDialogs.showWarning(Bundle.MessageNoSelection_Text()); } return selected; }
private void moveItemUp() { int index = menuItemsTable.getSelectedRow(); // Return if nothing was selected. if (index == -1) return; // Return if the first item is selected. if (index == 0) return; nodeAttributesDialog.moveParameterItemUp(parameter, index); // TODO: Changing the selection doesn't have any effect on Mac. menuItemsTable.changeSelection(index - 1, 1, false, false); }
/** Listener to handle button actions */ public void actionPerformed(ActionEvent e) { // Check if the user pressed the remove button if (e.getSource() == remove_button) { int row = table.getSelectedRow(); model.removeRow(row); table.clearSelection(); table.repaint(); valueChanged(null); } // Check if the user pressed the remove all button if (e.getSource() == remove_all_button) { model.clearAll(); table.setRowSelectionInterval(0, 0); table.repaint(); valueChanged(null); } // Check if the user pressed the filter button if (e.getSource() == filter_button) { filter.showDialog(); if (filter.okPressed()) { // Update the display with new filter model.setFilter(filter); table.repaint(); } } // Check if the user pressed the start button if (e.getSource() == start_button) { start(); } // Check if the user pressed the stop button if (e.getSource() == stop_button) { stop(); } // Check if the user wants to switch layout if (e.getSource() == layout_button) { details_panel.remove(details_soap); details_soap.removeAll(); if (details_soap.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) { details_soap = new JSplitPane(JSplitPane.VERTICAL_SPLIT); } else { details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); } details_soap.setTopComponent(request_panel); details_soap.setRightComponent(response_panel); details_soap.setResizeWeight(.5); details_panel.add(details_soap, BorderLayout.CENTER); details_panel.validate(); details_panel.repaint(); } // Check if the user is changing the reflow option if (e.getSource() == reflow_xml) { request_text.setReflowXML(reflow_xml.isSelected()); response_text.setReflowXML(reflow_xml.isSelected()); } }
// appointment time and what not public void mouseClicked(MouseEvent e) { int row = Cal.getSelectedRow(); // this will give you the row number int col = Cal.getSelectedColumn(); // this will give you the column number if (row != -1 && col != -1 && Cal.getValueAt(row, col) != null) { // this now will only activate when there is an actual date associated with // that day input(row, col, currentYear); } }
/** 改变ScheduleObject对象. */ private void processTaskTable() { Vector v = getCTimeList(); if (taskTable == null) return; int index = taskTable.getSelectedRow(); if (index > -1) { JTaskTableModel model = (JTaskTableModel) taskTable.getModel(); JTaskObject task = (JTaskObject) model.taskList.get(index); task.schedule.modeContent = v; model.setValueAt(task, index, 0); } }
private void moveItemDown() { int index = menuItemsTable.getSelectedRow(); // Return if nothing was selected. if (index == -1) return; java.util.List<Parameter.MenuItem> items = parameter.getMenuItems(); // Return if the last item is selected. if (index >= items.size() - 1) return; nodeAttributesDialog.moveParameterItemDown(parameter, index); // TODO: Changing the selection doesn't have any effect on Mac. menuItemsTable.changeSelection(index + 1, 1, false, false); }
public void comprar(JTable table) { Cliente c = null; Producto p = null; double precio = 0; try { c = busquedaCliente(table); p = sistema.getEmpresa().getProductos().get(table.getSelectedRow()); precio = p.getPrecio(); // Codigo para la compra sistema .getEmpresa() .nuevaCompra( c.getNombre(), c.getApellido(), c.getCedula(), p.getMarca(), p.getModelo(), p.getPrecio(), p.getClave()); JOptionPane.showMessageDialog( this, "El cliente " + "ha comprado exitosamente este producto.\n" + "Producto: " + sistema.getEmpresa().getProductos().get(table.getSelectedRow()).getMarca() + " " + sistema.getEmpresa().getProductos().get(table.getSelectedRow()).getModelo() + "\n" + "Ingreso para la empresa: " + precio); sistema.getGuardar().guardarVentas(sistema, null); sistema.getEmpresa().setIngreso(precio); sistema.getEmpresa().setNumVentas(1); guardarVentaIngreso(); abrirMenuFacturar(c, p); sistema.mostrarPanel(PanelBase.PANEL_INICIO); } catch (ArrayIndexOutOfBoundsException ex) { JOptionPane.showMessageDialog(this, "No se ha seleccionado una computadora"); } }
public void actionPerformed(final ActionEvent e) { if (e.getSource() instanceof JButton) { final JButton button = (JButton) e.getSource(); if (button.getText().equals("Save")) { AccountManager.getAccounts().clear(); String[] data = new String[4]; for (int i = 0; i < table.getRowCount(); i++) { for (int x = 0; x < table.getColumnCount(); x++) { data[x] = (String) table.getValueAt(i, x); } AccountManager.getAccounts().add(new Account(data[0], data[1], data[2], data[3])); } AccountManager.saveAccounts(); dispose(); } else if (button.getToolTipText().equals("Add")) { final String str = JOptionPane.showInputDialog( getParent(), "Enter the account username:"******"New Account", JOptionPane.QUESTION_MESSAGE); if (str == null || str.isEmpty()) { return; } final int row = table.getRowCount(); ((DefaultTableModel) table.getModel()).addRow(new Object[] {str, null, null, null}); ((DefaultTableModel) table.getModel()).fireTableRowsInserted(row, row); } else if (button.getToolTipText().equals("Remove")) { final int row = table.getSelectedRow(); final String user = (String) table.getModel().getValueAt(table.getSelectedRow(), 0); if (user != null) { for (int i = 0; i < AccountManager.getAccounts().size(); i++) { if (AccountManager.getAccounts().get(i).getUsername().equals(user)) { AccountManager.getAccounts().remove(i); } } ((DefaultTableModel) table.getModel()).fireTableRowsDeleted(row, row); } } } }
@Override public void valueChanged(ListSelectionEvent lsEve) { int rowNum = table.getSelectedRow(); int colNum = table.getSelectedColumn(); // System.out.println("Reached in else"); if (colNum > 0) { selectAllCB.setVisible(false); deleteBut.setVisible(false); new MessagePan(rowNum, workingSet); backBut.setVisible(true); Home.home.homeFrame.setVisible(true); } }