本文整理匯總了Java中com.intellij.util.ui.UIUtil.changeBackGround方法的典型用法代碼示例。如果您正苦於以下問題:Java UIUtil.changeBackGround方法的具體用法?Java UIUtil.changeBackGround怎麽用?Java UIUtil.changeBackGround使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.util.ui.UIUtil
的用法示例。
在下文中一共展示了UIUtil.changeBackGround方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: customizeCellRenderer
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
protected void customizeCellRenderer(@NotNull JList list, Object value, int index, boolean selected, boolean hasFocus) {
setIcon(getListEntryIcon(myAllContents.get(index)));
if (myUseIdeaEditor) {
int max = list.getModel().getSize();
String indexString = String.valueOf(index + 1);
int count = String.valueOf(max).length() - indexString.length();
char[] spaces = new char[count];
Arrays.fill(spaces, ' ');
String prefix = indexString + new String(spaces) + " ";
append(prefix, SimpleTextAttributes.GRAYED_ATTRIBUTES);
} else if (UIUtil.isUnderGTKLookAndFeel()) {
// Fix GTK background
Color background = selected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground();
UIUtil.changeBackGround(this, background);
}
String text = ((Item) value).shortText;
FontMetrics metrics = list.getFontMetrics(list.getFont());
int charWidth = metrics.charWidth('m');
int maxLength = list.getParent().getParent().getWidth() * 3 / charWidth / 2;
text = StringUtil.first(text, maxLength, true); // do not paint long strings
append(text, SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
示例2: customizeCellRenderer
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
setIcon(myListEntryIcon);
if (myUseIdeaEditor) {
int max = list.getModel().getSize();
String indexString = String.valueOf(index + 1);
int count = String.valueOf(max).length() - indexString.length();
char[] spaces = new char[count];
Arrays.fill(spaces, ' ');
String prefix = indexString + new String(spaces) + " ";
append(prefix, SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
else if (UIUtil.isUnderGTKLookAndFeel()) {
// Fix GTK background
Color background = selected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground();
UIUtil.changeBackGround(this, background);
}
String text = ((Item)value).shortText;
FontMetrics metrics = list.getFontMetrics(list.getFont());
int charWidth = metrics.charWidth('m');
int maxLength = list.getParent().getParent().getWidth() * 3 / charWidth / 2;
text = StringUtil.first(text, maxLength, true); // do not paint long strings
append(text, SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
示例3: customizeCellRenderer
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (UIUtil.isUnderGTKLookAndFeel()) {
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
UIUtil.changeBackGround(this, background);
}
IgnoredFileBean bean = (IgnoredFileBean)value;
final String path = bean.getPath();
if (path != null) {
if (path.endsWith("/")) {
append(VcsBundle.message("ignored.configure.item.directory", path), SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
else {
append(VcsBundle.message("ignored.configure.item.file", path), SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
}
else if (bean.getMask() != null) {
append(VcsBundle.message("ignored.configure.item.mask", bean.getMask()), SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
}
示例4: getTreeCellRendererComponent
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public final Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
invalidate();
if (value instanceof CheckedTreeNode) {
CheckedTreeNode node = (CheckedTreeNode)value;
NodeState state = getNodeStatus(node);
myCheckbox.setVisible(true);
myCheckbox.setSelected(state != NodeState.CLEAR);
myCheckbox.setEnabled(node.isEnabled() && state != NodeState.PARTIAL);
myCheckbox.setOpaque(false);
myCheckbox.setBackground(null);
setBackground(null);
}
else {
myCheckbox.setVisible(false);
}
myTextRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if (UIUtil.isUnderGTKLookAndFeel()) {
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
UIUtil.changeBackGround(this, background);
}
else if (UIUtil.isUnderNimbusLookAndFeel()) {
UIUtil.changeBackGround(this, UIUtil.TRANSPARENT_COLOR);
}
customizeRenderer(tree, value, selected, expanded, leaf, row, hasFocus);
revalidate();
return this;
}
示例5: customizeCellRenderer
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
protected void customizeCellRenderer(final JList list,
final Object value,
final int index,
final boolean selected,
final boolean hasFocus) {
// Fix GTK background
if (UIUtil.isUnderGTKLookAndFeel()){
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
UIUtil.changeBackGround(this, background);
}
if (value == null) {
append(XDebuggerBundle.message("stack.frame.loading.text"), SimpleTextAttributes.GRAY_ATTRIBUTES);
return;
}
if (value instanceof String) {
append((String)value, SimpleTextAttributes.ERROR_ATTRIBUTES);
return;
}
XStackFrame stackFrame = (XStackFrame)value;
if (!selected) {
XSourcePosition position = stackFrame.getSourcePosition();
if (position != null) {
final VirtualFile virtualFile = position.getFile();
if (virtualFile.isValid()) {
Color c = myColorsManager.getFileColor(virtualFile);
if (c != null) setBackground(c);
}
}
}
stackFrame.customizePresentation(this);
}
示例6: getTreeCellRendererComponent
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
public final Component getTreeCellRendererComponent(JTree tree,
Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {
if (!(value instanceof UpdaterTreeNode)) {
return null;
}
UpdaterTreeNode node = (UpdaterTreeNode)value;
invalidate();
myCheckbox.setVisible(true);
if (node.getCurrentState() == NodeStateHolder.SelectedState.MIXED) {
myCheckbox.setState(ThreeStateCheckBox.State.DONT_CARE);
}
else {
myCheckbox.setSelected(node.getCurrentState() == NodeStateHolder.SelectedState.INSTALLED);
}
myCheckbox.setOpaque(false);
myCheckbox.setBackground(null);
setBackground(null);
myTextRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if (UIUtil.isUnderGTKLookAndFeel()) {
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
UIUtil.changeBackGround(this, background);
}
else if (UIUtil.isUnderNimbusLookAndFeel()) {
UIUtil.changeBackGround(this, UIUtil.TRANSPARENT_COLOR);
}
node.customizeRenderer(this, tree, selected, expanded, leaf, row, hasFocus);
revalidate();
return this;
}
示例7: initTree
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
private void initTree() {
myTree = new CheckboxTree(new CheckboxTree.CheckboxTreeCellRenderer(true) {
@Override
public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
if (!(value instanceof CheckedTreeNode)) return;
CheckedTreeNode node = (CheckedTreeNode)value;
SimpleTextAttributes attributes = node.getUserObject() instanceof IntentionActionMetaData ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
final String text = getNodeText(node);
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
UIUtil.changeBackGround(this, background);
if (text != null) {
SearchUtil.appendFragments(myFilter != null ? myFilter.getFilter() : null,
text,
attributes.getStyle(),
attributes.getFgColor(),
background,
getTextRenderer());
}
}
}, new CheckedTreeNode(null));
myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
TreePath path = e.getPath();
Object userObject = ((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject();
selectionChanged(userObject);
}
});
myFilter = new MyFilterComponent();
myComponent = new JPanel(new BorderLayout());
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
myNorthPanel = new JPanel(new BorderLayout());
myNorthPanel.add(myFilter, BorderLayout.CENTER);
final DefaultActionGroup group = new DefaultActionGroup();
final CommonActionsManager actionManager = CommonActionsManager.getInstance();
final DefaultTreeExpander treeExpander = new DefaultTreeExpander(myTree);
group.add(actionManager.createExpandAllAction(treeExpander, myTree));
group.add(actionManager.createCollapseAllAction(treeExpander, myTree));
myNorthPanel.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent(), BorderLayout.WEST);
myComponent.add(myNorthPanel, BorderLayout.NORTH);
myComponent.add(scrollPane, BorderLayout.CENTER);
myFilter.reset();
}