Example usage for org.apache.wicket.model ResourceModel getObject

List of usage examples for org.apache.wicket.model ResourceModel getObject

Introduction

In this page you can find the example usage for org.apache.wicket.model ResourceModel getObject.

Prototype

@Override
    public String getObject() 

Source Link

Usage

From source file:com.pushinginertia.wicket.core.model.TimeDurationModel.java

License:Open Source License

protected String loadResourceString(final String resourceKey) {
    final ResourceModel model = new ResourceModel(resourceKey);
    return model.getObject();
}

From source file:it.av.es.service.impl.OrderServiceHibernate.java

License:Apache License

/**
 * {@inheritDoc}//w w  w .ja v a 2  s  . c o  m
 */
@Override
public String getNotesForDisplay(Order order) {
    StringBuilder buffer = new StringBuilder();
    buffer.append("total: ");
    buffer.append(NumberUtil.italianCurrency.format(order.getTotalAmount()));
    if (StringUtils.isNotBlank(order.getNotes())) {
        buffer.append("\n");
        buffer.append(order.getNotes());
    }
    ClosingDays closingDay = order.getCustomer().getClosingDay();
    if (closingDay != null) {
        buffer.append("\n");
        buffer.append("closed: ");
        ResourceModel resourceModel = new ResourceModel(
                closingDay.getClass().getSimpleName() + "." + closingDay.name());
        buffer.append(resourceModel.getObject());
        ClosingRange closingRange = order.getCustomer().getClosingRange();
        if (closingRange != null) {
            buffer.append(" ");
            buffer.append(new ResourceModel(closingRange.getClass().getSimpleName() + "." + closingRange.name())
                    .getObject());
        }
    }
    if (order.getDeliveryTimeRequired() != null) {
        buffer.append("\n");
        buffer.append("cons. tass.: ");
        buffer.append(DateUtil.SDF2SHOWDATE.print(order.getDeliveryTimeRequired().getTime()));
    }
    if (order.getCustomer().getSignboard() != null) {
        buffer.append("\n");
        buffer.append(new ResourceModel("customer.signboard").getObject());
        buffer.append(": ");
        buffer.append(order.getCustomer().getSignboard());
    }
    if (!order.getCustomer().getDeliveryDays().isEmpty()) {
        buffer.append("\n");
        buffer.append("consegna: ");
        for (DeliveryDays d : order.getCustomer().getDeliveryDays()) {
            buffer.append(new ResourceModel(d.name()).getObject());
            buffer.append(" ");
        }
    }
    if (order.getCustomer().isPhoneForewarning()) {
        buffer.append("\n");
        buffer.append("preavv. tel: ");
        buffer.append(StringUtils.isNotBlank(order.getShippingAddress().getPhoneNumber())
                ? order.getShippingAddress().getPhoneNumber()
                : "");
    }
    if (order.getCustomer().getDeployngType() != null) {
        buffer.append("\n");
        DeploingType type = order.getCustomer().getDeployngType();
        buffer.append(new ResourceModel(type.getClass().getSimpleName() + "." + type.name()).getObject());
    }
    if (order.getCustomer().getDeliveryVehicle() != null) {
        buffer.append("\n");
        DeliveryVehicle dv = order.getCustomer().getDeliveryVehicle();
        buffer.append(new ResourceModel(dv.getClass().getSimpleName() + "." + dv.name()).getObject());
    }
    if (order.getCustomer().getDeliveryType() != null) {
        buffer.append("\n");
        DeliveryType type = order.getCustomer().getDeliveryType();
        buffer.append(new ResourceModel(type.getClass().getSimpleName() + "." + type.name()).getObject());
    }
    buffer.append("\n");
    return buffer.toString();
}

From source file:nl.knaw.dans.dccd.web.entitytree.EntityTreePanel.java

License:Apache License

