Example usage for com.google.gwt.user.client.ui HorizontalPanel setCellHorizontalAlignment

List of usage examples for com.google.gwt.user.client.ui HorizontalPanel setCellHorizontalAlignment

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui HorizontalPanel setCellHorizontalAlignment.

Prototype

public void setCellHorizontalAlignment(IsWidget w, HorizontalAlignmentConstant align) 

Source Link

Document

Overloaded version for IsWidget.

Usage

From source file:org.jboss.errai.workspaces.client.widgets.WSLoginPanel.java

License:Apache License

public WSLoginPanel() {
    this.widget = new Composite() {
        {/*w  w w . j av a  2  s . c o  m*/
            VerticalPanel mainPanel = new VerticalPanel();
            HorizontalPanel login = new HorizontalPanel();
            HorizontalPanel password = new HorizontalPanel();
            HorizontalPanel buttons = new HorizontalPanel();

            mainPanel.add(login);
            mainPanel.add(password);
            mainPanel.add(buttons);

            Label userNameLabel = new Label("User:");
            Label passwordLabel = new Label("Password:");

            userNameInput = new TextBox();
            passwordInput = new PasswordTextBox();

            login.add(userNameLabel);
            login.add(userNameInput);
            login.setWidth("100%");
            login.setCellHorizontalAlignment(userNameInput, HasAlignment.ALIGN_RIGHT);
            password.add(passwordLabel);

            password.add(passwordInput);
            password.setWidth("100%");
            password.setCellHorizontalAlignment(passwordInput, HasAlignment.ALIGN_RIGHT);

            loginButton = new Button("Login");
            buttons.add(loginButton);
            buttons.setWidth("100%");
            buttons.setCellHorizontalAlignment(loginButton, HasAlignment.ALIGN_RIGHT);

            // clickhandler comes form presenter

            KeyDownHandler formSubmit = new KeyDownHandler() {
                public void onKeyDown(KeyDownEvent event) {
                    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                        loginButton.click();
                    }
                }
            };

            userNameInput.addKeyDownHandler(formSubmit);
            passwordInput.addKeyDownHandler(formSubmit);

            initWidget(mainPanel);
        }
    };
}

From source file:org.kaaproject.avro.ui.gwt.client.widget.BusyPopup.java

License:Apache License

public BusyPopup() {
    glass = Document.get().createDivElement();
    glass.setClassName(Utils.avroUiStyle.busyGlass());

    glass.getStyle().setPosition(Position.ABSOLUTE);
    glass.getStyle().setLeft(0, Unit.PX);
    glass.getStyle().setTop(0, Unit.PX);
    glass.getStyle().setZIndex(GLASS_Z_INDEX);

    getElement().getStyle().setZIndex(POPUP_Z_INDEX);

    HorizontalPanel panel = new HorizontalPanel();
    panel.setSize("320px", "70px");
    panel.addStyleName(Utils.avroUiStyle.busyPopup());
    Image image = new Image();
    image.setResource(Utils.resources.busyIndicator());
    panel.add(image);/*  www. j  ava  2s.  c  om*/
    panel.setCellWidth(image, "60px");
    panel.setCellHorizontalAlignment(image, HasHorizontalAlignment.ALIGN_CENTER);
    panel.setCellVerticalAlignment(image, HasVerticalAlignment.ALIGN_MIDDLE);
    Label label = new Label();
    label.setText(Utils.constants.busyPopupText());
    label.getElement().getStyle().setPaddingRight(15, Unit.PX);
    panel.add(label);
    panel.setCellHorizontalAlignment(label, HasHorizontalAlignment.ALIGN_CENTER);
    panel.setCellVerticalAlignment(label, HasVerticalAlignment.ALIGN_MIDDLE);
    setWidget(panel);

}

From source file:org.kie.workbench.common.screens.datamodeller.client.widgets.advanceddomain.util.CommandDrivenAccordionGroup.java

License:Apache License

public CommandDrivenAccordionGroup(String commandName, Command command) {
    super(Constants.ACCORDION_GROUP);

    DivWidget body = new DivWidget(Constants.ACCORDION_BODY);

    body.add(innerBody);/*from w ww  .  j av  a 2 s. c om*/

    collapse = new Collapse();

    collapse.setWidget(body);

    collapse.setExistTrigger(true);

    trigger.addStyleName(Constants.ACCORDION_TOGGLE);

    collapseTrigger = new CollapseTrigger("#" + collapse.getId());

    collapseTrigger.setWidget(trigger);

    DivWidget heading = new DivWidget(Constants.ACCORDION_HEADING);

    HorizontalPanel headingContent = new HorizontalPanel();
    heading.add(headingContent);

    headingContent.setWidth("100%");

    headingContent.add(collapseTrigger);
    final int currentItem = item;

    this.command = command;
    commandButton = new Button(commandName, new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (CommandDrivenAccordionGroup.this.command != null) {
                CommandDrivenAccordionGroup.this.command.execute();
            }
        }
    });

    commandButton.setStylePrimaryName("accordion-toggle");

    DivWidget buttonContainer = new DivWidget();
    buttonContainer.setStyle(new Style() {
        @Override
        public String get() {
            return "float: right;";
        }
    });

    buttonContainer.add(commandButton);
    headingContent.add(buttonContainer);

    headingContent.setCellHorizontalAlignment(buttonContainer, HasHorizontalAlignment.ALIGN_RIGHT);

    super.add(heading);

    super.add(collapse.asWidget());
}

