use of com.intellij.ui.components.JBLabel in project intellij-community by JetBrains.
the class GitCrlfDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
JLabel description = new JBLabel("<html>You are about to commit CRLF line separators to the Git repository.<br/>" + "It is recommended to set core.autocrlf Git attribute to <code>" + RECOMMENDED_VALUE + "</code> to avoid line separator issues.</html>");
JLabel additionalDescription = new JBLabel("<html>Fix and Commit: <code>git config --global core.autocrlf " + RECOMMENDED_VALUE + "</code> will be called,<br/>" + "Commit as Is: the config value won't be set.</html>", UIUtil.ComponentStyle.SMALL);
JLabel readMore = LinkLabel.create("Read more", () -> BrowserUtil.browse("https://help.github.com/articles/dealing-with-line-endings"));
JLabel icon = new JLabel(UIUtil.getWarningIcon(), SwingConstants.LEFT);
myDontWarn = new JBCheckBox("Don't warn again");
myDontWarn.setMnemonic('w');
JPanel rootPanel = new JPanel(new GridBagLayout());
GridBag g = new GridBag().setDefaultInsets(new Insets(0, 6, DEFAULT_VGAP, DEFAULT_HGAP)).setDefaultAnchor(GridBagConstraints.LINE_START).setDefaultFill(GridBagConstraints.HORIZONTAL);
rootPanel.add(icon, g.nextLine().next().coverColumn(4));
rootPanel.add(description, g.next());
rootPanel.add(readMore, g.nextLine().next().next());
rootPanel.add(additionalDescription, g.nextLine().next().next().pady(DEFAULT_HGAP));
rootPanel.add(myDontWarn, g.nextLine().next().next().insets(0, 0, 0, 0));
return rootPanel;
}
use of com.intellij.ui.components.JBLabel in project intellij-community by JetBrains.
the class RestoreReferencesDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
final JPanel panel = new JPanel(new BorderLayout(UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP));
myList = new JBList(myNamedElements);
myList.setCellRenderer(new FQNameCellRenderer());
panel.add(ScrollPaneFactory.createScrollPane(myList), BorderLayout.CENTER);
panel.add(new JBLabel(myContainsClassesOnly ? CodeInsightBundle.message("dialog.paste.on.import.text") : CodeInsightBundle.message("dialog.paste.on.import.text2"), SMALL, BRIGHTER), BorderLayout.NORTH);
final JPanel buttonPanel = new JPanel(new VerticalFlowLayout());
final JButton okButton = new JButton(CommonBundle.getOkButtonText());
getRootPane().setDefaultButton(okButton);
buttonPanel.add(okButton);
final JButton cancelButton = new JButton(CommonBundle.getCancelButtonText());
buttonPanel.add(cancelButton);
panel.setPreferredSize(JBUI.size(500, 400));
return panel;
}
use of com.intellij.ui.components.JBLabel 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.components.JBLabel in project intellij-community by JetBrains.
the class FindPopupPanel method initComponents.
private void initComponents() {
myTitleLabel = new JBLabel(FindBundle.message("find.in.path.dialog.title"), UIUtil.ComponentStyle.REGULAR);
myTitleLabel.setFont(myTitleLabel.getFont().deriveFont(Font.BOLD));
myTitleLabel.setBorder(JBUI.Borders.empty(0, 4, 0, 16));
myCbCaseSensitive = new StateRestoringCheckBox(FindBundle.message("find.popup.case.sensitive"));
ItemListener liveResultsPreviewUpdateListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
scheduleResultsUpdate();
}
};
myCbCaseSensitive.addItemListener(liveResultsPreviewUpdateListener);
myCbPreserveCase = new StateRestoringCheckBox(FindBundle.message("find.options.replace.preserve.case"));
myCbPreserveCase.addItemListener(liveResultsPreviewUpdateListener);
myCbPreserveCase.setVisible(myHelper.getModel().isReplaceState());
myCbWholeWordsOnly = new StateRestoringCheckBox(FindBundle.message("find.popup.whole.words"));
myCbWholeWordsOnly.addItemListener(liveResultsPreviewUpdateListener);
myCbRegularExpressions = new StateRestoringCheckBox(FindBundle.message("find.popup.regex"));
myCbRegularExpressions.addItemListener(liveResultsPreviewUpdateListener);
myCbFileFilter = new StateRestoringCheckBox(FindBundle.message("find.popup.filemask"));
myCbFileFilter.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (myCbFileFilter.isSelected()) {
myFileMaskField.setEnabled(true);
if (myCbFileFilter.getClientProperty("dontRequestFocus") == null) {
myFileMaskField.selectAll();
IdeFocusManager.getInstance(myProject).requestFocus(myFileMaskField, true);
}
} else {
myFileMaskField.setEnabled(false);
if (myCbFileFilter.getClientProperty("dontRequestFocus") == null) {
IdeFocusManager.getInstance(myProject).requestFocus(mySearchComponent, true);
}
}
}
});
myCbFileFilter.addItemListener(liveResultsPreviewUpdateListener);
myFileMaskField = new TextFieldWithAutoCompletion<String>(myProject, new TextFieldWithAutoCompletion.StringsCompletionProvider(myFileMasks, null), false, null) {
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
setBackground(enabled ? JBColor.background() : UIUtil.getComboBoxDisabledBackground());
}
};
myFileMaskField.setPreferredWidth(JBUI.scale(100));
myFileMaskField.addDocumentListener(new com.intellij.openapi.editor.event.DocumentAdapter() {
@Override
public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent e) {
scheduleResultsUpdate();
}
});
DefaultActionGroup switchContextGroup = new DefaultActionGroup();
switchContextGroup.add(new MySwitchContextToggleAction(FindModel.SearchContext.ANY));
switchContextGroup.add(new MySwitchContextToggleAction(FindModel.SearchContext.IN_COMMENTS));
switchContextGroup.add(new MySwitchContextToggleAction(FindModel.SearchContext.IN_STRING_LITERALS));
switchContextGroup.add(new MySwitchContextToggleAction(FindModel.SearchContext.EXCEPT_COMMENTS));
switchContextGroup.add(new MySwitchContextToggleAction(FindModel.SearchContext.EXCEPT_STRING_LITERALS));
switchContextGroup.add(new MySwitchContextToggleAction(FindModel.SearchContext.EXCEPT_COMMENTS_AND_STRING_LITERALS));
switchContextGroup.setPopup(true);
Presentation filterPresentation = new Presentation();
filterPresentation.setIcon(AllIcons.General.Filter);
AnAction myShowFilterPopupAction = new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
if (PlatformDataKeys.CONTEXT_COMPONENT.getData(e.getDataContext()) == null)
return;
ListPopup listPopup = JBPopupFactory.getInstance().createActionGroupPopup(null, switchContextGroup, e.getDataContext(), false, null, 10);
listPopup.showUnderneathOf(myFilterContextButton);
}
};
myFilterContextButton = new ActionButton(myShowFilterPopupAction, filterPresentation, ActionPlaces.UNKNOWN, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE) {
@Override
public int getPopState() {
int state = super.getPopState();
if (state != ActionButtonComponent.NORMAL)
return state;
return mySelectedContextName.equals(FindDialog.getPresentableName(FindModel.SearchContext.ANY)) ? ActionButtonComponent.NORMAL : ActionButtonComponent.PUSHED;
}
};
myFilterContextButton.setFocusable(true);
DefaultActionGroup tabResultsContextGroup = new DefaultActionGroup();
tabResultsContextGroup.add(new ToggleAction(FindBundle.message("find.options.skip.results.tab.with.one.usage.checkbox")) {
@Override
public boolean isSelected(AnActionEvent e) {
return FindSettings.getInstance().isSkipResultsWithOneUsage();
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
myHelper.setSkipResultsWithOneUsage(state);
}
@Override
public void update(@NotNull AnActionEvent e) {
super.update(e);
e.getPresentation().setVisible(!myHelper.isReplaceState());
}
});
tabResultsContextGroup.add(new ToggleAction(FindBundle.message("find.open.in.new.tab.checkbox")) {
@Override
public boolean isSelected(AnActionEvent e) {
return FindSettings.getInstance().isShowResultsInSeparateView();
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
myHelper.setUseSeparateView(state);
}
});
tabResultsContextGroup.setPopup(true);
Presentation tabSettingsPresentation = new Presentation();
tabSettingsPresentation.setIcon(AllIcons.General.SecondaryGroup);
myTabResultsButton = new ActionButton(tabResultsContextGroup, tabSettingsPresentation, ActionPlaces.UNKNOWN, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE);
myOKButton = new JButton(FindBundle.message("find.popup.find.button"));
myOkActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FindModel validateModel = myHelper.getModel().clone();
applyTo(validateModel, false);
ValidationInfo validationInfo = getValidationInfo(validateModel);
if (validationInfo == null) {
myHelper.getModel().copyFrom(validateModel);
myHelper.updateFindSettings();
myHelper.doOKAction();
} else {
String message = validationInfo.message;
Messages.showMessageDialog(FindPopupPanel.this, message, CommonBundle.getErrorTitle(), Messages.getErrorIcon());
return;
}
Disposer.dispose(myBalloon);
}
};
myOKButton.addActionListener(myOkActionListener);
registerKeyboardAction(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!myHelper.isReplaceState()) {
navigateToSelectedUsage();
return;
}
myOkActionListener.actionPerformed(e);
}
}, NEW_LINE, WHEN_IN_FOCUSED_WINDOW);
registerKeyboardAction(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (myHelper.isReplaceState())
return;
myOkActionListener.actionPerformed(e);
}
}, OK_FIND, WHEN_IN_FOCUSED_WINDOW);
mySearchComponent = new JTextArea();
mySearchComponent.setColumns(25);
mySearchComponent.setRows(1);
myReplaceComponent = new JTextArea();
myReplaceComponent.setColumns(25);
myReplaceComponent.setRows(1);
mySearchTextArea = new SearchTextArea(mySearchComponent, true, true);
myReplaceTextArea = new SearchTextArea(myReplaceComponent, false, false);
DocumentAdapter documentAdapter = new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
mySearchComponent.setRows(Math.max(1, Math.min(3, StringUtil.countChars(mySearchComponent.getText(), '\n') + 1)));
myReplaceComponent.setRows(Math.max(1, Math.min(3, StringUtil.countChars(myReplaceComponent.getText(), '\n') + 1)));
if (myBalloon == null)
return;
if (e.getDocument() == mySearchComponent.getDocument()) {
scheduleResultsUpdate();
}
}
};
mySearchComponent.getDocument().addDocumentListener(documentAdapter);
myReplaceComponent.getDocument().addDocumentListener(documentAdapter);
mySearchTextArea.setMultilineEnabled(false);
myReplaceTextArea.setMultilineEnabled(false);
Pair<FindPopupScopeUI.ScopeType, JComponent>[] scopeComponents = myScopeUI.getComponents();
List<AnAction> scopeActions = new LinkedList<>();
myScopeDetailsPanel = new JPanel(new CardLayout());
for (Pair<FindPopupScopeUI.ScopeType, JComponent> scopeComponent : scopeComponents) {
FindPopupScopeUI.ScopeType scopeType = scopeComponent.first;
scopeActions.add(new MySelectScopeToggleAction(scopeType));
myScopeDetailsPanel.add(scopeType.name, scopeComponent.second);
}
myScopeSelectionToolbar = createToolbar(scopeActions.toArray(AnAction.EMPTY_ARRAY));
mySelectedScope = scopeComponents[0].first;
myResultsPreviewTable = new JBTable() {
@Override
public Dimension getPreferredScrollableViewportSize() {
return new Dimension(getWidth(), 1 + getRowHeight() * 4);
}
};
myResultsPreviewTable.setFocusable(false);
myResultsPreviewTable.getEmptyText().setShowAboveCenter(false);
myResultsPreviewTable.setShowColumns(false);
myResultsPreviewTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myResultsPreviewTable.setShowGrid(false);
myResultsPreviewTable.setIntercellSpacing(JBUI.emptySize());
new DoubleClickListener() {
@Override
protected boolean onDoubleClick(MouseEvent event) {
if (event.getSource() != myResultsPreviewTable)
return false;
navigateToSelectedUsage();
return true;
}
}.installOn(myResultsPreviewTable);
myResultsPreviewTable.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
myResultsPreviewTable.transferFocus();
}
});
applyFont(JBUI.Fonts.label(), myCbCaseSensitive, myCbPreserveCase, myCbWholeWordsOnly, myCbRegularExpressions, myResultsPreviewTable);
ScrollingUtil.installActions(myResultsPreviewTable, false, mySearchComponent);
ScrollingUtil.installActions(myResultsPreviewTable, false, myReplaceComponent);
UIUtil.redirectKeystrokes(myDisposable, mySearchComponent, myResultsPreviewTable, NEW_LINE);
UIUtil.redirectKeystrokes(myDisposable, myReplaceComponent, myResultsPreviewTable, NEW_LINE);
ActionListener helpAction = new ActionListener() {
public void actionPerformed(final ActionEvent e) {
HelpManager.getInstance().invokeHelp("reference.dialogs.findinpath");
}
};
registerKeyboardAction(helpAction, KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
registerKeyboardAction(helpAction, KeyStroke.getKeyStroke(KeyEvent.VK_HELP, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
myUsagePreviewPanel = new UsagePreviewPanel(myProject, new UsageViewPresentation(), Registry.is("ide.find.as.popup.editable.code")) {
@Override
public Dimension getPreferredSize() {
return new Dimension(myResultsPreviewTable.getWidth(), Math.max(getHeight(), getLineHeight() * 15));
}
};
Disposer.register(myDisposable, myUsagePreviewPanel);
myResultsPreviewTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting())
return;
int index = myResultsPreviewTable.getSelectedRow();
if (index != -1) {
UsageInfo usageInfo = ((UsageInfo2UsageAdapter) myResultsPreviewTable.getModel().getValueAt(index, 0)).getUsageInfo();
myUsagePreviewPanel.updateLayout(usageInfo.isValid() ? Collections.singletonList(usageInfo) : null);
VirtualFile file = usageInfo.getVirtualFile();
String path = "";
if (file != null) {
String relativePath = VfsUtilCore.getRelativePath(file, myProject.getBaseDir());
if (relativePath == null)
relativePath = file.getPath();
path = "<html><body> " + relativePath.replace(file.getName(), "<b>" + file.getName() + "</b>") + "</body></html>";
}
myUsagePreviewPanel.setBorder(IdeBorderFactory.createTitledBorder(path, false, new JBInsets(8, 0, -14, 0)));
} else {
myUsagePreviewPanel.updateLayout(null);
myUsagePreviewPanel.setBorder(IdeBorderFactory.createBorder());
}
}
});
mySearchRescheduleOnCancellationsAlarm = new Alarm();
JBSplitter splitter = new JBSplitter(true, .33f);
splitter.setSplitterProportionKey(SPLITTER_SERVICE_KEY);
splitter.setDividerWidth(JBUI.scale(2));
splitter.getDivider().setBackground(OnePixelDivider.BACKGROUND);
JBScrollPane scrollPane = new JBScrollPane(myResultsPreviewTable) {
@Override
public Dimension getMinimumSize() {
Dimension size = super.getMinimumSize();
size.height = myResultsPreviewTable.getPreferredScrollableViewportSize().height;
return size;
}
};
scrollPane.setBorder(IdeBorderFactory.createEmptyBorder());
splitter.setFirstComponent(scrollPane);
JPanel bottomPanel = new JPanel(new MigLayout("flowx, ins 4 4 0 4, fillx, hidemode 2, gap 0"));
bottomPanel.add(myTabResultsButton);
bottomPanel.add(Box.createHorizontalGlue(), "growx, pushx");
myOKHintLabel = new JBLabel(KeymapUtil.getShortcutsText(new Shortcut[] { new KeyboardShortcut(OK_FIND, null) }));
myOKHintLabel.setEnabled(false);
bottomPanel.add(myOKHintLabel, "gapright 10");
bottomPanel.add(myOKButton);
myCodePreviewComponent = myUsagePreviewPanel.createComponent();
splitter.setSecondComponent(myCodePreviewComponent);
JPanel scopesPanel = new JPanel(new MigLayout("flowx, gap 26, ins 0"));
scopesPanel.add(myScopeSelectionToolbar.getComponent());
scopesPanel.add(myScopeDetailsPanel, "growx, pushx");
setLayout(new MigLayout("flowx, ins 4, gap 0, fillx, hidemode 3"));
int cbGapLeft = myCbCaseSensitive.getInsets().left;
int cbGapRight = myCbCaseSensitive.getInsets().right;
String cbGap = cbGapLeft + cbGapRight < 16 ? "gapright " + (16 - cbGapLeft - cbGapRight) : "";
add(myTitleLabel, "sx 2, growx, pushx, growy");
add(myCbCaseSensitive, cbGap);
add(myCbPreserveCase, cbGap);
add(myCbWholeWordsOnly, cbGap);
add(myCbRegularExpressions, "gapright 0");
add(RegExHelpPopup.createRegExLink("<html><body><b>?</b></body></html>", myCbRegularExpressions, LOG), "gapright " + (16 - cbGapLeft));
add(myCbFileFilter);
add(myFileMaskField, "gapright 16");
add(myFilterContextButton, "wrap");
add(mySearchTextArea, "pushx, growx, sx 10, gaptop 4, wrap");
add(myReplaceTextArea, "pushx, growx, sx 10, gaptop 4, wrap");
add(scopesPanel, "sx 10, pushx, growx, ax left, wrap, gaptop 4, gapbottom 4");
add(splitter, "pushx, growx, growy, pushy, sx 10, wrap, pad -4 -4 4 4");
add(bottomPanel, "pushx, growx, dock south, sx 10");
MnemonicHelper.init(this);
setFocusCycleRoot(true);
setFocusTraversalPolicy(new ContainerOrderFocusTraversalPolicy() {
@Override
public Component getComponentAfter(Container container, Component c) {
return (c == myResultsPreviewTable) ? mySearchComponent : super.getComponentAfter(container, c);
}
});
}
use of com.intellij.ui.components.JBLabel in project kotlin by JetBrains.
the class RestoreReferencesDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
final JPanel panel = new JPanel(new BorderLayout(UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP));
myList = new JBList(myNamedElements);
myList.setCellRenderer(new KotlinImportListRenderer());
panel.add(ScrollPaneFactory.createScrollPane(myList), BorderLayout.CENTER);
panel.add(new JBLabel(myContainsClassesOnly ? CodeInsightBundle.message("dialog.paste.on.import.text") : CodeInsightBundle.message("dialog.paste.on.import.text2"), SMALL, BRIGHTER), BorderLayout.NORTH);
final JPanel buttonPanel = new JPanel(new VerticalFlowLayout());
final JButton okButton = new JButton(CommonBundle.getOkButtonText());
getRootPane().setDefaultButton(okButton);
buttonPanel.add(okButton);
final JButton cancelButton = new JButton(CommonBundle.getCancelButtonText());
buttonPanel.add(cancelButton);
panel.setPreferredSize(new Dimension(500, 400));
return panel;
}
Aggregations