Java Code Examples for org.apache.wicket.AttributeModifier

The following are top voted examples for showing how to use org.apache.wicket.AttributeModifier. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: sakai   File: CSSFeedbackPanel.java   Source Code and License 7 votes vote down vote up
public CSSFeedbackPanel(String id) {
	super(id);
	WebMarkupContainer feedbackul = (WebMarkupContainer) get("feedbackul");
	if(feedbackul != null){
		feedbackul.add(new AttributeModifier("class", true, new Model() {
			private static final long	serialVersionUID	= 1L;
			public Serializable getObject() {
				if(anyErrorMessage()){
					return "alertMessage";
				}else if(anyMessage()){
					return "success";
				}else{
					return "";
				}
			}
		}));
		feedbackul.add(new AttributeModifier("style", true, new Model("list-style-type:none")));
	}
}
 
Example 2
Project: karate   File: VarsRefreshingView.java   Source Code and License 6 votes vote down vote up
@Override
protected void populateItem(Item<Var> item) {
    String name = item.getModel().getObject().getName();
    item.add(new AjaxLink("show") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            selectedName = name;
            Component headerPanel = getPage().get(BasePage.STICKY_HEADER_ID);
            VarModel varModel = new VarModel(model.getSessionId(), name);
            VarPanel varPanel = new VarPanel(BasePage.STICKY_HEADER_ID, varModel, VarsRefreshingView.this);                
            headerPanel = headerPanel.replaceWith(varPanel);
            target.add(headerPanel);
            Component varsPanel = getPage().get(BasePage.LEFT_NAV_ID);
            target.add(varsPanel);
        }
    }.add(new Label("name", name)));
    String type = item.getModel().getObject().getValue().getTypeAsShortString();
    item.add(new Label("type", type));
    if (name.equals(selectedName)) {
        item.add(new AttributeModifier("class", "success"));
    }
}
 
Example 3
Project: MasterStats   File: BasePage.java   Source Code and License 6 votes vote down vote up
/**
 * generates the navbar and mark the active page
 *
 * @param activePage page to be marked active (null for no active page)
 */
private void loadNavbar(final PageType activePage) {
    // add an entry for each page type
    add(new ListView<PageType>("navbar_left_elements", Arrays.asList(PageType.values())) {
        @Override
        protected void populateItem(final ListItem<PageType> item) {
            final PageType type = item.getModelObject();
            // create a link for the page type
            BookmarkablePageLink<String> link = new BookmarkablePageLink<>("navbar_left_element_link", type.getPageClass());
            link.add(new Label("navbar_left_element_text", type.getLinkText()));
            // if the type is same as active page, mark it as active
            if (type.equals(activePage)) link.add(new AttributeAppender("class", "active", " "));
            item.add(link);
        }
    });

    // create the summoner search region drop down menu
    // get all valid entries
    List<String> endpoints = Arrays.asList(RiotEndpoint.PLAYABLE_ENDPOINTS)
            .stream().map(RiotEndpoint::name).collect(Collectors.toList());
    // add the options to the drop down menu
    DropDownChoice<String> dropDownChoice = new DropDownChoice<>("navbar_form_regions_select",
            new PropertyModel<>(this, "selectedRegion"), endpoints, new StringChoiceRenderer());
    dropDownChoice.add(new AttributeModifier("name", "region"));
    add(dropDownChoice);
}
 
Example 4
Project: engerek   File: TooltipBehavior.java   Source Code and License 6 votes vote down vote up
@Override
public void onConfigure(final Component component) {
    component.setOutputMarkupId(true);

    component.add(AttributeModifier.replace("data-toggle", "tooltip"));
    component.add(new AttributeModifier("data-placement", getDataPlacement()) {

        @Override
        protected String newValue(String currentValue, String replacementValue) {
            if (StringUtils.isEmpty(currentValue)) {
                return replacementValue;
            }
            return currentValue;
        }
    });
}
 
Example 5
Project: engerek   File: AssignmentTablePanel.java   Source Code and License 6 votes vote down vote up
protected AttributeModifier getClassModifier(ListItem<AssignmentEditorDto> item){
	return AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {
		private static final long serialVersionUID = 1L;

		@Override
		public String getObject() {
			AssignmentEditorDto dto = item.getModel().getObject();
			ObjectReferenceType targetRef = dto.getTargetRef();
			if (targetRef != null && targetRef.getType() != null) {
				return WebComponentUtil.getBoxThinCssClasses(targetRef.getType());
			} else {
				return GuiStyleConstants.CLASS_OBJECT_RESOURCE_BOX_THIN_CSS_CLASSES;
			}
		}
	});
}
 
Example 6
Project: engerek   File: AssignmentEditorPanel.java   Source Code and License 6 votes vote down vote up
protected void initLayout() {
	setOutputMarkupId(true);
	headerRow = new WebMarkupContainer(ID_HEADER_ROW);
	headerRow.add(AttributeModifier.append("class", createHeaderClassModel(getModel())));
	headerRow.setOutputMarkupId(true);
	add(headerRow);

	initHeaderRow();

	WebMarkupContainer body = new WebMarkupContainer(ID_BODY);
	body.setOutputMarkupId(true);
	body.add(new VisibleEnableBehaviour() {

		@Override
		public boolean isVisible() {
			AssignmentEditorDto editorDto = AssignmentEditorPanel.this.getModel().getObject();
			return !editorDto.isMinimized();
		}
	});
	add(body);

	initBodyLayout(body);
}
 
Example 7
Project: engerek   File: LinkIconPanel.java   Source Code and License 6 votes vote down vote up
private void initLayout(IModel<String> model, IModel<String> titleModel) {
    AjaxLink link = new AjaxLink(ID_LINK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onClickPerformed(target);
        }
    };

    Label image = new Label(ID_IMAGE);
    image.add(AttributeModifier.replace("class", model));
    if (titleModel != null) {
        image.add(AttributeModifier.replace("title", titleModel));
    }
    link.add(image);
    link.setOutputMarkupId(true);
    add(link);
}
 
Example 8
Project: engerek   File: PrismContainerPanel.java   Source Code and License 6 votes vote down vote up
private void addOrReplaceProperties(IModel<ContainerWrapper> model, final Form form, boolean isToBeReplaced){
     ListView<ItemWrapper> properties = new ListView<ItemWrapper>("properties",
             new PropertyModel(model, "properties")) {
private static final long serialVersionUID = 1L;

@Override
         protected void populateItem(final ListItem<ItemWrapper> item) {
             item.add(new PrismPropertyPanel("property", item.getModel(), form, pageBase));
             item.add(new VisibleEnableBehaviour() {
             	private static final long serialVersionUID = 1L;
             	
             	@Override
             	public boolean isVisible() {
             		return item.getModel().getObject().isVisible();
             	}
             });
             item.add(AttributeModifier.append("class", createStyleClassModel(item.getModel())));
         }
     };
     properties.setReuseItems(true);
     if (isToBeReplaced) {
         replace(properties);
     } else {
         add(properties);
     }
 }
 
