Java 类javax.swing.DropMode 实例源码

项目:VISNode    文件:ProcessBrowser.java   
/**
 * Creates the process list
 *
 * @return JComponent
 */
private JComponent buildList() {
    list = new JList<>();
    list.setCellRenderer(new CellRenderer(list.getCellRenderer()));
    list.setTransferHandler(new ProcessTransferHandler());
    list.setDragEnabled(true);
    list.setDropMode(DropMode.ON_OR_INSERT);
    list.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            if (e.getClickCount() % 2 == 0) {
                ProcessInformationPane.showDialog(list.getSelectedValue());
            }
        }
    });
    return ScrollFactory.pane(list).create();
}
项目:rapidminer    文件:PlotConfigurationTree.java   
public PlotConfigurationTree(PlotConfiguration plotConfiguration, DataTable dataTable,
        DataTableColumnListTransferHandler aTH) {
    super();
    expandAll();

    // forces the tree to ask the nodes for the correct row heights
    // must also be invoked after LaF changes...
    setRowHeight(0);

    getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    setExpandsSelectedPaths(true);

    // DnD support
    setDragEnabled(true);
    setDropMode(DropMode.INSERT);

    // Rendering
    setShowsRootHandles(false);
    setBackground(Colors.WHITE);
    setCellRenderer(new PlotConfigurationTreeCellRenderer(aTH));
    putClientProperty("JTree.lineStyle", "Horizontal");

    createNewTreeModel(plotConfiguration);
}
项目:modeller    文件:BagTree.java   
/**
 * BagTree.
 *
 * @param bagView BagView
 * @param path    String
 */
public BagTree(final BagView bagView, final String path) {
    super();
    this.setShowsRootHandles(true);
    basePath = path;
    parentNode = new DefaultMutableTreeNode(basePath);
    initialize();
    initListeners();
    final JTextField nameTextField = new JTextField();
    bagtreeRowModifier = nameTextField.getFontMetrics(nameTextField.getFont()).getHeight() + 5;
    this.setDragEnabled(true);
    this.setDropMode(DropMode.ON_OR_INSERT);
    this.setTransferHandler(new BagTreeTransferHandler());
    this.getSelectionModel().setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);
    bagView.registerTreeListener(path, this);
}
项目:rapidminer-studio    文件:PlotConfigurationTree.java   
public PlotConfigurationTree(PlotConfiguration plotConfiguration, DataTable dataTable,
        DataTableColumnListTransferHandler aTH) {
    super();
    expandAll();

    // forces the tree to ask the nodes for the correct row heights
    // must also be invoked after LaF changes...
    setRowHeight(0);

    getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    setExpandsSelectedPaths(true);

    // DnD support
    setDragEnabled(true);
    setDropMode(DropMode.INSERT);

    // Rendering
    setShowsRootHandles(false);
    setBackground(Colors.WHITE);
    setCellRenderer(new PlotConfigurationTreeCellRenderer(aTH));
    putClientProperty("JTree.lineStyle", "Horizontal");

    createNewTreeModel(plotConfiguration);
}
项目:swingx    文件:DNDRendererVisualCheck.java   
/**
     * Issue #370-swingx: drop-on not shown correctly.
     * 
     * Check core default renderer as renderer in Table.
     */
    public void interactiveDropOnVisualsTable() {
        JXTable xTable = new JXTable(new AncientSwingTeam());
        installTransferHandler(xTable);
        xTable.getColumn(0).setCellRenderer(new DefaultTableCellRenderer());
        JTable table = new JTable(new AncientSwingTeam());
        installTransferHandler(table);
//        xTable.setDropMode(DropMode.USE_SELECTION);
//        table.setDropMode(DropMode.USE_SELECTION);
        xTable.setDropMode(DropMode.ON_OR_INSERT);
        table.setDropMode(DropMode.ON_OR_INSERT);
        JXFrame frame = wrapWithScrollingInFrame(xTable, table,
                "JXTable (first column core renderer) <-> core table: drop-on appearance");
        JTextField textField = new JTextField("drag me over first column....");
        textField.setDragEnabled(true);
        addStatusComponent(frame, textField);
        show(frame);
    }
