Example usage for com.vaadin.ui DragAndDropWrapper setSizeUndefined

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

Introduction

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

Prototype

@Override
    public void setSizeUndefined() 

Source Link

Usage

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 ww. j a va2s . com*/
    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.mcparland.john.ComponentCollection.java

License:Apache License

/**
 * Create some tabs for each size/*  www.j  a  va 2  s  .c om*/
 * 
 * @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 button./* ww w .j  a  v  a  2s.  c  om*/
 * 
 * @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:org.hip.vif.web.util.UploadComponent.java

License:Open Source License

private Component createDropBox(final IBibliographyTask inTask) {
    final CssLayout lDropPane = new CssLayout();
    lDropPane.setWidth("200px"); //$NON-NLS-1$
    lDropPane.setHeight("40px"); //$NON-NLS-1$
    lDropPane.addStyleName("v-textfield"); //$NON-NLS-1$
    final Label lHint = new Label(Activator.getMessages().getMessage("ui.upload.drop.box")); //$NON-NLS-1$
    lHint.setStyleName("vif-drop-hint"); //$NON-NLS-1$
    lDropPane.addComponent(lHint);//from   w  w  w .j  a  v a 2  s .c om

    final DragAndDropWrapper outDrop = new DragAndDropWrapper(lDropPane);
    outDrop.setDropHandler(new DropHandler() {
        @Override
        public AcceptCriterion getAcceptCriterion() { // NOPMD
            return AcceptAll.get();
        }

        @Override
        public void drop(final DragAndDropEvent inEvent) { // NOPMD
            final Transferable lTransferable = inEvent.getTransferable();
            if (lTransferable instanceof WrapperTransferable) {
                final Html5File[] lFiles = ((WrapperTransferable) lTransferable).getFiles();
                for (final Html5File lFile : lFiles) {
                    lFile.setStreamVariable(createStreamVariable(lFile.getFileName(), inTask));
                }
            }
        }
    });

    outDrop.setSizeUndefined();
    outDrop.setImmediate(true);
    return outDrop;
}

From source file:org.jumpmind.metl.ui.views.design.EditFlowPalette.java

License:Open Source License

protected void addItemToFlowPanelSection(String labelName, String componentType, VerticalLayout componentLayout,
        ClassResource icon, String componentId) {

    FlowPaletteItem paletteItem = new FlowPaletteItem(labelName);
    if (componentId != null) {
        paletteItem.setShared(true);/*  w w w  . j  a v  a2 s  .  c o  m*/
        paletteItem.setComponentId(componentId);
    } else {
        paletteItem.setComponentType(componentType);
        paletteItem.setShared(false);
    }
    paletteItem.setIcon(icon);
    paletteItem.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
    paletteItem.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
    paletteItem.addStyleName("leftAligned");
    paletteItem.setWidth(100, Unit.PERCENTAGE);
    DragAndDropWrapper wrapper = new DragAndDropWrapper(paletteItem);
    wrapper.setSizeUndefined();
    wrapper.setDragStartMode(DragStartMode.WRAPPER);
    componentLayout.addComponent(wrapper);
    componentLayout.setComponentAlignment(wrapper, Alignment.TOP_CENTER);

}

From source file:org.jumpmind.metl.ui.views.design.EditFlowPanel.java

License:Open Source License

public EditFlowPanel(ApplicationContext context, String flowId, DesignNavigator designNavigator,
        TabbedPanel tabs) {//from w  w w . ja v a2  s .com

    this.configurationService = context.getConfigurationService();
    this.flow = configurationService.findFlow(flowId);
    this.readOnly = context.isReadOnly(configurationService.findProjectVersion(flow.getProjectVersionId()),
            Privilege.DESIGN);
    this.context = context;
    this.tabs = tabs;
    this.designNavigator = designNavigator;

    this.propertySheet = new PropertySheet(context, tabs, readOnly);
    this.propertySheet.setListener((components) -> {
        List<FlowStep> steps = new ArrayList<FlowStep>();
        for (Component c : components) {
            steps.add(EditFlowPanel.this.flow.findFlowStepWithComponentId(c.getId()));
        }
        refreshStepOnDiagram(steps);
    });
    this.propertySheet.setCaption("Property Sheet");

    this.componentPalette = new EditFlowPalette(this, context, flow.getProjectVersionId());

    addComponent(componentPalette);

    VerticalLayout rightLayout = new VerticalLayout();
    rightLayout.setSizeFull();

    rightLayout.addComponent(buildButtonBar());

    VerticalSplitPanel splitPanel = new VerticalSplitPanel();
    splitPanel.setSizeFull();
    splitPanel.setSplitPosition(50, Unit.PERCENTAGE);

    diagramLayout = new VerticalLayout();
    diagramLayout.setWidth(10000, Unit.PIXELS);
    diagramLayout.setHeight(10000, Unit.PIXELS);

    DragAndDropWrapper wrapper = new DragAndDropWrapper(diagramLayout);
    wrapper.setSizeUndefined();
    wrapper.setDropHandler(new DropHandler());

    flowPanel = new Panel();
    flowPanel.setSizeFull();
    flowPanel.addStyleName(ValoTheme.PANEL_WELL);
    flowPanel.setContent(wrapper);

    splitPanel.addComponent(flowPanel);
    splitPanel.addComponent(propertySheet);

    rightLayout.addComponent(splitPanel);
    rightLayout.setExpandRatio(splitPanel, 1);

    addComponent(rightLayout);
    setExpandRatio(rightLayout, 1);

    if (flow.getFlowSteps().size() > 0) {
        selected = new ArrayList<AbstractObject>();
        selected.add(flow.getFlowSteps().get(0));
        propertySheet.setSource(selected);
    }

    redrawFlow();
}

