Example usage for com.vaadin.ui DragAndDropWrapper setDropHandler

List of usage examples for com.vaadin.ui DragAndDropWrapper setDropHandler

Introduction

In this page you can find the example usage for com.vaadin.ui DragAndDropWrapper setDropHandler.

Prototype

public void setDropHandler(DropHandler dropHandler) 

Source Link

Usage

From source file:annis.gui.querybuilder.TigerQueryBuilderCanvas.java

License:Apache License

public TigerQueryBuilderCanvas(QueryController controller) {
    this.controller = controller;

    nodes = new HashMap<>();
    edges = new ArrayList<>();

    setSizeFull();/*from  w ww  .  jav  a 2 s .c  o  m*/
    setImmediate(true);

    area = new AbsoluteLayout();
    area.setWidth("2000px");
    area.setHeight("2000px");
    area.addStyleName("no-vertical-drag-hints");
    area.addStyleName("no-horizontal-drag-hints");
    area.addStyleName("no-box-drag-hints");

    canvas = new SimpleCanvas();
    canvas.setSizeFull();
    canvas.addStyleName("tigerquery-builder-canvas");

    handler = new AbsoluteDropHandler(this, area);

    DragAndDropWrapper areaPane = new DragAndDropWrapper(area);
    areaPane.setWidth("2000px");
    areaPane.setHeight("2000px");
    areaPane.setDropHandler(handler);

    area.addComponent(canvas, "top:0px;left:0px");

    setContent(areaPane);

    addStyleName("no-vertical-drag-hints");
    addStyleName("no-horizontal-drag-hints");
    addStyleName("no-box-drag-hints");
}

From source file:com.hybridbpm.ui.component.bpm.designer.ProcessEditor.java

License:Apache License

private void prepareModeler() {

    processModelLayout.setProcessEditor(this);
    final DragAndDropWrapper pane = new DragAndDropWrapper(processModelLayout);
    pane.setDragStartMode(DragAndDropWrapper.DragStartMode.NONE);
    pane.setDropHandler(processModelLayout.dropHandler);
    processModelLayout.setProcessModel(processModel);
    processModelLayout.initUI();/*w  w w.j a  v a 2  s  .c o  m*/

    cssLayout.addComponent(pane);
    cssLayout.addStyleName("process-editor");
    cssLayout.setSizeFull();

    editorBackground.setSizeFull();
    editorBackground.setMargin(false);
    editorBackground.setSpacing(false);
    editorBackground.addComponent(cssLayout);

    mainPanel.setContent(editorBackground);
}

From source file:com.jorambarrez.PropertyPanel.java

License:Apache License

protected void initTrashIcon() {
    Embedded trashIcon = new Embedded(null, Images.MODELER_TRASH);
    trashIcon.setWidth(63, UNITS_PIXELS);
    trashIcon.setHeight(61, UNITS_PIXELS);
    trashIcon.setType(Embedded.TYPE_IMAGE);

    VerticalLayout trashLayout = new VerticalLayout();
    trashLayout.setWidth(120, UNITS_PIXELS);
    trashLayout.setHeight(120, UNITS_PIXELS);
    trashLayout.addComponent(trashIcon);
    trashLayout.setComponentAlignment(trashIcon, Alignment.MIDDLE_CENTER);

    DragAndDropWrapper dragAndDropWrapper = new DragAndDropWrapper(trashLayout);
    dragAndDropWrapper.setDragStartMode(DragStartMode.NONE);
    dragAndDropWrapper.setSizeUndefined();
    addComponent(dragAndDropWrapper);/*from   w  w w  . j a v a2  s . c  o  m*/
    setComponentAlignment(dragAndDropWrapper, Alignment.BOTTOM_CENTER);

    dragAndDropWrapper.setDropHandler(new DropHandler() {
        private static final long serialVersionUID = 1L;

        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }

        public void drop(DragAndDropEvent event) {
            WrapperTransferable wrapperTransferable = (WrapperTransferable) event.getTransferable();
            Node srcNode = (Node) wrapperTransferable.getSourceComponent();

            // TODO: use eventrouter!
            ModelerApp.get().getFlowEditor().removeNode(srcNode);
        }
    });
}

From source file:com.klwork.explorer.ui.custom.UploadComponent.java

License:Apache License