项目:swingx    文件:DNDRendererVisualCheck.java   
/**
     * Issue #370-swingx: drop-on not shown correctly.
     * 
     * Check core default renderer as renderer in Table.
     */
    public void interactiveDropOnVisualsList() {
        JXList xTable = new JXList(AncientSwingTeam.createNamedColorListModel());
        installTransferHandler(xTable);
        JList table = new JList(xTable.getModel());
        installTransferHandler(table);
//        xTable.setDropMode(DropMode.USE_SELECTION);
//        table.setDropMode(DropMode.USE_SELECTION);
        xTable.setDropMode(DropMode.ON_OR_INSERT);
        table.setDropMode(DropMode.ON_OR_INSERT);
        JXFrame frame = wrapWithScrollingInFrame(xTable, table,
                "JXList <-> core list: drop-on appearance");
        JTextField textField = new JTextField("drag me over first column....");
        textField.setDragEnabled(true);
        addStatusComponent(frame, textField);
        show(frame);
    }
项目:swingx    文件:DNDRendererVisualCheck.java   
/**
     * Issue #370-swingx: drop-on not shown correctly.
     * 
     * Check core default renderer as renderer in Table.
     */
    public void interactiveDropOnVisualsTree() {
        JXTree xTable = new JXTree(AncientSwingTeam.createNamedColorTreeModel());
        installTransferHandler(xTable);
        xTable.setCellRenderer(new DefaultTreeRenderer());
        JTree table = new JTree(xTable.getModel());
        installTransferHandler(table);
//        xTable.setDropMode(DropMode.USE_SELECTION);
//        table.setDropMode(DropMode.USE_SELECTION);
        xTable.setDropMode(DropMode.ON_OR_INSERT);
        table.setDropMode(DropMode.ON_OR_INSERT);
        JXFrame frame = wrapWithScrollingInFrame(xTable, table,
                "JXTree <-> core tree: drop-on appearance");
        JTextField textField = new JTextField("drag me over first column....");
        textField.setDragEnabled(true);
        addStatusComponent(frame, textField);
        show(frame);
    }
项目:AppWoksUtils    文件:ExtTextTable.java   
/**
     * @param tableModel
     */
    public ExtTextTable() {
        super(new ExtTestModel());
        setSearchEnabled(true);

        setDragEnabled(true);
        setDropMode(DropMode.ON);

        final DragDropHelper ddh = new DragDropHelper();
        this.setTransferHandler(ddh);
        addRowHighlighter(new SelectionHighlighter(null, new Color(10, 10, 10, 40)));
//        getModel().addExtComponentRowHighlighter(new ExtComponentRowHighlighter<TextObject>(Color.BLACK,Color.RED,null) {
//            
//            @Override
//            public boolean accept(ExtColumn<TextObject> column, TextObject value, boolean selected, boolean focus, int row) {
//                // TODO Auto-generated method stub
//                return selected;
//            }
//        });
        // this.setShowHorizontalLines(false);

        setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);


    }
项目:MIDI-Automator    文件:ItemList.java   
/**
 * Initializer
 */
public void init() {
    super.init();

    firstClickStrategy = new BlinkingStrategy(this,
            MainFrame.METRONOM_COLOR_FIRST_CLICK,
            MainFrame.METRONOM_BLINK_RATE, 1);
    otherClickStrategy = new BlinkingStrategy(this,
            MainFrame.METRONOM_COLOR_OTHER_CLICK,
            MainFrame.METRONOM_BLINK_RATE, 1);

    setName(NAME);
    addMouseListener(doubleClickListener);
    setBlinkingStrategy(otherClickStrategy);
    setFont(new Font(FONT_FAMILY, Font.BOLD, FONT_SIZE));
    setCache(getSelectionBackground());
    setDropMode(DropMode.INSERT);
    setTransferHandler(transferHandler);
    setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    addListSelectionListener(selectionHandler);

    DragSource fileListDragSource = new DragSource();
    fileListDragSource.createDefaultDragGestureRecognizer(this,
            DnDConstants.ACTION_MOVE, itemListDragGestureListener);
}
项目:AndrOBD    文件:PvExplorer.java   
public PvExplorer(ProcessVar pv)
{
    setDividerSize(2);
    setPreferredSize(new Dimension(640, 480));

    pvTree = new JTree(new PvTreeNode(pv));
    pvTree.getSelectionModel().addTreeSelectionListener(this);
    pvTree.setDragEnabled(true);
    pvTree.setDropMode(DropMode.ON_OR_INSERT);
    pvTree.setTransferHandler(xferHdlr);

    pvTable = new PvTable(pv);
    pvTable.setDragEnabled(true);
    pvTable.setDropMode(DropMode.ON_OR_INSERT);
    pvTable.addMouseListener(tblMouseLstnr);
    pvTable.setTransferHandler(xferHdlr);

    JScrollPane spPvTree = new JScrollPane(pvTree);
    add(spPvTree, JSplitPane.LEFT);
    JScrollPane spPvTable = new JScrollPane(pvTable);
    add(spPvTable, JSplitPane.RIGHT);
}
项目:PhotMan    文件:PhotManFrame.java   
/**
 * Creates the center pane that shows the pictures thumbnail list.
 */
