Ejemplo n.º 1
0
 public void reset() {
   final RowTableModel stm = (RowTableModel) getModel();
   final ListSelectionModel lsm = getSelectionModel();
   getSelectionModel().clearSelection();
   lsm.clearSelection();
   stm.reset();
 }
Ejemplo n.º 2
0
    public void install() {
      configureButton();
      loadButton.setAction(this);
      if (selectedRow == -1) {
        selectionModel.clearSelection();
      } else {
        selectionModel.setSelectionInterval(selectedRow, selectedRow);
      }
      selectionModel.addListSelectionListener(this);

      showCompanion(false);
      sheetSupport.install();
    }
Ejemplo n.º 3
0
 /**
  * Selects a set of cells.
  *
  * @param indices an array of the indices of the cells to select
  * @see ListSelectionModel#addSelectionInterval
  * @see #isSelectedIndex
  * @see #addListSelectionListener
  */
 public void setCheckBoxListSelectedIndices(int[] indices) {
   ListSelectionModel listSelectionModel = getCheckBoxListSelectionModel();
   try {
     listSelectionModel.setValueIsAdjusting(true);
     listSelectionModel.clearSelection();
     int size = getModel().getSize();
     for (int indice : indices) {
       if (indice >= 0 && indice < size) {
         listSelectionModel.addSelectionInterval(indice, indice);
       }
     }
   } finally {
     listSelectionModel.setValueIsAdjusting(false);
   }
 }
  @Override
  public void reset() {

    myPairs = new ArrayList<NameLocationPair>(myNewPairs);
    ExternalResourceManagerEx manager = ExternalResourceManagerEx.getInstanceEx();

    String[] urls = manager.getAvailableUrls();
    for (String url : urls) {
      String loc =
          myProject == null
              ? manager.getResourceLocation(url, (String) null)
              : manager.getResourceLocation(url, myProject);
      myPairs.add(new NameLocationPair(url, FileUtil.toSystemDependentName(loc), true));
    }
    if (myProject != null) {
      urls = manager.getAvailableUrls(myProject);
      for (String url : urls) {
        String loc = manager.getResourceLocation(url, myProject);
        myPairs.add(new NameLocationPair(url, FileUtil.toSystemDependentName(loc), false));
      }
    }

    Collections.sort(myPairs);

    myIgnoredUrls = new ArrayList<String>();
    final String[] ignoredResources = manager.getIgnoredResources();
    ContainerUtil.addAll(myIgnoredUrls, ignoredResources);

    Collections.sort(myIgnoredUrls);

    if (myExtPanel != null) {
      myExtPanel.setData(myPairs);
      myIgnorePanel.setData(myIgnoredUrls);
      if (!myNewPairs.isEmpty()) {
        ListSelectionModel selectionModel = myExtPanel.getTable().getSelectionModel();
        selectionModel.clearSelection();
        for (NameLocationPair newPair : myNewPairs) {
          int index = myPairs.indexOf(newPair);
          selectionModel.addSelectionInterval(index, index);
        }
      }
    }

    setModified(!myNewPairs.isEmpty());
  }
  @Override
  public void simpleMatchSelectionChanged(Collection<SimpleMatch> selected) {
    // adjust table selection to match match list selection
    // FIXME: is this really where I should be doing this?

    // selection is the same, don't do anything
    Collection<SimpleMatch> tableSelection = getSelectedFromTable();
    if (tableSelection.containsAll(selected) && tableSelection.size() == selected.size()) return;

    ListSelectionModel lsm = matchTable.getSelectionModel();
    lsm.setValueIsAdjusting(true);
    lsm.clearSelection();
    for (SimpleMatch c : selected) {
      int idx = matches.indexOf(c);
      lsm.addSelectionInterval(idx, idx);
    }
    lsm.setValueIsAdjusting(false);
  }
