Package javax.swing

Examples of javax.swing.TransferHandler$SwingDropTarget


   
    private static final class WidgetDragger extends MouseMotionAdapter {
        @Override
        public void mouseDragged(MouseEvent e) {
            JComponent c = (JComponent) e.getSource();
            TransferHandler th = c.getTransferHandler();
            th.exportAsDrag(c, e, TransferHandler.COPY);
        }
View Full Code Here


    private static final class WidgetDragger extends MouseMotionAdapter {
        @Override
        public void mouseDragged(MouseEvent e) {
            JComponent c = (JComponent) e.getSource();
            TransferHandler th = c.getTransferHandler();
            th.exportAsDrag(c, e, TransferHandler.COPY);
        }
View Full Code Here

     */
    @SuppressWarnings("serial")
    public TransferableIcon(final AbstractComponent referencedComponent, final ViewTransferCallback viewTransferCallback) {
        super(MCTIcons.processIcon(referencedComponent.getAsset(ImageIcon.class), ICON_COLOR, false));
        final AtomicBoolean clicked = new AtomicBoolean(false);
        setTransferHandler(new TransferHandler() {
            @Override
            public int getSourceActions(JComponent c) {
                return canComponentBeContained()?COPY:NONE;
            }

            private boolean canComponentBeContained() {
                PolicyContext context = new PolicyContext();
                context.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(),Collections.singleton(referencedComponent));
                String policyCategoryKey = PolicyInfo.CategoryType.CAN_OBJECT_BE_CONTAINED_CATEGORY.getKey();
                Platform platform = PlatformAccess.getPlatform();
                PolicyManager policyManager = platform.getPolicyManager();
                ExecutionResult result = policyManager.execute(policyCategoryKey, context);
                return result.getStatus();
            }
           
            @Override
            protected Transferable createTransferable(JComponent c) {
                return new ViewRoleSelection(viewTransferCallback.getViewsToTransfer().toArray(new View[0]));
            }
           
            @Override
            protected void exportDone(JComponent source, Transferable data, int action) {
                super.exportDone(source, data, action);
                clicked.set(false);
            }
        });
        addMouseMotionListener(new MouseMotionAdapter() {
           
            @Override
            public void mouseDragged(MouseEvent e) {
                if (clicked.get()) {
                    JComponent c = (JComponent) e.getSource();
                    TransferHandler th = c.getTransferHandler();
                    th.exportAsDrag(c, e, TransferHandler.COPY);
                }
            }

        });
        addMouseListener(new MouseAdapter() {
View Full Code Here

        }

        // Fix for 4915454 - override the default implementation to avoid
        // loading SystemFlavorMap and associated classes.
        public void setTransferHandler(TransferHandler newHandler) {
            TransferHandler oldHandler = (TransferHandler)
                getClientProperty(XTextTransferHelper.getTransferHandlerKey());
            putClientProperty(XTextTransferHelper.getTransferHandlerKey(),
                              newHandler);

            firePropertyChange("transferHandler", oldHandler, newHandler);
View Full Code Here

        }

        // Fix for 4915454 - override the default implementation to avoid
        // loading SystemFlavorMap and associated classes.
        public void setTransferHandler(TransferHandler newHandler) {
            TransferHandler oldHandler = (TransferHandler)
                getClientProperty(XTextTransferHelper.getTransferHandlerKey());
            putClientProperty(XTextTransferHelper.getTransferHandlerKey(),
                              newHandler);

            firePropertyChange("transferHandler", oldHandler, newHandler);
View Full Code Here

     */
    public EditorScrollPane(AdvancedCALEditor editor) {
        super (editor);

        setRowHeaderView(sidePanel);
        setTransferHandler(new TransferHandler("text"));       
        setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
        setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    }
View Full Code Here

             */
            public void defaultDragEnter(DropTargetDragEvent e) {
                DataFlavor[] flavors = e.getCurrentDataFlavors();

                JComponent c = (JComponent)e.getDropTargetContext().getComponent();
                TransferHandler importer = c.getTransferHandler();
               
                if (importer != null && importer.canImport(c, flavors)) {
                    canImport = true;
                } else {
                    canImport = false;
                }
               
View Full Code Here

             */
            public void defaultDrop(DropTargetDropEvent e) {
                int dropAction = e.getDropAction();

                JComponent c = (JComponent)e.getDropTargetContext().getComponent();
                TransferHandler importer = c.getTransferHandler();

                if (canImport && importer != null) {
                    e.acceptDrop(dropAction);
                   
                    try {
                        Transferable t = e.getTransferable();
                        e.dropComplete(importer.importData(c, t));
                    } catch (RuntimeException re) {
                        e.dropComplete(false);
                    }
                } else {
                    e.rejectDrop();
View Full Code Here

             */
            public void dragEnter(DropTargetDragEvent e) {
                DataFlavor[] flavors = e.getCurrentDataFlavors();
   
                JComponent c = (JComponent)e.getDropTargetContext().getComponent();
                TransferHandler importer = c.getTransferHandler();
               
                if (importer != null && importer.canImport(c, flavors)) {
                    canImport = true;
                } else {
                    canImport = false;
                }
               
View Full Code Here

             */
            public void drop(DropTargetDropEvent e) {
                int dropAction = e.getDropAction();
   
                JComponent c = (JComponent)e.getDropTargetContext().getComponent();
                TransferHandler importer = c.getTransferHandler();
   
                if (canImport && importer != null) {
                    e.acceptDrop(dropAction);
                   
                    try {
                        Transferable t = e.getTransferable();
                        e.dropComplete(importer.importData(c, t));
                    } catch (RuntimeException re) {
                        e.dropComplete(false);
                    }
                } else {
                    e.rejectDrop();
View Full Code Here

TOP

Related Classes of javax.swing.TransferHandler$SwingDropTarget

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.