use of com.intellij.ui.ToolbarDecorator in project google-cloud-intellij by GoogleCloudPlatform.
the class BreakpointConfigurationPanel method loadFrom.
@Override
public void loadFrom(@NotNull XLineBreakpoint<CloudLineBreakpointProperties> breakpoint) {
XBreakpointBase lineBreakpointImpl = breakpoint instanceof XBreakpointBase ? (XBreakpointBase) breakpoint : null;
Breakpoint javaBreakpoint = BreakpointManager.getJavaBreakpoint(breakpoint);
CloudLineBreakpointType.CloudLineBreakpoint cloudBreakpoint = null;
if (javaBreakpoint instanceof CloudLineBreakpointType.CloudLineBreakpoint) {
cloudBreakpoint = (CloudLineBreakpointType.CloudLineBreakpoint) javaBreakpoint;
}
if (cloudBreakpoint == null || lineBreakpointImpl == null) {
return;
}
XDebuggerEditorsProvider debuggerEditorsProvider = cloudLineBreakpointType.getEditorsProvider(breakpoint, cloudBreakpoint.getProject());
if (debuggerEditorsProvider != null) {
treePanel = new XDebuggerTreePanel(cloudBreakpoint.getProject(), debuggerEditorsProvider, this, breakpoint.getSourcePosition(), "GoogleCloudTools.BreakpointWatchContextMenu", null);
List<XExpression> watches = new ArrayList<XExpression>();
for (String watchExpression : breakpoint.getProperties().getWatchExpressions()) {
watches.add(debuggerEditorsProvider.createExpression(((XBreakpointBase) breakpoint).getProject(), new DocumentImpl(watchExpression), getFileTypeLanguage(breakpoint), EvaluationMode.EXPRESSION));
}
rootNode = new WatchesRootNode(treePanel.getTree(), this, watches.toArray(new XExpression[watches.size()]));
treePanel.getTree().setRoot(rootNode, false);
watchPanel.removeAll();
watchPanel.add(watchLabel, BorderLayout.NORTH);
treePanel.getTree().getEmptyText().setText("There are no custom watches for this snapshot location.");
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(treePanel.getTree()).disableUpDownActions();
decorator.setToolbarPosition(ActionToolbarPosition.RIGHT);
decorator.setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
executeAction(XDebuggerActions.XNEW_WATCH);
}
});
decorator.setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
executeAction(XDebuggerActions.XREMOVE_WATCH);
}
});
CustomLineBorder border = new CustomLineBorder(CaptionPanel.CNT_ACTIVE_BORDER_COLOR, SystemInfo.isMac ? 1 : 0, 0, SystemInfo.isMac ? 0 : 1, 0);
decorator.setToolbarBorder(border);
watchPanel.add(decorator.createPanel(), BorderLayout.CENTER);
}
}
use of com.intellij.ui.ToolbarDecorator in project azure-tools-for-java by Microsoft.
the class AppSettingsTableUtils method createAppSettingPanel.
public static JPanel createAppSettingPanel(AppSettingsTable appSettingsTable) {
final JPanel result = new JPanel();
// create the parent panel which contains app settings table and prompt panel
result.setLayout(new GridLayoutManager(2, 1));
final JTextPane promptPanel = new JTextPane();
final GridConstraints paneConstraint = new GridConstraints(1, 0, 1, 1, 0, GridConstraints.FILL_BOTH, 7, 7, null, null, null);
promptPanel.setFocusable(false);
result.add(promptPanel, paneConstraint);
final AnActionButton btnAdd = new AnActionButton(message("common.add"), AllIcons.General.Add) {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
final String key = DefaultLoader.getUIHelper().showInputDialog(appSettingsTable, message("function.appSettings.add.key.message"), message("function.appSettings.add.key.title"), null);
if (StringUtils.isEmpty(key)) {
return;
}
final String value = DefaultLoader.getUIHelper().showInputDialog(appSettingsTable, message("function.appSettings.add.value.message"), message("function.appSettings.add.value.title"), null);
appSettingsTable.addAppSettings(key, value);
appSettingsTable.repaint();
}
};
final AnActionButton btnRemove = new AnActionButton(message("common.remove"), AllIcons.General.Remove) {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
try {
appSettingsTable.removeAppSettings(appSettingsTable.getSelectedRow());
appSettingsTable.repaint();
} catch (IllegalArgumentException iae) {
PluginUtil.displayErrorDialog(message("function.appSettings.remove.error.title"), iae.getMessage());
}
}
};
final AnActionButton importButton = new AnActionButton(message("common.import"), AllIcons.ToolbarDecorator.Import) {
@Override
@AzureOperation(name = "function.import_app_settings", type = AzureOperation.Type.TASK)
public void actionPerformed(AnActionEvent anActionEvent) {
final ImportAppSettingsDialog importAppSettingsDialog = new ImportAppSettingsDialog(appSettingsTable.getLocalSettingsPath());
importAppSettingsDialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent windowEvent) {
super.windowClosed(windowEvent);
final Map<String, String> appSettings = importAppSettingsDialog.getAppSettings();
if (importAppSettingsDialog.shouldErase()) {
appSettingsTable.clear();
}
if (appSettings != null) {
appSettingsTable.addAppSettings(appSettings);
}
}
});
importAppSettingsDialog.setLocationRelativeTo(appSettingsTable);
importAppSettingsDialog.pack();
importAppSettingsDialog.setVisible(true);
}
};
final AnActionButton exportButton = new AnActionButton(message("function.appSettings.export.title"), AllIcons.ToolbarDecorator.Export) {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
try {
final File file = DefaultLoader.getUIHelper().showFileSaver(message("function.appSettings.export.description"), LOCAL_SETTINGS_JSON);
if (file != null) {
AppSettingsTableUtils.exportLocalSettingsJsonFile(file, appSettingsTable.getAppSettings());
PluginUtil.displayInfoDialog(message("function.appSettings.export.succeed.title"), message("function.appSettings.export.succeed.message"));
}
} catch (IOException e) {
final String title = message("function.appSettings.export.error.title");
final String message = message("function.appSettings.export.error.failedToSave", e.getMessage());
PluginUtil.displayErrorDialog(title, message);
}
}
};
appSettingsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent listSelectionEvent) {
final String prompt = AzureFunctionsConstants.getAppSettingHint(appSettingsTable.getSelectedKey());
promptPanel.setText(prompt);
}
});
appSettingsTable.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent focusEvent) {
final String prompt = AzureFunctionsConstants.getAppSettingHint(appSettingsTable.getSelectedKey());
promptPanel.setText(prompt);
}
@Override
public void focusLost(FocusEvent focusEvent) {
promptPanel.setText("");
}
});
final ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(appSettingsTable).addExtraActions(btnAdd, btnRemove, importButton, exportButton).setToolbarPosition(ActionToolbarPosition.RIGHT);
final JPanel tablePanel = tableToolbarDecorator.createPanel();
final GridConstraints tableConstraint = new GridConstraints(0, 0, 1, 1, 0, GridConstraints.FILL_BOTH, 7, 7, null, null, null);
result.add(tablePanel, tableConstraint);
result.setMinimumSize(new Dimension(-1, 100));
return result;
}
use of com.intellij.ui.ToolbarDecorator in project azure-tools-for-java by Microsoft.
the class SubscriptionsDialog method createUIComponents.
private void createUIComponents() {
contentPane = new JPanel();
contentPane.setPreferredSize(new Dimension(350, 200));
DefaultTableModel model = new SubscriptionTableModel();
// Set the text read by JAWS
model.addColumn("Selected");
model.addColumn("Subscription name");
model.addColumn("Subscription ID");
table = new JBTable();
table.setModel(model);
TableColumn column = table.getColumnModel().getColumn(CHECKBOX_COLUMN);
// Don't show title text
column.setHeaderValue("");
column.setMinWidth(23);
column.setMaxWidth(23);
JTableUtils.enableBatchSelection(table, CHECKBOX_COLUMN);
table.getTableHeader().setReorderingAllowed(false);
new TableSpeedSearch(table);
AnActionButton refreshAction = new AnActionButton("Refresh", AllIcons.Actions.Refresh) {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
this.setEnabled(false);
model.setRowCount(0);
model.fireTableDataChanged();
table.getEmptyText().setText("Refreshing");
AppInsightsClient.createByType(AppInsightsClient.EventType.Subscription, "", "Refresh", null);
final AzureString title = AzureOperationBundle.title("account|subscription.refresh");
final AzureTask task = new AzureTask(project, title, true, () -> {
try {
SubscriptionsDialog.this.refreshSubscriptions();
} finally {
this.setEnabled(true);
}
}, AzureTask.Modality.ANY);
AzureTaskManager.getInstance().runInBackground(task);
}
};
refreshAction.registerCustomShortcutSet(KeyEvent.VK_R, InputEvent.ALT_DOWN_MASK, contentPane);
ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(table).disableUpDownActions().addExtraActions(refreshAction);
panelTable = tableToolbarDecorator.createPanel();
}
use of com.intellij.ui.ToolbarDecorator in project azure-tools-for-java by Microsoft.
the class WebAppBasePropertyView method createUIComponents.
private void createUIComponents() {
tableModel = new DefaultTableModel();
tableModel.addColumn(TABLE_HEADER_KEY);
tableModel.addColumn(TABLE_HEADER_VALUE);
tblAppSetting = new JBTable(tableModel);
tblAppSetting.setRowSelectionAllowed(true);
tblAppSetting.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
tblAppSetting.getEmptyText().setText(TABLE_LOADING_MESSAGE);
tblAppSetting.addPropertyChangeListener(evt -> {
if ("tableCellEditor".equals(evt.getPropertyName())) {
if (!tblAppSetting.isEditing()) {
editedAppSettings.clear();
int row = 0;
while (row < tableModel.getRowCount()) {
Object keyObj = tableModel.getValueAt(row, 0);
String key = "";
String value = "";
if (keyObj != null) {
key = (String) keyObj;
}
if (key.isEmpty() || editedAppSettings.containsKey(key)) {
tableModel.removeRow(row);
continue;
}
Object valueObj = tableModel.getValueAt(row, 1);
if (valueObj != null) {
value = (String) valueObj;
}
editedAppSettings.put(key, value);
++row;
}
updateSaveAndDiscardBtnStatus();
updateTableActionBtnStatus(false);
} else {
updateTableActionBtnStatus(true);
}
}
});
btnAdd = new AnActionButton(BUTTON_ADD, AllIcons.General.Add) {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
if (tblAppSetting.isEditing()) {
tblAppSetting.getCellEditor().stopCellEditing();
}
tableModel.addRow(new String[] { "", "" });
tblAppSetting.editCellAt(tblAppSetting.getRowCount() - 1, 0);
}
};
btnRemove = new AnActionButton(BUTTON_REMOVE, AllIcons.General.Remove) {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
int selectedRow = tblAppSetting.getSelectedRow();
if (selectedRow == -1) {
return;
}
editedAppSettings.remove(tableModel.getValueAt(selectedRow, 0));
tableModel.removeRow(selectedRow);
updateSaveAndDiscardBtnStatus();
}
};
btnEdit = new AnActionButton(BUTTON_EDIT, AllIcons.Actions.Edit) {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
int selectedRow = tblAppSetting.getSelectedRow();
int selectedCol = tblAppSetting.getSelectedColumn();
if (selectedRow == -1 || selectedCol == -1) {
return;
}
tblAppSetting.editCellAt(selectedRow, selectedCol);
}
};
ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(tblAppSetting).addExtraActions(btnAdd, btnRemove, btnEdit).setToolbarPosition(ActionToolbarPosition.RIGHT);
pnlAppSettings = tableToolbarDecorator.createPanel();
}
use of com.intellij.ui.ToolbarDecorator in project sonarlint-intellij by SonarSource.
the class SonarQubeServerMgmtPanel method create.
private void create() {
Application app = ApplicationManager.getApplication();
serverManager = app.getComponent(SonarLintEngineManager.class);
serverChangeListener = app.getMessageBus().syncPublisher(GlobalConfigurationListener.TOPIC);
serverList = new JBList();
serverList.getEmptyText().setText(LABEL_NO_SERVERS);
serverList.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
if (evt.getClickCount() == 2) {
editServer();
}
}
});
serverList.addListSelectionListener(e -> {
if (!e.getValueIsAdjusting()) {
onServerSelect();
}
});
serversPanel = new JPanel(new BorderLayout());
ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(serverList).setEditActionName("Edit").setEditAction(e -> editServer()).disableUpDownActions();
toolbarDecorator.setAddAction(new AddServerAction());
toolbarDecorator.setRemoveAction(new RemoveServerAction());
serversPanel.add(toolbarDecorator.createPanel(), BorderLayout.CENTER);
splitter = new Splitter(true);
splitter.setFirstComponent(serversPanel);
splitter.setSecondComponent(createServerStatus());
JBLabel emptyLabel = new JBLabel("No server selected", SwingConstants.CENTER);
emptyPanel = new JPanel(new BorderLayout());
emptyPanel.add(emptyLabel, BorderLayout.CENTER);
Border b = IdeBorderFactory.createTitledBorder("SonarQube servers");
panel = new JPanel(new BorderLayout());
panel.setBorder(b);
panel.add(splitter);
serverList.setCellRenderer(new ColoredListCellRenderer() {
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
SonarQubeServer server = (SonarQubeServer) value;
if (server.isSonarCloud()) {
setIcon(SonarLintIcons.ICON_SONARCLOUD_16);
} else {
setIcon(SonarLintIcons.ICON_SONARQUBE_16);
}
append(server.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
if (!server.isSonarCloud()) {
append(" (" + server.getHostUrl() + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES, false);
}
}
});
}
Aggregations