From source file:org.mindinformatics.gwt.domeo.plugins.annotation.comment.ui.tile.TCommentTile.java

License:Apache License

public void createProvenanceBar(HorizontalPanel provenance, final MAnnotation annotation) {
    int step = 0;
    try {// w ww .ja v  a2  s .  c o m
        Resources resource = Domeo.resources;
        Image editIcon = new Image(resource.editLittleIcon());
        editIcon.setTitle("Edit Item");
        editIcon.setStyleName(ATileComponent.tileResources.css().button());
        //editIcon.addClickHandler(ActionEditAnnotation.getClickHandler(_domeo, this, _listener, getAnnotation()));
        step = 1;

        Image showIcon = new Image(resource.showLittleIcon());
        showIcon.setTitle("Show Item in Context");
        showIcon.setStyleName(ATileComponent.tileResources.css().button());
        showIcon.addClickHandler(ActionShowAnnotation.getClickHandler(_domeo, this, getAnnotation()));
        step = 2;

        /*
        Image addCommentIcon = new Image(resource.addCommentIcon());
        addCommentIcon.setTitle("Comment on item");
        addCommentIcon.setStyleName(ATileComponent.tileResources.css().button());
        addCommentIcon.addClickHandler(new ClickHandler() {
           @Override
           public void onClick(ClickEvent event) {
              showCommentForm();
           }
        });
        step=3;
                
        Image commentBranchIcon = new Image(resource.splitCommentIcon());
        commentBranchIcon.setTitle("Comment on item");
        commentBranchIcon.setStyleName(ATileComponent.tileResources.css().button());
        commentBranchIcon.addClickHandler(new ClickHandler() {
           @Override
           public void onClick(ClickEvent event) {
              showCommentBranchForm();
           }
        });
        step=4;
        */

        //final CommentsViewerPanel viewer = _viewer;
        final MAnnotation ann = _annotation;
        submitButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                if (addCommentBody.getText().trim().length() == 0)
                    return;
                MAnnotationSelector selector = AnnotationFactory.createAnnotationSelector(
                        _domeo.getAgentManager().getUserPerson(),
                        _domeo.getPersistenceManager().getCurrentResource(), ann);
                MCommentAnnotation annotation = AnnotationFactory.createComment(
                        _domeo.getPersistenceManager().getCurrentSet(),
                        _domeo.getAgentManager().getUserPerson(), _domeo.getAgentManager().getSoftware(),
                        _domeo.getPersistenceManager().getCurrentResource(), selector,
                        addCommentBody.getText());
                if (addCommentTitle.getValue() != null && addCommentTitle.getValue().trim().length() > 0) {
                    annotation.setTitle(addCommentTitle.getValue());
                }

                _domeo.getAnnotationPersistenceManager().addAnnotationOfAnnotation(annotation, ann,
                        _domeo.getAnnotationPersistenceManager().getSetByAnnotationId(ann.getLocalId()));

                ASideTab tab = _domeo.getDiscussionSideTab();
                ASidePanel panel = _domeo.getSidePanelsFacade().getPanelForTab(tab);
                ((ICommentsRefreshableComponent) panel).refreshFromRoot();
                _domeo.refreshAnnotationComponents();

                TCommentTile c = new TCommentTile(_domeo, _listener);
                TreeItem i = new TreeItem(c.getTile());
                i.setState(true);
                c.initializeLens(annotation);

                hideCommentForm();
                //viewer.refreshThreadsTree();
            }
        });

        cancelButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                hideCommentForm();
            }
        });

        Image deleteIcon = new Image(resource.deleteLittleIcon());
        deleteIcon.setTitle("Delete Item");
        deleteIcon.setStyleName(ATileComponent.tileResources.css().button());
        deleteIcon.addClickHandler(ActionDeleteAnnotation.getClickHandler(_domeo, this, getAnnotation()));
        step = 5;

        _domeo.getLogger().debug(this, "" + annotation.getCreator());
        _domeo.getLogger().debug(this, annotation.getCreator().getUri());

        // TODO move to an abstract tile class
        if (((BooleanPreference) _domeo.getPreferences().getPreferenceItem(Domeo.class.getName(),
                Domeo.PREF_DISPLAY_PROVENANCE)).getValue()) {
            if (annotation.getCreator().getUri().equals(_domeo.getAgentManager().getUserPerson().getUri())) {
                if (((BooleanPreference) _domeo.getPreferences().getPreferenceItem(Domeo.class.getName(),
                        Domeo.PREF_DISPLAY_USER_PROVENANCE)).getValue()) {
                    provenance.clear();
                    step = 6;
                    // TODO Externalize the icon management to the plugins
                    if (SelectorUtils.isOnMultipleTargets(annotation.getSelectors())) {
                        Image ic = new Image(Domeo.resources.multipleLittleIcon());
                        ic.setTitle("Annotation on multiple targets");
                        provenance.add(ic);
                        provenance.setCellWidth(ic, "18px");
                    } else if (annotation.getSelector() != null
                            && annotation.getSelector().getTarget() instanceof MOnlineImage) {
                        Image ic = new Image(Domeo.resources.littleImageIcon());
                        ic.setTitle("Annotation on image");
                        provenance.add(ic);
                        provenance.setCellWidth(ic, "18px");
                    } else {
                        if (SelectorUtils.isOnAnnotation(annotation.getSelectors())) {
                            if (((MCommentAnnotation) annotation).getTitle() != null
                                    && ((MCommentAnnotation) annotation).getTitle().trim().length() > 0) {
                                Image ic = new Image(Domeo.resources.splitCommentIcon());
                                ic.setTitle("Discussion branch");
                                provenance.add(ic);
                                provenance.setCellWidth(ic, "18px");
                            } else {
                                Image ic = new Image(Domeo.resources.littleCommentIcon());
                                ic.setTitle("Discussion comment");
                                provenance.add(ic);
                                provenance.setCellWidth(ic, "18px");
                            }
                        } else if (SelectorUtils.isOnResourceTarget(annotation.getSelectors())) {
                            Image ic = new Image(Domeo.resources.littleCommentsIcon());
                            ic.setTitle("Annotation on annotation");
                            provenance.add(ic);
                            provenance.setCellWidth(ic, "18px");
                        } else {
                            Image ic = new Image(Domeo.resources.littleTextIcon());
                            ic.setTitle("Annotation on text");
                            provenance.add(ic);
                            provenance.setCellWidth(ic, "18px");
                        }
                    }
                    step = 7;

                    provenance.add(new HTML(
                            "<span style='font-weight: bold; font-size: 12px; color: #696969'>By Me</span>  <span style='padding-left:5px' title='"
                                    + annotation.getFormattedCreationDate() + "'>"
                                    + elaspedTime((new Date()).getTime() - annotation.getCreatedOn().getTime())
                                    + " ago</span>"));
                    if (!(annotation.getSelector() instanceof MTargetSelector)
                            && !(annotation.getSelector() instanceof MAnnotationSelector)) {
                        provenance.add(showIcon);
                        provenance.setCellWidth(showIcon, "22px");
                        provenance.add(editIcon);
                        provenance.setCellWidth(editIcon, "22px");
                    }
                    //                  provenance.add(addCommentIcon);
                    //                  provenance.setCellHorizontalAlignment(addCommentIcon, HasHorizontalAlignment.ALIGN_LEFT);
                    //                  provenance.setCellWidth(addCommentIcon, "22px");
                    //                  provenance.add(commentBranchIcon);
                    //                  provenance.setCellHorizontalAlignment(commentBranchIcon, HasHorizontalAlignment.ALIGN_LEFT);
                    //                  provenance.setCellWidth(commentBranchIcon, "22px");
                    provenance.add(deleteIcon);
                    provenance.setCellHorizontalAlignment(deleteIcon, HasHorizontalAlignment.ALIGN_LEFT);
                    provenance.setCellWidth(deleteIcon, "22px");
                } else {
                    provenance.setVisible(false);
                }
            } else {
                provenance.clear();
                step = 8;
                if (SelectorUtils.isOnMultipleTargets(annotation.getSelectors())) {
                    Image ic = new Image(Domeo.resources.multipleLittleIcon());
                    ic.setTitle("Annotation on multiple targets");
                    provenance.add(ic);
                    provenance.setCellWidth(ic, "18px");
                } else if (annotation.getSelector() != null
                        && annotation.getSelector().getTarget() instanceof MOnlineImage) {
                    Image ic = new Image(Domeo.resources.littleImageIcon());
                    ic.setTitle("Annotation on image");
                    provenance.add(ic);
                    provenance.setCellWidth(ic, "18px");
                } else {
                    Image ic = new Image(Domeo.resources.littleTextIcon());
                    ic.setTitle("Annotation on text");
                    provenance.add(ic);
                    provenance.setCellWidth(ic, "18px");
                }

                step = 9;
                provenance.add(new HTML("<span style='font-weight: bold; font-size: 12px; color: #696969'>By "
                        + annotation.getCreator().getName()
                        + "</span>  <span style='padding-left:5px; font-size: 12px; color: #696969;' title='"
                        + annotation.getFormattedCreationDate() + "'>"
                        + elaspedTime((new Date()).getTime() - annotation.getCreatedOn().getTime())
                        + " ago</span>"));

                provenance.add(showIcon);
                provenance.add(editIcon);
                //provenance.add(commentBranchIcon);
                //provenance.add(addCommentIcon);
                provenance.add(deleteIcon);
            }
        } else {
            provenance.setVisible(false);
        }
    } catch (Exception e) {
        _domeo.getLogger().exception(this,
                "Provenance bar generation exception @" + step + " " + e.getMessage());
    }
}

