Example usage for org.apache.wicket.util.value ValueMap put

List of usage examples for org.apache.wicket.util.value ValueMap put

Introduction

In this page you can find the example usage for org.apache.wicket.util.value ValueMap put.

Prototype

@Override
public Object put(final String key, final Object value) 

Source Link

Usage

From source file:com.cloudera.recordbreaker.fisheye.SettingsPage.java

License:Open Source License

public SettingsPage() {
    FishEye fe = FishEye.getInstance();/*from w ww  .  j  a va  2  s .  co m*/
    AccessController accessCtrl = fe.getAccessController();
    final String username = accessCtrl.getCurrentUser();
    final ValueMap logins = new ValueMap();
    logins.put("currentuser", username);
    this.setOutputMarkupPlaceholderTag(true);

    //
    // Login/logout
    //
    add(new LoginForm("loginform", logins));
    add(new LogoutForm("logoutform", logins));
    final Label loginErrorLabel = new Label("loginErrorMessage", "Your username and password did not match.");
    loginErrorMsgDisplay.add(loginErrorLabel);
    loginErrorMsgDisplay.setOutputMarkupPlaceholderTag(true);
    add(loginErrorMsgDisplay);
    loginErrorMsgDisplay.setVisibilityAllowed(false);

    //
    // Add filesystem/remove filesystem
    //
    final ValueMap fsinfo = new ValueMap();
    add(new FilesystemRegistrationForm("fsaddform", fsinfo));
    add(new FilesystemInfoForm("fsinfoform", fsinfo));
    final Label fsErrorLabel = new Label("fsErrorMessage", "The filesystem was not found.");
    fsErrorMsgDisplay.add(fsErrorLabel);
    fsErrorMsgDisplay.setOutputMarkupPlaceholderTag(true);
    add(fsErrorMsgDisplay);
    fsErrorMsgDisplay.setVisibilityAllowed(false);

    //
    // Hive query server info
    //
    add(new QueryServerInfoForm("queryserverinfo", new ValueMap()));

    //
    // If the filesystem is there, we need to have info about its crawls
    //
    /**
    WebMarkupContainer crawlContainer = new WebMarkupContainer("crawlContainer");
    ListView<CrawlSummary> crawlListView = new ListView<CrawlSummary>("crawlListView", crawlList) {
      protected void populateItem(ListItem<CrawlSummary> item) {
        CrawlSummary cs = item.getModelObject();
        // Fields are: 'crawlid' and 'crawllastexamined'
        item.add(new Label("crawlid", "" + cs.getCrawlId()));
        item.add(new Label("crawllastexamined", cs.getLastExamined()));
      }
    };
    crawlContainer.add(crawlListView);
    fsDisplayContainer.add(crawlContainer);
    crawlContainer.setVisibilityAllowed(crawlList.size() > 0);
    **/

    //
    // Standard environment variables
    //
    add(new Label("fisheyeStarttime", fe.getStartTime().toString()));
    add(new Label("fisheyePort", "" + fe.getPort()));
    try {
        add(new Label("fisheyeDir", "" + fe.getFisheyeDir().getCanonicalPath()));
    } catch (IOException iex) {
        add(new Label("fisheyeDir", "unknown"));
    }
}

From source file:de.javakaffee.misc.wicket.ccs.SingleParameterNoPathCodingStrategy.java

License:Apache License

@Override
@SuppressWarnings("unchecked")
protected ValueMap decodeParameters(final String urlFragment, final Map urlParameters) {
    final ValueMap firstParam = super.decodeParameters(urlFragment, urlParameters);

    final ValueMap params = _queryStringUrlCodingStrategy.decodeParameters(urlFragment, urlParameters);
    final Object firstParamValue = firstParam.get(FIRST_PARAMETER_KEY);
    if (firstParamValue != null) {
        params.put(FIRST_PARAMETER_KEY, firstParamValue);
    }/* w w  w .  ja  v  a  2 s  . co  m*/

    return params;
}

From source file:de.voolk.marbles.web.pages.admin.auth.ListUserPage.java

License:Open Source License

@SuppressWarnings("serial")
public ListUserPage() {
    action = new WebComponent("action");
    add(action);//  w w w. ja v  a  2  s .  c  om
    add(new DataView<User>("userList", new UserDataProvider(authentificationService)) {
        @SuppressWarnings("rawtypes")
        private Link removeLink;

        @Override
        @SuppressWarnings("rawtypes")
        protected void populateItem(Item<User> userItem) {
            final User user = userItem.getModelObject();
            removeLink = new Link("remove") {
                @Override
                public void onClick() {
                    selectedUsertoRemove = user;
                    ValueMap info = new ValueMap();
                    info.put("user", user.getName());
                    new ReplacingConfirmationActionPanel(action, new StringResourceModel("remove.confirmation",
                            ListUserPage.this, new Model<ValueMap>(info))) {
                        @Override
                        public void execute() {
                            pageService.removeAllPages(user);
                            authentificationService.removeUser(user.getId());
                            setResponsePage(ListUserPage.this.getClass());
                        }

                        @Override
                        public void cancel() {
                            super.cancel();
                            selectedUsertoRemove = null;
                        }
                    };
                }
            };
            String crossPic = "cross.png";
            if (authentificationService.userHasRole(user, IdentSession.SYSTEM_ROLE)
                    || selectedUsertoRemove != null) {
                removeLink.setEnabled(false);
                crossPic = "cross_gray.png";
            }
            removeLink.add(new Image("crossImg", new ResourceReference(ListUserPage.class, crossPic)));
            userItem.add(removeLink);
            userItem.add(new Label("id", String.valueOf(user.getId())));
            userItem.add(new Label("name", user.getName()));
            userItem.add(new Label("email", user.getEmail()));
        }
    });
}

