use of com.intellij.ui.ToolbarDecorator in project intellij-community by JetBrains.
the class CertificateConfigurable method initializeUI.
private void initializeUI() {
myTree = new Tree();
myTreeBuilder = new CertificateTreeBuilder(myTree);
myTrustManager = CertificateManager.getInstance().getCustomTrustManager();
// show newly added certificates
myTrustManager.addListener(this);
myTree.getEmptyText().setText("No certificates");
myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
myTree.setRootVisible(false);
//myTree.setShowsRootHandles(false);
ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTree).disableUpDownActions();
decorator.setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
// show choose file dialog, add certificate
FileChooser.chooseFile(CERTIFICATE_DESCRIPTOR, null, null, file -> {
String path = file.getPath();
X509Certificate certificate = CertificateUtil.loadX509Certificate(path);
if (certificate == null) {
Messages.showErrorDialog(myRootPanel, "Malformed X509 server certificate", "Not Imported");
} else if (myCertificates.contains(certificate)) {
Messages.showWarningDialog(myRootPanel, "Certificate already exists", "Not Imported");
} else {
myCertificates.add(certificate);
myTreeBuilder.addCertificate(certificate);
addCertificatePanel(certificate);
myTreeBuilder.selectCertificate(certificate);
}
});
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
// allow to delete several certificates at once
for (X509Certificate certificate : myTreeBuilder.getSelectedCertificates(true)) {
myCertificates.remove(certificate);
myTreeBuilder.removeCertificate(certificate);
}
if (myCertificates.isEmpty()) {
showCard(EMPTY_PANEL);
} else {
myTreeBuilder.selectFirstCertificate();
}
}
});
myTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
X509Certificate certificate = myTreeBuilder.getFirstSelectedCertificate(true);
if (certificate != null) {
showCard(getCardName(certificate));
}
}
});
myCertificatesListPanel.add(decorator.createPanel(), BorderLayout.CENTER);
}
use of com.intellij.ui.ToolbarDecorator in project intellij-community by JetBrains.
the class EditVariableDialog method createVariablesTable.
private JComponent createVariablesTable() {
final String[] names = { CodeInsightBundle.message("templates.dialog.edit.variables.table.column.name"), CodeInsightBundle.message("templates.dialog.edit.variables.table.column.expression"), CodeInsightBundle.message("templates.dialog.edit.variables.table.column.default.value"), CodeInsightBundle.message("templates.dialog.edit.variables.table.column.skip.if.defined") };
// Create a model of the data.
TableModel dataModel = new VariablesModel(names);
// Create the table
myTable = new JBTable(dataModel);
myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myTable.setPreferredScrollableViewportSize(new Dimension(500, myTable.getRowHeight() * 8));
myTable.getColumn(names[0]).setPreferredWidth(120);
myTable.getColumn(names[1]).setPreferredWidth(200);
myTable.getColumn(names[2]).setPreferredWidth(200);
myTable.getColumn(names[3]).setPreferredWidth(100);
if (myVariables.size() > 0) {
myTable.getSelectionModel().setSelectionInterval(0, 0);
}
Predicate<Macro> isAcceptableInContext = macro -> myContextTypes.stream().anyMatch(macro::isAcceptableInContext);
Stream<String> availableMacroNames = Arrays.stream(MacroFactory.getMacros()).filter(isAcceptableInContext).map(Macro::getPresentableName).sorted();
Set<String> uniqueNames = availableMacroNames.collect(Collectors.toCollection(LinkedHashSet::new));
ComboBox comboField = new ComboBox();
uniqueNames.forEach(comboField::addItem);
comboField.setEditable(true);
DefaultCellEditor cellEditor = new DefaultCellEditor(comboField);
cellEditor.setClickCountToStart(1);
myTable.getColumn(names[1]).setCellEditor(cellEditor);
myTable.setRowHeight(comboField.getPreferredSize().height);
JTextField textField = new JTextField();
/*textField.addMouseListener(
new PopupHandler(){
public void invokePopup(Component comp,int x,int y){
showCellPopup((JTextField)comp,x,y);
}
}
);*/
cellEditor = new DefaultCellEditor(textField);
cellEditor.setClickCountToStart(1);
myTable.setDefaultEditor(String.class, cellEditor);
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable).disableAddAction().disableRemoveAction();
return decorator.createPanel();
}
use of com.intellij.ui.ToolbarDecorator 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.ToolbarDecorator 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.ToolbarDecorator in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudDebugHistoricalSnapshots method configureToolbar.
/**
* Sets up the the toolbar that appears in the cloud debugger snapshots panel.
*/
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());
}
Aggregations