Example usage for com.vaadin.ui DragAndDropWrapper setHeight

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

Introduction

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

Prototype

@Override
    public void setHeight(String height) 

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  w w  . j  a  v a  2s  . 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: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);//www .  j av  a  2  s  .  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;
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.layout.LinkCreationFormLayout.java

License:Mozilla Public License

public void initLayout() {
    setCaption(action.getCaption());// w  ww  .  j  a v a  2s  .c o  m
    // main window layout
    setWidth(FULL_SIZE);
    setMargin(true);
    setSpacing(true);
    final Form inputForm = new Form();
    inputForm.setReadOnly(true);
    inputForm.setWidth(INPUT_FORM_WIDTH);
    addComponent(inputForm);
    inputForm.setImmediate(true);
    inputForm.setWriteThrough(false);

    // set up form data binding
    final LinkData linkData = new LinkData(fromInstance);
    linkData.setToInstance(S23MKernel.coreGraphs.vertex); //default target instance
    final BeanItem<LinkData> item = new BeanItem<LinkData>(linkData);
    inputForm.setItemDataSource(item);
    inputForm.setVisibleItemProperties(LinkData.getDisplayedInstances());
    final HorizontalLayout buttonBarLayout = new HorizontalLayout();
    buttonBarLayout.setSpacing(true);
    buttonBarLayout.setHeight(BUTTON_BAR_HEIGHT);
    inputForm.getFooter().addComponent(buttonBarLayout);

    for (final String key : LinkData.getDisplayedInstances()) {
        inputForm.getField(key).setWidth(FIELD_WIDTH);
    }

    // drop handler
    final DragAndDropWrapper targetWrapper = new DragAndDropWrapper(inputForm);
    targetWrapper.setWidth(FULL_SIZE);
    targetWrapper.setHeight(FULL_SIZE);

    targetWrapper.setDropHandler(new DropHandler() {

        public void drop(final DragAndDropEvent event) {
            final DataBoundTransferable t = (DataBoundTransferable) event.getTransferable();
            final TreeNode node = (TreeNode) t.getData("itemId");
            inputForm.getItemDataSource().getItemProperty(LinkData.TO_INSTANCE).setValue(node.getSet());
            inputForm.getField(LinkData.TARGET).requestRepaint();
        }

        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }
    });
    addComponent(targetWrapper);
    //parent.getMainApplication().getContainmentTreePanel().setEditMode(true);
    //add all visible instances from the fromInstance
    //parent.getMainApplication().getContainmentTreePanel().getScopeMap()
    //      .putAll(addAllVisibleInstanceUUIDs(fromInstance));
    //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null);
    //((org.s23m.cell.editor.semanticdomain.Editor)getApplication()).updateContainmentTree();

    final Button okBtn = new Button("OK", new Button.ClickListener() {
        public void buttonClick(final ClickEvent event) {
            // create a new link instance
            final Set metaInstance = (action.equals(TreeActionHandler.ACTION_CREATE_VISIBILITY))
                    ? S23MKernel.coreGraphs.visibility
                    : S23MKernel.coreGraphs.superSetReference;
            if (action.equals(TreeActionHandler.ACTION_CREATE_VISIBILITY)
                    || action.equals(TreeActionHandler.ACTION_CREATE_SSR)) {
                final Set src = (Set) inputForm.getItemDataSource().getItemProperty(LinkData.FROM_INSTANCE)
                        .getValue();
                final Set trgt = (Set) inputForm.getItemDataSource().getItemProperty(LinkData.TO_INSTANCE)
                        .getValue();
                if (src != null && trgt != null) {
                    final Set v = Instantiation.arrow(metaInstance, src, trgt);
                    String msg = "";
                    if (!v.identity().isEqualTo(
                            S23MSemanticDomains.semanticErr_TargetIsNotWithinVisibility.identity())) {
                        inputForm.commit();
                        msg = "Successfully created a new link";
                        parent.getMainApplication().getMainWindow().showNotification(msg);
                        ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree();
                        parent.closeTab(LinkCreationFormLayout.this);
                    } else {
                        msg = "Failed creating a visibility link: " + v.identity().name();
                        parent.getMainApplication().getMainWindow().showNotification("Error",
                                v.identity().name(), Notification.TYPE_ERROR_MESSAGE);
                    }
                    //parent.getMainApplication().getConsole().setValue(
                    //      parent.getMainApplication().getConsole().getValue() + msg
                    //            + "\n");
                }
            }
            //parent.getMainApplication().getContainmentTreePanel().setEditMode(false);
            //parent.getMainApplication().getContainmentTreePanel().getScopeMap().clear();
            //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null);
        }
    });

    final Button closeBtn = new Button("Cancel", new Button.ClickListener() {
        public void buttonClick(final ClickEvent event) {
            inputForm.discard();
            parent.getMainApplication().getContainmentTreePanel().setEditMode(false);
            parent.getMainApplication().getContainmentTreePanel().getScopeMap().clear();
            ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree();
            //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null);
            //changeSupport.removePropertyChangeListener(EditorController.getInstance());
            parent.closeTab(LinkCreationFormLayout.this);
        }
    });

    buttonBarLayout.addComponent(okBtn);
    buttonBarLayout.addComponent(closeBtn);
    buttonBarLayout.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT);
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.layout.SemanticInstanceCreationFormLayout.java

