コード例 #1
0
ファイル: CheckBoxList.java プロジェクト: rdolphin/jide-oss
 protected void toggleSelections() {
   int[] indices = _list.getSelectedIndices();
   CheckBoxListSelectionModel selectionModel = _list.getCheckBoxListSelectionModel();
   selectionModel.removeListSelectionListener(this);
   selectionModel.setValueIsAdjusting(true);
   try {
     if (indices.length > 0) {
       boolean selected = selectionModel.isSelectedIndex(indices[0]);
       for (int index : indices) {
         if (!_list.isCheckBoxEnabled(index)) {
           continue;
         }
         if (selected && selectionModel.isSelectedIndex(index)) {
           selectionModel.removeSelectionInterval(index, index);
         } else if (!selected && !selectionModel.isSelectedIndex(index)) {
           selectionModel.addSelectionInterval(index, index);
         }
       }
     }
   } finally {
     selectionModel.setValueIsAdjusting(false);
     selectionModel.addListSelectionListener(this);
     _list.repaint();
   }
 }
コード例 #2
0
    public void mouseReleased(MouseEvent e) {
      if (e.isConsumed()) {
        return;
      }

      if (!_list.isCheckBoxEnabled()) {
        return;
      }

      if (!_list.isClickInCheckBoxOnly() || clicksInCheckBox(e)) {
        e.consume();
      }
    }
コード例 #3
0
ファイル: CheckBoxList.java プロジェクト: rdolphin/jide-oss
    protected boolean clicksInCheckBox(MouseEvent e) {
      int index = _list.locationToIndex(e.getPoint());
      Rectangle bounds = _list.getCellBounds(index, index);

      if (bounds != null) {
        if (_list.getComponentOrientation().isLeftToRight()) {
          return e.getX() < bounds.x + hotspot;
        } else {
          return e.getX() > bounds.x + bounds.width - hotspot;
        }
      } else {
        return false;
      }
    }
コード例 #4
0
  private void reloadList() {
    myList.clear();
    final List<RDefaultRepository> repositories = myController.getDefaultRepositories();
    RPackageService service = RPackageService.getInstance();

    for (RDefaultRepository repository : repositories) {
      myList.addItem(
          repository,
          repository.getUrl(),
          service.enabledRepositories.contains(repository.getUrl()));
    }
    for (String repository : service.userRepositories) {
      myList.addItem(repository, repository, true);
    }
  }
コード例 #5
0
    public void mousePressed(MouseEvent e) {
      if (e.isConsumed()) {
        return;
      }

      if (!_list.isCheckBoxEnabled()) {
        return;
      }

      if (!_list.isClickInCheckBoxOnly() || clicksInCheckBox(e)) {
        int index = _list.locationToIndex(e.getPoint());
        toggleSelection(index);
        e.consume();
      }
    }
コード例 #6
0
 @Override
 protected void doOKAction() {
   this.processDoNotAskOnOk(0);
   if (this.getOKAction().isEnabled()) {
     List<RRepository> enabled = Lists.newArrayList();
     for (int i = 0; i < myList.getItemsCount(); i++) {
       if (myList.isItemSelected(i)) {
         final Object item = myList.getItemAt(i);
         enabled.add((RRepository) item);
       }
     }
     myController.setCRANMirror(currentCRANMirror);
     myController.setRepositories(enabled);
     this.close(0);
   }
 }
コード例 #7
0
ファイル: CheckBoxList.java プロジェクト: rdolphin/jide-oss
    protected void toggleSelection(int index) {
      if (!_list.isEnabled() || !_list.isCheckBoxEnabled(index)) {
        return;
      }

      CheckBoxListSelectionModel selectionModel = _list.getCheckBoxListSelectionModel();
      boolean selected = selectionModel.isSelectedIndex(index);
      selectionModel.removeListSelectionListener(this);
      try {
        if (selected) selectionModel.removeSelectionInterval(index, index);
        else selectionModel.addSelectionInterval(index, index);
      } finally {
        selectionModel.addListSelectionListener(this);
        _list.repaint();
      }
    }
