Java Code Examples for org.apache.wicket.ajax.markup.html.AjaxLink#add()

The following examples show how to use org.apache.wicket.ajax.markup.html.AjaxLink#add() . 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: ParamSpecListViewPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	AjaxLink<Void> link = new AjaxLink<Void>("link") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			new SideFloating(target, SideFloating.Placement.RIGHT) {

				@Override
				protected String getTitle() {
					ParamSpec param = paramSpecs.get(index);
					return "Parameter Spec (type: " + EditableUtils.getDisplayName(param.getClass()) + ")";
				}

				@Override
				protected void onInitialize() {
					super.onInitialize();
					add(AttributeAppender.append("class", "param-spec input-spec def-detail"));
				}

				@Override
				protected Component newBody(String id) {
					Set<String> excludedProperties = Sets.newHashSet("canBeChangedBy", "nameOfEmptyValue");
					return BeanContext.view(id, paramSpecs.get(index), excludedProperties, true);
				}

			};
		}
		
	};
	link.add(newLabel("label"));
	add(link);
}
 
Example 2
Source File: InnerReportsPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
private AjaxLink<String> createLink(String id, final IModel<InnerReport> model) {

		AjaxLink<String> link = new AjaxLink<String>(id) {

			@Override
			public void onClick(AjaxRequestTarget target) {								
				click(model.getObject(), target);
			}
		};
		link.add(new Label("label", getString("Section.Audit.innerReports." + model.getObject().toString())));	
		link.add(new Label("description", getString("Section.Audit.innerReports." + model.getObject().getDescription() + ".desc")));
		link.add(AttributeModifier.append("class", "section-" + model.getObject().toString().toLowerCase()));
		return link;
	}
 
Example 3
Source File: ShoppingEditBulkPage.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public LinkPanel(String id, final IModel labelModel) {
	super(id);
	AjaxLink link = new AjaxLink("link") {
		@Override
		public void onClick(AjaxRequestTarget target) {
			clicked(target);
		}
	};
	link.add(new Label("linkLabel", labelModel));
	add(link);
}
 
Example 4
Source File: BaseTreePage.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected AjaxLink getExpandCollapseLink(){
	//Expand Collapse Link:
	final Label expandCollapse = new Label("expandCollapse", new StringResourceModel("exapndNodes", null));
	expandCollapse.setOutputMarkupId(true);
	AjaxLink expandLink  = new AjaxLink("expandAll")
	{
		boolean expand = true;
		@Override
		public void onClick(AjaxRequestTarget target)
		{
			if(expand){
				getTree().getTreeState().expandAll();
				expandCollapse.setDefaultModel(new StringResourceModel("collapseNodes", null));
				collapseEmptyFolders();
			}else{
				getTree().getTreeState().collapseAll();
				expandCollapse.setDefaultModel(new StringResourceModel("exapndNodes", null));
			}
			target.add(expandCollapse);
			getTree().updateTree(target);
			expand = !expand;

		}
		@Override
		public boolean isVisible() {
			return getTree().getDefaultModelObject() != null;
		}
	};
	expandLink.add(expandCollapse);
	return expandLink;
}
 
Example 5
Source File: ButtonFunctionBoxPanel.java    From ontopia with Apache License 2.0 5 votes vote down vote up
protected Component getButton(String id) {

    AjaxLink<Object> button = new AjaxLink<Object>(id) {

      @Override
      protected void onComponentTag(ComponentTag tag) {
        tag.setName("input");
        tag.put("type", "button");
        tag.put("value", getButtonLabel().getObject().toString());
        super.onComponentTag(tag);
      }

      @Override
      public void onClick(AjaxRequestTarget target) {
        ButtonFunctionBoxPanel.this.onClick(target);
      }
    };

    List<IBehavior> behaviors = getButtonBehaviors();
    if (behaviors != null) {
      Iterator<IBehavior> it = behaviors.iterator();
      while (it.hasNext()) {
        button.add(it.next());
      }
    }
    return button;
  }
 
Example 6
Source File: ShoppingEditBulkPage.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public LinkPanel(String id, final IModel labelModel) {
	super(id);
	AjaxLink link = new AjaxLink("link") {
		@Override
		public void onClick(AjaxRequestTarget target) {
			clicked(target);
		}
	};
	link.add(new Label("linkLabel", labelModel));
	add(link);
}
 
