org.apache.wicket.markup.html.link.AbstractLink Java Examples

The following examples show how to use org.apache.wicket.markup.html.link.AbstractLink. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AjaxCommand.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
protected AbstractLink newLink(String id) {
	return new AjaxFallbackLink<Object>(id)
       {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		@Override
		public void onClick(Optional<AjaxRequestTarget> targetOptional) {
			AjaxCommand.this.onClick(targetOptional);
			trySendActionPerformed();
		}
       };
}
 
Example #2
Source File: ExportOSchemaCommand.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
protected AbstractLink newLink(String id) {
	return new ResourceLink<Object>(id, new DatabaseExportResource()
	{

		@Override
		protected ResourceResponse newResourceResponse(Attributes attrs) {
			ResourceResponse resourceResponse = super.newResourceResponse(attrs);
			resourceResponse.setFileName("schema.gz");
			return resourceResponse;
		}

		@Override
		protected void configureODatabaseExport(ODatabaseExport dbExport) {
			dbExport.setOptions("-excludeAll=true -includeSchema=true");
		}
		
	});
}
 
Example #3
Source File: URLPagingNavigation.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected AbstractLink newPagingNavigationLink(final String id, final IPageable pageable, final long pageIndex) {

    final LinksSupport links = ((AbstractWebPage) getPage()).getWicketSupportFacade().links();
    final PaginationSupport pagination = ((AbstractWebPage) getPage()).getWicketSupportFacade().pagination();

    final PageParameters pageParameters = links.getFilteredCurrentParameters(getPage().getPageParameters());
    pageParameters.set(WebParametersKeys.PAGE, pageIndex);

    final Link rez = links.newLink(id, pageParameters);
    if (pagination.markSelectedPageLink(rez, getPage().getPageParameters(), (int) pageIndex)) {
        rez.setModel(new Model(Boolean.TRUE));
    }

    return  rez;
}
 
Example #4
Source File: URLPagingNavigator.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected AbstractLink newPagingNavigationIncrementLink(final String id, final IPageable pageable, final int increment) {

    final LinksSupport links = ((AbstractWebPage) getPage()).getWicketSupportFacade().links();
    final PageParameters map = links.getFilteredCurrentParameters(pageParameters);

    final long total = pageable.getPageCount();
    final long current = pageable.getCurrentPage();
    final long tryPage = current + increment;

    map.set(WebParametersKeys.PAGE, tryPage < 0 ? 0 : tryPage >= total ? total - 1 : tryPage);

    return (AbstractLink) links.newLink(id, map).add(new AttributeModifier("class", "nav-page-control"));

    //return new PagingNavigationIncrementLink<Void>(id, pageable, increment);
}
 
Example #5
Source File: Command.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
protected AbstractLink newLink(String id)
 {
 	return new Link<Object>(id)
     {
         /**
 * 
 */
private static final long serialVersionUID = 1L;

@Override
public void onClick()
         {
             Command.this.onClick();
             trySendActionPerformed();
         }
     };
 }
 
Example #6
Source File: DashboardPopupMenuModel.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
@Override
protected List<MenuItem> load() {
	Injector.get().inject(this);
       List<MenuItem> menuItems = new ArrayList<MenuItem>();
       Object dashboard = model.getObject();
       
       DashboardSection dashboardSection = (DashboardSection)sectionManager.getSection(DashboardSection.ID);
       List<ActionContributor> popupContributors = dashboardSection.getPopupContributors();
       if (popupContributors != null) {
       	for (ActionContributor contributor : popupContributors) {    
       			if (contributor.isVisible()) {
        			AbstractLink link = contributor.getLink(createActionContext(dashboard));
        			if (link.isVisible()) {
        				menuItems.add(new MenuItem(link, contributor.getActionName(),  contributor.getActionImage()));
        			}
       			}
       	}        	
       }
                      
       //MenuItem menuItem = new MenuItem("images/" + ThemesManager.getActionImage(storageService.getSettings().getColorTheme()), null);
       MenuItem menuItem = new MenuItem("images/actions.png", null);
       menuItem.setMenuItems(menuItems);
       
       return Arrays.asList(menuItem);
}
 
Example #7
Source File: WicketPageTestBase.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Searches ContentMenuEntryPanels.
 * @param container
 * @param accessKey
 * @return Found component with the given label or null if no such component found.
 * @see FormComponent#getModelObject()
 * @see LabeledWebMarkupContainer#getLabel()
 * @see ContentMenuEntryPanel#getLabel()
 */