Example 9
Project: engerek   File: TextPopupPanel.java   Source Code and License 6 votes vote down vote up
private void initLayout() {
    final TextField input = initTextField();

    input.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            //nothing to do, just update model data
        }
    });
    input.add(new Behavior() {

        @Override
        public void bind(Component component) {
            super.bind(component);

            component.add(AttributeModifier.replace("onkeydown",
                    Model.of("if(event.keyCode == 13) {event.preventDefault();}")));
        }
    });
    input.setOutputMarkupId(true);
    add(input);
}
 
Example 10
Project: engerek   File: TextDetailsPanel.java   Source Code and License 6 votes vote down vote up
public TextDetailsPanel(String id, IModel<T> model, Class clazz){
    super(id);

    final TextField<T> text = new TextField<>(ID_INPUT, model);
    text.setType(clazz);
    add(text);

    Label details = new Label(ID_DETAILS);
    details.add(AttributeModifier.replace("title", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return createAssociationTooltip();
        }
    }));
    details.add(new InfoTooltipBehavior(){

        @Override
        public String getDataPlacement(){
            return "bottom";
        }
    });
    add(details);
}
 
Example 11
Project: engerek   File: AsyncDashboardPanel.java   Source Code and License 6 votes vote down vote up
public AsyncDashboardPanel(String id, IModel<String> title, String icon, IModel<V> callableParameterModel,
                           Duration durationSecs, String boxCssClasses, boolean noPadding) {
    super(id, callableParameterModel, durationSecs);
    
    initLayout(noPadding);

    WebMarkupContainer dashboardTitle = (WebMarkupContainer) get(
            createComponentPath(ID_DASHBOARD_PARENT, ID_DASHBOARD_TITLE));

    Label label = (Label) dashboardTitle.get(ID_TITLE);
    label.setDefaultModel(title);

    if (boxCssClasses == null) {
    	boxCssClasses = GuiStyleConstants.CLASS_BOX_DEFAULT;
    }
    Component dashboardParent = get(ID_DASHBOARD_PARENT);
    dashboardParent.add(new AttributeAppender("class", " " + boxCssClasses));

    WebMarkupContainer iconI = new WebMarkupContainer(ID_ICON);
    iconI.add(AttributeModifier.replace("class", icon));
    dashboardTitle.add(iconI);
}
 
Example 12
Project: engerek   File: DashboardPanel.java   Source Code and License 6 votes vote down vote up
private void initLayout(IModel<String> titleModel, String icon, String boxCssClasses) {
	if (boxCssClasses == null) {
    	boxCssClasses = GuiStyleConstants.CLASS_BOX_DEFAULT;
    }
	
    WebMarkupContainer dashboardParent = new WebMarkupContainer(ID_DASHBOARD_PARENT);
    dashboardParent.add(new AttributeAppender("class", " " + boxCssClasses));
    add(dashboardParent);

    WebMarkupContainer dashboardTitle = new WebMarkupContainer(ID_DASHBOARD_TITLE);
    dashboardParent.add(dashboardTitle);
    Label title = new Label(ID_TITLE);
    title.setRenderBodyOnly(true);
    title.setDefaultModel(titleModel);
    dashboardTitle.add(title);

    WebMarkupContainer dashboardContent = new WebMarkupContainer(ID_DASHBOARD_CONTENT);
    dashboardContent.add(getMainComponent(ID_CONTENT));
    dashboardParent.add(dashboardContent);
    
    WebMarkupContainer iconI = new WebMarkupContainer(ID_ICON);
    iconI.add(AttributeModifier.replace("class", icon));
    dashboardTitle.add(iconI);
}
 
Example 13
Project: engerek   File: CapabilitiesPanel.java   Source Code and License 6 votes vote down vote up
private void createCapabilityButton(String id) {
	AjaxLink<Boolean> button = new AjaxLink<Boolean>(id, new PropertyModel<Boolean>(getModel(), id)) {

		@Override
		public void onClick(AjaxRequestTarget target) {
			// TODO:
		}

	};

	button.add(new AttributeModifier("class",
			button.getModelObject() ? "btn btn-app btn-resource-capability bg-light-blue"
					: "btn btn-app btn-resource-capability bg-gray text-light-blue"));

	button.add(new Label("label", new ResourceModel("CapabilitiesType." + id)));

	add(button);
}
 
Example 14
Project: engerek   File: PageSelfRegistration.java   Source Code and License 6 votes vote down vote up
private void createPasswordPanel(WebMarkupContainer staticRegistrationForm) {
	// ProtectedStringType initialPassword = null;
	PasswordPanel password = new PasswordPanel(ID_PASSWORD,
			new PropertyModel<ProtectedStringType>(userModel, "credentials.password.value"), false, true);
	password.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
	password.getBaseFormComponent().setRequired(true);
	staticRegistrationForm.add(password);

	Label help = new Label(ID_TOOLTIP);
	final StringResourceModel tooltipText = createStringResource("PageSelfRegistration.password.policy");
	help.add(AttributeModifier.replace("title", tooltipText));
	help.add(new InfoTooltipBehavior());
	help.add(new VisibleEnableBehaviour() {
		private static final long serialVersionUID = 1L;

		@Override
		public boolean isVisible() {

			return StringUtils.isNotEmpty(tooltipText.getObject());
		}
	});
	staticRegistrationForm.add(help);
}
 
Example 15
Project: vlo-curation   File: AvailabilityFacetPanel.java   Source Code and License 6 votes vote down vote up
@Override
protected void populateItem(Item<Count> item) {
    //model for actual value
    final PropertyModel<String> valueModel = new PropertyModel<>(item.getModel(), "name");

    //checkbox
    final Component selector = createValueCheckbox("selector", valueModel.getObject());
    item.add(selector);

    //label
    item.add(new WebMarkupContainer("label")
            //child label
            .add(new FieldValueLabel("name", valueModel, fieldNameModel))
            //count label
            .add(new Label("count", new PropertyModel<String>(item.getModel(), "count")))
            //reference to checkbox
            .add(new AttributeModifier("for", selector.getMarkupId()))
            .add(new AttributeAppender("class", valueModel, " "))
    );

    //description as tooltip (title)
    final IModel<FieldValueDescriptor> descriptorModel = new MapValueModel<>(descriptorsModel, valueModel);
    final IModel<String> descriptionModel = new PropertyModel<>(descriptorModel, "description");
    item.add(new AttributeModifier("title", descriptionModel));
}
 
