use of com.intellij.ui.AnActionButton in project azure-tools-for-java by Microsoft.
the class LibrariesConfigurationDialog method createUIComponents.
private void createUIComponents() {
librariesList = new JBList(currentLibs);
tempList = new ArrayList(currentLibs);
librariesPanel = ToolbarDecorator.createDecorator(librariesList).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
addLibrary();
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
removeLibrary();
}
}).setEditAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
editLibrary();
}
}).disableUpDownActions().createPanel();
}
use of com.intellij.ui.AnActionButton in project azure-tools-for-java by Microsoft.
the class SubscriptionsDialog method createUIComponents.
private void createUIComponents() {
DefaultTableModel model = new SubscriptionTableModel();
model.addColumn("");
model.addColumn("Subscription name");
model.addColumn("Subscription ID");
table = new JBTable();
table.setModel(model);
TableColumn column = table.getColumnModel().getColumn(0);
column.setMinWidth(23);
column.setMaxWidth(23);
table.setRowSelectionAllowed(false);
table.setCellSelectionEnabled(false);
AnActionButton refreshAction = new AnActionButton("Refresh", AllIcons.Actions.Refresh) {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
AppInsightsClient.createByType(AppInsightsClient.EventType.Subscription, "", "Refresh", null);
refreshSubscriptions();
}
};
ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(table).disableUpDownActions().addExtraActions(refreshAction);
panelTable = tableToolbarDecorator.createPanel();
}
use of com.intellij.ui.AnActionButton in project intellij-community by JetBrains.
the class LibraryRootsComponent method init.
private void init(AbstractTreeStructure treeStructure) {
myTree = new Tree(new DefaultTreeModel(new DefaultMutableTreeNode()));
myTree.setRootVisible(false);
myTree.setShowsRootHandles(true);
new LibraryRootsTreeSpeedSearch(myTree);
myTree.setCellRenderer(new LibraryTreeRenderer());
myTreeBuilder = new LibraryTableTreeBuilder(myTree, (DefaultTreeModel) myTree.getModel(), treeStructure);
myTreePanel.setLayout(new BorderLayout());
ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(myTree).disableUpDownActions().setRemoveActionName(ProjectBundle.message("library.remove.action")).disableRemoveAction();
toolbarDecorator.setPanelBorder(new CustomLineBorder(1, 0, 0, 0));
final List<AttachRootButtonDescriptor> popupItems = new ArrayList<>();
for (AttachRootButtonDescriptor descriptor : myDescriptor.createAttachButtons()) {
Icon icon = descriptor.getToolbarIcon();
if (icon != null) {
AttachItemAction action = new AttachItemAction(descriptor, descriptor.getButtonText(), icon);
toolbarDecorator.addExtraAction(AnActionButton.fromAction(action));
} else {
popupItems.add(descriptor);
}
}
myAddExcludedRootActionButton = new AddExcludedRootActionButton();
toolbarDecorator.addExtraAction(myAddExcludedRootActionButton);
toolbarDecorator.addExtraAction(new AnActionButton("Remove", IconUtil.getRemoveIcon()) {
@Override
public void actionPerformed(AnActionEvent e) {
final Object[] selectedElements = getSelectedElements();
if (selectedElements.length == 0) {
return;
}
ApplicationManager.getApplication().runWriteAction(() -> {
for (Object selectedElement : selectedElements) {
if (selectedElement instanceof ItemElement) {
final ItemElement itemElement = (ItemElement) selectedElement;
getLibraryEditor().removeRoot(itemElement.getUrl(), itemElement.getRootType());
} else if (selectedElement instanceof OrderRootTypeElement) {
final OrderRootType rootType = ((OrderRootTypeElement) selectedElement).getOrderRootType();
final String[] urls = getLibraryEditor().getUrls(rootType);
for (String url : urls) {
getLibraryEditor().removeRoot(url, rootType);
}
} else if (selectedElement instanceof ExcludedRootElement) {
getLibraryEditor().removeExcludedRoot(((ExcludedRootElement) selectedElement).getUrl());
}
}
});
libraryChanged(true);
}
@Override
public void updateButton(AnActionEvent e) {
super.updateButton(e);
Object[] elements = getSelectedElements();
Presentation presentation = e.getPresentation();
if (ContainerUtil.and(elements, new FilteringIterator.InstanceOf<>(ExcludedRootElement.class))) {
presentation.setText("Cancel Exclusion");
} else {
presentation.setText(getTemplatePresentation().getText());
}
}
@Override
public ShortcutSet getShortcut() {
return CommonShortcuts.getDelete();
}
});
toolbarDecorator.setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
if (popupItems.isEmpty()) {
new AttachFilesAction(myDescriptor.getAttachFilesActionName()).actionPerformed(null);
return;
}
List<AnAction> actions = new ArrayList<>();
actions.add(new AttachFilesAction(myDescriptor.getAttachFilesActionName()));
for (AttachRootButtonDescriptor descriptor : popupItems) {
actions.add(new AttachItemAction(descriptor, descriptor.getButtonText(), null));
}
final DefaultActionGroup group = new DefaultActionGroup(actions);
JBPopupFactory.getInstance().createActionGroupPopup(null, group, DataManager.getInstance().getDataContext(button.getContextComponent()), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true).show(button.getPreferredPopupPoint());
}
});
myTreePanel.add(toolbarDecorator.createPanel(), BorderLayout.CENTER);
Disposer.register(this, myTreeBuilder);
}
use of com.intellij.ui.AnActionButton in project intellij-community by JetBrains.
the class JsonSchemaMappingsView method createUI.
private void createUI(final Project project) {
myProject = project;
myTableView = new TableView<>();
myTableView.getTableHeader().setVisible(false);
myDecorator = ToolbarDecorator.createDecorator(myTableView);
myDecorator.setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
final int[] rows = myTableView.getSelectedRows();
if (rows != null && rows.length > 0) {
int cnt = 0;
for (int row : rows) {
myTableView.getListTableModel().removeRow(row - cnt);
++cnt;
}
myTableView.getListTableModel().fireTableDataChanged();
myTreeUpdater.run();
}
}
}).setAddAction(new MyAddActionButtonRunnable(project)).disableUpDownActions();
mySchemaField = new TextFieldWithBrowseButton();
SwingHelper.installFileCompletionAndBrowseDialog(myProject, mySchemaField, JsonBundle.message("json.schema.add.schema.chooser.title"), FileChooserDescriptorFactory.createSingleFileDescriptor());
attachNavigateToSchema();
myError = SwingHelper.createHtmlLabel("Warning: conflicting mappings. <a href=\"#\">Show details</a>", null, s -> {
final BalloonBuilder builder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(myErrorText, UIUtil.getBalloonWarningIcon(), MessageType.WARNING.getPopupBackground(), null);
builder.setDisposable(this);
builder.setHideOnClickOutside(true);
builder.setCloseButtonEnabled(true);
builder.createBalloon().showInCenterOf(myError);
});
final FormBuilder builder = FormBuilder.createFormBuilder();
final JBLabel label = new JBLabel("JSON schema file:");
builder.addLabeledComponent(label, mySchemaField);
label.setBorder(JBUI.Borders.empty(0, 10, 0, 10));
mySchemaField.setBorder(JBUI.Borders.empty(0, 0, 0, 10));
final JPanel wrapper = new JPanel(new BorderLayout());
wrapper.setBorder(JBUI.Borders.empty(0, 10, 0, 10));
myErrorIcon = new JBLabel(UIUtil.getBalloonWarningIcon());
wrapper.add(myErrorIcon, BorderLayout.WEST);
wrapper.add(myError, BorderLayout.CENTER);
builder.addComponent(wrapper);
builder.addComponentFillVertically(myDecorator.createPanel(), 5);
myComponent = builder.getPanel();
}
use of com.intellij.ui.AnActionButton in project intellij-community by JetBrains.
the class EnvVariablesTable method createExtraActions.
@NotNull
@Override
protected AnActionButton[] createExtraActions() {
AnActionButton copyButton = new AnActionButton(ActionsBundle.message("action.EditorCopy.text"), AllIcons.Actions.Copy) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
stopEditing();
StringBuilder sb = new StringBuilder();
List<EnvironmentVariable> variables = getSelection();
for (EnvironmentVariable environmentVariable : variables) {
if (environmentVariable.getIsPredefined() || isEmpty(environmentVariable))
continue;
if (sb.length() > 0)
sb.append('\n');
sb.append(StringUtil.escapeChar(environmentVariable.getName(), '=')).append('=').append(StringUtil.escapeChar(environmentVariable.getValue(), '='));
}
CopyPasteManager.getInstance().setContents(new StringSelection(sb.toString()));
}
@Override
public boolean isEnabled() {
return super.isEnabled() && !getSelection().isEmpty();
}
};
AnActionButton pasteButton = new AnActionButton(ActionsBundle.message("action.EditorPaste.text"), AllIcons.Actions.Menu_paste) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
removeSelected();
stopEditing();
String content = CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
if (content == null || !content.contains("="))
return;
List<EnvironmentVariable> parsed = new ArrayList<>();
List<String> lines = StringUtil.split(content, "\n");
for (String line : lines) {
int pos = line.indexOf('=');
if (pos == -1)
continue;
while (pos > 0 && line.charAt(pos - 1) == '\\') {
pos = line.indexOf('=', pos + 1);
}
line = line.replaceAll("[\\\\]{1}", "\\\\\\\\");
parsed.add(new EnvironmentVariable(StringUtil.unescapeStringCharacters(line.substring(0, pos)), StringUtil.unescapeStringCharacters(line.substring(pos + 1)), false));
}
List<EnvironmentVariable> variables = new ArrayList<>(getEnvironmentVariables());
variables.addAll(parsed);
setValues(variables);
}
};
return new AnActionButton[] { copyButton, pasteButton };
}
Aggregations