private void setCenterPane() {
    DefaultListModel<PhotManImage> dlm = new DefaultListModel<>();
    m_thumbnails = new JList<>(dlm);
    m_thumbnails.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    m_thumbnails.setTransferHandler(new PhotManListItemTransferHandler());
    m_thumbnails.setDropMode(DropMode.INSERT);
    m_thumbnails.setDragEnabled(true);
    m_thumbnails.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    m_thumbnails.setVisibleRowCount(0);
    m_thumbnails.setFixedCellWidth(m_options.getThumbnailSize()+10);
    m_thumbnails.setFixedCellHeight(m_options.getThumbnailSize()+30);
    m_thumbnails.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));

    m_thumbnails.setCellRenderer(new PhotManListCellRenderer());
    JScrollPane imagesScroll = new JScrollPane(m_thumbnails);
    m_contentPane.add(imagesScroll,BorderLayout.CENTER);        
}
项目:olivia-swing    文件:OliviaTree.java   
public OliviaTree() {
  //設定
    this.setFocusable(true);
    //複数選択可能にする
    this.getSelectionModel().setSelectionMode(
            TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    //ノード名を編集可能にする
    this.setEditable(true);
    this.setCellEditor(new OliviaCellEditor(this, new OliviaCellEditField(this)));
    //ドラッグドロップを可能にする
    this.setDragEnabled(true);
    this.setDropMode(DropMode.ON_OR_INSERT);


    //モデル側のプロジェクトを反映
    this.model = Olivia.getView().getComponents().getTreeArea();

    initialize(Olivia.getProjects().getCurrentProject());

}
项目:rapidminer-5    文件:PlotConfigurationTree.java   
public PlotConfigurationTree(PlotConfiguration plotConfiguration, DataTable dataTable, DataTableColumnListTransferHandler aTH) {
    super();
    expandAll();

    // forces the tree to ask the nodes for the correct row heights
    // must also be invoked after LaF changes...
    setRowHeight(0);

    getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    setExpandsSelectedPaths(true);

    // DnD support
    setDragEnabled(true);
    setDropMode(DropMode.INSERT);

    // Rendering
    setShowsRootHandles(false);
    setCellRenderer(new PlotConfigurationTreeCellRenderer(aTH));
    putClientProperty("JTree.lineStyle", "Horizontal");

    createNewTreeModel(plotConfiguration);
}
项目:TreeTable    文件:TreeTable.java   
public void setDropMode(DropMode dropMode) {
    if (dropMode == null) {
        dropModeSet = false;
        updateDropMode();
    } else {
        switch (dropMode) {
        default:
            throw new IllegalArgumentException("Unsupported DropMode: " + dropMode);
        case ON:
        case INSERT:
        case INSERT_ROWS:
        case INSERT_COLS:
        case ON_OR_INSERT:
        case ON_OR_INSERT_ROWS:
        case ON_OR_INSERT_COLS:
        }
        dropModeSet = true;
        table.setDropMode(dropMode);
    }
}
项目:Slipstream-Mod-Manager    文件:ChecklistTreePanel.java   
public ChecklistTreePanel() {
    super( new BorderLayout() );

    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode( "Root", true );
    treeModel = new DefaultTreeModel( rootNode, true );
    tree = new JTree( treeModel );
    tree.setCellRenderer( new DefaultTreeCellRenderer() );
    tree.setRootVisible( false );
    tree.getSelectionModel().setSelectionMode( TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION );
    checklistManager = new ChecklistTreeManager( tree, true, null );

    JScrollPane scrollPane = new JScrollPane( tree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
    this.add( scrollPane, BorderLayout.CENTER );

    tree.setTransferHandler( new TreeTransferHandler( tree ) );
    tree.setDropMode( DropMode.ON_OR_INSERT );  // Drop between rows, or onto groups.
    tree.setDragEnabled( true );
}
项目:pdfjumbler    文件:JDragDropList.java   
public JDragDropList(StandardListModel<T> model) {
    super(model);

    setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    setDragEnabled(true);
    setDropMode(DropMode.INSERT);
    setTransferHandler(new JDDLTransferHandler());
}
项目:incubator-netbeans    文件:FolderList.java   
/** Creates new form FolderList */
public FolderList (String label, char mnemonic, String accessibleDesc, String fcMessage,
                   char addButtonMnemonic, String addButtonAccessibleDesc,
                   char removeButtonMnemonic,String removeButtonAccessibleDesc) {
    this.fcMessage = fcMessage;
    initComponents();
    this.jLabel1.setText(label);
    this.jLabel1.setDisplayedMnemonic(mnemonic);
    this.roots.getAccessibleContext().setAccessibleName(accessibleDesc);
    this.roots.setCellRenderer(new Renderer());
    this.roots.setModel (new DefaultListModel());
    this.roots.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                removeButton.setEnabled(roots.getSelectedIndices().length != 0);
            }
        }
    });
    this.roots.setDragEnabled(true);
    this.roots.setDropMode(DropMode.INSERT);
    this.roots.setTransferHandler(new DNDHandle());
    this.addButton.getAccessibleContext().setAccessibleDescription(addButtonAccessibleDesc);
    this.addButton.setMnemonic (addButtonMnemonic);        
    this.removeButton.getAccessibleContext().setAccessibleDescription(removeButtonAccessibleDesc);
    this.removeButton.setMnemonic (removeButtonMnemonic);
    this.removeButton.setEnabled(false);
}
项目:marathonv5    文件:JListXTest.java   
@BeforeMethod public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
                @Override public void eventDispatched(AWTEvent event) {
                }
            }, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
            frame = new JFrame("My Dialog");
            frame.setName("dialog-1");
            Object[] listData = new Object[30];
            for (int i = 1; i <= listData.length; i++) {
                if (i == 25) {
                    listData[i - 1] = "List Item - '" + i + "'";
                } else {
                    listData[i - 1] = "List Item - " + i;
                }
            }
            list = new JList(listData);
            list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            list.setName("list-1");
            list.setDragEnabled(true);
            JPanel p = new JPanel(new BorderLayout());
            p.add(new JScrollPane(list), BorderLayout.NORTH);
            textfield = new JTextField(80);
            textfield.setName("text-field");
            textfield.setDropMode(DropMode.USE_SELECTION);
            p.add(textfield, BorderLayout.SOUTH);
            frame.getContentPane().add(p);
            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
            list.requestFocusInWindow();
        }
    });
}
项目:marathonv5    文件:DropDemo.java   
@Override public void actionPerformed(ActionEvent ae) {
    Object val = dropCombo.getSelectedItem();
    if (val == "USE_SELECTION") {
        list.setDropMode(DropMode.USE_SELECTION);
    } else if (val == "ON") {
        list.setDropMode(DropMode.ON);
    } else if (val == "INSERT") {
        list.setDropMode(DropMode.INSERT);
    } else if (val == "ON_OR_INSERT") {
        list.setDropMode(DropMode.ON_OR_INSERT);
    }
}
项目:ramus    文件:TableEditor.java   
@Override
public JComponent getComponent() {
    pane = new JScrollPane();
    pane.setViewportView(editorTable);

    header = new TableHeader(editorTable, model);

    header.setDragEnabled(true);
    header.setTransferHandler(new RowTransferHandle());
    header.setDropMode(DropMode.INSERT);

    pane.setRowHeaderView(header);


    editorTable.setDropMode(DropMode.INSERT_ROWS);
    editorTable.setTransferHandler(new RowTransferHandle());

    return pane;
}
项目:openjdk-jdk10    文件:LastNodeLowerHalfDrop.java   
private JScrollPane getContent() {
    jTree = new JTree(getTreeModel());
    jTree.setRootVisible(false);
    jTree.setDragEnabled(true);
    jTree.setDropMode(DropMode.INSERT);
    jTree.setTransferHandler(new TreeTransferHandler());
    jTree.getSelectionModel().setSelectionMode(
            TreeSelectionModel.SINGLE_TREE_SELECTION);
    expandTree(jTree);
    return new JScrollPane(jTree);
}
项目:scorekeeperfrontend    文件:DriverTable.java   
public DriverTable(EntryModel m)
{
    super(m, new EntrantRenderer(), new DriverTransferHandler(), 0, 2);

    setDragEnabled(true);
    setDropMode(DropMode.INSERT);

    InputMap im = getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "cut"); // delete is same as Ctl+X

    addMouseListener(new DriverContextMenu(this));
    getTableHeader().addMouseListener( new RowHeaderTableResizer() );
}
项目:workcraft    文件:StgSimulationTool.java   
StateTable(final StateTableModel model) {
    super(model);
    getTableHeader().setReorderingAllowed(false);
    setDragEnabled(true);
    setDropMode(DropMode.INSERT_ROWS);
    setTransferHandler(new StateTableRowTransferHandler(this));
    setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    setRowHeight(SizeHelper.getComponentHeightFromFont(this.getFont()));
    setDefaultRenderer(SignalData.class, new SignalDataRenderer());
    setDefaultRenderer(Boolean.class, new BooleanCellRenderer());
    setDefaultEditor(Boolean.class, new BooleanCellEditor());
    setDefaultRenderer(Color.class, new ColorCellRenderer());
    setDefaultEditor(Color.class, new ColorCellEditor());
}
项目:taxonaut    文件:NameTable.java   
public GenericNameTable(final T[] names,
         Locale locale)
   {
super();
setModel(createModel(names, locale));
// setAutoCreateRowSorter(true);
setDragEnabled(true);
setDropMode(DropMode.ON);
   }
