Java 类com.intellij.psi.codeStyle.arrangement.std.ArrangementUiComponent 实例源码

项目:intellij-ce-playground    文件:ArrangementListRowDecorator.java   
public ArrangementListRowDecorator(@NotNull ArrangementUiComponent delegate,
                                   @NotNull ArrangementMatchingRulesControl control)
{
  myDelegate = delegate;
  myControl = control;

  mySortLabel.setVisible(false);

  AnAction action = ActionManager.getInstance().getAction("Arrangement.Rule.Edit");
  Presentation presentation = action.getTemplatePresentation().clone();
  Icon editIcon = presentation.getIcon();
  Dimension buttonSize = new Dimension(editIcon.getIconWidth(), editIcon.getIconHeight());
  myEditButton = new MyActionButton(action, presentation, ArrangementConstants.MATCHING_RULES_CONTROL_PLACE, buttonSize);
  myEditButton.setVisible(false);

  FontMetrics metrics = getFontMetrics(getFont());
  int maxWidth = 0;
  for (int i = 0; i <= 99; i++) {
    maxWidth = Math.max(metrics.stringWidth(String.valueOf(i)), maxWidth);
  }
  int height = metrics.getHeight() - metrics.getDescent() - metrics.getLeading();
  int diameter = Math.max(maxWidth, height) * 5 / 3;
  myRowIndexControl = new ArrangementRuleIndexControl(diameter, height);

  setOpaque(true);
  init();
}
项目:intellij-ce-playground    文件:DefaultArrangementUiComponentFactory.java   
@Nullable
@Override
public ArrangementUiComponent build(@NotNull StdArrangementTokenUiRole role,
                                    @NotNull List<ArrangementSettingsToken> tokens,
                                    @NotNull ArrangementColorsProvider colorsProvider,
                                    @NotNull ArrangementStandardSettingsManager settingsManager)
{
  switch (role) {
    case CHECKBOX:
      if (tokens.size() != 1) {
        throw new IllegalArgumentException("Can't build a checkbox token for elements " + tokens);
      }
      else {
        return new ArrangementCheckBoxUiComponent(tokens.get(0));
      }
    case COMBO_BOX:
      if (tokens.isEmpty()) {
        throw new IllegalArgumentException("Can't build a combo box token with empty content");
      }
      return new ArrangementComboBoxUiComponent(tokens);
    case LABEL:
      if (tokens.size() != 1) {
        throw new IllegalArgumentException("Can't build a label token for elements " + tokens);
      }
      return new ArrangementLabelUiComponent(tokens.get(0));
    case TEXT_FIELD:
      if (tokens.size() != 1) {
        throw new IllegalArgumentException("Can't build a text field token for elements " + tokens);
      }
      return new ArrangementTextFieldUiComponent(tokens.get(0));
    case BULB:
      if (tokens.size() != 1) {
        throw new IllegalArgumentException("Can't build a bulb token for elements " + tokens);
      }
      return new ArrangementAtomMatchConditionComponent(
        settingsManager, colorsProvider, new ArrangementAtomMatchCondition(tokens.get(0)), null
      );
  }
  return null;
}
项目:tools-idea    文件:ArrangementListRowDecorator.java   
public ArrangementListRowDecorator(@NotNull ArrangementUiComponent delegate,
                                   @NotNull ArrangementMatchingRulesControl control)
{
  myDelegate = delegate;
  myControl = control;

  mySortLabel.setVisible(false);

  AnAction action = ActionManager.getInstance().getAction("Arrangement.Rule.Edit");
  Presentation presentation = action.getTemplatePresentation().clone();
  Icon editIcon = presentation.getIcon();
  Dimension buttonSize = new Dimension(editIcon.getIconWidth(), editIcon.getIconHeight());
  myEditButton = new MyActionButton(action, presentation, ArrangementConstants.MATCHING_RULES_CONTROL_PLACE, buttonSize);
  myEditButton.setVisible(false);

  FontMetrics metrics = getFontMetrics(getFont());
  int maxWidth = 0;
  for (int i = 0; i <= 99; i++) {
    maxWidth = Math.max(metrics.stringWidth(String.valueOf(i)), maxWidth);
  }
  int height = metrics.getHeight() - metrics.getDescent() - metrics.getLeading();
  int diameter = Math.max(maxWidth, height) * 5 / 3;
  myRowIndexControl = new ArrangementRuleIndexControl(diameter, height);

  setOpaque(true);
  init();
}
项目:tools-idea    文件:ArrangementAndMatchConditionComponent.java   
@Override
public void onMouseRelease(@NotNull MouseEvent event) {
  Point location = event.getLocationOnScreen();
  for (ArrangementUiComponent component : myComponents) {
    Rectangle bounds = component.getScreenBounds();
    if (bounds != null && bounds.contains(location)) {
      component.onMouseRelease(event);
      return;
    }
  }
}
项目:tools-idea    文件:ArrangementAndMatchConditionComponent.java   
@Override
public Rectangle onMouseEntered(@NotNull MouseEvent event) {
  Point location = event.getLocationOnScreen();
  for (ArrangementUiComponent component : myComponents) {
    Rectangle bounds = component.getScreenBounds();
    if (bounds != null && bounds.contains(location)) {
      myComponentUnderMouse = component;
      return component.onMouseEntered(event);
    }
  }
  return null;
}
项目:tools-idea    文件:DefaultArrangementUiComponentFactory.java   
@Nullable
@Override
public ArrangementUiComponent build(@NotNull StdArrangementTokenUiRole role,
                                    @NotNull List<ArrangementSettingsToken> tokens,
                                    @NotNull ArrangementColorsProvider colorsProvider,
                                    @NotNull ArrangementStandardSettingsManager settingsManager)
{
  switch (role) {
    case CHECKBOX:
      if (tokens.size() != 1) {
        throw new IllegalArgumentException("Can't build a checkbox token for elements " + tokens);
      }
      else {
        return new ArrangementCheckBoxUiComponent(tokens.get(0));
      }
    case COMBO_BOX:
      if (tokens.isEmpty()) {
        throw new IllegalArgumentException("Can't build a combo box token with empty content");
      }
      return new ArrangementComboBoxUiComponent(tokens);
    case LABEL:
      if (tokens.size() != 1) {
        throw new IllegalArgumentException("Can't build a label token for elements " + tokens);
      }
      return new ArrangementLabelUiComponent(tokens.get(0));
    case TEXT_FIELD:
      if (tokens.size() != 1) {
        throw new IllegalArgumentException("Can't build a text field token for elements " + tokens);
      }
      return new ArrangementTextFieldUiComponent(tokens.get(0));
    case BULB:
      if (tokens.size() != 1) {
        throw new IllegalArgumentException("Can't build a bulb token for elements " + tokens);
      }
      return new ArrangementAtomMatchConditionComponent(
        settingsManager, colorsProvider, new ArrangementAtomMatchCondition(tokens.get(0)), null
      );
  }
  return null;
}
项目:consulo    文件:ArrangementListRowDecorator.java   
public ArrangementListRowDecorator(@Nonnull ArrangementUiComponent delegate,
                                   @Nonnull ArrangementMatchingRulesControl control)
{
  myDelegate = delegate;
  myControl = control;

  mySortLabel.setVisible(false);

  AnAction action = ActionManager.getInstance().getAction("Arrangement.Rule.Edit");
  Presentation presentation = action.getTemplatePresentation().clone();
  Icon editIcon = presentation.getIcon();
  Dimension buttonSize = new Dimension(editIcon.getIconWidth(), editIcon.getIconHeight());
  myEditButton = new ActionButton(action, presentation, ArrangementConstants.MATCHING_RULES_CONTROL_PLACE, buttonSize);
  myEditButton.setVisible(false);

  FontMetrics metrics = getFontMetrics(getFont());
  int maxWidth = 0;
  for (int i = 0; i <= 99; i++) {
    maxWidth = Math.max(metrics.stringWidth(String.valueOf(i)), maxWidth);
  }
  int height = metrics.getHeight() - metrics.getDescent() - metrics.getLeading();
  int diameter = Math.max(maxWidth, height) * 5 / 3;
  myRowIndexControl = new ArrangementRuleIndexControl(diameter, height);

  setOpaque(true);
  init();
}
项目:consulo    文件:DefaultArrangementUiComponentFactory.java   
@Nullable
@Override
public ArrangementUiComponent build(@Nonnull StdArrangementTokenUiRole role,
                                    @Nonnull List<ArrangementSettingsToken> tokens,
                                    @Nonnull ArrangementColorsProvider colorsProvider,
                                    @Nonnull ArrangementStandardSettingsManager settingsManager)
{
  switch (role) {
    case CHECKBOX:
      if (tokens.size() != 1) {
        throw new IllegalArgumentException("Can't build a checkbox token for elements " + tokens);
      }
      else {
        return new ArrangementCheckBoxUiComponent(tokens.get(0));
      }
    case COMBO_BOX:
      if (tokens.isEmpty()) {
        throw new IllegalArgumentException("Can't build a combo box token with empty content");
      }
      return new ArrangementComboBoxUiComponent(tokens);
    case LABEL:
      if (tokens.size() != 1) {
        throw new IllegalArgumentException("Can't build a label token for elements " + tokens);
      }
      return new ArrangementLabelUiComponent(tokens.get(0));
    case TEXT_FIELD:
      if (tokens.size() != 1) {
        throw new IllegalArgumentException("Can't build a text field token for elements " + tokens);
      }
      return new ArrangementTextFieldUiComponent(tokens.get(0));
    case BULB:
      if (tokens.size() != 1) {
        throw new IllegalArgumentException("Can't build a bulb token for elements " + tokens);
      }
      return new ArrangementAtomMatchConditionComponent(
        settingsManager, colorsProvider, new ArrangementAtomMatchCondition(tokens.get(0)), null
      );
  }
  return null;
}
项目:tools-idea    文件:ArrangementAndMatchConditionComponent.java   
@Override
public void setSelected(boolean selected) {
  for (ArrangementUiComponent component : myComponents) {
    component.setSelected(selected);
  }
}
项目:tools-idea    文件:ArrangementAndMatchConditionComponent.java   
@Override
public Rectangle onMouseMove(@NotNull MouseEvent event) {
  Point location = event.getLocationOnScreen();
  for (ArrangementUiComponent component : myComponents) {
    Rectangle bounds = component.getScreenBounds();
    if (bounds == null || !bounds.contains(location)) {
      continue;
    }
    if (myComponentUnderMouse == null) {
      myComponentUnderMouse = component;
      Rectangle rectangleOnEnter = myComponentUnderMouse.onMouseEntered(event);
      Rectangle rectangleOnMove = myComponentUnderMouse.onMouseMove(event);
      if (rectangleOnEnter != null && rectangleOnMove != null) {
        return myScreenBounds; // Repaint row
      }
      else if (rectangleOnEnter != null) {
        return rectangleOnEnter;
      }
      else {
        return rectangleOnMove;
      }
    }
    else {
      if (myComponentUnderMouse != component) {
        myComponentUnderMouse.onMouseExited();
        myComponentUnderMouse = component;
        component.onMouseEntered(event);
        return myScreenBounds; // Repaint row.
      }
      else {
        return component.onMouseMove(event);
      }
    }
  }
  if (myComponentUnderMouse == null) {
    return null;
  }
  else {
    Rectangle result = myComponentUnderMouse.onMouseExited();
    myComponentUnderMouse = null;
    return result;
  }
}
项目:tools-idea    文件:ArrangementAndMatchConditionComponent.java   
@Override
public void reset() {
  for (ArrangementUiComponent component : myComponents) {
    component.reset();
  }
}
项目:tools-idea    文件:ArrangementAndMatchConditionComponent.java   
@Override
public void setListener(@NotNull Listener listener) {
  for (ArrangementUiComponent component : myComponents) {
    component.setListener(listener);
  } 
}