Example 16
Project: vlo-curation   File: ContentSearchFormPanel.java   Source Code and License 6 votes vote down vote up
public ContentSearchFormPanel(String id, final IModel<SolrDocument> documentModel, final IModel<String> endpointModel) {
    super(id);

    // Create a model that returns a JSON representation of the endpoint and document id
    final IModel<String> jsonModel = createJsonModel(documentModel, endpointModel);
    setModel(jsonModel);

    // Populate attributes in form elements...
    // Outer <form> element
    final WebMarkupContainer fcsForm = new WebMarkupContainer("fcsForm");
    // The action of the form should be the aggregator endpoint
    fcsForm.add(new AttributeModifier("action", vloConfig.getFederatedContentSearchUrl()));
    add(fcsForm);

    // Hidden form field for aggregation context
    final WebMarkupContainer aggregationContext = new WebMarkupContainer("aggregationContent");
    // The value should be the JSON object
    aggregationContext.add(new AttributeModifier("value", jsonModel));
    fcsForm.add(aggregationContext);
}
 
Example 17
Project: vlo-curation   File: BootstrapDropdown.java   Source Code and License 6 votes vote down vote up
protected Component createMenu(String id) {
    final WebMarkupContainer menu = new WebMarkupContainer(id);
    menu.add(new ListView<DropdownMenuItem>("menuItem", getModel()) {
        @Override
        protected void populateItem(ListItem<DropdownMenuItem> item) {
            final DropdownMenuItem itemObject = item.getModelObject();
            //link that forms the menu item's action
            item.add(itemObject.getLink("link")
                    //link label defined by the menu item object
                    .add(new Label("label", itemObject.getLabel()))
                    //icon with icon class defined by the menu item object
                    .add(new WebMarkupContainer("icon")
                            .add(new AttributeModifier("class", itemObject.getIconClass())))
            );
        }
    });
    return menu;
}
 
Example 18
Project: superfly   File: LabelPasswordTextFieldRow.java   Source Code and License 6 votes vote down vote up
public LabelPasswordTextFieldRow(String aId, IModel<String> aModel, String aResourceKey, boolean aRequired) {
    super(aId);

    // row
    WebMarkupContainer row = new WebMarkupContainer("row");
    row.add(new AttributeAppender("class", new Model<String>(aRequired ? "required" : ""), " "));
    add(row);

    // label
    Label label = new Label("label-id", new ResourceModel(aResourceKey));
    label.add(new AttributeModifier("for", new Model<String>(aId)));
    row.add(label);

    // field
    row.add(passwordTextField = new LabeledRequiredTextField("field-id", aModel, aId, aResourceKey, aRequired));
}
 
Example 19
Project: owsi-core-parent   File: CoreLabelColumn.java   Source Code and License 6 votes vote down vote up
private CoreLabel decorate(CoreLabel label, IModel<T> rowModel) {
	if (multiline) {
		label.multiline();
	}
	if (showPlaceholder) {
		if (placeholderModel != null) {
			label.showPlaceholder(placeholderModel);
		} else {
			label.showPlaceholder();
		}
	}
	if (tooltipRenderer != null) {
		label.add(new AttributeModifier("title", tooltipRenderer.asModel(rowModel)));
	}
	return label;
}
 
Example 20
Project: sakai   File: SortGradeItemsByGradeItemPanel.java   Source Code and License 6 votes vote down vote up
@Override
public void onInitialize() {
	super.onInitialize();

	final List<Assignment> assignments = this.businessService.getGradebookAssignments(SortType.SORT_BY_SORTING);

	add(new ListView<Assignment>("gradeItemList", assignments) {
		@Override
		protected void populateItem(final ListItem<Assignment> assignmentItem) {
			final Assignment assignment = assignmentItem.getModelObject();
			assignmentItem.add(new Label("name", assignment.getName()));
			assignmentItem.add(new HiddenField<Long>("id",
					Model.of(assignment.getId())).add(
							new AttributeModifier("name",
									String.format("id", assignment.getId()))));
			assignmentItem.add(new HiddenField<Integer>("order",
					Model.of(assignment.getSortOrder())).add(
							new AttributeModifier("name",
									String.format("item_%s[order]", assignment.getId()))));
			assignmentItem.add(new HiddenField<Integer>("current_order",
					Model.of(assignment.getSortOrder())).add(
							new AttributeModifier("name",
									String.format("item_%s[current_order]", assignment.getId()))));
		}
	});
}
 
Example 21
Project: owsi-core-parent   File: HideablePagingNavigator.java   Source Code and License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	// Get the navigation bar and add it to the hierarchy
	pagingNavigation = newNavigation("navigation", pageable, labelProvider);
	pagingNavigation.setViewSize(viewSize);
	add(pagingNavigation);
	
	// Add additional page links
	first = newPagingNavigationLink("first", pageable, 0);
	first.add(new AttributeModifier("title", new ResourceModel("PagingNavigator.first")));
	add(first);
	last = newPagingNavigationLink("last", pageable, -1);
	last.add(new AttributeModifier("title", new ResourceModel("PagingNavigator.last")));
	add(last);
}
 
Example 22
Project: owsi-core-parent   File: GenericSelect2DropDownMultipleChoice.java   Source Code and License 6 votes vote down vote up
@Override
protected void onInitialize() {
	ensureChoicesModelIsWrapped();
	
	super.onInitialize();
	
	add(new AttributeModifier("style", new LoadableDetachableModel<String>() {
		private static final long serialVersionUID = 1L;
		
		@Override
		protected String load() {
			return "width: " + width.getWidth();
		}
	}) {
		private static final long serialVersionUID = 1L;

		@Override
		public boolean isEnabled(Component component) {
			return width != null;
		}
	});
}
 
Example 23
Project: owsi-core-parent   File: GenericSelect2DropDownSingleChoice.java   Source Code and License 6 votes vote down vote up
@Override
protected void onInitialize() {
	ensureChoicesModelIsWrapped();
	
	super.onInitialize();
	
	add(new AttributeModifier("style", new LoadableDetachableModel<String>() {
		private static final long serialVersionUID = 1L;
		
		@Override
		protected String load() {
			return "width: " + width.getWidth();
		}
	}) {
		private static final long serialVersionUID = 1L;

		@Override
		public boolean isEnabled(Component component) {
			return width != null;
		}
	});
}
 
Example 24
Project: u-qasar.platform   File: UserListPage.java   Source Code and License 6 votes vote down vote up
private Icon getRegistrationStatusIcon(final User user) {
	final RegistrationStatus status = user.getRegistrationStatus();
	String typeString;
	switch (status) {
		case CANCELLED:
			typeString = "ban-circle";
			break;
		case PENDING:
			typeString = "time";
			break;
		default:
			typeString = "check-sign";
	}
	IconType type = new IconType(typeString);
	Icon icon = new Icon("td.status", type);
	icon.add(new AttributeModifier("title", Model.of(user.getRegistrationStatus())));
	return icon;
}
 
