/**
   * Moves the column and heading at <code>columnIndex</code> to <code>newIndex</code>. The old
   * column at <code>columnIndex</code> will now be found at <code>newIndex</code>. The column that
   * used to be at <code>newIndex</code> is shifted left or right to make room. This will not move
   * any columns if <code>columnIndex</code> equals <code>newIndex</code>. This method also posts a
   * <code>columnMoved</code> event to its listeners.
   *
   * @param columnIndex the index of column to be moved
   * @param newIndex new index to move the column
   * @exception IllegalArgumentException if <code>column</code> or <code>newIndex</code> are not in
   *     the valid range
   */
  public void moveColumn(int columnIndex, int newIndex) {
    if ((columnIndex < 0)
        || (columnIndex >= getColumnCount())
        || (newIndex < 0)
        || (newIndex >= getColumnCount()))
      throw new IllegalArgumentException("moveColumn() - Index out of range");

    TableColumn aColumn;

    // If the column has not yet moved far enough to change positions
    // post the event anyway, the "draggedDistance" property of the
    // tableHeader will say how far the column has been dragged.
    // Here we are really trying to get the best out of an
    // API that could do with some rethinking. We preserve backward
    // compatibility by slightly bending the meaning of these methods.
    if (columnIndex == newIndex) {
      fireColumnMoved(new TableColumnModelEvent(this, columnIndex, newIndex));
      return;
    }
    aColumn = (TableColumn) tableColumns.elementAt(columnIndex);

    tableColumns.removeElementAt(columnIndex);
    boolean selected = selectionModel.isSelectedIndex(columnIndex);
    selectionModel.removeIndexInterval(columnIndex, columnIndex);

    tableColumns.insertElementAt(aColumn, newIndex);
    selectionModel.insertIndexInterval(newIndex, 1, true);
    if (selected) {
      selectionModel.addSelectionInterval(newIndex, newIndex);
    } else {
      selectionModel.removeSelectionInterval(newIndex, newIndex);
    }

    fireColumnMoved(new TableColumnModelEvent(this, columnIndex, newIndex));
  }
  private void createArchiveTreeTable() {

    List l = ivcn.localFindAll();
    treeTable = new JXTreeTable(studyList);
    treeTable.setHorizontalScrollEnabled(true);
    treeTable.setRootVisible(false);
    treeTable.setShowsRootHandles(true);
    treeTable.setShowHorizontalLines(true);
    treeTable.setShowVerticalLines(true);
    treeTable.setColumnMargin(1);
    treeTable.setColumnControlVisible(false);
    treeTable.setRolloverEnabled(true);
    treeTable.setScrollsOnExpand(true);
    treeTable.setTreeCellRenderer(new TreeTableCellRenderer());
    treeTable.setAutoCreateColumnsFromModel(false);
    treeTable.setColumnFactory(
        new ColumnFactory() {
          public void configureColumnWidths(JXTable table, TableColumnExt columnExt) {}
        });
    // treeTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

    ListSelectionModel lsm = treeTable.getSelectionModel();
    lsm.addListSelectionListener(this);

    CompoundHighlighter cp = new CompoundHighlighter();
    cp.addHighlighter(new AlternateRowHighlighter(ROW_COLOR1, ROW_COLOR2, Color.white));
    cp.addHighlighter(new HierarchicalColumnHighlighter(COL_COLOR1, Color.white));

    treeTable.setHighlighters(cp);
    for (int i = 0; i < ARCHIVE_COLUMN_WIDTH.length; i++) {
      TableColumn column = treeTable.getColumnModel().getColumn(i);
      column.setPreferredWidth(ARCHIVE_COLUMN_WIDTH[i]);
      column.setHeaderRenderer(new TableHeaderRenderer(Color.black));
    }
  }