コード例 #8
0
  private void doDeleteDirectory() {
    if (myResourceDir == null) {
      return;
    }

    final int selectedIndex = myDirectoriesList.getSelectedIndex();
    if (selectedIndex < 0) {
      return;
    }

    final String selectedDirName = myDirNames[selectedIndex];
    final VirtualFile selectedDir = myResourceDir.findChild(selectedDirName);
    if (selectedDir == null) {
      return;
    }

    final VirtualFileDeleteProvider provider = new VirtualFileDeleteProvider();
    provider.deleteElement(
        new DataContext() {
          @Override
          public Object getData(@NonNls String dataId) {
            if (PlatformDataKeys.VIRTUAL_FILE_ARRAY.getName().equals(dataId)) {
              return new VirtualFile[] {selectedDir};
            } else {
              return null;
            }
          }
        });
    updateDirectories(false);
  }
コード例 #9
0
ファイル: CheckBoxList.java プロジェクト: rdolphin/jide-oss
 public void intervalRemoved(ListDataEvent e) {
   /* Sync the SelectionModel with the DataModel.
    */
   ListSelectionModel listSelectionModel = _list.getCheckBoxListSelectionModel();
   if (listSelectionModel != null) {
     listSelectionModel.removeIndexInterval(e.getIndex0(), e.getIndex1());
   }
 }
コード例 #10
0
ファイル: CheckBoxList.java プロジェクト: rdolphin/jide-oss
 public void propertyChange(PropertyChangeEvent evt) {
   if (evt.getOldValue() instanceof ListModel) {
     ((ListModel) evt.getOldValue()).removeListDataListener(this);
   }
   if (evt.getNewValue() instanceof ListModel) {
     _list.getCheckBoxListSelectionModel().setModel((ListModel) evt.getNewValue());
     ((ListModel) evt.getNewValue()).addListDataListener(this);
   }
 }
コード例 #11
0
ファイル: CheckBoxList.java プロジェクト: rdolphin/jide-oss
    public void keyPressed(KeyEvent e) {
      if (e.isConsumed()) {
        return;
      }

      if (!_list.isCheckBoxEnabled()) {
        return;
      }

      if (e.getModifiers() == 0 && e.getKeyChar() == KeyEvent.VK_SPACE) toggleSelections();
    }
コード例 #12
0
 void checkRunned() {
   if (runned) {
     list.selectAll(); // Add all clusters to Field again
     contentpanel.resetColors(); // Reset the colors
     PointCategory.resetIndex(); // Reset the point index
     field.reset(); // Reset the field
     updateContentPanel();
     empty.removeAll();
     empty.validate();
     runned = false;
   }
 }
コード例 #13
0
ファイル: CheckBoxList.java プロジェクト: rdolphin/jide-oss
    public void intervalAdded(ListDataEvent e) {
      int minIndex = Math.min(e.getIndex0(), e.getIndex1());
      int maxIndex = Math.max(e.getIndex0(), e.getIndex1());

      /* Sync the SelectionModel with the DataModel.
       */

      ListSelectionModel listSelectionModel = _list.getCheckBoxListSelectionModel();
      if (listSelectionModel != null) {
        listSelectionModel.insertIndexInterval(minIndex, maxIndex - minIndex + 1, true);
      }
    }
コード例 #14
0
ファイル: CQFrame.java プロジェクト: siwells/monkeypuzzle
 public void setScheme(Subtree scheme) {
   this.scheme = scheme;
   cbList = new CheckBoxList();
   Vector<CQCheck> cqChecks = scheme.getCqChecks();
   checkBoxes = new JCheckBox[cqChecks.size()];
   for (int cq = 0; cq < cqChecks.size(); cq++) {
     CQCheck cqCheck = cqChecks.elementAt(cq);
     checkBoxes[cq] = new JCheckBox(cqCheck.getCqText());
     checkBoxes[cq].setSelected(cqCheck.isCqAnswered());
   }
   cbList.setListData(checkBoxes);
   cqScrollPane.setViewportView(cbList);
 }
