use of com.intellij.util.ui.components.BorderLayoutPanel in project intellij-community by JetBrains.
the class ToBeMergedDialog method initUI.
private void initUI() {
final ListSelectionListener selectionListener = e -> {
List<SvnChangeList> changeLists = myRevisionsList.getSelectedObjects();
myAlreadyMerged.clear();
for (SvnChangeList changeList : changeLists) {
myAlreadyMerged.addAll(getAlreadyMergedPaths(changeList));
}
myRepositoryChangesBrowser.setChangesToDisplay(collectChanges(changeLists, false));
mySplitter.doLayout();
myRepositoryChangesBrowser.repaint();
};
final MyListCellRenderer listCellRenderer = new MyListCellRenderer();
myRevisionsList = new TableView<SvnChangeList>() {
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
return listCellRenderer;
}
@Override
public void valueChanged(ListSelectionEvent e) {
super.valueChanged(e);
selectionListener.valueChanged(e);
}
};
myRevisionsList.setExpandableItemsEnabled(false);
new TableViewSpeedSearch<SvnChangeList>(myRevisionsList) {
@Override
protected String getItemText(@NotNull SvnChangeList element) {
return element.getComment();
}
};
myRevisionsList.setModelAndUpdateColumns(myRevisionsModel);
myRevisionsList.setTableHeader(null);
myRevisionsList.setShowGrid(false);
final AbstractBaseTagMouseListener mouseListener = new AbstractBaseTagMouseListener() {
@Override
public Object getTagAt(@NotNull MouseEvent e) {
JTable table = (JTable) e.getSource();
int row = table.rowAtPoint(e.getPoint());
int column = table.columnAtPoint(e.getPoint());
if (row == -1 || column == -1)
return null;
listCellRenderer.customizeCellRenderer(table, table.getValueAt(row, column), table.isRowSelected(row));
return listCellRenderer.myRenderer.getFragmentTagAt(e.getPoint().x - table.getCellRect(row, column, false).x);
}
};
mouseListener.installOn(myRevisionsList);
myMore100Action = new MoreXAction(100);
myMore500Action = new MoreXAction(500);
BorderLayoutPanel panel = JBUI.Panels.simplePanel().addToCenter(ScrollPaneFactory.createScrollPane(myRevisionsList)).addToTop(createToolbar().getComponent());
mySplitter = new Splitter(false, 0.7f);
mySplitter.setFirstComponent(panel);
myRepositoryChangesBrowser = new RepositoryChangesBrowser(myMergeContext.getProject(), Collections.<SvnChangeList>emptyList(), emptyList(), null);
myRepositoryChangesBrowser.getDiffAction().registerCustomShortcutSet(myRepositoryChangesBrowser.getDiffAction().getShortcutSet(), myRevisionsList);
setChangesDecorator();
mySplitter.setSecondComponent(myRepositoryChangesBrowser);
mySplitter.setDividerWidth(2);
addRevisionListListeners();
myPanel.add(mySplitter, BorderLayout.CENTER);
}
use of com.intellij.util.ui.components.BorderLayoutPanel in project intellij-community by JetBrains.
the class CaptureConfigurable method createComponent.
@Nullable
@Override
public JComponent createComponent() {
myTableModel = new MyTableModel();
JBTable table = new JBTable(myTableModel);
table.setColumnSelectionAllowed(false);
TableColumnModel columnModel = table.getColumnModel();
TableUtil.setupCheckboxColumn(columnModel.getColumn(MyTableModel.ENABLED_COLUMN));
ToolbarDecorator decorator = ToolbarDecorator.createDecorator(table);
decorator.setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
myTableModel.addRow();
}
});
decorator.setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
TableUtil.removeSelectedItems(table);
}
});
decorator.setMoveUpAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
TableUtil.moveSelectedItemsUp(table);
}
});
decorator.setMoveDownAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
TableUtil.moveSelectedItemsDown(table);
}
});
decorator.addExtraAction(new DumbAwareActionButton("Duplicate", "Duplicate", PlatformIcons.COPY_ICON) {
@Override
public boolean isEnabled() {
return table.getSelectedRowCount() == 1;
}
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
selectedCapturePoints(table).forEach(c -> {
try {
int idx = myTableModel.add(c.clone());
table.getSelectionModel().setSelectionInterval(idx, idx);
} catch (CloneNotSupportedException ex) {
LOG.error(ex);
}
});
}
});
decorator.addExtraAction(new DumbAwareActionButton("Enable Selected", "Enable Selected", PlatformIcons.SELECT_ALL_ICON) {
@Override
public boolean isEnabled() {
return table.getSelectedRowCount() > 0;
}
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
selectedCapturePoints(table).forEach(c -> c.myEnabled = true);
table.repaint();
}
});
decorator.addExtraAction(new DumbAwareActionButton("Disable Selected", "Disable Selected", PlatformIcons.UNSELECT_ALL_ICON) {
@Override
public boolean isEnabled() {
return table.getSelectedRowCount() > 0;
}
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
selectedCapturePoints(table).forEach(c -> c.myEnabled = false);
table.repaint();
}
});
new DumbAwareAction("Toggle") {
@Override
public void update(@NotNull AnActionEvent e) {
e.getPresentation().setEnabled(table.getSelectedRowCount() == 1);
}
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
selectedCapturePoints(table).forEach(c -> c.myEnabled = !c.myEnabled);
table.repaint();
}
}.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0)), table);
decorator.addExtraAction(new DumbAwareActionButton("Import", "Import", AllIcons.Actions.Install) {
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, true, false, true, true) {
@Override
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
return super.isFileVisible(file, showHiddenFiles) && (file.isDirectory() || "xml".equals(file.getExtension()) || file.getFileType() == FileTypes.ARCHIVE);
}
@Override
public boolean isFileSelectable(VirtualFile file) {
return file.getFileType() == StdFileTypes.XML;
}
};
descriptor.setDescription("Please select a file to import.");
descriptor.setTitle("Import Capture Points");
VirtualFile[] files = FileChooser.chooseFiles(descriptor, e.getProject(), null);
if (ArrayUtil.isEmpty(files))
return;
table.getSelectionModel().clearSelection();
for (VirtualFile file : files) {
try {
Document document = JDOMUtil.loadDocument(file.getInputStream());
List<Element> children = document.getRootElement().getChildren();
children.forEach(element -> {
int idx = myTableModel.addIfNeeded(XmlSerializer.deserialize(element, CapturePoint.class));
table.getSelectionModel().addSelectionInterval(idx, idx);
});
} catch (Exception ex) {
final String msg = ex.getLocalizedMessage();
Messages.showErrorDialog(e.getProject(), msg != null && msg.length() > 0 ? msg : ex.toString(), "Export Failed");
}
}
}
});
decorator.addExtraAction(new DumbAwareActionButton("Export", "Export", AllIcons.Actions.Export) {
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
VirtualFileWrapper wrapper = FileChooserFactory.getInstance().createSaveFileDialog(new FileSaverDescriptor("Export Selected Capture Points to File...", "", "xml"), e.getProject()).save(null, null);
if (wrapper == null)
return;
Element rootElement = new Element("capture-points");
selectedCapturePoints(table).forEach(c -> {
try {
CapturePoint clone = c.clone();
clone.myEnabled = false;
rootElement.addContent(XmlSerializer.serialize(clone));
} catch (CloneNotSupportedException ex) {
LOG.error(ex);
}
});
try {
JDOMUtil.write(rootElement, wrapper.getFile());
} catch (Exception ex) {
final String msg = ex.getLocalizedMessage();
Messages.showErrorDialog(e.getProject(), msg != null && msg.length() > 0 ? msg : ex.toString(), "Export Failed");
}
}
@Override
public boolean isEnabled() {
return table.getSelectedRowCount() > 0;
}
});
BorderLayoutPanel panel = JBUI.Panels.simplePanel();
panel.addToCenter(decorator.createPanel());
myCaptureVariables = new JCheckBox(DebuggerBundle.message("label.capture.configurable.capture.variables"));
panel.addToBottom(myCaptureVariables);
return panel;
}
use of com.intellij.util.ui.components.BorderLayoutPanel in project intellij-community by JetBrains.
the class MacIntelliJComboBoxUI method createPopup.
@Override
protected ComboPopup createPopup() {
return new BasicComboPopup(myComboBox) {
@Override
protected void configurePopup() {
super.configurePopup();
setBorderPainted(false);
setBorder(JBUI.Borders.empty());
setBackground(Gray.xFF);
}
@Override
protected void configureList() {
super.configureList();
wrapRenderer();
}
@Override
protected PropertyChangeListener createPropertyChangeListener() {
final PropertyChangeListener listener = super.createPropertyChangeListener();
return new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
listener.propertyChange(evt);
if ("renderer".equals(evt.getPropertyName())) {
wrapRenderer();
}
}
};
}
class ComboBoxRendererWrapper implements ListCellRenderer {
private final ListCellRenderer myRenderer;
public ComboBoxRendererWrapper(@NotNull ListCellRenderer renderer) {
myRenderer = renderer;
}
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = myRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
BorderLayoutPanel panel = JBUI.Panels.simplePanel(c).withBorder(JBUI.Borders.empty(0, 8));
panel.setBackground(c.getBackground());
return panel;
}
}
private void wrapRenderer() {
ListCellRenderer renderer = list.getCellRenderer();
if (!(renderer instanceof ComboBoxRendererWrapper) && renderer != null) {
list.setCellRenderer(new ComboBoxRendererWrapper(renderer));
}
}
};
}
use of com.intellij.util.ui.components.BorderLayoutPanel in project intellij-community by JetBrains.
the class ChooseModulesDialog method createNorthPanel.
protected JComponent createNorthPanel() {
BorderLayoutPanel panel = JBUI.Panels.simplePanel(15, 10);
if (myIcon != null) {
JLabel iconLabel = new JLabel(myIcon);
panel.addToLeft(JBUI.Panels.simplePanel().addToTop(iconLabel));
}
BorderLayoutPanel messagePanel = JBUI.Panels.simplePanel();
if (myMessage != null) {
JLabel textLabel = new JLabel(myMessage);
textLabel.setBorder(JBUI.Borders.emptyBottom(5));
textLabel.setUI(new MultiLineLabelUI());
messagePanel.addToTop(textLabel);
}
panel.add(messagePanel, BorderLayout.CENTER);
final JScrollPane jScrollPane = ScrollPaneFactory.createScrollPane();
jScrollPane.setViewportView(myView);
jScrollPane.setPreferredSize(JBUI.size(300, 80));
panel.addToBottom(jScrollPane);
return panel;
}
use of com.intellij.util.ui.components.BorderLayoutPanel in project intellij-community by JetBrains.
the class XDebuggerEditorBase method decorate.
protected JPanel decorate(JComponent component, boolean multiline, boolean showEditor) {
BorderLayoutPanel panel = JBUI.Panels.simplePanel();
JPanel factoryPanel = JBUI.Panels.simplePanel();
factoryPanel.add(myChooseFactory, multiline ? BorderLayout.NORTH : BorderLayout.CENTER);
panel.add(factoryPanel, BorderLayout.WEST);
if (!multiline && showEditor) {
component = addMultilineButton(component);
}
panel.addToCenter(component);
return panel;
}
Aggregations