List of usage examples for com.intellij.openapi.actionSystem ActionToolbarPosition TOP
ActionToolbarPosition TOP
To view the source code for com.intellij.openapi.actionSystem ActionToolbarPosition TOP.
Click Source Link
From source file:com.google.cloud.tools.intellij.debugger.ui.CloudDebugHistoricalSnapshots.java
License:Apache License
/** * Sets up the the toolbar that appears in the cloud debugger snapshots panel. */// ww w.j a v a2s .c o m private void configureToolbar() { final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(table).disableUpDownActions() .disableAddAction().setToolbarPosition(ActionToolbarPosition.TOP); decorator.setRemoveAction(new RemoveSelectedBreakpointsAction()); decorator.addExtraAction(new RemoveAllBreakpointsAction()); decorator.addExtraAction(new ReactivateBreakpointAction()); this.add(decorator.createPanel()); }
From source file:com.google.gct.idea.debugger.ui.CloudDebugHistoricalSnapshots.java
License:Apache License
public CloudDebugHistoricalSnapshots(@NotNull CloudDebugProcessHandler processHandler) { super(new BorderLayout()); myTable = new JBTable() { // Returning the Class of each column will allow different // renderers to be used based on Class @Override//w ww.j a v a 2 s . co m public Class getColumnClass(int column) { if (column == 0) { return Icon.class; } Object value = getValueAt(0, column); return value != null ? getValueAt(0, column).getClass() : String.class; } // We override prepareRenderer to supply a tooltip in the case of an error. @NotNull @Override public Component prepareRenderer(@NotNull TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); if (c instanceof JComponent) { JComponent jc = (JComponent) c; Breakpoint breakpoint = CloudDebugHistoricalSnapshots.this.getModel().getBreakpoints().get(row); jc.setToolTipText(BreakpointUtil.getUserErrorMessage(breakpoint.getStatus())); } return c; } }; myTable.setModel(new MyModel(null)); myTable.setTableHeader(null); myTable.setShowGrid(false); myTable.setRowMargin(0); myTable.getColumnModel().setColumnMargin(0); myTable.getColumnModel().getColumn(1).setCellRenderer(new SnapshotTimeCellRenderer()); myTable.getColumnModel().getColumn(2).setCellRenderer(new DefaultRenderer()); myTable.getColumnModel().getColumn(3).setCellRenderer(new DefaultRenderer()); myTable.getColumnModel().getColumn(4).setCellRenderer(new MoreCellRenderer()); myTable.resetDefaultFocusTraversalKeys(); myTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); myTable.setPreferredScrollableViewportSize(new Dimension(WINDOW_WIDTH_PX, WINDOW_HEIGHT_PX)); myTable.setAutoCreateColumnsFromModel(false); myTable.getEmptyText().setText(GctBundle.getString("clouddebug.nosnapshots")); final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable).disableUpDownActions() .disableAddAction(); decorator.setToolbarPosition(ActionToolbarPosition.TOP); decorator.setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { fireDeleteBreakpoints(getSelectedBreakpoints()); } }); decorator.addExtraAction(new AnActionButton(GctBundle.getString("clouddebug.delete.all"), GoogleCloudToolsIcons.CLOUD_DEBUG_DELETE_ALL_BREAKPOINTS) { @Override public void actionPerformed(AnActionEvent e) { if (Messages.showDialog(GctBundle.getString("clouddebug.remove.all"), GctBundle.getString("clouddebug.delete.snapshots"), new String[] { GctBundle.getString("clouddebug.buttondelete"), GctBundle.getString("clouddebug.cancelbutton") }, 1, Messages.getQuestionIcon()) == 0) { MyModel model = (MyModel) myTable.getModel(); fireDeleteBreakpoints(model.getBreakpoints()); } } }); decorator.addExtraAction(new AnActionButton(GctBundle.getString("clouddebug.reactivatesnapshotlocation"), GoogleCloudToolsIcons.CLOUD_DEBUG_REACTIVATE_BREAKPOINT) { @Override public void actionPerformed(AnActionEvent e) { myProcess.getBreakpointHandler().cloneToNewBreakpoints(getSelectedBreakpoints()); } }); this.add(decorator.createPanel()); myProcess = processHandler.getProcess(); onBreakpointsChanged(); myProcess.getXDebugSession().addSessionListener(this); myProcess.addListener(this); // This is the click handler that does one of three things: // 1. Single click on a final snapshot will load the debugger with that snapshot // 2. Single click on a pending snapshot will show the line of code // 3. Single click on "More" will show the breakpoint config dialog. myTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent me) { JTable table = (JTable) me.getSource(); Point p = me.getPoint(); Breakpoint breakpoint = getBreakPoint(p); int col = table.columnAtPoint(p); if (breakpoint != null && col == 4 && supportsMoreConfig(breakpoint)) { BreakpointsDialogFactory.getInstance(myProcess.getXDebugSession().getProject()) .showDialog(myProcess.getBreakpointHandler().getXBreakpoint(breakpoint)); } else if (me.getClickCount() == 1 && breakpoint != null && myTable.getSelectedRows().length == 1) { myProcess.navigateToSnapshot(breakpoint.getId()); } } }); // we use a motion listener to create a hand cursor over a link within a table. myTable.addMouseMotionListener(new MouseMotionListener() { @Override public void mouseDragged(MouseEvent me) { } @Override public void mouseMoved(MouseEvent me) { JTable table = (JTable) me.getSource(); Point p = me.getPoint(); int column = table.columnAtPoint(p); Breakpoint breakpoint = getBreakPoint(p); if (column == 4 && breakpoint != null && supportsMoreConfig(breakpoint)) { if (myTable.getCursor() != HAND_CURSOR) { myTable.setCursor(HAND_CURSOR); } return; } if (myTable.getCursor() != DEFAULT_CURSOR) { myTable.setCursor(DEFAULT_CURSOR); } } }); }
From source file:com.intellij.ui.CommonActionsPanel.java
License:Apache License
CommonActionsPanel(ListenerFactory factory, @Nullable JComponent contextComponent,
ActionToolbarPosition position, @Nullable AnActionButton[] additionalActions,
@Nullable Comparator<AnActionButton> buttonComparator, String addName, String removeName,
String moveUpName, String moveDownName, String editName, Icon addIcon, Buttons... buttons) {
super(new BorderLayout());
final Listener listener = factory.createListener(this);
AnActionButton[] actions = new AnActionButton[buttons.length];
for (int i = 0; i < buttons.length; i++) {
Buttons button = buttons[i];/*from ww w . j av a 2 s .c om*/
String name = null;
switch (button) {
case ADD:
name = addName;
break;
case EDIT:
name = editName;
break;
case REMOVE:
name = removeName;
break;
case UP:
name = moveUpName;
break;
case DOWN:
name = moveDownName;
break;
}
final MyActionButton b = button.createButton(listener, name,
button == Buttons.ADD && addIcon != null ? addIcon : button.getIcon());
actions[i] = b;
myButtons.put(button, b);
}
if (additionalActions != null && additionalActions.length > 0) {
final ArrayList<AnActionButton> allActions = new ArrayList<AnActionButton>(Arrays.asList(actions));
allActions.addAll(Arrays.asList(additionalActions));
actions = allActions.toArray(new AnActionButton[allActions.size()]);
}
myActions = actions;
for (AnActionButton action : actions) {
action.setContextComponent(contextComponent);
}
if (buttonComparator != null) {
Arrays.sort(myActions, buttonComparator);
}
ArrayList<AnAction> toolbarActions = new ArrayList<AnAction>(Arrays.asList(myActions));
for (int i = 0; i < toolbarActions.size(); i++) {
if (toolbarActions.get(i) instanceof AnActionButton.CheckedAnActionButton) {
toolbarActions.set(i, ((AnActionButton.CheckedAnActionButton) toolbarActions.get(i)).getDelegate());
}
}
myDecorateButtons = UIUtil.isUnderAquaLookAndFeel() && position == ActionToolbarPosition.BOTTOM;
final ActionManagerEx mgr = (ActionManagerEx) ActionManager.getInstance();
final ActionToolbar toolbar = mgr.createActionToolbar(ActionPlaces.UNKNOWN,
new DefaultActionGroup(toolbarActions.toArray(new AnAction[toolbarActions.size()])),
position == ActionToolbarPosition.BOTTOM || position == ActionToolbarPosition.TOP,
myDecorateButtons);
toolbar.getComponent().setOpaque(false);
toolbar.getComponent().setBorder(null);
add(toolbar.getComponent(), BorderLayout.CENTER);
}
From source file:com.intellij.ui.ToolbarDecorator.java
License:Apache License
public ToolbarDecorator setAsUsualTopToolbar() { myAsUsualTopToolbar = true; setToolbarPosition(ActionToolbarPosition.TOP); return this; }
From source file:com.intellij.ui.ToolbarDecorator.java
License:Apache License
public ToolbarDecorator setToolbarPosition(ActionToolbarPosition position) { myToolbarPosition = position;/*from w ww. jav a2 s . c om*/ myActionsPanelBorder = new CustomLineBorder(myToolbarPosition == ActionToolbarPosition.BOTTOM ? 1 : 0, myToolbarPosition == ActionToolbarPosition.RIGHT ? 1 : 0, myToolbarPosition == ActionToolbarPosition.TOP ? 1 : 0, myToolbarPosition == ActionToolbarPosition.LEFT ? 1 : 0); return this; }
From source file:com.intellij.ui.TreeToolbarDecorator.java
License:Apache License
@Override public ToolbarDecorator initPosition() { return setToolbarPosition(SystemInfo.isMac ? ActionToolbarPosition.BOTTOM : ActionToolbarPosition.TOP); }
From source file:com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialog.java
License:Apache License
private JComponent createMasterView() { myTreeController = new BreakpointItemsTreeController(myRulesEnabled) { @Override/*from w w w. j a v a 2s . c o m*/ public void nodeStateWillChangeImpl(CheckedTreeNode node) { if (node instanceof BreakpointItemNode) { ((BreakpointItemNode) node).getBreakpointItem().saveState(); } super.nodeStateWillChangeImpl(node); } @Override public void nodeStateDidChangeImpl(CheckedTreeNode node) { super.nodeStateDidChangeImpl(node); if (node instanceof BreakpointItemNode) { myDetailController.doUpdateDetailView(true); } } @Override protected void selectionChangedImpl() { super.selectionChangedImpl(); saveCurrentItem(); myDetailController.updateDetailView(); } }; final JTree tree = new BreakpointsCheckboxTree(myProject, myTreeController) { @Override protected void onDoubleClick(CheckedTreeNode node) { navigate(false); } }; PopupHandler.installPopupHandler(tree, new ActionGroup() { @NotNull @Override public AnAction[] getChildren(@Nullable AnActionEvent e) { ActionGroup group = new ActionGroup("Move to group", true) { @NotNull @Override public AnAction[] getChildren(@Nullable AnActionEvent e) { Set<String> groups = getBreakpointManager().getAllGroups(); AnAction[] res = new AnAction[groups.size() + 3]; int i = 0; res[i++] = new MoveToGroupAction(null); for (String group : groups) { res[i++] = new MoveToGroupAction(group); } res[i++] = new AnSeparator(); res[i] = new MoveToGroupAction(); return res; } }; return new AnAction[] { group }; } }, ActionPlaces.UNKNOWN, ActionManager.getInstance()); new AnAction("BreakpointDialog.GoToSource") { @Override public void actionPerformed(AnActionEvent e) { navigate(true); close(OK_EXIT_CODE); } }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)), tree); new AnAction("BreakpointDialog.ShowSource") { @Override public void actionPerformed(AnActionEvent e) { navigate(true); close(OK_EXIT_CODE); } }.registerCustomShortcutSet( ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE).getShortcutSet(), tree); final DefaultActionGroup breakpointTypes = new DefaultActionGroup(); for (XBreakpointType<?, ?> type : XBreakpointUtil.getBreakpointTypes()) { if (type.isAddBreakpointButtonVisible()) { breakpointTypes.addAll(new AddXBreakpointAction(type)); } } ToolbarDecorator decorator = ToolbarDecorator.createDecorator(tree) .setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { JBPopupFactory.getInstance() .createActionGroupPopup(null, breakpointTypes, DataManager.getInstance().getDataContext(button.getContextComponent()), JBPopupFactory.ActionSelectionAid.NUMBERING, false) .show(button.getPreferredPopupPoint()); } }).setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { myTreeController.removeSelectedBreakpoints(myProject); } }).setRemoveActionUpdater(new AnActionButtonUpdater() { @Override public boolean isEnabled(AnActionEvent e) { boolean enabled = false; final ItemWrapper[] items = myMasterController.getSelectedItems(); for (ItemWrapper item : items) { if (item.allowedToRemove()) { enabled = true; } } return enabled; } }).setToolbarPosition(ActionToolbarPosition.TOP) .setToolbarBorder(IdeBorderFactory.createEmptyBorder()); tree.setBorder(IdeBorderFactory.createBorder()); for (ToggleActionButton action : myToggleRuleActions) { decorator.addExtraAction(action); } JPanel decoratedTree = decorator.createPanel(); decoratedTree.setBorder(IdeBorderFactory.createEmptyBorder()); myTreeController.setTreeView(tree); myTreeController.buildTree(myBreakpointItems); initSelection(myBreakpointItems); final BreakpointPanelProvider.BreakpointsListener listener = new BreakpointPanelProvider.BreakpointsListener() { @Override public void breakpointsChanged() { collectItems(); myTreeController.rebuildTree(myBreakpointItems); myDetailController.doUpdateDetailView(true); } }; for (BreakpointPanelProvider provider : myBreakpointsPanelProviders) { provider.addListener(listener, myProject, myListenerDisposable); } return decoratedTree; }
From source file:org.intellij.xquery.runner.ui.datasources.DataSourceListPanel.java
License:Apache License
private ToolbarDecorator prepareDataSourcesTableToolbarDecorator(final JBList dataSourceList) { return ToolbarDecorator.createDecorator(dataSourceList).setAddAction(new AnActionButtonRunnable() { @Override//ww w. j a v a2s .c om public void run(AnActionButton button) { showAddDataSourcePopupWithActionExecutor(getAddDataSourceActionExecutor()); } }).setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { dataSourceDetailsPanel.stopDisplayingDetails(); ListUtil.removeSelectedItems(dataSourceList); dataSourceList.repaint(); } }).disableUpDownActions().setToolbarPosition(ActionToolbarPosition.TOP); }