From source file:org.mindinformatics.gwt.domeo.plugins.annotation.commentaries.linear.ui.tile.TLinearCommentTile.java

License:Apache License

public void createProvenanceBar(HorizontalPanel provenance, final MAnnotation annotation) {
    int step = 0;
    try {/*from   w  ww  . ja v a 2  s . c om*/
        Resources resource = Domeo.resources;
        Image editIcon = new Image(resource.editLittleIcon());
        editIcon.setTitle("Edit Item");
        editIcon.setStyleName(ATileComponent.tileResources.css().button());
        //editIcon.addClickHandler(ActionEditAnnotation.getClickHandler(_domeo, this, _listener, getAnnotation()));
        step = 1;

        Image showIcon = new Image(resource.showLittleIcon());
        showIcon.setTitle("Show Item in Context");
        showIcon.setStyleName(ATileComponent.tileResources.css().button());
        showIcon.addClickHandler(ActionShowAnnotation.getClickHandler(_domeo, this, getAnnotation()));
        step = 2;

        /*
        Image addCommentIcon = new Image(resource.addCommentIcon());
        addCommentIcon.setTitle("Comment on item");
        addCommentIcon.setStyleName(ATileComponent.tileResources.css().button());
        addCommentIcon.addClickHandler(new ClickHandler() {
           @Override
           public void onClick(ClickEvent event) {
              showCommentForm();
           }
        });
        step=3;
                
        Image commentBranchIcon = new Image(resource.splitCommentIcon());
        commentBranchIcon.setTitle("Comment on item");
        commentBranchIcon.setStyleName(ATileComponent.tileResources.css().button());
        commentBranchIcon.addClickHandler(new ClickHandler() {
           @Override
           public void onClick(ClickEvent event) {
              showCommentBranchForm();
           }
        });
        step=4;
        */

        //final CommentsViewerPanel viewer = _viewer;
        final MAnnotation ann = _annotation;
        submitButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                if (addCommentBody.getText().trim().length() == 0)
                    return;
                MAnnotationSelector selector = AnnotationFactory.createAnnotationSelector(
                        _domeo.getAgentManager().getUserPerson(),
                        _domeo.getPersistenceManager().getCurrentResource(), ann);
                MLinearCommentAnnotation annotation = LinearCommentsFactory.createLinearComment(
                        _domeo.getAgentManager().getUserPerson(), _domeo.getAgentManager().getSoftware(),
                        selector, addCommentBody.getText());
                if (addCommentTitle.getValue() != null && addCommentTitle.getValue().trim().length() > 0) {
                    annotation.setTitle(addCommentTitle.getValue());
                }

                _domeo.getAnnotationPersistenceManager().addAnnotationOfAnnotation(annotation, ann,
                        _domeo.getAnnotationPersistenceManager().getSetByAnnotationId(ann.getLocalId()));

                ASideTab tab = _domeo.getLinearCommentsSideTab();
                ASidePanel panel = _domeo.getSidePanelsFacade().getPanelForTab(tab);
                ((ICommentsRefreshableComponent) panel).refreshFromRoot();
                _domeo.refreshAnnotationComponents();

                TLinearCommentTile c = new TLinearCommentTile(_domeo, _listener);
                TreeItem i = new TreeItem(c.getTile());
                i.setState(true);
                c.initializeLens(annotation);

                hideCommentForm();
                //viewer.refreshThreadsTree();
            }
        });

        cancelButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                hideCommentForm();
            }
        });

        Image deleteIcon = new Image(resource.deleteLittleIcon());
        deleteIcon.setTitle("Delete Item");
        deleteIcon.setStyleName(ATileComponent.tileResources.css().button());
        deleteIcon.addClickHandler(ActionDeleteAnnotation.getClickHandler(_domeo, this, getAnnotation()));
        step = 5;
        _domeo.getLogger().debug(this, "" + annotation);
        step = 50;
        //_domeo.getLogger().debug(this, ""+annotation.getCreator());
        step = 500;
        _domeo.getLogger().debug(this, annotation.getCreator().getUri());
        step = 5000;

        // TODO move to an abstract tile class
        if (((BooleanPreference) _domeo.getPreferences().getPreferenceItem(Domeo.class.getName(),
                Domeo.PREF_DISPLAY_PROVENANCE)).getValue()) {
            if (annotation.getCreator().getUri().equals(_domeo.getAgentManager().getUserPerson().getUri())) {
                if (((BooleanPreference) _domeo.getPreferences().getPreferenceItem(Domeo.class.getName(),
                        Domeo.PREF_DISPLAY_USER_PROVENANCE)).getValue()) {
                    provenance.clear();
                    step = 6;
                    // TODO Externalize the icon management to the plugins
                    if (SelectorUtils.isOnMultipleTargets(annotation.getSelectors())) {
                        Image ic = new Image(Domeo.resources.multipleLittleIcon());
                        ic.setTitle("Annotation on multiple targets");
                        provenance.add(ic);
                        provenance.setCellWidth(ic, "18px");
                    } else if (annotation.getSelector() != null
                            && annotation.getSelector().getTarget() instanceof MOnlineImage) {
                        Image ic = new Image(Domeo.resources.littleImageIcon());
                        ic.setTitle("Annotation on image");
                        provenance.add(ic);
                        provenance.setCellWidth(ic, "18px");
                    } else {
                        if (SelectorUtils.isOnAnnotation(annotation.getSelectors())) {
                            if (((MLinearCommentAnnotation) annotation).getTitle() != null
                                    && ((MCommentAnnotation) annotation).getTitle().trim().length() > 0) {
                                Image ic = new Image(Domeo.resources.splitCommentIcon());
                                ic.setTitle("Discussion branch");
                                provenance.add(ic);
                                provenance.setCellWidth(ic, "18px");
                            } else {
                                Image ic = new Image(Domeo.resources.commentIcon());
                                ic.setTitle("Discussion comment");
                                provenance.add(ic);
                                provenance.setCellWidth(ic, "18px");
                            }
                        } else if (SelectorUtils.isOnResourceTarget(annotation.getSelectors())) {
                            Image ic = new Image(Domeo.resources.littleCommentsIcon());
                            ic.setTitle("Annotation on annotation");
                            provenance.add(ic);
                            provenance.setCellWidth(ic, "18px");
                        } else {
                            Image ic = new Image(Domeo.resources.littleTextIcon());
                            ic.setTitle("Annotation on text");
                            provenance.add(ic);
                            provenance.setCellWidth(ic, "18px");
                        }
                    }
                    step = 7;

                    provenance.add(new HTML(
                            "<span style='font-weight: bold; font-size: 12px; color: #696969'>By Me</span>  <span style='padding-left:5px' title='"
                                    + annotation.getFormattedCreationDate() + "'>"
                                    + elaspedTime((new Date()).getTime() - annotation.getCreatedOn().getTime())
                                    + " ago</span>"));
                    if (!(annotation.getSelector() instanceof MTargetSelector)
                            && !(annotation.getSelector() instanceof MAnnotationSelector)) {
                        provenance.add(showIcon);
                        provenance.setCellWidth(showIcon, "22px");
                        provenance.add(editIcon);
                        provenance.setCellWidth(editIcon, "22px");
                    }
                    //                  provenance.add(addCommentIcon);
                    //                  provenance.setCellHorizontalAlignment(addCommentIcon, HasHorizontalAlignment.ALIGN_LEFT);
                    //                  provenance.setCellWidth(addCommentIcon, "22px");
                    //                  provenance.add(commentBranchIcon);
                    //                  provenance.setCellHorizontalAlignment(commentBranchIcon, HasHorizontalAlignment.ALIGN_LEFT);
                    //                  provenance.setCellWidth(commentBranchIcon, "22px");
                    provenance.add(deleteIcon);
                    provenance.setCellHorizontalAlignment(deleteIcon, HasHorizontalAlignment.ALIGN_LEFT);
                    provenance.setCellWidth(deleteIcon, "22px");
                } else {
                    provenance.setVisible(false);
                }
            } else {
                provenance.clear();
                step = 8;
                if (SelectorUtils.isOnMultipleTargets(annotation.getSelectors())) {
                    Image ic = new Image(Domeo.resources.multipleLittleIcon());
                    ic.setTitle("Annotation on multiple targets");
                    provenance.add(ic);
                    provenance.setCellWidth(ic, "18px");
                } else if (annotation.getSelector() != null
                        && annotation.getSelector().getTarget() instanceof MOnlineImage) {
                    Image ic = new Image(Domeo.resources.littleImageIcon());
                    ic.setTitle("Annotation on image");
                    provenance.add(ic);
                    provenance.setCellWidth(ic, "18px");
                } else {
                    Image ic = new Image(Domeo.resources.littleTextIcon());
                    ic.setTitle("Annotation on text");
                    provenance.add(ic);
                    provenance.setCellWidth(ic, "18px");
                }

                step = 9;
                provenance.add(new HTML("<span style='font-weight: bold; font-size: 12px; color: #696969'>By "
                        + annotation.getCreator().getName()
                        + "</span>  <span style='padding-left:5px; font-size: 12px; color: #696969;' title='"
                        + annotation.getFormattedCreationDate() + "'>"
                        + elaspedTime((new Date()).getTime() - annotation.getCreatedOn().getTime())
                        + " ago</span>"));

                provenance.add(showIcon);
                provenance.add(editIcon);
                //provenance.add(commentBranchIcon);
                //provenance.add(addCommentIcon);
                provenance.add(deleteIcon);
            }
        } else {
            provenance.setVisible(false);
        }
    } catch (Exception e) {
        _domeo.getLogger().exception(this,
                "Provenance bar generation exception @" + step + " " + e.getMessage());
    }
}

