Example usage for java.awt.dnd DnDConstants ACTION_COPY_OR_MOVE

List of usage examples for java.awt.dnd DnDConstants ACTION_COPY_OR_MOVE

Introduction

In this page you can find the example usage for java.awt.dnd DnDConstants ACTION_COPY_OR_MOVE.

Prototype

int ACTION_COPY_OR_MOVE

To view the source code for java.awt.dnd DnDConstants ACTION_COPY_OR_MOVE.

Click Source Link

Document

An int representing a "copy" or "move" action.

Usage

From source file:EditorDropTarget4.java

protected boolean acceptOrRejectDrag(DropTargetDragEvent dtde) {
    int dropAction = dtde.getDropAction();
    int sourceActions = dtde.getSourceActions();
    boolean acceptedDrag = false;

    DnDUtils.debugPrintln("\tSource actions are " + DnDUtils.showActions(sourceActions) + ", drop action is "
            + DnDUtils.showActions(dropAction));

    // Reject if the object being transferred
    // or the operations available are not acceptable.
    if (!acceptableType || (sourceActions & DnDConstants.ACTION_COPY_OR_MOVE) == 0) {
        DnDUtils.debugPrintln("Drop target rejecting drag");
        dtde.rejectDrag();/*  ww w .  j a v a  2  s.c  o  m*/
    } else if (!draggingFile && !pane.isEditable()) {
        // Can't drag text to a read-only JEditorPane
        DnDUtils.debugPrintln("Drop target rejecting drag");
        dtde.rejectDrag();
    } else if ((dropAction & DnDConstants.ACTION_COPY_OR_MOVE) == 0) {
        // Not offering copy or move - suggest a copy
        DnDUtils.debugPrintln("Drop target offering COPY");
        dtde.acceptDrag(DnDConstants.ACTION_COPY);
        acceptedDrag = true;
    } else {
        // Offering an acceptable operation: accept
        DnDUtils.debugPrintln("Drop target accepting drag");
        dtde.acceptDrag(dropAction);
        acceptedDrag = true;
    }

    return acceptedDrag;
}

From source file:edu.clemson.cs.nestbed.client.gui.MoteConfigPanel.java

public MoteConfigPanel(MoteTestbedAssignment mtbAssignment, ProgramManager programManager, int projDepConfID,
        MoteManager moteManager, MoteTypeManager moteTypeManager, MoteDeploymentConfigurationManager mdcManager)
        throws RemoteException, NotBoundException, MalformedURLException {

    this.programManager = programManager;
    this.mtbAssignment = mtbAssignment;
    this.projDepConfID = projDepConfID;
    this.mote = moteManager.getMote(mtbAssignment.getMoteID());
    this.moteType = moteTypeManager.getMoteType(mote.getMoteTypeID());
    this.mdcManager = mdcManager;
    this.moteDepConfig = mdcManager.getMoteDeploymentConfiguration(projDepConfID, mote.getID());
    this.radioChangeListener = new RadioChangeListener();
    this.radioSpinner = new JSpinner(
            new SpinnerNumberModel(MAX_RADIO_POWER, MIN_RADIO_POWER, MAX_RADIO_POWER, RADIO_POWER_INCR));

    setIcon(new ImageIcon(moteType.getImage()).getImage());

    if (this.moteDepConfig != null) {
        this.program = programManager.getProgram(moteDepConfig.getProgramID());
        radioSpinner.setValue(moteDepConfig.getRadioPowerLevel());
    } else {/*from www  .ja  v  a2  s  .c  o m*/
        radioSpinner.setEnabled(false);
    }
    radioSpinner.setToolTipText("Radio Power Level");

    Dimension labelSize = new Dimension(LABEL_WIDTH, LABEL_HEIGHT);
    JLabel addressLabel = new JLabel("" + mtbAssignment.getMoteAddress());
    addressLabel.setSize(labelSize);
    addressLabel.setPreferredSize(labelSize);

    Dimension spinnerSize = new Dimension(SPINNER_WIDTH, SPINNER_HEIGHT);
    radioSpinner.setSize(spinnerSize);
    radioSpinner.setPreferredSize(spinnerSize);
    radioSpinner.addChangeListener(radioChangeListener);

    setToolTipText(getToolTipString());
    addMouseListener(new MotePanelMouseListener());

    add(addressLabel);
    addressLabel.setLocation(2, 0);

    add(radioSpinner);
    radioSpinner.setLocation(getWidth() - SPINNER_WIDTH - 2, getHeight() - SPINNER_HEIGHT - 2);

    mdcManager.addRemoteObserver(new MoteDeploymentConfigObserver());
    new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, new ProgramDropTarget(), true);
}

From source file:FileTreeDropTarget.java