public Component findComponentByAccessKey(final MarkupContainer container, final char accessKey)
{
  final Component[] component = new Component[1];
  container.visitChildren(new IVisitor<Component, Void>() {
    @Override
    public void component(final Component object, final IVisit<Void> visit)
    {
      if (object instanceof AbstractLink) {
        final AbstractLink link = (AbstractLink) object;
        final AttributeModifier attrMod = WicketUtils.getAttributeModifier(link, "accesskey");
        if (attrMod == null || attrMod.toString().contains("object=[n]") == false) {
          return;
        }
        component[0] = object;
        visit.stop();
      }
    }
  });
  return component[0];
}
 
Example #8
Source File: ContentMenuEntryPanel.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @see org.apache.wicket.Component#onInitialize()
 */
@SuppressWarnings("serial")
@Override
protected void onInitialize()
{
  super.onInitialize();
  if (link == null) {
    this.link = new AbstractLink(LINK_ID) {
    };
  } else {
    this.hasLink = true;
  }
  li.add(link);
  link.add(labelComponent);
  caret = new WebMarkupContainer("caret");
  if (subMenu.hasEntries() == true) {
    // Children available.
    link.add(AttributeModifier.append("class", "dropdown-toggle"));
    link.add(AttributeModifier.append("data-toggle", "dropdown"));
    li.add(AttributeModifier.append("class", "dropdown"));
  } else {
    dropDownMenu.setVisible(false);
    caret.setVisible(false);
  }
  link.add(caret);
}
 
Example #9
Source File: OmMenuItem.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
public AbstractLink create(String markupId) {
	AbstractLink item;
	if (Strings.isEmpty(title)) {
		item = new MenuDivider();
	} else if (items.isEmpty()) {
		item = new NavbarAjaxLink<String>(markupId, Model.of(title)) {
			private static final long serialVersionUID = 1L;

			@Override
			public void onClick(AjaxRequestTarget target) {
				OmMenuItem.this.onClick(target);
			}
		}.setIconType(icon);
		item.add(AttributeModifier.append(ATTR_CLASS, "nav-link"));
	} else {
		item = new NavbarDropDownButton(Model.of(title), Model.of(icon)) {
			private static final long serialVersionUID = 1L;

			@Override
			protected List<AbstractLink> newSubMenuButtons(String markupId) {
				return items.stream().map(mItem -> ((OmMenuItem)mItem).create(markupId)).collect(Collectors.toList());
			}
		};
	}
	item.add(AttributeModifier.append(ATTR_TITLE, desc));
	item.setVisible(visible);
	return item;
}
 
Example #10
Source File: ExportCommand.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected AbstractLink newLink(String id) {
	IResource resource = new ResourceStreamResource()
	{
		@Override
		protected IResourceStream getResourceStream(Attributes attrs)
		{
			return new DataExportResourceStreamWriter(dataExporter, table);
		}
	}.setFileName(fileNameModel.getObject() + "." + dataExporter.getFileNameExtension());

	return new ResourceLink<Void>(id, resource);
}
 
Example #11
Source File: LinkViewPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected AbstractLink newLink(String id)
{
	ODocumentPageLink link = new ODocumentPageLink(id, getModel());
	if(titleModel!=null) link.setBody(titleModel);
	else link.setDocumentNameAsBody(true);
	return link;
}
 
Example #12
Source File: JEXLTransformerWidget.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
protected AbstractLink getEventsLink(final String linkid) {
    return new AjaxLink<String>(linkid) {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            transformers.setItem(target, JEXLTransformerWidget.this.item);
            transformers.toggle(target, true);
        }
    };
}
 
Example #13
Source File: EtcdNodePanel.java    From etcd-viewer with Apache License 2.0 5 votes vote down vote up
private AbstractLink createNavigationLink(final String id, final IModel<String> targetKey) {
        return new NavigationPageLink(id, registry, targetKey);

/*        return new AjaxLink<String>(id, targetKey) {
            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                key.setObject(getModelObject());

                target.add(EtcdNodePanel.this);
                onNodeKeyUpdated(target);
            }
            @Override
            public String getBeforeDisabledLink() {
                return "";
            }
            @Override
            public String getAfterDisabledLink() {
                return "";
            }
            @Override
            protected void onConfigure() {
                super.onConfigure();
                setEnabled(selectedCluster != null && selectedCluster.getObject() != null && getModelObject() != null );
            }
        };*/
    }
 
Example #14
Source File: ProductDetailPage.java    From AppStash with Apache License 2.0 5 votes vote down vote up
private AbstractLink addToCartLink() {
    return new IndicatingAjaxLink<Void>("addToCart") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            target.add(feedback);
            send(getPage(), Broadcast.BREADTH, new AddToCartEvent(target, getPage(), productInfoModel.getObject(), getTags()));
        }
    };
}
 