From source file:org.mindinformatics.gwt.domeo.plugins.annotation.micropubs.ui.form.FMicroPublicationForm.java

License:Apache License

public void refreshQualifiers() {
    qualifiersPanel.clear();/*from ww w.ja v  a  2s.c o m*/

    Integer counter = 0;
    VerticalPanel vp = new VerticalPanel();
    vp.setWidth("444px");

    for (MMpRelationship q : qualifiers) {
        final MMpRelationship _q = q;
        if (q.getObjectElement() instanceof MMpQualifier) {
            MLinkedResource res = ((MMpQualifier) q.getObjectElement()).getQualifier();

            StringBuffer sb = new StringBuffer();
            sb.append("<img src='" + Domeo.resources.tagIcon().getSafeUri().asString() + "'/> " + "<b>"
                    + res.getLabel() + "</b> from <a target=\"_blank\"href=\"" + res.getSource().getUrl()
                    + "\">" + res.getSource().getLabel() + "</a>");
            if (res.getDescription() != null && res.getDescription().length() > 0)
                sb.append(", " + res.getDescription());
            boolean nodigester = true;
            List<ITrustedResourceDigester> digesters = _domeo.getLinkedDataDigestersManager()
                    .getLnkedDataDigesters(res);
            for (ITrustedResourceDigester digester : digesters) {
                if (digester.getLinkLabel(res).trim().length() > 0) {
                    sb.append(", <a target=\"_blank\"href=\"" + digester.getLinkUrl(res) + "\">@"
                            + digester.getLinkLabel(res) + "</a>&nbsp;");
                    nodigester = false;
                }
            }
            HorizontalPanel hp = new HorizontalPanel();
            hp.setStyleName(style.indexWrapper());
            hp.setWidth("444px");
            hp.add(new HTML(sb.toString()));
            vp.add(hp);

            final Image removeIcon = new Image(Domeo.resources.deleteLittleIcon());
            removeIcon.setStyleName(style.link());
            removeIcon.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    hasChanged = true;
                    qualifiers.remove(_q);
                    if (_item != null) {
                        _item.getQualifiers().remove(_q);
                        _ann.setHasChanged(true);
                    }
                    refreshQualifiers();
                }
            });
            hp.add(removeIcon);
            hp.setCellWidth(removeIcon, "16px");
            hp.setCellHorizontalAlignment(removeIcon, HasHorizontalAlignment.ALIGN_RIGHT);
        }
    }

    qualifiersPanel.add(vp);
}