项目:taxonaut    文件:NameTable.java   
public GenericNameTable(final NameTreeNode[] nodes,
         Locale locale)
   {
super(createModel(nodes, locale));
// setAutoCreateRowSorter(true);
setDragEnabled(true);
setDropMode(DropMode.ON);
   }
项目:ca-iris    文件:ProxyTablePanel.java   
/** Initialize the drag/drop behavior for rows if needed */
private void initRowDragDrop() {
    if (!model.hasManualSort())
        return;

    table.setDragEnabled(model.canUpdate(getExampleProxy()));
    table.setDropMode(DropMode.INSERT_ROWS);
    table.setTransferHandler(new ProxyTableRowTransferHandler(table));
}
项目:SporeModder    文件:FilteredTree.java   
public FilteredTree(FilteredTreeModel treeModel, FilteredTreeDragAndDrop dragAndDrop) {
    super(treeModel);

    this.dragAndDrop = dragAndDrop;

    this.setDragEnabled(true);
    this.setTransferHandler(new FilteredTreeTransferHandler());
    this.setDropMode(DropMode.ON_OR_INSERT);
}
项目:binnavi    文件:TypesTree.java   
public TypesTree() {
  setRootVisible(false);
  setDragEnabled(true);
  setDropMode(DropMode.INSERT); // Dropped objects are inserted behind the drop location.
  setToggleClickCount(1); // Child nodes expand with a single click.
  final DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
  selectionModel.setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
  setSelectionModel(selectionModel);
  final IconNodeRenderer renderer = new IconNodeRenderer();
  renderer.setFont(GuiHelper.MONOSPACED_FONT);
  setCellRenderer(renderer);
}
项目:PasswordSafe    文件:UniversalTransferHandler.java   
public boolean importData(TransferSupport support)
{
    isDrop = support.isDrop();
    if(isDrop)
    {
        dropLocation = support.getDropLocation().getDropPoint();

        if(support.getComponent() instanceof JTextComponent)
        {
            modeBetween = ((JTextComponent)support.getComponent()).getDropMode() == DropMode.INSERT;
            dropBias = ((JTextComponent.DropLocation)support.getDropLocation()).getBias();
            dropAction = support.getDropAction();
        }
    }
    else
    {
        dropLocation = null;
    }

    try
    {
        return super.importData(support);
    }
    finally
    {
        isDrop = false;
        modeBetween = false;
        dropBias = null;
        dropAction = MOVE;
        dropLocation = null;
    }
}
项目:fhaes    文件:CustomizeDialog.java   
/**
 * Creates the initial lists of DataItems.
 * 
 * @param handler handles drag-and-drop operations.
 * @param items the list of DataItems.
 * @return the created JScrollPane.
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
private static JScrollPane makeList(TransferHandler handler, List<DataItem> items) {

    DefaultListModel listModel = new DefaultListModel();

    for (DataItem item : items)
        listModel.addElement(item);

    JList list = new JList(listModel);
    list.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    list.setDropMode(DropMode.INSERT);
    list.setDragEnabled(true);
    list.setTransferHandler(handler);

    // Disable row Cut, Copy, Paste
    AbstractAction dummyAction = new AbstractAction() {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) { /* Dummy action */

        }
    };
    list.getActionMap().put(TransferHandler.getCutAction().getValue(Action.NAME), dummyAction);
    list.getActionMap().put(TransferHandler.getCopyAction().getValue(Action.NAME), dummyAction);
    list.getActionMap().put(TransferHandler.getPasteAction().getValue(Action.NAME), dummyAction);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportView(list);
    return scrollPane;
}
项目:mzmine2    文件:ProjectTree.java   
/**
    * Constructor
    */
   public ProjectTree() {

ProjectTreeRenderer renderer = new ProjectTreeRenderer();
setCellRenderer(renderer);

DefaultTreeCellEditor editor = new DefaultTreeCellEditor(this,
    renderer, new ProjectTreeEditor(this));
setCellEditor(editor);
setEditable(true);
setInvokesStopCellEditing(true);

setRootVisible(true);
setShowsRootHandles(false);

setToggleClickCount(-1);

// Activate drag&drop
ProjectTreeDnDHandler dndHandler = new ProjectTreeDnDHandler();
setTransferHandler(dndHandler);
setDropMode(DropMode.INSERT);
setDragEnabled(true);

// Attach a handler for handling popup menus and double clicks
ProjectTreeMouseHandler popupHandler = new ProjectTreeMouseHandler(this);
addMouseListener(popupHandler);

   }