Exemplo n.º 3
0
 private void moveSelectedRows(int increment) {
   if (increment == 0) {
     return;
   }
   if (myEntryTable.isEditing()) {
     myEntryTable.getCellEditor().stopCellEditing();
   }
   final ListSelectionModel selectionModel = myEntryTable.getSelectionModel();
   for (int row = increment < 0 ? 0 : myModel.getRowCount() - 1;
       increment < 0 ? row < myModel.getRowCount() : row >= 0;
       row += increment < 0 ? +1 : -1) {
     if (selectionModel.isSelectedIndex(row)) {
       final int newRow = moveRow(row, increment);
       selectionModel.removeSelectionInterval(row, row);
       selectionModel.addSelectionInterval(newRow, newRow);
     }
   }
   myModel.fireTableRowsUpdated(0, myModel.getRowCount() - 1);
   Rectangle cellRect = myEntryTable.getCellRect(selectionModel.getMinSelectionIndex(), 0, true);
   if (cellRect != null) {
     myEntryTable.scrollRectToVisible(cellRect);
   }
   myEntryTable.repaint();
   myListeners.getMulticaster().entryMoved();
 }
    public void valueChanged(ListSelectionEvent e) {
      ListSelectionModel lsm = (ListSelectionModel) e.getSource();

      int firstIndex = e.getFirstIndex();
      int lastIndex = e.getLastIndex();
      boolean isAdjusting = e.getValueIsAdjusting();
      output.append(
          "Event for indexes "
              + firstIndex
              + " - "
              + lastIndex
              + "; isAdjusting is "
              + isAdjusting
              + "; selected indexes:");

      if (lsm.isSelectionEmpty()) {
        output.append(" <none>");
      } else {
        // Find out which indexes are selected.
        int minIndex = lsm.getMinSelectionIndex();
        int maxIndex = lsm.getMaxSelectionIndex();
        for (int i = minIndex; i <= maxIndex; i++) {
          if (lsm.isSelectedIndex(i)) {
            output.append(" " + i);
          }
        }
      }
      output.append(newline);
      output.setCaretPosition(output.getDocument().getLength());
    }
Exemplo n.º 5
0
 public void reset() {
   final RowTableModel stm = (RowTableModel) getModel();
   final ListSelectionModel lsm = getSelectionModel();
   getSelectionModel().clearSelection();
   lsm.clearSelection();
   stm.reset();
 }
  // Implementation of valueChanged
  public void valueChanged(ListSelectionEvent e) {
    if (e.getSource() == table.getSelectionModel()) {
      ListSelectionModel ls = table.getSelectionModel();

      int index = ls.getMinSelectionIndex();
      long id = (long) table.getValueAt(index, 0);

      updateFeesData(id);
    } else {
      ListSelectionModel ls = feestable.getSelectionModel();

      int index = ls.getMinSelectionIndex();

      float feespayed = (float) feestable.getValueAt(index, 1);
      float totalfees = (float) feestable.getValueAt(index, 2);

      feespayedlabel.setText("Fees Payed: " + feespayed);
      totalfeeslabel.setText("Total Fees: " + totalfees);

      if (totalfees - feespayed > 0) {
        feesduelabel.setText("Fees Due: " + (totalfees - feespayed));
      }

      panel_6.revalidate();
    }
  }
  public void initialSyncUIWithDataModel() {
    // Esto es necesario por ejemplo porque al inicializarse el UI se eliminan todos
    // los nodos, volverán a crearse al sincronizarse con el data model,
    // pero ahora sin el atributo selected que había originalmente en los nodos
    // seleccionados

    ItsNatHTMLSelectMultImpl comp = getItsNatHTMLSelectMult();
    ListSelectionModel selModel = comp.getListSelectionModel();

    int len = comp.getListModel().getSize();
    ItsNatListMultSelUIInternal compUI = comp.getItsNatListMultSelUIInternal();
    for (int i = 0; i <= len; i++) {
      boolean selected = selModel.isSelectedIndex(i);
      compUI.setSelectedIndex(i, selected);
    }

    HTMLSelectElement elem = getItsNatHTMLSelectMult().getHTMLSelectElement();
    ((ItsNatNodeInternal) elem)
        .addEventListenerInternal(
            "DOMCharacterDataModified",
            this,
            false); // Para cuando cambie el contenido de una opción
    ((ItsNatNodeInternal) elem)
        .addEventListenerInternal("DOMAttrModified", this, false); // Para el atributo selected

    super.initialSyncUIWithDataModel();
  }