From source file:org.mindinformatics.gwt.domeo.plugins.annotation.micropubs.ui.form.FMicroPublicationForm.java

License:Apache License

private void displayReferenceInEvidence(VerticalPanel vp, Integer counter, final MMpRelationship relationship) {
    HorizontalPanel hp1 = new HorizontalPanel();
    hp1.setWidth("442px");
    hp1.setStyleName(style.indexWrapper());

    if (relationship.getName().equals(IMicroPublicationsOntology.supportedBy)) {
        final Image supportedByIcon = new Image(localResources.supportedBy());
        supportedByIcon.setTitle("Supported By");
        supportedByIcon.setStyleName(style.link());
        supportedByIcon.addClickHandler(new ClickHandler() {
            @Override/*from  w w w  .j a v  a2s .co m*/
            public void onClick(ClickEvent event) {
                EvidenceRelationshipBubble bubble = new EvidenceRelationshipBubble(_this, _domeo, _item,
                        relationship, "");
                int x = supportedByIcon.getAbsoluteLeft();
                int y = supportedByIcon.getAbsoluteTop();
                bubble.show(x, y);
            }
        });
        hp1.add(supportedByIcon);
        hp1.setCellWidth(supportedByIcon, "22px");
    } else if (relationship.getName().equals(IMicroPublicationsOntology.challengedBy)) {
        final Image supportedByIcon = new Image(localResources.challengedBy());
        supportedByIcon.setTitle("Supported By");
        supportedByIcon.setStyleName(style.link());
        supportedByIcon.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                EvidenceRelationshipBubble bubble = new EvidenceRelationshipBubble(_this, _domeo, _item,
                        relationship, "");
                int x = supportedByIcon.getAbsoluteLeft();
                int y = supportedByIcon.getAbsoluteTop();
                bubble.show(x, y);
            }
        });
        hp1.add(supportedByIcon);
        hp1.setCellWidth(supportedByIcon, "22px");
    }

    hp1.add(PubMedCitationPainter
            .getFullCitation(((MMpReference) relationship.getObjectElement()).getReference(), _domeo));

    final MMpRelationship _q = relationship;
    final Image removeIcon = new Image(Domeo.resources.deleteLittleIcon());
    removeIcon.setStyleName(style.link());
    removeIcon.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            hasChanged = true;
            evidence.remove(_q);
            if (_item != null) {
                _item.getEvidence().remove(_q);
                _ann.setHasChanged(true);
            }
            refreshSupport();
            //box.setEnabled(false);
            //_container.addImageAsData(_image);
        }
    });
    hp1.add(removeIcon);
    hp1.setCellWidth(removeIcon, "16px");
    hp1.setCellHorizontalAlignment(removeIcon, HasHorizontalAlignment.ALIGN_RIGHT);

    vp.add(hp1);
}