项目:metasfresh    文件:VTreePanel.java   
/**
 * Tree Panel for browsing and editing of a tree. Need to call initTree
 * 
 * @param WindowNo WindowNo
 * @param editable if true you can edit it
 * @param hasBar has OutlookBar
 */
public VTreePanel(int WindowNo_IGNORED, final boolean hasBar, final boolean editable)
{
    super();
    tree.setModel(new AdempiereTreeModel()); // set an empty tree model just to avoid displaying the sample tree nodes
    log.info("Bar=" + hasBar + ", Editable=" + editable);

    m_hasBar = hasBar;
    m_editable = editable;

    // static init
    jbInit();
    if (!m_hasBar)
    {
        treePopupMenu.remove(mFavoritesBarAdd);
    }

    // base settings
    if (editable)
    {
        tree.setDragEnabled(true);
        tree.setTransferHandler(handler);
        tree.setDropMode(DropMode.INSERT);
        setMappings(tree);
    }
    else
    {
        treePopupMenu.remove(mFrom);
        treePopupMenu.remove(mTo);
    }
}
项目:incubator-taverna-workbench    文件:IterationStrategyEditor.java   
public IterationStrategyEditor() {
    super();
    // Make this a drag source
    if (!GraphicsEnvironment.isHeadless()) {
        this.setDragEnabled(true);  
        this.setDropMode(DropMode.ON_OR_INSERT);  
        this.setTransferHandler(new TreeTransferHandler());  
        this.getSelectionModel().setSelectionMode(  
                TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);  
        expandTree();
    }

    //
}
项目:r2cat    文件:SequenceOrderTable.java   
public SequenceOrderTable(MatchList matches) {
    super(new SequenceOrderTableModel(matches));

    this.matches = matches;
    matches.addObserver(this);

    this.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    this.setColumnSelectionAllowed(false);
    this.setAutoscrolls(true);
    this.setRowSelectionAllowed(true);
    this.setDragEnabled(true);
    this.setDropMode(DropMode.INSERT_ROWS);
    this.setTransferHandler(new SequenceOrderTableTransferHandler());
}
项目:snap-desktop    文件:LayerManagerForm.java   
private CheckBoxTree createCheckBoxTree(LayerTreeModel treeModel) {

        final CheckBoxTree checkBoxTree = new CheckBoxTree(treeModel) {
            @Override
            public boolean isPathEditable(TreePath path) {
                Layer layer = getLayer(path);
                if (layer != null) {
                    return isLayerNameEditable(layer);
                }
                return false;
            }  
        };
        checkBoxTree.setRootVisible(false);
        checkBoxTree.setShowsRootHandles(true);
        checkBoxTree.setDigIn(false);

        checkBoxTree.setEditable(true);
        checkBoxTree.setDragEnabled(true);
        checkBoxTree.setDropMode(DropMode.ON_OR_INSERT);
        checkBoxTree.setTransferHandler(new LayerTreeTransferHandler(view, checkBoxTree));

        checkBoxTree.getSelectionModel().addTreeSelectionListener(new LayerSelectionListener());

        final CheckBoxTreeSelectionModel checkBoxSelectionModel = checkBoxTree.getCheckBoxTreeSelectionModel();
        checkBoxSelectionModel.addTreeSelectionListener(new CheckBoxTreeSelectionListener());

        final DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) checkBoxTree.getActualCellRenderer();
        renderer.setLeafIcon(null);
        renderer.setClosedIcon(null);
        renderer.setOpenIcon(null);
        return checkBoxTree;
    }