Example 7
Source File: BaseTreePage.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected AjaxLink getExpandCollapseLink(){
	//Expand Collapse Link:
	final Label expandCollapse = new Label("expandCollapse", new StringResourceModel("exapndNodes", null));
	expandCollapse.setOutputMarkupId(true);
	AjaxLink expandLink  = new AjaxLink("expandAll")
	{
		boolean expand = true;
		@Override
		public void onClick(AjaxRequestTarget target)
		{
			if(expand){
				getTree().getTreeState().expandAll();
				expandCollapse.setDefaultModel(new StringResourceModel("collapseNodes", null));
				collapseEmptyFolders();
			}else{
				getTree().getTreeState().collapseAll();
				expandCollapse.setDefaultModel(new StringResourceModel("exapndNodes", null));
			}
			target.add(expandCollapse);
			getTree().updateTree(target);
			expand = !expand;

		}
		@Override
		public boolean isVisible() {
			return getTree().getDefaultModelObject() != null;
		}
	};
	expandLink.add(expandCollapse);
	return expandLink;
}
 
Example 8
Source File: AbstractActionItemLink.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
public AbstractActionItemLink(IModel<T> label, IconType iconType){
	AjaxLink<T> link = new AjaxLink<T>("link") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			AbstractActionItemLink.this.onClick(target);
			
		}
	};
	add(link);
	WebMarkupContainer webMarkupContainer = new WebMarkupContainer("icon-type");
	webMarkupContainer.add(new AttributeAppender("class", "glyphicon glyphicon-" + iconType.getCssName()));
	link.add(webMarkupContainer);
}
 
Example 9
Source File: LocatorListViewPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	AjaxLink<Void> link = new AjaxLink<Void>("link") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			new SideFloating(target, Placement.RIGHT) {

				@Override
				protected String getTitle() {
					return "Service Locator";
				}

				@Override
				protected void onInitialize() {
					super.onInitialize();
					add(AttributeAppender.append("class", "locator def-detail"));
				}

				@Override
				protected Component newBody(String id) {
					return BeanContext.view(id, locators.get(index), Sets.newHashSet("job"), true);
				}
					
			};
		}
		
	};
	link.add(newLabel("label"));
	add(link);
}
 
Example 10
Source File: ActionListViewPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	AjaxLink<Void> link = new AjaxLink<Void>("link") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			new SideFloating(target, SideFloating.Placement.RIGHT) {

				@Override
				protected String getTitle() {
					return "Popst Build Action (type: " + EditableUtils.getDisplayName(actions.get(index).getClass()) + ")";
				}

				@Override
				protected void onInitialize() {
					super.onInitialize();
					add(AttributeAppender.append("class", "post-build-action def-detail"));
				}

				@Override
				protected Component newBody(String id) {
					return BeanContext.view(id, actions.get(index));
				}

			};
		}
		
	};
	link.add(newLabel("label"));
	add(link);
}
 
Example 11
Source File: JobTriggerListViewPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	AjaxLink<Void> link = new AjaxLink<Void>("link") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			new SideFloating(target, SideFloating.Placement.RIGHT) {

				@Override
				protected String getTitle() {
					return "Trigger (type: " + EditableUtils.getDisplayName(triggers.get(index).getClass()) + ")";
				}

				@Override
				protected void onInitialize() {
					super.onInitialize();
					add(AttributeAppender.append("class", "job-trigger def-detail"));
				}

				@Override
				protected Component newBody(String id) {
					return BeanContext.view(id, triggers.get(index));
				}

			};
		}
		
	};
	link.add(newLabel("label"));
	add(link);
}
 
Example 12
Source File: JobPrivilegeListViewPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	AjaxLink<Void> link = new AjaxLink<Void>("link") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			new SideFloating(target, Placement.RIGHT) {

				@Override
				protected String getTitle() {
					return "Job Privilege";
				}

				@Override
				protected void onInitialize() {
					super.onInitialize();
					add(AttributeAppender.append("class", "job-privilege def-detail"));
				}

				@Override
				protected Component newBody(String id) {
					return BeanContext.view(id, privileges.get(index));
				}
					
			};
		}
		
	};
	link.add(newLabel("label"));
	add(link);
}
 
Example 13
Source File: JobDependencyListViewPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	AjaxLink<Void> link = new AjaxLink<Void>("link") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			new SideFloating(target, Placement.RIGHT) {

				@Override
				protected String getTitle() {
					return "Job Dependency";
				}

				@Override
				protected void onInitialize() {
					super.onInitialize();
					add(AttributeAppender.append("class", "job-dependency def-detail"));
				}

				@Override
				protected Component newBody(String id) {
					return BeanContext.view(id, dependencies.get(index));
				}
					
			};
		}
		
	};
	link.add(newLabel("label"));
	add(link);
}
 
Example 14
Source File: JobReportListViewPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	AjaxLink<Void> link = new AjaxLink<Void>("link") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			new SideFloating(target, SideFloating.Placement.RIGHT) {

				@Override
				protected String getTitle() {
					JobReport report = reports.get(index);
					return "Report (type: " + EditableUtils.getDisplayName(report.getClass()) + ")";
				}

				@Override
				protected void onInitialize() {
					super.onInitialize();
					add(AttributeAppender.append("class", "job-report def-detail"));
				}

				@Override
				protected Component newBody(String id) {
					return BeanContext.view(id, reports.get(index));
				}

			};
		}
		
	};
	link.add(newLabel("label"));
	add(link);
}
 
