Example usage for org.apache.wicket Component add

List of usage examples for org.apache.wicket Component add

Introduction

In this page you can find the example usage for org.apache.wicket Component add.

Prototype

public Component add(final Behavior... behaviors) 

Source Link

Document

Adds a behavior modifier to the component.

Usage

From source file:org.cyclop.web.components.column.ColumnValuePanel.java

License:Apache License

@Override
protected void onInitialize() {
    super.onInitialize();

    String convertedValue = converter.convert(cqlColumnValue.value);
    final String convertedValueNotNull = convertedValue == null ? "" : convertedValue;
    final String trimmedEntry = converter.trimColumnContent(convertedValueNotNull, embeddedColumn);
    boolean trimmed = convertedValueNotNull.length() - trimmedEntry.length() > 10;

    infoDialog = new InfoDialog("columnContentDialog");
    infoDialog.setVisible(trimmed);// w w w. ja  v a  2  s.  c  o  m
    add(infoDialog);

    Component fullContentLink;
    Label columnContent;
    if (trimmed) {
        fullContentLink = new AjaxFallbackLink<Object>("columnContentLink") {
            @Override
            public void onClick(AjaxRequestTarget target) {

                String title = crateInfoDialogTitle(cqlPartitionKeyValue, cqlColumnValue.columnName);
                infoDialog.open(target, this.getMarkupId(), title, convertedValueNotNull);
            }
        };

        columnContent = new Label("columnContent", trimmedEntry);
        fullContentLink.add(new AttributeModifier("title", new IModel<String>() {

            @Override
            public void detach() {
            }

            @Override
            public String getObject() {
                String conv = converter.trimColumnTooltipContent(convertedValueNotNull);
                return conv;
            }

            @Override
            public void setObject(String object) {
            }
        }));

    } else {
        fullContentLink = new Label("columnContentLink", "") {
            @Override
            protected void onComponentTag(ComponentTag tag) {
                if ("a".equalsIgnoreCase(tag.getName())) {
                    tag.setName("div");
                }
                super.onComponentTag(tag);
            }
        };
        columnContent = new Label("columnContent", convertedValueNotNull);
        fullContentLink.setRenderBodyOnly(true);
    }
    add(fullContentLink);
    add(columnContent);
}

From source file:org.cyclop.web.components.column.WidgetFactory.java

License:Apache License

public void addColumnTitle(Component colValue, Optional<CqlPartitionKeyValue> partitionKey,
        CqlExtendedColumnName column) {/* w ww  .j  a  v  a  2s .c  o  m*/
    StringBuilder title = new StringBuilder();
    if (partitionKey.isPresent()) {
        title.append(partitionKey.get().value);
        title.append(" -> ");
    }
    title.append(column.part);

    colValue.add(new AttributeAppender("title", title.toString()));
}

From source file:org.dcm4chee.web.common.login.LoginPage.java

License:LGPL

public LoginPage() {
    super();//from  w  w  w .  ja  v a 2 s.  c o  m

    selectorPanel.setShowLogoutLink(false);

    String nodeInfo;
    try {
        nodeInfo = System.getProperty("dcm4che.archive.nodename", InetAddress.getLocalHost().getHostName());
    } catch (UnknownHostException e) {
        nodeInfo = "DCM4CHEE";
    }
    add(new Label("loginLabel",
            new StringResourceModel("loginLabel", LoginPage.this, null, new Object[] { nodeInfo })));

    add(new SignInPanel("signInPanel") {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean signIn(String username, String password) {
            try {
                ((WaspSession) getSession()).login(new WebLoginContext(username, password));
            } catch (LoginException e) {
                return false;
            }
            return true;
        }

        protected void onSignInFailed() {
            Component user = LoginPage.this.get("signInPanel:signInForm:username");
            user.add(FocusOnLoadBehaviour.newFocusAndSelectBehaviour());
        }
    }.add(new AttributeModifier("align", true, new Model<String>("left"))));
    this.get("signInPanel:signInForm").add(new FocusOnLoadBehaviour());
}

