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:org.pentaho.reporting.designer.core.ReportDesignerFrame.java

public ReportDesignerFrame() throws XulException {
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    final ImageIcon icon = IconLoader.getInstance().getProductIcon();
    if (icon != null) {
        setIconImage(icon.getImage());/*from   www  .  j a  va 2 s .c  om*/
    }

    setTitle(Messages.getString("ReportDesignerFrame.Title"));
    addWindowListener(new WindowCloseHandler());

    viewController = new FrameViewController(this);
    context = new DefaultReportDesignerContext(viewController);
    viewController.initializeXulDesignerFrame(context);

    welcomePane = new WelcomePane(ReportDesignerFrame.this, getContext());
    fieldSelectorPaletteDialog = new FieldSelectorPaletteDialog(ReportDesignerFrame.this, getContext());

    statusBar = new StatusBar(context);

    reportEditorPane = new FancyTabbedPane();
    reportEditorPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    reportEditorPane.getModel().addChangeListener(new ReportTabActivationHandler());
    reportEditorPane.addMouseListener(new ReportTabPanePopupHandler());

    dockingPane = new GlobalPane(false);
    dockingPane.setMainComponent(reportEditorPane);

    attributeEditorPanel = new ElementPropertiesPanel();
    attributeEditorPanel.setAllowAttributeCard(true);
    attributeEditorPanel.setReportDesignerContext(context);

    treePanel = new TreeSidePanel(context, attributeEditorPanel);

    initializeToolWindows();

    paletteToolBar = createPaletteToolBar();

    final JPanel contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(context.getToolBar("main-toolbar"), BorderLayout.NORTH); // NON-NLS
    contentPane.add(dockingPane, BorderLayout.CENTER);
    contentPane.add(statusBar, BorderLayout.SOUTH);
    contentPane.add(paletteToolBar, BorderLayout.WEST);
    setContentPane(contentPane);

    setJMenuBar(createMenuBar());
    setDropTarget(new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, new DefaultDropTargetListener()));

    context.addPropertyChangeListener(ReportDesignerContext.ACTIVE_CONTEXT_PROPERTY,
            new ReportTabActivationHandler());
    context.addPropertyChangeListener(ReportDesignerContext.STATUS_TEXT_PROPERTY, new StatusTextHandler());
    context.addPropertyChangeListener(ReportDesignerContext.PAGE_PROPERTY, new PageTextHandler());
    context.addPropertyChangeListener(ReportDesignerContext.REPORT_RENDER_CONTEXT_PROPERTY,
            new ReportEditorContextHandler());

    Toolkit.getDefaultToolkit().addAWTEventListener(new DragSelectionToggleHandler(), AWTEvent.KEY_EVENT_MASK);

    if (MacOSXIntegration.MAC_OS_X) {
        try {
            final AboutAction aboutAction = new AboutAction();
            aboutAction.setReportDesignerContext(context);

            final SettingsAction settingsAction = new SettingsAction();
            settingsAction.setReportDesignerContext(context);

            final QuitAction quitAction = new QuitAction();
            quitAction.setReportDesignerContext(context);

            final OpenReportAction openReportAction = new OpenReportAction();
            openReportAction.setReportDesignerContext(context);

            MacOSXIntegration.setOpenFileAction(openReportAction);
            MacOSXIntegration.setAboutAction(aboutAction);
            MacOSXIntegration.setPreferencesAction(settingsAction);
            MacOSXIntegration.setQuitAction(quitAction);
        } catch (Throwable e) {
            DebugLog.log("Failed to activate MacOS-X integration", e); // NON-NLS
        }
    }

    visibleElementsUpdateHandler = new VisibleElementsUpdateHandler();
    WorkspaceSettings.getInstance().addSettingsListener(visibleElementsUpdateHandler);
}

From source file:org.pmedv.blackboard.EditorUtils.java

/**
 * Configures the drop target for new symbols to be dragged from the symbol
 * table to the editor.//from  w w w .jav a 2s . c o m
 */