Example #15
Source File: TreeIconsActionPanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public static ContextImage getCurrentFolderImage(final Response response, final AbstractLink folderLink, final TreeTableNode node)
{
  final ContextImage folderImage = (ContextImage) folderLink.get("folderImage");
  final ContextImage folderOpenImage = (ContextImage) folderLink.get("folderOpenImage");
  final boolean isOpen = node.isOpened();
  folderImage.setVisible(!isOpen);
  folderOpenImage.setVisible(isOpen);
  if (isOpen == true) {
    return folderOpenImage;
  } else {
    return folderImage;
  }
}
 
Example #16
Source File: ProductDetailPage.java    From the-app with Apache License 2.0 5 votes vote down vote up
private AbstractLink addToCartLink() {
    return new IndicatingAjaxLink<Void>("addToCart") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            target.add(feedback);
            send(getPage(), Broadcast.BREADTH, new AddToCartEvent(target, getPage(), productInfoModel.getObject(), getTags()));
        }
    };
}
 
Example #17
Source File: ItemTransformerWidget.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
protected AbstractLink getEventsLink(final String linkid) {
    return new AjaxLink<String>(linkid) {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            transformers.setItem(target, ItemTransformerWidget.this.item);
            transformers.toggle(target, true);
        }
    };
}
 
Example #18
Source File: Details.java    From syncope with Apache License 2.0 5 votes vote down vote up
private static List<RealmTO> getRealmsFromLinks(final List<AbstractLink> realmLinks) {
    List<RealmTO> realms = new ArrayList<>();

    realmLinks.stream().
            map(Component::getDefaultModelObject).
            filter(modelObject -> modelObject instanceof RealmTO).
            forEachOrdered(modelObject -> realms.add((RealmTO) modelObject));

    return realms;
}
 
Example #19
Source File: MarkupProvider.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
public MarkupProvider()
{
	registerMarkupContent(DropDownChoice.class, "<select wicket:id=\"component\" class=\"custom-select\"></select>");
	registerMarkupContent(ListMultipleChoice.class, "<select wicket:id=\"component\" class=\"form-control\"></select>");
	registerMarkupContent(CheckBox.class, "<input type=\"checkbox\" wicket:id=\"component\"/>");
	registerMarkupContent(TextField.class, "<input type=\"text\" wicket:id=\"component\" class=\"form-control\"/>");
	registerMarkupContent(NumberTextField.class, "<input type=\"number\" wicket:id=\"component\" class=\"form-control\"/>");
	registerMarkupContent(TextArea.class, "<textarea wicket:id=\"component\" class=\"form-control\"></textarea>");
	registerMarkupContent(FormComponentPanel.class, "<div wicket:id=\"component\"></div>");
	registerMarkupContent(Panel.class, "<div wicket:id=\"component\"></div>");
	registerMarkupContent(AbstractLink.class, "<a wicket:id=\"component\"></a>");
	registerMarkupContent(StructureTable.class, "<table wicket:id=\"component\"></table>");
	registerMarkupContent(Select2MultiChoice.class, "<select wicket:id=\"component\" class=\"form-control\"/>");
	registerMarkupContent(Select2Choice.class, "<select wicket:id=\"component\" class=\"form-control\"/>");
}
 
Example #20
Source File: BookmarkablePageLinkCommand.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected AbstractLink newLink(String id) {
	return new BookmarkablePageLink<T>(id, pageClass) {
		@Override
		public PageParameters getPageParameters() {
			return BookmarkablePageLinkCommand.this.getPageParameters();
		}
	};
}
 