public EntityTreePanel(String id, IModel model, final ProjectPermissionLevel permissionLevel,
        final boolean entitiesEditable) {
    super(id, model);
    this.entitiesEditable = entitiesEditable;

    // assume DendroProject is the model object
    Project project = (Project) model.getObject();
    EntityTree entityTree = project.entityTree;

    // build the UI tree model
    EntityUITreeBuilder treeBuilder = new EntityUITreeBuilder(entitiesEditable);
    ProjectEntity projectEntity = entityTree.getProjectEntity();
    DefaultMutableTreeNode rootNode = treeBuilder.buildProjectUINodesTree(projectEntity, permissionLevel);
    treeModel = new DefaultTreeModel(rootNode);

    // create the UI tree with the model
    linkTree = new LinkTree("tree", treeModel) {
        private static final long serialVersionUID = 8851142522578546998L;

        @Override/*from  ww  w  .  j a  v a2  s  . co  m*/
        protected void onNodeLinkClicked(Object node, BaseTree tree, AjaxRequestTarget target) {

            if (!tree.getTreeState().isNodeSelected(node)) {
                logger.debug("node is deselected, reselecting in order to disable this!");
                // select again, forcing single selection!
                // it is a hack, when clicking doesn't work it should not
                // look clickable...
                tree.getTreeState().selectNode(node, true);
                return;
            }

            //logger.info("clicked: " + node);
            // the resources are in DccdAttrPanel.xml etc. ?
            ResourceModel nameModel = new ResourceModel("entity_name_" + node.toString(), node.toString());
            logger.debug("clicked: " + nameModel.getObject().toString());

            // I know it's a DefaultMutableTreeNode
            EntityUITreeNodeModel nodeModel = (EntityUITreeNodeModel) ((DefaultMutableTreeNode) node)
                    .getUserObject();

            // let others do their thing
            onSelectionChanged(nodeModel, tree, target);
        }

        // When we edit in a form we might have unsaved changes, 
        // add a behavior on each link to show a confirm dialog
        @Override
        public MarkupContainer newLink(String id, ILinkCallback callback) {
            MarkupContainer newLink = super.newLink(id, callback);

            if (entitiesEditable) {
                String condition = "formOnRender != (formBeforeSubmit=Wicket.Form.doSerialize(getFormWatched()))";
                String message = getString("unsavedchanges_entitychange_message");

                newLink.add(new ConditionalLinkConfirmationBehavior(message, condition));
            }
            return newLink;
        }

        /*
        // Trying to change the looks of invalid nodes... 
        // extending AttributeModifier might be what we want... but with css it is tricky
        class AddCSSClassBehavior extends AbstractBehavior {
           private static final long   serialVersionUID   = 1L;
                
           @Override
           public void onComponentTag(Component component, ComponentTag tag)
           {
              super.onComponentTag(component, tag);
                      
              //String classes = tag.getAttributes().getString("class");
              //logger.debug("CSS Class: " + classes);
              logger.debug("---> Changing tag: " + tag.getName());
                      
              // As a test just set the background to yellow
              tag.getAttributes().put("style", "background-color:yellow;");
              // but we don't have control over the content inside
              // We could have a JavaScript (jQuery possibly) 
              // to fix all the inside of the tags marked wit the class   
           }
        };
        @Override
        protected Component newNodeComponent(String id, IModel<Object> model)
        {
           Component component = super.newNodeComponent(id, model);
           //logger.debug("---> id: " + id); 
                   
           // Note: these are the table cells on the row with the link
           component.add(new AddCSSClassBehavior());
                   
           return component;
        }
        */

    };
    //linkTree.getTreeState().expandAll();
    // Have the toplevel of the tree expanded
    linkTree.getTreeState().expandNode(rootNode);

    add(linkTree);

    // selection, initial
    linkTree.getTreeState().selectNode(rootNode, true);

    //--- Tree expand/collapse 

    add(new AjaxLink("expandAll") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            linkTree.getTreeState().expandAll();
            linkTree.updateTree(target);
        }
    });

    add(new AjaxLink("collapseAll") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            linkTree.getTreeState().collapseAll();
            linkTree.updateTree(target);
        }
    });

}

From source file:org.geoserver.web.data.store.arcsde.ArcSDECoverageStoreEditPanel.java

License:Open Source License

/**
 * //  w  w w. j a va  2  s .c  o  m
 * @param paramsModel
 * @param isNew
 * @return a combobox set up to display the list of available raster tables if the StoreInfo is
 *         new, or a non editable text box if we're editing an existing StoreInfo
 */
