Java 类com.intellij.ui.CommonActionsPanel 实例源码

项目:intellij-ce-playground    文件:BreakpointsFavoriteListProvider.java   
@Override
public void handle(@NotNull CommonActionsPanel.Buttons type, Project project, @NotNull Set<Object> selectedObjects, JComponent component) {
  Rectangle bounds = component.getBounds();
  if (component instanceof JTree) {
    JTree tree = (JTree)component;
    bounds = tree.getRowBounds(tree.getLeadSelectionRow());
    bounds.y += bounds.height/2;
    bounds = tree.getVisibleRect().intersection(bounds);
  }
  Point whereToShow = new Point((int)bounds.getCenterX(), (int)bounds.getCenterY());
  BreakpointItem breakpointItem = (BreakpointItem)((AbstractTreeNode)selectedObjects.iterator().next()).getValue();
  switch (type) {
    case EDIT:
      DebuggerSupport debuggerSupport = XBreakpointUtil.getDebuggerSupport(myProject, breakpointItem);
      if (debuggerSupport == null) return;
      debuggerSupport.getEditBreakpointAction().editBreakpoint(myProject, component, whereToShow, breakpointItem);
      break;
    case REMOVE:
      breakpointItem.removed(myProject);
      break;
    default: break;
  }
}
项目:intellij-ce-playground    文件:BookmarksFavoriteListProvider.java   
@Override
public boolean willHandle(@NotNull CommonActionsPanel.Buttons type, Project project, @NotNull Set<Object> selectedObjects) {
  switch (type) {
    case EDIT:
      if (selectedObjects.size() != 1) {
        return false;
      }
      Object toEdit = selectedObjects.iterator().next();
      return toEdit instanceof AbstractTreeNode && ((AbstractTreeNode)toEdit).getValue() instanceof Bookmark;
    case REMOVE:
      for (Object toRemove : selectedObjects) {
        if (!(toRemove instanceof AbstractTreeNode && ((AbstractTreeNode)toRemove).getValue() instanceof Bookmark)) {
          return false;
        }
      }
      return true;
    default:
      return false;
  }
}
项目:intellij-ce-playground    文件:EditFavoritesAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  Project project = e.getProject();
  FavoritesViewTreeBuilder treeBuilder = FavoritesTreeViewPanel.FAVORITES_TREE_BUILDER_KEY.getData(e.getDataContext());
  String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(e.getDataContext());
  if (project == null || treeBuilder == null || listName == null) {
    return;
  }
  FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
  FavoritesListProvider provider = favoritesManager.getListProvider(listName);
  Set<Object> selection = treeBuilder.getSelectedElements();
  if (provider != null && provider.willHandle(CommonActionsPanel.Buttons.EDIT, project, selection)) {
    provider.handle(CommonActionsPanel.Buttons.EDIT, project, selection, treeBuilder.getTree());
    return;
  }
  favoritesManager.renameList(project, listName);
}
项目:intellij-ce-playground    文件:EditFavoritesAction.java   
@Override
public void update(AnActionEvent e) {
  e.getPresentation().setText(getTemplatePresentation().getText());
  e.getPresentation().setIcon(CommonActionsPanel.Buttons.EDIT.getIcon());
  e.getPresentation().setEnabled(true);
  Project project = e.getProject();
  FavoritesViewTreeBuilder treeBuilder = FavoritesTreeViewPanel.FAVORITES_TREE_BUILDER_KEY.getData(e.getDataContext());
  String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(e.getDataContext());
  if (project == null || treeBuilder == null || listName == null) {
    e.getPresentation().setEnabled(false);
    return;
  }
  FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
  FavoritesListProvider provider = favoritesManager.getListProvider(listName);
  Set<Object> selection = treeBuilder.getSelectedElements();
  if (provider != null) {
    e.getPresentation().setEnabled(provider.willHandle(CommonActionsPanel.Buttons.EDIT, project, selection));
    e.getPresentation().setText(provider.getCustomName(CommonActionsPanel.Buttons.EDIT));
  }
}
项目:tools-idea    文件:BreakpointsFavoriteListProvider.java   
@Override
public void handle(@NotNull CommonActionsPanel.Buttons type, Project project, @NotNull Set<Object> selectedObjects, JComponent component) {
  Rectangle bounds = component.getBounds();
  if (component instanceof JTree) {
    JTree tree = (JTree)component;
    bounds = tree.getRowBounds(tree.getLeadSelectionRow());
    bounds.y += bounds.height/2;
    bounds = tree.getVisibleRect().intersection(bounds);
  }
  Point whereToShow = new Point((int)bounds.getCenterX(), (int)bounds.getCenterY());
  BreakpointItem breakpointItem = (BreakpointItem)((AbstractTreeNode)selectedObjects.iterator().next()).getValue();
  switch (type) {
    case EDIT:
      DebuggerSupport debuggerSupport = XBreakpointUtil.getDebuggerSupport(myProject, breakpointItem);
      if (debuggerSupport == null) return;
      debuggerSupport.getEditBreakpointAction().editBreakpoint(myProject, component, whereToShow, breakpointItem);
      break;
    case REMOVE:
      breakpointItem.removed(myProject);
      break;
    default: break;
  }
}
项目:tools-idea    文件:BookmarksFavoriteListProvider.java   
@Override
public boolean willHandle(@NotNull CommonActionsPanel.Buttons type, Project project, @NotNull Set<Object> selectedObjects) {
  switch (type) {
    case EDIT:
      if (selectedObjects.size() != 1) {
        return false;
      }
      Object toEdit = selectedObjects.iterator().next();
      return toEdit instanceof AbstractTreeNode && ((AbstractTreeNode)toEdit).getValue() instanceof Bookmark;
    case REMOVE:
      for (Object toRemove : selectedObjects) {
        if (!(toRemove instanceof AbstractTreeNode && ((AbstractTreeNode)toRemove).getValue() instanceof Bookmark)) {
          return false;
        }
      }
      return true;
    default:
      return false;
  }
}
项目:tools-idea    文件:EditFavoritesAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  Project project = e.getProject();
  FavoritesViewTreeBuilder treeBuilder = FavoritesTreeViewPanel.FAVORITES_TREE_BUILDER_KEY.getData(e.getDataContext());
  String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(e.getDataContext());
  if (project == null || treeBuilder == null || listName == null) {
    return;
  }
  FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
  FavoritesListProvider provider = favoritesManager.getListProvider(listName);
  Set<Object> selection = treeBuilder.getSelectedElements();
  if (provider != null && provider.willHandle(CommonActionsPanel.Buttons.EDIT, project, selection)) {
    provider.handle(CommonActionsPanel.Buttons.EDIT, project, selection, treeBuilder.getTree());
    return;
  }
  favoritesManager.renameList(project, listName);
}
项目:tools-idea    文件:EditFavoritesAction.java   
@Override
public void update(AnActionEvent e) {
  e.getPresentation().setText(CommonActionsPanel.Buttons.EDIT.getText());
  e.getPresentation().setIcon(CommonActionsPanel.Buttons.EDIT.getIcon());
  e.getPresentation().setEnabled(true);
  Project project = e.getProject();
  FavoritesViewTreeBuilder treeBuilder = FavoritesTreeViewPanel.FAVORITES_TREE_BUILDER_KEY.getData(e.getDataContext());
  String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(e.getDataContext());
  if (project == null || treeBuilder == null || listName == null) {
    e.getPresentation().setEnabled(false);
    return;
  }
  FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
  FavoritesListProvider provider = favoritesManager.getListProvider(listName);
  Set<Object> selection = treeBuilder.getSelectedElements();
  if (provider != null) {
    e.getPresentation().setEnabled(provider.willHandle(CommonActionsPanel.Buttons.EDIT, project, selection));
    e.getPresentation().setText(provider.getCustomName(CommonActionsPanel.Buttons.EDIT));
  }
}
项目:consulo    文件:BreakpointsFavoriteListProvider.java   
@Override
public void handle(@Nonnull CommonActionsPanel.Buttons type, Project project, @Nonnull Set<Object> selectedObjects, JComponent component) {
  Rectangle bounds = component.getBounds();
  if (component instanceof JTree) {
    JTree tree = (JTree)component;
    bounds = tree.getRowBounds(tree.getLeadSelectionRow());
    bounds.y += bounds.height/2;
    bounds = tree.getVisibleRect().intersection(bounds);
  }
  Point whereToShow = new Point((int)bounds.getCenterX(), (int)bounds.getCenterY());
  BreakpointItem breakpointItem = (BreakpointItem)((AbstractTreeNode)selectedObjects.iterator().next()).getValue();
  switch (type) {
    case EDIT:
      DebuggerSupport debuggerSupport = XBreakpointUtil.getDebuggerSupport(myProject, breakpointItem);
      if (debuggerSupport == null) return;
      debuggerSupport.getEditBreakpointAction().editBreakpoint(myProject, component, whereToShow, breakpointItem);
      break;
    case REMOVE:
      breakpointItem.removed(myProject);
      break;
    default: break;
  }
}
项目:consulo    文件:BookmarksFavoriteListProvider.java   
@Override
public boolean willHandle(@Nonnull CommonActionsPanel.Buttons type, Project project, @Nonnull Set<Object> selectedObjects) {
  switch (type) {
    case EDIT:
      if (selectedObjects.size() != 1) {
        return false;
      }
      Object toEdit = selectedObjects.iterator().next();
      return toEdit instanceof AbstractTreeNode && ((AbstractTreeNode)toEdit).getValue() instanceof Bookmark;
    case REMOVE:
      for (Object toRemove : selectedObjects) {
        if (!(toRemove instanceof AbstractTreeNode && ((AbstractTreeNode)toRemove).getValue() instanceof Bookmark)) {
          return false;
        }
      }
      return true;
    default:
      return false;
  }
}
项目:consulo    文件:EditFavoritesAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  Project project = e.getProject();
  FavoritesViewTreeBuilder treeBuilder = e.getDataContext().getData(FavoritesTreeViewPanel.FAVORITES_TREE_BUILDER_KEY);
  String listName = e.getDataContext().getData(FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY);
  if (project == null || treeBuilder == null || listName == null) {
    return;
  }
  FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
  FavoritesListProvider provider = favoritesManager.getListProvider(listName);
  Set<Object> selection = treeBuilder.getSelectedElements();
  if (provider != null && provider.willHandle(CommonActionsPanel.Buttons.EDIT, project, selection)) {
    provider.handle(CommonActionsPanel.Buttons.EDIT, project, selection, treeBuilder.getTree());
    return;
  }
  favoritesManager.renameList(project, listName);
}
项目:consulo    文件:EditFavoritesAction.java   
@Override
public void update(AnActionEvent e) {
  e.getPresentation().setText(CommonActionsPanel.Buttons.EDIT.getText());
  e.getPresentation().setIcon(CommonActionsPanel.Buttons.EDIT.getIcon());
  e.getPresentation().setEnabled(true);
  Project project = e.getProject();
  FavoritesViewTreeBuilder treeBuilder = e.getDataContext().getData(FavoritesTreeViewPanel.FAVORITES_TREE_BUILDER_KEY);
  String listName = e.getDataContext().getData(FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY);
  if (project == null || treeBuilder == null || listName == null) {
    e.getPresentation().setEnabled(false);
    return;
  }
  FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
  FavoritesListProvider provider = favoritesManager.getListProvider(listName);
  Set<Object> selection = treeBuilder.getSelectedElements();
  if (provider != null) {
    e.getPresentation().setEnabled(provider.willHandle(CommonActionsPanel.Buttons.EDIT, project, selection));
    e.getPresentation().setText(provider.getCustomName(CommonActionsPanel.Buttons.EDIT));
  }
}
项目:intellij-ce-playground    文件:BreakpointsFavoriteListProvider.java   
@Nullable
@Override
public String getCustomName(@NotNull CommonActionsPanel.Buttons type) {
  switch (type) {
    case EDIT:
      return "Edit breakpoint";
    case REMOVE:
      return "Remove breakpoint";
    default:
      return null;
  }
}
项目:intellij-ce-playground    文件:BookmarksFavoriteListProvider.java   
@Nullable
@Override
public String getCustomName(@NotNull CommonActionsPanel.Buttons type) {
  switch (type) {
    case EDIT:
      return IdeBundle.message("action.bookmark.edit.description");
    case REMOVE:
      return IdeBundle.message("action.bookmark.delete");
    default:
      return null;
  }
}
项目:tools-idea    文件:BreakpointsFavoriteListProvider.java   
@Nullable
@Override
public String getCustomName(@NotNull CommonActionsPanel.Buttons type) {
  switch (type) {
    case EDIT:
      return "Edit breakpoint";
    case REMOVE:
      return "Remove breakpoint";
    default:
      return null;
  }
}
项目:tools-idea    文件:BookmarksFavoriteListProvider.java   
@Nullable
@Override
public String getCustomName(@NotNull CommonActionsPanel.Buttons type) {
  switch (type) {
    case EDIT:
      return IdeBundle.message("action.bookmark.edit.description");
    case REMOVE:
      return IdeBundle.message("action.bookmark.delete");
    default:
      return null;
  }
}
项目:intellij-xquery    文件:VariablesPanelGuiTest.java   
private void clickButton(CommonActionsPanel.Buttons button) {
    final AnActionButton action = getAnActionButton(button);
    final AnActionEvent event = new TestActionEvent(action);

    execute(new GuiTask() {
        @Override
        protected void executeInEDT() throws Throwable {
            action.actionPerformed(event);
        }
    });
}
项目:consulo    文件:BreakpointsFavoriteListProvider.java   
@Nullable
@Override
public String getCustomName(@Nonnull CommonActionsPanel.Buttons type) {
  switch (type) {
    case EDIT:
      return "Edit breakpoint";
    case REMOVE:
      return "Remove breakpoint";
    default:
      return null;
  }
}
项目:consulo    文件:BookmarksFavoriteListProvider.java   
@Nullable
@Override
public String getCustomName(@Nonnull CommonActionsPanel.Buttons type) {
  switch (type) {
    case EDIT:
      return IdeBundle.message("action.bookmark.edit.description");
    case REMOVE:
      return IdeBundle.message("action.bookmark.delete");
    default:
      return null;
  }
}
项目:intellij-ce-playground    文件:BreakpointsFavoriteListProvider.java   
@Override
public boolean willHandle(@NotNull CommonActionsPanel.Buttons type, Project project, @NotNull Set<Object> selectedObjects) {
  return (selectedObjects.size() == 1 && (type == CommonActionsPanel.Buttons.EDIT || type == CommonActionsPanel.Buttons.REMOVE)) &&
         ((AbstractTreeNode)selectedObjects.iterator().next()).getValue() instanceof BreakpointItem;
}
项目:intellij-ce-playground    文件:DeleteFromFavoritesAction.java   
@Override
public void updateButton(AnActionEvent e) {
  e.getPresentation().setText(getTemplatePresentation().getText());
  final DataContext dataContext = e.getDataContext();
  Project project = e.getProject();
  FavoritesViewTreeBuilder builder = FavoritesTreeViewPanel.FAVORITES_TREE_BUILDER_KEY.getData(dataContext);
  if (project == null || builder == null) {
    e.getPresentation().setEnabled(false);
    return;
  }
  Set<Object> selection = builder.getSelectedElements();
  String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext);
  if (listName == null) {//Selection is empty or contains several items under favorites/bookmarks/breakpoints at the same time
    e.getPresentation().setText(CommonActionsPanel.Buttons.REMOVE.getText());
    e.getPresentation().setEnabled(false);
    return;
  }

  FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
  FavoritesListProvider provider = favoritesManager.getListProvider(listName);
  if (provider != null) {
    boolean willHandle = provider.willHandle(CommonActionsPanel.Buttons.REMOVE, project, selection);
    e.getPresentation().setEnabled(willHandle);
    if (willHandle) {
      e.getPresentation().setText(provider.getCustomName(CommonActionsPanel.Buttons.REMOVE));
    } else {
      e.getPresentation().setText(CommonActionsPanel.Buttons.REMOVE.getText());
    }
    return;
  }

  FavoritesTreeNodeDescriptor[] roots = FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS_DATA_KEY.getData(dataContext);

  if (roots == null || roots.length == 0 || selection.isEmpty()) {
    e.getPresentation().setEnabled(false);
    return;
  }
  for (Object o : selection) {
    if (o instanceof AbstractTreeNode) {
      AbstractTreeNode node = (AbstractTreeNode)o;
      int deep = getDeep(node);
      if (deep != 2 && deep != 3) {//favorite list or it's nested "root"
        e.getPresentation().setEnabled(false);
        return;
      }
    }
    else {
      e.getPresentation().setEnabled(false);
      return;
    }
  }
}
项目:intellij-ce-playground    文件:FavoritesListProvider.java   
@Nullable
String getCustomName(@NotNull CommonActionsPanel.Buttons type);
项目:intellij-ce-playground    文件:AbstractFavoritesListProvider.java   
@Nullable
@Override
public String getCustomName(@NotNull CommonActionsPanel.Buttons type) {
  return null;
}
项目:intellij-ce-playground    文件:AbstractFavoritesListProvider.java   
@Override
public boolean willHandle(@NotNull CommonActionsPanel.Buttons type, Project project, @NotNull Set<Object> selectedObjects) {
  return false;
}
项目:intellij-ce-playground    文件:AbstractFavoritesListProvider.java   
@Override
public void handle(@NotNull CommonActionsPanel.Buttons type, Project project, @NotNull Set<Object> selectedObjects, JComponent component) {
}
项目:intellij-ce-playground    文件:DomCollectionControl.java   
public AddAction() {
  setShortcutSet(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.ADD));
}
项目:intellij-ce-playground    文件:DomCollectionControl.java   
public EditAction() {
  super(ApplicationBundle.message("action.edit"), null, EDIT_ICON);
  setShortcutSet(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.EDIT));
}
项目:intellij-ce-playground    文件:DomCollectionControl.java   
public RemoveAction() {
  super(ApplicationBundle.message("action.remove"), null, REMOVE_ICON);
  setShortcutSet(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.REMOVE));
}
项目:intellij-ce-playground    文件:AddDomElementAction.java   
protected ShowPopupAction(ActionGroup group) {
  super(ApplicationBundle.message("action.add"), null, DomCollectionControl.ADD_ICON);
  myGroup = group;
  setShortcutSet(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.ADD));
}
项目:tools-idea    文件:BreakpointsFavoriteListProvider.java   
@Override
public boolean willHandle(@NotNull CommonActionsPanel.Buttons type, Project project, @NotNull Set<Object> selectedObjects) {
  return (selectedObjects.size() == 1 && (type == CommonActionsPanel.Buttons.EDIT || type == CommonActionsPanel.Buttons.REMOVE)) &&
         ((AbstractTreeNode)selectedObjects.iterator().next()).getValue() instanceof BreakpointItem;
}
项目:tools-idea    文件:DeleteFromFavoritesAction.java   
@Override
public void updateButton(AnActionEvent e) {
  e.getPresentation().setText(getTemplatePresentation().getText());
  final DataContext dataContext = e.getDataContext();
  Project project = e.getProject();
  FavoritesViewTreeBuilder builder = FavoritesTreeViewPanel.FAVORITES_TREE_BUILDER_KEY.getData(dataContext);
  if (project == null || builder == null) {
    e.getPresentation().setEnabled(false);
    return;
  }
  Set<Object> selection = builder.getSelectedElements();
  String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext);

  FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
  FavoritesListProvider provider = favoritesManager.getListProvider(listName);
  if (provider != null) {
    boolean willHandle = provider.willHandle(CommonActionsPanel.Buttons.REMOVE, project, selection);
    e.getPresentation().setEnabled(willHandle);
    if (willHandle) {
      e.getPresentation().setText(provider.getCustomName(CommonActionsPanel.Buttons.REMOVE));
    }
    return;
  }

  FavoritesTreeNodeDescriptor[] roots = FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS_DATA_KEY.getData(dataContext);

  if (roots == null || roots.length == 0 || selection.isEmpty()) {
    e.getPresentation().setEnabled(false);
    return;
  }
  for (Object o : selection) {
    if (o instanceof AbstractTreeNode) {
      AbstractTreeNode node = (AbstractTreeNode)o;
      int deep = getDeep(node);
      if (deep != 2 && deep != 3) {//favorite list or it's nested "root"
        e.getPresentation().setEnabled(false);
        return;
      }
    }
    else {
      e.getPresentation().setEnabled(false);
      return;
    }
  }
}
项目:tools-idea    文件:FavoritesListProvider.java   
@Nullable
String getCustomName(@NotNull CommonActionsPanel.Buttons type);
项目:tools-idea    文件:AbstractFavoritesListProvider.java   
@Nullable
@Override
public String getCustomName(@NotNull CommonActionsPanel.Buttons type) {
  return null;
}
项目:tools-idea    文件:AbstractFavoritesListProvider.java   
@Override
public boolean willHandle(@NotNull CommonActionsPanel.Buttons type, Project project, @NotNull Set<Object> selectedObjects) {
  return false;
}
项目:tools-idea    文件:AbstractFavoritesListProvider.java   
@Override
public void handle(@NotNull CommonActionsPanel.Buttons type, Project project, @NotNull Set<Object> selectedObjects, JComponent component) {
}
项目:tools-idea    文件:DomCollectionControl.java   
public AddAction() {
  setShortcutSet(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.ADD));
}
项目:tools-idea    文件:DomCollectionControl.java   
public EditAction() {
  super(ApplicationBundle.message("action.edit"), null, DomCollectionControl.EDIT_ICON);
  setShortcutSet(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.EDIT));
}
项目:tools-idea    文件:DomCollectionControl.java   
public RemoveAction() {
  super(ApplicationBundle.message("action.remove"), null, DomCollectionControl.REMOVE_ICON);
  setShortcutSet(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.REMOVE));
}
项目:tools-idea    文件:AddDomElementAction.java   
protected ShowPopupAction(ActionGroup group) {
  super(ApplicationBundle.message("action.add"), null, DomCollectionControl.ADD_ICON);
  myGroup = group;
  setShortcutSet(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.ADD));
}
项目:intellij-xquery    文件:DataSourceListPanelGuiTest.java   
private AnActionButton getAnActionButton(CommonActionsPanel.Buttons button) {
    return panel.getToolbarDecorator()
            .getActionsPanel()
            .getAnActionButton(button);
}