Example 15
Source File: JobServiceListViewPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	AjaxLink<Void> link = new AjaxLink<Void>("link") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			new SideFloating(target, Placement.RIGHT) {

				@Override
				protected String getTitle() {
					return "Service";
				}

				@Override
				protected void onInitialize() {
					super.onInitialize();
					add(AttributeAppender.append("class", "job-service def-detail"));
				}

				@Override
				protected Component newBody(String id) {
					return BeanContext.view(id, services.get(index));
				}
					
			};
		}
		
	};
	link.add(newLabel("label"));
	add(link);
}
 
Example 16
Source File: ProjectDependencyListViewPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	AjaxLink<Void> link = new AjaxLink<Void>("link") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			new SideFloating(target, Placement.RIGHT) {

				@Override
				protected String getTitle() {
					return "Project Dependency";
				}

				@Override
				protected void onInitialize() {
					super.onInitialize();
					add(AttributeAppender.append("class", "project-dependency def-detail"));
				}

				@Override
				protected Component newBody(String id) {
					return BeanContext.view(id, dependencies.get(index));
				}
					
			};
		}
		
	};
	link.add(newLabel("label"));
	add(link);
}
 
Example 17
Source File: RevisionSelector.java    From onedev with MIT License 4 votes vote down vote up
private Component newItem(String itemId, String itemValue) {
	String ref;
	if (itemValue.startsWith(COMMIT_FLAG))
		ref = itemValue.substring(COMMIT_FLAG.length());
	else if (itemValue.startsWith(ADD_FLAG))
		ref = itemValue.substring(ADD_FLAG.length());
	else
		ref = itemValue;
	
	AjaxLink<Void> link = new ViewStateAwareAjaxLink<Void>("link") {

		@Override
		protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
			super.updateAjaxAttributes(attributes);
			attributes.getAjaxCallListeners().add(new ConfirmLeaveListener());
		}
		
		@Override
		public void onClick(AjaxRequestTarget target) {
			if (itemValue.startsWith(ADD_FLAG)) {
				onCreateRef(target, ref);
			} else {
				selectRevision(target, ref);
			}
		}

		@Override
		protected void onComponentTag(ComponentTag tag) {
			super.onComponentTag(tag);
			
			if (!itemValue.startsWith(ADD_FLAG)) {
				String url = getRevisionUrl(ref);
				if (url != null)
					tag.put("href", url);
			}
		}
		
	};
	if (itemValue.startsWith(COMMIT_FLAG)) {
		link.add(new Label("label", ref));
		link.add(AttributeAppender.append("class", "icon commit"));
	} else if (itemValue.startsWith(ADD_FLAG)) {
		String label;
		if (branchesActive)
			label = "<div class='name'>Create branch <b>" + HtmlEscape.escapeHtml5(ref) + "</b></div>";
		else
			label = "<div class='name'>Create tag <b>" + HtmlEscape.escapeHtml5(ref) + "</b></div>";
		label += "<div class='revision'>from " + HtmlEscape.escapeHtml5(revision) + "</div>";
		link.add(new Label("label", label).setEscapeModelStrings(false));
		link.add(AttributeAppender.append("class", "icon add"));
	} else if (ref.equals(revision)) {
		link.add(new Label("label", ref));
		link.add(AttributeAppender.append("class", "icon current"));
	} else {
		link.add(new Label("label", ref));
	}
	WebMarkupContainer item = new WebMarkupContainer(itemId);
	item.setOutputMarkupId(true);
	item.add(AttributeAppender.append("data-value", HtmlEscape.escapeHtml5(itemValue)));
	item.add(link);
	
	return item;
}
 
