Java Code Examples for javax.swing.ListSelectionModel#setSelectionMode()

The following examples show how to use javax.swing.ListSelectionModel#setSelectionMode() . 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: SkillInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public ModelMap createModels(final CharacterFacade character)
{
	Objects.requireNonNull(character);
	ModelMap models = new ModelMap();

	ListSelectionModel listModel = new DefaultListSelectionModel();
	listModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

	models.put(ListSelectionModel.class, listModel);
	models.put(SkillPointTableModel.class, new SkillPointTableModel(character));
	models.put(SkillTreeViewModel.class, new SkillTreeViewModel(character, listModel));
	models.put(FilterHandler.class, new FilterHandler(character, listModel));
	models.put(InfoHandler.class, new InfoHandler(character));
	models.put(LevelSelectionHandler.class, new LevelSelectionHandler(character, listModel));
	models.put(SkillRankSpinnerEditor.class, new SkillRankSpinnerEditor(character, listModel));

	SkillSheetHandler skillSheetHandler = new SkillSheetHandler(character);
	models.put(SkillSheetHandler.class, skillSheetHandler);
	models.put(SkillFilterHandler.class, new SkillFilterHandler(character, skillSheetHandler));
	return models;
}
 
Example 2
Source File: AbilityChooserTab.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
public Hashtable<Object, Object> createState(CharacterFacade character,
	ListFacade<AbilityCategory> categories, ListFacade<AbilityCategory> fullCategoryList, String title)
{
	Hashtable<Object, Object> state = new Hashtable<>();
	CategoryTableModel categoryTableModel =
			new CategoryTableModel(character, fullCategoryList, categoryBar, categoryTable);
	state.put(CategoryTableModel.class, categoryTableModel);

	ListSelectionModel listModel = new DefaultListSelectionModel();
	listModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	state.put(ListSelectionModel.class, listModel);
	state.put(AbilityTreeTableModel.class, new AbilityTreeTableModel(character, categories));
	state.put(AvailableAbilityTreeViewModel.class, new AvailableAbilityTreeViewModel(character, listModel, title));
	state.put(InfoHandler.class, new InfoHandler(character));
	state.put(TreeRendererHandler.class, new TreeRendererHandler(character));
	state.put(AddAction.class, new AddAction(character));
	state.put(RemoveAction.class, new RemoveAction(character));
	state.put(AbilityFilterHandler.class, new AbilityFilterHandler(character));
	state.put(CategoryFilterHandler.class, new CategoryFilterHandler(categoryTableModel));
	return state;
}
 
Example 3
Source File: SkillInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public ModelMap createModels(final CharacterFacade character)
{
	Objects.requireNonNull(character);
	ModelMap models = new ModelMap();

	ListSelectionModel listModel = new DefaultListSelectionModel();
	listModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

	models.put(ListSelectionModel.class, listModel);
	models.put(SkillPointTableModel.class, new SkillPointTableModel(character));
	models.put(SkillTreeViewModel.class, new SkillTreeViewModel(character, listModel));
	models.put(FilterHandler.class, new FilterHandler(character, listModel));
	models.put(InfoHandler.class, new InfoHandler(character));
	models.put(LevelSelectionHandler.class, new LevelSelectionHandler(character, listModel));
	models.put(SkillRankSpinnerEditor.class, new SkillRankSpinnerEditor(character, listModel));

	SkillSheetHandler skillSheetHandler = new SkillSheetHandler(character);
	models.put(SkillSheetHandler.class, skillSheetHandler);
	models.put(SkillFilterHandler.class, new SkillFilterHandler(character, skillSheetHandler));
	return models;
}
 
