Java Code Examples for org.apache.wicket.markup.html.WebMarkupContainer#setVisible()

The following examples show how to use org.apache.wicket.markup.html.WebMarkupContainer#setVisible() . 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: MyNamePronunciationDisplay.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
private void addNameRecord() {
    WebMarkupContainer nameRecordingContainer = new WebMarkupContainer("nameRecordingContainer");

    nameRecordingContainer.add(new Label("nameRecordingLabel", new ResourceModel("profile.name.recording")));
    WebMarkupContainer audioPlayer = new WebMarkupContainer("audioPlayer");

    final String slash = Entity.SEPARATOR;
    final StringBuilder path = new StringBuilder();
    path.append(slash);
    path.append("direct");
    path.append(slash);
    path.append("profile");
    path.append(slash);
    path.append(userProfile.getUserUuid());
    path.append(slash);
    path.append("pronunciation");
    path.append("?v=");
    path.append(RandomStringUtils.random(8, true, true));

    audioPlayer.add(new AttributeModifier("src", path.toString()));
    nameRecordingContainer.add(audioPlayer);
    add(nameRecordingContainer);

    if (profileLogic.getUserNamePronunciation(userProfile.getUserUuid()) == null) nameRecordingContainer.setVisible(false);
    else visibleFieldCount++;
}
 
Example 2
Source File: FilterPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
public FilterPanel(String id, IModel<String> name, final Form form, List<AbstractFilterPanel<?, ?>> filterPanels) {
    super(id);
    final WebMarkupContainer container = new WebMarkupContainer("container");
    this.containerId = container.getMarkupId();
    initFilterPanels(filterPanels);
    List<FilterTab> tabs = createPanelSwitches("switch", filterPanels);
    currentTab = tabs.get(0);
    addFilterPanels(container, filterPanels, tabs);
    addFilterSwitches(container, tabs);
    container.setOutputMarkupPlaceholderTag(true);
    container.setVisible(false);
    container.add(newOkButton("okButton", container, form));
    container.add(newClearButton("clearButton", container, form, filterPanels));
    container.add(newOnEnterPressBehavior(container));
    add(newShowFilterButton("showFilters", container));
    container.add(new Label("panelTitle", name).setOutputMarkupPlaceholderTag(true));
    add(container);
    setOutputMarkupPlaceholderTag(true);
}
 
Example 3
Source File: AbstractSecuredPage.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @see org.apache.wicket.Component#onInitialize()
 */
@Override
protected void onInitialize()
{
  super.onInitialize();
  final WebMarkupContainer breadcrumbContainer = new WebMarkupContainer("breadcrumb");
  body.add(breadcrumbContainer);
  breadcrumbContainer.add(contentMenuBarPanel);
  if (isBreadCrumbVisible() == true) {
    final RepeatingView breadcrumbItems = new RepeatingView("li");
    breadcrumbContainer.add(breadcrumbItems);
    final WebPage returnTo = this.getReturnToPage();
    if (returnTo != null && returnTo instanceof AbstractSecuredPage) {
      addBreadCrumbs(breadcrumbItems, (AbstractSecuredPage) returnTo);
    } else {
      breadcrumbItems.setVisible(false);
    }
    breadcrumbContainer.add(new Label("active", getTitle()));
  } else {
    breadcrumbContainer.setVisible(false);
  }
}
 
Example 4
Source File: MyBusinessDisplay.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
private int addBusinessBiography(final UserProfile userProfile,
		int visibleFieldCount) {

	WebMarkupContainer businessBiographyContainer = new WebMarkupContainer(
			"businessBiographyContainer");
	businessBiographyContainer.add(new Label("businessBiographyLabel",
			new ResourceModel("profile.business.bio")));
	businessBiographyContainer.add(new Label("businessBiography",
			ProfileUtils.processHtml(userProfile.getBusinessBiography()))
			.setEscapeModelStrings(false));
	add(businessBiographyContainer);

	if (StringUtils.isBlank(userProfile.getBusinessBiography())) {
		businessBiographyContainer.setVisible(false);
	} else {
		visibleFieldCount++;
	}
	return visibleFieldCount;
}
 