Example 25
Project: sakai   File: AjaxLazyLoadImage.java   Source Code and License 6 votes vote down vote up
public Image renderImage(AjaxRequestTarget target, boolean fullRender) {
	if(returnPage != null || returnClass != null) {
		link.add(new AttributeModifier("title", new ResourceModel("click_to_max")));
		link.setEnabled(true);
	}
	link.removeAll();
	Image img = null;
	if(!autoDetermineChartSizeByAjax) {
		img = createImage("content", getImageData());
	}else{
		img = createImage("content", getImageData(selectedWidth, selectedHeight));
	}
	img.add(AttributeModifier.replace("style", "display: none; margin: 0 auto;"));
	link.add(img);
	setState((byte) 1);
	if(fullRender) {
		if(target != null) {
			target.add(link);	
			target.appendJavaScript("jQuery('#"+img.getMarkupId()+"').fadeIn();");
		}		
		setState((byte) 2);
	}
	return img;
}
 
Example 26
Project: ManagedProperties   File: NumberFieldFragment.java   Source Code and License 6 votes vote down vote up
@Override
protected Component getFormInput(String wicketID, IModel<Number> model) {
    NumberTextField field = new NumberTextField(wicketID, model);
    Class attributeInputType = getAttribute().getInputType();
    if (attributeInputType == Float.class || attributeInputType == Double.class) {
        formInput.add(AttributeModifier.replace("step", new LoadableDetachableModel<String>() {
            @Override
            protected String load() {
                return "0.0001";
            }

        }));
    }
    
    return field;
}
 
Example 27
Project: openmeetings   File: MessagesContactsPanel.java   Source Code and License 6 votes vote down vote up
private void selectFolder(WebMarkupContainer folder, Long id, AjaxRequestTarget target) {
	selectedFolder = folder;
	selectedFolderModel.setObject(id);
	setDefaultFolderClass();
	selectFolder(folder);
	emptySelection(target);
	selectDropDown.setModelObject(SELECT_CHOOSE);
	moveDropDown.setModelObject(NOT_MOVE_FOLDER);
	deleteBtn.add(AttributeModifier.replace("value", Application.getString(TRASH_FOLDER_ID.equals(id) ? "1256" : "80")));
	readBtn.setEnabled(false);
	unreadBtn.setEnabled(false);
	if (target != null) {
		updateTable(target);
		target.add(folders, unread, selectDropDown, moveDropDown);
		target.add(dataContainer.getContainer(), dataContainer.getNavigator());
		target.add(dataContainer.getLinks());
	}
}
 
Example 28
Project: openmeetings   File: ClientIcon.java   Source Code and License 6 votes vote down vote up
public final void update(IPartialPageRequestHandler handler) {
	cssClass.setLength(0);
	StringBuilder cls = new StringBuilder(ICON_CLASS);
	cls.append(getAlign()).append(mainCssClass);
	if (isClickable()) {
		//request/remove
		cls.append(CLS_CLICKABLE);
		add(addOnClick(getScript()));
	} else {
		add(addOnClick(""));
	}
	internalUpdate();
	add(AttributeModifier.replace(ATTR_TITLE, getTitle()));
	add(AttributeModifier.replace(ATTR_CLASS, cls.append(cssClass)));
	if (handler != null) {
		handler.add(this);
	}
}
 
Example 29
Project: openmeetings   File: RoomClientPanel.java   Source Code and License 6 votes vote down vote up
public RoomClientPanel(String id, ListItem<Client> item, final RoomPanel room) {
	super(id, item.getModel());
	setRenderBodyOnly(true);
	Client c = item.getModelObject();
	final String uid = c.getUid();
	item.setMarkupId(String.format("user%s", c.getUid()));
	item.add(AttributeModifier.append("style", String.format("background-image: url(profile/%s);", c.getUserId())));
	item.add(AttributeModifier.append("data-userid", c.getUserId()));
	add(new RefreshIcon("refresh", uid, room));
	final String name = getName(c);
	add(new Label("name", name));
	add(new UserSpeaksIcon("user-speaks", uid, room));
	item.add(AttributeModifier.replace(ATTR_TITLE, name));
	WebMarkupContainer actions = new WebMarkupContainer("actions");
	actions.add(new KickIcon("kick", uid, room));
	actions.add(new WebMarkupContainer("privateChat").setVisible(!room.getRoom().isHidden(RoomElement.Chat) && !getUserId().equals(c.getUserId())));
	actions.setVisible(room.getClient().hasRight(Right.moderator));
	if (c.getUid().equals(room.getClient().getUid())) {
		actions.add(new SelfIconsPanel("icons", uid, room, false));
		item.add(AttributeModifier.append(ATTR_CLASS, "current"));
	} else {
		actions.add(new ClientIconsPanel("icons", uid, room));
	}
	add(actions);
}
 
Example 30
Project: sakai   File: FeedbackLabel.java   Source Code and License 6 votes vote down vote up
/**
 * Set the content of this FeedbackLabel, depending on if the component has a FeedbackMessage.
 *
 * The HTML class attribute will be filled with the error level of the feedback message. That way, you can easily
 * style different messages differently. Examples:
 *
 * class = "feedbacklabel INFO"
 * class = "feedbacklabel ERROR"
 * class = "feedbacklabel DEBUG"
 * class = "feedbacklabel FATAL"
 *
 *
 * @see Component
 */
@Override
protected void onBeforeRender() {
    super.onBeforeRender();
    this.setDefaultModel(null);

    if(component.hasFeedbackMessage()){
        if(this.text!=null){
            this.setDefaultModel(text);
        } else {
            this.setDefaultModel(new Model(component.getFeedbackMessages().first()));
        }

        this.add(new AttributeModifier("class", true, new Model("feedbackLabel " + component.getFeedbackMessages().first().getLevelAsString())));
    } else {
        this.setDefaultModel(null);
    }
  
}
 
Example 31
Project: u-qasar.platform   File: LinkableUserBadge.java   Source Code and License 6 votes vote down vote up
public LinkableUserBadge(String id, IModel<User> model) {
	super(id, model);
	Validate.notNull(model);
	Validate.notNull(model.getObject());
	user = model.getObject();

	BookmarkablePageLink<UserPage> container = new BookmarkablePageLink<>(
			"profile.link", UserPage.class, UserPage.forUser(user));
	container.add(userName = new Label("userName",
			new PropertyModel<String>(model, "userName")));

	WebMarkupContainer picture = new WebMarkupContainer("picture");
	picture.add(new UserProfilePictureBackgroundBehaviour(user, User.PictureDimensions.Badge));
	container.add(picture);
	container.add(new AttributeModifier("title", user.getFullName()));
	add(container);
}
 
