use of com.intellij.ui.components.JBLabel in project android by JetBrains.
the class UIUtils method getHtml.
/**
* Gets valid/consistent html markup for use in Swing component display.
* NOTE: Use {@code setHtml} when working with editors.
*
* @param content The html body content, excluding the <body></body> tags.
* @param css Extra css to add. Example ".testClass { color: red}\n.anotherClass { border: 1px solid blue}".
* @param headContent Extra header content to add. Example "<title>My Favorite!!</title>".
*/
public static String getHtml(@NotNull String content, @Nullable /*not required*/
String css, @Nullable /*not required*/
String headContent) {
// Use the label font as the default for markup so that it appears more consistent with non-html elements.
// TODO: Determine if the label font is the ideal font choice.
Font defaultFont = new JBLabel().getFont();
// NOTE: HTMLBuilder has poor support for granular/structured css and header manipulation. The rest of its methods are just a more
// verbose way of emitting string constants like "<html>" which isn't useful. Opting to directly manipulate markup instead.
// See https://docs.oracle.com/javase/8/docs/api/javax/swing/text/html/CSS.html for supported css.
// Summary of changes:
// * Use standard label font family so this is more in sync with labels and text based panels.
// * Defeat default list item treatment. It's hard coded in ListView as a poorly rendered 8px disc + large margins.
// * Add bottom margins to list items for legibility.
// * Colorizes <code>, resets the font size and uses a more legible monospace if available.
String text = "<html><head><style>body { font-family: " + defaultFont.getFamily() + "; margin: 0px; } " + "ol {margin: 0 0 0 20px; } ul {list-style-type: circle; margin: 0 0 0 20px; } " + "li {margin: 0 0 10px 10px; } " + "code { font-family: 'Roboto Mono', 'Courier New', monospace; color: " + getCssColor(CODE_COLOR) + "; font-size: 1em; }" + // in that event and accommodate the size change in your document.
".as-shim { margin: 0 0 0 0; }";
if (css != null) {
text += "\n" + css;
}
text += "</style>";
if (headContent != null) {
text += "\n" + headContent;
}
text += "</head><body><div class=\"as-shim\">" + content + "</div></body></html>";
return text;
}
use of com.intellij.ui.components.JBLabel in project android by JetBrains.
the class FormFactorUtilsTest method formFactorsImage.
@Test
public void formFactorsImage() {
JBLabel jLabel = new JBLabel();
Icon withEmulatorIcons = FormFactorUtils.getFormFactorsImage(jLabel, true);
Icon allIcons = FormFactorUtils.getFormFactorsImage(jLabel, false);
assertNotNull(withEmulatorIcons);
assertNotNull(allIcons);
// Note: When running unit tests, it will not load the real images, each icon uses a 1x1 pixel size
assertTrue(allIcons.getIconWidth() >= withEmulatorIcons.getIconWidth());
}
use of com.intellij.ui.components.JBLabel in project intellij-plugins by JetBrains.
the class PhoneGapConfigurable method createComponent.
@Nullable
@Override
public JComponent createComponent() {
if (myWrapper == null) {
myExecutablePath = PhoneGapUtil.createPhoneGapExecutableTextField(myProject);
myWorkingDirectory = PhoneGapUtil.createPhoneGapWorkingDirectoryField(myProject);
myVersion = new JBLabel();
myUIController = new UIController();
myExcludePlatformsCheckBox = new JCheckBox(PhoneGapBundle.message("phonegap.conf.exclude.platforms"));
myRepositoryStore = new RepositoryStore();
myUIController.reset(mySettings.getState());
phoneGapPluginsView = new PhoneGapPluginsView(myProject);
JPanel panel = FormBuilder.createFormBuilder().addLabeledComponent(PhoneGapBundle.message("phonegap.conf.executable.name"), myExecutablePath).addLabeledComponent(PhoneGapBundle.message("phonegap.conf.version.name"), myVersion).addLabeledComponent(PhoneGapBundle.message("phonegap.conf.work.dir.name"), myWorkingDirectory).addComponent(myExcludePlatformsCheckBox).addComponent(phoneGapPluginsView.getPanel()).getPanel();
myWrapper = new JPanel(new BorderLayout());
myWrapper.add(panel, BorderLayout.NORTH);
setupListeners();
phoneGapPluginsView.setupService(myExecutablePath.getText(), myWorkingDirectory.getText(), myRepositoryStore, getVersionCallback());
}
return myWrapper;
}
use of com.intellij.ui.components.JBLabel in project intellij-leiningen-plugin by derkork.
the class LeiningenSettings method createComponent.
public JComponent createComponent() {
JPanel outerPanel = new JPanel(new BorderLayout());
JPanel leinPanel = new JPanel(new FormLayout("80dlu, fill:80dlu:grow, 20dlu, 80dlu", "p,p,p"));
CellConstraints c = new CellConstraints();
int row = 1;
leinPanel.add(new JBLabel("Leiningen executable:"), c.xy(1, row));
this.leinBinSelectorField = new TextFieldWithBrowseButton();
leinBinSelectorField.addBrowseFolderListener("Select the Leiningen executable", "'lein' on Linux/MacOS, 'lein.bat' on Windows. ", null, new FileChooserDescriptor(true, false, false, false, false, false));
leinPanel.add(leinBinSelectorField, c.xy(2, row));
row++;
leinPanel.add(new JBLabel("Leiningen Home:"), c.xy(1, row));
this.leinHomeSelectorField = new TextFieldWithBrowseButton();
leinHomeSelectorField.addBrowseFolderListener("Select the Leiningen home directory", "usually at $USER_HOME/.lein", null, new FileChooserDescriptor(false, true, false, false, false, false));
leinPanel.add(leinHomeSelectorField, c.xy(2, row));
this.overrideLeinHome = new JBCheckBox();
leinPanel.add(overrideLeinHome, c.xy(3, row));
leinPanel.add(new JBLabel("Override"), c.xy(4, row));
row++;
leinPanel.add(new JBLabel("Leiningen Jar:"), c.xy(1, row));
this.leinJarSelectorField = new TextFieldWithBrowseButton();
leinJarSelectorField.addBrowseFolderListener("Select the Leiningen Jar", "usually at $USER_HOME/.lein/self-installs/leinigen-VERSION-standalone.jar", null, new FileChooserDescriptor(true, false, true, true, false, false));
leinPanel.add(leinJarSelectorField, c.xy(2, row));
this.overrideLeinJar = new JBCheckBox();
leinPanel.add(overrideLeinJar, c.xy(3, row));
leinPanel.add(new JBLabel("Override"), c.xy(4, row));
outerPanel.add(leinPanel, BorderLayout.NORTH);
myWatcher = new UserActivityWatcher();
myWatcher.register(outerPanel);
myWatcher.addUserActivityListener(new UserActivityListener() {
public void stateChanged() {
changed = true;
leinJarSelectorField.setEnabled(overrideLeinJar.isSelected());
leinHomeSelectorField.setEnabled(overrideLeinHome.isSelected());
}
});
return outerPanel;
}
use of com.intellij.ui.components.JBLabel in project buck by facebook.
the class DetailNodeRenderer method render.
@Override
public Component render(Object value) {
BuckTreeNodeDetail node = (BuckTreeNodeDetail) value;
Icon icon = AllIcons.Ide.Info_notifications;
if (node.getType() == BuckTreeNodeDetail.DetailType.ERROR) {
icon = AllIcons.Ide.Error;
} else if (node.getType() == BuckTreeNodeDetail.DetailType.WARNING) {
icon = AllIcons.Ide.Warning_notifications;
}
String message = "<html><pre style='margin:0px'>" + HtmlEscapers.htmlEscaper().escape(node.getDetail()) + "</pre></html>";
JBLabel result = new JBLabel(message, icon, SwingConstants.HORIZONTAL);
result.setToolTipText("<pre>" + node.getDetail() + "</pre>");
return result;
}
Aggregations