Example 5
Source File: WarningsFooterPanel.java    From webanno with Apache License 2.0 6 votes vote down vote up
public WarningsFooterPanel(String aId)
{
    super(aId);
    
    Properties settings = SettingsUtil.getSettings();
    
    // set up warnings shown when using an embedded DB or some unsupported browser
    boolean isBrowserWarningVisible = isBrowserWarningVisible(settings);
    boolean isDatabaseWarningVisible = isDatabaseWarningVisible(settings);
    
    embeddedDbWarning = new Label("embeddedDbWarning", new ResourceModel("warning.database"));
    embeddedDbWarning.setVisible(isDatabaseWarningVisible);
    add(embeddedDbWarning);
    browserWarning = new Label("browserWarning", new ResourceModel("warning.browser"));
    browserWarning.setVisible(isBrowserWarningVisible);
    add(browserWarning);
    
    WebMarkupContainer warningsContainer = new WebMarkupContainer("warnings");
    warningsContainer.setVisible(isBrowserWarningVisible || isDatabaseWarningVisible);  
    add(warningsContainer);
}
 
Example 6
Source File: MultilevelPanel.java    From syncope with Apache License 2.0 6 votes vote down vote up
public MultilevelPanel(final String id) {
    super(id);

    firstLevelContainer = new WebMarkupContainer("firstLevelContainer");
    firstLevelContainer.setOutputMarkupPlaceholderTag(true);
    firstLevelContainer.setVisible(true);
    add(firstLevelContainer);

    secondLevelContainer = new WebMarkupContainer("secondLevelContainer");
    secondLevelContainer.setOutputMarkupPlaceholderTag(true);
    secondLevelContainer.setVisible(false);
    add(secondLevelContainer);

    secondLevelContainer.add(new AjaxLink<String>("back") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            onClickBackInternal(target);
            prev(target);
        }
    });
}
 
Example 7
Source File: MyNamePronunciationDisplay.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
private void addNameRecord() {
    WebMarkupContainer nameRecordingContainer = new WebMarkupContainer("nameRecordingContainer");

    nameRecordingContainer.add(new Label("nameRecordingLabel", new ResourceModel("profile.name.recording")));
    WebMarkupContainer audioPlayer = new WebMarkupContainer("audioPlayer");

    final String slash = Entity.SEPARATOR;
    final StringBuilder path = new StringBuilder();
    path.append(slash);
    path.append("direct");
    path.append(slash);
    path.append("profile");
    path.append(slash);
    path.append(userProfile.getUserUuid());
    path.append(slash);
    path.append("pronunciation");
    path.append("?v=");
    path.append(RandomStringUtils.random(8, true, true));

    audioPlayer.add(new AttributeModifier("src", path.toString()));
    nameRecordingContainer.add(audioPlayer);
    add(nameRecordingContainer);

    if (profileLogic.getUserNamePronunciation(userProfile.getUserUuid()) == null) nameRecordingContainer.setVisible(false);
    else visibleFieldCount++;
}
 
Example 8
Source File: MenuItem.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public MenuItem(String id, IModel itemText, Class itemPageClass, PageParameters pageParameters, boolean first, Class menusCurrentPageClass) {
	super(id);

	boolean currentPage = itemPageClass.equals(menusCurrentPageClass);

	// link version
	menuItemLinkHolder = new WebMarkupContainer("menuItemLinkHolder");
	menuItemLink = new BookmarkablePageLink("menuItemLink", itemPageClass, pageParameters);
	menuLinkText = new Label("menuLinkText", itemText);
	menuLinkText.setRenderBodyOnly(true);
	menuItemLink.add(menuLinkText);
	menuItemLinkHolder.add(menuItemLink);
	menuItemLinkHolder.setVisible(!currentPage);
	add(menuItemLinkHolder);

	// span version
	menuItemLabel = new Label("menuItemLabel", itemText);
	menuItemLabel.setVisible(currentPage);
	add(menuItemLabel);
	
	//add current page styling
	AttributeModifier currentPageStyling = new AttributeModifier("class", new Model("current"));
	if(currentPage) {
		menuItemLabel.add(currentPageStyling);
	}

	if(first) {
		add(new AttributeModifier("class", new Model("firstToolBarItem")));
	}
}
 
