Java Code Examples for org.apache.wicket.behavior.AttributeAppender

The following examples show how to use org.apache.wicket.behavior.AttributeAppender. These examples are extracted from open source projects. 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 Project: onedev   Source File: PasswordPropertyEditor.java    License: MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	input = new PasswordTextField("input", Model.of(getModelObject()));
	input.setRequired(false);
	input.setResetPassword(false);
	input.setLabel(Model.of(getDescriptor().getDisplayName()));
	add(input);

	Password password = getDescriptor().getPropertyGetter().getAnnotation(Password.class);
	String autoComplete = password.autoComplete();
	if (StringUtils.isNotBlank(autoComplete))
		input.add(AttributeAppender.append("autocomplete", autoComplete));
	input.add(new OnTypingDoneBehavior() {

		@Override
		protected void onTypingDone(AjaxRequestTarget target) {
			onPropertyUpdating(target);
		}
		
	});
}
 
Example 2
Source Project: onedev   Source File: WatchStatusLink.java    License: MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	add(AttributeAppender.append("class", new LoadableDetachableModel<String>() {

		@Override
		protected String load() {
			WatchStatus status = getWatchStatus();
			if (status == WatchStatus.DO_NOT_WATCH)
				return "do-not-watch";
			else if (status == WatchStatus.WATCH)
				return "watch";
			else
				return "default";
		}
		
	}));
	
}
 
Example 3
Source Project: onedev   Source File: SideInfoPanel.java    License: MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(newContent("content"));
	add(new AjaxLink<Void>("close") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			String script = String.format("$('#%s').hide('slide', {direction: 'right', duration: 200});", SideInfoPanel.this.getMarkupId());
			target.appendJavaScript(script);
			send(getPage(), Broadcast.BREADTH, new SideInfoClosed(target));
		}
		
	});
	
	add(AttributeAppender.append("class", "side-info closed"));
}
 
Example 4
Source Project: onedev   Source File: PersonIdentPanel.java    License: MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(new UserAvatar("avatar", personIdent).setVisible(mode != Mode.NAME));
	add(new Label("name", personIdent.getName()).setVisible(mode != Mode.AVATAR));
	
	add(AttributeAppender.append("class", "user"));
	
	add(new DropdownHoverBehavior(AlignPlacement.top(8), 350) {

		@Override
		protected Component newContent(String id) {
			return new PersonCardPanel(id, personIdent, gitRole);
		}
		
	});
}
 
Example 5
Source Project: onedev   Source File: SideBar.java    License: MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(newHead("head"));
	add(new Tabbable("tabs", newTabs()));
	add(new WebMarkupContainer("miniToggle").setVisible(miniCookieKey!=null));

	add(AttributeAppender.append("class", "sidebar"));
	
	if (miniCookieKey != null) {
		add(AttributeAppender.append("class", "minimizable"));
		WebRequest request = (WebRequest) RequestCycle.get().getRequest();
		Cookie miniCookie = request.getCookie(miniCookieKey);
		if (miniCookie != null) {
			if ("yes".equals(miniCookie.getValue()))
				add(AttributeAppender.append("class", "minimized"));
		} else if (WicketUtils.isDevice()) {
			add(AttributeAppender.append("class", "minimized"));
		}
	} 
}
 
Example 6
Source Project: onedev   Source File: ModalPanel.java    License: MIT License 6 votes vote down vote up
@Override
protected void onBeforeRender() {
	if (!inited) {
		WebMarkupContainer dialog = new WebMarkupContainer("dialog");
		add(dialog);
		
		dialog.add(newContent(CONTENT_ID));

		String cssClass = getCssClass();
		if (cssClass != null)
			dialog.add(AttributeAppender.append("class", cssClass));
		
		inited = true;
	}
	super.onBeforeRender();
}
 
Example 7
Source Project: onedev   Source File: BlobIcon.java    License: MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(AttributeAppender.append("class", new LoadableDetachableModel<String>() {

		@Override
		protected String load() {
			BlobIdent blobIdent = (BlobIdent) getDefaultModelObject();
			if (blobIdent.isTree())
				return " fa fa-folder-o";
			else if (blobIdent.isGitLink()) 
				return " fa fa-ext fa-folder-submodule-o";
			else if (blobIdent.isSymbolLink()) 
				return " fa fa-ext fa-folder-symbol-link-o";
			else  
				return " fa fa-file-text-o";
		}
		
	}));
}
 
Example 8
Source Project: onedev   Source File: IssueActivitiesPanel.java    License: MIT License 6 votes vote down vote up
@Override
protected void onBeforeRender() {
	activitiesView = new RepeatingView("activities");
	addOrReplace(activitiesView);
	Issue issue = getIssue();

	for (IssueActivity activity: getActivities()) {
		if (issue.isVisitedAfter(activity.getDate())) {
			activitiesView.add(newActivityRow(activitiesView.newChildId(), activity));
		} else {
			Component row = newActivityRow(activitiesView.newChildId(), activity);
			row.add(AttributeAppender.append("class", "new"));
			activitiesView.add(row);
		}
	}		
	
	super.onBeforeRender();
}
 
