Java Code Examples for org.apache.wicket.markup.html.link.Link.setVisible()

The following are Jave code examples for showing how to use setVisible() of the org.apache.wicket.markup.html.link.Link class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: openNaEF   File: LocationViewPage.java   Source Code and License Vote up 6 votes
private void createAddLocationLink() {
    Link<Void> link = new Link<Void>("addLocation") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            LocationAddPage page = new LocationAddPage(LocationViewPage.this, current);
            setResponsePage(page);
        }
    };
    if (LocationUtil.isTrash(current)) {
        link.setEnabled(false);
        link.setVisible(false);
    }

    LocationType type = LocationType.getByCaption(LocationRenderer.getLocationType(current));
    if (LocationType.RACK.equals(type)) {
        link.add(new Label("label", ""));
    } else {
        link.add(new Label("label", "Add child location"));
    }
    add(link);
}
 
Example 2
Project: openNaEF   File: LocationViewPage.java   Source Code and License Vote up 6 votes
private void createEditLocationLink() {
    Link<Void> link = new Link<Void>("editLocation") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            LocationEditPage page = new LocationEditPage(LocationViewPage.this, current);
            setResponsePage(page);
        }
    };
    if (!LocationUtil.isEditable(current)) {
        link.setEnabled(false);
        link.setVisible(false);
    }
    add(link);
}
 
Example 3
Project: openNaEF   File: LocationViewPage.java   Source Code and License Vote up 6 votes
private void createDeleteLocationLink() {
    Link<Void> link = new Link<Void>("deleteLocation") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            LocationDeletePage page = new LocationDeletePage(LocationViewPage.this, current);
            setResponsePage(page);
        }
    };
    if (!LocationUtil.isEditable(current)) {
        link.setEnabled(false);
        link.setVisible(false);
    }
    add(link);
}
 
Example 4
Project: openNaEF   File: LocationViewPage.java   Source Code and License Vote up 6 votes
private void createAddNodeLink() {
    final WebPage page;
    if (LocationUtil.isNodeAssignable(current)) {
        page = new NodeEditPage(LocationViewPage.this, null, current);
    } else {
        page = null;
    }
    Link<Void> link = new Link<Void>("addNode") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            setResponsePage(page);
        }
    };
    boolean editable = LocationUtil.isNodeAssignable(current);
    link.setEnabled(editable);
    link.setVisible(editable);
    add(link);
}
 
Example 5
Project: projectforge-webapp   File: TreeIconsActionPanel.java   Source Code and License Vote up 6 votes
/**
 * Without click support (neither for selection nor for editing).
 * @param id component id
 * @param model model for contact
 * @param label The label to show (additional to the row_pointer.png). The id of the label should be LABEL_ID.
 */
public TreeIconsActionPanel(final String id, final IModel< ? > model, final Label label, final TreeTable< ? > treeTable)
{
  super(id, model);
  this.treeTable = treeTable;
  final Link<Void> selectLink = new Link<Void>("select") {
    @Override
    public void onClick()
    {
      // Do nothing
    };
  };
  selectLink.setVisible(false);
  this.link = selectLink;
  add(selectLink);
  add(label);
}
 
Example 6
Project: projectforge-webapp   File: RechnungEditForm.java   Source Code and License Vote up 6 votes
@SuppressWarnings("serial")
@Override
protected void onRenderPosition(final WebMarkupContainer item, final RechnungsPositionDO position)
{
  // item.add(new AuftragsPositionFormComponent("orderPosition", new PropertyModel<AuftragsPositionDO>(position, "auftragsPosition"),
  // false));

  final Link<String> orderLink = new Link<String>("orderLink") {
    @Override
    public void onClick()
    {
      if (position.getAuftragsPosition() != null) {
        final PageParameters parameters = new PageParameters();
        parameters.add(AbstractEditPage.PARAMETER_KEY_ID, position.getAuftragsPosition().getAuftrag().getId());
        final AuftragEditPage auftragEditPage = new AuftragEditPage(parameters);
        auftragEditPage.setReturnToPage(getParentPage());
        setResponsePage(auftragEditPage);
      }
    }
  };
  item.add(orderLink);
  if (position.getAuftragsPosition() == null) {
    orderLink.setVisible(false);
  }
  orderLink.add(new PresizedImage("linkImage", WebConstants.IMAGE_FIND));
}
 