Example 9
Source File: MenuConfigContent.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public MenuConfigContent(final String id, final Menu menu)
{
  super(id);
  final RepeatingView mainMenuRepeater = new RepeatingView("mainMenuItem");
  add(mainMenuRepeater);
  if (menu == null) {
    mainMenuRepeater.setVisible(false);
    log.error("Oups, menu is null. Configuration of favorite menu not possible.");
    return;
  }
  int counter = 0;
  if (menu.getMenuEntries() == null) {
    // Should only occur in maintenance mode!
    return;
  }
  for (final MenuEntry mainMenuEntry : menu.getMenuEntries()) {
    if (mainMenuEntry.hasSubMenuEntries() == false) {
      continue;
    }
    final WebMarkupContainer mainMenuContainer = new WebMarkupContainer(mainMenuRepeater.newChildId());
    mainMenuRepeater.add(mainMenuContainer);
    if (counter++ % 5 == 0) {
      mainMenuContainer.add(AttributeModifier.append("class", "mm_clear"));
    }
    mainMenuContainer.add(new Label("label", new ResourceModel(mainMenuEntry.getI18nKey())));
    final RepeatingView subMenuRepeater = new RepeatingView("menuItem");
    mainMenuContainer.add(subMenuRepeater);
    for (final MenuEntry subMenuEntry : mainMenuEntry.getSubMenuEntries()) {
      final WebMarkupContainer subMenuContainer = new WebMarkupContainer(subMenuRepeater.newChildId());
      subMenuRepeater.add(subMenuContainer);
      final AbstractLink link = NavAbstractPanel.getMenuEntryLink(subMenuEntry, false);
      if (link != null) {
        subMenuContainer.add(link);
      } else {
        subMenuContainer.setVisible(false);
      }
    }
  }
}
 
Example 10
Source File: Menus.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/** Render Sakai Menu. */
@SuppressWarnings("unchecked")
private void renderBody() {
	setRenderBodyOnly(true);
	
	boolean isSiteStatsAdminPage = Locator.getFacade().getStatsAuthz().isSiteStatsAdminPage();
	boolean isSiteStatsView = Locator.getFacade().getStatsAuthz().isUserAbleToViewSiteStats(siteId);
	boolean isBrowsingThisSite = siteId.equals(realSiteId);
	
	// admin menu
	AdminMenu adminMenu = new AdminMenu("adminMenu");
	add(adminMenu);
	
	// standard menu
	WebMarkupContainer standardMenuContainer = new WebMarkupContainer("standardMenuContainer");
	// menu
	Menu standardMenu = new Menu("standardMenu", siteId);
	standardMenuContainer.add(standardMenu);
	add(standardMenuContainer);
	
	// menus rendering
	if(isSiteStatsAdminPage) {
		adminMenu.setVisible(true);
		if(!isBrowsingThisSite) {
			standardMenuContainer.setVisible(true);
			standardMenuContainer.add(new AttributeModifier("style", new Model("margin: 10px 5px 5px 5px;")));
		}else{
			standardMenuContainer.setVisible(false);
		}
	}else if(isSiteStatsView){
		adminMenu.setVisible(false);
		standardMenuContainer.setVisible(true);
	}else{
		adminMenu.setVisible(false);
		standardMenuContainer.setVisible(false);
	}
}
 