From source file:org.lucidj.browser.ComponentPalette.java

License:Apache License

private boolean add_component_to_palette(ComponentDescriptor component) {
    String canonical_name = component.getComponentClass();
    String icon_title = component.getIconTitle();

    log.info("*** => ADDING component {} ({})", canonical_name, component);

    int base_width = 6;
    int margin_h_size_px = base_width / 2;
    int margin_v_size_px = base_width;
    int icon_size_px = base_width * 6;
    int font_size_px = 2 * base_width + 2;
    int icon_box_width_px = base_width * 12;

    String icon_html = "<div style='text-align: center; height:auto; display:inline-block; " + "margin:"
            + margin_v_size_px + "px " + margin_h_size_px + "px;" + "width:" + icon_box_width_px
            + "px; line-height:1.1em;'>" + "<img src='" + component.getIconUrl() + "' " + "width='"
            + icon_size_px + "px' height='" + icon_size_px + "px' />"
            + "<div style='white-space:normal; word-wrap:break-word; font-weight: 400;" + "font-size:"
            + font_size_px + "px;'>" + icon_title + "</div>" + "</div>";

    Label icon_label = new Label(icon_html, ContentMode.HTML);
    icon_label.setWidthUndefined();/*ww  w.  ja v a2 s . c o m*/

    // Put the component in a D&D wrapper and allow dragging it
    final DragAndDropWrapper icon_dd_wrap = new DragAndDropWrapper(icon_label);
    icon_dd_wrap.setDragStartMode(DragAndDropWrapper.DragStartMode.COMPONENT);

    // Set the wrapper to wrap tightly around the component
    icon_dd_wrap.setSizeUndefined();
    icon_dd_wrap.setData(component);

    // Set canonical_name for drag-drop AND on the Label for double-click
    icon_dd_wrap.setId(canonical_name);
    icon_label.setId(canonical_name);

    // Remember this association
    component_to_vaadin.put(component, icon_dd_wrap);

    // Add the wrapper, not the component, to the layout
    self.addComponent(icon_dd_wrap);
    return (true);
}

From source file:org.lucidj.iconlist.renderer.IconListRenderer.java

License:Apache License

private AbstractComponent create_icon(Map<String, Object> component) {
    String icon_title = (String) component.get("iconTitle");

    if (icon_title == null) {
        icon_title = "No title";
    }/* w ww  .ja  v a  2  s.c  o m*/

    Resource icon_resource = iconHelper.getIcon((String) component.get("iconUrl"), 32);

    Button button_icon = new Button(icon_title);
    button_icon.setIcon(icon_resource);
    button_icon.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    button_icon.addStyleName(ValoTheme.BUTTON_SMALL);
    button_icon.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
    button_icon.addStyleName("x-icon-button");
    button_icon.addStyleName("icon-size-32");
    button_icon.addClickListener(this);
    button_icon.setWidthUndefined();
    button_caption_wrap(button_icon);

    // Put the component in a D&D wrapper and allow dragging it
    final DragAndDropWrapper icon_dd_wrap = new DragAndDropWrapper(button_icon);
    icon_dd_wrap.setDragStartMode(DragAndDropWrapper.DragStartMode.COMPONENT);

    // Set the wrapper to wrap tightly around the component
    icon_dd_wrap.setSizeUndefined();
    icon_dd_wrap.setData(component);

    // Set ID for drag-drop AND on the Label for double-click
    if (component.containsKey("entryId")) {
        String entryId = (String) component.get("entryId");
        icon_dd_wrap.setId(entryId);
        button_icon.setId(entryId);
    }

    // Component data is the map itself
    button_icon.setData(component);

    // Remember this association
    component_to_vaadin.put(component, icon_dd_wrap);
    return (icon_dd_wrap);
}

From source file:org.peergreen.vaadin.diagram.Toolbar.java

License:Open Source License

private Component createDragEntry(final ToolbarItem item) {
    Entry entry = new Entry(item);
    DragAndDropWrapper drag = new DragAndDropWrapper(entry) {
        @Override//from   w w w.j  av a  2 s  .c o m
        public Transferable getTransferable(final Map<String, Object> variables) {
            variables.put("component-type", item.getName());
            return super.getTransferable(variables);
        }
    };
    drag.setSizeUndefined();
    drag.setDragStartMode(DragStartMode.COMPONENT);
    return drag;
}