protected void addDropPanel() {
    Panel dropPanel = new Panel();
    dropPanel.setContent(new VerticalLayout());
    DragAndDropWrapper dragAndDropWrapper = new DragAndDropWrapper(dropPanel);
    //WW_TODO ?//from ww  w.  j a va  2  s. c om
    dragAndDropWrapper.setDropHandler(this);
    dragAndDropWrapper.setWidth("80%");
    addComponent(dragAndDropWrapper);
    setComponentAlignment(dragAndDropWrapper, Alignment.MIDDLE_CENTER);
    //
    Label dropLabel = new Label(i18nManager.getMessage(Messages.UPLOAD_DROP));
    dropLabel.setSizeUndefined();
    ((VerticalLayout) dropPanel.getContent()).addComponent(dropLabel);
    ((VerticalLayout) dropPanel.getContent()).setComponentAlignment(dropLabel, Alignment.MIDDLE_CENTER);
}

From source file:com.mcparland.john.DragAndDropPanel.java

License:Apache License

/**
 * Create a drag-and-droppable layout.//from w w w.j a  v  a  2 s .  c  o  m
 * 
 * @param layout
 *            the layout.
 * @return a drag-and-droppable layout.
 */
private Component createLayout(final AbstractLayout layout) {
    layout.addComponent(createButton("One"));
    layout.addComponent(createButton("Two"));
    layout.addComponent(createButton("Three"));
    layout.addComponent(createButton("Four"));

    final DragAndDropWrapper dndWrapper = new DragAndDropWrapper(layout);
    dndWrapper.setSizeFull();
    dndWrapper.setDropHandler(new DropHandler() {

        /*
         * (non-Javadoc)
         * 
         * @see com.vaadin.event.dd.DropHandler#getAcceptCriterion()
         */
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }

        /*
         * (non-Javadoc)
         * 
         * @see com.vaadin.event.dd.DropHandler#drop(com.vaadin.event.dd.
         * DragAndDropEvent)
         */
        public void drop(DragAndDropEvent event) {
            WrapperTransferable t = (WrapperTransferable) event.getTransferable();
            layout.addComponent(t.getSourceComponent());
        }
    });

    return dndWrapper;
}

From source file:com.peergreen.example.webconsole.extensions.ConfirmDialogExtension.java

License:Open Source License

public ConfirmDialogExtension() {
    setSizeFull();//from w  w  w  .  j a v  a 2  s  .c o  m
    setSpacing(true);
    setMargin(true);

    Link showCodeSource = new Link("Show code source",
            new ExternalResource(GitHubClassURL.getURL(ConfirmDialogExtension.class)));
    showCodeSource.setTargetName("_blank");
    addComponent(showCodeSource);
    setComponentAlignment(showCodeSource, Alignment.TOP_RIGHT);

    Label title = new Label("Drag and drop components from a panel to another");
    title.addStyleName("h1");
    addComponent(title);
    setComponentAlignment(title, Alignment.MIDDLE_CENTER);

    HorizontalLayout row = new HorizontalLayout();
    row.setSizeFull();
    row.setSpacing(true);
    row.setMargin(true);

    VerticalLayout leftPanel = new VerticalLayout();
    leftPanel.setSpacing(true);
    leftPanel.addStyleName("dashed-area");
    leftPanel.addComponent(getDraggableComponent(new Label("Label")));
    leftPanel.addComponent(getDraggableComponent(new Button("Button")));
    DragAndDropWrapper leftPanelWrapper = new DragAndDropWrapper(leftPanel);
    row.addComponent(leftPanelWrapper);
    row.setComponentAlignment(leftPanelWrapper, Alignment.TOP_LEFT);

    VerticalLayout rightPanel = new VerticalLayout();
    rightPanel.setSpacing(true);
    rightPanel.addStyleName("dashed-area");
    DragAndDropWrapper rightPanelWrapper = new DragAndDropWrapper(rightPanel);
    row.addComponent(rightPanelWrapper);
    row.setComponentAlignment(rightPanelWrapper, Alignment.TOP_RIGHT);

    leftPanelWrapper.setDropHandler(new ConfirmDialogExtensionDropHandler(rightPanel, leftPanel));
    rightPanelWrapper.setDropHandler(new ConfirmDialogExtensionDropHandler(leftPanel, rightPanel));

    addComponent(row);
    setExpandRatio(row, 1.5f);
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.DeployablePanel.java

License:Open Source License

@PostConstruct
public void init() {

    setSizeFull();//from  w w w  . j  a va  2s.c o m

    VerticalLayout mainContent = new VerticalLayout();
    mainContent.setSpacing(true);
    mainContent.setMargin(true);
    mainContent.setStyleName("deployable-style");
    mainContent.setSizeFull();

    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    Button openManager = new Button("Edit repositories");
    openManager.addStyleName("link");
    openManager.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (tabSheet.getTab(manager) == null) {
                tabSheet.addTab(manager, "Manager",
                        new ClassResource(getClass(), "/images/22x22/configuration.png"), containers.size())
                        .setClosable(true);
            }
            tabSheet.setSelectedTab(manager);
        }
    });
    header.addComponent(openManager);
    header.setComponentAlignment(openManager, Alignment.MIDDLE_RIGHT);
    mainContent.addComponent(header);

    tabSheet.setSizeFull();
    mainContent.addComponent(tabSheet);
    mainContent.setExpandRatio(tabSheet, 1.5f);

    DragAndDropWrapper mainContentWrapper = new DragAndDropWrapper(mainContent);
    mainContentWrapper.setDropHandler(new DeploymentDropHandler(deploymentViewManager, this, notifierService));
    mainContentWrapper.setSizeFull();

    setContent(mainContentWrapper);
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deployed.DeployedPanel.java