Ejemplo n.º 6
0
  private void resetSelection(@NotNull String[] selectedSerials) {
    MyDeviceTableModel model = (MyDeviceTableModel) myDeviceTable.getModel();
    Set<String> selectedSerialsSet = new HashSet<String>();
    Collections.addAll(selectedSerialsSet, selectedSerials);
    IDevice[] myDevices = model.myDevices;
    ListSelectionModel selectionModel = myDeviceTable.getSelectionModel();
    boolean cleared = false;

    for (int i = 0, n = myDevices.length; i < n; i++) {
      String serialNumber = myDevices[i].getSerialNumber();
      if (selectedSerialsSet.contains(serialNumber)) {
        if (!cleared) {
          selectionModel.clearSelection();
          cleared = true;
        }
        selectionModel.addSelectionInterval(i, i);
      }
    }
  }
  public void valueChanged(ListSelectionEvent e) {

    boolean isAdjusting = e.getValueIsAdjusting();
    if (isAdjusting) return;

    searchButton.setEnabled(
        ((networkSelectionModel.isSelectionEmpty()) && (localSelectionModel.isSelectionEmpty()))
            ? false
            : true);

    ListSelectionModel lsm = (ListSelectionModel) e.getSource();
    if (lsm == localSelectionModel) {
      networkSelectionModel.removeListSelectionListener(this);
      networkList.clearSelection();
      networkSelectionModel.addListSelectionListener(this);
      String localSelection = (String) localList.getSelectedValue();
      if (localSelection != null) {
        if ("local archive".equalsIgnoreCase(localSelection)) {
          rightPanelLayout.show(rPanel, SEARCH_RESULT_PANEL);
        } else if ("local directory".equalsIgnoreCase(localSelection)) {
          rightPanelLayout.show(rPanel, DIRECTORY_PANEL);
        }
        networkSelectionModel.clearSelection();
        resetSearchLabels();
      }
    } else if (lsm == networkSelectionModel) {
      rightPanelLayout.show(rPanel, SEARCH_RESULT_PANEL);
      localSelectionModel.removeListSelectionListener(this);
      localList.clearSelection();
      localSelectionModel.addListSelectionListener(this);
      updateSearchLabels((ImageServerNodeDescription) networkList.getSelectedValue());

    } else {
      if (lsm.isSelectionEmpty()) {
        if (e.getSource() == treeTable.getSelectionModel()) openArchiveButton.setEnabled(false);
        else openDirButton.setEnabled(false);
      } else {
        if (e.getSource() == treeTable.getSelectionModel()) openArchiveButton.setEnabled(true);
        else openDirButton.setEnabled(true);
      }
    }
  }
Ejemplo n.º 8
0
 /**
  * Method selectRow
  *
  * @param row int
  */
 public void selectRow(int row) {
   final ListSelectionModel lsm = getSelectionModel();
   lsm.clearSelection();
   lsm.setSelectionInterval(row, row);
   scrollToVisible(this);
 }
Ejemplo n.º 9
0
        public void valueChanged(ListSelectionEvent e) {
          if (!e.getValueIsAdjusting() && cur == null) { // prevent recursion
            ListSelectionModel lsm = (ListSelectionModel) e.getSource();
            cur = lsm;
            ListSelectionModel rfl; // reflect changes in other model
            int mn = lsm.getMinSelectionIndex();
            int mx = lsm.getMaxSelectionIndex();
            if (lsm == src) {
              rfl = dst;
            } else {
              rfl = src;
            }
            int min = 0;
            int max =
                map == null
                    ? lsm.getMaxSelectionIndex()
                    : lsm == src ? map.getSrcSize() : map.getDstSize();
            BitSet bidx = null;
            if (map != null && !map.isOneToOne()) {
              bidx = new BitSet(max + 1);
            }
            rfl.setValueIsAdjusting(true);
            if (map == null) {
              rfl.clearSelection();
            }

            for (int i = min; i <= max; i++) {
              if (map == null) {
                if (lsm.isSelectedIndex(i)) {
                  rfl.addSelectionInterval(i, i);
                } else {
                  rfl.removeSelectionInterval(i, i);
                }
              } else if (map.isOneToOne()) {
                int j = lsm == src ? map.getDst(i) : map.getSrc(i);
                if (j < 0) continue;
                if (lsm.isSelectedIndex(i)) {
                  rfl.addSelectionInterval(j, j);
                } else {
                  rfl.removeSelectionInterval(j, j);
                }
              } else {
                // How to deal with OneToMany mapping?
                // All dst indices selected -> select src index
                // Any dst indices selected -> select src index
                //
                if (!bidx.get(i)) {
                  bidx.set(i); // Flag this index as visited
                  // Get the set of destination indices
                  int di[] = lsm == src ? map.getDsts(i) : map.getSrcs(i);
                  if (di != null) {
                    for (int j = 0; j < di.length; j++) {
                      if (di[j] < 0) continue;
                      // Get the set of source indices for each destination index
                      int si[] = lsm == dst ? map.getDsts(di[j]) : map.getSrcs(di[j]);
                      if (si != null) {
                        boolean allSet = true;
                        boolean anySet = false;
                        for (int k = 0; k < si.length; k++) {
                          bidx.set(si[k]); // Flag this index as visited
                          allSet &= lsm.isSelectedIndex(si[k]);
                          anySet |= lsm.isSelectedIndex(si[k]);
                        }
                        if (allSet || (!allSelected && anySet)) {
                          rfl.addSelectionInterval(di[j], di[j]);
                        } else {
                          rfl.removeSelectionInterval(di[j], di[j]);
                        }
                      }
                    }
                  }
                }
              }
            }
            rfl.setValueIsAdjusting(false);
            cur = null;
          }
        }