From source file:org.dcm4chee.wizard.common.login.LoginPage.java

License:LGPL

public LoginPage() {
    super();// w w w.  ja  v  a 2  s.  c o  m

    selectorPanel.setShowLogoutLink(false);

    String nodeInfo;
    try {
        nodeInfo = System.getProperty("dcm4che.archive.nodename", InetAddress.getLocalHost().getHostName());
    } catch (UnknownHostException e) {
        nodeInfo = "DCM4CHEE";
    }
    add(new Label("loginLabel",
            new StringResourceModel("loginLabel", LoginPage.this, null, new Object[] { nodeInfo })));

    add(new SignInPanel("signInPanel") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSignInFailed() {
            Component user = LoginPage.this.get("signInPanel:signInForm:username");
            user.add(FocusOnLoadBehavior.newFocusAndSelectBehaviour());
        }
    }.add(new AttributeModifier("align", new Model<String>("left"))));
    this.get("signInPanel:signInForm").add(new FocusOnLoadBehavior());
}

From source file:org.dcm4chee.wizard.panel.BasicConfigurationPanel.java

License:LGPL

private void addCreateDevice() {
    AjaxLink<Object> createDevice = getCreateDeviceLink();
    Component createDeviceImg = new Image("createDeviceImg", ImageManager.IMAGE_WIZARD_DEVICE_ADD);
    createDeviceImg.add(new ImageSizeBehaviour("vertical-align: middle;"));
    createDevice.add(createDeviceImg);/*from w ww . j a va  2  s .  com*/
    createDevice.add(new TooltipBehavior("dicom."));
    Component createDeviceText = new Label("createDeviceText", new ResourceModel("dicom.createDevice.text"));
    createDeviceText.add(new AttributeAppender("style", Model.of("vertical-align: middle"), " "));
    createDevice.add(createDeviceText);
    form.add(createDevice);
}

From source file:org.devproof.portal.core.module.common.util.PortalUtil.java

License:Apache License

public static void addSyntaxHightlighter(Component component, String theme) {
    component.add(JavascriptPackageResource.getHeaderContribution(CommonConstants.class,
            "js/SyntaxHighlighter/shCore.js"));
    component.add(JavascriptPackageResource.getHeaderContribution(CommonConstants.class,
            "js/SyntaxHighlighter/shAutoloader.js"));
    //        component.add(CSSPackageResource.getHeaderContribution(CommonConstants.class, "css/SyntaxHighlighter/shCore.css"));
    component.add(CSSPackageResource.getHeaderContribution(CommonConstants.class,
            "css/SyntaxHighlighter/shCore" + theme + ".css"));
    //        component.add(CSSPackageResource.getHeaderContribution(CommonConstants.class, "css/SyntaxHighlighter/shTheme" + theme + ".css"));
    Map<String, Object> values = new MiniMap<String, Object>(1);
    CharSequence urlWithShCore = RequestCycle.get().urlFor(CommonConstants.REF_SYNTAXHIGHLIGHTER_JS);
    CharSequence urlWithoutShCore = StringUtils.removeEnd(urlWithShCore.toString(), "shCore.js");
    values.put("jsPath", urlWithoutShCore);
    component.add(TextTemplateHeaderContributor.forJavaScript(CommonConstants.class,
            "js/SyntaxHighlighter/SyntaxHighlighterCopy.js", new MapModel<String, Object>(values)));
}

From source file:org.devproof.portal.core.module.common.util.PortalUtil.java

License:Apache License

public static void addJQuery(Component component) {
    component.add(
            JavascriptPackageResource.getHeaderContribution(CommonConstants.class, "js/jquery-1.5.1.min.js"));
    component//  w  ww  .j ava 2s  . co m
            .add(JavascriptPackageResource.getHeaderContribution(CommonConstants.class, "js/jquery.center.js"));
}

