use of com.intellij.ui.components.JBScrollPane in project intellij-community by JetBrains.
the class CustomizePluginsStepPanel method createScrollPane.
static JBScrollPane createScrollPane(JPanel gridPanel) {
JBScrollPane scrollPane = new JBScrollPane(gridPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
// to disallow resetting border on LaF change
scrollPane.setBorder(JBUI.Borders.empty());
return scrollPane;
}
use of com.intellij.ui.components.JBScrollPane in project intellij-community by JetBrains.
the class AppUIUtil method showPrivacyPolicyAgreement.
/**
* @param htmlText Updated version of Privacy Policy text if any.
* If it's {@code null}, the standard text from bundled resources would be used.
*/
public static void showPrivacyPolicyAgreement(@NotNull String htmlText) {
DialogWrapper dialog = new DialogWrapper(true) {
@Nullable
@Override
protected JComponent createCenterPanel() {
JPanel centerPanel = new JPanel(new BorderLayout(JBUI.scale(5), JBUI.scale(5)));
JEditorPane viewer = SwingHelper.createHtmlViewer(true, null, JBColor.WHITE, JBColor.BLACK);
viewer.setFocusable(true);
viewer.addHyperlinkListener(new HyperlinkAdapter() {
@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
URL url = e.getURL();
if (url != null) {
BrowserUtil.browse(url);
} else {
SwingHelper.scrollToReference(viewer, e.getDescription());
}
}
});
viewer.setText(htmlText);
StyleSheet styleSheet = ((HTMLDocument) viewer.getDocument()).getStyleSheet();
styleSheet.addRule("body {font-family: \"Segoe UI\", Tahoma, sans-serif;}");
styleSheet.addRule("body {margin-top:0;padding-top:0;}");
styleSheet.addRule("body {font-size:" + JBUI.scaleFontSize(13) + "pt;}");
styleSheet.addRule("h2, em {margin-top:" + JBUI.scaleFontSize(20) + "pt;}");
styleSheet.addRule("h1, h2, h3, p, h4, em {margin-bottom:0;padding-bottom:0;}");
styleSheet.addRule("p, h1 {margin-top:0;padding-top:" + JBUI.scaleFontSize(6) + "pt;}");
styleSheet.addRule("li {margin-bottom:" + JBUI.scaleFontSize(6) + "pt;}");
styleSheet.addRule("h2 {margin-top:0;padding-top:" + JBUI.scaleFontSize(13) + "pt;}");
viewer.setCaretPosition(0);
viewer.setBorder(JBUI.Borders.empty(0, 5, 5, 5));
centerPanel.add(new JLabel("Please read and accept these terms and conditions:"), BorderLayout.NORTH);
centerPanel.add(new JBScrollPane(viewer, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER);
return centerPanel;
}
@Override
protected void createDefaultActions() {
super.createDefaultActions();
init();
setOKButtonText("Accept");
setCancelButtonText("Reject and Exit");
setAutoAdjustable(false);
}
@Override
public void doCancelAction() {
super.doCancelAction();
ApplicationEx application = ApplicationManagerEx.getApplicationEx();
if (application == null) {
System.exit(Main.PRIVACY_POLICY_REJECTION);
} else {
((ApplicationImpl) application).exit(true, true, false);
}
}
};
dialog.setModal(true);
dialog.setTitle(ApplicationNamesInfo.getInstance().getFullProductName() + " Privacy Policy Agreement");
dialog.setSize(JBUI.scale(509), JBUI.scale(395));
dialog.show();
}
use of com.intellij.ui.components.JBScrollPane 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.JBScrollPane in project intellij-community by JetBrains.
the class FileDocumentManagerImpl method handleErrorsOnSave.
private void handleErrorsOnSave(@NotNull Map<Document, IOException> failures) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
IOException ioException = ContainerUtil.getFirstItem(failures.values());
if (ioException != null) {
throw new RuntimeException(ioException);
}
return;
}
for (IOException exception : failures.values()) {
LOG.warn(exception);
}
final String text = StringUtil.join(failures.values(), Throwable::getMessage, "\n");
final DialogWrapper dialog = new DialogWrapper(null) {
{
init();
setTitle(UIBundle.message("cannot.save.files.dialog.title"));
}
@Override
protected void createDefaultActions() {
super.createDefaultActions();
myOKAction.putValue(Action.NAME, UIBundle.message(myOnClose ? "cannot.save.files.dialog.ignore.changes" : "cannot.save.files.dialog.revert.changes"));
myOKAction.putValue(DEFAULT_ACTION, null);
if (!myOnClose) {
myCancelAction.putValue(Action.NAME, CommonBundle.getCloseButtonText());
}
}
@Override
protected JComponent createCenterPanel() {
final JPanel panel = new JPanel(new BorderLayout(0, 5));
panel.add(new JLabel(UIBundle.message("cannot.save.files.dialog.message")), BorderLayout.NORTH);
final JTextPane area = new JTextPane();
area.setText(text);
area.setEditable(false);
area.setMinimumSize(new Dimension(area.getMinimumSize().width, 50));
panel.add(new JBScrollPane(area, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER);
return panel;
}
};
if (dialog.showAndGet()) {
for (Document document : failures.keySet()) {
reloadFromDisk(document);
}
}
}
use of com.intellij.ui.components.JBScrollPane in project intellij-community by JetBrains.
the class FocusTracesDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
JPanel panel = new JPanel(new BorderLayout());
JBSplitter splitter = new JBSplitter(true, .5F, .2F, .8F);
splitter.setFirstComponent(new JBScrollPane(myRequestsTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
JComponent consoleComponent = new JPanel(new BorderLayout());
consoleComponent.add(consoleView.getComponent(), BorderLayout.CENTER);
int row = myRequestsTable.getSelectedRow();
if (row >= 0) {
consoleView.print(ExceptionUtil.getThrowableText(myRequests.get(row).trace), ConsoleViewContentType.NORMAL_OUTPUT);
}
splitter.setSecondComponent(new JBScrollPane(consoleComponent, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
panel.add(splitter, BorderLayout.CENTER);
return panel;
}
Aggregations