License:Mozilla Public License

private void initLayout() {
    setCaption(action.getCaption());/*  ww w .  j  a va2  s  . c  om*/
    setWidth(FULL_SIZE);
    setMargin(true);
    setSpacing(true);

    final Form inputForm = new Form();
    inputForm.setReadOnly(true);
    inputForm.setWidth(INPUT_FORM_WIDTH);
    addComponent(inputForm);
    inputForm.setImmediate(true);
    inputForm.setWriteThrough(false);

    inputForm.setFormFieldFactory(new FormFieldFactory() {
        public Field createField(final Item item, final Object propertyId, final Component uiContext) {
            final String textLabel = DefaultFieldFactory.createCaptionByPropertyId(propertyId);
            final TextField f = new TextField(textLabel);
            if (propertyId.toString().equals(SemanticInstanceData.REFERENCED_SEMANTIC_IDENTITY_NAME)) {
                f.setRequiredError(textLabel + " is a mandatory field.");
                f.setRequired(true);
            }
            if (action.equals(TreeActionHandler.ACTION_ADD_SEMANTIC_DOMAIN)) {
                if (propertyId.toString().equals(SemanticInstanceData.NAME)) {
                    f.setRequiredError(textLabel + " is a mandatory field.");
                    f.setRequired(true);
                }
            }
            return f;
        }
    });

    //set up form data binding
    final SemanticInstanceData formData = new SemanticInstanceData("", "", containerInstnace);
    final BeanItem<SemanticInstanceData> item = new BeanItem<SemanticInstanceData>(formData);
    inputForm.setItemDataSource(item);
    if (action.equals(TreeActionHandler.ACTION_ADD_SEMANTIC_ROLE)) {
        inputForm.setVisibleItemProperties(SemanticInstanceData.getDisplayedInstancesForSemanticRole());
    } else {
        inputForm.setVisibleItemProperties(SemanticInstanceData.getDisplayedInstances());
    }

    // drop handler
    final DragAndDropWrapper targetWrapper = new DragAndDropWrapper(inputForm);
    targetWrapper.setWidth(INPUT_FORM_WIDTH);
    targetWrapper.setHeight(INPUT_FORM_WIDTH);

    targetWrapper.setDropHandler(new DropHandler() {

        public void drop(final DragAndDropEvent event) {
            final DataBoundTransferable t = (DataBoundTransferable) event.getTransferable();
            final TreeNode node = (TreeNode) t.getData("itemId");
            inputForm.getItemDataSource().getItemProperty(SemanticInstanceData.REFERENCED_SEMANTIC_IDENTITY)
                    .setValue(node.getSet());
            inputForm.getField(SemanticInstanceData.REFERENCED_SEMANTIC_IDENTITY_NAME).requestRepaint();
        }

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

    addComponent(targetWrapper);

    final HorizontalLayout buttonBarLayout = new HorizontalLayout();
    buttonBarLayout.setSpacing(true);
    buttonBarLayout.setHeight(BUTTON_BAR_HEIGHT);
    inputForm.getFooter().addComponent(buttonBarLayout);

    final Button okBtn = new Button("OK", new Button.ClickListener() {
        public void buttonClick(final ClickEvent event) {
            try {
                if (action.equals(TreeActionHandler.ACTION_ADD_SEMANTIC_IDENTITY)) {
                    inputForm.commit();
                    if (isAnonymousData(formData)) {
                        Instantiation.addAnonymousDisjunctSemanticIdentitySet(formData.getSemanticDomain());
                    } else {
                        Instantiation.addDisjunctSemanticIdentitySet(formData.getName(),
                                formData.getPluralName(), formData.getSemanticDomain());
                    }
                    closeOperation("New semantic identity is created");
                } else if (action.equals(TreeActionHandler.ACTION_ADD_SEMANTIC_DOMAIN)) {
                    inputForm.commit();
                    if (!isAnonymousData(formData)) {
                        Instantiation.addSemanticDomain(formData.getName(), formData.getPluralName(),
                                formData.getSemanticDomain());
                        closeOperation("New semantic domain is created");
                    }
                } else if (action.equals(TreeActionHandler.ACTION_ADD_SEMANTIC_ROLE)) {
                    inputForm.commit();
                    if (formData.getReferencedSemanticIdentity() != null) {
                        F_Transaction.commitChangedSets();
                        log.info("Changeset size " + org.s23m.cell.api.Query.changedSets().size());

                        if (isAnonymousData(formData)) {
                            final Set r = Instantiation.addAnonymousSemanticRole(formData.getSemanticDomain(),
                                    formData.getReferencedSemanticIdentity());
                            log.info("AnonymousSemanticRole " + r.identity().uniqueRepresentationReference()
                                    + " created.");
                        } else {
                            final Set r = Instantiation.addSemanticRole(formData.getName(),
                                    formData.getPluralName(), formData.getSemanticDomain(),
                                    formData.getReferencedSemanticIdentity());
                            log.info("Semantic role " + r.identity().name() + " created.");
                        }

                        log.info("Changeset size after creation "
                                + org.s23m.cell.api.Query.changedSets().size());
                        closeOperation("New semantic role is created");
                    } else {
                        parentTab.getMainApplication().getMainWindow().showNotification(
                                "Missing referenced semantic identity", Window.Notification.TYPE_ERROR_MESSAGE);
                    }
                }
            } catch (final EmptyValueException th) {
            }
        }

        private void closeOperation(final String message) {
            parentTab.getMainApplication().getMainWindow().showNotification(message);
            ((Editor) getApplication()).updateContainmentTree();
            //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null);
            //changeSupport.removePropertyChangeListener(EditorController.getInstance());
            parentTab.closeTab(SemanticInstanceCreationFormLayout.this);
        }
    });

    final Button cancelBtn = new Button("Cancel", new Button.ClickListener() {
        public void buttonClick(final ClickEvent event) {
            inputForm.discard();
            ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree();
            //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null);
            changeSupport.removePropertyChangeListener(EditorController.getInstance());
            parentTab.closeTab(SemanticInstanceCreationFormLayout.this);
        }
    });

    buttonBarLayout.addComponent(okBtn);
    buttonBarLayout.addComponent(cancelBtn);
    buttonBarLayout.setComponentAlignment(cancelBtn, Alignment.TOP_RIGHT);

}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.layout.VertexCreationFormLayout.java

License:Mozilla Public License

private void createInputForm() {
    setCaption(action.getCaption());/*w w  w  .  j  av a  2  s  .c o  m*/
    setWidth(WINDOW_WIDTH);

    setMargin(true);
    setSpacing(true);

    final Form inputForm = new Form();
    inputForm.setWidth(INPUT_FORM_WIDTH);
    addComponent(inputForm);
    inputForm.setImmediate(true);
    inputForm.setWriteThrough(false);

    final InstantiationData instData = new InstantiationData(metaInstance, containerInstance.identity().name(),
            false, "", "");
    final BeanItem<InstantiationData> instItem = new BeanItem<InstantiationData>(instData);
    inputForm.setItemDataSource(instItem);
    inputForm.setVisibleItemProperties(InstantiationData.getDisplayOrder());

    // drop handler
    final DragAndDropWrapper targetWrapper = new DragAndDropWrapper(inputForm);
    targetWrapper.setWidth(WINDOW_WIDTH);
    targetWrapper.setHeight("100%");

    targetWrapper.setDropHandler(new DropHandler() {

        public void drop(final DragAndDropEvent event) {
            final DataBoundTransferable t = (DataBoundTransferable) event.getTransferable();
            final TreeNode node = (TreeNode) t.getData("itemId");
            if (SetType.isSemanticDomainNode(node.getSet())) {
                instData.setIdentity(node.getSet());
                inputForm.getField(InstantiationData.NAME).requestRepaint();
                inputForm.getField(InstantiationData.PLURAL_NAME).requestRepaint();
                inputForm.setComponentError(null);
            } else {
                inputForm.getItemDataSource().getItemProperty(InstantiationData.METAINSTANCE)
                        .setValue(node.getSet());
                inputForm.getField(InstantiationData.METAINSTANCE_NAME).requestRepaint();

            }
        }

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

    final HorizontalLayout okbar = new HorizontalLayout();
    okbar.setSpacing(true);
    okbar.setHeight(BUTTON_BAR_HEIGHT);
    inputForm.getFooter().addComponent(okbar);
    for (final String key : InstantiationData.getDisplayOrder()) {
        inputForm.getField(key).setWidth(FIELD_WIDTH);
    }

    final Button okBtn = new Button(OK_BUTTON_TEXT, new Button.ClickListener() {
        public void buttonClick(final ClickEvent event) {
            //create a new instance
            inputForm.commit();
            if (!checkForEmptyInstances(instData)) {
                Set s = null;
                String msgCaption = "";

                if (action.equals(TreeActionHandler.ACTION_ADD)) {
                    msgCaption = INSTANCE_ADDITION_MSG;
                    if (instData.isAbstract()) {
                        ;
                        s = containerInstance.addAbstract(instData.getMetaInstance(), instData.getIdentity());
                    } else {
                        s = containerInstance.addConcrete(instData.getMetaInstance(), instData.getIdentity());
                    }
                } else if (action.equals(TreeActionHandler.ACTION_INSTANTIATE)) {
                    msgCaption = INSTANCE_INSTANTIATION_MSG;
                    if (instData.isAbstract()) {
                        s = Instantiation.instantiateAbstract(metaInstance, instData.getIdentity());
                    } else {
                        s = Instantiation.instantiateConcrete(metaInstance, instData.getIdentity());
                    }
                }

                if (s != null && s.identity().name().equals(instData.getName())) {
                    parent.getMainApplication().getMainWindow().showNotification(msgCaption);
                    ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree();
                    //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null);
                    //changeSupport.removePropertyChangeListener(EditorController.getInstance());
                    parent.closeTab(VertexCreationFormLayout.this);
                } else {
                    parent.getMainApplication().getMainWindow().showNotification("Error", s.identity().name(),
                            Notification.TYPE_ERROR_MESSAGE);
                }
            }
        }

        private boolean checkForEmptyInstances(final InstantiationData instData) {
            boolean gotEmptyValue = false;
            if (instData.getMetaInstance() == null) {
                inputForm.setComponentError(new UserError(
                        DefaultFieldFactory.createCaptionByPropertyId(InstantiationData.METAINSTANCE)
                                + " is missing."));
                gotEmptyValue = true;
            }
            if (instData.getIdentity() == null) {
                inputForm.setComponentError(
                        new UserError(DefaultFieldFactory.createCaptionByPropertyId(InstantiationData.IDENTITY)
                                + " is missing."));
                gotEmptyValue = true;
            }
            return gotEmptyValue;
        }
    });

    final Button closeBtn = new Button(CANCEL_BUTTON_TEXT, new Button.ClickListener() {
        public void buttonClick(final ClickEvent event) {
            inputForm.discard();
            ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree();
            //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null);
            changeSupport.removePropertyChangeListener(EditorController.getInstance());
            parent.closeTab(VertexCreationFormLayout.this);
        }
    });

    okbar.addComponent(okBtn);
    okbar.addComponent(closeBtn);
    okbar.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT);
}