From source file:org.efaps.ui.wicket.components.menu.DropDownMenuPanel.java

License:Apache License

/**
 * @param _wicketId wicketId of this Panel
 * @param _model model for this Panel/*w  w  w .  j  a v  a 2s .c  o m*/
 * @param _idGenerator helper for ids
 * @throws CacheReloadException on error
 */
public DropDownMenuPanel(final String _wicketId, final IModel<?> _model, final IdGenerator _idGenerator)
        throws CacheReloadException {
    super(_wicketId, _model);
    add(new DropDownMenuBehavior());
    final UIMenuItem menuItem = (UIMenuItem) super.getDefaultModelObject();

    final RepeatingView itemRepeater = new RepeatingView("itemRepeater");
    add(itemRepeater);

    for (final UIMenuItem childItem : menuItem.getChildren()) {
        if (childItem.hasChildren()) {
            itemRepeater.add(
                    new PopupMenuPanel(_idGenerator.newChildId(), Model.of(childItem), _idGenerator, false));
        } else {
            Component item = null;
            if (childItem.getReference() != null) {
                childItem.setURL(childItem.getReference());
                if (childItem.getReference()
                        .equals("/" + getSession().getApplication().getApplicationKey() + "/taskadmin?")) {
                    item = new TaskAdminItem(_idGenerator.newChildId(), Model.of(childItem));
                }
                if (childItem.getReference()
                        .equals("/" + getSession().getApplication().getApplicationKey() + "/connection?")) {
                    item = new ConnectionItem(_idGenerator.newChildId(), Model.of(childItem));
                }
            }

            if (item == null) {
                if (childItem.getTarget() != Target.UNKNOWN) {
                    if (childItem.getTarget() == Target.MODAL) {
                        item = new OpenModalItem(_idGenerator.newChildId(), Model.of(childItem));
                    } else if (childItem.getTarget() == Target.POPUP) {
                        item = new PopupItem(_idGenerator.newChildId(), Model.of(childItem));
                    } else if (childItem.getTarget() == Target.HIDDEN) {
                        item = new ExecItem(_idGenerator.newChildId(), Model.of(childItem));
                    } else {
                        item = new LinkItem(_idGenerator.newChildId(), Model.of(childItem));
                    }
                } else {
                    if (childItem instanceof UISearchItem) {
                        item = new SearchItem(_idGenerator.newChildId(), Model.of(childItem));
                    } else if (childItem.getCommand().getTargetForm() != null
                            || childItem.getCommand().getTargetTable() != null) {
                        item = new LinkItem(_idGenerator.newChildId(), Model.of(childItem));
                    } else if (childItem.getCommand().isSubmit()) {
                        item = new SubmitItem(_idGenerator.newChildId(), Model.of(childItem));
                    } else {
                        item = new ExecItem(_idGenerator.newChildId(), Model.of(childItem));
                    }
                }
            }
            if (item != null) {
                item.add(new MenuItemBehavior());
                itemRepeater.add(item);
            }
        }
    }
}

From source file:org.efaps.ui.wicket.components.menu.MenuBarPanel.java

License:Apache License

/**
 * @param _wicketId wicketId of this Panel
 * @param _model model for this Panel//from  w ww.j a  v  a  2s.c  o m
 * @throws CacheReloadException on error
 */
