当前位置: 首页>>代码示例>>Java>>正文


Java ActionButton类代码示例

本文整理汇总了Java中com.intellij.openapi.actionSystem.impl.ActionButton的典型用法代码示例。如果您正苦于以下问题:Java ActionButton类的具体用法?Java ActionButton怎么用?Java ActionButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ActionButton类属于com.intellij.openapi.actionSystem.impl包,在下文中一共展示了ActionButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createButton

import com.intellij.openapi.actionSystem.impl.ActionButton; //导入依赖的package包/类
@NotNull
private ActionButton createButton(@NotNull final ButtonType type) {
  final AnAction action;
  switch (type) {
    case LEFT:
      action = new LeftAction();
      break;
    case RIGHT:
      action = new RightAction();
      break;
    case ALL_LEFT:
      action = new AllLeftAction();
      break;
    case ALL_RIGHT:
      action = new AllRightAction();
      break;
    default: throw new IllegalArgumentException("Unsupported button type: " + type);
  }


  ActionButton button = createButton(action);
  myButtons.put(type, button);
  return button;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:JBMovePanel.java

示例2: SearchTextArea

import com.intellij.openapi.actionSystem.impl.ActionButton; //导入依赖的package包/类
public SearchTextArea(boolean search) {
  myTextArea = new JTextArea();
  setBorder(JBUI.Borders.empty(6, 6, 6, 8));
  setLayout(new BorderLayout(JBUI.scale(4), 0));
  myTextArea.addPropertyChangeListener("background", this);
  myTextArea.addFocusListener(this);
  myTextArea.setBorder(null);
  myTextArea.setOpaque(false);
  JBScrollPane scrollPane = new JBScrollPane(myTextArea,
                                             ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                                             ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  scrollPane.getVerticalScrollBar().setBackground(UIUtil.TRANSPARENT_COLOR);
  scrollPane.getViewport().setBorder(null);
  scrollPane.getViewport().setOpaque(false);
  scrollPane.setBorder(JBUI.Borders.emptyRight(2));
  scrollPane.setOpaque(false);
  ShowHistoryAction historyAction = new ShowHistoryAction(search);
  ActionButton button =
    new ActionButton(historyAction, historyAction.getTemplatePresentation(), ActionPlaces.UNKNOWN, new Dimension(JBUI.scale(16), JBUI.scale(16)));
  button.setLook(new InplaceActionButtonLook());
  JPanel p = new NonOpaquePanel(new BorderLayout());
  p.add(button, BorderLayout.NORTH);
  add(p, BorderLayout.WEST);
  add(scrollPane, BorderLayout.CENTER);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:SearchTextArea.java

示例3: stop

import com.intellij.openapi.actionSystem.impl.ActionButton; //导入依赖的package包/类
@TestOnly
public boolean stop() {
  for (ActionButton button : getToolbarButtons()) {
    final AnAction action = button.getAction();
    if (action != null && action.getClass().getName().equals("com.intellij.execution.actions.StopAction")) {
      //noinspection ConstantConditions
      boolean enabled = method("isButtonEnabled").withReturnType(boolean.class).in(button).invoke();
      if (enabled) {
        button.click();
        return true;
      }
      return false;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ExecutionToolWindowFixture.java

示例4: getMnemonicCharIndex

import com.intellij.openapi.actionSystem.impl.ActionButton; //导入依赖的package包/类
private int getMnemonicCharIndex(ActionButton button, AnAction action, String text) {
  final int mnemonicIndex = button.getPresentation().getDisplayedMnemonicIndex();
  if (mnemonicIndex != -1) {
    return mnemonicIndex;
  }
  final ShortcutSet shortcutSet = action.getShortcutSet();
  final Shortcut[] shortcuts = shortcutSet.getShortcuts();
  for (int i = 0; i < shortcuts.length; i++) {
    Shortcut shortcut = shortcuts[i];
    if (shortcut instanceof KeyboardShortcut) {
      KeyboardShortcut keyboardShortcut = (KeyboardShortcut)shortcut;
      if (keyboardShortcut.getSecondKeyStroke() == null) { // we are interested only in "mnemonic-like" shortcuts
        final KeyStroke keyStroke = keyboardShortcut.getFirstKeyStroke();
        final int modifiers = keyStroke.getModifiers();
        if ((modifiers & KeyEvent.ALT_MASK) != 0) {
          return (keyStroke.getKeyChar() != KeyEvent.CHAR_UNDEFINED)
                 ? text.indexOf(keyStroke.getKeyChar())
                 : text.indexOf(KeyEvent.getKeyText(keyStroke.getKeyCode()));
        }
      }
    }
  }
  return -1;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:ActionButtonUI.java

示例5: paintDefaultButton

import com.intellij.openapi.actionSystem.impl.ActionButton; //导入依赖的package包/类
private void paintDefaultButton(Graphics g, ActionButton c) {
  AnAction action = c.getAction();

  int state = c.getPopState();

  if (state != ActionButtonComponent.NORMAL) {
    paintBackground(c, g, c.getSize(), state);
    paintBorder(c, g, c.getSize(), state);
  }

  paintIcon(g, c, c.getIcon());

  if (action instanceof ActionGroup && ((ActionGroup)action).isPopup()) {

    int x = JBUI.scale(5);
    int y = JBUI.scale(4);

    if (state == ActionButtonComponent.PUSHED) {
      x += JBUI.scale(1);
      y += JBUI.scale(1);
    }

    AllIcons.General.Dropdown.paintIcon(c, g, x, y);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:ActionButtonUI.java

示例6: paintBorder

import com.intellij.openapi.actionSystem.impl.ActionButton; //导入依赖的package包/类
protected void paintBorder(ActionButton button, Graphics g, Dimension size, int state) {
  if (UIUtil.isUnderAquaLookAndFeel()) {
    if (state == ActionButtonComponent.POPPED) {
      g.setColor(ALPHA_30);
      g.drawRoundRect(0, 0, size.width - 2, size.height - 2, 4, 4);
    }
  }
  else {
    final double shift = UIUtil.isUnderDarcula() ? 1 / 0.49 : 0.49;
    g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(), shift));
    ((Graphics2D)g).setStroke(BASIC_STROKE);
    final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
    g.drawRoundRect(0, 0, size.width - JBUI.scale(2), size.height - JBUI.scale(2), JBUI.scale(4), JBUI.scale(4));
    config.restore();
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:ActionButtonUI.java

示例7: paintBackground

import com.intellij.openapi.actionSystem.impl.ActionButton; //导入依赖的package包/类
protected void paintBackground(ActionButton button, Graphics g, Dimension size, int state) {
  if (UIUtil.isUnderAquaLookAndFeel()) {
    if (state == ActionButtonComponent.PUSHED) {
      ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, ALPHA_40, size.width, size.height, ALPHA_20));
      g.fillRect(0, 0, size.width - 1, size.height - 1);

      g.setColor(ALPHA_120);
      g.drawLine(0, 0, 0, size.height - 2);
      g.drawLine(1, 0, size.width - 2, 0);

      g.setColor(ALPHA_30);
      g.drawRect(1, 1, size.width - 3, size.height - 3);
    }
    else if (state == ActionButtonComponent.POPPED) {
      ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, Gray._235, 0, size.height, Gray._200));
      g.fillRect(1, 1, size.width - 3, size.height - 3);
    }
  }
  else {
    final Color bg = UIUtil.getPanelBackground();
    final boolean dark = UIUtil.isUnderDarcula();
    g.setColor(state == ActionButtonComponent.PUSHED ? ColorUtil.shift(bg, dark ? 1d / 0.7d : 0.7d) : dark ? Gray._255.withAlpha(40) : ALPHA_40);
    g.fillRect(JBUI.scale(1), JBUI.scale(1), size.width - JBUI.scale(2), size.height - JBUI.scale(2));
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:ActionButtonUI.java

示例8: createToolbar

import com.intellij.openapi.actionSystem.impl.ActionButton; //导入依赖的package包/类
private ActionToolbar createToolbar(final ActionGroup group) {
  final ActionToolbarImpl actionToolbar =
          new ActionToolbarImpl(ActionPlaces.CONTEXT_TOOLBAR, group, true, DataManager.getInstance(), ActionManagerEx.getInstanceEx(),
                                KeymapManagerEx.getInstanceEx()) {

            @Override
            protected ActionButton createToolbarButton(final AnAction action,
                                                       boolean minimalMode,
                                                       boolean decorateButtons,
                                                       final String place,
                                                       final Presentation presentation,
                                                       final Dimension minimumSize) {
              final ActionButton result = new ActionButton(action, presentation, place, minimumSize);
              result.setMinimalMode(minimalMode);
              result.setDecorateButtons(decorateButtons);
              return result;
            }
          };

  actionToolbar.setTargetComponent(myEditor.getContentComponent());
  return actionToolbar;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:ContextMenuImpl.java

示例9: createButton

import com.intellij.openapi.actionSystem.impl.ActionButton; //导入依赖的package包/类
@Nonnull
private ActionButton createButton(@Nonnull final ButtonType type) {
  final AnAction action;
  switch (type) {
    case LEFT:
      action = new LeftAction();
      break;
    case RIGHT:
      action = new RightAction();
      break;
    case ALL_LEFT:
      action = new AllLeftAction();
      break;
    case ALL_RIGHT:
      action = new AllRightAction();
      break;
    default: throw new IllegalArgumentException("Unsupported button type: " + type);
  }


  ActionButton button = createButton(action);
  myButtons.put(type, button);
  return button;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:JBMovePanel.java

示例10: KeyPromoterAction

import com.intellij.openapi.actionSystem.impl.ActionButton; //导入依赖的package包/类
/**
 * Constructor used when have to fall back to inspect an AWT event instead of actions that are directly provided
 * by IDEA. Tool-window stripe buttons are such a case where I'm not notified by IDEA if one is pressed
 *
 * @param event mouse event that happened
 */
KeyPromoterAction(AWTEvent event) {
    final Object source = event.getSource();
    if (source instanceof ActionButton) {
        analyzeActionButton((ActionButton) source);
    } else if (source instanceof StripeButton) {
        analyzeStripeButton((StripeButton) source);
    } else if (source instanceof ActionMenuItem) {
        analyzeActionMenuItem((ActionMenuItem) source);
    } else if (source instanceof JButton) {
        analyzeJButton((JButton) source);
    }

}
 
开发者ID:halirutan,项目名称:IntelliJ-Key-Promoter-X,代码行数:20,代码来源:KeyPromoterAction.java

示例11: analyzeActionButton

import com.intellij.openapi.actionSystem.impl.ActionButton; //导入依赖的package包/类
/**
 * Information extraction for buttons on the toolbar
 *
 * @param source source of the action
 */
private void analyzeActionButton(ActionButton source) {
    final AnAction action = source.getAction();
    if (action != null) {
        fixValuesFromAction(action);
    }
    mySource = ActionSource.MAIN_TOOLBAR;
}
 
开发者ID:halirutan,项目名称:IntelliJ-Key-Promoter-X,代码行数:13,代码来源:KeyPromoterAction.java

示例12: buildShortcutIfAvailable

import com.intellij.openapi.actionSystem.impl.ActionButton; //导入依赖的package包/类
public static Optional<ShortcutAction> buildShortcutIfAvailable(Component eventSource) {
    ShortcutAction shortcut = null;

    if (isActionButton(eventSource)) {
        shortcut = buildShortcut((ActionButton) eventSource);
    } else if (isActionMenuItem(eventSource)) {
        shortcut = buildShortcut((ActionMenuItem) eventSource);
    }

    if (shortcut != null && StringUtil.isEmptyOrSpaces(shortcut.getShortcutText())) {
        return Optional.empty();
    }

    return Optional.ofNullable(shortcut);
}
 
开发者ID:treytrahin,项目名称:force-shortcuts-intellij-plugin,代码行数:16,代码来源:ShortcutActionFactory.java

示例13: buildShortcut

import com.intellij.openapi.actionSystem.impl.ActionButton; //导入依赖的package包/类
public static ShortcutAction buildShortcut(ActionButton actionButton) {
    AnAction anAction = actionButton.getAction();
    if (anAction == null) {
        return null;
    }

    String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(anAction);
    String description = anAction.getTemplatePresentation().getText();

    return new ShortcutAction(shortcutText, description);
}
 
开发者ID:treytrahin,项目名称:force-shortcuts-intellij-plugin,代码行数:12,代码来源:ShortcutActionFactory.java

示例14: setShowButtons

import com.intellij.openapi.actionSystem.impl.ActionButton; //导入依赖的package包/类
public void setShowButtons(@NotNull ButtonType... types) {
  for (ActionButton button : myButtons.values()) {
    button.setVisible(false);
  }
  for (ButtonType type : types) {
    myButtons.get(type).setVisible(true);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JBMovePanel.java

示例15: setEnabled

import com.intellij.openapi.actionSystem.impl.ActionButton; //导入依赖的package包/类
@Override
public void setEnabled(boolean enabled) {
  super.setEnabled(enabled);
  myLeftList.setEnabled(enabled);
  myRightList.setEnabled(enabled);
  for (ActionButton button : myButtons.values()) {
    button.setEnabled(enabled);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:JBMovePanel.java


注:本文中的com.intellij.openapi.actionSystem.impl.ActionButton类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。