Search in sources :

Example 1 with DefaultMouseListener

use of com.limegroup.gnutella.gui.tables.DefaultMouseListener in project frostwire by frostwire.

the class LibraryExplorer method setupTree.

private void setupTree() {
    tree = new LibraryIconTree(model);
    tree.setRowHeight(TableSettings.DEFAULT_TABLE_ROW_HEIGHT.getValue());
    tree.setRootVisible(false);
    tree.setShowsRootHandles(false);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setCellRenderer(new NodeRenderer());
    tree.setDragEnabled(true);
    tree.setTransferHandler(new LibraryFilesTransferHandler(tree));
    ((BasicTreeUI) tree.getUI()).setExpandedIcon(null);
    ((BasicTreeUI) tree.getUI()).setCollapsedIcon(null);
    SkinPopupMenu popup = new SkinPopupMenu();
    popup.add(new SkinMenuItem(refreshAction));
    popup.add(new SkinMenuItem(exploreAction));
    popup.add(new SkinMenuItem(new ConfigureOptionsAction(OptionsConstructor.SHARED_KEY, I18n.tr("Configure Options"), I18n.tr("You can configure the FrostWire\'s Options."))));
    tree.addMouseListener(new DefaultMouseListener(new TreeMouseObserver(tree, popup)));
    tree.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (LibraryUtils.isRefreshKeyEvent(e)) {
                refreshSelection(true);
            }
        }
    });
    treeSelectionListener = new LibraryExplorerTreeSelectionListener();
    tree.addTreeSelectionListener(treeSelectionListener);
    ToolTipManager.sharedInstance().registerComponent(tree);
}
Also used : SkinMenuItem(com.frostwire.gui.theme.SkinMenuItem) SkinPopupMenu(com.frostwire.gui.theme.SkinPopupMenu) KeyAdapter(java.awt.event.KeyAdapter) ConfigureOptionsAction(com.limegroup.gnutella.gui.options.ConfigureOptionsAction) DefaultMouseListener(com.limegroup.gnutella.gui.tables.DefaultMouseListener) KeyEvent(java.awt.event.KeyEvent) BasicTreeUI(javax.swing.plaf.basic.BasicTreeUI)

Example 2 with DefaultMouseListener

use of com.limegroup.gnutella.gui.tables.DefaultMouseListener in project frostwire by frostwire.

the class LibraryPlaylists method setupList.

private void setupList() {
    LibraryPlaylistsMouseObserver _listMouseObserver = new LibraryPlaylistsMouseObserver();
    listSelectionListener = new LibraryPlaylistsSelectionListener();
    SortedListModel sortedModel = new SortedListModel(model, SortOrder.ASCENDING, new Comparator<LibraryPlaylistsListCell>() {

        @Override
        public int compare(LibraryPlaylistsListCell o1, LibraryPlaylistsListCell o2) {
            if (o1 == newPlaylistCell || o1 == starredPlaylistCell) {
                return -1;
            }
            if (o2 == newPlaylistCell || o2 == starredPlaylistCell) {
                return 1;
            }
            return o1.getText().compareTo(o2.getText());
        }
    });
    list = new LibraryIconList(sortedModel);
    list.setFixedCellHeight(TableSettings.DEFAULT_TABLE_ROW_HEIGHT.getValue());
    list.setCellRenderer(new LibraryPlaylistsCellRenderer());
    list.addMouseListener(new DefaultMouseListener(_listMouseObserver));
    list.addListSelectionListener(listSelectionListener);
    list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    list.setLayoutOrientation(JList.VERTICAL);
    list.setPrototypeCellValue(new LibraryPlaylistsListCell("test", "", GUIMediator.getThemeImage("playlist"), null, null));
    list.setVisibleRowCount(-1);
    list.setDragEnabled(true);
    list.setTransferHandler(new LibraryPlaylistsTransferHandler(list));
    ToolTipManager.sharedInstance().registerComponent(list);
    list.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            list_keyPressed(e);
        }
    });
    list.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 1) {
                actionStartRename();
            }
        }
    });
    textName = new JTextField();
    ThemeMediator.fixKeyStrokes(textName);
    UIDefaults defaults = new UIDefaults();
    defaults.put("TextField.contentMargins", new InsetsUIResource(0, 4, 0, 4));
    textName.putClientProperty("Nimbus.Overrides.InheritDefaults", Boolean.TRUE);
    textName.putClientProperty("Nimbus.Overrides", defaults);
    textName.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            textName_keyPressed(e);
        }
    });
    textName.setVisible(false);
    list.add(textName);
}
Also used : InsetsUIResource(javax.swing.plaf.InsetsUIResource) DefaultMouseListener(com.limegroup.gnutella.gui.tables.DefaultMouseListener)

Aggregations

DefaultMouseListener (com.limegroup.gnutella.gui.tables.DefaultMouseListener)2 SkinMenuItem (com.frostwire.gui.theme.SkinMenuItem)1 SkinPopupMenu (com.frostwire.gui.theme.SkinPopupMenu)1 ConfigureOptionsAction (com.limegroup.gnutella.gui.options.ConfigureOptionsAction)1 KeyAdapter (java.awt.event.KeyAdapter)1 KeyEvent (java.awt.event.KeyEvent)1 InsetsUIResource (javax.swing.plaf.InsetsUIResource)1 BasicTreeUI (javax.swing.plaf.basic.BasicTreeUI)1