Example 32
Project: invesdwin-nowicket   File: AWebPage.java   Source Code and License 6 votes vote down vote up
protected Navbar newNavbar(final String id) {
    final Navbar navbar = new Navbar(id) {

        @Override
        protected TransparentWebMarkupContainer newContainer(final String componentId) {
            final TransparentWebMarkupContainer container = super.newCollapseContainer(componentId);
            container.add(AttributeModifier.replace("class", getContainerClass()));
            return container;
        }

        @Override
        protected Class<? extends Page> getHomePage() {
            return getNavbarHomePage();
        }

    };
    navbar.setBrandName(Model.of("invesdwin-NoWicket"));
    navbar.setBrandImage(DEFAULT_LOGO, Model.of("logo"));

    addSignInOrSignOutPageToNavbar(navbar);

    return navbar;
}
 
Example 33
Project: invesdwin-nowicket   File: GridColumnBorder.java   Source Code and License 6 votes vote down vote up
public GridColumnBorder(final GridColumnHtmlElement element) {
    super(element.getWicketId());
    this.element = element;

    final AttributeModifier hasError = AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {
        @Override
        public String getObject() {
            final Component component = element.getContext()
                    .getComponentRegistry()
                    .getComponent(element.getModelWicketId());
            final FormComponent<?> formComponent = Components.asFormComponent(component);
            if (formComponent != null) {
                if (!formComponent.isValid()) {
                    return "has-error";
                }
            }
            return null;
        }
    });
    add(hasError);
    this.help = new Label("help", Model.of()); //needs to escape markup or modals do not close
    help.setEscapeModelStrings(false);
    addToBorder(help);
}
 
Example 34
Project: invesdwin-nowicket   File: ModalContainer.java   Source Code and License 6 votes vote down vote up
public ModalContainer(final String id) {
    super(id);
    modalContent = new WebMarkupContainer("modalContent");
    modalContent.setOutputMarkupId(true);
    add(modalContent);
    /*
     * initialially put empty panel, later keep the ones as invisible that have been replaced to be able to show
     * replaced stacked modals properly
     */
    modalContent.add(new WebMarkupContainer(PANEL_MARKUP_ID));
    titleLabel = new Label("title");
    titleLabel.setEscapeModelStrings(false);
    modalContent.add(titleLabel);
    setOutputMarkupId(true);
    add(new CssClassNameAppender("modal"));
    add(new CssClassNameAppender("fade"));
    add(new AttributeModifier("data-keyboard", "false"));
    add(new AttributeModifier("data-backdrop", "static"));
}
 
Example 35
Project: webanno   File: FinishImage.java   Source Code and License 6 votes vote down vote up
public FinishImage(String id, final IModel<AnnotatorState> aModel)
{
    super(id, aModel);

    add(new AttributeModifier("src", LambdaModel.of(() -> {
        if (aModel.getObject().getProject() != null
                && aModel.getObject().getDocument() != null) {
            if (isFinished(aModel, aModel.getObject().getUser(), documentService)) {
                return "images/accept.png";
            }
            else {
                return "images/inprogress.png";
            }
        }
        else {
            return "images/inprogress.png";
        }
    })));
}
 
Example 36
Project: sakai   File: FileSelectorPanel.java   Source Code and License 6 votes vote down vote up
public FileSelectorPanel(String id, String siteId, IModel model, boolean showDefaultBaseFoldersOnly) {
	super(id, model);
	this.siteId = siteId;
	this.showDefaultBaseFoldersOnly = showDefaultBaseFoldersOnly;
	
	// selected files
	HiddenField selectedFiles = new HiddenField("selectedFiles", new PropertyModel(this, "selectedFiles"));
	add(selectedFiles);
	
	// hover div (for disabling control)
	WebMarkupContainer containerHover = new WebMarkupContainer("containerHover");
	if(isEnabled()) {
		containerHover.add(new AttributeModifier("style", new Model("display: block")));
	}else{
		containerHover.add(new AttributeModifier("style", new Model("display: none")));
	}
	add(containerHover);
	
	add(ajaxResourcesLoader);
}
 
Example 37
Project: elpaaso-core   File: ApplicationVisibilityPanel.java   Source Code and License 6 votes vote down vote up
private void initComponent() {
    WebMarkupContainer applicationPublicSpan = new WebMarkupContainer(APP_VISIBILITY_PUBLIC);
    WebMarkupContainer applicationPrivateSpan = new WebMarkupContainer(APP_VISIBILITY_PRIVATE);
    Joiner joiner = Joiner.on(", ");
    String members = joiner.join(getModelObject().listMembers());
    applicationPublicSpan.add(AttributeModifier.replace("title", new ResourceModel("portal.application.members.label").getObject() + " : " + members));
    applicationPrivateSpan.add(AttributeModifier.replace("title", new ResourceModel("portal.application.members.label").getObject() + " : " + members));
    add(applicationPublicSpan);
    applicationPublicSpan.add(new CacheActivatedImage("applicationVisibilityPanelPublicImage",new ResourceModel("visibility-public").getObject()));
    add(applicationPrivateSpan);
    applicationPrivateSpan.add(new CacheActivatedImage("applicationVisibilityPanelPrivateImage",new ResourceModel("visibility-private").getObject()));

    boolean applicationIsPublic = getModelObject().isPublic();
    applicationPublicSpan.setVisible(applicationIsPublic);
    applicationPrivateSpan.setVisible(!applicationIsPublic);
}
 
Example 38
Project: artifactory   File: BintrayInfoPanel.java   Source Code and License 6 votes vote down vote up
private void addLatestVersionToPanel(final BintrayPackageInfo packageInfo) {
    String latestVersion = String.format("%s", packageInfo.getLatest_version());
    TitledPageLink latestVersionLink = new TitledPageLink("latestVersion", latestVersion, null) {
        @Override
        protected CharSequence getURL() {
            StringBuilder urlBuilder = new StringBuilder(
                    ConstantValues.bintrayUrl.getString() + "/version/show/general").
                    append("/").append(packageInfo.getOwner()).
                    append("/").append(packageInfo.getRepo()).
                    append("/").append(packageInfo.getName()).
                    append("/").append(packageInfo.getLatest_version());
            return urlBuilder.toString();
        }
    };
    latestVersionLink.add(new AttributeModifier("target", "_blank"));
    infoBorder.add(latestVersionLink);
}
 
