Java Code Examples for javax.swing.ListSelectionModel#MULTIPLE_INTERVAL_SELECTION

The following examples show how to use javax.swing.ListSelectionModel#MULTIPLE_INTERVAL_SELECTION . 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: JTableSelectionModelEditor.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Node storeToXML(Document doc) {
    Object value = getValue();
    int selectionMode = -1;
    Object[] values = getEnumerationValues();
    if (values[4].equals(value)) {
        selectionMode = ListSelectionModel.SINGLE_SELECTION;
    } else if (values[7].equals(value)) {
        selectionMode = ListSelectionModel.SINGLE_INTERVAL_SELECTION;
    } else if (values[10].equals(value)) {
        selectionMode = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION;
    }
    org.w3c.dom.Element el = null;
    el = doc.createElement(XML_TABLE_SELECTION_MODEL);
    el.setAttribute(ATTR_SELECTION_MODE, Integer.toString(selectionMode));
    return el;
}
 
Example 2
Source File: TableView.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** 
 * Check if selection of the nodes could break
 * the selection mode set in the ListSelectionModel.
 * @param nodes the nodes for selection
 * @return true if the selection mode is broken
 */
private boolean isSelectionModeBroken(Node[] nodes) {
    
    // if nodes are empty or single then everthing is ok
    // or if discontiguous selection then everthing ok
    if (nodes.length <= 1 || table.getSelectionModel().getSelectionMode() == 
            ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) {
        return false;
    }

    // if many nodes
    
    // breaks single selection mode
    if (table.getSelectionModel().getSelectionMode() == 
        ListSelectionModel.SINGLE_SELECTION) {
        return true;
    }
    
    // check the contiguous selection mode

    // check selection's rows
    
    // all is ok
    return false;
}
 
Example 3
Source File: OutlineView.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** 
 * Check if selection of the nodes could break
 * the selection mode set in the ListSelectionModel.
 * @param nodes the nodes for selection
 * @return true if the selection mode is broken
 */
private boolean isSelectionModeBroken(Node[] nodes) {
    
    // if nodes are empty or single then everthing is ok
    // or if discontiguous selection then everthing ok
    if (nodes.length <= 1 || outline.getSelectionModel().getSelectionMode() == 
            ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) {
        return false;
    }

    // if many nodes
    
    // breaks single selection mode
    if (outline.getSelectionModel().getSelectionMode() == 
        ListSelectionModel.SINGLE_SELECTION) {
        return true;
    }
    
    // check the contiguous selection mode

    // check selection's rows
    
    // all is ok
    return false;
}
 
Example 4
Source File: MessageList.java    From desktopclient-java with GNU General Public License v3.0 6 votes vote down vote up
MessageList(View view, ChatView chatView, Chat chat) {
    // render and editor item are equal (but not the same!)
    super(view,
            new MessageListFlyWeightItem(view),
            new MessageListFlyWeightItem(view),
            // allow multiple selections for "copy" action
            ListSelectionModel.MULTIPLE_INTERVAL_SELECTION,
            true,
            false);

    mChatView = chatView;
    mChat = chat;

    //this.setEditable(false);
    //this.setAutoscrolls(true);
    this.setOpaque(false);

    // hide grid
    this.setShowGrid(false);

    // copy values to clipboard using the in-build 'copy' action, invoked by custom right-click
    // menu or default ctrl+c shortcut
    this.setTransferHandler(new CopyTransferHandler(mView));

    this.updateOnEDT(null);
}
 
Example 5
Source File: JTableSelectionModelEditor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void readFromXML(Node element) throws IOException {
    org.w3c.dom.NamedNodeMap attributes = element.getAttributes();
    Object[] values = getEnumerationValues();
    Object value;
    Node node = attributes.getNamedItem(ATTR_SELECTION_MODE);
    int selectionMode = Integer.valueOf(node.getNodeValue()).intValue();
    switch (selectionMode) {
        case ListSelectionModel.SINGLE_SELECTION: value = values[4]; break;
        case ListSelectionModel.SINGLE_INTERVAL_SELECTION: value = values[7]; break;
        case ListSelectionModel.MULTIPLE_INTERVAL_SELECTION: value = values[10]; break;
        default: value = values[1]; break;
    }
    setValue(value);
}
 
Example 6
Source File: ListBoxBuilder.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public ListBoxBuilder<T> multipleIntervalSelectionMode() {
   this.selectionMode = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION;
   return this;
}
 
Example 7
Source File: TeamServicesSettingsModel.java    From azure-devops-intellij with MIT License 4 votes vote down vote up
public TeamServicesSettingsModel(final Project project) {
    ArgumentHelper.checkNotNull(project, "project");
    this.project = project;
    this.tableModel = new ServerContextTableModel(ServerContextTableModel.GENERAL_COLUMNS, ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    this.deleteContexts = new ArrayList<ServerContext>();
}