Exemplo n.º 8
0
    public void actionPerformed(ActionEvent e) {
      /*
       * This method can be called only if
       * there's a valid selection,
       * so go ahead and remove whatever's selected.
       */

      ListSelectionModel lsm = list.getSelectionModel();
      int firstSelected = lsm.getMinSelectionIndex();
      int lastSelected = lsm.getMaxSelectionIndex();
      listModel.removeRange(firstSelected, lastSelected);

      int size = listModel.size();

      if (size == 0) {
        // List is empty: disable delete, up, and down buttons.
        deleteButton.setEnabled(false);
        upButton.setEnabled(false);
        downButton.setEnabled(false);

      } else {
        // Adjust the selection.
        if (firstSelected == listModel.getSize()) {
          // Removed item in last position.
          firstSelected--;
        }
        list.setSelectedIndex(firstSelected);
      }
    }
 public void update(final AnActionEvent event) {
   final ListSelectionModel selectionModel = list.getSelectionModel();
   final int lastSelectedIndex = selectionModel.getMaxSelectionIndex();
   event
       .getPresentation()
       .setEnabled((lastSelectedIndex >= 0) && (lastSelectedIndex < (listModel.size() - 1)));
 }
Exemplo n.º 10
0
  /**
   * *******************************************************************************
   *
   * @return
   */
  protected File getSelectedFile() {
    ListSelectionModel selectionModel = getSelectionModel();
    int row = selectionModel.getAnchorSelectionIndex();
    DirectoryTableModel tableModel = (DirectoryTableModel) getModel();

    return tableModel.getFile(row);
  }
  @Override
  public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting()) {
      return;
    }
    configurationPanel.removeAll();
    ListSelectionModel m = (ListSelectionModel) e.getSource();
    // single selection, so max selection index is the only one selected.
    selectedIndex = m.getMaxSelectionIndex();

    JPanel panel = new DefaultReportConfigurationPanel();
    ReportModule module = modules.get(selectedIndex);
    boolean generalModuleSelected = false;
    if (module instanceof GeneralReportModule) {
      JPanel generalPanel = ((GeneralReportModule) module).getConfigurationPanel();
      panel = (generalPanel == null) ? new JPanel() : generalPanel;
      generalModuleSelected = true;
    }

    descriptionTextPane.setText(module.getDescription());
    configurationPanel.add(panel, BorderLayout.CENTER);
    configurationPanel.revalidate();

    wizPanel.setNext(!generalModuleSelected);
    wizPanel.setFinish(generalModuleSelected);
  }