protected boolean acceptOrRejectDrag(DropTargetDragEvent dtde) {
    int dropAction = dtde.getDropAction();
    int sourceActions = dtde.getSourceActions();
    boolean acceptedDrag = false;

    DnDUtils.debugPrintln("\tSource actions are " + DnDUtils.showActions(sourceActions) + ", drop action is "
            + DnDUtils.showActions(dropAction));

    Point location = dtde.getLocation();
    boolean acceptableDropLocation = isAcceptableDropLocation(location);

    // Reject if the object being transferred 
    // or the operations available are not acceptable.
    if (!acceptableType || (sourceActions & DnDConstants.ACTION_COPY_OR_MOVE) == 0) {
        DnDUtils.debugPrintln("Drop target rejecting drag");
        dtde.rejectDrag();/*  w  w  w.j a va  2s . co  m*/
    } else if (!tree.isEditable()) {
        // Can't drag to a read-only FileTree
        DnDUtils.debugPrintln("Drop target rejecting drag");
        dtde.rejectDrag();
    } else if (!acceptableDropLocation) {
        // Can only drag to writable directory
        DnDUtils.debugPrintln("Drop target rejecting drag");
        dtde.rejectDrag();
    } else if ((dropAction & DnDConstants.ACTION_COPY_OR_MOVE) == 0) {
        // Not offering copy or move - suggest a copy
        DnDUtils.debugPrintln("Drop target offering COPY");
        dtde.acceptDrag(DnDConstants.ACTION_COPY);
        acceptedDrag = true;
    } else {
        // Offering an acceptable operation: accept
        DnDUtils.debugPrintln("Drop target accepting drag");
        dtde.acceptDrag(dropAction);
        acceptedDrag = true;
    }

    return acceptedDrag;
}

From source file:com.mirth.connect.client.ui.components.MirthTree.java

public void dragEnter(DropTargetDragEvent dtde) {
    try {// w w w .j  a v a2s  .  c om
        Transferable tr = dtde.getTransferable();

        if (parent.currentContentPage == parent.channelEditPanel.transformerPane
                && tr.isDataFlavorSupported(supportedDropFlavor)) {
            dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
        } else {
            dtde.rejectDrag();
        }
    } catch (Exception e) {
        dtde.rejectDrag();
    }
}

From source file:de.tor.tribes.ui.windows.AbstractDSWorkbenchFrame.java

@Override
public void dragEnter(DropTargetDragEvent dtde) {
    if (dtde.isDataFlavorSupported(VillageTransferable.villageDataFlavor)
            || dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) {
        dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
    }/*from  w ww .  j  ava2s.  c om*/
}

From source file:com.eviware.soapui.impl.wsdl.panels.teststeps.support.PropertyHolderTable.java

protected JTable buildPropertiesTable() {
    propertiesModel = getPropertyHolderTableModel();
    propertiesTable = new PropertiesHolderJTable();
    propertiesTable.setName(PROPERTIES_HOLDER_TABLE_NAME);
    propertiesTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    propertiesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            int selectedRow = propertiesTable.getSelectedRow();
            if (removePropertyAction != null) {
                removePropertyAction.setEnabled(selectedRow != -1);
            }//  w w w .j ava  2 s. c o m

            if (movePropertyUpAction != null) {
                movePropertyUpAction.setEnabled(selectedRow > 0);
            }

            if (movePropertyDownAction != null) {
                movePropertyDownAction
                        .setEnabled(selectedRow >= 0 && selectedRow < propertiesTable.getRowCount() - 1);
            }
        }
    });

    propertiesTable.setDragEnabled(true);
    propertiesTable.setTransferHandler(new TransferHandler("testProperty"));

    if (getHolder().getModelItem() != null) {
        DropTarget dropTarget = new DropTarget(propertiesTable,
                new PropertyHolderTablePropertyExpansionDropTarget());
        dropTarget.setDefaultActions(DnDConstants.ACTION_COPY_OR_MOVE);
    }

    // Set render this only for value column. In this cell render we handle password shadowing.
    propertiesTable.getColumnModel().getColumn(1).setCellRenderer(new PropertiesTableCellRenderer());
    return propertiesTable;
}

From source file:de.tor.tribes.ui.windows.AbstractDSWorkbenchFrame.java

@Override
public void drop(DropTargetDropEvent dtde) {
    if (dtde.isDataFlavorSupported(VillageTransferable.villageDataFlavor)
            || dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) {
        dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
    } else {// w  ww  .  j  a  v a  2 s .  co  m
        dtde.rejectDrop();
        return;
    }

    Transferable t = dtde.getTransferable();
    List<Village> v;
    MapPanel.getSingleton().setCurrentCursor(MapPanel.getSingleton().getCurrentCursor());
    try {
        v = (List<Village>) t.getTransferData(VillageTransferable.villageDataFlavor);
        fireVillagesDraggedEvent(v, dtde.getLocation());
    } catch (Exception ignored) {
    }
}

From source file:com.mirth.connect.client.ui.components.MirthTree.java