Example 9
Source Project: sakai   Source File: StudentVisitsWidget.java    License: Educational Community License v2.0 6 votes vote down vote up
private Fragment getLazyLoadedMiniStats(String markupId) {
    Fragment ministatFragment = new Fragment(markupId, "ministatFragment", this);
    int miniStatsCount = widgetMiniStats != null ? widgetMiniStats.size() : 0;
    Loop miniStatsLoop = new Loop("widgetRow", miniStatsCount) {
        private static final long serialVersionUID = 1L;
        @Override
        protected void populateItem(LoopItem item) {
            int index = item.getIndex();
            WidgetMiniStat ms = widgetMiniStats.get(index);

            Label widgetValue = new Label("widgetValue", Model.of(ms.getValue()));
            Label widgetLabel = new Label("widgetLabel", Model.of(ms.getLabel()));
            WebMarkupContainer widgetIcon = new WebMarkupContainer("widgetIcon");
            widgetIcon.add(new AttributeAppender("class", " " + ms.getSecondValue()));

            item.add(widgetValue);
            item.add(widgetLabel);
            item.add(widgetIcon);
        }
    };
    ministatFragment.add(miniStatsLoop);
    return ministatFragment;
}
 
Example 10
Source Project: onedev   Source File: UserPasswordPage.java    License: MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	if (getUser().getPassword().equals(User.EXTERNAL_MANAGED)) {
		String message;
		if (getUser().getSsoInfo().getConnector() != null) {
			message = "The user is currently authenticated via SSO provider '" 
					+ getUser().getSsoInfo().getConnector() 
					+ "', please change password there instead";
		} else {
			message = "The user is currently authenticated via external system, "
					+ "please change password there instead";
		}
		add(new Label("content", message).add(AttributeAppender.append("class", "alert alert-warning")));
	} else {
		add(new PasswordEditPanel("content", userModel));
	}
}
 
Example 11
Source Project: onedev   Source File: UserPage.java    License: MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(new SideBar("userSidebar", null) {

		@Override
		protected Component newHead(String componentId) {
			Fragment fragment = new Fragment(componentId, "sidebarHeadFrag", UserPage.this);
			User user = userModel.getObject();
			fragment.add(new UserAvatar("avatar", user)
					.add(AttributeAppender.append("title", user.getDisplayName())));
			fragment.add(new Label("name", user.getDisplayName()));
			return fragment;
		}
		
		@Override
		protected List<? extends Tab> newTabs() {
			return UserPage.this.newTabs();
		}
		
	});
}
 
Example 12
Source Project: onedev   Source File: MyPasswordPage.java    License: MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	if (getLoginUser().getPassword().equals(User.EXTERNAL_MANAGED)) {
		String message;
		if (getLoginUser().getSsoInfo().getConnector() != null) {
			message = "You are currently authenticated via SSO provider '" 
					+ getLoginUser().getSsoInfo().getConnector() 
					+ "', please change password there instead";
		} else {
			message = "You are currently authenticated via external system, "
					+ "please change password there instead";
		}
		add(new Label("content", message).add(AttributeAppender.append("class", "alert alert-warning")));
	} else {
		add(new PasswordEditPanel("content", new AbstractReadOnlyModel<User>() {

			@Override
			public User getObject() {
				return getLoginUser();
			}
			
		}));
	}
}
 
Example 13
Source Project: webanno   Source File: TextAreaFeatureEditor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected AbstractTextComponent createInputField()
{
    TextArea<String> textarea = new TextArea<>("value");
    textarea.add(new AjaxPreventSubmitBehavior());
    try {
        String traitsString = getModelObject().feature.getTraits();
        StringFeatureTraits traits = 
                JSONUtil.fromJsonString(StringFeatureTraits.class, traitsString);
        textarea.add(new AttributeModifier("rows", traits.getCollapsedRows()));
        textarea.add(new AttributeAppender("onfocus",
                "this.rows=" + traits.getExpandedRows() + ";"));
        textarea.add(new AttributeAppender("onblur",
                "this.rows=" + traits.getCollapsedRows() + ";"));
    }
    catch (IOException e) {
        e.printStackTrace();
    }
    return textarea;
}
 
Example 14
Source Project: webanno   Source File: SidebarPanel.java    License: Apache License 2.0 6 votes vote down vote up
public SidebarPanel(String aId, IModel<AnnotatorState> aModel,
        final AnnotationActionHandler aActionHandler, final CasProvider aCasProvider,
        AnnotationPage aAnnotationPage)
{
    super(aId);

    Validate.notNull(aActionHandler, "Action handler must not be null");
    
    setOutputMarkupId(true);
    setOutputMarkupPlaceholderTag(true);
    
    actionHandler = aActionHandler;
    casProvider = aCasProvider;
    annotationPage = aAnnotationPage;
    stateModel = aModel;
    
    tabsPanel = new SidebarTabbedPanel<>("leftSidebarContent",
            makeTabs());
    add(tabsPanel);
    
    add(new AttributeAppender("class", () -> tabsPanel.isExpanded() ? "" : "collapsed", " "));
}
 