License:Open Source License

@PostConstruct
public void init() {
    setSizeFull();/*from  w  w w . j av  a 2s  . c  o  m*/
    Table table = new Table();

    VerticalLayout mainContent = new VerticalLayout();
    mainContent.setSpacing(true);
    mainContent.setMargin(true);
    mainContent.setStyleName("deployable-style");
    mainContent.setSizeFull();

    setContent(mainContent);

    HorizontalLayout toolBar = new HorizontalLayout();
    toolBar.setMargin(true);
    toolBar.setSpacing(true);
    toolBar.setWidth("100%");

    // Select all deployed artifacts
    CheckBox selectAll = new CheckBox("All");
    selectAll.addValueChangeListener(new SelectAll(table));
    toolBar.addComponent(selectAll);
    toolBar.setExpandRatio(selectAll, 1);

    // Filter
    TextField filter = new TextField();
    filter.setInputPrompt("Filter deployed artifacts");
    filter.setWidth("100%");
    filter.addTextChangeListener(new FilterFiles(TREE_ITEM_ID, container));
    toolBar.addComponent(filter);
    toolBar.setComponentAlignment(filter, Alignment.TOP_LEFT);
    toolBar.setExpandRatio(filter, 3);

    HorizontalLayout actionArea = new HorizontalLayout();
    final NativeSelect actionSelection = new NativeSelect();
    actionSelection.addItem(DeploymentActions.UNDEPLOY);
    actionSelection.addItem(DeploymentActions.DELETE);
    actionSelection.addItem(DeploymentActions.DEPLOYMENT_PLAN);
    actionSelection.setWidth("100px");
    actionSelection.setNullSelectionAllowed(false);

    Button doButton = new Button("Do");
    doButton.addStyleName("default");
    doButton.addClickListener(
            new DoClickListener(artifactBuilder, table, actionSelection, deploymentViewManager));

    actionArea.addComponent(actionSelection);
    actionArea.addComponent(doButton);
    toolBar.addComponent(actionArea);
    toolBar.setComponentAlignment(actionArea, Alignment.TOP_RIGHT);
    mainContent.addComponent(toolBar);

    VerticalLayout deployedContainer = new VerticalLayout();
    DragAndDropWrapper deployedContainerWrapper = new DragAndDropWrapper(deployedContainer);
    deployedContainerWrapper
            .setDropHandler(new DeploymentDropHandler(deploymentViewManager, this, notifierService));
    deployedContainerWrapper.setSizeFull();
    mainContent.addComponent(deployedContainerWrapper);
    mainContent.setExpandRatio(deployedContainerWrapper, 1.5f);

    container.addContainerProperty(TREE_ITEM_ID, String.class, null);
    table.setSizeFull();
    table.setImmediate(true);
    table.setMultiSelect(true);
    table.setSelectable(true);
    table.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);
    table.setContainerDataSource(container);
    table.setDragMode(Table.TableDragMode.MULTIROW);
    table.setItemCaptionPropertyId(TREE_ITEM_ID);
    table.setCellStyleGenerator(new ItemStyle(DeployableContainerType.DEPLOYED, deploymentManager));
    table.addShortcutListener(new DeleteFileShortcutListener(deploymentViewManager, table, "Delete",
            ShortcutAction.KeyCode.DELETE, null));
    table.setItemDescriptionGenerator(new ItemDescription());
    table.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
                DeployableEntry deployableEntry = (DeployableEntry) event.getItemId();
                try {
                    ArtifactStatusReport report = deploymentManager
                            .getReport(deployableEntry.getUri().toString());
                    event.getComponent().getUI()
                            .addWindow(new DeployableWindow(deployableEntry, report).getWindow());
                } catch (ArtifactStatusReportException e) {
                    LOGGER.warn("Cannot get artifact status report for ''{0}''", deployableEntry.getUri(), e);
                    event.getComponent().getUI().addWindow(new DeployableWindow(deployableEntry).getWindow());
                }
            }
        }
    });
    deployedContainer.addComponent(table);
    deployedContainer.setExpandRatio(table, 1.5f);

    refresh();
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deploymentplan.DeploymentPlanPanel.java