Example 11
Source File: MenuItem.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public MenuItem(String id, IModel itemText, Class itemPageClass, PageParameters pageParameters, boolean first, Class menusCurrentPageClass) {
	super(id);

	boolean currentPage = itemPageClass.equals(menusCurrentPageClass);

	// link version
	menuItemLinkHolder = new WebMarkupContainer("menuItemLinkHolder");
	menuItemLink = new BookmarkablePageLink("menuItemLink", itemPageClass, pageParameters);
	menuLinkText = new Label("menuLinkText", itemText);
	menuLinkText.setRenderBodyOnly(true);
	menuItemLink.add(menuLinkText);
	menuItemLinkHolder.add(menuItemLink);
	menuItemLinkHolder.setVisible(!currentPage);
	add(menuItemLinkHolder);

	// span version
	menuItemLabel = new Label("menuItemLabel", itemText);
	menuItemLabel.setVisible(currentPage);
	add(menuItemLabel);
	
	//add current page styling
	AttributeModifier currentPageStyling = new AttributeModifier("class", new Model("current"));
	if(currentPage) {
		menuItemLabel.add(currentPageStyling);
	}

	if(first) {
		add(new AttributeModifier("class", new Model("firstToolBarItem")));
	}
}
 
Example 12
Source File: OrderItemListPanel.java    From the-app with Apache License 2.0 5 votes vote down vote up
private Component discountHeader(){
    WebMarkupContainer webMarkupContainer = new WebMarkupContainer ("discountHeader");
    //If there are no promotions hide the title
    if (Config.getProperty("GLOBAL_DISCOUNT")==null ||
        Double.parseDouble(Config.getProperty("GLOBAL_DISCOUNT"))==0){
        webMarkupContainer.setVisible(false);
    } else {
      webMarkupContainer.add(new Label("discountPercent", Config.getProperty("GLOBAL_DISCOUNT")));
    }
    return webMarkupContainer;
}
 
Example 13
Source File: EventToWorkflowViewer.java    From oodt with Apache License 2.0 5 votes vote down vote up
public EventToWorkflowViewer(String id, String workflowUrlStr, final Class<? extends WebPage> viewerPage) {
  super(id);
  this.wm = new WorkflowMgrConn(workflowUrlStr);
  WebMarkupContainer wTable = new WebMarkupContainer("wtable");
  wTable.setVisible(false);
  PropertyModel<List<Workflow>> workflowsModel = new PropertyModel<List<Workflow>>(this, "workflows");
  ListView<Workflow> workflowView = new ListView<Workflow>("workflow_list", workflowsModel) {
    private static final long serialVersionUID = 5894604290395257941L;

    @Override
    protected void populateItem(ListItem<Workflow> item) {
      Link<String> wLink = new Link<String>("workflow_link", new Model(item.getModelObject().getId())){
        
         /* (non-Javadoc)
         * @see org.apache.wicket.markup.html.link.Link#onClick()
         */
        @Override
        public void onClick() {
          PageParameters params = new PageParameters();
          params.add("id", getModelObject());
          setResponsePage(viewerPage, params);
        }
      };
      
      wLink.add(new Label("workflow_name", item.getModelObject().getName()));
      item.add(wLink);
    }
  };

  EventWorkflowForm form = 
    new EventWorkflowForm("event_workflow_frm", workflowsModel, wTable);

  wTable.add(workflowView);
  add(wTable);
  add(form);
}
 
Example 14
Source File: MyNamePronunciationDisplay.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private void addPhoneticPronunciation() {
    WebMarkupContainer phoneticPronunciationContainer = new WebMarkupContainer("phoneticPronunciationContainer");

    phoneticPronunciationContainer.add(new Label("phoneticPronunciationLabel", new ResourceModel("profile.phonetic")));
    phoneticPronunciationContainer.add(new Label("phoneticPronunciation", ProfileUtils.processHtml(userProfile.getPhoneticPronunciation())).setEscapeModelStrings(false));
    add(phoneticPronunciationContainer);

    if (StringUtils.isBlank(userProfile.getPhoneticPronunciation())) phoneticPronunciationContainer.setVisible(false);
    else visibleFieldCount++;
}
 