Exemplo n.º 12
0
  public void updateTableUiForFoundValue(
      TableSearcherCell cell, int replacementCount, boolean isReplace) {
    // log.debug("updateTableUiForFoundValue()");
    // boolean found = cell.isFound();
    int curRow = -1;
    int curCol = -1;
    if (replacementCount > 0) {
      // log.debug("updateTableUiForFoundValue() - update for found cell");

      curRow = cell.getRow();
      curCol = cell.getColumn();
      // log.debug("updateTableUiForFoundValue() - Cell row[" + curRow + "] ");
      // log.debug("                               Cell col[" + curCol + "] ");
      // log.debug("updateTableUiForFoundValue() - preoapring to set selection model");
      if (curRow != -1 && curCol != -1) {
        ListSelectionModel rsm = table.getSelectionModel();
        ListSelectionModel csm = table.getColumnModel().getSelectionModel();
        Rectangle rect = table.getCellRect(curRow, curCol, false);
        if (!isSearchSelection()) {
          rsm.setSelectionInterval(curRow, curRow);
          csm.setSelectionInterval(curCol, curCol);
        } else {
          table.setEmphasizedCell(curRow, curCol);
          if (rect != null) {
            table.repaint(rect);
          } else {
            table.repaint();
          }
        }
        if (rect != null && table.getAutoscrolls()) {
          // log.debug("updateTableUiForFoundValue() - preparing to scroll");
          table.scrollRectToVisible(rect);
          // log.debug("updateTableUiForFoundValue() - done scrolling");
        }
      }
      if (isSearchDown()) {
        enablePreviousButton();
      } else {
        enableNextButton();
      }
      updateStatusLabel(replacementCount, isReplace);
    } else {
      // log.debug("updateTableUiForFoundValue() found nothing");
      if (isSearchDown()) {
        setFinishedSearchingDown(true);
        if (!getWrapSearchFlag()) {
          disableNextButton();
          enablePreviousButton();
        }
        setStatusLabelWithFailedFind();
      } else {
        setFinishedSearchingUp(true);
        if (!getWrapSearchFlag()) {
          disablePreviousButton();
          enableNextButton();
        }
        setStatusLabelWithFailedFind();
      }
    }
  }
      /**
       * Sorts the rows of the table alphabetically.
       *
       * @param column index of the column to sort. In this table there are only 2 columns.
       */
      public void sort(int column) {
        // Orders the layer alphabetically according the Spanish
        // alphabetically rules
        switch (column) {
          case 0:
            stringComparator.setColumn(WFSLayerStringComparator.LAYER_NAME);
            break;
          case 1:
            stringComparator.setColumn(WFSLayerStringComparator.GEOMETRY_TYPE);
            break;
        }

        if (previousColumnSorted != column) stringComparator.setAscendingOrdering(true);

        previousColumnSorted = (short) column;

        WFSLayerNode layer = getSelectedValue();

        Collections.sort(layers, stringComparator);

        if (layer != null) {
          updatingSelection = true;
          unselectAllFeatures();
          int row = Collections.binarySearch(layers, layer, stringComparator);

          if (row != -1) {
            ListSelectionModel model = getSelectionModel();
            model.setLeadSelectionIndex(row);
          }

          updatingSelection = false;
        }
        stringComparator.setAscendingOrdering(!stringComparator.isAscendingOrdering());
      }
Exemplo n.º 14
0
  public void EVENT_moveBottom(ActionEvent e) {
    int selection[] = table.getSelectedRows();

    int offset = 0;
    if (selection != null && selection.length > 0) {
      for (int i : selection) {
        DownloadWrapper dw = rows.get(i - offset);
        final Download d = dw.download;
        ui.getCore()
            .invokeLater(
                new Runnable() {

                  @Override
                  public void run() {
                    ui.getCore().getNetworkManager().getDownloadManager().moveBottom(d);
                  }
                });
        moveBottom(i - offset, dw);
        offset++;
      }
      model.fireTableStructureChanged();
      // for(int i : selection) if (i<rows.size()-1)
      // table.getSelectionModel().addSelectionInterval(i+1,i+1);
      ListSelectionModel sm = table.getSelectionModel();
      sm.addSelectionInterval(rows.size() - selection.length, rows.size() - 1);
    }
  }
    @Override
    public void valueChanged(ListSelectionEvent e) {
      //            throw new UnsupportedOperationException("Not supported yet."); //To change body
      // of generated methods, choose Tools | Templates.
      try {

        if (e.getValueIsAdjusting()) {
          return;
        }
        ListSelectionModel lsm = (ListSelectionModel) e.getSource();
        if (lsm.isSelectionEmpty()) {

        } else {
          int lead = lsm.getLeadSelectionIndex();
          view.setDepartmentInfo(displayRowValues(lead));

          view.setBtnEditEnable(true);
          view.setBtnDeleteEnable(true);
          view.setBtnAddEnable(false);
        }
      } catch (Exception se) {
        JOptionPane.showMessageDialog(
            departmentView, se + "from ListSelectionListener " + getClass().getName());
      }
    }