public void drop(DropTargetDropEvent dtde) {
    if (parent.currentContentPage != parent.channelEditPanel.transformerPane) {
        return;//from w  w  w.  j  a v  a  2 s  .c  o m
    }

    try {
        TreeNode selectedNode = (TreeNode) this.getLastSelectedPathComponent();

        if (selectedNode == null) {
            return;
        }

        dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
        Transferable tr = dtde.getTransferable();

        if (supportedDropFlavor == TreeTransferable.MAPPER_DATA_FLAVOR) {
            Object transferData = tr.getTransferData(TreeTransferable.MAPPER_DATA_FLAVOR);
            MapperDropData data = (MapperDropData) transferData;

            parent.channelEditPanel.transformerPane.addNewStep(
                    constructMessageBuilderStepName(data.getNode(), selectedNode),
                    constructPath(selectedNode, prefix, suffix).toString(), data.getMapping(),
                    TransformerPane.MESSAGE_BUILDER);
        } else if (supportedDropFlavor == TreeTransferable.MESSAGE_BUILDER_DATA_FLAVOR) {
            Object transferData = tr.getTransferData(TreeTransferable.MESSAGE_BUILDER_DATA_FLAVOR);
            MessageBuilderDropData data = (MessageBuilderDropData) transferData;
            parent.channelEditPanel.transformerPane.addNewStep(
                    constructMessageBuilderStepName(selectedNode, data.getNode()), data.getMessageSegment(),
                    constructPath(selectedNode, prefix, suffix).toString(), TransformerPane.MESSAGE_BUILDER);
        } else {
            dtde.rejectDrop();
        }
    } catch (Exception e) {
        dtde.rejectDrop();
    }

}

From source file:net.rptools.tokentool.ui.TokenCompositionPanel.java

public void drop(DropTargetDropEvent dtde) {

    Transferable transferable = dtde.getTransferable();
    dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);

    try {/*ww w  .  j a  va2 s.c om*/
        if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
            List<URL> urls = new FileTransferableHandler().getTransferObject(transferable);

            for (URL url : urls) {
                String baseName = java.net.URLDecoder.decode(FilenameUtils.getBaseName(url.getFile()), "UTF-8");
                TokenTool.getFrame().getControlPanel().setNamePrefixField(baseName);
            }
        }
    } catch (UnsupportedFlavorException | IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    try {
        Image image = new ImageTransferableHandler().getTransferObject(transferable);
        if (!(image instanceof BufferedImage)) {
            // Convert to buffered image
            image = ImageUtil.createCompatibleImage(image);
        }

        setToken((BufferedImage) image);
    } catch (UnsupportedFlavorException ufe) {
        ufe.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }

    fireCompositionChanged();
}

From source file:edu.clemson.cs.nestbed.client.gui.ConfigManagerFrame.java

public ConfigManagerFrame(Testbed testbed, Project project, ProjectDeploymentConfiguration config)
        throws RemoteException, NotBoundException, MalformedURLException, ClassNotFoundException {
    super(testbed.getName() + " Deployment Configuration Manager");

    this.testbed = testbed;
    this.project = project;
    this.config = config;

    lookupRemoteManagers();//from   w ww. j  a  v  a2s.co  m
    // TODO:  We need to deregister listeners
    programCompileManager.addRemoteObserver(new ProgramCompileObserver());
    programManager.addRemoteObserver(new ProgramObserver());
    progProfManager.addRemoteObserver(new ProgramProfilingSymbolObserver());
    progProfMsgSymManager.addRemoteObserver(new ProgramProfilingMessageSymbolObserver());

    createComponents();
    programTree.addMouseListener(new ProgramTreeMouseListener());
    programTree.setCellRenderer(new ProgramTreeCellRenderer());
    programTree.setRootVisible(false);
    programTree.setShowsRootHandles(true);
    programTree.setDragEnabled(true);
    programTree.setTransferHandler(new ProgramTreeTransferHandler());
    programTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    profilingSymbolTable.addMouseListener(new ProfilingSymbolTableMouseListener());
    profilingSymbolTable.setModel(new ProfilingSymbolTableModel());
    profilingSymbolTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    new DropTarget(profilingSymbolTable, DnDConstants.ACTION_COPY_OR_MOVE, new ProgramSymbolDropTarget(), true);

    profilingMsgTable.addMouseListener(new ProfilingMessageTableMouseListener());
    profilingMsgTable.setModel(new ProfilingMessageSymbolTableModel());
    profilingMsgTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    new DropTarget(profilingMsgTable, DnDConstants.ACTION_COPY_OR_MOVE, new ProgramMessageSymbolDropTarget(),
            true);

    setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
    setJMenuBar(buildMenuBar());

    Container c = getContentPane();
    c.setLayout(new BorderLayout());

    JSplitPane top = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, buildLeftPanel(), buildMoteGridPanel());

    JSplitPane panel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, top, buildBottomPanel());

    c.add(panel, BorderLayout.CENTER);
}