Example 15
Source File: MyStudentDisplay.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public MyStudentDisplay(final String id, final UserProfile userProfile) {
	
	super(id);
	
	//heading
	add(new Label("heading", new ResourceModel("heading.student")));
	
	String course = userProfile.getCourse();
	String subjects = userProfile.getSubjects();
	
	int visibleFieldCount = 0;
	
	//course
	WebMarkupContainer courseContainer = new WebMarkupContainer("courseContainer");
	courseContainer.add(new Label("courseLabel", new ResourceModel("profile.course")));
	courseContainer.add(new Label("course", course));
	add(courseContainer);
	if(StringUtils.isBlank(course)) {
		courseContainer.setVisible(false);
	} else {
		visibleFieldCount++;
	}
	
	//subjects
	WebMarkupContainer subjectsContainer = new WebMarkupContainer("subjectsContainer");
	subjectsContainer.add(new Label("subjectsLabel", new ResourceModel("profile.subjects")));
	subjectsContainer.add(new Label("subjects", subjects));
	add(subjectsContainer);
	if(StringUtils.isBlank(subjects)) {
		subjectsContainer.setVisible(false);
	} else {
		visibleFieldCount++;
	}

	//edit button
	AjaxFallbackLink editButton = new AjaxFallbackLink("editButton", new ResourceModel("button.edit")) {
		
		private static final long serialVersionUID = 1L;

		public void onClick(AjaxRequestTarget target) {
			Component newPanel = new MyStudentEdit(id, userProfile);
			newPanel.setOutputMarkupId(true);
			MyStudentDisplay.this.replaceWith(newPanel);
			if(target != null) {
				target.add(newPanel);
				//resize iframe
				target.appendJavaScript("setMainFrameHeight(window.name);");
			}
			
		}
					
	};
	editButton.add(new Label("editButtonLabel", new ResourceModel("button.edit")));
	editButton.setOutputMarkupId(true);
	
	if(userProfile.isLocked() && !sakaiProxy.isSuperUser()) {
		editButton.setVisible(false);
	}
	
	add(editButton);
	
	//no fields message
	Label noFieldsMessage = new Label("noFieldsMessage", new ResourceModel("text.no.fields"));
	add(noFieldsMessage);
	if(visibleFieldCount > 0) {
		noFieldsMessage.setVisible(false);
	}
}
 