private FormComponent addTableNameComponent(final IModel paramsModel, final boolean isNew) {

    final FormComponent tableNameComponent;
    final String panelId = "tableNamePanel";

    if (isNew) {
        RasterTableSelectionPanel selectionPanel;
        selectionPanel = new RasterTableSelectionPanel(panelId, paramsModel, storeEditForm, server, port,
                instance, user, password);
        add(selectionPanel);

        DropDownChoice tableDropDown = selectionPanel.getFormComponent();
        tableNameComponent = tableDropDown;
    } else {
        /*
         * We're editing an existing store. Don't allow to change the table name, it could be
         * catastrophic for the Catalog/ResourcePool as ability to get to the coverage is really
         * based on the Store's URL and the CoverageInfo is tied to it
         */
        final IModel paramValue = new MapModel(paramsModel, TABLE_NAME);
        final String resourceKey = RESOURCE_KEY_PREFIX + "." + TABLE_NAME;
        final IModel paramLabelModel = new ResourceModel(resourceKey, TABLE_NAME);
        final boolean required = true;
        TextParamPanel tableNamePanel;
        tableNamePanel = new TextParamPanel(panelId, paramValue, paramLabelModel, required);
        add(tableNamePanel);

        tableNameComponent = tableNamePanel.getFormComponent();
        tableNameComponent.setEnabled(false);

        final String titleKey = resourceKey + ".title";
        ResourceModel titleModel = new ResourceModel(titleKey);
        String title = String.valueOf(titleModel.getObject());

        tableNamePanel.add(new SimpleAttributeModifier("title", title));
    }

    return tableNameComponent;
}

From source file:org.geoserver.web.data.store.arcsde.ArcSDECoverageStoreEditPanel.java

License:Open Source License

private FormComponent addPasswordPanel(final IModel paramsModel) {

    final String paramName = PASSWORD_PARAM.key;
    final String resourceKey = RESOURCE_KEY_PREFIX + "." + paramName;

    final PasswordParamPanel pwdPanel = new PasswordParamPanel(paramName, new MapModel(paramsModel, paramName),
            new ResourceModel(resourceKey, paramName), true);
    add(pwdPanel);//from  w w  w .  ja v a  2  s  .  c  om

    String defaultTitle = String.valueOf(PASSWORD_PARAM.title);

    ResourceModel titleModel = new ResourceModel(resourceKey + ".title", defaultTitle);
    String title = String.valueOf(titleModel.getObject());

    pwdPanel.add(new SimpleAttributeModifier("title", title));

    return pwdPanel.getFormComponent();
}

From source file:org.geoserver.web.data.store.arcsde.ArcSDECoverageStoreEditPanel.java

License:Open Source License

private FormComponent addTextPanel(final IModel paramsModel, final Param param) {

    final String paramName = param.key;
    final String resourceKey = getClass().getSimpleName() + "." + paramName;

    final boolean required = param.required;

    final TextParamPanel textParamPanel = new TextParamPanel(paramName, new MapModel(paramsModel, paramName),
            new ResourceModel(resourceKey, paramName), required);
    textParamPanel.getFormComponent().setType(param.type);

    String defaultTitle = String.valueOf(param.title);

    ResourceModel titleModel = new ResourceModel(resourceKey + ".title", defaultTitle);
    String title = String.valueOf(titleModel.getObject());

    textParamPanel.add(new SimpleAttributeModifier("title", title));

    add(textParamPanel);//from   w w w  . j  av a2  s.  co  m
    return textParamPanel.getFormComponent();
}

From source file:org.geoserver.web.data.store.arcsde.RasterTableSelectionPanel.java

License:Open Source License