Example 18
Source File: SourceViewPanel.java    From onedev with MIT License 4 votes vote down vote up
private NestedTree<Symbol> newOutlineSearchSymbolTree(ModalPanel modal, List<Symbol> symbols, 
		@Nullable String searchInput) {
	IModel<HashSet<Symbol>> state;
	if (StringUtils.isNotBlank(searchInput)) {
		state = new Model<HashSet<Symbol>>(new HashSet<>(symbols));
	} else {
		state = new Model<HashSet<Symbol>>(new HashSet<>(getChildSymbols(symbols, null)));
	}
	NestedTree<Symbol> tree = new NestedTree<Symbol>("result", newSymbolTreeProvider(symbols), state) {

		@Override
		protected void onInitialize() {
			super.onInitialize();
			add(new HumanTheme());				
		}

		@Override
		protected Component newContentComponent(String id, IModel<Symbol> nodeModel) {
			Symbol symbol = nodeModel.getObject();
			
			Fragment fragment = new Fragment(id, "outlineSearchNodeFrag", SourceViewPanel.this);
			fragment.setOutputMarkupId(true);
			
			AjaxLink<Void> link = new ViewStateAwareAjaxLink<Void>("link") {

				@Override
				public void onClick(AjaxRequestTarget target) {
					modal.close();
					context.onSelect(target, context.getBlobIdent(), SourceRendererProvider.getPosition(symbol.getPosition()));
				}
				
			};
			link.add(symbol.renderIcon("icon"));
			link.add(symbol.render("label", null));
			link.add(AttributeAppender.append("data-symbolindex", symbols.indexOf(symbol)));
			
			fragment.add(link);

			for (Symbol each: symbols) {
				if (each.isDisplayInOutline()) {
					if (symbol == each)
						link.add(AttributeAppender.append("class", "active"));
					break;
				}
			}
			
			return fragment;
		}
		
	};		
	
	tree.setOutputMarkupId(true);
	
	return tree;
}
 
Example 19
Source File: DashboardNavigationPanel.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
private AjaxLink createTitleLink(final Object object, int index) {
  	final String dashboardId = getDashboardId(object);
  	String title = getTitle(object);
  	String owner;
try {
	owner = dashboardService.getDashboardOwner(dashboardId);
} catch (NotFoundException e) {
	// never happening
	throw new RuntimeException(e);
}
      AjaxLink<Void> titleLink = new AjaxLink<Void>("titleLink") {

	private static final long serialVersionUID = 1L;

	@Override
          public void onClick(AjaxRequestTarget target) {
              SectionContext sectionContext = NextServerSession.get().getSectionContext(DashboardSection.ID);
              sectionContext.getData().put(SectionContextConstants.SELECTED_DASHBOARD_ID, dashboardId);
              DashboardBrowserPanel browserPanel = findParent(DashboardBrowserPanel.class);
              target.add(browserPanel);
              // don't work (see decebal's post on wiquery forum)
              /*
              if (isLink(object)) {
              	DashboardPanel dashboardPanel = browserPanel.getDashboardPanel();
              	dashboardPanel.disableSortable(target);
              }
              */
          }

      };

      IModel<String> linkImageModel = new LoadableDetachableModel<String>() {

          private static final long serialVersionUID = 1L;

          @Override
          protected String load() {
              String imagePath = "images/dashboard.png";
              if (isLink(object)) {
                  imagePath = "images/dashboard_link.png";
              }
              
              return imagePath;
          }

      };
      final ContextImage link = new ContextImage("titleImage", linkImageModel);
      titleLink.add(link);

      if (index == 0) {
      	title = getString("dashboard.my");
      }
      titleLink.add(new Label("title", title));
      if (isLink(object)) {
          titleLink.add(new SimpleTooltipBehavior(getString("DashboardNavigationPanel.owner") + ": " + owner));
      } 
      return titleLink;
  }
 
Example 20
Source File: AnalysisNavigationPanel.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
private AjaxLink createTitleLink(final Object analysis, int index) {

		String title = getTitle(analysis);

		AjaxLink<Void> titleLink = new AjaxLink<Void>("titleLink") {

			private static final long serialVersionUID = 1L;

			@Override
			public void onClick(AjaxRequestTarget target) {
				 SectionContext sectionContext =  NextServerSession.get().getSectionContext(AnalysisSection.ID);
				 sectionContext.getData().put(SectionContextConstants.SELECTED_ANALYSIS_ID, getAnalysisId(analysis));
				 AnalysisBrowserPanel browserPanel = findParent(AnalysisBrowserPanel.class);
				 Analysis a = null;
				 if (isLink(analysis)) {
					 try {
						a = (Analysis)storageService.getEntityById(getAnalysisId(analysis));
					} catch (NotFoundException e) {					
						e.printStackTrace();
						LOG.error(e.getMessage(),e);
					}
				 } else {
					 a = (Analysis)analysis;
				 }
				 browserPanel.getAnalysisPanel().changeDataProvider(new Model<Analysis>(a), target);
				 target.add(browserPanel);

			}

		};

		IModel<String> linkImageModel = new LoadableDetachableModel<String>() {

			private static final long serialVersionUID = 1L;

			@Override
			protected String load() {
				String imagePath = "images/analysis.png";
				if (isLink(analysis)) {					
                    imagePath = "images/analysis_link.png";
                } else if (((Analysis)analysis).isFreezed()) {
                	imagePath = "images/analysis_freeze.png";
                }
				return imagePath;
			}

		};
		final ContextImage link = new ContextImage("titleImage", linkImageModel);
		titleLink.add(link);

		titleLink.add(new Label("title", title));
		titleLink.add(new SimpleTooltipBehavior(getTitle(analysis)));
		return titleLink;
	}