Example 15
Source Project: inception   Source File: ProjectsOverviewPage.java    License: Apache License 2.0 5 votes vote down vote up
private WebMarkupContainer createRoleFilters()
{
    ListView<PermissionLevel> listview = new ListView<PermissionLevel>(MID_ROLE_FILTER,
            asList(PermissionLevel.values()))
    {
        private static final long serialVersionUID = -4762585878276156468L;

        @Override
        protected void populateItem(ListItem<PermissionLevel> aItem)
        {
            PermissionLevel level = aItem.getModelObject();
            LambdaAjaxLink link = new LambdaAjaxLink("roleFilterLink", _target -> 
                    actionApplyRoleFilter(_target, aItem.getModelObject()));
            link.add(new Label(MID_LABEL, getString(
                    Classes.simpleName(level.getDeclaringClass()) + '.' + level.toString())));
            link.add(new AttributeAppender("class", () -> 
                    activeRoleFilters.getObject().contains(aItem.getModelObject())
                    ? "active" : "", " "));
            aItem.add(link);
        }
    };

    WebMarkupContainer container = new WebMarkupContainer("roleFilters");
    container.setOutputMarkupPlaceholderTag(true);
    container.add(listview);

    return container;
}
 
Example 16
Source Project: onedev   Source File: InputAssistBehavior.java    License: MIT License 5 votes vote down vote up
@Override
protected void onBind() {
	super.onBind();
	
	Component input = getComponent();
	input.add(AttributeAppender.append("class", "input-assist"));
	input.setOutputMarkupId(true);
}
 
Example 17
Source Project: onedev   Source File: BeanListPropertyEditor.java    License: MIT License 5 votes vote down vote up
private WebMarkupContainer addRow(Serializable element) {
	WebMarkupContainer row = new WebMarkupContainer(rows.newChildId());
	row.setOutputMarkupId(true);
	rows.add(row);
	
	RepeatingView columns = new RepeatingView("properties");
	row.add(columns);
	
	for (PropertyContext<Serializable> propertyContext: propertyContexts) {
		WebMarkupContainer column = new WebMarkupContainer(columns.newChildId());
		column.add(AttributeAppender.append("class", "property-" + propertyContext.getPropertyName()));
		columns.add(column);
		
		Serializable propertyValue = (Serializable) propertyContext.getPropertyValue(element);
		PropertyEditor<?> propertyEditor = propertyContext.renderForEdit("propertyEditor", Model.of(propertyValue));
		column.add(propertyEditor);
		column.add(new FencedFeedbackPanel("feedback", propertyEditor));
	}
	
	row.add(new AjaxButton("deleteElement") {

		@Override
		protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
			super.onSubmit(target, form);
			markFormDirty(target);
			target.appendJavaScript($(row).chain("remove").get());
			rows.remove(row);
			target.add(noElements);
			onPropertyUpdating(target);
		}

	}.setDefaultFormProcessing(false));
	
	return row;
}
 
Example 18
Source Project: onedev   Source File: ProjectDependencyListViewPanel.java    License: 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 19
Source Project: onedev   Source File: ParamSpecListViewPanel.java    License: 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 20
Source Project: onedev   Source File: JobServiceListViewPanel.java    License: 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 21
Source Project: onedev   Source File: JobReportListViewPanel.java    License: 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 22
Source Project: onedev   Source File: JobDependencyListViewPanel.java    License: 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 23
Source Project: onedev   Source File: JobPrivilegeListViewPanel.java    License: 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 24
Source Project: onedev   Source File: JobTriggerListViewPanel.java    License: 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 25
Source Project: onedev   Source File: ActionListViewPanel.java    License: 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 26
Source Project: onedev   Source File: PropertyViewer.java    License: MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	add(newContent("content", descriptor));
	add(AttributeAppender.append("class", "property-viewer editable"));
}
 
Example 27
Source Project: onedev   Source File: LocatorListViewPanel.java    License: 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 28
Source Project: onedev   Source File: MilestoneStatusLabel.java    License: MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {

		@Override
		public String getObject() {
			return "label label-" + (milestoneModel.getObject().isClosed()? "success": "warning");
		}
		
	}));		
}
 
Example 29
Source Project: onedev   Source File: MilestoneDueLabel.java    License: MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	Milestone milestone = milestoneModel.getObject();
	if (!milestone.isClosed() && milestone.getDueDate().before(new Date())) 
		add(AttributeAppender.append("style", "color: red;"));		
}
 
Example 30
Source Project: onedev   Source File: DropdownLink.java    License: MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	add(AttributeAppender.append("class", "dropdown-link"));
	
	setOutputMarkupId(true);
}