Example usage for com.vaadin.ui DragAndDropWrapper DragAndDropWrapper

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

Introduction

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

Prototype

public DragAndDropWrapper(Component root) 

Source Link

Document

Wraps given component in a DragAndDropWrapper .

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 . j a v  a 2 s  .  com
    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.constellio.app.ui.pages.base.MainLayoutImpl.java

public MainLayoutImpl(AppLayerFactory appLayerFactory) {
    this.presenter = new MainLayoutPresenter(this);

    mainMenuContentFooterLayout = new HorizontalLayout();
    mainMenuContentFooterLayout.setSizeFull();
    mainMenuContentFooterLayout.addStyleName("main-menu-content-footer");

    contentViewWrapper = new Panel();

    Navigator navigator = new Navigator(UI.getCurrent(), contentViewWrapper);
    NavigatorConfigurationService navigatorConfigurationService = appLayerFactory
            .getNavigatorConfigurationService();
    navigatorConfigurationService.configure(navigator);
    UI.getCurrent().setNavigator(navigator);

    contentFooterWrapperLayout = new CssLayout();
    contentFooterWrapperLayout.setId("content-footer-wrapper");

    contentFooterLayout = new VerticalLayout();
    contentFooterLayout.addStyleName("content-footer");

    header = buildHeader();//from   ww w.  j av  a2s. c  o  m
    header.setSizeUndefined();

    mainMenu = buildMainMenu();

    userDocumentsWindow = new UserDocumentsWindow();
    dragAndDropWrapper = new DragAndDropWrapper(mainMenuContentFooterLayout);
    dragAndDropWrapper.setSizeFull();
    dragAndDropWrapper.setDropHandler(userDocumentsWindow);
    navigator.addViewChangeListener(new ViewChangeListener() {
        @Override
        public boolean beforeViewChange(ViewChangeEvent event) {
            return true;
        }

        @Override
        public void afterViewChange(ViewChangeEvent event) {
            View newView = event.getNewView();
            if (newView instanceof NoDragAndDrop) {
                dragAndDropWrapper.setDropHandler(null);
            } else if (newView instanceof DropHandler) {
                dragAndDropWrapper.setDropHandler((DropHandler) newView);
            } else {
                List<DropHandler> viewDropHandlers = ComponentTreeUtils.getChildren((Component) newView,
                        DropHandler.class);
                if (viewDropHandlers.size() > 1) {
                    dragAndDropWrapper.setDropHandler(null);
                } else if (viewDropHandlers.size() == 1) {
                    dragAndDropWrapper.setDropHandler(viewDropHandlers.get(0));
                } else if (dragAndDropWrapper.getDropHandler() != userDocumentsWindow) {
                    dragAndDropWrapper.setDropHandler(userDocumentsWindow);
                }
            }
            //            SerializationUtils.clone(event.getOldView());
            //            SerializationUtils.clone(newView);
        }
    });

    addComponent(header);
    addComponent(dragAndDropWrapper);
    setExpandRatio(dragAndDropWrapper, 1);

    mainMenuContentFooterLayout.addComponent(mainMenu);
    mainMenuContentFooterLayout.addComponent(contentFooterWrapperLayout);
    mainMenuContentFooterLayout.setExpandRatio(contentFooterWrapperLayout, 1);

    contentFooterWrapperLayout.addComponent(contentFooterLayout);

    contentFooterLayout.addComponent(contentViewWrapper);

    Component message = buildMessage();
    if (message != null) {
        message.addStyleName("message");
        contentFooterLayout.addComponent(message);
    }

    contentFooterLayout.setExpandRatio(contentViewWrapper, 1);

    Component footer = buildFooter();
    if (footer != null) {
        contentFooterLayout.addComponent(footer);
    }

    Component license = buildLicense();
    if (license != null) {
        license.addStyleName("license");
    }

    PagesComponentsExtensionParams params = new PagesComponentsExtensionParams(header, mainMenu,
            contentFooterLayout, this, contentViewWrapper, contentFooterWrapperLayout, presenter.getUser());
    appLayerFactory.getExtensions().getSystemWideExtensions().decorateView(params);
    String collection = ConstellioUI.getCurrentSessionContext().getCurrentCollection();
    if (collection != null) {
        appLayerFactory.getExtensions().forCollection(collection).decorateView(params);
    }

    buildInitJavascript();
}

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();/*www .j  a  v a  2 s. com*/

    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);/*w w  w  .  j a  va  2s. 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 ?/*w  w  w  .  j a v a  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.ComponentCollection.java

License:Apache License

/**
 * Create some tabs for each size/*from  ww w.  j a  v a2s . c  o m*/
 * 
 * @param sizes
 *            the sizes
 */
private void createTabs() {
    for (String size : sizes) {
        final Layout layout = createLayout();
        layout.setCaption("Icons size " + size + " x " + size);
        addComponent(layout);

        for (String icon : icons) {
            final Image image = createImage(size, icon);
            DragAndDropWrapper imageWrap = new DragAndDropWrapper(image);
            imageWrap.setDragStartMode(DragStartMode.COMPONENT);
            imageWrap.setSizeUndefined();
            layout.addComponent(imageWrap);
        }
    }
}

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

License:Apache License

/**
 * Create a drag-and-droppable layout./*from   w ww  .ja  v a2s .  c om*/
 * 
 * @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.mcparland.john.DragAndDropPanel.java

License:Apache License

/**
 * Create a drag-and-droppable button.//w  w  w .  ja v a 2 s .  c  o m
 * 
 * @param name
 *            the name of the button.
 * @return a drag-and-droppable button.
 */
public Component createButton(String name) {
    Button button = new Button(name);
    DragAndDropWrapper buttonWrap = new DragAndDropWrapper(button);
    buttonWrap.setDragStartMode(DragStartMode.COMPONENT);
    buttonWrap.setSizeUndefined();
    return buttonWrap;
}

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

License:Open Source License

public ConfirmDialogExtension() {
    setSizeFull();//from  ww 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.example.webconsole.extensions.ConfirmDialogExtension.java

License:Open Source License

private DragAndDropWrapper getDraggableComponent(Component component) {
    DragAndDropWrapper dragAndDropWrapper = new DragAndDropWrapper(component);
    dragAndDropWrapper.setDragStartMode(DragAndDropWrapper.DragStartMode.COMPONENT);
    return dragAndDropWrapper;
}