Exemplo n.º 16
0
    public void valueChanged(ListSelectionEvent e) {
      ListSelectionModel lsm = (ListSelectionModel) e.getSource();

      int firstIndex = e.getFirstIndex();
      int lastIndex = e.getLastIndex();
      boolean isAdjusting = e.getValueIsAdjusting();

      if (lsm.isSelectionEmpty()) {

      } else {
        // Find out which indexes are selected.
        int selected = lsm.getMinSelectionIndex();
        int index = masterTable.convertRowIndexToModel(selected);
        EntityTableModel etm = (EntityTableModel) masterTable.getModel();
        Cita c = (Cita) etm.getBeanAt(index);

        Integer id = c.getIdCita();
        String nombreCliente = c.getCliente().getNombre() + " " + c.getCliente().getApellido();
        String nombreSesion = c.getSesion().getDescripcion();
        Date fechaCita = c.getFechaCita();
        Integer minutosMaquina = c.getDuracion();

        txtId.setText(id.toString());
        //            txtNombre.setText(nombre);
        //            txtDescripcion.setText(descripcion);
        //            txtCosto.setValue(costo);
        try {
          txtCosto.commitEdit();
        } catch (ParseException ex) {
          Logger.getLogger(CitasView.class.getName()).log(Level.SEVERE, null, ex);
        }

        modificar = true;
      }
    }
    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();
    }
