List of usage examples for com.intellij.openapi.actionSystem ActionToolbarPosition BOTTOM
ActionToolbarPosition BOTTOM
To view the source code for com.intellij.openapi.actionSystem ActionToolbarPosition BOTTOM.
Click Source Link
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 w w w. j a v a2 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 initPosition() { setToolbarPosition(SystemInfo.isMac ? ActionToolbarPosition.BOTTOM : ActionToolbarPosition.RIGHT); return this; }
From source file:com.intellij.ui.ToolbarDecorator.java
License:Apache License
public ToolbarDecorator setToolbarPosition(ActionToolbarPosition position) { myToolbarPosition = position;/* www . j ava 2 s.co m*/ 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.uiDesigner.clientProperties.ConfigureClientPropertiesDialog.java
License:Apache License
@Nullable protected JComponent createCenterPanel() { myClassTree = new Tree(); myClassTree.setRootVisible(false);/* www . j a v a 2 s . co m*/ myClassTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { final TreePath leadSelectionPath = e.getNewLeadSelectionPath(); if (leadSelectionPath == null) return; final DefaultMutableTreeNode node = (DefaultMutableTreeNode) leadSelectionPath .getLastPathComponent(); mySelectedClass = (Class) node.getUserObject(); updateSelectedProperties(); } }); myClassTree.setCellRenderer(new ColoredTreeCellRenderer() { public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; if (node.getUserObject() instanceof Class) { Class cls = (Class) node.getUserObject(); if (cls != null) { append(cls.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES); } } } }); fillClassTree(); myPropertiesTable = new JBTable(); myPropertiesTable.setModel(myTableModel); mySplitter = new Splitter(false, Float.valueOf(myPropertiesComponent.getValue(SPLITTER_PROPORTION_PROPERTY, "0.5f"))); mySplitter.setFirstComponent( ToolbarDecorator.createDecorator(myClassTree).setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { ClassNameInputDialog dlg = new ClassNameInputDialog(myProject, mySplitter); dlg.show(); if (dlg.getExitCode() == OK_EXIT_CODE) { String className = dlg.getClassName(); if (className.length() == 0) return; final Class aClass; try { aClass = Class.forName(className); } catch (ClassNotFoundException ex) { Messages.showErrorDialog(mySplitter, UIDesignerBundle.message("client.properties.class.not.found", className), UIDesignerBundle.message("client.properties.title")); return; } if (!JComponent.class.isAssignableFrom(aClass)) { Messages.showErrorDialog( mySplitter, UIDesignerBundle .message("client.properties.class.not.component", className), UIDesignerBundle.message("client.properties.title")); return; } myManager.addClientPropertyClass(className); fillClassTree(); } } }).setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { if (mySelectedClass != null) { myManager.removeClientPropertyClass(mySelectedClass); fillClassTree(); } } }).setToolbarPosition(SystemInfo.isMac ? ActionToolbarPosition.BOTTOM : ActionToolbarPosition.RIGHT) .createPanel()); mySplitter.setSecondComponent(ToolbarDecorator.createDecorator(myPropertiesTable).disableUpDownActions() .setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { AddClientPropertyDialog dlg = new AddClientPropertyDialog(myProject); dlg.show(); if (dlg.getExitCode() == OK_EXIT_CODE) { ClientPropertiesManager.ClientProperty[] props = myManager .getClientProperties(mySelectedClass); for (ClientPropertiesManager.ClientProperty prop : props) { if (prop.getName().equalsIgnoreCase(dlg.getEnteredProperty().getName())) { Messages.showErrorDialog(mySplitter, UIDesignerBundle.message("client.properties.already.defined", prop.getName()), UIDesignerBundle.message("client.properties.title")); return; } } myManager.addConfiguredProperty(mySelectedClass, dlg.getEnteredProperty()); updateSelectedProperties(); } } }).setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { int row = myPropertiesTable.getSelectedRow(); if (row >= 0 && row < mySelectedProperties.length) { myManager.removeConfiguredProperty(mySelectedClass, mySelectedProperties[row].getName()); updateSelectedProperties(); if (mySelectedProperties.length > 0) { if (row >= mySelectedProperties.length) row--; myPropertiesTable.getSelectionModel().setSelectionInterval(row, row); } } } }).createPanel()); return mySplitter; }
From source file:org.jetbrains.idea.svn.dialogs.BranchConfigurationDialog.java
License:Apache License
public BranchConfigurationDialog(@NotNull final Project project, @NotNull final SvnBranchConfigurationNew configuration, final @NotNull SVNURL rootUrl, @NotNull final VirtualFile root, @NotNull String url) { super(project, true); myRoot = root;//from www .j a v a 2s .c om init(); setTitle(SvnBundle.message("configure.branches.title")); final String trunkUrl = configuration.getTrunkUrl(); if (trunkUrl == null || trunkUrl.trim().length() == 0) { configuration.setTrunkUrl(url); } mySvnBranchConfigManager = SvnBranchConfigurationManager.getInstance(project).getSvnBranchConfigManager(); myTrunkLocationTextField.setText(configuration.getTrunkUrl()); myTrunkLocationTextField.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { final String selectedUrl = SelectLocationDialog.selectLocation(project, myTrunkLocationTextField.getText()); if (selectedUrl != null) { myTrunkLocationTextField.setText(selectedUrl); } } }); final TrunkUrlValidator trunkUrlValidator = new TrunkUrlValidator(rootUrl, configuration); myTrunkLocationTextField.getTextField().getDocument().addDocumentListener(trunkUrlValidator); trunkUrlValidator.textChanged(null); myErrorPrompt.setUI(new MultiLineLabelUI()); myErrorPrompt.setForeground(SimpleTextAttributes.ERROR_ATTRIBUTES.getFgColor()); final MyListModel listModel = new MyListModel(configuration); myLocationList = new JBList(listModel); myListPanel.add(ToolbarDecorator.createDecorator(myLocationList).setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { final String selectedUrl = SelectLocationDialog.selectLocation(project, rootUrl.toDecodedString()); if (selectedUrl != null) { if (!configuration.getBranchUrls().contains(selectedUrl)) { configuration.addBranches(selectedUrl, new InfoStorage<List<SvnBranchItem>>( new ArrayList<SvnBranchItem>(), InfoReliability.empty)); mySvnBranchConfigManager.reloadBranches(myRoot, selectedUrl, null); listModel.fireItemAdded(); myLocationList.setSelectedIndex(listModel.getSize() - 1); } } } }).setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { int selIndex = myLocationList.getSelectedIndex(); Object[] selection = myLocationList.getSelectedValues(); for (Object urlObj : selection) { String url = (String) urlObj; int index = configuration.getBranchUrls().indexOf(url); configuration.removeBranch(url); listModel.fireItemRemoved(index); } if (listModel.getSize() > 0) { if (selIndex >= listModel.getSize()) selIndex = listModel.getSize() - 1; myLocationList.setSelectedIndex(selIndex); } } }).disableUpDownActions().setToolbarPosition(ActionToolbarPosition.BOTTOM).createPanel(), BorderLayout.CENTER); }