本文整理汇总了Java中com.intellij.ui.ColoredListCellRenderer类的典型用法代码示例。如果您正苦于以下问题:Java ColoredListCellRenderer类的具体用法?Java ColoredListCellRenderer怎么用?Java ColoredListCellRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ColoredListCellRenderer类属于com.intellij.ui包,在下文中一共展示了ColoredListCellRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showHistory
import com.intellij.ui.ColoredListCellRenderer; //导入依赖的package包/类
private void showHistory() {
List<XExpression> expressions = myExpressionEditor.getRecentExpressions();
if (!expressions.isEmpty()) {
ListPopupImpl popup = new ListPopupImpl(new BaseListPopupStep<XExpression>(null, expressions) {
@Override
public PopupStep onChosen(XExpression selectedValue, boolean finalChoice) {
myExpressionEditor.setExpression(selectedValue);
myExpressionEditor.requestFocusInEditor();
return FINAL_CHOICE;
}
}) {
@Override
protected ListCellRenderer getListElementRenderer() {
return new ColoredListCellRenderer<XExpression>() {
@Override
protected void customizeCellRenderer(JList list, XExpression value, int index, boolean selected, boolean hasFocus) {
append(value.getExpression());
}
};
}
};
popup.getList().setFont(EditorUtil.getEditorFont());
popup.showUnderneathOf(myExpressionEditor.getEditorComponent());
}
}
示例2: RunnersEditorComponent
import com.intellij.ui.ColoredListCellRenderer; //导入依赖的package包/类
public RunnersEditorComponent() {
myRunnerPanel.setLayout(myLayout);
myRunnerPanel.add(myNoRunner, NO_RUNNER_COMPONENT);
myRunnersList.setModel(myListModel);
myRunnersList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
updateRunnerComponent();
}
});
updateRunnerComponent();
myRunnersList.setCellRenderer(new ColoredListCellRenderer() {
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
Executor executor = (Executor)value;
setIcon(executor.getIcon());
append(executor.getId(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
});
}
示例3: renderItem
import com.intellij.ui.ColoredListCellRenderer; //导入依赖的package包/类
@Override
public void renderItem(ColoredListCellRenderer renderer) {
if (myFrameworkType != null) {
renderer.setIcon(myFrameworkType.getIcon());
renderer.append(myFrameworkType.getPresentableName());
if (myFile != null) {
renderer.append(" in " + myFile.getName());
renderer.append(" (" + myFile.getPresentableUrl() + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
}
}
else {
renderer.setIcon(VirtualFilePresentation.getIcon(myFile));
renderer.append(myFile.getName());
renderer.append(" (" + myFile.getPresentableUrl() + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
}
}
示例4: GtRepoChooser
import com.intellij.ui.ColoredListCellRenderer; //导入依赖的package包/类
GtRepoChooser(@NotNull Project project, @Nullable Component parentComponent) {
super(project, parentComponent, false, IdeModalityType.PROJECT);
this.project = project;
centerPanel = new JPanel(new BorderLayout());
repoList = new JBList<>();
repoList.setCellRenderer(new ColoredListCellRenderer<GitRepository>() {
@Override
protected void customizeCellRenderer(@NotNull JList<? extends GitRepository> list, GitRepository value, int index,
boolean selected, boolean hasFocus) {
append(GtUtil.name(value));
StringBand url = new StringBand(" (");
url.append(value.getRoot().getPresentableUrl());
url.append(")");
append(url.toString(), SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
});
JBScrollPane scrollPane = new JBScrollPane(repoList);
centerPanel.add(scrollPane, BorderLayout.CENTER);
setTitle(ResBundle.getString("configurable.prj.autoFetch.exclusions.add.title"));
init();
}
示例5: showHistory
import com.intellij.ui.ColoredListCellRenderer; //导入依赖的package包/类
private void showHistory() {
List<XExpression> expressions = myExpressionEditor.getRecentExpressions();
if (!expressions.isEmpty()) {
ListPopupImpl popup = new ListPopupImpl(new BaseListPopupStep<XExpression>(null, expressions) {
@Override
public PopupStep onChosen(XExpression selectedValue, boolean finalChoice) {
myExpressionEditor.setExpression(selectedValue);
myExpressionEditor.requestFocusInEditor();
return FINAL_CHOICE;
}
}) {
@Override
protected ListCellRenderer getListElementRenderer() {
return new ColoredListCellRenderer<XExpression>() {
@Override
protected void customizeCellRenderer(@Nonnull JList list, XExpression value, int index, boolean selected, boolean hasFocus) {
append(value.getExpression());
}
};
}
};
popup.getList().setFont(EditorUtil.getEditorFont());
popup.showUnderneathOf(myExpressionEditor.getEditorComponent());
}
}
示例6: SelectFromListDialog
import com.intellij.ui.ColoredListCellRenderer; //导入依赖的package包/类
public SelectFromListDialog(Project project,
Object[] objects,
ToStringAspect toStringAspect,
String title,
@JdkConstants.ListSelectionMode int selectionMode) {
super(project, true);
myToStringAspect = toStringAspect;
myList.setSelectionMode(selectionMode);
setTitle(title);
for (Object object : objects) {
myModel.addElement(object);
}
myList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
setOKActionEnabled(myList.getSelectedValues().length > 0);
}
});
myList.setSelectedIndex(0);
myList.setCellRenderer(new ColoredListCellRenderer(){
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
append(myToStringAspect.getToStirng(value),
new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, list.getForeground()));
}
});
init();
}
示例7: ColumnFilteringStrategy
import com.intellij.ui.ColoredListCellRenderer; //导入依赖的package包/类
public ColumnFilteringStrategy(final ChangeListColumn column,
final Class<? extends CommittedChangesProvider> providerClass) {
myModel = new MyListModel();
myValueList = new JBList();
myScrollPane = ScrollPaneFactory.createScrollPane(myValueList);
myValueList.setModel(myModel);
myValueList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(final ListSelectionEvent e) {
for (ChangeListener listener : myListeners) {
listener.stateChanged(new ChangeEvent(this));
}
}
});
myValueList.setCellRenderer(new ColoredListCellRenderer() {
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (index == 0) {
append(value.toString(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
}
else if (value.toString().length() == 0) {
append(VcsBundle.message("committed.changes.filter.none"), SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
else {
append(value.toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
}
});
myColumn = column;
myProviderClass = providerClass;
}
示例8: createCenterPanel
import com.intellij.ui.ColoredListCellRenderer; //导入依赖的package包/类
@Override
protected JComponent createCenterPanel() {
myJBList = new JBList(mySettings);
myJBList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myJBList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
Object selectedValue = myJBList.getSelectedValue();
if (selectedValue instanceof RunnerAndConfigurationSettings) {
mySelectedSettings = (RunnerAndConfigurationSettings)selectedValue;
}
else {
mySelectedSettings = null;
}
setOKActionEnabled(mySelectedSettings != null);
}
});
myJBList.setCellRenderer(new ColoredListCellRenderer() {
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof RunnerAndConfigurationSettings) {
RunnerAndConfigurationSettings settings = (RunnerAndConfigurationSettings)value;
RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
setIcon(runManager.getConfigurationIcon(settings));
RunConfiguration configuration = settings.getConfiguration();
append(configuration.getName(), settings.isTemporary()
? SimpleTextAttributes.GRAY_ATTRIBUTES
: SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
}
});
return new JBScrollPane(myJBList);
}
示例9: customizeNonPsiElementLeftRenderer
import com.intellij.ui.ColoredListCellRenderer; //导入依赖的package包/类
@Override
protected boolean customizeNonPsiElementLeftRenderer(ColoredListCellRenderer renderer,
JList list,
Object value,
int index,
boolean selected,
boolean hasFocus) {
if (!(value instanceof NavigationItem)) return false;
NavigationItem item = (NavigationItem)value;
TextAttributes attributes = getNavigationItemAttributes(item);
SimpleTextAttributes nameAttributes = attributes != null ? SimpleTextAttributes.fromTextAttributes(attributes) : null;
Color color = list.getForeground();
if (nameAttributes == null) nameAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, color);
renderer.append(item + " ", nameAttributes);
ItemPresentation itemPresentation = item.getPresentation();
assert itemPresentation != null;
renderer.setIcon(itemPresentation.getIcon(true));
String locationString = itemPresentation.getLocationString();
if (!StringUtil.isEmpty(locationString)) {
renderer.append(locationString, new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, JBColor.GRAY));
}
return true;
}
示例10: customizeNonPsiElementLeftRenderer
import com.intellij.ui.ColoredListCellRenderer; //导入依赖的package包/类
@Override
protected boolean customizeNonPsiElementLeftRenderer(ColoredListCellRenderer renderer,
JList list,
Object value,
int index,
boolean selected,
boolean hasFocus) {
if (!(value instanceof NavigationItem)) return false;
NavigationItem item = (NavigationItem)value;
TextAttributes attributes = getNavigationItemAttributes(item);
SimpleTextAttributes nameAttributes = attributes != null ? SimpleTextAttributes.fromTextAttributes(attributes) : null;
Color color = list.getForeground();
if (nameAttributes == null) nameAttributes = new SimpleTextAttributes(Font.PLAIN, color);
renderer.append(item + " ", nameAttributes);
ItemPresentation itemPresentation = item.getPresentation();
assert itemPresentation != null;
renderer.setIcon(itemPresentation.getIcon(true));
String locationString = itemPresentation.getLocationString();
if (!StringUtil.isEmpty(locationString)) {
renderer.append(locationString, new SimpleTextAttributes(Font.PLAIN, JBColor.GRAY));
}
return true;
}
示例11: renderItem
import com.intellij.ui.ColoredListCellRenderer; //导入依赖的package包/类
@Override
public void renderItem(ColoredListCellRenderer renderer) {
if (myFrameworkTypeId != null) {
renderer.append(myFrameworkTypeId, SimpleTextAttributes.ERROR_ATTRIBUTES);
if (myFileUrl != null) {
renderer.append(" in " + myFileUrl, SimpleTextAttributes.ERROR_ATTRIBUTES);
}
}
else {
renderer.append(myFileUrl, SimpleTextAttributes.ERROR_ATTRIBUTES);
}
renderer.setIcon(EmptyIcon.ICON_16);
}
示例12: getLanguageCodeCellRenderer
import com.intellij.ui.ColoredListCellRenderer; //导入依赖的package包/类
/** Returns a {@link ListCellRenderer} suitable for displaying languages when the list model contains String language codes */
@NotNull
public ListCellRenderer getLanguageCodeCellRenderer() {
final Function<Object, String> nameMapper = getLanguageNameMapper();
return new ColoredListCellRenderer() {
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
append(nameMapper.fun(value));
setIcon(getFlag((String)value, null));
}
};
}
示例13: getRegionCodeCellRenderer
import com.intellij.ui.ColoredListCellRenderer; //导入依赖的package包/类
/** Returns a {@link ListCellRenderer} suitable for displaying regions when the list model contains String region codes */
@NotNull
public ListCellRenderer getRegionCodeCellRenderer() {
final Function<Object, String> nameMapper = getRegionNameMapper();
return new ColoredListCellRenderer() {
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
append(nameMapper.fun(value));
setIcon(getFlag(null, (String)value));
}
};
}
示例14: setTrace
import com.intellij.ui.ColoredListCellRenderer; //导入依赖的package包/类
public void setTrace(@NotNull VmTraceData trace) {
myTraceData = trace;
List<ThreadInfo> threads = trace.getThreads(true);
if (threads.isEmpty()) {
return;
}
ThreadInfo defaultThread = Iterables.find(threads, new Predicate<ThreadInfo>() {
@Override
public boolean apply(ThreadInfo input) {
return MAIN_THREAD_NAME.equals(input.getName());
}
}, threads.get(0));
myTraceViewCanvas.setTrace(trace, defaultThread, getCurrentRenderClock());
myThreadCombo.setModel(new DefaultComboBoxModel(threads.toArray()));
myThreadCombo.setSelectedItem(defaultThread);
myThreadCombo.setRenderer(new ColoredListCellRenderer() {
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
String name = value instanceof ThreadInfo ? ((ThreadInfo)value).getName() : value.toString();
append(name);
}
});
myThreadCombo.setEnabled(true);
myRenderClockSelectorCombo.setEnabled(true);
myVmStatsTreeTableModel.setTraceData(trace, defaultThread);
myVmStatsTreeTableModel.setClockType(getCurrentRenderClock());
myTreeTable.setModel(myVmStatsTreeTableModel);
VmStatsTreeUtils.adjustTableColumnWidths(myTreeTable);
VmStatsTreeUtils.setCellRenderers(myTreeTable);
VmStatsTreeUtils.setSpeedSearch(myTreeTable);
VmStatsTreeUtils.enableSorting(myTreeTable, myVmStatsTreeTableModel);
}
示例15: customizeCellRenderer
import com.intellij.ui.ColoredListCellRenderer; //导入依赖的package包/类
public void customizeCellRenderer(ColoredListCellRenderer cellRenderer, boolean selected, boolean hasFocus) {
cellRenderer.setIcon(getSmallIcon());
if (myAnyComponent) {
cellRenderer.append(UIDesignerBundle.message("palette.non.palette.component"), SimpleTextAttributes.REGULAR_ATTRIBUTES);
cellRenderer.setToolTipText(UIDesignerBundle.message("palette.non.palette.component.tooltip"));
}
else {
cellRenderer.append(getClassShortName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
cellRenderer.setToolTipText(getToolTipText());
}
}