From source file:net.kornr.swit.button.ButtonResource.java

License:Apache License

/**
 * Return a ValueMap to associate to a ButtonResource ResourceReference.
 * This methods registers the pair [template, text] if it it not already in the normal cache.
 * @param template//w w w  . j a v a  2 s .c o  m
 * @param text
 * @return
 */
static public ValueMap getValueMap(ButtonTemplate template, String text) {
    Long id = getUniqueId(new ButtonResourceKey(template, text));
    ValueMap map = new ValueMap();
    map.put("id", id.toString());
    return map;
}

From source file:net.kornr.swit.button.ButtonResource.java

License:Apache License

/**
 * Return a ValueMap for a pair [template, text]. The pair is stored in the temporary cache.
 * //from   www.j a  va  2s .  co  m
 * @param template the ButtonTemplate object to use
 * @param text the text of the button
 * @param download true if the resource should be sent to the browser as an attachment, false (the default) to send it normally as an inline image. 
 * @param filename if download is true, this specified the filename under which the button image should be sent to the web browser. Can be null, for a default value.
 * @return A ValueMap to use with a ButtonResource ResourceReference 
 */
static public ValueMap getTemporaryValueMap(ButtonTemplate template, String text, boolean download,
        String filename) {
    Long id = getTemporaryId(new ButtonResourceKey(template, text));
    ValueMap map = new ValueMap();
    map.put("id", id.toString());
    if (download)
        map.put("download", "please");
    if (download && filename != null)
        map.put("filename", filename);
    return map;
}

From source file:net.kornr.swit.wicket.border.graphics.BorderMaker.java

License:Apache License

public static org.apache.wicket.markup.html.image.Image getImage(String id, Long imageId, String type,
        boolean indexed) {
    ValueMap args = new ValueMap();
    args.put("border", type);
    args.put("id", imageId.toString());
    args.put("type", indexed ? "indexed" : "rgb");
    ResourceReference ref = getReference();
    org.apache.wicket.markup.html.image.Image img = new org.apache.wicket.markup.html.image.Image(id, ref,
            args);//from  www .  j av  a  2  s .  c  om

    Dimension dim = BorderMaker.get(imageId).getMapSize(type);

    img.add(new AttributeModifier("width", true, new Model<String>("" + dim.width)));
    img.add(new AttributeModifier("height", true, new Model<String>("" + dim.height)));
    return img;
}

From source file:net.kornr.swit.wicket.border.graphics.BorderMaker.java

License:Apache License

public static String getUrl(Long imageId, String type, boolean indexed) {
    ValueMap args = new ValueMap();
    args.put("border", type);
    args.put("id", imageId.toString());
    args.put("type", indexed ? "indexed" : "rgb");
    ResourceReference ref = getReference();
    return RequestCycle.get().urlFor(ref, args).toString();
}

From source file:net.kornr.swit.wicket.layout.threecol.ThreeColumnsLayoutResource.java

License:Apache License

static public String urlFor(LayoutInfo layout, Integer left, Integer right, Integer unit) {
    ResourceReference ref = ThreeColumnsLayoutResource.getResourceReference();
    ValueMap args = new ValueMap();
    args.put("id", layout.getName());
    if (left != null)
        args.put("left", left.toString());
    if (right != null)
        args.put("right", right.toString());
    if (unit != null) {
        switch (layout.getUnit()) {
        case LayoutInfo.UNIT_EM:
            args.put("unit", "em");
            break;
        case LayoutInfo.UNIT_PIXEL:
            args.put("unit", "px");
            break;
        case LayoutInfo.UNIT_PERCENTAGE:
            args.put("unit", "%");
            break;
        }/* w  ww .j a v  a2s.c o  m*/
    }

    return RequestCycle.get().urlFor(ref, args).toString();
}

From source file:net.kornr.swit.wicket.layout.threecol.ThreeColumnsLayoutResource.java

License:Apache License