From source file:org.mindinformatics.gwt.domeo.plugins.annotation.micropubs.ui.form.FMicroPublicationForm.java

License:Apache License

private void displayStatementInEvidence(VerticalPanel vp, Integer counter, final MMpRelationship relationship) {
    HorizontalPanel hp1 = new HorizontalPanel();
    hp1.setWidth("442px");
    hp1.setStyleName(style.indexWrapper());

    if (relationship.getName().equals(IMicroPublicationsOntology.supportedBy)) {
        final Image supportedByIcon = new Image(localResources.supportedBy());
        supportedByIcon.setTitle("Supported By");
        supportedByIcon.setStyleName(style.link());
        supportedByIcon.addClickHandler(new ClickHandler() {
            @Override//from   w w w. jav  a 2  s  . co  m
            public void onClick(ClickEvent event) {
                EvidenceRelationshipBubble bubble = new EvidenceRelationshipBubble(_this, _domeo, _item,
                        relationship, "");
                int x = supportedByIcon.getAbsoluteLeft();
                int y = supportedByIcon.getAbsoluteTop();
                bubble.show(x, y);
            }
        });
        hp1.add(supportedByIcon);
        hp1.setCellWidth(supportedByIcon, "22px");
    } else if (relationship.getName().equals(IMicroPublicationsOntology.challengedBy)) {
        final Image supportedByIcon = new Image(localResources.challengedBy());
        supportedByIcon.setTitle("Supported By");
        supportedByIcon.setStyleName(style.link());
        supportedByIcon.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                EvidenceRelationshipBubble bubble = new EvidenceRelationshipBubble(_this, _domeo, _item,
                        relationship, "");
                int x = supportedByIcon.getAbsoluteLeft();
                int y = supportedByIcon.getAbsoluteTop();
                bubble.show(x, y);
            }
        });
        hp1.add(supportedByIcon);
        hp1.setCellWidth(supportedByIcon, "22px");
    }

    hp1.add(new HTML(((MMpStatement) relationship.getObjectElement()).getText()));

    final Image removeIcon = new Image(Domeo.resources.deleteLittleIcon());
    removeIcon.setStyleName(style.link());
    removeIcon.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            //box.setEnabled(false);
            //_container.addImageAsData(_image);
        }
    });
    hp1.add(removeIcon);
    hp1.setCellWidth(removeIcon, "16px");
    hp1.setCellHorizontalAlignment(removeIcon, HasHorizontalAlignment.ALIGN_RIGHT);

    vp.add(hp1);
}