コード例 #15
0
 void selectAll() {
   list.selectAll();
 }
コード例 #16
0
ファイル: CheckBoxList.java プロジェクト: rdolphin/jide-oss
 protected void toggleSelection() {
   int index = _list.getSelectedIndex();
   toggleSelection(index);
 }
コード例 #17
0
ファイル: CheckBoxList.java プロジェクト: rdolphin/jide-oss
 public void valueChanged(ListSelectionEvent e) {
   _list.repaint();
 }
コード例 #18
0
  private void updateDirectories(boolean updateFileCombo) {
    final Module module = getModule();
    List<VirtualFile> valuesDirs = Collections.emptyList();

    if (module != null) {
      final AndroidFacet facet = AndroidFacet.getInstance(module);

      if (facet != null) {
        myResourceDir = AndroidRootUtil.getResourceDir(facet);

        if (myResourceDir != null) {
          valuesDirs =
              AndroidResourceUtil.getResourceSubdirs(
                  ResourceFolderType.VALUES.getName(), new VirtualFile[] {myResourceDir});
        }
      }
    }

    Collections.sort(
        valuesDirs,
        new Comparator<VirtualFile>() {
          @Override
          public int compare(VirtualFile f1, VirtualFile f2) {
            return f1.getName().compareTo(f2.getName());
          }
        });

    final Map<String, JCheckBox> oldCheckBoxes = myCheckBoxes;
    final int selectedIndex = myDirectoriesList.getSelectedIndex();
    final String selectedDirName = selectedIndex >= 0 ? myDirNames[selectedIndex] : null;

    final List<JCheckBox> checkBoxList = new ArrayList<JCheckBox>();
    myCheckBoxes = new HashMap<String, JCheckBox>();
    myDirNames = new String[valuesDirs.size()];

    int newSelectedIndex = -1;

    int i = 0;

    for (VirtualFile dir : valuesDirs) {
      final String dirName = dir.getName();
      final JCheckBox oldCheckBox = oldCheckBoxes.get(dirName);
      final boolean selected = oldCheckBox != null && oldCheckBox.isSelected();
      final JCheckBox checkBox = new JCheckBox(dirName, selected);
      checkBoxList.add(checkBox);
      myCheckBoxes.put(dirName, checkBox);
      myDirNames[i] = dirName;

      if (dirName.equals(selectedDirName)) {
        newSelectedIndex = i;
      }
      i++;
    }
    myDirectoriesList.setModel(new CollectionListModel<JCheckBox>(checkBoxList));

    if (newSelectedIndex >= 0) {
      myDirectoriesList.setSelectedIndex(newSelectedIndex);
    }

    if (checkBoxList.size() == 1) {
      checkBoxList.get(0).setSelected(true);
    }

    if (updateFileCombo) {
      final Object oldItem = myFileNameCombo.getEditor().getItem();
      final Set<String> fileNameSet = new HashSet<String>();

      for (VirtualFile valuesDir : valuesDirs) {
        for (VirtualFile file : valuesDir.getChildren()) {
          fileNameSet.add(file.getName());
        }
      }
      final List<String> fileNames = new ArrayList<String>(fileNameSet);
      Collections.sort(fileNames);
      myFileNameCombo.setModel(new DefaultComboBoxModel(fileNames.toArray()));
      myFileNameCombo.getEditor().setItem(oldItem);
    }
  }
コード例 #19
0
 private void doUnselectAllDirs() {
   for (JCheckBox checkBox : myCheckBoxes.values()) {
     checkBox.setSelected(false);
   }
   myDirectoriesList.repaint();
 }