License:Open Source License

@PostConstruct
public void init() {
    setSizeFull();//from   w w w.ja  va2s  . c o m

    TreeTable table = new TreeTable();

    VerticalLayout mainContent = new VerticalLayout();
    mainContent.setSpacing(true);
    mainContent.setMargin(true);
    mainContent.setStyleName("deployable-style");
    mainContent.setSizeFull();

    setContent(mainContent);

    HorizontalLayout toolBar = new HorizontalLayout();
    toolBar.setMargin(true);
    toolBar.setSpacing(true);
    toolBar.setWidth("100%");

    // Deployment Plan name
    Label deploymentPlanNameLabel = new Label("Plan");
    toolBar.addComponent(deploymentPlanNameLabel);
    toolBar.setExpandRatio(deploymentPlanNameLabel, 1);

    deploymentPlanName = new TextField();
    deploymentPlanName.setInputPrompt(getDefaultName());
    deploymentPlanName.setWidth("100%");
    toolBar.addComponent(deploymentPlanName);
    toolBar.setComponentAlignment(deploymentPlanName, Alignment.TOP_LEFT);
    toolBar.setExpandRatio(deploymentPlanName, 3);

    error = new Label("", ContentMode.HTML);
    error.addStyleName("error");
    error.setSizeUndefined();
    error.addStyleName("light");
    error.addStyleName("v-animate-reveal");
    error.setVisible(false);
    toolBar.addComponent(error);
    toolBar.setComponentAlignment(error, Alignment.TOP_RIGHT);
    toolBar.setExpandRatio(error, 1);
    mainContent.addComponent(toolBar);
    mainContent.setComponentAlignment(toolBar, Alignment.TOP_LEFT);
    mainContent.setExpandRatio(toolBar, 1);

    VerticalLayout deploymentPlanContainer = new VerticalLayout();
    DragAndDropWrapper deploymentPlanContainerWrapper = new DragAndDropWrapper(deploymentPlanContainer);
    DropHandler deploymentPlanDropHandler = new DeploymentDropHandler(deploymentViewManager, this,
            notifierService);
    deploymentPlanContainerWrapper.setDropHandler(deploymentPlanDropHandler);
    deploymentPlanContainerWrapper.setSizeFull();
    mainContent.addComponent(deploymentPlanContainerWrapper);
    mainContent.setExpandRatio(deploymentPlanContainerWrapper, 10);

    container.addContainerProperty(TREE_ITEM_ID, String.class, null);
    table.setSizeFull();
    table.setImmediate(true);
    table.setMultiSelect(true);
    table.setSelectable(true);
    table.setContainerDataSource(container);
    table.setDragMode(Table.TableDragMode.MULTIROW);
    table.setItemCaptionPropertyId(TREE_ITEM_ID);
    table.setCellStyleGenerator(new ItemStyle(DeployableContainerType.DEPLOYED));
    table.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);
    table.setDropHandler(new OrderedContainerDropHandler(table, deploymentPlanDropHandler));
    table.addShortcutListener(new ShortcutListener("Delete", ShortcutAction.KeyCode.DELETE, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            Table table = (Table) target;
            Collection<DeployableEntry> deployableEntries = (Collection<DeployableEntry>) table.getValue();
            for (DeployableEntry deployableEntry : deployableEntries) {
                removeDeployable(deployableEntry);
            }
        }
    });
    deploymentPlanContainer.addComponent(table);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setSizeFull();
    footer.setSpacing(true);
    footer.setMargin(true);
    footer.addStyleName("footer");
    footer.setWidth("100%");

    deployIt = new CheckBox("Deploy this deployment plan");
    footer.addComponent(deployIt);
    footer.setComponentAlignment(deployIt, Alignment.TOP_LEFT);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(true);
    Button cancel = new Button("Cancel");
    cancel.addClickListener(new CancelButtonListener());
    Button create = new Button("Create");
    create.addClickListener(new CreateButtonListener());
    create.addStyleName("wide");
    create.addStyleName("default");
    buttons.addComponent(cancel);
    buttons.addComponent(create);
    footer.addComponent(buttons);
    footer.setComponentAlignment(buttons, Alignment.TOP_RIGHT);

    mainContent.addComponent(footer);
    mainContent.setComponentAlignment(footer, Alignment.BOTTOM_RIGHT);
    mainContent.setExpandRatio(footer, 1);
}

