Java Code Examples for com.intellij.ui.components.JBList#addListSelectionListener()

The following examples show how to use com.intellij.ui.components.JBList#addListSelectionListener() . 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: DataSourceListPanel.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private JBList prepareDataSourcesList(DefaultListModel dataSourcesListModel) {
    final JBList dataSourcesList = new JBList(dataSourcesListModel);
    dataSourcesList.getEmptyText().setText("No data sources defined");
    dataSourcesList.setDragEnabled(false);
    dataSourcesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dataSourcesList.setCellRenderer(new DataSourceConfigurationCellRenderer());
    dataSourcesList.addListSelectionListener(getSelectionChangedListener());
    return dataSourcesList;
}
 
Example 2
Source File: GuiForm.java    From MavenHelper with Apache License 2.0 5 votes vote down vote up
private void createUIComponents() {
	listDataModel = new DefaultListModel();
	leftPanelList = new JBList(listDataModel);
	leftPanelList.addListSelectionListener(new MyListSelectionListener());
	// no generics in IJ12
	leftPanelList.setCellRenderer(new ColoredListCellRenderer() {
		@Override
		protected void customizeCellRenderer(JList jList, Object o, int i, boolean b, boolean b2) {
			MyListNode value = (MyListNode) o;
			String rightVersion = value.getRightVersion();
			final String[] split = value.key.split(":");
			boolean conflict = value.isConflict();

			SimpleTextAttributes attributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
			SimpleTextAttributes boldAttributes = SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
			if (conflict && allDependenciesAsListRadioButton.isSelected()) {
				attributes = SimpleTextAttributes.ERROR_ATTRIBUTES;
				boldAttributes = errorBoldAttributes;
			}

			if (showGroupId.isSelected()) {
				append(split[0] + " : ", attributes);
			}
			append(split[1], boldAttributes);
			append(" : " + rightVersion, attributes);

		}
	});
	rightTree = new MyHighlightingTree(project);
	leftTree = new MyHighlightingTree(project);
}
 
Example 3
Source File: AbstractExternalSystemConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private void prepareProjectSettings(@Nonnull SystemSettings s) {
  myProjectsModel = new DefaultListModel();
  myProjectsList = new JBList(myProjectsModel);
  myProjectsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

  addTitle(ExternalSystemBundle.message("settings.title.linked.projects", myExternalSystemId.getReadableName()));
  myComponent.add(new JBScrollPane(myProjectsList), ExternalSystemUiUtil.getFillLineConstraints(1));

  addTitle(ExternalSystemBundle.message("settings.title.project.settings"));
  List<ProjectSettings> settings = ContainerUtilRt.newArrayList(s.getLinkedProjectsSettings());
  myProjectsList.setVisibleRowCount(Math.max(3, Math.min(5, settings.size())));
  ContainerUtil.sort(settings, new Comparator<ProjectSettings>() {
    @Override
    public int compare(ProjectSettings s1, ProjectSettings s2) {
      return getProjectName(s1.getExternalProjectPath()).compareTo(getProjectName(s2.getExternalProjectPath()));
    }
  });

  myProjectSettingsControls.clear();
  for (ProjectSettings setting : settings) {
    ExternalSystemSettingsControl<ProjectSettings> control = createProjectSettingsControl(setting);
    control.fillUi(myComponent, 1);
    myProjectsModel.addElement(getProjectName(setting.getExternalProjectPath()));
    myProjectSettingsControls.add(control);
    control.showUi(false);
  }

  myProjectsList.addListSelectionListener(new ListSelectionListener() {
    @SuppressWarnings("unchecked")
    @Override
    public void valueChanged(ListSelectionEvent e) {
      if (e.getValueIsAdjusting()) {
        return;
      }
      int i = myProjectsList.getSelectedIndex();
      if (i < 0) {
        return;
      }
      if (myActiveProjectSettingsControl != null) {
        myActiveProjectSettingsControl.showUi(false);
      }
      myActiveProjectSettingsControl = myProjectSettingsControls.get(i);
      myActiveProjectSettingsControl.showUi(true);
    }
  });

  
  if (!myProjectsModel.isEmpty()) {
    addTitle(ExternalSystemBundle.message("settings.title.system.settings", myExternalSystemId.getReadableName()));
    myProjectsList.setSelectedIndex(0);
  }
}
 
Example 4
Source File: FocusDebugger.java    From consulo with Apache License 2.0 3 votes vote down vote up
private JComponent init() {
  final JPanel result = new JPanel(new BorderLayout());

  myLogModel = new DefaultListModel();
  myLog = new JBList(myLogModel);
  myLog.setCellRenderer(new FocusElementRenderer());


  myAllocation = new JEditorPane();
  final DefaultCaret caret = new DefaultCaret();
  myAllocation.setCaret(caret);
  caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
  myAllocation.setEditable(false);


  final Splitter splitter = new Splitter(true);
  splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myLog));
  splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(myAllocation));

  myLog.addListSelectionListener(this);

  KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(this);

  result.add(splitter, BorderLayout.CENTER);


  final DefaultActionGroup group = new DefaultActionGroup();
  group.add(new ClearAction());

  result.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent(), BorderLayout.NORTH);

  return result;
}