public static DropTarget configureDropTarget(final BoardEditor editor, final int raster) {

    DropTarget dt = new DropTarget(editor, new DropTargetAdapter() {

        final DataFlavor flavors[] = { DataFlavor.imageFlavor };

        @Override
        public void drop(DropTargetDropEvent e) {

            int xloc = BoardUtil.snap((int) e.getLocation().getX(), raster);
            int yloc = BoardUtil.snap((int) e.getLocation().getY(), raster);

            SymbolBean symbol = null;
            try {
                symbol = (SymbolBean) e.getTransferable().getTransferData(flavors[0]);
            } catch (Exception e1) {
                e1.printStackTrace();
            }

            Symbol sym = new Symbol(symbol);

            sym.setXLoc(xloc);
            sym.setYLoc(yloc);

            for (Item subItem : sym.getItems()) {

                if (subItem instanceof Line) {
                    Line line = (Line) subItem;
                    line.setStart(new Point((int) line.getStart().getX() + xloc,
                            (int) line.getStart().getY() + yloc));
                    line.setEnd(
                            new Point((int) line.getEnd().getX() + +xloc, (int) line.getEnd().getY() + yloc));
                    line.setOldstart(new Point(line.getStart()));
                    line.setOldEnd(new Point(line.getEnd()));
                } else {
                    subItem.setXLoc(subItem.getXLoc() + xloc);
                    subItem.setYLoc(subItem.getYLoc() + yloc);
                    subItem.setOldXLoc(subItem.getXLoc());
                    subItem.setOldYLoc(subItem.getYLoc());
                    subItem.setOldWidth(subItem.getWidth());
                    subItem.setOldHeight(subItem.getHeight());
                }

            }

            editor.getModel().getCurrentLayer().getItems().add(sym);
            sym.setLayer(editor.getModel().getCurrentLayer().getIndex());
            editor.refresh();
            e.dropComplete(true);
            e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);

            // Switch to select mode after drop
            ctx.getBean(SetSelectModeCommand.class).execute(null);

            if (!editor.getUndoManager().addEdit(new AddItemEdit(sym))) {
                log.info("Could not add edit " + this.getClass());
            }
            editor.setFileState(FileState.DIRTY);

            ctx.getBean(RedoCommand.class).setEnabled(editor.getUndoManager().canRedo());
            ctx.getBean(UndoCommand.class).setEnabled(editor.getUndoManager().canUndo());
        }

    });

    return dt;

}

From source file:pkgrenamer.Main.java

