如果您对org.openide.util.actions.CallbackSystemAction的实例源码感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于org.openi
如果您对org.openide.util.actions.CallbackSystemAction的实例源码感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于org.openide.util.actions.CallbackSystemAction的实例源码的详细内容,我们还将为您解答源代码案例的相关问题,并且为您提供关于com.intellij.openapi.actionSystem.ActionButtonComponent的实例源码、com.intellij.openapi.actionSystem.ActionGroupUtil的实例源码、com.intellij.openapi.actionSystem.ActionGroup的实例源码、com.intellij.openapi.actionSystem.ActionManager的实例源码的有价值信息。
本文目录一览:- org.openide.util.actions.CallbackSystemAction的实例源码(源代码案例)
- com.intellij.openapi.actionSystem.ActionButtonComponent的实例源码
- com.intellij.openapi.actionSystem.ActionGroupUtil的实例源码
- com.intellij.openapi.actionSystem.ActionGroup的实例源码
- com.intellij.openapi.actionSystem.ActionManager的实例源码
org.openide.util.actions.CallbackSystemAction的实例源码(源代码案例)
private void detachSystemActionPerformer(JTextComponent c){ if (c == null) return; Action action = getEditorAction(c); if (action == null) return; Action globalSystemAction = getSystemAction(c); if (globalSystemAction == null) return; if (globalSystemAction instanceof CallbackSystemAction){ Object key = ((CallbackSystemAction)globalSystemAction).getActionMapKey(); ActionMap am = c.getActionMap(); if (am != null) { Object ea = am.get(key); if (action.equals(ea)) { am.remove(key); } } } }
public void editorActivated() { Action ea = getEditorAction(); Action sa = getSystemAction(); if (ea != null && sa != null) { if (updatePerformer) { if (ea.isEnabled() && sa instanceof CallbackSystemAction) { ((CallbackSystemAction)sa).setActionPerformer(this); } } if (syncEnabling) { if (enabledPropertySyncL == null) { enabledPropertySyncL = new EnabledPropertySyncListener(sa); } ea.addPropertychangelistener(enabledPropertySyncL); } } }
private FindSupport(TopComponent tc) { this.tc = tc; bar = new FindBar(this); ActionMap actionMap = tc.getActionMap(); CallbackSystemAction a = SystemAction.get(org.openide.actions.FindAction.class); actionMap.put(a.getActionMapKey(),new FindAction(true)); actionMap.put(FIND_NEXT_ACTION,new FindAction(true)); actionMap.put(FIND_PREVIoUS_ACTION,new FindAction(false)); // Hack ensuring the same shortcuts as editor JEditorPane pane = new JEditorPane(); for (Action action : pane.getEditorKitForContentType("text/x-java").getActions()) { // NOI18N Object name = action.getValue(Action.NAME); if (FIND_NEXT_ACTION.equals(name) || FIND_PREVIoUS_ACTION.equals(name)) { reuseShortcut(action); } } // PENDING the colors below should not be hardcoded HighlighterAll = new DefaultHighlighter.DefaultHighlightPainter(new Color(255,180,66)); HighlighterCurrent = new DefaultHighlighter.DefaultHighlightPainter(new Color(176,197,227)); pattern = Pattern.compile("$^"); // NOI18N }
void setActions (final Node.Property pd) { final CallbackSystemAction setDefault = (CallbackSystemAction)SystemAction .get(SetDefaultValueAction.class); // Enable / disable DefaultValueAction if (pd.supportsDefaultValue () && pd.canWrite ()) { setDefault.setActionPerformer (new ActionPerformer () { public void performAction (SystemAction a) { try { pd.restoreDefaultValue (); // workaround of bug #21182: forces a node's property change propertyChange ( new PropertyChangeEvent (this,pd.getName (),null,null)); } catch (Exception e) { setDefault.setActionPerformer (null); } } }); } else { setDefault.setActionPerformer (null); } }
@Override protected boolean processKeyBinding(Keystroke ks,KeyEvent e,int condition,boolean pressed) { boolean ret = super.processKeyBinding(ks,e,condition,pressed); // XXX #250546 Reason of overriding: to process global shortcut. if ((JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT == condition) && (ret == false) && !e.isConsumed()) { Keymap km = Lookup.getDefault().lookup(Keymap.class); Action action = (km != null) ? km.getAction(ks) : null; if (action == null) { return false; } if (action instanceof CallbackSystemAction) { CallbackSystemAction csAction = (CallbackSystemAction) action; if (tabbedPane != null) { Action a = tabbedPane.getActionMap().get(csAction.getActionMapKey()); if (a != null) { a.actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED,Utilities.keyToString(ks))); return true; } } } return false; } else { return ret; } }
@Override protected boolean processKeyBinding(Keystroke ks,Utilities.keyToString(ks))); return true; } } } return false; } else { return ret; } }
private void editorActivated(final JEditorPane editor) { //System.out.println("editor("+editor+") activated."); final Action copy = getAction (DefaultEditorKit.copyAction,editor); if (copy != null) { final CallbackSystemAction syscopy = ((CallbackSystemAction) SystemAction.get (copyAction.class)); final ActionPerformer perf = new ActionPerformer () { public void performAction (SystemAction action) { copy.actionPerformed (new ActionEvent (editor,"")); // NOI18N } }; syscopy.setActionPerformer(copy.isEnabled() ? perf : null); Propertychangelistener copyListener; copy.addPropertychangelistener(copyListener = new Propertychangelistener() { public void propertyChange(PropertyChangeEvent evt) { if ("enabled".equals(evt.getPropertyName())) { // NOI18N if (((Boolean)evt.getNewValue()).booleanValue()) { syscopy.setActionPerformer(perf); } else if (syscopy.getActionPerformer() == perf) { syscopy.setActionPerformer(null); } } } }); if (editor.equals(jEditorPane1)) copyL = copyListener; else copyP = copyListener; } }
private void editorActivated(final JEditorPane editor) { //System.out.println("editor("+editor+") activated."); final Action copy = getAction (DefaultEditorKit.copyAction,"")); // NOI18N } }; syscopy.setActionPerformer(copy.isEnabled() ? perf : null); Propertychangelistener copyListener; copy.addPropertychangelistener(copyListener = new Propertychangelistener() { public void propertyChange(PropertyChangeEvent evt) { if ("enabled".equals(evt.getPropertyName())) { // NOI18N if (((Boolean)evt.getNewValue()).booleanValue()) { syscopy.setActionPerformer(perf); } else if (syscopy.getActionPerformer() == perf) { syscopy.setActionPerformer(null); } } } }); if (editor.equals(jEditorPane1)) copyL = copyListener; else copyP = copyListener; } }
private void editorActivated(final JEditorPane editor) { final Action copy = getAction (DefaultEditorKit.copyAction,"")); // NOI18N } }; syscopy.setActionPerformer(copy.isEnabled() ? perf : null); Propertychangelistener copyListener; copy.addPropertychangelistener(copyListener = new Propertychangelistener() { public void propertyChange(PropertyChangeEvent evt) { if ("enabled".equals(evt.getPropertyName())) { // NOI18N if (((Boolean)evt.getNewValue()).booleanValue()) { syscopy.setActionPerformer(perf); } else if (syscopy.getActionPerformer() == perf) { syscopy.setActionPerformer(null); } } } }); if (editor.equals(jEditorPane1)) copyL = copyListener; else copyP = copyListener; } }
private void attachSystemActionPerformer(JTextComponent c){ if (c == null) return; Action action = getEditorAction(c); if (action == null) return; Action globalSystemAction = getSystemAction(c); if (globalSystemAction == null) return; if (globalSystemAction instanceof CallbackSystemAction){ Object key = ((CallbackSystemAction)globalSystemAction).getActionMapKey(); c.getActionMap ().put (key,action); } }
/** * Lazy creation of the popup menu. Adds SetDeafulValuetAction * to the menu. */ private void createPopup() { if (popupMenu == null) { popupMenu = new jpopupmenuPlus(); // popupMenu.add (new copyAction ().getPopupPresenter ()); // popupMenu.add (new PasteAction ().getPopupPresenter ()); // popupMenu.addSeparator (); CallbackSystemAction setDefault = (CallbackSystemAction)SystemAction.get(SetDefaultValueAction.class); popupMenu.add(setDefault.getPopupPresenter()); } }
protected Class<? extends CallbackSystemAction> actionClass() { return DeleteAction.class; }
protected Class<? extends CallbackSystemAction> actionClass() { return copyAction.class; }
protected Class<? extends CallbackSystemAction> actionClass() { return CutAction.class; }
protected Class<? extends CallbackSystemAction> actionClass() { return PasteAction.class; }
/** Which action to test. */ protected abstract Class<? extends CallbackSystemAction> actionClass();
com.intellij.openapi.actionSystem.ActionButtonComponent的实例源码
protected void paintBorder(Graphics g,Dimension size,int state) { GraphicsConfig config = GraphicsUtil.setupAAPainting(g); try { if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.POPPED) { g.setColor(JBColor.GRAY); ((Graphics2D)g).draw(getShape(size)); } } else if (SystemInfo.isMac && UIUtil.isUnderIntelliJLaF()) { //do nothing } else { final double shift = UIUtil.isUnderDarcula() ? 1 / 0.49 : 0.49; g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(),shift)); ((Graphics2D)g).setstroke(BASIC_stroke); ((Graphics2D)g).draw(getShape(size)); } } finally { config.restore(); } }
public void paintBorder(Graphics g,JComponent component,int state) { if (state == ActionButtonComponent.norMAL) return; Rectangle r = new Rectangle(component.getWidth(),component.getHeight()); if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.POPPED) { g.setColor(ALPHA_30); g.drawRoundRect(r.x,r.y,r.width - 2,r.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(r.x,4); config.restore(); } }
private static void paintBackground(Graphics g,int state) { if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.PUSHED) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0,ALPHA_40,size.width,size.height,ALPHA_20)); g.fillRect(0,size.width - 1,size.height - 1); g.setColor(ALPHA_120); g.drawLine(0,size.height - 2); g.drawLine(1,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,Gray._235,Gray._200)); g.fillRect(1,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)); } }
private static void paintBorder(Graphics g,int state) { if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.POPPED) { g.setColor(ALPHA_30); g.drawRoundRect(0,size.height - 2,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,size.height - JBUI.scale(2),JBUI.scale(4),JBUI.scale(4)); config.restore(); } }
@Override public void paintIcon(Component c,Graphics g,int x,int y) { final Dimension size = new Dimension(getIconWidth() + 2*x,getIconHeight() + 2*x); myLook.paintBackground(g,size,ActionButtonComponent.POPPED); myLook.paintBorder(g,ActionButtonComponent.POPPED); myIcon.paintIcon(c,g,x + (getIconWidth() - myIcon.getIconWidth())/2,y + (getIconHeight() - myIcon.getIconHeight())/2); }
@Override public void paintBackground(Graphics g,int state) { if (state == ActionButtonComponent.PUSHED) { g.setColor(component.getBackground().darker()); ((Graphics2D)g).fill(g.getClip()); } }
public void paintBackground(Graphics g,int state) { if (state != ActionButtonComponent.norMAL) { Component opaque = UIUtil.findNearestOpaque(component); Color bg = opaque != null? opaque.getBackground() : null; paintBackground(g,component.getSize(),bg,state); } }
public void paintIcon(Graphics g,ActionButtonComponent actionButton,Icon icon) { final int width = icon.getIconWidth(); final int height = icon.getIconHeight(); final int x = (int)Math.ceil((actionButton.getWidth() - width) / 2); final int y = (int)Math.ceil((actionButton.getHeight() - height) / 2); paintIconAt(g,actionButton,icon,x,y); }
@Override public void paintBackground(Graphics g,int state) { if (state == ActionButtonComponent.PUSHED) { g.setColor(component.getBackground().darker()); ((Graphics2D)g).fill(g.getClip()); } }
public void paintBackground(Graphics g,int state) { if (state == ActionButtonComponent.norMAL) return; Dimension dimension = component.getSize(); if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.PUSHED) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0,dimension.width,dimension.height,dimension.width - 1,dimension.height - 1); g.setColor(ALPHA_120); g.drawLine(0,dimension.height - 2); g.drawLine(1,dimension.width - 2,dimension.width - 3,dimension.height - 3); } else if (state == ActionButtonComponent.POPPED) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0,dimension.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(1,dimension.height - 2); } }
public void paintIcon(Graphics g,Icon icon) { int width = icon.getIconWidth(); int height = icon.getIconHeight(); int x = (int)Math.ceil((actionButton.getWidth() - width) / 2); int y = (int)Math.ceil((actionButton.getHeight() - height) / 2); paintIconAt(g,y); }
@Override public void actionPerformed(@Nonnull AnActionEvent e) { DefaultActionGroup group = new DefaultActionGroup(ActionManager.getInstance().getAction(myActionGroup)); ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null,group,e.getDataContext(),JBPopupFactory.ActionSelectionAid.MNEMONICS,true,ToolWindowContentUI.POPUP_PLACE); Component component = e.getInputEvent().getComponent(); if (component instanceof ActionButtonComponent) { popup.showUnderneathOf(component); } else { popup.showInCenterOf(component); } }
@Override protected void paintBorder(ActionButton button,int state) { final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); g.setColor(state == ActionButtonComponent.POPPED || state == ActionButtonComponent.PUSHED ? ModernUIUtil.getSelectionBackground() : ModernUIUtil.getBorderColor(button)); g.drawRect(0,size.width - JBUI.scale(1),size.height - JBUI.scale(1)); config.restore(); }
@Override protected void paintBackground(ActionButton button,int state) { if (state == ActionButtonComponent.PUSHED) { g.setColor(ColorUtil.toAlpha(ModernUIUtil.getSelectionBackground(),100)); g.fillRect(JBUI.scale(1),size.height - JBUI.scale(2)); } }
@Override public void paintIcon(Component c,int y) { final Dimension size = new Dimension(getIconWidth() + 2 * x,getIconHeight() + 2 * x); paintBackground(g,ActionButtonComponent.POPPED); paintBorder(g,x + (getIconWidth() - myIcon.getIconWidth()) / 2,y + (getIconHeight() - myIcon.getIconHeight()) / 2); }
protected void showPopup(final ListPopup groupPopup,final AnActionEvent e) { final Component component = e.getInputEvent().getComponent(); if (component instanceof ActionButtonComponent) { groupPopup.showUnderneathOf(component); } else { groupPopup.showInBestPositionFor(e.getDataContext()); } }
public <ButtonType extends JComponent & ActionButtonComponent> void paintBackground(Graphics g,ButtonType button) { paintBackground(g,button,getState(button)); }
public <ButtonType extends JComponent & ActionButtonComponent> void paintBorder(Graphics g,ButtonType button) { paintBorder(g,getState(button)); }
@SuppressWarnings("MethodMayBeStatic") @ActionButtonComponent.ButtonState protected int getState(ActionButtonComponent button) { // DO NOT inline this method! Because of compiler bug up-cast from ButtonType to ActionButtonComponent is important! return button.getPopState(); }
void paintBackground(Graphics g,Color background,int state) { GraphicsConfig config = GraphicsUtil.setupAAPainting(g); try { Color bg = background == null ? JBColor.background() : background; if (UIUtil.isUnderAquaLookAndFeel() || (SystemInfo.isMac && UIUtil.isUnderIntelliJLaF())) { if (state == ActionButtonComponent.PUSHED) { if (UIUtil.isUnderAquaLookAndFeel()) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0,ALPHA_20)); ((Graphics2D)g).fill(getShape(size)); g.setColor(ALPHA_30); ((Graphics2D)g).draw(getShape(size)); } else { g.setColor(ColorUtil.darker(bg,1)); ((Graphics2D)g).fill(getShape(size)); g.setColor(Gray.xC0); ((Graphics2D)g).draw(getShape(size)); } } else if (state == ActionButtonComponent.POPPED) { if (UIUtil.isUnderAquaLookAndFeel()) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0,ColorUtil.darker(bg,2))); ((Graphics2D)g).fill(getShape(size)); } else { ((Graphics2D)g).setPaint(ColorUtil.darker(bg,1)); ((Graphics2D)g).fill(getShape(size)); g.setColor(Gray.xCC); ((Graphics2D)g).draw(getShape(size)); } } } else { 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); ((Graphics2D)g).fill(getShape(size)); } } finally { config.restore(); } }
public void paintBorder(Graphics g,int state) { if (state != ActionButtonComponent.norMAL) { paintBorder(g,state); } }
public void paintIconAt(Graphics g,ActionButtonComponent button,Icon icon,int y) { icon.paintIcon(null,y); }
public <ButtonType extends JComponent & ActionButtonComponent> void paintBackground(Graphics g,getState(button)); }
public <ButtonType extends JComponent & ActionButtonComponent> void paintBorder(Graphics g,getState(button)); }
@SuppressWarnings("MethodMayBeStatic") @ActionButtonComponent.ButtonState protected int getState(ActionButtonComponent button) { // DO NOT inline this method! Because of compiler bug up-cast from ButtonType to ActionButtonComponent is important! return button.getPopState(); }
public void paintIconAt(Graphics g,y); }
public abstract void paintBackground(Graphics g,@ActionButtonComponent.ButtonState int state);
public abstract void paintBorder(Graphics g,@ActionButtonComponent.ButtonState int state);
public abstract void paintIcon(Graphics g,Icon icon);
public abstract void paintIconAt(Graphics g,int y);
public abstract void paintBackground(Graphics g,@ActionButtonComponent.ButtonState int state);
public abstract void paintBorder(Graphics g,@ActionButtonComponent.ButtonState int state);
public abstract void paintIcon(Graphics g,Icon icon);
public abstract void paintIconAt(Graphics g,int y);
com.intellij.openapi.actionSystem.ActionGroupUtil的实例源码
public void update(AnActionEvent e) { e.getPresentation().setVisible(!ActionGroupUtil.isGroupEmpty(this,e)); }
@Override public void update(AnActionEvent e) { e.getPresentation().setVisible(!ActionGroupUtil.isGroupEmpty(this,e)); }
public void update(AnActionEvent e) { e.getPresentation().setVisible(!ActionGroupUtil.isGroupEmpty(this,e,LaterInvocator.isInModalContext())); }
com.intellij.openapi.actionSystem.ActionGroup的实例源码
@Override protected void createTrees(@NotNull final Map<String,JTree> type2TreeMap) { ActionGroup group = (ActionGroup)ActionManager.getInstance().getAction(IdeActions.GROUP_CALL_HIERARCHY_POPUP); final JTree tree1 = createTree(false); PopupHandler.installPopupHandler(tree1,group,ActionPlaces.CALL_HIERARCHY_VIEW_POPUP,ActionManager.getInstance()); final BaSEOnThisMethodAction baSEOnThisMethodAction = new BaSEOnThisMethodAction(); baSEOnThisMethodAction .registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_CALL_HIERARCHY).getShortcutSet(),tree1); type2TreeMap.put(CALLEE_TYPE,tree1); final JTree tree2 = createTree(false); PopupHandler.installPopupHandler(tree2,ActionManager.getInstance()); baSEOnThisMethodAction .registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_CALL_HIERARCHY).getShortcutSet(),tree2); type2TreeMap.put(CALLER_TYPE,tree2); }
private void createConsole(@NotNull final NetService netService) { TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(netService.getProject()); netService.configureConsole(consoleBuilder); console = consoleBuilder.getConsole(); ApplicationManager.getApplication().invokelater(new Runnable() { @Override public void run() { ActionGroup actionGroup = netService.getConsoletoolWindowActions(); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNowN,actionGroup,false); SimpletoolWindowPanel toolWindowPanel = new SimpletoolWindowPanel(false,true); toolWindowPanel.setContent(console.getComponent()); toolWindowPanel.setToolbar(toolbar.getComponent()); ToolWindow toolWindow = ToolWindowManager.getInstance(netService.getProject()) .registerToolWindow(netService.getConsoletoolWindowId(),false,ToolWindowAnchor.BottOM,netService.getProject(),true); toolWindow.setIcon(netService.getConsoletoolWindowIcon()); Content content = ContentFactory.SERVICE.getInstance().createContent(toolWindowPanel,"",false); disposer.register(content,console); toolWindow.getContentManager().addContent(content); } },netService.getProject().getdisposed()); }
private static int getChildrenCountRecursive(ActionGroup group) { AnAction[] children; if (group instanceof DefaultActionGroup) { children = ((DefaultActionGroup) group).getChildActionsOrStubs(); } else { children = group.getChildren(null); } int count = 0; for (AnAction child : children) { if (child instanceof ActionGroup) { count += getChildrenCountRecursive((ActionGroup) child); } else { count++; } } return count; }
@Override public void readExternal(Element element) throws InvalidDataException { myGroupPath = new ArrayList<String>(); for (Object o : element.getChildren(PATH)) { myGroupPath.add(((Element)o).getAttributeValue(VALUE)); } final String attributeValue = element.getAttributeValue(VALUE); if (element.getAttributeValue(IS_ACTION) != null) { myComponent = attributeValue; } else if (element.getAttributeValue(SEParaTOR) != null) { myComponent = Separator.getInstance(); } else if (element.getAttributeValue(IS_GROUP) != null) { final AnAction action = ActionManager.getInstance().getAction(attributeValue); myComponent = action instanceof ActionGroup ? ActionsTreeUtil.createGroup((ActionGroup)action,true,null) : new Group(attributeValue,attributeValue,null); } myActionType = Integer.parseInt(element.getAttributeValue(ACTION_TYPE)); myAbsolutePosition = Integer.parseInt(element.getAttributeValue(POSITION)); DefaultJDOMExternalizer.readExternal(this,element); }
public AnAction getCorrectedAction(String id) { if (! myIdToNameList.contains(new Pair(id,""))){ return ActionManager.getInstance().getAction(id); } if (myIdToActionGroup.get(id) == null) { for (Pair pair : myIdToNameList) { if (pair.first.equals(id)){ final ActionGroup actionGroup = (ActionGroup)ActionManager.getInstance().getAction(id); if (actionGroup != null) { //J2EE/Commander plugin was disabled myIdToActionGroup.put(id,CustomizationUtil.correctActionGroup(actionGroup,this,pair.second,pair.second)); } } } } return myIdToActionGroup.get(id); }
public boolean isCorrectActionGroup(ActionGroup group,String defaultGroupName) { if (myActions.isEmpty()){ return false; } final String text = group.getTemplatePresentation().getText(); if (!StringUtil.isEmpty(text)) { for (ActionUrl url : myActions) { if (url.getGroupPath().contains(text) || url.getGroupPath().contains(defaultGroupName)) { return true; } if (url.getComponent() instanceof Group) { final Group urlGroup = (Group)url.getComponent(); String id = urlGroup.getName() != null ? urlGroup.getName() : urlGroup.getId(); if (id == null || id.equals(text) || id.equals(defaultGroupName)) { return true; } } } return false; } return true; }
@NotNull private ActionGroup createActions() { DefaultActionGroup popupGroup = new DefaultActionGroup(null,false); AbstractRepositoryManager<Repo> repositoryManager = myRepositoryManager; if (repositoryManager.moreThanOneRoot()) { if (userWantsSyncControl()) { fillWithCommonRepositoryActions(popupGroup,repositoryManager); } else { fillPopupWithCurrentRepositoryActions(popupGroup,createRepositoriesActions()); } } else { fillPopupWithCurrentRepositoryActions(popupGroup,null); } popupGroup.addSeparator(); return popupGroup; }
@Override @NotNull public AnAction[] getChildren(@Nullable AnActionEvent e) { List<AnAction> result = new ArrayList<AnAction>(); for (AnAction action : myDelegate.getChildren(e)) { if (myExcludes.contains(action)) { continue; } if (action instanceof ActionGroup) { result.add(new ExcludingActionGroup((ActionGroup) action,myExcludes)); } else { result.add(action); } } return result.toArray(new AnAction[result.size()]); }
@NotNull public ActionGroup getToolbaractions(Project project,DeviceContext deviceContext) { DefaultActionGroup group = new DefaultActionGroup(); group.add(new ScreenshotAction(project,deviceContext)); group.add(new ScreenRecorderAction(project,deviceContext)); group.add(DumpSysActions.create(project,deviceContext)); //group.add(new MyFileExplorerAction()); group.add(new Separator()); group.add(new TerminateVMAction(deviceContext)); //group.add(new MyAllocationTrackerAction()); //group.add(new Separator()); return group; }
@NotNull private ActionGroup createActionToolbar(JComponent consolePanel,ConsoleView consoleView,@NotNull final RunnerLayoutUi myUi,runcontentDescriptor contentDescriptor,Executor runExecutorInstance) { final DefaultActionGroup actionGroup = new DefaultActionGroup(); actionGroup.add(new Filteraction()); actionGroup.add(new RerunAction(consolePanel,consoleView)); actionGroup.add(new StopAction()); actionGroup.add(new FormatAction()); actionGroup.add(new MyCloseAction(runExecutorInstance,contentDescriptor,myProject)); return actionGroup; }
private static JComponent createConsolePanel(ConsoleView view,ActionGroup actions) { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(view.getComponent(),BorderLayout.CENTER); panel.add(createtoolbar(actions),BorderLayout.WEST); return panel; }
/** * Create a list of idea actions that the user can choose,to change their pairs. * * @param pairController Pair logic controller for list of members. * @return list of actions. */ private static ActionGroup createActions(@NotNull PairController pairController,@NotNull TeamMemberAction.TeamMemberActionPerformer teamMemberActionPerformer) { DefaultActionGroup defaultActionGroup = new DefaultActionGroup(null,false); PairConfig pairConfig = pairController.getPairConfig(); for (TeamMember teamMember : pairConfig.getTeamMembers()) { defaultActionGroup.add(new TeamMemberAction(teamMember,teamMemberActionPerformer)); } return defaultActionGroup; }
private static ActionToolbar createtoolbarFromGroupId(final String groupId) { final ActionManager actionManager = ActionManager.getInstance(); if (!actionManager.isGroup(groupId)) { throw new IllegalStateException(groupId + " should have been a group"); } final ActionGroup group = ((ActionGroup)actionManager.getAction(groupId)); final ActionToolbarImpl editorToolbar = ((ActionToolbarImpl)actionManager.createActionToolbar(ActionPlaces.EDITOR_TOOLBAR,true)); editorToolbar.setopaque(false); editorToolbar.setBorder(new JBEmptyBorder(0,2,2)); return editorToolbar; }
@NotNull private ActionGroup createActionToolbar(JComponent consolePanel,Executor runExecutorInstance) { final DefaultActionGroup actionGroup = new DefaultActionGroup(); actionGroup.add(new RerunAction(consolePanel,myProject)); return actionGroup; }
protected void createTrees(@NotNull Map<String,JTree> trees) { final JTree tree = createTree(false); ActionGroup group = (ActionGroup)ActionManager.getInstance().getAction(IdeActions.GROUP_METHOD_HIERARCHY_POPUP); PopupHandler.installPopupHandler(tree,ActionPlaces.METHOD_HIERARCHY_VIEW_POPUP,ActionManager.getInstance()); final BaSEOnThisMethodAction baSEOnThisMethodAction = new BaSEOnThisMethodAction(); baSEOnThisMethodAction .registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_METHOD_HIERARCHY).getShortcutSet(),tree); trees.put(METHOD_TYPE,tree); }
ActionGroup createActions(@Nullable DefaultActionGroup toInsert) { DefaultActionGroup popupGroup = new DefaultActionGroup(null,false); popupGroup.addAction(new HgNewBranchAction(myProject,Collections.singletonList(myRepository),myRepository)); popupGroup.addAction(new HgNewBookmarkAction(Collections.singletonList(myRepository),myRepository)); popupGroup.addAction(new HgBranchPopupActions.HgCloseBranchAction(Collections.singletonList(myRepository),myRepository)); popupGroup.addAction(new HgShowUnnamedHeadsForCurrentBranchAction(myRepository)); if (toInsert != null) { popupGroup.addAll(toInsert); } popupGroup.addSeparator("Bookmarks"); List<String> bookmarkNames = getSortednamesWithoutHashes(myRepository.getBookmarks()); String currentBookmark = myRepository.getCurrentBookmark(); for (String bookmark : bookmarkNames) { AnAction bookmarkAction = new BookmarkActions(myProject,bookmark); if (bookmark.equals(currentBookmark)) { bookmarkAction.getTemplatePresentation().setIcon(PlatformIcons.CHECK_ICON); } popupGroup.add(bookmarkAction); } popupGroup.addSeparator("Branches"); List<String> branchNamesList = new ArrayList<String>(myRepository.getopenedBranches());//only opened branches have to be shown Collections.sort(branchNamesList); for (String branch : branchNamesList) { if (!branch.equals(myRepository.getCurrentBranch())) { // don't show current branch in the list popupGroup.add(new HgCommonBranchActions(myProject,branch)); } } return popupGroup; }
public void initContent() { final ActionManager actionManager = ActionManager.getInstance(); final ActionGroup actionGroup = (ActionGroup)actionManager.getAction(TOOL_WINDOW_TOOLBAR_ID); ActionToolbar actionToolbar = actionManager.createActionToolbar(myPlace,true); JPanel toolbarControl = new JPanel(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.weightx = 1; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.WEST; toolbarControl.add(actionToolbar.getComponent(),constraints); for (JComponent component : getToolbarControls()) { component.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP)); toolbarControl.add(component,constraints); } setToolbar(toolbarControl); final JComponent payloadControl = buildContent(); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(payloadControl); JScrollBar scrollBar = scrollPane.getVerticalScrollBar(); scrollBar.setUnitIncrement(scrollBar.getUnitIncrement() * 7); myContent.add(scrollPane,CONTENT_CARD_NAME); RichTextControlBuilder builder = new RichTextControlBuilder(); builder.setBackgroundColor(payloadControl.getBackground()); builder.setForegroundColor(UIUtil.getInactiveTextColor()); builder.setFont(payloadControl.getFont()); builder.setText(GradleBundle.message("gradle.toolwindow.text.no.linked.project")); final JComponent noLinkedProjectControl = builder.build(); myContent.add(noLinkedProjectControl,NON_LINKED_CARD_NAME); update(); }
@NotNull public abstract ListPopupStep createActionsstep(@NotNull ActionGroup actionGroup,@NotNull DataContext dataContext,boolean showNumbers,boolean showdisabledActions,String title,Component component,boolean honorActionMnemonics);
@NotNull public abstract ListPopupStep createActionsstep(@NotNull ActionGroup actionGroup,boolean honorActionMnemonics,int defaultOptionIndex,final boolean autoSelectionEnabled);
@NotNull public abstract ListPopup createActionGroupPopup(@Nls(capitalization = Nls.Capitalization.Title) String title,@NotNull ActionGroup actionGroup,@Nullable Runnable disposeCallback,int maxRowCount,@Nullable Condition<AnAction> preselectActionCondition);
public ToolbarPanel(JComponent contentComponent,ActionGroup actions,final String toolbarPlace) { super(new GridBagLayout()); setBorder(BorderFactory.createEtchedBorder()); if (contentComponent.getBorder() != null) { contentComponent.setBorder(BorderFactory.createEmptyBorder()); } final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(toolbarPlace,actions,true); add(actionToolbar.getComponent(),new GridBagConstraints(0,GridBagConstraints.RELATIVE,1,1.0,0.0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(0,0),0)); add(contentComponent,GridBagConstraints.BOTH,0)); }
public TabInfo setActions(ActionGroup group,String place) { ActionGroup old = myGroup; myGroup = group; myPlace = place; myChangeSupport.firePropertyChange(ACTION_GROUP,old,myGroup); return this; }
public TabInfo setTabLabelActions(final ActionGroup tabActions,String place) { ActionGroup old = myTabLabelActions; myTabLabelActions = tabActions; myTabActionPlace = place; myChangeSupport.firePropertyChange(TAB_ACTION_GROUP,myTabLabelActions); return this; }
public static MouseListener installPopupHandler(JComponent component,@NotNull final ActionGroup group,final String place,final ActionManager actionManager) { if (ApplicationManager.getApplication() == null) return new MouseAdapter(){}; PopupHandler popupHandler = new PopupHandler() { public void invokePopup(Component comp,int x,int y) { final ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(place,group); popupMenu.getComponent().show(comp,x,y); } }; component.addMouseListener(popupHandler); return popupHandler; }
public static MouseListener installFollowingSelectionTreePopup(final JTree tree,final ActionManager actionManager){ if (ApplicationManager.getApplication() == null) return new MouseAdapter(){}; PopupHandler handler = new PopupHandler() { public void invokePopup(Component comp,int y) { if (tree.getPathForLocation(x,y) != null && Arrays.binarySearch(tree.getSelectionRows(),tree.getRowForLocation(x,y)) > -1) { //do not show popup menu on rows other than selection final ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(place,group); popupMenu.getComponent().show(comp,y); } } }; tree.addMouseListener(handler); return handler; }
@Override protected ActionGroup createActionGroup() { DefaultActionGroup group = new DefaultActionGroup(); group.add(createallAction()); group.add(createSelectMultipleValuesAction()); if (!myDataHolder.getCurrentUser().isEmpty()) { group.add(createPredefinedValueAction(Collections.singleton(VcslogUserFilterImpl.ME))); } group.addAll(createRecentItemsActionGroup()); return group; }
/** * Returns filter components which will be added to the Log toolbar. */ @NotNull public ActionGroup createActionGroup() { DefaultActionGroup actionGroup = new DefaultActionGroup(); actionGroup.add(new TextFilterComponent(myTextFilterModel)); actionGroup.add(new FilteractionComponent(new Computable<JComponent>() { @Override public JComponent compute() { return new BranchFilterPopupComponent(myUiProperties,myBranchFilterModel).initUi(); } })); actionGroup.add(new FilteractionComponent(new Computable<JComponent>() { @Override public JComponent compute() { return new UserFilterPopupComponent(myUiProperties,myLogDataHolder,myUserFilterModel).initUi(); } })); actionGroup.add(new FilteractionComponent(new Computable<JComponent>() { @Override public JComponent compute() { return new datefilterPopupComponent(mydatefilterModel).initUi(); } })); actionGroup.add(new FilteractionComponent(new Computable<JComponent>() { @Override public JComponent compute() { return new StructureFilterPopupComponent(myStructureFilterModel,myUi.getColorManager()).initUi(); } })); return actionGroup; }
@Override protected ActionGroup createActionGroup() { DefaultActionGroup actionGroup = new DefaultActionGroup(); actionGroup.add(createallAction()); actionGroup.add(createSelectMultipleValuesAction()); actionGroup.add(constructActionGroup(myFilterModel.getDataPack(),createRecentItemsActionGroup(),new Function<String,AnAction>() { @Override public AnAction fun(String name) { return createPredefinedValueAction(Collections.singleton(name)); } },myBranchFilterModel.getVisibleRoots())); return actionGroup; }
@Override protected ActionGroup createActionGroup() { Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); cal.add(Calendar.DAY_OF_YEAR,-1); Date oneDayBefore = cal.getTime(); cal.add(Calendar.DAY_OF_YEAR,-6); Date oneWeekBefore = cal.getTime(); return new DefaultActionGroup(createallAction(),new DateAction(oneDayBefore,"Last 24 hours"),new DateAction(oneWeekBefore,"Last 7 days"),new SelectAction()); }
public WelcomePane(ActionGroup actions,WelcomeScreen screen) { super(new GridBagLayout()); JPanel actionsPanel = new CardActionsPanel(actions) { @Override public Dimension getPreferredSize() { return new Dimension(500,super.getPreferredSize().height); } }; actionsPanel.setBorder(new LineBorder(WelcomeScreenColors.BORDER_COLOR)); JPanel recentsPanel = new JPanel(new BorderLayout(30,30)); recentsPanel.add(new RecentProjectPanel(screen)); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.insets = new Insets(15,15,15); c.weightx = 0.33; c.weighty = 1; c.fill = GridBagConstraints.BOTH; add(recentsPanel,c); c.gridx = 1; c.gridy = 0; c.weightx = 0.66; c.weighty = 1; c.insets = new Insets(15,15); c.anchor = GridBagConstraints.norTH; c.fill = GridBagConstraints.BOTH; add(actionsPanel,c); }
public static EditorPopupHandler createEditorPopupHandler(@NotNull final String groupId) { return new EditorPopupHandler() { @Override public void invokePopup(final EditorMouseEvent event) { if (!event.isConsumed() && event.getArea() == EditorMouseEventArea.EDITING_AREA) { ActionGroup group = (ActionGroup)CustomActionsSchema.getInstance().getCorrectedAction(groupId); showEditorPopup(event,group); } } }; }
public static EditorPopupHandler createEditorPopupHandler(@NotNull final ActionGroup group) { return new EditorPopupHandler() { @Override public void invokePopup(final EditorMouseEvent event) { showEditorPopup(event,group); } }; }
private static void showEditorPopup(final EditorMouseEvent event,@NotNull final ActionGroup group) { if (!event.isConsumed() && event.getArea() == EditorMouseEventArea.EDITING_AREA) { ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.EDITOR_POPUP,group); MouseEvent e = event.getMouseEvent(); final Component c = e.getComponent(); if (c != null && c.isShowing()) { popupMenu.getComponent().show(c,e.getX(),e.getY()); } e.consume(); } }
@Override public void setActions(final ActionGroup actions,String place,@Nullable JComponent contextComponent) { final ActionGroup oldActions = myActions; myActions = actions; myPlace = place; myActionsContextComponent = contextComponent; myChangeSupport.firePropertyChange(PROP_ACTIONS,oldActions,myActions); }
@Override public ActionGroup getCaptionActions() { DefaultActionGroup group = new DefaultActionGroup(); group.add(new InsertBeforeAction()); group.add(new InsertAfteraction()); group.add(new Splitaction()); group.add(new DeleteAction()); return group; }
public boolean isGroupContainsInPath(ActionGroup group){ for (String s : myGroupPath) { if (s.equals(group.getTemplatePresentation().getText())) { return true; } } return false; }
public void fillActionGroups(DefaultMutableTreeNode root){ final ActionManager actionManager = ActionManager.getInstance(); for (Pair pair : myIdToNameList) { final ActionGroup actionGroup = (ActionGroup)actionManager.getAction(pair.first); if (actionGroup != null) { //J2EE/Commander plugin was disabled root.add(ActionsTreeUtil.createNode(ActionsTreeUtil.createGroup(actionGroup,null,false))); } } }
/** * @param currentRepository Pass null in the case of common repositories - none repository will be highlighted then. * @param actionsGroup * @param branchText */ public RootAction(@NotNull T repository,@Nullable T currentRepository,@NotNull ActionGroup actionsGroup,@NotNull String branchText) { super("",true); myRepository = repository; myGroup = actionsGroup; myBranchText = branchText; if (repository.equals(currentRepository)) { getTemplatePresentation().setIcon(PlatformIcons.CHECK_ICON); } getTemplatePresentation().setText(DvcsUtil.getShortRepositoryName(repository),false); }
public JComponent initContent() { mybrowser = new CommittedChangesTreebrowser(myProject,Collections.<Committedchangelist>emptyList()); mybrowser.getEmptyText().setText(VcsBundle.message("incoming.changes.not.loaded.message")); ActionGroup group = (ActionGroup) ActionManager.getInstance().getAction("IncomingChangesToolbar"); final ActionToolbar toolbar = mybrowser.createGroupFilterToolbar(myProject,Collections.<AnAction>emptyList()); mybrowser.setToolBar(toolbar.getComponent()); mybrowser.setTableContextMenu(group,Collections.<AnAction>emptyList()); myConnection = myBus.connect(); myConnection.subscribe(CommittedChangesCache.COMMITTED_TOPIC,new MyCommittedChangesListener()); loadChangesTobrowser(false,true); JPanel contentPane = new JPanel(new BorderLayout()); contentPane.add(mybrowser,BorderLayout.CENTER); return contentPane; }
@Override public ActionGroup getCaptionActions() { DefaultActionGroup group = new DefaultActionGroup(); group.add(new InsertBeforeAction()); group.add(new InsertAfteraction()); group.add(new Splitaction()); group.add(new DeleteAction()); group.add(new GroupRowsColumnsAction()); group.add(new UngroupRowsColumnsAction()); return group; }
com.intellij.openapi.actionSystem.ActionManager的实例源码
public void initBPMNModelMenu() { DefaultActionGroup modelMenu = (DefaultActionGroup) ActionManager.getInstance().getAction("yaoqiang.actions.BPMNModelMenu"); AppMenu model = new ModelMenu(); for (int i = 0; i < model.getItemCount(); i++) { JMenuItem item = model.getItem(i); if (item == null) { modelMenu.addSeparator(); } else { AnAction action = new AnAction(item.getText()) { @Override public void actionPerformed(AnActionEvent e) { item.getAction().actionPerformed(new ActionEvent(e,"")); } }; modelMenu.add(action); } } }
@Override public void apply() throws ConfigurationException { PropertiesComponent prop = PropertiesComponent.getInstance(); prop.setValue(FOLDER,imageFolder.getText()); String timeExecutionValue = timeExecution.getText(); prop.setValue(TIME_EXECUTION,timeExecutionValue); int opcity = opacity.getValue(); prop.setValue(OPACITY,String.valueOf(opcity)); boolean isdisabled = disabled.isSelected(); prop.setValue(disABLED,isdisabled); scheduledexecutorserviceHandler.shutdownExecution(); if(isdisabled) { ActionManager.getInstance().getAction("clearBackgroundImage").actionPerformed(null); }else { ActionManager.getInstance().getAction("randomBackgroundImage").actionPerformed(null); } }
@Override public JLabel getListCellRendererComponent(JList<? extends StatisticsItem> list,StatisticsItem value,int index,boolean isSelected,boolean cellHasFocus) { final Color foreground = list.getForeground(); final String message = KeyPromoterBundle.message( "kp.list.item",value.getShortcut(),value.description,value.count,value.count == 1 ? "time" : "times" ); setText(message); setForeground(foreground); setBorder(new EmptyBorder(2,10,2,10)); if (value.ideaActionID != null && !"".equals(value.ideaActionID)) { final AnAction action = ActionManager.getInstance().getAction(value.ideaActionID); if (action != null) { final Icon icon = action.getTemplatePresentation().getIcon(); if (icon != null) { setIcon(icon); } } } return this; }
@NotNull default DefaultActionGroup getTaskDescriptionActionGroup() { final DefaultActionGroup group = new DefaultActionGroup(); String[] ids = new String[]{ StudyCheckAction.ACTION_ID,StudyPrevIoUsTaskAction.ACTION_ID,StudyNextTaskAction.ACTION_ID,StudyRefreshTaskFileAction.ACTION_ID,StudyShowHintAction.ACTION_ID }; ActionManager actionManager = ActionManager.getInstance(); Arrays.stream(ids) .map(actionManager::getAction) .filter(Objects::nonNull) .forEach(group::add); group.add(new StudyEditInputAction()); return group; }
private static void processKeymap(final Element configurableElement){ final ActionManager actionManager = ActionManager.getInstance(); final String componentName = actionManager.getComponentName(); final SearchableOptionsRegistrar searchableOptionsRegistrar = SearchableOptionsRegistrar.getInstance(); final Set<String> ids = ((ActionManagerImpl)actionManager).getActionIds(); final TreeSet<OptionDescription> options = new TreeSet<OptionDescription>(); for (String id : ids) { final AnAction anAction = actionManager.getAction(id); final String text = anAction.getTemplatePresentation().getText(); if (text != null) { collectOptions(searchableOptionsRegistrar,options,text,componentName); } final String description = anAction.getTemplatePresentation().getDescription(); if (description != null) { collectOptions(searchableOptionsRegistrar,description,componentName); } } writeOptions(configurableElement,options); }
@Override public void actionPerformed(AnActionEvent e) { ActionManager am = ActionManager.getInstance(); DefaultActionGroup actionGroup = (DefaultActionGroup) am.getAction(LaunchSearchActionRegistration.COMPONENT_GROUP); // https://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+Popups // https://github.com/linux-china/idea-string-manipulation/blob/master/src/main/java/osmedile/intellij/stringmanip/PopupChoiceAction.java#L23 JBPopupFactory .getInstance() .createActionGroupPopup("Onlinesearch",actionGroup,e.getDataContext(),JBPopupFactory.ActionSelectionAid.NUMBERING,false) .showInBestPositionFor(e.getDataContext()); }
@NotNull @Override protected AnAction[] computeChildren(@NotNull ActionManager manager) { CheckoutProvider[] providers = CheckoutProvider.EXTENSION_POINT_NAME.getExtensions(); if (providers.length == 0) { return EMPTY_ARRAY; } Arrays.sort(providers,new CheckoutProvider.CheckoutProviderComparator()); AnAction[] children = new AnAction[providers.length]; for (int i = 0; i < providers.length; i++) { CheckoutProvider provider = providers[i]; children[i] = createAction(provider); } return children; }
@Override protected void addVcsspecificActions(@NotNull ActionManager manager,@NotNull List<AnAction> actions) { add("Git.Branches",manager,actions); add("Vcs.Push",actions); add("Git.Stash",actions); add("Git.Unstash",actions); add("ChangesView.AddUnversioned",actions); add("Git.ResolveConflicts",actions); // Github addSeparator(actions); final AnAction githubRebase = manager.getAction("Github.Rebase"); if (githubRebase != null) { actions.add(new Separator(GitBundle.message("vcs.popup.git.github.section"))); actions.add(githubRebase); } }
private void createConsole(@NotNull final NetService netService) { TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(netService.getProject()); netService.configureConsole(consoleBuilder); console = consoleBuilder.getConsole(); ApplicationManager.getApplication().invokelater(new Runnable() { @Override public void run() { ActionGroup actionGroup = netService.getConsoletoolWindowActions(); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNowN,false); SimpletoolWindowPanel toolWindowPanel = new SimpletoolWindowPanel(false,true); toolWindowPanel.setContent(console.getComponent()); toolWindowPanel.setToolbar(toolbar.getComponent()); ToolWindow toolWindow = ToolWindowManager.getInstance(netService.getProject()) .registerToolWindow(netService.getConsoletoolWindowId(),false,ToolWindowAnchor.BottOM,netService.getProject(),true); toolWindow.setIcon(netService.getConsoletoolWindowIcon()); Content content = ContentFactory.SERVICE.getInstance().createContent(toolWindowPanel,"",false); disposer.register(content,console); toolWindow.getContentManager().addContent(content); } },netService.getProject().getdisposed()); }
@Nullable private static String getGoalActionId(DataContext context) { final List<String> goals = MavendataKeys.MAVEN_GOALS.getData(context); if (goals == null || goals.size() != 1) { return null; } MavenProject project = MavenActionUtil.getMavenProject(context); if (project == null) return null; String goal = goals.get(0); final MavenShortcutsManager shortcutsManager = getShortcutsManager(context); String actionId = shortcutsManager != null ? shortcutsManager.getActionId(project.getPath(),goal) : null; if (actionId != null) { AnAction action = ActionManager.getInstance().getAction(actionId); if (action == null) { MavenKeymapExtension.getorRegisteraction(project,actionId,goal); } } return actionId; }
private Action createcopyAction() { ActionManager actionManager = ActionManager.getInstance(); if (actionManager == null) return null; AnAction action = actionManager.getAction(IdeActions.ACTION_copY); if (action == null) return null; return new AbstractAction(action.getTemplatePresentation().getText(),action.getTemplatePresentation().getIcon()) { @Override public void actionPerformed(ActionEvent e) { StringSelection content = new StringSelection(getText()); ClipboardSynchronizer.getInstance().setContent(content,content); } @Override public boolean isEnabled() { return !getText().isEmpty(); } }; }
@NotNull static JPanel createTreePanel(@NotNull CheckBoxTreeView tree) { JPanel treePanel = new JPanel(new BorderLayout()); DefaultActionGroup group = new DefaultActionGroup(); CommonActionsManager actions = CommonActionsManager.getInstance(); group.addAll(actions.createExpandAllAction(tree,treePanel),actions.createCollapseAllAction(tree,treePanel)); ActionToolbar actionToolBar = ActionManager.getInstance().createActionToolbar("",group,true); JPanel buttonsPanel = new JPanel(new BorderLayout()); buttonsPanel.add(actionToolBar.getComponent(),BorderLayout.CENTER); buttonsPanel.setBorder(new SideBorder(JBColor.border(),SideBorder.TOP | SideBorder.LEFT | SideBorder.RIGHT,1)); treePanel.add(buttonsPanel,BorderLayout.norTH); treePanel.add(ScrollPaneFactory.createScrollPane(tree),BorderLayout.CENTER); return treePanel; }
public RunnerLayoutUiImpl(@NotNull Project project,@NotNull disposable parent,@NotNull String runnerId,@NotNull String runnerTitle,@NotNull String sessionName) { myLayout = RunnerLayoutSettings.getInstance().getLayout(runnerId); disposer.register(parent,this); myContentUI = new RunnerContentUi(project,this,ActionManager.getInstance(),IdeFocusManager.getInstance(project),myLayout,runnerTitle + " - " + sessionName); disposer.register(this,myContentUI); myViewsContentManager = getContentFactory().createContentManager(myContentUI.getContentUI(),project); myViewsContentManager.addDataProvider(this); disposer.register(this,myViewsContentManager); }
@Override public void beforeActionPerformed(AnAction action,DataContext dataContext,AnActionEvent event) { final InputEvent input = event.getInputEvent(); if (input instanceof MouseEvent) { final String id = ActionManager.getInstance().getId(action); final ShortcutPromoterEP ep = myExtensions.get(id); if (ep != null) { PromoterState state = myState.get(id); if (state == null) { state = new PromoterState(); myState.put(id,state); } state.incclicks(); } } }
public AnAction getCorrectedAction(String id) { if (! myIdToNameList.contains(new Pair(id,""))){ return ActionManager.getInstance().getAction(id); } if (myIdToActionGroup.get(id) == null) { for (Pair pair : myIdToNameList) { if (pair.first.equals(id)){ final ActionGroup actionGroup = (ActionGroup)ActionManager.getInstance().getAction(id); if (actionGroup != null) { //J2EE/Commander plugin was disabled myIdToActionGroup.put(id,CustomizationUtil.correctActionGroup(actionGroup,pair.second,pair.second)); } } } } return myIdToActionGroup.get(id); }
private void editToolbarIcon(String actionId,DefaultMutableTreeNode node) { final AnAction anAction = ActionManager.getInstance().getAction(actionId); if (isToolbaraction(node) && anAction.getTemplatePresentation().getIcon() == null) { final int exitCode = Messages.showOkCancelDialog(IdeBundle.message("error.adding.action.without.icon.to.toolbar"),IdeBundle.message("title.unable.to.add.action.without.icon.to.toolbar"),Messages.getinformationIcon()); if (exitCode == Messages.OK) { mySelectedSchema.addIconCustomization(actionId,null); anAction.getTemplatePresentation().setIcon(AllIcons.Toolbar.UnkNown); anAction.getTemplatePresentation().setdisabledIcon(IconLoader.getdisabledIcon(AllIcons.Toolbar.UnkNown)); anAction.setDefaultIcon(false); node.setUserObject(Pair.create(actionId,AllIcons.Toolbar.UnkNown)); myActionsTree.repaint(); CustomActionsSchema.setCustomizationSchemaForCurrentProjects(); } } }
@Override protected void doOKAction() { if (myNode != null) { if (!doSetIcon(myNode,myTextField.getText(),getContentPane())) { return; } final Object userObject = myNode.getUserObject(); if (userObject instanceof Pair) { String actionId = (String)((Pair)userObject).first; final AnAction action = ActionManager.getInstance().getAction(actionId); final Icon icon = (Icon)((Pair)userObject).second; action.getTemplatePresentation().setIcon(icon); action.setDefaultIcon(icon == null); editToolbarIcon(actionId,myNode); } myActionsTree.repaint(); } CustomActionsSchema.setCustomizationSchemaForCurrentProjects(); super.doOKAction(); }
@Override protected void doOKAction() { final ActionManager actionManager = ActionManager.getInstance(); TreeUtil.traverseDepth((TreeNode)myTree.getModel().getRoot(),new TreeUtil.Traverse() { @Override public boolean accept(Object node) { if (node instanceof DefaultMutableTreeNode) { final DefaultMutableTreeNode mutableNode = (DefaultMutableTreeNode)node; final Object userObject = mutableNode.getUserObject(); if (userObject instanceof Pair) { String actionId = (String)((Pair)userObject).first; final AnAction action = actionManager.getAction(actionId); Icon icon = (Icon)((Pair)userObject).second; action.getTemplatePresentation().setIcon(icon); action.setDefaultIcon(icon == null); editToolbarIcon(actionId,mutableNode); } } return true; } }); super.doOKAction(); CustomActionsSchema.setCustomizationSchemaForCurrentProjects(); }
/** * Create some actions * * @param horizontal is horizontal displayed * @return */ public static ActionToolbar createtoolbarWithActions(boolean horizontal,AnAction... actions) { DefaultActionGroup group = new DefaultActionGroup(); if (actions != null) { for (AnAction anAction : actions) { group.add(anAction); } } //group.addSeparator(); return ActionManager.getInstance().createActionToolbar("unkNown",horizontal);// horizontal }
public ActionToolbar createtoolbar() { DefaultActionGroup group = new DefaultActionGroup(); group.add(new ScrollToTheEndToolbaraction(this.getEditor())); group.add(new ClearLogAction(this)); group.add(new StartAction(this,getProject())); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("left",false); toolbar.setTargetComponent(this.getComponent()); return toolbar; }
private void send() { String msg = String.format("%s(Reviews: %s)",text.getText(),styledText.getText()); for (IMChatConsole console : consoles) { console.send(msg); } if (openGerritReviewCheckBox.isSelected()) { AnAction action = ActionManager.getInstance().getActionorStub(""); } }
@Nullable private PsiJavaFile createPackageInfoFile(PsiFile file,PsiPackage target) { DataManager.getInstance().getDataContextFromFocus().doWhenDone((Consumer<DataContext>) context -> { AnActionEvent event = new AnActionEvent(null,context,new Presentation(),0); new CreatePackageInfoAction().actionPerformed(event); }); return packageInfoFile(target,file.getContainingDirectory()); }
public static ActionToolbar createActionToolbar(Tree componentsTree) { DefaultActionGroup defaultActionGroup = new DefaultActionGroup(); defaultActionGroup.addAction(ActionManager.getInstance().getAction("Xray.Refresh")); defaultActionGroup.addAction(new CollapseAllAction(componentsTree)); defaultActionGroup.addAction(new ExpandAllAction(componentsTree)); return ActionManager.getInstance().createActionToolbar(ActionPlaces.CHANGES_VIEW_TOOLBAR,defaultActionGroup,true); }
/** * Constructor used when we get notified by IDEA through {@link com.intellij.openapi.actionSystem.ex.AnActionListener} * * @param action action that was performed * @param event event that fired the action * @param source the source of the action */ KeyPromoteraction(AnAction action,AnActionEvent event,ActionSource source) { myMnemonic = event.getPresentation().getMnemonic(); myIdeaActionID = ActionManager.getInstance().getId(action); myDescription = event.getPresentation().getText(); mySource = source; myShortcut = KeyPromoterUtils.getKeyboardShortcutsText(myIdeaActionID); }
/** * This method can be used at several places to update shortcut,description and ideaAction from an {@link AnAction} * * @param anAction action to extract values from */ private void fixValuesFromAction(AnAction anAction) { myDescription = anAction.getTemplatePresentation().getText(); myIdeaActionID = ActionManager.getInstance().getId(anAction); myShortcut = KeyPromoterUtils.getKeyboardShortcutsText(myIdeaActionID); }
@Override public Component getListCellRendererComponent(JList<? extends StatisticsItem> list,boolean cellHasFocus) { final Color foreground = list.getForeground(); final Color background = list.getBackground(); final String message = KeyPromoterBundle.message( "kp.list.suppressed.item",value.description ); if (isSelected) { setBackground(JBColor.GRAY); } else { setBackground(background); } setText(message); setForeground(foreground); setBorder(new EmptyBorder(2,10)); if (value.ideaActionID != null && !"".equals(value.ideaActionID)) { final AnAction action = ActionManager.getInstance().getAction(value.ideaActionID); if (action != null) { final Icon icon = action.getTemplatePresentation().getIcon(); if (icon != null) { setIcon(icon); } } } return this; }
private static void activatePlaceholder(TaskFile taskFile,AnswerPlaceholder placeholder,PsiFile file,Editor editor,Project project) { AnAction action = ActionManager.getInstance().getAction(CCActivatePlaceholder.ACTION_ID); if (action != null) { CCAnswerPlaceholderAction.CCState state = new CCAnswerPlaceholderAction.CCState(taskFile,placeholder,file,editor,project); ((CCActivatePlaceholder)action).performAnswerPlaceholderAction(state); } }
@NotNull @Override public DefaultActionGroup getTaskDescriptionActionGroup() { DefaultActionGroup taskDescriptionActionGroup = super.getTaskDescriptionActionGroup(); taskDescriptionActionGroup.remove(ActionManager.getInstance().getAction(StudyShowHintAction.ACTION_ID)); StudyFillPlaceholdersAction fillPlaceholdersAction = new StudyFillPlaceholdersAction(); fillPlaceholdersAction.getTemplatePresentation().setIcon(EduKotlinIcons.FILL_PLACEHOLDERS_ICON); fillPlaceholdersAction.getTemplatePresentation().setText("Fill Answer Placeholders"); taskDescriptionActionGroup.add(fillPlaceholdersAction); return taskDescriptionActionGroup; }
private void initToolWindow() { initTree(); JPanel panel = new SeedStackNavigatorPanel(myProject,tree); final ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(myProject); toolWindow = (ToolWindowEx) manager.registerToolWindow(TOOL_WINDOW_ID,ToolWindowAnchor.LEFT,myProject,true); toolWindow.setIcon(SeedStackIcons.logo); final ContentFactory contentFactory = ServiceManager.getService(ContentFactory.class); final Content content = contentFactory.createContent(panel,false); ContentManager contentManager = toolWindow.getContentManager(); contentManager.addContent(content); contentManager.setSelectedContent(content,false); final ToolWindowManagerAdapter listener = new ToolWindowManagerAdapter() { boolean wasVisible = false; @Override public void stateChanged() { if (toolWindow.isdisposed()) return; boolean visible = toolWindow.isVisible(); if (!visible) { return; } scheduleStructureUpdate(null); } }; manager.addToolWindowManagerListener(listener,myProject); ActionManager actionManager = ActionManager.getInstance(); DefaultActionGroup group = new DefaultActionGroup(); toolWindow.setAdditionalGearactions(group); }
SeedStackNavigatorPanel(Project project,SimpleTree tree) { super(true,true); this.project = project; this.tree = tree; final ActionManager actionManager = ActionManager.getInstance(); ActionToolbar actionToolbar = actionManager.createActionToolbar( "SeedStack Navigator Toolbar",(DefaultActionGroup) actionManager.getAction("SeedStack.NavigatorActionsToolbar"),true ); actionToolbar.setTargetComponent(tree); setToolbar(actionToolbar.getComponent()); setContent(ScrollPaneFactory.createScrollPane(tree)); }
public static void executeAction(String actionId,InputEvent e) { ActionManager actionManager = ActionManager.getInstance(); AnAction action = actionManager.getAction(actionId); if (action != null) { Presentation presentation = new Presentation(); AnActionEvent event = new AnActionEvent(e,DataManager.getInstance().getDataContext(e.getComponent()),presentation,actionManager,0); action.update(event); if (presentation.isEnabled()) { action.actionPerformed(event); } } }
private void setupAction() { try { ActionManager.getInstance().registeraction("GenerateValueClass",new GenerateValueClass()); } catch (Throwable e) { e.printstacktrace(); } }
public static ExportTestResultsAction create(String toolWindowId,runconfiguration runtimeConfiguration) { ExportTestResultsAction action = new ExportTestResultsAction(); action.copyFrom(ActionManager.getInstance().getAction(ID)); action.myToolWindowId = toolWindowId; action.myrunconfiguration = runtimeConfiguration; return action; }
public NavigateAction(@NotNull String text,@NotNull LineMarkerInfo<T> info,@Nullable String originalActionId) { super(text); myInfo = info; if (originalActionId != null) { ShortcutSet set = ActionManager.getInstance().getAction(originalActionId).getShortcutSet(); setShortcutSet(set); } }
protected void onTemplateFinished(TemplateManager manager,Template template) { // format and add ; final ActionManager actionManager = ActionManagerImpl.getInstance(); final String editorCompleteStatementText = "EditorCompleteStatement"; final AnAction action = actionManager.getAction(editorCompleteStatementText); actionManager.tryToExecute(action,ActionCommand.getInputEvent(editorCompleteStatementText),null,ActionPlaces.UNKNowN,true); }
@Override public void initComponent() { checkAndCreateRootDir(); ActionManager am = ActionManager.getInstance(); ArrayList<PackageTemplate> listPackageTemplate = PackageTemplateHelper.getListPackageTemplate(); for (PackageTemplate pt : listPackageTemplate) { if (!pt.isShouldRegisteraction()) { continue; } RunTemplateAction action = new RunTemplateAction(pt.getName(),pt); am.registeraction(Const.ACTION_PREFIX + action.getName(),action); } }
protected jpopupmenu createPopup(boolean toolWindow) { DefaultActionGroup group = new DefaultActionGroup(); DefaultActionGroup newGroup = new DefaultActionGroup("_New",true); final RepositorybrowserComponent browser = getRepositorybrowser(); newGroup.add(new AddLocationAction(browser)); newGroup.add(new MkDirAction(browser)); group.add(newGroup); group.addSeparator(); group.add(new RefreshAction(browser)); group.add(new discardLocationAction(browser)); ActionPopupMenu menu = ActionManager.getInstance().createActionPopupMenu("",group); return menu.getComponent(); }
public JComponent initContent() { mybrowser = new CommittedChangesTreebrowser(myProject,Collections.<Committedchangelist>emptyList()); mybrowser.getEmptyText().setText(VcsBundle.message("incoming.changes.not.loaded.message")); ActionGroup group = (ActionGroup) ActionManager.getInstance().getAction("IncomingChangesToolbar"); final ActionToolbar toolbar = mybrowser.createGroupFilterToolbar(myProject,Collections.<AnAction>emptyList()); mybrowser.setToolBar(toolbar.getComponent()); mybrowser.setTableContextMenu(group,Collections.<AnAction>emptyList()); myConnection = myBus.connect(); myConnection.subscribe(CommittedChangesCache.COMMITTED_TOPIC,new MyCommittedChangesListener()); loadChangesTobrowser(false,true); JPanel contentPane = new JPanel(new BorderLayout()); contentPane.add(mybrowser,BorderLayout.CENTER); return contentPane; }
public void addToolbaractions(final DialogWrapper dialogWrapper) { final ActionGroup group = (ActionGroup) ActionManager.getInstance().getAction("AlienCommitChangesDialog.AdditionalActions"); final AnAction[] children = group.getChildren(null); if (children != null) { for (AnAction anAction : children) { super.addToolbaraction(anAction); } } }
@Override public void invoke(@NotNull Project project,@NotNull PsiElement element) throws IncorrectOperationException { final PsiElement intentionElement = getIntentionElement(element); for (PsiReference psiReference : intentionElement.getReferences()) { if (psiReference instanceof CssModulesUnkNownClasspsiReference) { final String className = psiReference.getRangeInElement().substring(intentionElement.getText()); final StylesheetFile stylesheetFile = ((CssModulesUnkNownClasspsiReference) psiReference).getStylesheetFile(); stylesheetFile.navigate(true); PsiElement ruleset = CssElementFactory.getInstance(project).createRuleset("." + className + " {\n\n}",stylesheetFile.getLanguage()); ruleset = stylesheetFile.add(ruleset); final int newCaretoffset = ruleset.getTextOffset() + ruleset.getText().indexOf("{") + 2; // after '{\n' final FileEditor[] editors = FileEditorManager.getInstance(project).getEditors(stylesheetFile.getVirtualFile()); for (FileEditor fileEditor : editors) { if (fileEditor instanceof TextEditor) { final Editor cssEditor = ((TextEditor) fileEditor).getEditor(); cssEditor.getCaretModel().movetoOffset(newCaretoffset); AnAction editorLineEnd = ActionManager.getInstance().getAction("EditorLineEnd"); if (editorLineEnd != null) { final AnActionEvent actionEvent = AnActionEvent.createFromDataContext( ActionPlaces.UNKNowN,new DataManagerImpl.MyDataContext(cssEditor.getComponent()) ); PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(cssEditor.getDocument()); editorLineEnd.actionPerformed(actionEvent); } } } return; } } }
今天关于org.openide.util.actions.CallbackSystemAction的实例源码和源代码案例的介绍到此结束,谢谢您的阅读,有关com.intellij.openapi.actionSystem.ActionButtonComponent的实例源码、com.intellij.openapi.actionSystem.ActionGroupUtil的实例源码、com.intellij.openapi.actionSystem.ActionGroup的实例源码、com.intellij.openapi.actionSystem.ActionManager的实例源码等更多相关知识的信息可以在本站进行查询。
本文标签: