com.intellij.ui.ColoredListCellRenderer Java Examples

The following examples show how to use com.intellij.ui.ColoredListCellRenderer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlutterLogFilterPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public FlutterLogFilterPanel(@NotNull OnFilterListener onFilterListener) {
  this.onFilterListener = onFilterListener;
  final ItemListener listener = e -> doFilter();
  matchCaseCheckBox.addItemListener(listener);
  regexCheckBox.addItemListener(listener);
  final List<FlutterLog.Level> logLevels = Arrays.stream(FlutterLog.Level.values())
    .collect(Collectors.toList());
  logLevelComboBox.setModel(new CollectionComboBoxModel<>(logLevels));
  logLevelComboBox.setSelectedItem(FlutterLog.Level.NONE);
  logLevelComboBox.addActionListener(event -> doFilter());
  logLevelComboBox.setRenderer(new ColoredListCellRenderer<FlutterLog.Level>() {
    @Override
    protected void customizeCellRenderer(@NotNull JList<? extends FlutterLog.Level> list,
                                         FlutterLog.Level value,
                                         int index,
                                         boolean selected,
                                         boolean hasFocus) {
      // When NONE is selected, show an empty string in the combo selector.
      final String label = index == -1 && value == FlutterLog.Level.NONE ? "" : value.toDisplayString();
      append(label);
    }
  });
}
 
Example #2
Source File: FlutterLogFilterPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public FlutterLogFilterPanel(@NotNull OnFilterListener onFilterListener) {
  this.onFilterListener = onFilterListener;
  final ItemListener listener = e -> doFilter();
  matchCaseCheckBox.addItemListener(listener);
  regexCheckBox.addItemListener(listener);
  final List<FlutterLog.Level> logLevels = Arrays.stream(FlutterLog.Level.values())
    .collect(Collectors.toList());
  logLevelComboBox.setModel(new CollectionComboBoxModel<>(logLevels));
  logLevelComboBox.setSelectedItem(FlutterLog.Level.NONE);
  logLevelComboBox.addActionListener(event -> doFilter());
  logLevelComboBox.setRenderer(new ColoredListCellRenderer<FlutterLog.Level>() {
    @Override
    protected void customizeCellRenderer(@NotNull JList<? extends FlutterLog.Level> list,
                                         FlutterLog.Level value,
                                         int index,
                                         boolean selected,
                                         boolean hasFocus) {
      // When NONE is selected, show an empty string in the combo selector.
      final String label = index == -1 && value == FlutterLog.Level.NONE ? "" : value.toDisplayString();
      append(label);
    }
  });
}
 
Example #3
Source File: ConfigurationSettingsEditor.java    From consulo with Apache License 2.0 6 votes vote down vote up
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);
    }
  });
}
 
Example #4
Source File: GtRepoChooser.java    From GitToolBox with Apache License 2.0 6 votes vote down vote up
GtRepoChooser(@NotNull Project project, @Nullable Component parentComponent) {
  super(project, parentComponent, false, IdeModalityType.PROJECT);
  this.project = project;
  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 = JBUI.Panels.simplePanel().addToCenter(scrollPane);
  centerPanel.setPreferredSize(JBUI.size(400, 300));
  setTitle(ResBundle.message("configurable.prj.autoFetch.exclusions.add.title"));
  init();
}
 
Example #5
Source File: TemplateKindCombo.java    From consulo with Apache License 2.0 6 votes vote down vote up
public TemplateKindCombo() {
  getComboBox().setRenderer(new ColoredListCellRenderer() {
    @Override
    protected void customizeCellRenderer(@Nonnull JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (value instanceof Trinity) {
        append((String)((Trinity)value).first);
        setIcon((Image)((Trinity)value).second);
      }
    }
  });

  new ComboboxSpeedSearch(getComboBox()) {
    @Override
    protected String getElementText(Object element) {
      if (element instanceof Trinity) {
        return (String)((Trinity)element).first;
      }
      return null;
    }
  };
  setButtonListener(null);
}
 
Example #6
Source File: ExpressionInputComponent.java    From consulo with Apache License 2.0 6 votes vote down vote up
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());
  }
}
 
Example #7
Source File: ComboBoxButtonImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
public ComboBoxButtonImpl(ComboBoxAction comboBoxAction, Presentation presentation) {
  myComboBoxAction = comboBoxAction;
  myPresentation = presentation;

  setRenderer(new ColoredListCellRenderer<Object>() {
    @Override
    protected void customizeCellRenderer(@Nonnull JList<?> list, Object value, int index, boolean selected, boolean hasFocus) {
      append(StringUtil.notNullize(myPresentation.getText()));
      setIcon(myPresentation.getIcon());
    }
  });

  // add and select one value
  revalidateValue();
  updateSize();
  updateTooltipText(presentation.getDescription());
}
 
Example #8
Source File: RunConfigurationBeforeRunProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #9
Source File: ColumnFilteringStrategy.java    From consulo with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #10
Source File: SelectFromListDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #11
Source File: LocalToServerSettingsEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
public LocalToServerSettingsEditor(final ServerType<S> type, DeploymentConfigurator<D> deploymentConfigurator, Project project) {
  myServerType = type;
  myDeploymentConfigurator = deploymentConfigurator;
  myProject = project;

   mySourceListModel = new SortedComboBoxModel<DeploymentSource>(new Comparator<DeploymentSource>() {
    @Override
    public int compare(DeploymentSource o1, DeploymentSource o2) {
      return o1.getPresentableName().compareToIgnoreCase(o2.getPresentableName());
    }
  });
  mySourceListModel.addAll(deploymentConfigurator.getAvailableDeploymentSources());
  mySourceComboBox = new ComboBox(mySourceListModel);
  mySourceComboBox.setRenderer(new ColoredListCellRenderer<DeploymentSource>() {
    @Override
    protected void customizeCellRenderer(@Nonnull JList list, DeploymentSource value, int index, boolean selected, boolean hasFocus) {
      if (value == null) return;
      setIcon(value.getIcon());
      append(value.getPresentableName());
    }
  });

  myDeploymentSettingsComponent = new JPanel(new BorderLayout());
  mySourceComboBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      onDeploymentSourceChanged(null);
    }
  });
}
 
Example #12
Source File: DesktopComboBoxImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public DesktopComboBoxImpl(ListModel<E> model) {
  DesktopComboBoxModelWrapper wrapper = new DesktopComboBoxModelWrapper<>(model);
  myModel = model;

  myComponent = new MyComboBoxWithWidePopup();
  myComponent.setModel(wrapper);
  myComponent.setRenderer(new ColoredListCellRenderer<E>() {
    @Override
    protected void customizeCellRenderer(@Nonnull JList<? extends E> list, E value, int index, boolean selected, boolean hasFocus) {
      DesktopItemPresentationImpl<E> render = new DesktopItemPresentationImpl<>(this);
      myRender.render(render, index, value);
    }
  });
}
 
Example #13
Source File: SelectDatabaseVendorDialog.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
private void initCombobox() {

        databaseVendorCombobox.setModel(new DefaultComboBoxModel(DatabaseVendor.values()));
        databaseVendorCombobox.setRenderer(new ColoredListCellRenderer() {
            @Override
            protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
                DatabaseVendor databaseVendor = (DatabaseVendor) value;
                setIcon(databaseVendor.icon);
                append(databaseVendor.name);
            }
        });

        databaseVendorCombobox.setSelectedItem(DatabaseVendor.MONGO);
    }
 
Example #14
Source File: AbstractAddDialog.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
void initCombo(final ComboBox combobox, final JPanel parentPanel) {
    combobox.setModel(new DefaultComboBoxModel(JsonDataType.values()));
    combobox.setRenderer(new ColoredListCellRenderer() {

        @Override
        protected void customizeCellRenderer(JList jList, Object o, int i, boolean b, boolean b2) {
            append(((JsonDataType) o).type);
        }
    });

    combobox.setSelectedItem(null);
    combobox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent itemEvent) {
            JsonDataType selectedType = (JsonDataType) combobox.getSelectedItem();
            currentEditor = UI_COMPONENT_BY_JSON_DATATYPE.get(selectedType);
            currentEditor.reset();

            parentPanel.invalidate();
            parentPanel.removeAll();
            parentPanel.add(currentEditor.getComponent(), BorderLayout.CENTER);
            parentPanel.validate();
        }
    });

    combobox.setSelectedItem(JsonDataType.STRING);
}
 
Example #15
Source File: DesktopListBoxImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public DesktopListBoxImpl(ListModel<E> model) {
  myModel = model;
  DesktopComboBoxModelWrapper<E> wrapper = new DesktopComboBoxModelWrapper<>(model);

  myComponent = new MyJBList<>(wrapper);
  myComponent.setCellRenderer(new ColoredListCellRenderer<E>() {
    @Override
    protected void customizeCellRenderer(@Nonnull JList<? extends E> list, E value, int index, boolean selected, boolean hasFocus) {
      DesktopItemPresentationImpl<E> render = new DesktopItemPresentationImpl<>(this);
      myRender.render(render, index, value);
    }
  });
}
 
Example #16
Source File: QuarkusModuleInfoStep.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void _init() {
    ProgressIndicator indicator = new EmptyProgressIndicator() {
        @Override
        public void setText(String text) {
            SwingUtilities.invokeLater(() -> panel.setLoadingText(text));
        }
    };
    try {
        QuarkusModel model = QuarkusModelRegistry.INSTANCE.load(context.getUserData(QuarkusConstants.WIZARD_ENDPOINT_URL_KEY), indicator);
        context.putUserData(QuarkusConstants.WIZARD_MODEL_KEY, model);
        final FormBuilder formBuilder = new FormBuilder();
        final CollectionComboBoxModel<ToolDelegate> toolModel = new CollectionComboBoxModel<>(Arrays.asList(ToolDelegate.getDelegates()));
        toolComboBox = new ComboBox<>(toolModel);
        toolComboBox.setRenderer(new ColoredListCellRenderer<ToolDelegate>() {
            @Override
            protected void customizeCellRenderer(@NotNull JList<? extends ToolDelegate> list, ToolDelegate toolDelegate, int index, boolean selected, boolean hasFocus) {
                this.append(toolDelegate.getDisplay());
            }
        });
        formBuilder.addLabeledComponent("Tool:", toolComboBox);
        groupIdField = new JBTextField("org.acme");
        formBuilder.addLabeledComponent("Group:", groupIdField);
        artifactIdField = new JBTextField("code-with-quarkus");
        formBuilder.addLabeledComponent("Artifact:", artifactIdField);
        versionField = new JBTextField("1.0.0-SNAPSHOT");
        formBuilder.addLabeledComponent("Version:", versionField);
        classNameField = new JBTextField("org.acme.ExampleResource");
        formBuilder.addLabeledComponent("Class name:", classNameField);
        pathField = new JBTextField("/hello");
        formBuilder.addLabeledComponent("Path:", pathField);
        panel.add(ScrollPaneFactory.createScrollPane(formBuilder.getPanel(), true), "North");
    } catch (IOException e) {
        LOGGER.error(e.getLocalizedMessage(), e);
        throw new RuntimeException(e);
    }
}
 
Example #17
Source File: GotoFileCellRenderer.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean customizeNonPsiElementLeftRenderer(ColoredListCellRenderer renderer, JList list, Object value, int index, boolean selected, boolean hasFocus) {
  return doCustomizeNonPsiElementLeftRenderer(renderer, list, value, getNavigationItemAttributes(value));
}
 