Example 7
Project: projectforge-webapp   File: HRListEntryPanel.java   Source Code and License Vote up 6 votes
public HRListEntryPanel(final String id, final HRFilter filter, final BigDecimal plannedDays, final BigDecimal actualDays,
    final Link< ? > link)
{
  super(id);
  final BigDecimal planned = filter.isShowPlanning() == true ? plannedDays : null;
  final BigDecimal actual = filter.isShowBookedTimesheets() == true ? actualDays : null;
  final Label plannedDaysLabel = new Label("plannedDays", NumberFormatter.format(planned, 2));
  add(plannedDaysLabel.setRenderBodyOnly(true));
  if (NumberHelper.isNotZero(plannedDays) == false) {
    plannedDaysLabel.setVisible(false);
  }
  add(link);
  final Label actualDaysLabel = new Label("actualDays", "(" + NumberFormatter.format(actual, 2) + ")");
  link.add(actualDaysLabel.setRenderBodyOnly(true));
  if (NumberHelper.isNotZero(actualDays) == false) {
    link.setVisible(false);
  }
}
 
Example 8
Project: Jouve-Project   File: AutoHidePagingNavigator.java   Source Code and License Vote up 6 votes
protected void onBeforeRender() {
	super.onBeforeRender();

	Link firstLink = (Link) get("first");
	firstLink.setVisible(pageable.getPageCount() > 2
			&& pageable.getCurrentPage() > 0);

	Link prevLink = (Link) get("prev");
	prevLink.setVisible(pageable.getCurrentPage() > 0);

	Link nextLink = (Link) get("next");
	nextLink
			.setVisible(pageable.getCurrentPage() < pageable.getPageCount() - 1);

	Link lastLink = (Link) get("last");
	lastLink.setVisible(pageable.getPageCount() > 2
			&& pageable.getCurrentPage() < pageable.getPageCount() - 1);
}
 
Example 9
Project: openNaEF   File: TransactionExecutionResultPage.java   Source Code and License Vote up 5 votes
public TransactionExecutionResultPage(final CustomTransaction transaction) {
    try {
        AAAWebUtil.checkAAA(this, OPERATION_NAME);
        add(UrlUtil.getTopLink("top"));
        Label titleLabel = new Label("title", transaction.getTitle());
        add(titleLabel);
        Label headLabel = new Label("head", transaction.getHead());
        add(headLabel);

        final String msg;
        final WebPage nextPage;
        if (transaction.isSuccess()) {
            msg = transaction.getSuccessResultMessage();
            nextPage = transaction.getForwardPage();
        } else {
            msg = transaction.getFailResultMessage();
            nextPage = transaction.getBackPage();
        }
        Label messageLabel = new Label("resultMessage", msg);
        add(messageLabel);
        Link<Void> backLink = new Link<Void>("back") {
            private static final long serialVersionUID = 1L;

            public void onClick() {
                setResponsePage(nextPage);
            }
        };
        backLink.setEnabled(nextPage != null);
        backLink.setVisible(nextPage != null);
        add(backLink);
    } catch (Exception e) {
        throw ExceptionUtils.throwAsRuntime(e);
    }
}
 