Example 4
Source File: AbilityChooserTab.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
public Hashtable<Object, Object> createState(CharacterFacade character,
	ListFacade<AbilityCategory> categories, ListFacade<AbilityCategory> fullCategoryList, String title)
{
	Hashtable<Object, Object> state = new Hashtable<>();
	CategoryTableModel categoryTableModel =
			new CategoryTableModel(character, fullCategoryList, categoryBar, categoryTable);
	state.put(CategoryTableModel.class, categoryTableModel);

	ListSelectionModel listModel = new DefaultListSelectionModel();
	listModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	state.put(ListSelectionModel.class, listModel);
	state.put(AbilityTreeTableModel.class, new AbilityTreeTableModel(character, categories));
	state.put(AvailableAbilityTreeViewModel.class, new AvailableAbilityTreeViewModel(character, listModel, title));
	state.put(InfoHandler.class, new InfoHandler(character));
	state.put(TreeRendererHandler.class, new TreeRendererHandler(character));
	state.put(AddAction.class, new AddAction(character));
	state.put(RemoveAction.class, new RemoveAction(character));
	state.put(AbilityFilterHandler.class, new AbilityFilterHandler(character));
	state.put(CategoryFilterHandler.class, new CategoryFilterHandler(categoryTableModel));
	return state;
}
 
Example 5
Source File: OutlineView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void setTo(ListSelectionModel sm) {
    sm.clearSelection();
    sm.setSelectionMode(selectionMode);
    for (int[] itv : intervals) {
        sm.addSelectionInterval(itv[0], itv[1]);
    }
    sm.setAnchorSelectionIndex(anchor);
    sm.setLeadSelectionIndex(lead);
}
 
Example 6
Source File: MessageHandlerPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public HandlerTable() {
    JTableHeader header = getTableHeader();
    header.setResizingAllowed(false);
    header.setReorderingAllowed(false);
    ListSelectionModel model = getSelectionModel();
    model.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    model.addListSelectionListener(new HandlerListSelectionListener());
}
 
Example 7
Source File: TubesProjectConfigPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public TubeTable(boolean client) {
    super();
    this.client = client;

    JTableHeader header = getTableHeader();
    header.setResizingAllowed(false);
    header.setReorderingAllowed(false);

    ListSelectionModel model = getSelectionModel();
    model.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    model.addListSelectionListener(new TubeListSelectionListener(client));
}
 
Example 8
Source File: TubesConfigPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public TubeTable() {
    JTableHeader header = getTableHeader();
    header.setResizingAllowed(false);
    header.setReorderingAllowed(false);
    ListSelectionModel model = getSelectionModel();
    model.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    model.addListSelectionListener(new TubeListSelectionListener());
}
 
Example 9
Source File: DescriptionInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public ModelMap createModels(CharacterFacade character)
{
	ModelMap models = new ModelMap();
	DefaultListModel<PageItem> listModel = new DefaultListModel<>();
	List<NoteInfoPane> notePaneList = new ArrayList<>();

	PageItem firstPage = new PageItem(
		character, LanguageBundle.getString("in_descBiography"), bioPane); //$NON-NLS-1$
	listModel.addElement(firstPage);
	listModel.addElement(new PageItem(
		character, LanguageBundle.getString("in_portrait"), portraitPane)); //$NON-NLS-1$
	listModel.addElement(new PageItem(
		character, LanguageBundle.getString("in_descCampHist"), histPane)); //$NON-NLS-1$

	models.put(ListModel.class, listModel);
	models.put(List.class, notePaneList);
	models.put(NoteListHandler.class, new NoteListHandler(character, listModel, notePaneList));

	ListSelectionModel model = new DefaultListSelectionModel();
	model.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	model.setSelectionInterval(0, 0);
	models.put(ListSelectionModel.class, model);
	models.put(PageHandler.class, new PageHandler(model, firstPage));
	models.put(AddAction.class, new AddAction(character));

	return models;
}
 