Exemplo n.º 18
0
 /**
  * Recursive traverse of tree to determine selections A leaf is selected if rsm is selected.
  * Nonleaf nodes are selected if all children are selected.
  *
  * @param tn node in the tree for which to determine selection
  * @param nodeidx the ordinal postion in the segments array
  * @param gsm the graph segments selection model
  * @param rsm the table row selection model
  * @return true if given node tn is selected, else false
  */
 private boolean selTraverse(
     TreeNode tn, int[] nodeidx, ListSelectionModel gsm, ListSelectionModel rsm) {
   boolean selected = true;
   if (!tn.isLeaf()) {
     // A nonleaf node is selected if all its children are selected.
     for (int i = 0; i < tn.getChildCount(); i++) {
       TreeNode cn = tn.getChildAt(i);
       selected &= selTraverse(cn, nodeidx, gsm, rsm);
     }
   } else {
     if (tn instanceof RowCluster) {
       // get the row index of the leaf node
       int ri = ((RowCluster) tn).getIndex();
       // A leaf is selected if its row is selected in the row selection rsm.
       selected = rsm.isSelectedIndex(ri);
     }
   }
   // Get the offset into the segments array
   int idx = nodeidx[0] * segOffset;
   if (selected) {
     gsm.addSelectionInterval(idx, idx + (segOffset - 1));
   } else {
     gsm.removeSelectionInterval(idx, idx + (segOffset - 1));
   }
   // Increment the nodeidx in the tree
   nodeidx[0]++;
   return selected;
 }
  private JPanel createLeftPanel() {

    ImageViewerClientNode ivcn = ImageViewerClientNode.getInstance();
    String[] localListArray =
        (ivcn.hasLocalArchive())
            ? (new String[] {"Local archive", "Local directory"})
            : (new String[] {"Local directory"});
    localList = new JXList(localListArray);
    localList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    localSelectionModel = localList.getSelectionModel();
    localSelectionModel.addListSelectionListener(this);
    JScrollPane localListScrollPane =
        new JScrollPane(
            localList,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    localListScrollPane.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    localListScrollPane.setPreferredSize(new Dimension(194, 300));
    localList.setSelectionForeground(Color.white);
    localList.setSelectionBackground(Color.darkGray);
    localList.setBackground(ROW_COLOR1); // Color.darkGray);
    localList.setForeground(Color.white);

    List<ImageServerNodeDescription> nodes =
        ImageViewerClientNode.getInstance().getQueryableNodes();
    networkList = (nodes != null) ? (new JXList(nodes.toArray())) : (new JXList());
    networkList.setCellRenderer(new NodeDescriptionRenderer());
    networkList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    networkSelectionModel = networkList.getSelectionModel();
    networkSelectionModel.addListSelectionListener(this);
    JScrollPane networkListScrollPane =
        new JScrollPane(
            networkList,
            JScrollPane.VERTICAL_SCROLLBAR_NEVER,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    networkListScrollPane.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    networkListScrollPane.setPreferredSize(new Dimension(194, 300));
    networkList.setSelectionForeground(Color.white);
    networkList.setSelectionBackground(Color.darkGray);
    networkList.setBackground(ROW_COLOR1); // Color.darkGray);
    networkList.setForeground(Color.white);

    JPanel listPanel = new JPanel(new BorderLayout(0, 5));
    JOutlookBar job = new JOutlookBar();
    job.addTab(
        "Local resources",
        new ImageIcon("resources/icons/swing/computer.png"),
        localListScrollPane);
    job.addTab(
        "Network resources",
        new ImageIcon("resources/icons/swing/network.png"),
        networkListScrollPane);
    job.setUI((TabbedPaneUI) (new ImageViewerOutlookBarUI()));

    listPanel.add(job, BorderLayout.CENTER);
    listPanel.add(refreshButton, BorderLayout.SOUTH);
    listPanel.setBorder(new EmptyBorder(0, 0, 0, 5));
    return listPanel;
  }
Exemplo n.º 20
0
 /**
  * Set the selection behavior for a OneToManyIndexMap.
  *
  * @param allSelected This only applies to OneToManyIndexMaps, if true all destination indices
  *     must be selected in order for the source index to be selected, if false then the source
  *     index is selected if any of its associated destination indices are selected.
  */
 public void setAllSelected(boolean allSelected) {
   this.allSelected = allSelected;
   if (map != null && !map.isOneToOne()) {
     selListener.valueChanged(
         new ListSelectionEvent(
             src, src.getMinSelectionIndex(), src.getMaxSelectionIndex(), false));
   }
 }
Exemplo n.º 21
0
 public void intervalRemoved(ListDataEvent e) {
   /* Sync the SelectionModel with the DataModel.
    */
   ListSelectionModel listSelectionModel = _list.getCheckBoxListSelectionModel();
   if (listSelectionModel != null) {
     listSelectionModel.removeIndexInterval(e.getIndex0(), e.getIndex1());
   }
 }
Exemplo n.º 22
0
 private void connectListeners() {
   final ListSelectionModel messageLedgerSelectionModel = messageLedger.getSelectionModel();
   messageLedgerSelectionModel.addListSelectionListener(new MessageLedgerListener());
   for (Object action : Actions.getActions()) {
     if (action instanceof ListSelectionListener) {
       messageLedgerSelectionModel.addListSelectionListener((ListSelectionListener) action);
     }
   }
 }
  @Override
  public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting()) return;
    ListSelectionModel lsm = (ListSelectionModel) e.getSource();
    if (e.getSource() == mapTable.getSelectionModel()) {
      mapErrorsLabel.setText("");
      if (lsm.isSelectionEmpty()) {
        mapDeleteButton.setEnabled(false);
        mapUpButton.setEnabled(false);
        mapDownButton.setEnabled(false);

        ruleTable.setModel(new DefaultTableModel());
        ruleInsertButton.setEnabled(false);
      } else {
        mapDeleteButton.setEnabled(true);

        int selrow = mapTable.getSelectedRow();
        int rows = mapTable.getRowCount();

        if (selrow > 0) mapUpButton.setEnabled(true);
        else mapUpButton.setEnabled(false);

        if (selrow < (rows - 1)) mapDownButton.setEnabled(true);
        else mapDownButton.setEnabled(false);

        MapRule maprule = this.editableSRX.getMappingRules().get(selrow);
        SegmentationRulesModel model = new SegmentationRulesModel(maprule.getRules());
        ruleTable.setModel(model);
        model.addExceptionListener(
            new ExceptionListener() {
              @Override
              public void exceptionThrown(Exception e) {
                ruleErrorsLabel.setText(e.getLocalizedMessage());
              }
            });
        ruleInsertButton.setEnabled(true);
      }
    } else if (e.getSource() == ruleTable.getSelectionModel()) {
      ruleErrorsLabel.setText("");
      if (lsm.isSelectionEmpty()) {
        ruleDeleteButton.setEnabled(false);
        ruleUpButton.setEnabled(false);
        ruleDownButton.setEnabled(false);
      } else {
        ruleDeleteButton.setEnabled(true);

        int rules = ruleTable.getRowCount();
        int rulerow = ruleTable.getSelectedRow();

        if (rulerow > 0) ruleUpButton.setEnabled(true);
        else ruleUpButton.setEnabled(false);

        if (rulerow < (rules - 1)) ruleDownButton.setEnabled(true);
        else ruleDownButton.setEnabled(false);
      }
    }
  }