Example 10
Project: openNaEF   File: LinkEditPage.java   Source Code and License Vote up 4 votes
public LinkEditPage(WebPage backPage, PortDto basePort) {
    try {
        this.editorName = AAAWebUtil.checkAAA(this, OPERATION_NAME);
        if (backPage == null) {
            throw new IllegalArgumentException();
        }
        this.backPage = backPage;
        if (basePort == null) {
            throw new IllegalArgumentException();
        }
        basePort.renew();
        this.basePort = basePort;
        this.l2Neighbor = NodeUtil.getLayer2Neighbor(basePort);
        this.model = new NeighborModel(basePort);

        Link<Void> backLink = new Link<Void>("back") {
            private static final long serialVersionUID = 1L;

            @Override
            public void onClick() {
                setResponsePage(getBackPage());
            }
        };
        add(backLink);
        add(new FeedbackPanel("feedback"));

        Label baseLabel = new Label("baseName", new PropertyModel<String>(this.model, "baseName"));
        add(baseLabel);
        Label nodeLabel1 = new Label("node", new PropertyModel<String>(this.model, "hereNodeName"));
        add(nodeLabel1);
        Label ifNameLabel1 = new Label("ifName", new PropertyModel<String>(this.model, "hereIfName"));
        add(ifNameLabel1);
        BookmarkablePageLink<Void> neighborLink =
                new BookmarkablePageLink<Void>("neighborNode",
                        SimpleNodeDetailPage.class,
                        NodeUtil.getNodeParameters(this.model.getThere()));
        add(neighborLink);
        Label nodeLabel2 = new Label("nodeName", new PropertyModel<String>(this.model, "thereNodeName"));
        neighborLink.add(nodeLabel2);
        Label ifNameLabel2 = new Label("neighborIfName", new PropertyModel<String>(this.model, "thereIfName"));
        add(ifNameLabel2);

        linkL2Node = createLink("layer2NeighborNode", l2Neighbor);
        add(linkL2Node);
        Label linkL2Label = new Label("layer2NeighborIfName", new PropertyModel<String>(this, "l2NeighborIfName"));
        add(linkL2Label);
        Link<Void> editLayer2 = createEditor("createLink", basePort, l2Neighbor);
        editLayer2.setEnabled(l2Neighbor == null);
        editLayer2.setVisible(l2Neighbor == null);
        add(editLayer2);
        Link<Void> deleteLayer2 = createDeleteButton("deleteLink", false, basePort);
        deleteLayer2.setEnabled(l2Neighbor != null);
        deleteLayer2.setVisible(l2Neighbor != null);
        add(deleteLayer2);

    } catch (Exception e) {
        throw ExceptionUtils.throwAsRuntime(e);
    }
}
 
