use of com.intellij.ui.components.JBPanel in project intellij-community by JetBrains.
the class CoverageConfigurable method createEditor.
@NotNull
protected JComponent createEditor() {
JPanel result = new JPanel(new GridBagLayout());
final DefaultComboBoxModel runnersModel = new DefaultComboBoxModel();
myCoverageRunnerCb = new JComboBox(runnersModel);
final JavaCoverageEnabledConfiguration javaCoverageEnabledConfiguration = JavaCoverageEnabledConfiguration.getFrom(myConfig);
LOG.assertTrue(javaCoverageEnabledConfiguration != null);
final JavaCoverageEngine provider = javaCoverageEnabledConfiguration.getCoverageProvider();
for (CoverageRunner runner : Extensions.getExtensions(CoverageRunner.EP_NAME)) {
if (runner.acceptsCoverageEngine(provider)) {
runnersModel.addElement(new CoverageRunnerItem(runner));
}
}
myCoverageRunnerCb.setRenderer(new ListCellRendererWrapper<CoverageRunnerItem>() {
@Override
public void customize(JList list, CoverageRunnerItem value, int index, boolean selected, boolean hasFocus) {
if (value != null) {
setText(value.getPresentableName());
}
}
});
myCoverageRunnerCb.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
final CoverageRunner runner = getSelectedRunner();
enableTracingPanel(runner != null && runner.isCoverageByTestApplicable());
myTrackPerTestCoverageCb.setEnabled(myTracingRb.isSelected() && canHavePerTestCoverage() && runner != null && runner.isCoverageByTestApplicable());
}
});
myRunnerPanel = new JPanel(new GridBagLayout());
myRunnerPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
myRunnerPanel.add(new JLabel("Choose coverage runner:"), new GridBagConstraints(0, 0, 1, 1, 0, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insetsRight(10), 0, 0));
myRunnerPanel.add(myCoverageRunnerCb, new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0));
final JPanel cPanel = new JPanel(new VerticalFlowLayout());
mySamplingRb = new JRadioButton("Sampling");
cPanel.add(mySamplingRb);
myTracingRb = new JRadioButton("Tracing");
cPanel.add(myTracingRb);
final ButtonGroup group = new ButtonGroup();
group.add(mySamplingRb);
group.add(myTracingRb);
ActionListener samplingListener = new ActionListener() {
public void actionPerformed(final ActionEvent e) {
final CoverageRunner runner = getSelectedRunner();
myTrackPerTestCoverageCb.setEnabled(canHavePerTestCoverage() && myTracingRb.isSelected() && runner != null && runner.isCoverageByTestApplicable());
}
};
mySamplingRb.addActionListener(samplingListener);
myTracingRb.addActionListener(samplingListener);
myTrackPerTestCoverageCb = new JCheckBox("Track per test coverage");
final JBPanel tracingPanel = JBUI.Panels.simplePanel(myTrackPerTestCoverageCb).withBorder(JBUI.Borders.emptyLeft(15));
cPanel.add(tracingPanel);
myRunnerPanel.add(cPanel, new GridBagConstraints(0, 1, GridBagConstraints.REMAINDER, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0));
final GridBagConstraints gc = new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, JBUI.emptyInsets(), 0, 0);
result.add(myRunnerPanel, gc);
JPanel panel = new JPanel(new GridBagLayout());
panel.setBorder(IdeBorderFactory.createTitledBorder(ExecutionBundle.message("record.coverage.filters.title"), false));
myClassFilterEditor = new MyClassFilterEditor(myProject);
final GridBagConstraints bagConstraints = new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, JBUI.emptyInsets(), 0, 0);
panel.add(myClassFilterEditor, bagConstraints);
bagConstraints.weighty = 0;
myTrackTestSourcesCb = new JCheckBox("Enable coverage in test folders");
panel.add(myTrackTestSourcesCb, bagConstraints);
gc.weighty = 1;
gc.fill = GridBagConstraints.BOTH;
result.add(panel, gc);
myCoverageNotSupportedLabel = new JLabel(CodeInsightBundle.message("code.coverage.is.not.supported"));
myCoverageNotSupportedLabel.setIcon(AllIcons.General.WarningDialog);
result.add(myCoverageNotSupportedLabel, gc);
return result;
}
use of com.intellij.ui.components.JBPanel in project intellij-community by JetBrains.
the class VcsStructureChooser method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
myTree = new Tree();
myTree.setBorder(BORDER);
myTree.setShowsRootHandles(true);
myTree.setRootVisible(false);
myTree.setExpandableItemsEnabled(false);
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, true, true, false, true) {
@Override
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
if (!super.isFileVisible(file, showHiddenFiles))
return false;
if (myRoots.contains(file))
return false;
ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
return !changeListManager.isIgnoredFile(file) && !changeListManager.isUnversioned(file);
}
};
descriptor.withRoots(new ArrayList<>(myRoots)).withShowHiddenFiles(true).withHideIgnored(true);
final MyCheckboxTreeCellRenderer cellRenderer = new MyCheckboxTreeCellRenderer(mySelectionManager, myModulesSet, myProject, myTree, myRoots);
FileSystemTreeImpl fileSystemTree = new FileSystemTreeImpl(myProject, descriptor, myTree, cellRenderer, null, o -> {
DefaultMutableTreeNode lastPathComponent = ((DefaultMutableTreeNode) o.getLastPathComponent());
Object uo = lastPathComponent.getUserObject();
if (uo instanceof FileNodeDescriptor) {
VirtualFile file = ((FileNodeDescriptor) uo).getElement().getFile();
String module = myModulesSet.get(file);
if (module != null)
return module;
return file == null ? "" : file.getName();
}
return o.toString();
});
fileSystemTree.getTreeBuilder().getUi().setNodeDescriptorComparator((o1, o2) -> {
if (o1 instanceof FileNodeDescriptor && o2 instanceof FileNodeDescriptor) {
VirtualFile f1 = ((FileNodeDescriptor) o1).getElement().getFile();
VirtualFile f2 = ((FileNodeDescriptor) o2).getElement().getFile();
boolean isDir1 = f1.isDirectory();
boolean isDir2 = f2.isDirectory();
if (isDir1 != isDir2)
return isDir1 ? -1 : 1;
return f1.getPath().compareToIgnoreCase(f2.getPath());
}
return o1.getIndex() - o2.getIndex();
});
new ClickListener() {
@Override
public boolean onClick(@NotNull MouseEvent e, int clickCount) {
int row = myTree.getRowForLocation(e.getX(), e.getY());
if (row < 0)
return false;
Object o = myTree.getPathForRow(row).getLastPathComponent();
if (getTreeRoot() == o || getFile(o) == null)
return false;
Rectangle rowBounds = myTree.getRowBounds(row);
cellRenderer.setBounds(rowBounds);
Rectangle checkBounds = cellRenderer.myCheckbox.getBounds();
checkBounds.setLocation(rowBounds.getLocation());
if (checkBounds.height == 0)
checkBounds.height = rowBounds.height;
if (checkBounds.contains(e.getPoint())) {
mySelectionManager.toggleSelection((DefaultMutableTreeNode) o);
myTree.revalidate();
myTree.repaint();
}
return true;
}
}.installOn(myTree);
myTree.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
TreePath[] paths = myTree.getSelectionPaths();
if (paths == null)
return;
for (TreePath path : paths) {
if (path == null)
continue;
Object o = path.getLastPathComponent();
if (getTreeRoot() == o || getFile(o) == null)
return;
mySelectionManager.toggleSelection((DefaultMutableTreeNode) o);
}
myTree.revalidate();
myTree.repaint();
e.consume();
}
}
});
JBPanel panel = new JBPanel(new BorderLayout());
panel.add(new JBScrollPane(fileSystemTree.getTree()), BorderLayout.CENTER);
final JLabel selectedLabel = new JLabel("");
selectedLabel.setBorder(JBUI.Borders.empty(2, 0));
panel.add(selectedLabel, BorderLayout.SOUTH);
mySelectionManager.setSelectionChangeListener(new PlusMinus<VirtualFile>() {
@Override
public void plus(VirtualFile virtualFile) {
mySelectedFiles.add(virtualFile);
recalculateErrorText();
}
private void recalculateErrorText() {
checkEmpty();
if (mySelectionManager.canAddSelection()) {
selectedLabel.setText("");
} else {
selectedLabel.setText(CAN_NOT_ADD_TEXT);
}
selectedLabel.revalidate();
}
@Override
public void minus(VirtualFile virtualFile) {
mySelectedFiles.remove(virtualFile);
recalculateErrorText();
}
});
panel.setPreferredSize(JBUI.size(400, 300));
return panel;
}
use of com.intellij.ui.components.JBPanel in project android by JetBrains.
the class GradleEditorComponent method addUiForGroup.
private void addUiForGroup(@NotNull GradleEditorEntityGroup group) {
JBPanel panel = new JBPanel(new BorderLayout());
panel.setBackground(UIUtil.getTableBackground());
panel.setBorder(IdeBorderFactory.createTitledBorder(group.getName()));
GradleEditorEntityTable table = new GradleEditorEntityTable(myProject);
for (GradleEditorEntity entity : group.getEntities()) {
table.getModel().add(entity);
}
panel.add(table);
addUiForGroup(group.getName(), panel, table);
}
use of com.intellij.ui.components.JBPanel in project android by JetBrains.
the class GradleEditorComponent method setData.
/**
* Configures current control to represent given groups (discarding all previously shown information).
*
* @param groups groups to show
*/
public void setData(@NotNull List<GradleEditorEntityGroup> groups) {
// Most likely use-case is that just table's data should be updated.
boolean sameTables = groups.size() == myTablesByGroupName.size();
for (GradleEditorEntityGroup group : groups) {
GradleEditorEntityTable table = myTablesByGroupName.get(group.getName());
if (table == null) {
sameTables = false;
} else {
if (table.isEditing()) {
table.getCellEditor().stopCellEditing();
}
table.getModel().setData(group.getEntities());
}
}
if (sameTables) {
return;
}
myCanvas.removeAll();
Map<String, GradleEditorEntityTable> tablesByGroupName = Maps.newHashMap(myTablesByGroupName);
myTablesByGroupName.clear();
Map<String, JBPanel> panelsByGroupName = Maps.newHashMap(myPanelsByGroupName);
myPanelsByGroupName.clear();
for (GradleEditorEntityGroup group : groups) {
JBPanel panel = panelsByGroupName.get(group.getName());
GradleEditorEntityTable table = tablesByGroupName.get(group.getName());
if (panel != null && table != null) {
addUiForGroup(group.getName(), panel, table);
} else {
addUiForGroup(group);
}
}
myCanvas.add(new JLabel(" "), new GridBag().weighty(1));
}
use of com.intellij.ui.components.JBPanel in project android by JetBrains.
the class BaseSegment method createSpacerPanel.
private JPanel createSpacerPanel(int spacerWidth) {
JBPanel panel = new JBPanel();
panel.setLayout(new BorderLayout());
Dimension spacerDimension = new Dimension(spacerWidth, 0);
panel.setPreferredSize(spacerDimension);
panel.setMinimumSize(spacerDimension);
return panel;
}
Aggregations