项目:com.opendoorlogistics    文件:TasksTable.java   
TasksTable(String vehicleId, TaskMover stopMover, ODLApi api) {
    this.vehicleId = vehicleId;
    this.transferHandler = new TaskTransferHandler(stopMover);
    this.isSchedule = Strings.equalsStd(vehicleId, ScheduleEditorConstants.UNLOADED_VEHICLE) == false;
    this.api = api;
    getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    setTransferHandler(transferHandler);
    setDropMode(DropMode.INSERT_ROWS);
    setDragEnabled(true);
    setFillsViewportHeight(true);
    // setAutoCreateRowSorter(true);
    setRowSorter(null);
}
项目:jClipCorn    文件:DnDList.java   
public DnDList() {
    super();
    setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    setDragEnabled(true);
    setDropMode(DropMode.INSERT);
    ds = new DragSource();
    ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this);
    setTransferHandler(new MyListDropHandler<>(this));
}
项目:TreeTable    文件:TreeTable.java   
private void updateDropMode() {
    if (dropModeSet)
        return;
    if (getRowSelectionAllowed()) {
        if (getColumnSelectionAllowed()) {
            table.setDropMode(DropMode.ON);
        } else {
            table.setDropMode(DropMode.INSERT_ROWS);
        }
    } else if (getColumnSelectionAllowed()) {
        table.setDropMode(DropMode.INSERT_COLS);
    } else {
        table.setDropMode(DropMode.ON);
    }
}
项目:sofd_swing    文件:JGridList.java   
public final void setDropMode(DropMode dropMode) {
    if (dropMode != null) {
        switch (dropMode) {
            case ON:
            case INSERT:
            case ON_OR_INSERT:
                this.dropMode = dropMode;
                return;
        }
    }

    throw new IllegalArgumentException(dropMode + ": Unsupported drop mode for JGridList");
}
项目:apache-jmeter-2.10    文件:MainFrame.java   
/**
 * Create and initialize the GUI representation of the test tree.
 *
 * @param treeModel
 *            the test tree model
 * @param treeListener
 *            the test tree listener
 *
 * @return the initialized test tree GUI
 */