Example #18
Source File: PsiElementListCellRenderer.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected boolean customizeNonPsiElementLeftRenderer(ColoredListCellRenderer renderer, JList list, Object value, int index, boolean selected, boolean hasFocus) {
  return false;
}
 
Example #19
Source File: SearchEverywherePsiRenderer.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean customizeNonPsiElementLeftRenderer(ColoredListCellRenderer renderer, JList list, Object value, int index, boolean selected, boolean hasFocus) {
  return GotoFileCellRenderer.doCustomizeNonPsiElementLeftRenderer(renderer, list, value, getNavigationItemAttributes(value));
}
 
Example #20
Source File: DesktopItemPresentationImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public DesktopItemPresentationImpl(ColoredListCellRenderer<E> renderer) {
  myRenderer = renderer;
}
 
Example #21
Source File: BreakpointItem.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void setupRenderer(ColoredListCellRenderer renderer, Project project, boolean selected) {
  setupGenericRenderer(renderer, true);
}
 
Example #22
Source File: XBreakpointItem.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void setupRenderer(ColoredListCellRenderer renderer, Project project, boolean selected) {
  setupGenericRenderer(renderer, true);
}
 
Example #23
Source File: SplitterItem.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void setupRenderer(ColoredListCellRenderer renderer, Project project, boolean selected) {
  //To change body of implemented methods use File | Settings | File Templates.
}
 
Example #24
Source File: CSharpSetupStep.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
public CSharpSetupStep(CSharpNewModuleContext context)
{
	super(context);

	JPanel panel = new JPanel(new VerticalFlowLayout());

	myTargetComboBox = new ComboBox<>(DotNetTarget.values());
	myTargetComboBox.setRenderer(new ColoredListCellRenderer<DotNetTarget>()
	{
		@Override
		protected void customizeCellRenderer(@Nonnull JList<? extends DotNetTarget> jList, DotNetTarget target, int i, boolean b, boolean b1)
		{
			append(target.getDescription());
		}
	});
	myTargetComboBox.addItemListener(e -> {
		if(e.getStateChange() == ItemEvent.SELECTED)
		{
			context.setTarget((DotNetTarget) myTargetComboBox.getSelectedItem());
		}
	});

	panel.add(myTargetComponent = LabeledComponent.create(myTargetComboBox, "Target"));

	List<String> validSdkTypes = new SmartList<>();
	for(Map.Entry<String, String[]> entry : CSharpNewModuleBuilder.ourExtensionMapping.entrySet())
	{
		// need check C# extension
		ModuleExtensionProviderEP providerEP = ModuleExtensionProviders.findProvider(entry.getValue()[1]);
		if(providerEP == null)
		{
			continue;
		}
		validSdkTypes.add(entry.getKey());
	}

	myComboBox = new SdkComboBox(SdkTable.getInstance(), sdkTypeId -> validSdkTypes.contains(sdkTypeId.getName()), false);
	myComboBox.addItemListener(e -> {
		if(e.getStateChange() == ItemEvent.SELECTED)
		{
			context.setSdk(myComboBox.getSelectedSdk());
		}
	});
	context.setSdk(myComboBox.getSelectedSdk());

	panel.add(LabeledComponent.create(myComboBox, ".NET SDK"));

	myAdditionalContentPanel.add(panel, BorderLayout.NORTH);
}
 
Example #25
Source File: ItemWrapper.java    From consulo with Apache License 2.0 votes vote down vote up
public abstract void setupRenderer(ColoredListCellRenderer renderer, Project project, boolean selected); 
Example #26
Source File: UnityListViewRender.java    From consulo-unity3d with Apache License 2.0 votes vote down vote up
protected abstract ColoredListCellRenderer<UnityAssetWrapper> createRight(); 
Example #27
Source File: UnityListViewRender.java    From consulo-unity3d with Apache License 2.0 votes vote down vote up
protected abstract ColoredListCellRenderer<UnityAssetWrapper> createLeft();