Example #21
Source File: TextLinkPanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param id
 * @param link Must have component id {@link #LINK_ID}
 * @param label The link text.
 */
public TextLinkPanel(final String id, final AbstractLink link, final IModel<String> label, final String tooltip)
{
  super(id);
  this.link = link;
  init(id, link, tooltip);
  this.label = new Label("text", label);
  link.add(this.label);
}
 
Example #22
Source File: ActionLinkPanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public ActionLinkPanel(final String id, final ActionLinkType actionLinkType, final String value)
{
  super(id);
  AbstractLink link1;
  if (actionLinkType == ActionLinkType.CALL) {
    add(link1 = getCallLink(value));
    add(getInvisibleSmsLink());
  } else if (actionLinkType == ActionLinkType.SMS) {
    add(new Label("link", "[invisible]").setVisible(false));
    add(getSmsLink(value));
  } else if (actionLinkType == ActionLinkType.CALL_AND_SMS) {
    add(link1 = getCallLink(value));
    add(getSmsLink(value));
  } else if (actionLinkType == ActionLinkType.MAIL) {
    add(link1 = new ExternalLink("link", "mailto:" + value, value));
    add(getInvisibleSmsLink());
  } else {
    final String url;
    if (value != null && value.contains("://") == true) {
      url = value;
    } else {
      url = "http://" + value;
    }
    add(link1 = new ExternalLink("link", url, value));
    link1.add(AttributeModifier.append("target", "_blank"));
    add(getInvisibleSmsLink());
  }
}
 
Example #23
Source File: TextLinkPanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param id
 * @param link Must have component id {@link #LINK_ID}
 * @param label The link text.
 * @param tooltip
 */
public TextLinkPanel(final String id, final AbstractLink link, final String label, final String tooltip)
{
  super(id);
  this.link = link;
  init(id, link, tooltip);
  this.label = new Label("text", label);
  link.add(this.label);
}
 
Example #24
Source File: ContentMenuEntryPanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public ContentMenuEntryPanel(final String id, final AbstractLink link, final String label)
{
  this(id);
  this.link = link;
  labelComponent = new Label("label", label).setRenderBodyOnly(true);
  this.label = label;
}
 
Example #25
Source File: MenuConfigContent.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public MenuConfigContent(final String id, final Menu menu)
{
  super(id);
  final RepeatingView mainMenuRepeater = new RepeatingView("mainMenuItem");
  add(mainMenuRepeater);
  if (menu == null) {
    mainMenuRepeater.setVisible(false);
    log.error("Oups, menu is null. Configuration of favorite menu not possible.");
    return;
  }
  int counter = 0;
  if (menu.getMenuEntries() == null) {
    // Should only occur in maintenance mode!
    return;
  }
  for (final MenuEntry mainMenuEntry : menu.getMenuEntries()) {
    if (mainMenuEntry.hasSubMenuEntries() == false) {
      continue;
    }
    final WebMarkupContainer mainMenuContainer = new WebMarkupContainer(mainMenuRepeater.newChildId());
    mainMenuRepeater.add(mainMenuContainer);
    if (counter++ % 5 == 0) {
      mainMenuContainer.add(AttributeModifier.append("class", "mm_clear"));
    }
    mainMenuContainer.add(new Label("label", new ResourceModel(mainMenuEntry.getI18nKey())));
    final RepeatingView subMenuRepeater = new RepeatingView("menuItem");
    mainMenuContainer.add(subMenuRepeater);
    for (final MenuEntry subMenuEntry : mainMenuEntry.getSubMenuEntries()) {
      final WebMarkupContainer subMenuContainer = new WebMarkupContainer(subMenuRepeater.newChildId());
      subMenuRepeater.add(subMenuContainer);
      final AbstractLink link = NavAbstractPanel.getMenuEntryLink(subMenuEntry, false);
      if (link != null) {
        subMenuContainer.add(link);
      } else {
        subMenuContainer.setVisible(false);
      }
    }
  }
}
 
Example #26
Source File: AbstractImportStoragePanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
protected void addActionLink(final RepeatingView actionLinkRepeater, final AbstractLink link, final String labelText, final String tooltip)
{
  final WebMarkupContainer actionLinkContainer = new WebMarkupContainer(actionLinkRepeater.newChildId());
  actionLinkRepeater.add(actionLinkContainer);
  final Label label = new Label("label", labelText);
  if (tooltip != null) {
    WicketUtils.addTooltip(label, tooltip);
  }
  actionLinkContainer.add(link.add(label));
}
 
Example #27
Source File: MenuPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public LinkFragment(AbstractLink link, String label) {
	super("linkFragment", "LINK_FRAGMENT", MenuPanel.this);

	setRenderBodyOnly(true);
	link.add(new Label(LINK_TEXT_ID, label));
	add(link);
}
 
Example #28
Source File: MenuItem.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public MenuItem(AbstractLink link, String label, String image) {
	if ((link != null) && !link.getId().equals(MenuPanel.LINK_ID)) {
		throw new IllegalArgumentException("The id must be MenuPanel.LINK_ID");
	}

	this.link = link;
	this.label = label;
	this.image = image;
}
 
Example #29
Source File: DeleteActionContributor.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public AbstractLink getLink(ActionContext context) {
    String message;
    if (context.getEntities().size() == 1) {
        message = new StringResourceModel("ActionContributor.Delete.name", null).getString() + " '" + context.getEntity().getName() + "' ?";
    } else {
        message = new StringResourceModel("deleteEntities", null).getString();
    }

    return new DeleteActionLink(context, message);
}
 
Example #30
Source File: DownloadActionContributor.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public AbstractLink getLink(ActionContext context) {
    List<Chart> charts = new ArrayList<Chart>();
    for (Entity entity : context.getEntities()) {
        charts.add((Chart)entity);
    }
    ChartResource download = new ChartResource(charts);
    
    return new ResourceLink<ReportResource>(context.getLinkId(), download);
}