public MenuBarPanel(final String _wicketId, final IModel<?> _model) throws CacheReloadException {
    super(_wicketId, _model);
    add(new MenuBarBehavior());
    add(AttributeModifier.append("class", "eFapsMenuBarPanel"));
    if (_model == null) {
        add(new WebMarkupContainer("itemRepeater"));
    } else {
        final UIMenuItem menuItem = (UIMenuItem) super.getDefaultModelObject();

        final RepeatingView itemRepeater = new RepeatingView("itemRepeater");
        add(itemRepeater);
        final IdGenerator idGenerator = new IdGenerator();
        for (final UIMenuItem childItem : menuItem.getChildren()) {
            if (childItem.hasChildren()) {
                itemRepeater
                        .add(new PopupMenuPanel(idGenerator.newChildId(), Model.of(childItem), idGenerator));
            } else {
                Component item = null;
                if (childItem.getReference() != null) {
                    childItem.setURL(childItem.getReference());
                    if (childItem.getReference()
                            .equals("/" + getSession().getApplication().getApplicationKey() + "/logout?")) {
                        item = new LogOutItem(idGenerator.newChildId(), Model.of(childItem));
                    } else if (childItem.getReference()
                            .equals("/" + getSession().getApplication().getApplicationKey() + "/setcompany?")) {
                        item = new SetCompanyItem(idGenerator.newChildId(), Model.of(childItem));
                    } else if (childItem.getReference()
                            .equals("/" + getSession().getApplication().getApplicationKey() + "/home?")) {
                        item = new HomeItem(idGenerator.newChildId(), Model.of(childItem));
                    } else if (childItem.getReference()
                            .equals("/" + getSession().getApplication().getApplicationKey() + "/taskadmin?")) {
                        item = new TaskAdminItem(idGenerator.newChildId(), Model.of(childItem));
                    } else if (childItem.getReference()
                            .equals("/" + getSession().getApplication().getApplicationKey() + "/connection?")) {
                        item = new ConnectionItem(idGenerator.newChildId(), Model.of(childItem));
                    }
                }
                if (item == null) {
                    if (childItem.getTarget() != Target.UNKNOWN) {
                        if (childItem.getTarget() == Target.MODAL) {
                            item = new OpenModalItem(idGenerator.newChildId(), Model.of(childItem));
                        } else if (childItem.getTarget() == Target.POPUP) {
                            item = new PopupItem(idGenerator.newChildId(), Model.of(childItem));
                        } else if (childItem.getTarget() == Target.HIDDEN) {
                            item = new ExecItem(idGenerator.newChildId(), Model.of(childItem));
                        } else {
                            item = new LinkItem(idGenerator.newChildId(), Model.of(childItem));
                        }
                    } else {
                        if (childItem instanceof UISearchItem) {
                            item = new SearchItem(idGenerator.newChildId(), Model.of(childItem));
                        } else if (childItem.getCommand().getTargetForm() != null
                                || childItem.getCommand().getTargetTable() != null) {
                            item = new LinkItem(idGenerator.newChildId(), Model.of(childItem));
                        } else if (childItem.getCommand().isSubmit()) {
                            item = new SubmitItem(idGenerator.newChildId(), Model.of(childItem));
                        } else {
                            item = new ExecItem(idGenerator.newChildId(), Model.of(childItem));
                        }
                    }
                }
                if (item != null) {
                    item.add(new MenuBarItemBehavior());
                    itemRepeater.add(item);
                }
            }
        }
    }
}

From source file:org.efaps.ui.wicket.components.table.field.FieldPanel.java

License:Apache License

/**
 * @param _wicketId wicketId for this component
 * @param _model model for this component
 *///from  w w w . j av a 2 s.co  m
public FieldPanel(final String _wicketId, final IModel<AbstractUIField> _model) {
    super(_wicketId, _model);
    final AbstractUIField uiField = _model.getObject();
    try {
        add(new AttributeAppender("style", Model.of("text-align:" + uiField.getFieldConfiguration().getAlign()),
                ";"));
        final Component field = uiField.getComponent("field");

        add(AttributeModifier.replace("title", uiField.getFactory().getStringValue(uiField)));

        if (uiField.isHide()) {
            field.add(new AttributeAppender("style", Model.of("display:none"), ";"));
        }
        if (uiField.editable()) {
            field.add(new SetSelectedRowBehavior(uiField.getFieldConfiguration().getName()));
        }
        add(field);
    } catch (final EFapsException e) {
        FieldPanel.LOG.error("Catched error during population of a FieldPanel", e);
    }
}