From source file:org.mindinformatics.gwt.domeo.plugins.annotation.micropubs.ui.form.FMicroPublicationForm.java

License:Apache License

private void displayImageInEvidence(VerticalPanel vp, Integer counter, final MMpRelationship relationship) {

    _domeo.getLogger().debug(this, "3c1");
    MOnlineImage image = (MOnlineImage) ((MImageInDocumentSelector) relationship.getObjectElement()
            .getSelector()).getTarget();
    _domeo.getLogger().debug(this, "3c2");
    VerticalPanel hp1 = new VerticalPanel();
    hp1.setWidth("442px");

    boolean small = false;
    boolean reduced = false;
    //Window.alert(image.getUrl() + " - " + image.getDisplayUrl());
    Image img = new Image(image.getDisplayUrl());
    _domeo.getLogger().debug(this, "3c3");
    if (img.getWidth() > 380) {
        img.setWidth("380px");
        reduced = true;/*  w  w  w.j  a  v a2  s  . c o  m*/
    } else if (img.getWidth() < 220) {
        small = true;
        //img.setWidth("200px"); 
    }
    if (image.getLabel() != null && image.getLabel().trim().length() > 0) {
        img.setTitle(image.getLabel());
    }

    _domeo.getLogger().debug(this, "3c4");
    if (!small) {

        HorizontalPanel main = new HorizontalPanel();
        main.setWidth("442px");

        //VerticalPanel actionsPanel = new VerticalPanel();
        //actionsPanel.setHeight("100%");

        if (relationship.getName().equals(IMicroPublicationsOntology.supportedBy)) {
            final Image supportedByIcon = new Image(localResources.supportedBy());
            supportedByIcon.setTitle("Supported By");
            supportedByIcon.setStyleName(style.link());
            supportedByIcon.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    EvidenceRelationshipBubble bubble = new EvidenceRelationshipBubble(_this, _domeo, _item,
                            relationship, "");
                    int x = supportedByIcon.getAbsoluteLeft();
                    int y = supportedByIcon.getAbsoluteTop();
                    bubble.show(x, y);
                }
            });
            main.add(supportedByIcon);
            main.setCellWidth(supportedByIcon, "22px");
        } else if (relationship.getName().equals(IMicroPublicationsOntology.challengedBy)) {
            final Image supportedByIcon = new Image(localResources.challengedBy());
            supportedByIcon.setTitle("Supported By");
            supportedByIcon.setStyleName(style.link());
            supportedByIcon.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    EvidenceRelationshipBubble bubble = new EvidenceRelationshipBubble(_this, _domeo, _item,
                            relationship, "");
                    int x = supportedByIcon.getAbsoluteLeft();
                    int y = supportedByIcon.getAbsoluteTop();
                    bubble.show(x, y);
                }
            });
            main.add(supportedByIcon);
            main.setCellWidth(supportedByIcon, "22px");
        }

        VerticalPanel left = new VerticalPanel();

        SimplePanel imageWrap = new SimplePanel();
        imageWrap.setStyleName(style.imageWrap());
        imageWrap.add(img);
        imageWrap.setStyleName(style.centerText());
        left.add(imageWrap);
        left.setCellHorizontalAlignment(img, HasHorizontalAlignment.ALIGN_LEFT);
        if (image.getLabel() != null && image.getLabel().trim().length() > 0) {
            HTML title = new HTML("<b>" + image.getLabel() + "</b>");
            left.add(title);
            left.setCellHorizontalAlignment(title, HasHorizontalAlignment.ALIGN_LEFT);
        } /* else {
           HTML title = new HTML("<b>Title</b>");
           left.add(title);
           left.setCellHorizontalAlignment(title, HasHorizontalAlignment.ALIGN_LEFT);
          } */
        main.add(left);
        main.setStyleName(style.indexWrapper());

        if (counter % 2 == 1) {
            left.addStyleName(style.indexOdd());
        } else {
            left.addStyleName(style.indexEven());
        }

        final Image removeIcon = new Image(Domeo.resources.deleteLittleIcon());
        removeIcon.setStyleName(style.link());
        removeIcon.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                //box.setEnabled(false);
                //_container.addImageAsData(_image);
            }
        });
        main.add(removeIcon);
        main.setCellWidth(removeIcon, "16px");
        main.setCellHorizontalAlignment(removeIcon, HasHorizontalAlignment.ALIGN_RIGHT);

        hp1.add(main);
    } else {
        HorizontalPanel main = new HorizontalPanel();
        main.setStyleName(style.indexWrapper());

        final Image supportedByIcon = new Image(localResources.supportedBy());
        supportedByIcon.setTitle("Supported By");
        supportedByIcon.setStyleName(style.link());
        supportedByIcon.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                EvidenceRelationshipBubble bubble = new EvidenceRelationshipBubble(_this, _domeo, _item,
                        relationship, "");
                int x = supportedByIcon.getAbsoluteLeft();
                int y = supportedByIcon.getAbsoluteTop();
                bubble.show(x, y);
            }
        });
        main.add(supportedByIcon);
        main.setCellWidth(supportedByIcon, "22px");

        SimplePanel imageWrap = new SimplePanel();
        imageWrap.setStyleName(style.imageWrap());
        imageWrap.add(img);
        main.add(imageWrap);

        //hp1.setCellHorizontalAlignment(img, HasHorizontalAlignment.ALIGN_CENTER);

        VerticalPanel right = new VerticalPanel();
        right.setWidth("100%");

        if (image.getLabel() != null && image.getLabel().trim().length() > 0) {
            HTML title = new HTML("<b>" + image.getLabel() + "</b>");
            right.add(title);
            right.setCellHorizontalAlignment(title, HasHorizontalAlignment.ALIGN_LEFT);
        } /*else {               
           HTML title = new HTML("title: <b>Title</b>");
           right.add(title);
           right.setCellHorizontalAlignment(title, HasHorizontalAlignment.ALIGN_LEFT);
          }*/

        main.add(right);
        main.setCellWidth(right, "100%");

        final Image removeIcon = new Image(Domeo.resources.deleteLittleIcon());
        removeIcon.setStyleName(style.link());
        removeIcon.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                //box.setEnabled(false);
                //_container.addImageAsData(_image);
            }
        });
        main.add(removeIcon);
        main.setCellWidth(removeIcon, "16px");
        main.setCellHorizontalAlignment(removeIcon, HasHorizontalAlignment.ALIGN_RIGHT);

        hp1.add(main);

        if (counter % 2 == 1) {
            right.addStyleName(style.indexOdd());
        } else {
            right.addStyleName(style.indexEven());
        }
    }
    vp.add(hp1);

}

