Java 类com.intellij.util.ui.ThreeStateCheckBox 实例源码

项目:intellij-ce-playground    文件:MultipleFacetEditorHelperImpl.java   
public CheckBoxBinding(final ThreeStateCheckBox common, final List<JCheckBox> checkBoxesList) {
  LOG.assertTrue(!checkBoxesList.isEmpty());
  myCommon = common;
  myCheckBoxesList = checkBoxesList;

  Boolean initialValue = checkBoxesList.get(0).isSelected();
  myInitialValues = new ArrayList<Boolean>();
  for (JCheckBox checkBox : checkBoxesList) {
    boolean value = checkBox.isSelected();
    myInitialValues.add(value);
    if (initialValue != null && value != initialValue) {
      initialValue = null;
    }
  }
  if (initialValue != null) {
    common.setThirdStateEnabled(false);
    common.setSelected(initialValue);
  }
  else {
    common.setThirdStateEnabled(true);
    common.setState(ThreeStateCheckBox.State.DONT_CARE);
  }

  myCommon.addActionListener(this);
}
项目:intellij-ce-playground    文件:MultipleFacetEditorHelperImpl.java   
@Override
public void actionPerformed(final ActionEvent e) {
  ThreeStateCheckBox.State state = myCommon.getState();
  for (int i = 0; i < myCheckBoxesList.size(); i++) {
    boolean value = state == ThreeStateCheckBox.State.SELECTED ? true : state == ThreeStateCheckBox.State.NOT_SELECTED ? false : myInitialValues.get(i);
    JCheckBox checkBox = myCheckBoxesList.get(i);

    if (value != checkBox.isSelected()) {
      ButtonModel model = checkBox.getModel();
      model.setArmed(true);
      model.setPressed(true);
      model.setPressed(false);
      model.setArmed(false);
    }
  }
}
项目:intellij-ce-playground    文件:UpdaterTreeNode.java   
public Renderer() {
  super(new BorderLayout());
  myCheckbox = new ThreeStateCheckBox();
  myTextRenderer = new ColoredTreeCellRenderer() {
    @Override
    public void customizeCellRenderer(@NotNull JTree tree,
                                      Object value,
                                      boolean selected,
                                      boolean expanded,
                                      boolean leaf,
                                      int row,
                                      boolean hasFocus) {
    }
  };
  myTextRenderer.setOpaque(true);
  add(myCheckbox, BorderLayout.WEST);
  add(myTextRenderer, BorderLayout.CENTER);
}
项目:tools-idea    文件:MultipleFacetEditorHelperImpl.java   
public CheckBoxBinding(final ThreeStateCheckBox common, final List<JCheckBox> checkBoxesList) {
  LOG.assertTrue(!checkBoxesList.isEmpty());
  myCommon = common;
  myCheckBoxesList = checkBoxesList;

  Boolean initialValue = checkBoxesList.get(0).isSelected();
  myInitialValues = new ArrayList<Boolean>();
  for (JCheckBox checkBox : checkBoxesList) {
    boolean value = checkBox.isSelected();
    myInitialValues.add(value);
    if (initialValue != null && value != initialValue) {
      initialValue = null;
    }
  }
  if (initialValue != null) {
    common.setThirdStateEnabled(false);
    common.setSelected(initialValue);
  }
  else {
    common.setThirdStateEnabled(true);
    common.setState(ThreeStateCheckBox.State.DONT_CARE);
  }

  myCommon.addActionListener(this);
}
项目:tools-idea    文件:MultipleFacetEditorHelperImpl.java   
@Override
public void actionPerformed(final ActionEvent e) {
  ThreeStateCheckBox.State state = myCommon.getState();
  for (int i = 0; i < myCheckBoxesList.size(); i++) {
    boolean value = state == ThreeStateCheckBox.State.SELECTED ? true : state == ThreeStateCheckBox.State.NOT_SELECTED ? false : myInitialValues.get(i);
    JCheckBox checkBox = myCheckBoxesList.get(i);

    if (value != checkBox.isSelected()) {
      ButtonModel model = checkBox.getModel();
      model.setArmed(true);
      model.setPressed(true);
      model.setPressed(false);
      model.setArmed(false);
    }
  }
}
项目:intellij-ce-playground    文件:ArtifactEditorImpl.java   
public void updateShowContentCheckbox() {
  final ThreeStateCheckBox.State state;
  if (mySubstitutionParameters.isAllSubstituted()) {
    state = ThreeStateCheckBox.State.SELECTED;
  }
  else if (mySubstitutionParameters.isNoneSubstituted()) {
    state = ThreeStateCheckBox.State.NOT_SELECTED;
  }
  else {
    state = ThreeStateCheckBox.State.DONT_CARE;
  }
  myShowContentCheckBox.setThirdStateEnabled(state == ThreeStateCheckBox.State.DONT_CARE);
  myShowContentCheckBox.setState(state);
  onShowContentSettingsChanged();
}
项目:intellij-ce-playground    文件:MultipleFacetEditorHelperImpl.java   
@Override
public void bind(@NotNull ThreeStateCheckBox common, @NotNull FacetEditor[] editors, @NotNull NotNullFunction<FacetEditor, JCheckBox> fun) {
  List<JCheckBox> checkBoxesList = new ArrayList<JCheckBox>();
  for (FacetEditor editor : editors) {
    checkBoxesList.add(fun.fun(editor));
  }

  CheckBoxBinding checkBoxBinding = new CheckBoxBinding(common, checkBoxesList);
  myBindings.add(checkBoxBinding);
}
项目:intellij-ce-playground    文件:UpdaterTreeNode.java   
@Override
public final Component getTreeCellRendererComponent(JTree tree,
                                                    Object value,
                                                    boolean selected,
                                                    boolean expanded,
                                                    boolean leaf,
                                                    int row,
                                                    boolean hasFocus) {
  if (!(value instanceof UpdaterTreeNode)) {
    return null;
  }
  UpdaterTreeNode node = (UpdaterTreeNode)value;
  invalidate();
  myCheckbox.setVisible(true);
  if (node.getCurrentState() == NodeStateHolder.SelectedState.MIXED) {
    myCheckbox.setState(ThreeStateCheckBox.State.DONT_CARE);
  }
  else {
    myCheckbox.setSelected(node.getCurrentState() == NodeStateHolder.SelectedState.INSTALLED);
  }
  myCheckbox.setOpaque(false);
  myCheckbox.setBackground(null);
  setBackground(null);
  myTextRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);

  if (UIUtil.isUnderGTKLookAndFeel()) {
    final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
    UIUtil.changeBackGround(this, background);
  }
  else if (UIUtil.isUnderNimbusLookAndFeel()) {
    UIUtil.changeBackGround(this, UIUtil.TRANSPARENT_COLOR);
  }
  node.customizeRenderer(this, tree, selected, expanded, leaf, row, hasFocus);
  revalidate();

  return this;
}
项目:tools-idea    文件:ArtifactEditorImpl.java   
public void updateShowContentCheckbox() {
  final ThreeStateCheckBox.State state;
  if (mySubstitutionParameters.isAllSubstituted()) {
    state = ThreeStateCheckBox.State.SELECTED;
  }
  else if (mySubstitutionParameters.isNoneSubstituted()) {
    state = ThreeStateCheckBox.State.NOT_SELECTED;
  }
  else {
    state = ThreeStateCheckBox.State.DONT_CARE;
  }
  myShowContentCheckBox.setThirdStateEnabled(state == ThreeStateCheckBox.State.DONT_CARE);
  myShowContentCheckBox.setState(state);
  onShowContentSettingsChanged();
}
项目:tools-idea    文件:MultipleFacetEditorHelperImpl.java   
@Override
public void bind(@NotNull ThreeStateCheckBox common, @NotNull FacetEditor[] editors, @NotNull NotNullFunction<FacetEditor, JCheckBox> fun) {
  List<JCheckBox> checkBoxesList = new ArrayList<JCheckBox>();
  for (FacetEditor editor : editors) {
    checkBoxesList.add(fun.fun(editor));
  }

  CheckBoxBinding checkBoxBinding = new CheckBoxBinding(common, checkBoxesList);
  myBindings.add(checkBoxBinding);
}
项目:consulo    文件:CheckboxTreeNoPolicy.java   
public CheckboxTreeCellRendererBase(boolean opaque, final boolean usePartialStatusForParentNodes) {
  super(new BorderLayout());
  myUsePartialStatusForParentNodes = usePartialStatusForParentNodes;
  myCheckbox = new ThreeStateCheckBox();
  myCheckbox.setSelected(false);
  myCheckbox.setThirdStateEnabled(false);
  myTextRenderer = new ColoredTreeCellRenderer() {
    @RequiredDispatchThread
    @Override
    public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { }
  };
  myTextRenderer.setOpaque(opaque);
  add(myCheckbox, BorderLayout.WEST);
  add(myTextRenderer, BorderLayout.CENTER);
}
项目:consulo    文件:PushLog.java   
@Override
public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
  if (!(value instanceof DefaultMutableTreeNode)) {
    return;
  }
  myCheckbox.setBorder(null); //checkBox may have no border by default, but insets are not null,
  // it depends on LaF, OS and isItRenderedPane, see com.intellij.ide.ui.laf.darcula.ui.DarculaCheckBoxBorder.
  // null border works as expected always.
  if (value instanceof RepositoryNode) {
    //todo simplify, remove instance of
    RepositoryNode valueNode = (RepositoryNode)value;
    myCheckbox.setVisible(valueNode.isCheckboxVisible());
    if (valueNode.isChecked() && valueNode.isLoading()) {
      myCheckbox.setState(ThreeStateCheckBox.State.DONT_CARE);
    }
    else {
      myCheckbox.setSelected(valueNode.isChecked());
    }
  }
  Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
  ColoredTreeCellRenderer renderer = getTextRenderer();
  if (value instanceof CustomRenderedTreeNode) {
    if (tree.isEditing() && mySyncStrategy && value instanceof RepositoryNode) {
      //sync rendering all editable fields
      ((RepositoryNode)value).render(renderer, mySyncRenderedText);
    }
    else {
      ((CustomRenderedTreeNode)value).render(renderer);
    }
  }
  else {
    renderer.append(userObject == null ? "" : userObject.toString());
  }
}
项目:consulo    文件:ArtifactEditorImpl.java   
public void updateShowContentCheckbox() {
  final ThreeStateCheckBox.State state;
  if (mySubstitutionParameters.isAllSubstituted()) {
    state = ThreeStateCheckBox.State.SELECTED;
  }
  else if (mySubstitutionParameters.isNoneSubstituted()) {
    state = ThreeStateCheckBox.State.NOT_SELECTED;
  }
  else {
    state = ThreeStateCheckBox.State.DONT_CARE;
  }
  myShowContentCheckBox.setThirdStateEnabled(state == ThreeStateCheckBox.State.DONT_CARE);
  myShowContentCheckBox.setState(state);
  onShowContentSettingsChanged();
}
项目:intellij-ce-playground    文件:ArtifactEditorImpl.java   
private void createUIComponents() {
  myShowContentCheckBox = new ThreeStateCheckBox();
  myShowSpecificContentOptionsButton = new FixedSizeButton(16);
}
项目:tools-idea    文件:ArtifactEditorImpl.java   
private void createUIComponents() {
  myShowContentCheckBox = new ThreeStateCheckBox();
  myShowSpecificContentOptionsButton = new FixedSizeButton(16);
}
项目:consulo    文件:ArtifactEditorImpl.java   
private void createUIComponents() {
  myShowContentCheckBox = new ThreeStateCheckBox();
  myShowSpecificContentOptionsButton = new FixedSizeButton(16);
}
项目:intellij-ce-playground    文件:MultipleFacetEditorHelper.java   
/**
 * Binds <code>common</code> 3-state checkbox to checkboxes in facet editors in such a way that all changes in it will be propogated to
 * target checkboxes.
 * @param common checkbox
 * @param editors editors
 * @param fun maps a facet editor to checkbox inside one of its tabs
 */
void bind(@NotNull ThreeStateCheckBox common, @NotNull FacetEditor[] editors, @NotNull NotNullFunction<FacetEditor, JCheckBox> fun);
项目:tools-idea    文件:MultipleFacetEditorHelper.java   
/**
 * Binds <code>common</code> 3-state checkbox to checkboxes in facet editors in such a way that all changes in it will be propogated to
 * target checkboxes.
 * @param common checkbox
 * @param editors editors
 * @param fun maps a facet editor to checkbox inside one of its tabs
 */
void bind(@NotNull ThreeStateCheckBox common, @NotNull FacetEditor[] editors, @NotNull NotNullFunction<FacetEditor, JCheckBox> fun);