Example 11
Project: superfly   File: ListUsersPage.java   Source Code and License Vote up 4 votes
private void downloadHtopTable(Item<UIUserForList> item, final UIUserForList user) {
    Link<Void> downloadHotpTableLink = new Link<Void>("download-hotp-table") {
        @Override
        public void onClick() {
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            try {
                hotpProvider.outputSequenceForDownload(user.getUsername(), os);
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
            final byte[] bytes = os.toByteArray();
            IResourceStream resourceStream = new AbstractResourceStream() {
                @Override
                public Time lastModifiedTime() {
                    return Time.now();
                }

                @Override
                public Bytes length() {
                    return Bytes.bytes(bytes.length);
                }

                @Override
                public InputStream getInputStream() throws ResourceStreamNotFoundException {
                    return new ByteArrayInputStream(bytes);
                }

                @Override
                public String getContentType() {
                    return "application/vnd.ms-excel";
                }

                @Override
                public void close() throws IOException {
                }
            };
            getRequestCycle().replaceAllRequestHandlers(new ResourceStreamRequestHandler(resourceStream,
                    hotpProvider.getSequenceForDownloadFileName(user.getUsername())));
        }
    };
    downloadHotpTableLink.setVisible(hotpProvider.outputsSequenceForDownload());
    item.add(downloadHotpTableLink);
}
 
Example 12
Project: oodt   File: VisibilityAndSortToggler.java   Source Code and License Vote up 4 votes
/**
 * @param id
 */
public VisibilityAndSortToggler(String id, String showLinkId,
    String hideLinkId, String sortLinkId, String unsortLinkId, String moreId,
    final ListModel model) {
  super(id, showLinkId, hideLinkId, moreId, model);

  Link<Link> sortLink;
  Link<Link> unsortLink = null;

  sortLink = new Link<Link>(sortLinkId, new Model<Link>(null)) {
    /*
     * (non-Javadoc)
     * 
     * @see org.apache.wicket.markup.html.link.Link#onClick()
     */
    @Override
    public void onClick() {
      Vector obj = (Vector) model.getObject();
      sortByStatus(obj);
      model.setObject(obj);
      getModelObject().setVisible(true);
      setVisible(false);
    }
  };

  unsortLink = new Link<Link>(unsortLinkId, new Model<Link>(sortLink)) {
    /*
     * (non-Javadoc)
     * 
     * @see org.apache.wicket.markup.html.link.Link#onClick()
     */
    @Override
    public void onClick() {
      Vector obj = (Vector) model.getObject();
      sortByName(obj);
      model.setObject(obj);
      getModelObject().setVisible(true);
      setVisible(false);
    }
  };

  unsortLink.setVisible(false);
  sortLink.setModelObject(unsortLink);
  unsortLink.setModelObject(sortLink);

  add(sortLink);
  add(unsortLink);

}
 
Example 13
Project: oodt   File: VisibilityToggler.java   Source Code and License Vote up 4 votes
/**
 * @param id
 */
public VisibilityToggler(String id, String showLinkId, String hideLinkId,
    String moreId, final ListModel model) {
  super(id, model);

  Link<Link> showLink;
  Link<Link> hideLink = null;
  final Vector allStatusList = (Vector) ((Vector) model.getObject()).clone();

  // subset the model
  model.setObject(subsetModelObject(model.getObject()));
  final WebMarkupContainer moreComponent = new WebMarkupContainer(moreId);
  add(moreComponent);

  showLink = new Link<Link>(showLinkId, new Model<Link>(null)) {
    /*
     * (non-Javadoc)
     * 
     * @see org.apache.wicket.markup.html.link.Link#onClick()
     */
    @Override
    public void onClick() {
      Vector obj = (Vector) model.getObject();
      obj.clear();
      obj.addAll(allStatusList);
      model.setObject(obj);
      moreComponent.setVisible(false);
      getModelObject().setVisible(true);
      setVisible(false);
    }
  };

  hideLink = new Link<Link>(hideLinkId, new Model<Link>(showLink)) {
    /*
     * (non-Javadoc)
     * 
     * @see org.apache.wicket.markup.html.link.Link#onClick()
     */
    @Override
    public void onClick() {
      Vector obj = (Vector) model.getObject();
      obj.clear();
      obj.addAll(getTopN(allStatusList, 3));
      model.setObject(obj);
      getModelObject().setVisible(true);
      setVisible(false);
      moreComponent.setVisible(true);
    }
  };

  hideLink.setVisible(false);
  showLink.setModelObject(hideLink);
  hideLink.setModelObject(showLink);

  add(showLink);
  add(hideLink);
}
 
Example 14
Project: projectforge-webapp   File: AddressListPhoneNumberPanel.java   Source Code and License Vote up 4 votes
@SuppressWarnings("serial")
public AddressListPhoneNumberPanel(final String id, final AddressListPage parentPage, final Integer addressId, final PhoneType phoneType,
    final String phoneNumber, final boolean favoriteNumber, final boolean sendSms, final IconType icon, final boolean first)
{
  super(id);
  final WebMarkupContainer linkOrSpan;
  if (parentPage.phoneCallSupported == true) {
    linkOrSpan = new Link<String>("directCallLink") {
      @Override
      public void onClick()
      {
        final PageParameters params = new PageParameters();
        params.add(PhoneCallPage.PARAMETER_KEY_ADDRESS_ID, addressId);
        params.add(PhoneCallPage.PARAMETER_KEY_NUMBER, phoneNumber);
        setResponsePage(new PhoneCallPage(params));
      }
    };
    add(WicketUtils.getInvisibleComponent("phoneNumber"));
  } else {
    linkOrSpan = new WebMarkupContainer("phoneNumber");
    add(WicketUtils.getInvisibleComponent("directCallLink"));
  }
  linkOrSpan.add(AttributeModifier.replace("onmouseover", "zoom('" + phoneNumber + "'); return false;"));
  final String tooltip = parentPage.getString(phoneType.getI18nKey());
  add(linkOrSpan);
  WicketUtils.addTooltip(linkOrSpan, tooltip);
  final Label numberLabel = new Label("number", phoneNumber);
  if (favoriteNumber == true) {
    numberLabel.add(AttributeModifier.replace("style", "color:red; font-weight:bold;"));
  } else {
    numberLabel.setRenderBodyOnly(true);
  }
  linkOrSpan.add(numberLabel);
  linkOrSpan.add(new IconPanel("phoneImage", icon));
  final Link<String> sendMessage = new Link<String>("sendMessageLink") {
    @Override
    public void onClick()
    {
      final PageParameters params = new PageParameters();
      params.add(SendSmsPage.PARAMETER_KEY_ADDRESS_ID, addressId);
      params.add(SendSmsPage.PARAMETER_KEY_PHONE_TYPE, phoneType.toString());
      setResponsePage(SendSmsPage.class, params);
    }
  };
  if (sendSms == false || parentPage.messagingSupported == false) {
    sendMessage.setVisible(false);
  }
  add(sendMessage);
}