static public String getStyle(LayoutInfo layout) {
    if (m_styles.containsKey(layout)) {
        return m_styles.get(layout);
    }/*  w  w  w.ja  va 2 s  . com*/

    // Map<String,Object> map = new HashMap<String,Object>();
    ValueMap map = layout.getClassId();
    map.put("right-column-width", new Integer(layout.getRightSize()).toString());
    map.put("left-column-width", new Integer(layout.getLeftSize()).toString());
    map.put("right-plus-left-columns-width", Integer.toString(layout.getRightSize() + layout.getLeftSize()));
    map.put("hundred-minus-right-plus-left-pc",
            Integer.toString(100 - (layout.getRightSize() + layout.getLeftSize())));
    map.put("hundred-minus-left-pc", Integer.toString(100 - layout.getLeftSize()));

    map.put("left-color", LayoutInfo.toCssValue(layout.getLeftColor()));
    map.put("right-color", LayoutInfo.toCssValue(layout.getRightColor()));
    map.put("middle-color", LayoutInfo.toCssValue(layout.getMiddleColor()));

    String unit = "em";
    switch (layout.getUnit()) {
    case LayoutInfo.UNIT_EM:
        unit = "em";
        break;
    case LayoutInfo.UNIT_PIXEL:
        unit = "px";
        break;
    case LayoutInfo.UNIT_PERCENTAGE:
        unit = "%";
        break;
    }

    map.put("unit", unit);

    PackagedTextTemplate template = null;

    String result = null;
    if (layout.getUnit() == LayoutInfo.UNIT_PERCENTAGE) {
        template = new PackagedTextTemplate(ThreeColumnsLayoutResource.class, "ThreeColumnsLayoutPanel_pc.css");
        result = template.asString(map);
    } else {
        template = new PackagedTextTemplate(ThreeColumnsLayoutResource.class,
                "ThreeColumnsLayoutPanel_empx.css");
        result = template.asString(map);
    }

    m_styles.put(layout, result);
    return result;
}

From source file:org.headsupdev.agile.app.milestones.ViewMilestoneGroup.java

License:Open Source License

public void layout() {
    super.layout();
    page = this;// w w w .  j  av a2s.  co m
    add(CSSPackageResource.getHeaderContribution(getClass(), "milestone.css"));

    String name = getPageParameters().getString("id");

    group = dao.find(name, getProject());
    if (group == null) {
        notFoundError();
        return;
    }

    addLinks(getLinks(group));
    addDetails();

    List<Comment> commentList = new LinkedList<Comment>();
    commentList.addAll(group.getComments());
    Collections.sort(commentList, new Comparator<Comment>() {
        public int compare(Comment comment1, Comment comment2) {
            return comment1.getCreated().compareTo(comment2.getCreated());
        }
    });
    add(new ListView<Comment>("comments", commentList) {
        protected void populateItem(ListItem<Comment> listItem) {
            Comment comment = listItem.getModelObject();
            listItem.add(new Image("icon", new ResourceReference(HeadsUpPage.class, "images/comment.png")));
            listItem.add(new Label("username", comment.getUser().getFullnameOrUsername()));
            listItem.add(new Label("created", new FormattedDateModel(comment.getCreated(),
                    ((HeadsUpSession) getSession()).getTimeZone())));

            listItem.add(new Label("comment", new MarkedUpTextModel(comment.getComment(), getProject()))
                    .setEscapeModelStrings(false));
        }
    });

    filter = new MilestoneFilterPanel("filter", getSession().getUser()) {
        @Override
        public Criterion getCompletedCriterion() {
            Criterion c = super.getCompletedCriterion();

            if (c == null) {
                c = Restrictions.eq("group", group);
            } else {
                c = Restrictions.and(c, Restrictions.eq("group", group));
            }

            return c;
        }

        @Override
        public void invalidDatePeriod() {
            warn("Invalid date period");
        }
    };
    if (group.isCompleted()) {
        filter.setFilters(0, false, true);
    } else {
        filter.setFilters(0, true, false);
    }
    add(filter);

    boolean hideProject = true;
    final SortableEntityProvider<Milestone> provider;
    if (getProject().equals(StoredProject.getDefault())) {
        provider = new MilestoneProvider(filter);
        hideProject = false;
    } else {
        provider = new MilestoneProvider(getProject(), filter);
    }

    add(new MilestoneListPanel("milestonelist", provider, this, hideProject, group));

    boolean timeEnabled = Boolean.parseBoolean(
            group.getProject().getConfigurationValue(StoredProject.CONFIGURATION_TIMETRACKING_ENABLED))
            && group.hasValidTimePeriod();
    add(new Image("graph", new ResourceReference("groupburndown.png"), getPageParameters())
            .setVisible(timeEnabled));
    add(new WorkRemainingTable("table", group).setVisible(timeEnabled));

    ValueMap params = new ValueMap();
    params.put("project", getProject().getId());
    params.put("groupId", group.getName());
    params.put("silent", true);
    add(new ResourceLink("exportgroup", new ResourceReference("export-worked.csv"), params)
            .setVisible(timeEnabled));
}