public RasterTableSelectionPanel(final String id, final IModel paramsModel, final Form storeEditForm,
        FormComponent server, FormComponent port, FormComponent instance, FormComponent user,
        FormComponent password) {/* ww w .java  2  s.c  om*/

    super(id);
    this.serverComponent = server;
    this.portComponent = port;
    this.instanceComponent = instance;
    this.userComponent = user;
    this.passwordComponent = password;

    final MapModel tableNameModel = new MapModel(paramsModel, TABLE_NAME);

    List<String> choices = new ArrayList<String>();
    if (tableNameModel.getObject() != null) {
        Object currentTableName = tableNameModel.getObject();
        choices.add(String.valueOf(currentTableName));
    }

    choice = new DropDownChoice("rasterTable", tableNameModel, choices);

    /*
     * Make table name match the option id
     */
    choice.setChoiceRenderer(new IChoiceRenderer() {
        private static final long serialVersionUID = 1L;

        public String getIdValue(Object tableName, int index) {
            return tableName.toString();
        }

        public Object getDisplayValue(Object tableName) {
            return tableName;
        }
    });
    choice.setOutputMarkupId(true);
    choice.setNullValid(false);
    choice.setRequired(true);

    final FormComponentFeedbackBorder feedback = new FormComponentFeedbackBorder("border");
    feedback.add(choice);
    add(feedback);
    {
        final String titleKey = RESOURCE_KEY_PREFIX + ".tableNameChoice.title";
        ResourceModel titleModel = new ResourceModel(titleKey);
        String title = String.valueOf(titleModel.getObject());
        choice.add(new SimpleAttributeModifier("title", title));
    }

    final AjaxSubmitLink refreshTablesLink = new AjaxSubmitLink("refresh", storeEditForm) {
        private static final long serialVersionUID = 1L;

        /**
         * We're not doing any validation here, just want to perform the same attempt to get to
         * the list of connection parameters than at {@link #onSumbit}
         */
        @Override
        protected void onError(AjaxRequestTarget target, Form form) {
            onSubmit(target, form);
        }

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form form) {

            final String server = serverComponent.getValue();
            final String port = portComponent.getValue();
            final String instance = instanceComponent.getValue();
            final String user = userComponent.getValue();
            final String password = passwordComponent.getValue();

            final ISessionPoolFactory sessionFac = getSessionFactory();

            List<String> rasterColumns;
            try {
                rasterColumns = getRasterColumns(server, port, instance, user, password, sessionFac);
            } catch (IllegalArgumentException e) {
                rasterColumns = Collections.emptyList();
                String message = "Refreshing raster tables list: " + e.getMessage();
                storeEditForm.error(message);
                target.addComponent(storeEditForm);// refresh
            }

            choice.setChoices(rasterColumns);
            target.addComponent(choice);
            // do nothing else, so we return to the same page...
        }
    };
    add(refreshTablesLink);
    {
        final String titleKey = RESOURCE_KEY_PREFIX + ".refresh.title";
        ResourceModel titleModel = new ResourceModel(titleKey);
        String title = String.valueOf(titleModel.getObject());
        refreshTablesLink.add(new SimpleAttributeModifier("title", title));
    }
}

From source file:org.geoserver.web.data.store.pgraster.PGRasterCoverageStoreEditPanel.java

License:Open Source License

private FormComponent addTextPanel(final IModel paramsModel, final String paramName) {

    final String resourceKey = getClass().getSimpleName() + "." + paramName;

    final boolean required = true;

    final TextParamPanel textParamPanel = new TextParamPanel(paramName, new MapModel(paramsModel, paramName),
            new ResourceModel(resourceKey, paramName), required);
    textParamPanel.getFormComponent().setType(String.class);

    String defaultTitle = paramName;

    ResourceModel titleModel = new ResourceModel(resourceKey + ".title", defaultTitle);
    String title = String.valueOf(titleModel.getObject());

    textParamPanel.add(new SimpleAttributeModifier("title", title));

    add(textParamPanel);//from   ww  w . j  a va2s  .  c o m
    return textParamPanel.getFormComponent();
}

From source file:org.geoserver.web.data.store.pgraster.PGRasterPanel.java

License:Open Source License

private FormComponent addPasswordPanel(final IModel paramsModel, final String paramName) {

    final String resourceKey = RESOURCE_KEY_PREFIX + "." + paramName;

    final PasswordParamPanel pwdPanel = new PasswordParamPanel(paramName, new MapModel(paramsModel, paramName),
            new ResourceModel(resourceKey, paramName), true);
    add(pwdPanel);/*from  w  w  w . j  a  v  a2 s.  c o m*/

    String defaultTitle = paramName;

    ResourceModel titleModel = new ResourceModel(resourceKey + ".title", defaultTitle);
    String title = String.valueOf(titleModel.getObject());

    pwdPanel.add(new SimpleAttributeModifier("title", title));

    return pwdPanel.getFormComponent();
}

From source file:org.geoserver.web.data.store.pgraster.PGRasterPanel.java

License:Open Source License

private FormComponent addTextPanel(final IModel paramsModel, final String paramName, final String paramTitle,
        final boolean required) {
    final String resourceKey = getClass().getSimpleName() + "." + paramName;

    final TextParamPanel textParamPanel = new TextParamPanel(paramName, new MapModel(paramsModel, paramTitle),
            new ResourceModel(resourceKey, paramName), required);
    textParamPanel.getFormComponent().setType(String.class/*param.type*/);

    String defaultTitle = paramTitle;

    ResourceModel titleModel = new ResourceModel(resourceKey + ".title", defaultTitle);
    String title = String.valueOf(titleModel.getObject());

    textParamPanel.add(new SimpleAttributeModifier("title", title));

    add(textParamPanel);/*w w w.ja  va2 s  . co m*/
    return textParamPanel.getFormComponent();
}