Example 16
Source File: GalleryImageEdit.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public GalleryImageEdit(String id,
		final String userId, final GalleryImage image,
		final long galleryPageIndex) {

	super(id);

	log.debug("GalleryImageEdit()");

	// feedback label for user alert in event remove/set actions fail
	final Label formFeedback = new Label("formFeedback");
	formFeedback.setOutputMarkupPlaceholderTag(true);
	add(formFeedback);

	Form imageEditForm = new Form("galleryImageEditForm");

	imageEditForm.setOutputMarkupId(true);
	add(imageEditForm);

	imageOptionsContainer = new WebMarkupContainer("galleryImageOptionsContainer");
	imageOptionsContainer.setOutputMarkupId(true);
	imageOptionsContainer.setOutputMarkupPlaceholderTag(true);

	imageOptionsContainer.add(new Label("removePictureLabel",
			new ResourceModel("pictures.removepicture")));

	AjaxFallbackButton removePictureButton = createRemovePictureButton(imageEditForm);
	imageOptionsContainer.add(removePictureButton);

	Label setProfileImageLabel = new Label("setProfileImageLabel",
			new ResourceModel("pictures.setprofileimage"));
	imageOptionsContainer.add(setProfileImageLabel);

	AjaxFallbackButton setProfileImageButton = createSetProfileImageButton(imageEditForm);

	if ((true == sakaiProxy.isOfficialImageEnabledGlobally() && 
			false == sakaiProxy.isUsingOfficialImageButAlternateSelectionEnabled())
			|| preferencesLogic.getPreferencesRecordForUser(userId).isUseOfficialImage()) {
		
		setProfileImageLabel.setVisible(false);
		setProfileImageButton.setVisible(false);
	}
	
	imageOptionsContainer.add(setProfileImageButton);

	imageEditForm.add(imageOptionsContainer);

	removeConfirmContainer = new WebMarkupContainer("galleryRemoveImageConfirmContainer");
	removeConfirmContainer.setOutputMarkupId(true);
	removeConfirmContainer.setOutputMarkupPlaceholderTag(true);

	Label removeConfirmLabel = new Label("removePictureConfirmLabel",
			new ResourceModel("pictures.removepicture.confirm"));
	removeConfirmContainer.add(removeConfirmLabel);

	AjaxFallbackButton removeConfirmButton = createRemoveConfirmButton(
			userId, image, (int) galleryPageIndex, formFeedback,
			imageEditForm);
	//removeConfirmButton.add(new FocusOnLoadBehaviour());
	removeConfirmContainer.add(removeConfirmButton);

	AjaxFallbackButton removeCancelButton = createRemoveCancelButton(imageEditForm);
	removeConfirmContainer.add(removeCancelButton);

	removeConfirmContainer.setVisible(false);
	imageEditForm.add(removeConfirmContainer);
	
	setProfileImageConfirmContainer = new WebMarkupContainer("gallerySetProfileImageConfirmContainer");
	setProfileImageConfirmContainer.setOutputMarkupId(true);
	setProfileImageConfirmContainer.setOutputMarkupPlaceholderTag(true);
	
	Label setProfileImageConfirmLabel = new Label("setProfileImageConfirmLabel",
			new ResourceModel("pictures.setprofileimage.confirm"));
	setProfileImageConfirmContainer.add(setProfileImageConfirmLabel);

	
	AjaxFallbackButton setProfileImageConfirmButton = createSetProfileImageConfirmButton(
			userId, image, (int) galleryPageIndex, formFeedback,
			imageEditForm);
	
	//setProfileImageConfirmButton.add(new FocusOnLoadBehaviour());
	setProfileImageConfirmContainer.add(setProfileImageConfirmButton);
	
	AjaxFallbackButton setProfileImageCancelButton = createSetProfileImageCancelButton(imageEditForm);
	setProfileImageConfirmContainer.add(setProfileImageCancelButton);

	setProfileImageConfirmContainer.setVisible(false);
	imageEditForm.add(setProfileImageConfirmContainer);
	
	add(new GalleryImageRenderer("galleryImageMainRenderer", image
			.getMainResource()));
}
 