Example 10
Source File: CompanionInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void initComponents()
{
	setTitle(LanguageBundle.getString("in_companionSelectRace")); //$NON-NLS-1$
	setLayout(new BorderLayout());
	Container container = getContentPane();
	{
		final ListSelectionModel selectionModel = raceTable.getSelectionModel();
		selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		selectionModel.addListSelectionListener(e -> {
                  if (!e.getValueIsAdjusting())
                  {
                      selectButton.setEnabled(!selectionModel.isSelectionEmpty());
                  }
              });
	}
	SearchFilterPanel searchBar = new SearchFilterPanel();
	container.add(searchBar, BorderLayout.NORTH);
	raceTable.setDisplayableFilter(searchBar);
	raceTable.addActionListener(this);
	raceTable.setTreeViewModel(this);
	container.add(new JScrollPane(raceTable), BorderLayout.CENTER);
	JPanel buttonPane = new JPanel(new FlowLayout());
	selectButton.addActionListener(this);
	selectButton.setEnabled(false);
	selectButton.setActionCommand("SELECT");
	buttonPane.add(selectButton);

	JButton cancelButton = new JButton(LanguageBundle.getString("in_cancel"));
	cancelButton.addActionListener(this);
	cancelButton.setActionCommand("CANCEL");
	buttonPane.add(cancelButton);
	container.add(buttonPane, BorderLayout.SOUTH);

	Utility.installEscapeCloseOperation(this);
}
 
Example 11
Source File: DescriptionInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public ModelMap createModels(CharacterFacade character)
{
	ModelMap models = new ModelMap();
	DefaultListModel<PageItem> listModel = new DefaultListModel<>();
	List<NoteInfoPane> notePaneList = new ArrayList<>();

	PageItem firstPage = new PageItem(
		character, LanguageBundle.getString("in_descBiography"), bioPane); //$NON-NLS-1$
	listModel.addElement(firstPage);
	listModel.addElement(new PageItem(
		character, LanguageBundle.getString("in_portrait"), portraitPane)); //$NON-NLS-1$
	listModel.addElement(new PageItem(
		character, LanguageBundle.getString("in_descCampHist"), histPane)); //$NON-NLS-1$

	models.put(ListModel.class, listModel);
	models.put(List.class, notePaneList);
	models.put(NoteListHandler.class, new NoteListHandler(character, listModel, notePaneList));

	ListSelectionModel model = new DefaultListSelectionModel();
	model.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	model.setSelectionInterval(0, 0);
	models.put(ListSelectionModel.class, model);
	models.put(PageHandler.class, new PageHandler(model, firstPage));
	models.put(AddAction.class, new AddAction(character));

	return models;
}
 
Example 12
Source File: CompanionInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void initComponents()
{
	setTitle(LanguageBundle.getString("in_companionSelectRace")); //$NON-NLS-1$
	setLayout(new BorderLayout());
	Container container = getContentPane();
	{
		final ListSelectionModel selectionModel = raceTable.getSelectionModel();
		selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		selectionModel.addListSelectionListener(e -> {
                  if (!e.getValueIsAdjusting())
                  {
                      selectButton.setEnabled(!selectionModel.isSelectionEmpty());
                  }
              });
	}
	SearchFilterPanel searchBar = new SearchFilterPanel();
	container.add(searchBar, BorderLayout.NORTH);
	raceTable.setDisplayableFilter(searchBar);
	raceTable.addActionListener(this);
	raceTable.setTreeViewModel(this);
	container.add(new JScrollPane(raceTable), BorderLayout.CENTER);
	JPanel buttonPane = new JPanel(new FlowLayout());
	selectButton.addActionListener(this);
	selectButton.setEnabled(false);
	selectButton.setActionCommand("SELECT");
	buttonPane.add(selectButton);

	JButton cancelButton = new JButton(LanguageBundle.getString("in_cancel"));
	cancelButton.addActionListener(this);
	cancelButton.setActionCommand("CANCEL");
	buttonPane.add(cancelButton);
	container.add(buttonPane, BorderLayout.SOUTH);

	Utility.installEscapeCloseOperation(this);
}