private JTree makeTree(TreeModel treeModel, JMeterTreeListener treeListener) {
    JTree treevar = new JTree(treeModel) {
        private static final long serialVersionUID = 240L;

        @Override
        public String getToolTipText(MouseEvent event) {
            TreePath path = this.getPathForLocation(event.getX(), event.getY());
            if (path != null) {
                Object treeNode = path.getLastPathComponent();
                if (treeNode instanceof DefaultMutableTreeNode) {
                    Object testElement = ((DefaultMutableTreeNode) treeNode).getUserObject();
                    if (testElement instanceof TestElement) {
                        String comment = ((TestElement) testElement).getComment();
                        if (comment != null && comment.length() > 0) {
                            return comment;
                            }
                        }
                    }
                }
            return null;
            }
        };
    treevar.setToolTipText("");
    treevar.setCellRenderer(getCellRenderer());
    treevar.setRootVisible(false);
    treevar.setShowsRootHandles(true);

    treeListener.setJTree(treevar);
    treevar.addTreeSelectionListener(treeListener);
    treevar.addMouseListener(treeListener);
    treevar.addKeyListener(treeListener);

    // enable drag&drop, install a custom transfer handler
    treevar.setDragEnabled(true);
    treevar.setDropMode(DropMode.ON_OR_INSERT);
    treevar.setTransferHandler(new JMeterTreeTransferHandler());

    return treevar;
}