Example 17
Source File: MySearch.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
private void searchByInterest(
		final PageableListView<Person> resultsListView,
		final PagingNavigator searchResultsNavigator,
		WebMarkupContainer searchHistoryContainer,
		AjaxRequestTarget target, String searchTerm, boolean connections,
		String worksiteId) {
					
	//search SakaiPerson for matches
	results = new ArrayList<Person>(searchLogic.findUsersByInterest(searchTerm, connections, worksiteId));
	Collections.sort(results);
	
	int numResults = results.size();
	int maxResults = sakaiProxy.getMaxSearchResults();
	int maxResultsPerPage = sakaiProxy.getMaxSearchResultsPerPage();

	// set current page if previously-viewed search
	int currentPage = getCurrentPageNumber();
	
	//show the label wrapper
	numSearchResultsContainer.setVisible(true);
	
	//text
	//Strip the chars for display purposes
	String cleanedSearchTerm = ProfileUtils.stripAndCleanHtml(searchTerm);
	if(numResults == 0) {
		numSearchResults.setDefaultModel(new StringResourceModel("text.search.byinterest.no.results", null, new Object[]{ cleanedSearchTerm } ));
		resultsContainer.setVisible(false);
		searchResultsNavigator.setVisible(false);
	} else if (numResults == 1) {
		numSearchResults.setDefaultModel(new StringResourceModel("text.search.byinterest.one.result", null, new Object[]{ cleanedSearchTerm } ));
		resultsContainer.setVisible(true);
		searchResultsNavigator.setVisible(false);
	} else if (numResults == maxResults) {
		resultsListView.setCurrentPage(currentPage);
		numSearchResults.setDefaultModel(new StringResourceModel("text.search.toomany.results", null, new Object[]{ cleanedSearchTerm, maxResults, maxResults } ));
		resultsContainer.setVisible(true);
		searchResultsNavigator.setVisible(true);
	} else if (numResults > maxResultsPerPage) {
		resultsListView.setCurrentPage(currentPage);
		numSearchResults.setDefaultModel(new StringResourceModel("text.search.byinterest.paged.results", null, new Object[]{ numResults, resultsListView.getViewSize(), cleanedSearchTerm } ));
		resultsContainer.setVisible(true);
		searchResultsNavigator.setVisible(true);
	} else {
		resultsListView.setCurrentPage(currentPage);
		numSearchResults.setDefaultModel(new StringResourceModel("text.search.byinterest.all.results", null, new Object[]{ numResults, cleanedSearchTerm } ));
		resultsContainer.setVisible(true);
		searchResultsNavigator.setVisible(false);
	}
	
	if (null != target) {
		//repaint components
		target.add(searchField);
		target.add(searchTypeRadioGroup);
		target.add(connectionsCheckBox);
		target.add(worksiteCheckBox);
		target.add(worksiteChoice);
		target.add(clearButton);
		target.add(numSearchResultsContainer);
		clearButton.setVisible(true);
		target.add(resultsContainer);
		clearHistoryButton.setVisible(true);
		searchHistoryContainer.setVisible(true);
		target.add(searchHistoryContainer);
		target.appendJavaScript("setMainFrameHeight(window.name);");
	}
}
 
Example 18
Source File: LoginPage.java    From oodt with Apache License 2.0 4 votes vote down vote up
public LoginPage(PageParameters parameters) {
  super();
  final CurationApp app = (CurationApp)Application.get();
  final CurationSession session = (CurationSession)getSession();
  String ssoClass = app.getSSOImplClass();
  final AbstractWebBasedSingleSignOn sso = SingleSignOnFactory
      .getWebBasedSingleSignOn(ssoClass);
  sso.setReq(((WebRequest) RequestCycle.get().getRequest())
      .getHttpServletRequest());
  sso.setRes(((WebResponse) RequestCycle.get().getResponse())
      .getHttpServletResponse());
  
  String action = parameters.getString("action");
  String appNameString = app.getProjectName()+" CAS Curation Interface";
  add(new Label("login_project_name", appNameString));
  replace(new Label("crumb_name", "Login"));
  final WebMarkupContainer creds = new WebMarkupContainer("invalid_creds");
  final WebMarkupContainer connect = new WebMarkupContainer("connect_error");
  creds.setVisible(false);
  connect.setVisible(false);
  final TextField<String> loginUser = new TextField<String>("login_username", new Model<String>(""));
  final PasswordTextField pass = new PasswordTextField("password", new Model<String>(""));
  
  
  Form<?> form = new Form<Void>("login_form"){

    private static final long serialVersionUID = 1L;
    
    @Override
    protected void onSubmit() {
      String username = loginUser.getModelObject();
      String password = pass.getModelObject();
      
      if(sso.login(username, password)){
        session.setLoggedIn(true);
        session.setLoginUsername(username);
        setResponsePage(WorkbenchPage.class);
      }
      else{
        session.setLoggedIn(false);
        if (session.getLoginUsername() == null){
          connect.setVisible(true);
        }
        else{
          creds.setVisible(true);
        }
      }
      
    }
    
  };
  
  form.add(loginUser);
  form.add(pass);
  form.add(creds);
  form.add(connect);
  add(form);
  
  if(action.equals("logout")){
    sso.logout();
    session.setLoginUsername(null);
    session.setLoggedIn(false);
    PageParameters params = new PageParameters();
    params.add("action", "login");
    setResponsePage(LoginPage.class, params);
  }

}
 