From source file:org.mindinformatics.gwt.domeo.plugins.annotation.micropubs.ui.form.FMicroPublicationForm2.java

License:Apache License

public void refreshQualifiers() {
    qualifiersPanel.clear();//from w  w  w  .ja v  a 2  s  .com

    VerticalPanel vp = new VerticalPanel();
    vp.setWidth("100%");

    if (qualifiers.size() > 0) {
        for (MMpRelationship q : qualifiers) {
            final MMpRelationship _q = q;
            if (q.getObjectElement() instanceof MMpQualifier) {
                MLinkedResource res = ((MMpQualifier) q.getObjectElement()).getQualifier();

                StringBuffer sb = new StringBuffer();
                sb.append("<img src='" + Domeo.resources.tagIcon().getSafeUri().asString() + "'/> " + "<b>"
                        + res.getLabel() + "</b> from <a target=\"_blank\"href=\"" + res.getSource().getUrl()
                        + "\">" + res.getSource().getLabel() + "</a>");
                if (res.getDescription() != null && res.getDescription().length() > 0)
                    sb.append(", " + res.getDescription());
                boolean nodigester = true;
                List<ITrustedResourceDigester> digesters = _domeo.getLinkedDataDigestersManager()
                        .getLnkedDataDigesters(res);
                for (ITrustedResourceDigester digester : digesters) {
                    if (digester.getLinkLabel(res).trim().length() > 0) {
                        sb.append(", <a target=\"_blank\"href=\"" + digester.getLinkUrl(res) + "\">@"
                                + digester.getLinkLabel(res) + "</a>&nbsp;");
                        nodigester = false;
                    }
                }
                HorizontalPanel hp = new HorizontalPanel();
                hp.setStyleName(style.indexWrapper());
                hp.setWidth("100%");
                hp.add(new HTML(sb.toString()));
                vp.add(hp);

                final Image removeIcon = new Image(Domeo.resources.deleteLittleIcon());
                removeIcon.setStyleName(style.link());
                removeIcon.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        hasChanged = true;
                        qualifiers.remove(_q);
                        if (_item != null) {
                            _item.getQualifiers().remove(_q);
                            _ann.setHasChanged(true);
                        }
                        refreshQualifiers();
                    }
                });
                hp.add(removeIcon);
                hp.setCellWidth(removeIcon, "16px");
                hp.setCellHorizontalAlignment(removeIcon, HasHorizontalAlignment.ALIGN_RIGHT);
            }
        }
    } else {
        vp.add(new HTML("No qualifier provided"));
    }

    resizeEvidenceTab();
    qualifiersPanel.add(vp);
}