Example 39
Project: elpaaso-core   File: DesignerArchitectureMatrixCellButtonPanel.java   Source Code and License 6 votes vote down vote up
private void initMonitoringUtlBtn() {

        /* monitoring icon*/
        monitoringUrlSpan = new WebMarkupContainer("monitoringUrlImg");
        monitoringUrl = null;

        monitoringUrlBtn = new ExternalLink("cell-monitoringUrl", (monitoringUrl != null) ? monitoringUrl.toString() : "") {

            private static final long serialVersionUID = 5630633258734623659L;

            @Override
            public boolean isVisible() {
                // TODO : when monitoring will be integrated this condition will have to change
                return monitoringUrl != null;
            }
        };

        monitoringUrlSpan.add(new AttributeAppender("class", new Model<String>((monitoringUrl != null) ? "monitoringUrl-enable" : "monitoringUrl-disable"), " "));
        //monitoringUrlBtn.add(new AttributeAppender("target", new Model<String>("_blank"), " " ));
        monitoringUrlBtn.add(new AttributeModifier("id", new Model<String>("monitoringURL")));
        monitoringUrlBtn.add(monitoringUrlSpan);
        add(monitoringUrlBtn);

    }
 
Example 40
Project: artifactory   File: SelectAllCheckboxColumn.java   Source Code and License 6 votes vote down vote up
@Override
public Component getHeader(String componentId) {
    CheckboxPanel panel = new CheckboxPanel(componentId);
    selectAllCheckbox = new StyledCheckbox(CHECKBOX_ID, getSelectAllModel());
    selectAllCheckbox.setTitle(getDisplayModel().getObject());
    selectAllCheckbox.add(new AttributeModifier("title", "Select All"));
    selectAllCheckbox.setOutputMarkupId(true);
    selectAllCheckbox.add(new AjaxFormComponentUpdatingBehavior("onclick") {
        @SuppressWarnings({"unchecked"})
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            SortableTable<T> table = (SortableTable<T>) selectAllCheckbox.findParent(DataTable.class);
            selectAll(table, target);
            onSelectAllUpdate(target);
        }
    });
    panel.add(selectAllCheckbox);
    return panel;
}
 
Example 41
Project: elpaaso-core   File: DesignerArchitectureMatrixCellButtonPanel.java   Source Code and License 6 votes vote down vote up
private void initConfigBtn() {

        /** view icon */
        configBtn = new AjaxLink<Void>("cell-config") {

            private static final long serialVersionUID = 6195327499501053622L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                logger.debug("config icon onClick");
                findParent(DesignerArchitectureMatrixCellButtonPanel.class).onClickConfigOverride(target);
            }

            @Override
            public boolean isVisible() {
                return allowOverride && DesignerArchitectureMatrixCellButtonPanel.this.getModelObject() instanceof LogicalConfigService;
            }

        };

        Model<String[]> labelModel = new Model<String[]>(new String[]{ getModelObject().getLabel() });
        configBtn.add(new AttributeModifier("title", new StringResourceModel("portal.designer.matrix.details.tooltip", labelModel)));

        add(configBtn);

    }
 
Example 42
Project: superfly   File: BaseSSOPage.java   Source Code and License 6 votes vote down vote up
protected BaseSSOPage() {
    SSOLoginData loginData = getSession().getSsoLoginData();
    WebMarkupContainer subsystemInfoContainer = new WebMarkupContainer("subsystem-info");
    boolean subsystemInfoVisible = isSubsystemInfoShown() && loginData != null;
    subsystemInfoContainer.setVisible(subsystemInfoVisible);
    add(subsystemInfoContainer);

    if (subsystemInfoVisible) {
        subsystemInfoContainer.add(new Label("subsystem-title", loginData.getSubsystemTitle()));
        subsystemInfoContainer.add(new Label("subsystem-url", loginData.getSubsystemUrl()));
    }

    IModel<String> cssUrlModel = createCssUrlModel();
    WebMarkupContainer cssUrlContainer = new WebMarkupContainer("login-css-url");
    cssUrlContainer.add(new AttributeModifier("href", cssUrlModel));
    cssUrlContainer.setVisible(StringUtils.hasText(cssUrlModel.getObject()));
    add(cssUrlContainer);
}
 
Example 43
Project: artifactory   File: ActionLink.java   Source Code and License 6 votes vote down vote up
public ActionLink(String id, ItemAction action, ActionableItem actionableItem) {
    super(id, Model.of(action.getDisplayName(actionableItem)));
    this.action = action;
    this.actionableItem = actionableItem;

    // add css classes
    add(new CssClass("icon-link"));
    add(new CssClass(action.getCssClass()));

    // set href for link actions
    String actionURL = action.getActionLinkURL(actionableItem);
    if (StringUtils.isNotEmpty(actionURL)) {
        add(new AttributeModifier("onclick", "window.open(this.href); return false;"));
        add(new AttributeModifier("href", actionURL));
    }
}
 
Example 44
Project: gitplex-mit   File: ConcreteListPropertyViewer.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(new ListView<PropertyContext<Serializable>>("headers", elementPropertyContexts) {

		@Override
		protected void populateItem(ListItem<PropertyContext<Serializable>> item) {
			item.add(new Label("header", EditableUtils.getName(item.getModelObject().getPropertyGetter())));
		}
		
	});
	add(new ListView<Serializable>("rows", elements) {

		@Override
		protected void populateItem(final ListItem<Serializable> rowItem) {
			rowItem.add(new ListView<PropertyContext<Serializable>>("columns", elementPropertyContexts) {

				@Override
				protected void populateItem(ListItem<PropertyContext<Serializable>> columnItem) {
					PropertyContext<Serializable> propertyContext = columnItem.getModelObject(); 
					Serializable elementPropertyValue = (Serializable) propertyContext.getPropertyValue(rowItem.getModelObject());
					columnItem.add(propertyContext.renderForView("cell", Model.of(elementPropertyValue)));
				}
				
			});
		}
		
	});
	WebMarkupContainer noElements = new WebMarkupContainer("noElements");
	noElements.setVisible(elements.isEmpty());
	noElements.add(AttributeModifier.append("colspan", elementPropertyContexts.size()));
	add(noElements);
}
 
Example 45
Project: gitplex-mit   File: DatePropertyEditor.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	DateTextFieldConfig config = new DateTextFieldConfig();
	config.autoClose(true);
	config.clearButton(true);
	config.withFormat(DateEditSupport.DATE_INPUT_FORMAT);
	input = new DateTextField("input", Model.of(getModelObject()), config);
	input.setType(getPropertyDescriptor().getPropertyClass());
	Method propertyGetter = getPropertyDescriptor().getPropertyGetter();
	if (propertyGetter.getAnnotation(OmitName.class) != null)
		input.add(AttributeModifier.replace("placeholder", EditableUtils.getName(propertyGetter)));
	
	add(input);

	add(new AttributeAppender("class", new LoadableDetachableModel<String>() {

		@Override
		protected String load() {
			if (hasErrors(true))
				return " has-error";
			else
				return "";
		}
		
	}));
}
 