Example 19
Source File: NavTopPanel.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public void init(final AbstractSecuredPage page)
{
  getMenu();
  this.favoritesMenu = FavoritesMenu.get();
  final WebMarkupContainer goMobile = new WebMarkupContainer("goMobile");
  add(goMobile);
  if (page.getMySession().isMobileUserAgent() == true) {
    goMobile.add(new BookmarkablePageLink<Void>("link", MenuMobilePage.class));
  } else {
    goMobile.setVisible(false);
  }
  add(new MenuConfig("menuconfig", getMenu(), favoritesMenu));
  @SuppressWarnings("serial")
  final Form<String> searchForm = new Form<String>("searchForm") {
    private String searchString;

    /**
     * @see org.apache.wicket.markup.html.form.Form#onSubmit()
     */
    @Override
    protected void onSubmit()
    {
      csrfTokenHandler.onSubmit();
      if (StringUtils.isNotBlank(searchString) == true) {
        final SearchPage searchPage = new SearchPage(new PageParameters(), searchString);
        setResponsePage(searchPage);
      }
      super.onSubmit();
    }
  };
  csrfTokenHandler = new CsrfTokenHandler(searchForm);
  add(searchForm);
  final TextField<String> searchField = new TextField<String>("searchField", new PropertyModel<String>(searchForm, "searchString"));
  WicketUtils.setPlaceHolderAttribute(searchField, getString("search.search"));
  searchForm.add(searchField);
  add(new BookmarkablePageLink<Void>("feedbackLink", FeedbackPage.class));
  {
    @SuppressWarnings("serial")
    final AjaxLink<Void> showBookmarkLink = new AjaxLink<Void>("showBookmarkLink") {
      /**
       * @see org.apache.wicket.ajax.markup.html.AjaxLink#onClick(org.apache.wicket.ajax.AjaxRequestTarget)
       */
      @Override
      public void onClick(final AjaxRequestTarget target)
      {
        bookmarkDialog.open(target);
        // Redraw the content:
        bookmarkDialog.redraw().addContent(target);
      }
    };
    add(showBookmarkLink);
    addBookmarkDialog();
  }
  {
    add(new Label("user", PFUserContext.getUser().getFullname()));
    if (accessChecker.isRestrictedUser() == true) {
      // Show ChangePaswordPage as my account for restricted users.
      final BookmarkablePageLink<Void> changePasswordLink = new BookmarkablePageLink<Void>("myAccountLink", ChangePasswordPage.class);
      add(changePasswordLink);
    } else {
      final BookmarkablePageLink<Void> myAccountLink = new BookmarkablePageLink<Void>("myAccountLink", MyAccountEditPage.class);
      add(myAccountLink);
    }
    final BookmarkablePageLink<Void> documentationLink = new BookmarkablePageLink<Void>("documentationLink", DocumentationPage.class);
    add(documentationLink);

    @SuppressWarnings("serial")
    final Link<String> logoutLink = new Link<String>("logoutLink") {
      @Override
      public void onClick()
      {
        LoginPage.logout((MySession) getSession(), (WebRequest) getRequest(), (WebResponse) getResponse(), userXmlPreferencesCache);
        setResponsePage(LoginPage.class);
      };
    };
    add(logoutLink);
  }
  addCompleteMenu();
  addFavoriteMenu();
}
 
Example 20
Source File: VisibilityToggler.java    From oodt with Apache License 2.0 4 votes vote down vote up
/**
 * @param id
 */
public VisibilityToggler(String id, String showLinkId, String hideLinkId,
    String moreId, final ListModel model) {
  super(id, model);

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

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

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

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

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

  add(showLink);
  add(hideLink);
}