static void onDropFiles(DropTargetDropEvent dtde, FileDropListener onDrop) {
    try {//  w ww.jav a 2s . co  m
        Transferable transferable = dtde.getTransferable();

        if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
            dtde.acceptDrop(DnDConstants.ACTION_MOVE);
            java.util.List<?> files = (java.util.List<?>) transferable
                    .getTransferData(DataFlavor.javaFileListFlavor);
            File[] fa = new File[files.size()];
            for (int i = 0; i < fa.length; i++) {
                fa[i] = (File) files.get(i);
            }
            onDrop.onDropFile(fa);
            dtde.getDropTargetContext().dropComplete(true);

        } else {
            if (sNixFileDataFlavor == null) {
                sNixFileDataFlavor = new DataFlavor("text/uri-list;class=java.lang.String");
            }
            dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
            String data = (String) transferable.getTransferData(sNixFileDataFlavor);
            if (data != null) {
                ArrayList<File> fs = new ArrayList<>();
                for (StringTokenizer st = new StringTokenizer(data, "\r\n"); st.hasMoreTokens();) {
                    String token = st.nextToken().trim();
                    if (token.startsWith("#") || token.isEmpty()) {
                        continue;
                    }
                    try {
                        fs.add(new File(new URI(token)));
                    } catch (Exception e) {
                    }
                }
                onDrop.onDropFile(fs.toArray(new File[0]));
                dtde.getDropTargetContext().dropComplete(true);
            } else {
                dtde.rejectDrop();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java

/**
 * Constructor/*  w  ww.  j a  va 2 s .  c  om*/
 *
 * @param typeRoot            is used to create the tree starting from a specific type node
 * @param registerDoubleClick register mouse double click on tree
 */
public DBBrowserTree(byte typeRoot, boolean registerDoubleClick) {
    super();
    this.typeRoot = typeRoot;
    populateTree(typeRoot);

    setCellRenderer(new DBBrowserTreeRenderer());
    getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    setRolloverEnabled(true);
    addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED));

    DragGestureRecognizer dgr = DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(this,
            DnDConstants.ACTION_COPY_OR_MOVE, new DBBrowserTreeDragGestureListener());

    DBBrowserTreeDropListener dropListener = new DBBrowserTreeDropListener();
    addTreeSelectionListener(dropListener);
    setDropTarget(new DropTarget(this, dropListener));

    if (registerDoubleClick) {
        addMouseDoubleClickListener();
    }

    instance = this;

    // single data source autoconnect
    DataSourceManager manager = DefaultDataSourceManager.getInstance();
    List<DataSource> sources = manager.getDataSources();
    if (sources.size() == 1) {
        if (Globals.singleSourceAutoConnect()) {
            DataSource ds = manager.getConnectedDataSource();
            if (ds == null) {
                connectToDataSource(sources.get(0).getName());
            }
        }
    } else {
        String dataSourceName = Globals.getSystemDataSource();
        DataSource ds = manager.getDataSource(dataSourceName);
        if (ds != null) {
            connectToDataSource(dataSourceName);
        }
    }
}

From source file:unikn.dbis.univis.visualization.pivottable.VPivotTable.java

public VPivotTable() {
    setBorder(new EtchedBorder());
    setPreferredSize(new Dimension(1000, 700));
    setLayout(new BorderLayout());
    setBackground(Color.white);//from   www .  j  ava2s . c  o  m

    /* *** First Row *** */
    JLabel jlabelMeasure = new JLabel("Measure:");
    jlabelMeasure.setVisible(false);
    JLabel jlabelX = new JLabel("X-Axis Elements:");
    JLabel forVerticalSpace = new JLabel(" ");
    panelFirstRow = new JPanel(new VTableLayout(3, 2, 3, 3));

    dropAreaMeasure = new JTextArea(textInMeasureBox);
    dropAreaMeasure.setToolTipText(textInMeasureBox);
    dropAreaMeasure.setForeground(Color.LIGHT_GRAY);
    dropAreaMeasure.setEditable(false);
    dropAreaMeasure.setPreferredSize(new Dimension(100, 20));
    dropAreaMeasure.setBorder(BorderFactory.createEtchedBorder(Color.WHITE, Color.LIGHT_GRAY));
    dropAreaMeasure.setVisible(false);

    dropAreaX = new JTextArea(textInXYBox);
    dropAreaX.setToolTipText(textInXYBox);
    dropAreaX.setForeground(Color.LIGHT_GRAY);
    dropAreaX.setEditable(false);
    dropAreaX.setPreferredSize(new Dimension(400, 20));
    dropAreaX.setBorder(BorderFactory.createEtchedBorder(Color.WHITE, Color.LIGHT_GRAY));

    panelFirstRow.add(jlabelMeasure);
    panelFirstRow.add(jlabelX);
    panelFirstRow.add(dropAreaMeasure);
    panelFirstRow.add(dropAreaX);
    panelFirstRow.add(forVerticalSpace);
    add(panelFirstRow, BorderLayout.NORTH);

    /* *** Second Row *** */
    JLabel jlabelY1 = new JLabel("Y-Axis");
    JLabel jlabelY2 = new JLabel("Elements:");
    panelSecondRow = new JPanel(new VTableLayout(1, 2, 3, 3));

    dropAreaY = new JTextArea(textInXYBox);
    dropAreaY.setToolTipText(textInXYBox);
    dropAreaY.setForeground(Color.LIGHT_GRAY);
    dropAreaY.setEditable(false);
    dropAreaY.setLineWrap(true);
    dropAreaY.setWrapStyleWord(true);
    dropAreaY.setPreferredSize(new Dimension(100, 400));
    dropAreaY.setBorder(BorderFactory.createEtchedBorder(Color.WHITE, Color.LIGHT_GRAY));

    JPanel panelY = new JPanel(new VTableLayout(3, 1, 1, 1));
    panelY.add(jlabelY1);
    panelY.add(jlabelY2);
    panelY.add(dropAreaY);
    panelSecondRow.add(panelY);
    add(panelSecondRow, BorderLayout.WEST);

    new DropTarget(dropAreaX, DnDConstants.ACTION_COPY_OR_MOVE, this);
    new DropTarget(dropAreaY, DnDConstants.ACTION_COPY_OR_MOVE, this);
}

From source file:xtrememp.PlaylistManager.java

@Override
@SuppressWarnings("unchecked")
public void drop(DropTargetDropEvent ev) {
    DropTargetContext targetContext = ev.getDropTargetContext();
    Transferable t = ev.getTransferable();
    try {// w w w .  ja v  a2s  . c o m
        // Windows
        if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
            ev.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
            addFiles((List<File>) t.getTransferData(DataFlavor.javaFileListFlavor), false);
            targetContext.dropComplete(true);
            // Linux
        } else if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
            ev.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
            String urls = (String) t.getTransferData(DataFlavor.stringFlavor);
            List<File> fileList = new ArrayList<>();
            StringTokenizer st = new StringTokenizer(urls);
            while (st.hasMoreTokens()) {
                URI uri = new URI(st.nextToken());
                fileList.add(new File(uri));
            }
            addFiles(fileList, false);
            targetContext.dropComplete(true);
        }
    } catch (UnsupportedFlavorException | InvalidDnDOperationException | IOException | URISyntaxException ex) {
        logger.error(ex.getMessage(), ex);
    }
}