From source file:gov.va.ds4p.ds4pmobileportal.ui.eHealthDirect.java

License:Open Source License

private Panel getDropPanel() {
    Panel p = new Panel();
    VerticalLayout v = (VerticalLayout) p.getContent();
    v.setSpacing(true);/*from w w  w.ja v  a 2s  .c  o  m*/
    //v.setHeight("100%");
    p.setStyleName(Runo.PANEL_LIGHT);

    Panel wrapperPanel = new Panel();
    VerticalLayout vDPanel = (VerticalLayout) wrapperPanel.getContent();
    deleteBTN.setIcon(new ThemeResource("../runo/icons/64/folder-add.png"));
    deleteBTN.setWidth("64px");
    deleteBTN.setHeight("64px");

    vDPanel.addComponent(deleteBTN);
    final DragAndDropWrapper wrapper = new DragAndDropWrapper(wrapperPanel);
    wrapper.setWidth("100px");
    wrapper.setHeight("100px");

    wrapperPanel.setStyleName(Runo.PANEL_LIGHT);

    wrapper.setDropHandler(new DropHandler() {

        @Override
        public void drop(DragAndDropEvent event) {
            // expecting this to be an html5 drag
            DragAndDropWrapper.WrapperTransferable tr = (DragAndDropWrapper.WrapperTransferable) event
                    .getTransferable();
            Html5File[] files = tr.getFiles();
            if (files != null) {
                for (final Html5File html5File : files) {
                    final String fileName = html5File.getFileName();

                    if (html5File.getFileSize() > FILE_SIZE_LIMIT) {
                        getWindow().showNotification("File rejected. Max 2MB files are accepted by Sampler",
                                Window.Notification.TYPE_WARNING_MESSAGE);
                    } else {

                        final ByteArrayOutputStream bas = new ByteArrayOutputStream();
                        StreamVariable streamVariable = new StreamVariable() {

                            public OutputStream getOutputStream() {
                                return bas;
                            }

                            public boolean listenProgress() {
                                return false;
                            }

                            public void onProgress(StreamVariable.StreamingProgressEvent event) {
                            }

                            public void streamingStarted(StreamVariable.StreamingStartEvent event) {
                            }

                            public void streamingFinished(StreamVariable.StreamingEndEvent event) {
                                progress.setVisible(false);
                                Boolean res = updateProviderProcessingInbox(bas.toByteArray());
                                if (res.booleanValue()) {
                                    getWindow().showNotification(
                                            "Processing Complete: " + fileName + " " + html5File.getType() + " "
                                                    + html5File.getFileSize(),
                                            Window.Notification.TYPE_HUMANIZED_MESSAGE);
                                } else {
                                    getWindow().showNotification(
                                            "Processing Error: You Do Not Have Necessary Permissions to Receive and Process Files.",
                                            Window.Notification.TYPE_TRAY_NOTIFICATION);
                                }
                            }

                            public void streamingFailed(StreamVariable.StreamingErrorEvent event) {
                                progress.setVisible(false);
                            }

                            public boolean isInterrupted() {
                                return false;
                            }
                        };
                        html5File.setStreamVariable(streamVariable);
                        progress.setVisible(true);
                    }
                }

            } else {
                String text = tr.getText();
                if (text != null) {
                    getWindow().showNotification(text, Window.Notification.TYPE_HUMANIZED_MESSAGE);
                }
            }
        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }
    });

    v.addComponent(wrapper);

    return p;
}