Example 46
Project: coling2016-marketing-blunders   File: ApplicationPageBase.java   Source Code and License 5 votes vote down vote up
private void commonInit() {
	getSession().setLocale(Locale.ENGLISH);

	feedbackPanel = new FeedbackPanel("feedbackPanel");
	feedbackPanel.setOutputMarkupId(true);
	feedbackPanel.add(new AttributeModifier("class", "error"));
	feedbackPanel.setFilter(new IFeedbackMessageFilter(){
		@Override
		public boolean accept(FeedbackMessage aMessage) {
			String username = "anonymous";
			if (aMessage.isFatal())
				LOG.fatal(username + ": " + aMessage.getMessage());
			else
			if (aMessage.isError())
				LOG.error(username + ": " + aMessage.getMessage());
			else
			if (aMessage.isWarning())
				LOG.warn(username + ": " + aMessage.getMessage());
			else
			if (aMessage.isInfo())
				LOG.info(username + ": " + aMessage.getMessage());
			else
			if (aMessage.isDebug())
				LOG.debug(username + ": " + aMessage.getMessage());
			return true;
		}
	});

	Properties props = getVersionProperties();
	String versionString = props.getProperty("version");
	versionLabel = new Label("version", versionString);

	add(feedbackPanel);
	add(versionLabel);

	add(new BookmarkablePageLink<Void>("homeButton", HomePage.class));
	add(new BookmarkablePageLink<Void>("footerHomeLink", HomePage.class));
}
 
Example 47
Project: MBaaS   File: CharacterPanel.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
    super.onInitialize();
    Label label = new Label("label", this.name);
    this.add(label);
    TextField<Character> field = new TextField<>("field", new PropertyModel<>(this.fields, this.name), Character.class);
    field.add(AttributeModifier.replace("maxlength", "1"));
    field.setType(Character.class);
    field.setLabel(Model.of(name));
    TextFeedbackPanel feedback = new TextFeedbackPanel("feedback", field);
    this.add(field);
    this.add(feedback);
}
 
Example 48
Project: engerek   File: AbstractAssignmentDetailsPanel.java   Source Code and License 5 votes vote down vote up
protected void initLayout(){
    WebMarkupContainer typeImage = new WebMarkupContainer(ID_TYPE_IMAGE);
    typeImage.setOutputMarkupId(true);
    typeImage.add(AttributeModifier.append("class", createImageModel()));
    typeImage.add(AttributeModifier.append("class", getAdditionalNameLabelStyleClass()));
    add(typeImage);

    Label name = new Label(ID_ASSIGNMENT_NAME, createHeaderModel());
    name.add(AttributeModifier.append("class", getAdditionalNameLabelStyleClass()));
    name.setOutputMarkupId(true);
    add(name);

    add(new Label(ID_DESCRIPTION, Model.of(getModelObject().getDescription())));

    add(initPropertiesContainer(ID_PROPERTIES_PANEL));

    AssignmentActivationPopupablePanel activationPanel = new AssignmentActivationPopupablePanel(ID_ACTIVATION_PANEL, getModel()){
        private static final long serialVersionUID = 1L;

        @Override
        protected boolean getButtonsPanelVisibility() {
            return false;
        }
    };
    activationPanel.setOutputMarkupId(true);
    add(activationPanel);

    AjaxButton doneButton = new AjaxButton(ID_DONE_BUTTON, createStringResource("AbstractAssignmentDetailsPanel.doneButton")) {
        private static final long serialVersionUID = 1L;
        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            redirectBack(ajaxRequestTarget);

        }
    };
    add(doneButton);
}
 
Example 49
Project: engerek   File: ShoppingCartEditorPanel.java   Source Code and License 5 votes vote down vote up
@Override
protected void initHeaderRow(){
    WebMarkupContainer box = new WebMarkupContainer(ID_BOX);
    headerRow.add(box);

    box.add(new AttributeModifier("class", BOX_CSS_CLASS + " " + getBoxAdditionalCssClass()));

    box.add(new Label(ID_DISPLAY_NAME, new PropertyModel<AssignmentEditorDto>(getModel(), AssignmentEditorDto.F_NAME)));
    box.add(new Label(ID_DESCRIPTION, new AbstractReadOnlyModel<String>() {
        @Override
        public String getObject(){
            return getModelObject().getTargetRef() != null
                    && getModelObject().getTargetRef().getDescription() != null ?
                    getModelObject().getTargetRef().getDescription() : "";
        }
    }));

    WebMarkupContainer iconBox = new WebMarkupContainer(ID_ICON_BOX);
    box.add(iconBox);

    if (getIconBoxAdditionalCssClass() != null) {
        iconBox.add(new AttributeModifier("class", ICON_BOX_CSS_CLASS + " " + getIconBoxAdditionalCssClass()));
    }

    Label icon = new Label(ID_ICON, "");
    icon.add(new AttributeModifier("class", getIconCssClass()));
    iconBox.add(icon);
}
 
Example 50
Project: engerek   File: AjaxIconButton.java   Source Code and License 5 votes vote down vote up
public AjaxIconButton(String id, IModel<String> icon, IModel<String> title) {
    super(id, icon);

    if (title != null) {
        add(AttributeModifier.replace("title", title));
    }
}
 
Example 51
Project: engerek   File: ImagePanel.java   Source Code and License 5 votes vote down vote up
public ImagePanel(String id, IModel<String> model, IModel<String> titleModel) {
    super(id);

    Label image = new Label(ID_IMAGE);
    add(image);

    image.add(AttributeModifier.replace("class", model));
    if (titleModel != null) {
        image.add(AttributeModifier.replace("title", titleModel));
    }
}
 
Example 52
Project: engerek   File: CountToolbar.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
    super.onInitialize();

    WebMarkupContainer td = new WebMarkupContainer(ID_TD);
    td.add(AttributeModifier.replace("colspan", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return String.valueOf(getTable().getColumns().size());
        }
    }));
    add(td);

    Label count = new Label(ID_COUNT, createModel());
    count.setRenderBodyOnly(true);
    td.add(count);

    PageSizePopover popover = new PageSizePopover(ID_PAGE_SIZE) {

        @Override
        protected void pageSizeChanged(AjaxRequestTarget target) {
            CountToolbar.this.pageSizeChanged(target);
        }
    };
    popover.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return CountToolbar.this.isPageSizePopupVisible();
        }
    });
    td.add(popover);
}
 