Exemplo n.º 24
0
 public void cleanUp() {
   if (src != null) {
     src.removeListSelectionListener(selListener);
     src = null;
   }
   if (dst != null) {
     dst.removeListSelectionListener(selListener);
     dst = null;
   }
 }
 private Collection<SimpleMatch> getSelectedFromTable() {
   ListSelectionModel lsm = matchTable.getSelectionModel();
   Collection<SimpleMatch> selMatches = new HashSet<>();
   for (int i = lsm.getMinSelectionIndex(); i <= lsm.getMaxSelectionIndex(); i++) {
     if (lsm.isSelectedIndex(i) && i < matches.size()) {
       selMatches.add(matches.get(i));
     }
   }
   return selMatches;
 }
Exemplo n.º 26
0
 @Override
 public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
   ListSelectionModel selectionModel = getSelectionModel();
   boolean selected = selectionModel.isSelectedIndex(rowIndex);
   if (selected) {
     selectionModel.removeSelectionInterval(rowIndex, rowIndex);
   } else {
     selectionModel.addSelectionInterval(rowIndex, rowIndex);
   }
 }
Exemplo n.º 27
0
 private JLabel renderTableCell(int rowIndex, int columnIndex) {
   TableCellRenderer cellRenderer = table.getCellRenderer(rowIndex, columnIndex);
   Object cellValue = table.getValueAt(rowIndex, columnIndex);
   ListSelectionModel selectionModel = table.getSelectionModel();
   boolean selected =
       rowIndex >= selectionModel.getMinSelectionIndex()
           && rowIndex <= selectionModel.getMaxSelectionIndex();
   return (JLabel)
       cellRenderer.getTableCellRendererComponent(
           table, cellValue, selected, false, rowIndex, columnIndex);
 }
Exemplo n.º 28
0
  private void checkImportability() {
    if (isVCFVerified || (ignorePINCheckbox.isSelected())) {
      ListSelectionModel model = (ListSelectionModel) importContactsTable.getSelectionModel();

      if ((importContactsTable.getRowCount() > 0) && (!model.isSelectionEmpty())) {
        importButton.setEnabled(true);
        return;
      }
    }
    importButton.setEnabled(false);
  }
  /** Updates the list with no feature selected. */
  public void unselectAllFeatures() {
    // Reset the last row selection of the features table
    int numberOfFeatures = getLstFeatures().getRowCount();

    if (numberOfFeatures > 0) {
      ListSelectionModel model = getLstFeatures().getSelectionModel();
      model.removeSelectionInterval(0, numberOfFeatures - 1); // whatever
      // row
      // selection
    }
  }
  private void changeSelection() {
    ListSelectionModel model = myTable.getSelectionModel();
    AutomatonEditorPanel<T, S> panel = getEditorPanel();
    panel.clearSelection();

    int min = model.getMinSelectionIndex(), max = model.getMaxSelectionIndex();
    if (min < 0) return;
    for (int i = min; i <= max; i++)
      if (model.isSelectedIndex(i) && myObjectMap.containsKey(i))
        panel.selectObject(myObjectMap.get(i));
  }