Example 53
Project: engerek   File: NavigatorPanel.java   Source Code and License 5 votes vote down vote up
private void initPrevious() {
    WebMarkupContainer previous = new WebMarkupContainer(ID_PREVIOUS);
    previous.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return isPreviousEnabled() ? "" : "disabled";
        }
    }));
    add(previous);
    AjaxLink previousLink = new AjaxLink(ID_PREVIOUS_LINK) {

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            previousPerformed(target);
        }
    };
    previousLink.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return isPreviousEnabled();
        }
    });
    previous.add(previousLink);
}
 
Example 54
Project: engerek   File: NavigatorPanel.java   Source Code and License 5 votes vote down vote up
private void initFirst() {
    WebMarkupContainer first = new WebMarkupContainer(ID_FIRST);
    first.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return isFirstEnabled() ? "" : "disabled";
        }
    }));
    add(first);
    AjaxLink firstLink = new AjaxLink(ID_FIRST_LINK) {

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            firstPerformed(target);
        }
    };
    firstLink.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return BooleanUtils.isTrue(showPageListingModel.getObject()) && isFirstEnabled();
        }
    });
    first.add(firstLink);
}
 
Example 55
Project: engerek   File: NavigatorPanel.java   Source Code and License 5 votes vote down vote up
private void initNext() {
    WebMarkupContainer next = new WebMarkupContainer(ID_NEXT);
    next.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return isNextEnabled() ? "" : "disabled";
        }
    }));
    add(next);

    AjaxLink nextLink = new AjaxLink(ID_NEXT_LINK) {

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            nextPerformed(target);
        }
    };
    nextLink.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return isNextEnabled();
        }
    });
    next.add(nextLink);
}
 
Example 56
Project: engerek   File: NavigatorPanel.java   Source Code and License 5 votes vote down vote up
private void initLast() {
    WebMarkupContainer last = new WebMarkupContainer(ID_LAST);
    last.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return isLastEnabled() ? "" : "disabled";
        }
    }));
    add(last);

    AjaxLink lastLink = new AjaxLink(ID_LAST_LINK) {

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            lastPerformed(target);
        }
    };
    lastLink.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return BooleanUtils.isTrue(showPageListingModel.getObject()) && isLastEnabled();
        }
    });
    last.add(lastLink);
}
 
Example 57
Project: engerek   File: DynamicFieldGroupPanel.java   Source Code and License 5 votes vote down vote up
private void initLayout(String groupName, List<AbstractFormItemType> formItems, Form<?> mainForm) {
	
	Label header = new Label(ID_HEADER, groupName);
	add(header);
	
	RepeatingView itemView = new RepeatingView(ID_PROPERTY);
	add(itemView);
	
	int i = 0;
	for (AbstractFormItemType formItem : formItems) {

		if (formItem instanceof FormFieldGroupType) {
			DynamicFieldGroupPanel<O> dynamicFieldGroupPanel = new DynamicFieldGroupPanel<O>(itemView.newChildId(), formItem.getName(), getModel(), FormTypeUtil.getFormItems(((FormFieldGroupType) formItem).getFormItems()), mainForm, getPageBase());
			dynamicFieldGroupPanel.setOutputMarkupId(true);
			itemView.add(dynamicFieldGroupPanel);
			continue;
		}
		
		ItemWrapper itemWrapper = createItemWrapper(formItem, getObjectWrapper());
		
		if (itemWrapper instanceof ContainerWrapper) {
			PrismContainerPanel containerPanel = new PrismContainerPanel(itemView.newChildId(),
					Model.of((ContainerWrapper) itemWrapper), true, mainForm, getPageBase());
				containerPanel.setOutputMarkupId(true);
				itemView.add(containerPanel);
		} else {
			PrismPropertyPanel<?> propertyPanel = new PrismPropertyPanel<>(itemView.newChildId(),
					Model.of(itemWrapper), mainForm, getPageBase());
			propertyPanel.setOutputMarkupId(true);
			propertyPanel.add(AttributeModifier.append("class", ((i % 2) == 0) ? "" : "stripe"));
			itemView.add(propertyPanel);
		}

		i++;

	}
}
 
Example 58
Project: engerek   File: SummaryTagSimple.java   Source Code and License 5 votes vote down vote up
public SummaryTagSimple(String id, final IModel<C> model) {
	super(id, model);
	
	Label tagIcon = new Label(ID_TAG_ICON, "");
	tagIcon.add(new AttributeModifier("class", new SummaryTagModel<String>(model) {
		@Override
		protected String getValue() {
			return getIconCssClass();
		}
	}));
	add(tagIcon);
	
	add(new Label(ID_TAG_LABEL, new SummaryTagModel<String>(model) {
		@Override
		protected String getValue() {
			return getLabel();
		}
	}));
	
	add(new AttributeModifier("style", new SummaryTagModel<String>(model) {
		@Override
		protected String getValue() {
			if (getColor() == null) {
				return null;
			}
			return "color: " + getColor();
		}
	}));
	
	add(new VisibleEnableBehaviour(){    		
           @Override
           public boolean isVisible(){
           	if (!initialized) {
   				initialize(model.getObject());
   			}
           	return !isHideTag();
           }
       });
}
 
Example 59
Project: engerek   File: InlineMenu.java   Source Code and License 5 votes vote down vote up
private void initMenuItem(ListItem<InlineMenuItem> menuItem) {
    final InlineMenuItem item = menuItem.getModelObject();

    menuItem.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (item.isMenuHeader()) {
                return "dropdown-header";
            } else if (item.isDivider()) {
                return "divider";
            }

            return getBoolean(item.getEnabled(), true) ? null : "disabled";
        }
    }));

        menuItem.add(new VisibleEnableBehaviour() {

            @Override
            public boolean isEnabled() {
                return getBoolean(item.getEnabled(), true);
            }

            @Override
            public boolean isVisible() {
                return getBoolean(item.getVisible(), true);
            }
        });

    WebMarkupContainer menuItemBody;
    if (item.isMenuHeader() || item.isDivider()) {
        menuItemBody = new MenuDividerPanel(ID_MENU_ITEM_BODY, menuItem.getModel());
    } else {
        menuItemBody = new MenuLinkPanel(ID_MENU_ITEM_BODY, menuItem.getModel());
    }
    menuItemBody.setRenderBodyOnly(true);
    menuItem.add(menuItemBody);
}
 
Example 60
Project: engerek   File: TextAreaPanel.java   Source Code and License 5 votes vote down vote up
public TextAreaPanel(String id, IModel<T> model, Integer rowsOverride) {
      super(id);

      final TextArea<T> text = new TextArea<T>(ID_INPUT, model);
if (rowsOverride != null) {
	text.add(new AttributeModifier("rows", rowsOverride));
}
      add(text);
  }