Java Code Examples for org.apache.wicket.model.LoadableDetachableModel

The following examples show how to use org.apache.wicket.model.LoadableDetachableModel. 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: inception   Source File: ActiveLearningSidebar.java    License: Apache License 2.0 6 votes vote down vote up
private Form<Void> createSessionControlForm()
{
    Form<Void> form = new Form<>(CID_SESSION_CONTROL_FORM);

    DropDownChoice<AnnotationLayer> layersDropdown = new BootstrapSelect<>(CID_SELECT_LAYER);
    layersDropdown.setModel(alStateModel.bind("layer"));
    layersDropdown.setChoices(LoadableDetachableModel.of(this::listLayersWithRecommenders));
    layersDropdown.setChoiceRenderer(new LambdaChoiceRenderer<>(AnnotationLayer::getUiName));
    layersDropdown.add(LambdaBehavior.onConfigure(it -> it.setEnabled(!alStateModel
        .getObject().isSessionActive())));
    layersDropdown.setOutputMarkupId(true);
    layersDropdown.setRequired(true);
    form.add(layersDropdown);
    
    form.add(new LambdaAjaxSubmitLink(CID_START_SESSION_BUTTON, this::actionStartSession)
            .add(visibleWhen(() -> !alStateModel.getObject().isSessionActive())));
    form.add(new LambdaAjaxLink(CID_STOP_SESSION_BUTTON, this::actionStopSession)
        .add(visibleWhen(() -> alStateModel.getObject().isSessionActive())));
    form.add(visibleWhen(() -> alStateModel.getObject().isDoExistRecommenders()));

    return form;
}
 
Example 2
Source Project: webanno   Source File: AnnotationInfoPanel.java    License: Apache License 2.0 6 votes vote down vote up
private Label createSelectedAnnotationTypeLabel()
{
    Label label = new Label("selectedAnnotationType", LoadableDetachableModel.of(() -> {
        try {
            AnnotationDetailEditorPanel editorPanel = findParent(
                    AnnotationDetailEditorPanel.class);
            return String.valueOf(selectFsByAddr(editorPanel.getEditorCas(),
                    getModelObject().getSelection().getAnnotation().getId())).trim();
        }
        catch (IOException e) {
            return "";
        }
    }));
    label.setOutputMarkupPlaceholderTag(true);
    // We show the extended info on the selected annotation only when run in development mode
    label.add(visibleWhen(() -> getModelObject().getSelection().getAnnotation().isSet()
            && DEVELOPMENT.equals(getApplication().getConfigurationType())));
    return label;
}
 
Example 3
public GazeteerList(String aId, IModel<? extends List<Gazeteer>> aChoices)
{
    super(aId, aChoices);
    
    setOutputMarkupPlaceholderTag(true);
    
    gazeteerList = new ListView<Gazeteer>("gazeteer", aChoices) {
        private static final long serialVersionUID = 2827701590781214260L;

        @Override
        protected void populateItem(ListItem<Gazeteer> aItem)
        {
            Gazeteer gazeteer = aItem.getModelObject();
            
            aItem.add(new Label("name", aItem.getModelObject().getName()));

            aItem.add(new LambdaAjaxLink("delete",
                _target -> actionDeleteGazeteer(_target, gazeteer)));

            aItem.add(new DownloadLink("download",
                    LoadableDetachableModel.of(() -> getGazeteerFile(gazeteer)),
                    gazeteer.getName()));
        }
    };
    add(gazeteerList);
}
 
Example 4
Source Project: the-app   Source File: ProductCatalogPage.java    License: Apache License 2.0 6 votes vote down vote up
private IModel<List<List<ProductInfo>>> productListModel() {
    return new LoadableDetachableModel<List<List<ProductInfo>>>() {
        @Override
        protected List<List<ProductInfo>> load() {
            List<List<ProductInfo>> lists = new ArrayList<>();
            List<ProductInfo> allProductInfos = new ArrayList<>(productService.findAll(productTypeModel.getObject()));
            while (allProductInfos.size() > 4) {
                List<ProductInfo> subList = allProductInfos.subList(0, 4);
                lists.add(new ArrayList<>(subList));
                allProductInfos.removeAll(subList);
            }
            lists.add(allProductInfos);
            return lists;
        }
    };
}
 
Example 5
Source Project: inception   Source File: SearchPage.java    License: Apache License 2.0 6 votes vote down vote up
public SearchForm(String id)
{
    super(id);
    
    setModel(CompoundPropertyModel.of(new SearchFormModel()));
    
    DropDownChoice<DocumentRepository> repositoryCombo = 
            new BootstrapSelect<DocumentRepository>("repository");
    repositoryCombo.setChoices(LoadableDetachableModel
            .of(() -> externalSearchService.listDocumentRepositories(project)));
    repositoryCombo.setChoiceRenderer(new ChoiceRenderer<DocumentRepository>("name"));
    repositoryCombo.setNullValid(false);
    add(repositoryCombo);
    
    if (!repositoryCombo.getChoices().isEmpty()) {
        repositoryCombo.setModelObject(repositoryCombo.getChoices().get(0));
    }
    
    add(new TextField<>("query", String.class));
    
    LambdaAjaxSubmitLink searchLink = new LambdaAjaxSubmitLink("submitSearch",
            this::actionSearch);
    add(searchLink);
    setDefaultButton(searchLink);
}
 
Example 6
Source Project: inception   Source File: ExternalResultDataProvider.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @see org.apache.wicket.markup.repeater.data.IDataProvider#model(java.lang.Object)
 */
@Override
public IModel<ExternalSearchResult> model(ExternalSearchResult object)
{
    return new LoadableDetachableModel<ExternalSearchResult>(object)
    {

        private static final long serialVersionUID = -8141568381625089300L;

        @Override
        protected ExternalSearchResult load()
        {
            return object;
        }
    };
}
 
Example 7
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 8
Source Project: ontopia   Source File: StartPage.java    License: Apache License 2.0 6 votes vote down vote up
private void addOtherTopicMapsSection() {
  // Alt. 2 Make a loadabledetachableModel for repository
  IModel<List<TopicMapReference>> eachNonOntopolyTopicMapModel = new LoadableDetachableModel<List<TopicMapReference>>() {
    @Override
    protected List<TopicMapReference> load() {
      OntopolyRepository repository = OntopolyContext.getOntopolyRepository();
      return repository.getNonOntopolyTopicMaps();
    }
  }; 

  ListView<TopicMapReference> eachTopicMap = new ListView<TopicMapReference>("eachNonOntopolyTopicMap", eachNonOntopolyTopicMapModel) {
    @Override
    protected void populateItem(ListItem<TopicMapReference> item) {
      final TopicMapReference ref = item.getModelObject();
      Map<String,String> pageParameterMap = new HashMap<String,String>();
      pageParameterMap.put("topicMapId",ref.getId());
      
      OntopolyBookmarkablePageLink link = new OntopolyBookmarkablePageLink(
          "nonOntTMLink", ConvertPage.class, new PageParameters(pageParameterMap), ref.getName());
      item.add(link);
    }
  };
  add(eachTopicMap);
}
 
Example 9
Source Project: webanno   Source File: ActionBar.java    License: Apache License 2.0 6 votes vote down vote up
public ActionBar(String aId)
{
    super(aId);

    add(new ListView<ActionBarExtension>("items",
            LoadableDetachableModel.of(this::getExtensions))
    {
        private static final long serialVersionUID = -3124915140030491897L;

        @Override
        protected void populateItem(ListItem<ActionBarExtension> aItem)
        {
            aItem.add(aItem.getModelObject().createActionBarItem("item",
                    (AnnotationPageBase) getPage()));
        }
    });
}
 
Example 10
Source Project: onedev   Source File: RequestStatusLabel.java    License: MIT License 6 votes vote down vote up
public RequestStatusLabel(String id, IModel<PullRequest> requestModel) {
	super(id, new LoadableDetachableModel<String>() {

		@Override
		protected String load() {
			PullRequest request = requestModel.getObject();
			CloseInfo closeInfo = request.getCloseInfo();
			if (closeInfo == null)
				return PullRequest.STATE_OPEN;
			else 
				return closeInfo.getStatus().toString();
		}
		
	});
	this.requestModel = requestModel;
}
 
Example 11
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 12
Source Project: onedev   Source File: InvalidPullRequestPage.java    License: MIT License 6 votes vote down vote up
public InvalidPullRequestPage(PageParameters params) {
	super(params);
	
	requestModel = new LoadableDetachableModel<PullRequest>() {

		@Override
		protected PullRequest load() {
			Long requestNumber = params.get(PARAM_REQUEST).toLong();
			PullRequest request = OneDev.getInstance(PullRequestManager.class).find(getProject(), requestNumber);
			if (request == null)
				throw new EntityNotFoundException("Unable to find pull request #" + requestNumber + " in project " + getProject());
			Preconditions.checkState(!request.isValid());
			return request;
		}

	};
}
 
Example 13
Source Project: onedev   Source File: PullRequestCommentedActivity.java    License: MIT License 6 votes vote down vote up
@Override
public Component render(String componentId, DeleteCallback deleteCallback) {
	return new PullRequestCommentedPanel(componentId, new LoadableDetachableModel<PullRequestComment>() {

		@Override
		protected PullRequestComment load() {
			return getComment();
		}
		
	}, new DeleteCallback() {
		
		@Override
		public void onDelete(AjaxRequestTarget target) {
			OneDev.getInstance(PullRequestCommentManager.class).delete(getComment());
			deleteCallback.onDelete(target);
		}
	});
}
 
Example 14
Source Project: onedev   Source File: MilestoneDetailPage.java    License: MIT License 6 votes vote down vote up
public MilestoneDetailPage(PageParameters params) {
	super(params);
	
	String idString = params.get(PARAM_MILESTONE).toString();
	if (StringUtils.isBlank(idString))
		throw new RestartResponseException(MilestoneListPage.class, MilestoneListPage.paramsOf(getProject(), false, null));
	
	Long milestoneId = Long.valueOf(idString);
	milestoneModel = new LoadableDetachableModel<Milestone>() {

		@Override
		protected Milestone load() {
			return OneDev.getInstance(MilestoneManager.class).load(milestoneId);
		}
		
	};
	
	query = params.get(PARAM_QUERY).toString();
}
 
Example 15
Source Project: ontopia   Source File: FieldsEditorExistingPanel.java    License: Apache License 2.0 6 votes vote down vote up
private static Component getCardinality(String id, final FieldAssignmentModel fam) {    
  LoadableDetachableModel<List<Cardinality>> cardinalityChoicesModel = new LoadableDetachableModel<List<Cardinality>>() {
    @Override
    protected List<Cardinality> load() {
      return Cardinality.getCardinalityTypes(fam.getFieldAssignment().getFieldDefinition().getTopicMap());
    }   
  };
  final IModel<Cardinality> cardModel = new MutableLoadableDetachableModel<Cardinality>() {
    @Override
    protected Cardinality load() {
      return fam.getFieldAssignment().getCardinality();
    }
    @Override
    public void setObject(Cardinality card) {
      fam.getFieldAssignment().getFieldDefinition().setCardinality(card);
      super.setObject(card);
    }
  };
  AjaxOntopolyDropDownChoice<Cardinality> choice = new AjaxOntopolyDropDownChoice<Cardinality>(id, cardModel,
      cardinalityChoicesModel, new TopicChoiceRenderer<Cardinality>());
  return choice;
}
 
Example 16
Source Project: onedev   Source File: SessionFeedbackPanel.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() {
			if (anyMessage(FeedbackMessage.ERROR) || anyMessage(FeedbackMessage.FATAL))
				return " error";
			else if (anyMessage(FeedbackMessage.WARNING))
				return " warning";
			else if (anyMessage(FeedbackMessage.SUCCESS))
				return " success";
			else
				return " info";
		}
		
	}));
}
 
Example 17
Source Project: onedev   Source File: RoleDetailPage.java    License: MIT License 6 votes vote down vote up
public RoleDetailPage(PageParameters params) {
	super(params);
	
	String roleIdString = params.get(PARAM_ROLE).toString();
	if (StringUtils.isBlank(roleIdString))
		throw new RestartResponseException(RoleListPage.class);
	
	roleModel = new LoadableDetachableModel<Role>() {

		@Override
		protected Role load() {
			return OneDev.getInstance(RoleManager.class).load(Long.valueOf(roleIdString));
		}
		
	};
}
 
Example 18
Source Project: onedev   Source File: GroupPage.java    License: MIT License 6 votes vote down vote up
public GroupPage(PageParameters params) {
	super(params);
	
	String groupIdString = params.get(PARAM_GROUP).toString();
	if (StringUtils.isBlank(groupIdString))
		throw new RestartResponseException(GroupListPage.class);
	
	Long groupId = Long.valueOf(groupIdString);
	
	groupModel = new LoadableDetachableModel<Group>() {

		@Override
		protected Group load() {
			return OneDev.getInstance(GroupManager.class).load(groupId);
		}
		
	};
}
 
Example 19
Source Project: onedev   Source File: UserPage.java    License: MIT License 6 votes vote down vote up
public UserPage(PageParameters params) {
	super(params);
	
	String userIdString = params.get(PARAM_USER).toString();
	if (StringUtils.isBlank(userIdString))
		throw new RestartResponseException(UserListPage.class);
	
	Long userId = Long.valueOf(userIdString);
	if (userId == User.SYSTEM_ID)
		throw new OneException("System user is not accessible");
	
	userModel = new LoadableDetachableModel<User>() {

		@Override
		protected User load() {
			return OneDev.getInstance(UserManager.class).load(userId);
		}
		
	};
}
 
Example 20
Source Project: inception   Source File: ActiveLearningSidebar.java    License: Apache License 2.0 5 votes vote down vote up
private Form<Void> createRecommendationOperationForm()
{
    recommendationForm = new Form<Void>(CID_RECOMMENDATION_FORM);
    recommendationForm.add(LambdaBehavior.visibleWhen(() -> {
        ActiveLearningUserState alState = alStateModel.getObject();
        return alState.isSessionActive() && alState.getSuggestion().isPresent();
    }));
    recommendationForm.setOutputMarkupPlaceholderTag(true);

    recommendationForm.add(createJumpToSuggestionLink());
    recommendationForm.add(new Label(CID_RECOMMENDED_PREDITION,
            LoadableDetachableModel.of(() -> alStateModel.getObject()
                    .getSuggestion().map(this::formatLabel).orElse(null))));
    recommendationForm.add(new Label(CID_RECOMMENDED_CONFIDENCE, () -> 
            alStateModel.getObject().getSuggestion()
                    .map(AnnotationSuggestion::getConfidence).orElse(null)));
    recommendationForm.add(new Label(CID_RECOMMENDED_DIFFERENCE, () -> 
            alStateModel.getObject().getCurrentDifference()
                    .map(Delta::getDelta).orElse(null)));
    recommendationForm.add((alStateModel.getObject().getLayer() != null
        && alStateModel.getObject().getSuggestion().isPresent()) ?
        initializeFeatureEditor() :
        new Label(CID_EDITOR).setVisible(false));

    recommendationForm.add(new LambdaAjaxButton<>(CID_ANNOTATE_BUTTON, this::actionAnnotate));
    recommendationForm.add(new LambdaAjaxLink(CID_SKIP_BUTTON, this::actionSkip));
    recommendationForm.add(new LambdaAjaxLink(CID_REJECT_BUTTON, this::actionReject));

    return recommendationForm;
}
 
Example 21
Source Project: inception   Source File: ActiveLearningSidebar.java    License: Apache License 2.0 5 votes vote down vote up
private LambdaAjaxLink createJumpToSuggestionLink()
{
    LambdaAjaxLink link = new LambdaAjaxLink(CID_RECOMMENDATION_COVERED_TEXT_LINK,
            this::actionJumpToSuggestion);
    link.add(new Label("leftContext",
            LoadableDetachableModel.of(() -> alStateModel.getObject().getLeftContext())));
    link.add(new Label("text", LoadableDetachableModel.of(() -> alStateModel.getObject()
            .getSuggestion().map(AnnotationSuggestion::getCoveredText).orElse(""))));
    link.add(new Label("rightContext",
            LoadableDetachableModel.of(() -> alStateModel.getObject().getRightContext())));
    return link;
}
 
Example 22
Source Project: the-app   Source File: HomePage.java    License: Apache License 2.0 5 votes vote down vote up
private Component topSellerPanel() {
    boolean userAuthorized = isUserAuthorized();
    String ressourceKey = userAuthorized ? "your.favorite.products.topic" : "category.top.seller.topic";
    String recommenderType = userAuthorized ? "FAVORITE_PRODUCTS" : "STARTPAGE_TOPSELLER";

    return new RecommendationItemListPanel("topSellerProductsContainer", feedback,recommenderType, new ResourceModel(ressourceKey),
            new LoadableDetachableModel<List<ProductInfo>>() {
                @Override
                protected List<ProductInfo> load() {
                    return recommendationService.getTopsellerRecommendations(4);
                }
            }) {
    };
}
 
Example 23
Source Project: inception   Source File: IRIValuePresenter.java    License: Apache License 2.0 5 votes vote down vote up
public IRIValuePresenter(String id, IModel<KBStatement> aModel, IModel<KnowledgeBase> aKBModel)
{
    super(id, aModel);
    
    kbModel = aKBModel;

    add(new IriInfoBadge("iriInfoBadge", LoadableDetachableModel
            .of(() -> ((IRI) getModelObject().getValue()).stringValue())));
    
    LambdaAjaxLink link = new LambdaAjaxLink("link",
        t -> actionIRILinkClicked(t, (IRI) aModel.getObject().getValue()));
    link.add(
            new Label("label", LoadableDetachableModel.of(() -> getLabel(aModel.getObject()))));
    add(link);
}
 
Example 24
Source Project: sakai   Source File: ExportPanel.java    License: Educational Community License v2.0 5 votes vote down vote up
private Component buildCustomDownloadLink() {
	return new DownloadLink("downloadCustomGradebook", new LoadableDetachableModel<File>() {
		private static final long serialVersionUID = 1L;

		@Override
		protected File load() {
			return buildFile(true);
		}

	}, buildFileName(true)).setCacheDuration(Duration.NONE).setDeleteAfterDownload(true).setOutputMarkupId(true);
}
 
Example 25
Source Project: inception   Source File: CurationSidebar.java    License: Apache License 2.0 5 votes vote down vote up
private Form<List<User>> createUserSelection()
{
    Form<List<User>> usersForm = new Form<List<User>>("usersForm",
            LoadableDetachableModel.of(this::listSelectedUsers));
    LambdaAjaxButton<Void> clearButton = new LambdaAjaxButton<>("clear", this::clearUsers);
    LambdaAjaxButton<Void> mergeButton = new LambdaAjaxButton<>("merge", this::merge);
    LambdaAjaxButton<Void> showButton = new LambdaAjaxButton<>("show", this::selectAndShow);
    usersForm.add(clearButton);
    usersForm.add(showButton);
    usersForm.add(mergeButton);
    selectedUsers = new CheckGroup<User>("selectedUsers", usersForm.getModelObject());
    users = new ListView<User>("users",
            LoadableDetachableModel.of(this::listUsers))
    {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<User> aItem)
        {
            aItem.add(new Check<User>("user", aItem.getModel()));
            aItem.add(new Label("name", aItem.getModelObject().getUsername()));

        }
    };
    selectedUsers.add(users);
    usersForm.add(selectedUsers);
    return usersForm;
}
 
Example 26
public StringMatchingRecommenderTraitsEditor(String aId, IModel<Recommender> aRecommender)
{
    super(aId, aRecommender);

    gazeteers = new GazeteerList("gazeteers", LoadableDetachableModel.of(this::listGazeteers));
    gazeteers.add(visibleWhen(() -> aRecommender.getObject() != null
            && aRecommender.getObject().getId() != null));
    add(gazeteers);
    
    FileInputConfig config = new FileInputConfig();
    config.initialCaption("Import gazeteers ...");
    config.allowedFileExtensions(asList("txt"));
    config.showPreview(false);
    config.showUpload(true);
    config.removeIcon("<i class=\"fa fa-remove\"></i>");
    config.uploadIcon("<i class=\"fa fa-upload\"></i>");
    config.browseIcon("<i class=\"fa fa-folder-open\"></i>");
    uploadField = new BootstrapFileInput("upload", new ListModel<>(), config) {
        private static final long serialVersionUID = -7072183979425490246L;

        @Override
        protected void onSubmit(AjaxRequestTarget aTarget)
        {
            actionUploadGazeteer(aTarget);
        }
    };
    uploadField.add(visibleWhen(() -> aRecommender.getObject() != null
            && aRecommender.getObject().getId() != null));
    add(uploadField);
}
 
Example 27
Source Project: webanno   Source File: ProjectConstraintsPanel.java    License: Apache License 2.0 5 votes vote down vote up
public SelectionForm(String aId, IModel<ConstraintSet> aModel)
{
    super(aId, aModel);

    LoadableDetachableModel<List<ConstraintSet>> rulesets = 
            new LoadableDetachableModel<List<ConstraintSet>>()
    {
        private static final long serialVersionUID = 1L;

        @Override
        protected List<ConstraintSet> load()
        {
            return constraintsService
                    .listConstraintSets(ProjectConstraintsPanel.this.getModelObject());
        }
    };
    
    add(new ListChoice<ConstraintSet>("ruleset", SelectionForm.this.getModel(), rulesets) {
        private static final long serialVersionUID = 1L;
        
        {
            setChoiceRenderer(new ChoiceRenderer<>("name"));
            setNullValid(false);
            add(new FormComponentUpdatingBehavior());
        }
        
        @Override
        protected CharSequence getDefaultChoice(String aSelectedValue)
        {
            return "";
        }
    });
}
 
Example 28
Source Project: inception   Source File: DocumentMetadataSidebar.java    License: Apache License 2.0 5 votes vote down vote up
public DocumentMetadataSidebar(String aId, IModel<AnnotatorState> aModel,
        AnnotationActionHandler aActionHandler, CasProvider aCasProvider,
        AnnotationPage aAnnotationPage)
{
    super(aId, aModel, aActionHandler, aCasProvider, aAnnotationPage);

    IModel<Project> project = LoadableDetachableModel.of(() -> aModel.getObject().getProject());
    IModel<SourceDocument> sourceDocument = LoadableDetachableModel
            .of(() -> aModel.getObject().getDocument());
    IModel<String> username = LoadableDetachableModel
            .of(() -> aModel.getObject().getUser().getUsername());
    
    add(new DocumentMetadataAnnotationSelectionPanel("annotations", project, sourceDocument,
            username, aCasProvider, aAnnotationPage, aActionHandler, getModelObject()));
}
 
Example 29
Source Project: inception   Source File: ProjectDashboardPage.java    License: Apache License 2.0 5 votes vote down vote up
protected void commonInit()
{
    setStatelessHint(true);
    setVersioned(false);
    
    // In case we restore a saved session, make sure the user actually still exists in the DB.
    // redirect to login page (if no usr is found, admin/admin will be created)
    User user = userRepository.getCurrentUser();
    if (user == null) {
        setResponsePage(LoginPage.class);
    }
    
    // If no project has been selected yet, redirect to the project overview page. This allows
    // us to keep the ProjectDashboardPage as the application home page.
    Project project = Session.get().getMetaData(CURRENT_PROJECT);
    if (project == null) {
        setResponsePage(ProjectsOverviewPage.class);
    }
    
    // if not either a curator or annotator, display warning message
    if (
            !annotationEnabeled(projectService, user, PROJECT_TYPE_ANNOTATION) && 
            !annotationEnabeled(projectService, user, PROJECT_TYPE_AUTOMATION) && 
            !annotationEnabeled(projectService, user, PROJECT_TYPE_CORRECTION) && 
            !curationEnabeled(projectService, user)) 
    {
        info("You are not member of any projects to annotate or curate");
    }
    
    menu = new DashboardMenu("menu", LoadableDetachableModel.of(this::getMenuItems));
    add(menu);
    
    Model<Project> currentProject = Model.of(getProject());
    add(new CurrentProjectDashlet("currentProjectDashlet", currentProject));
    add(new ActivitiesDashlet("activitiesDashlet", currentProject));
}
 
Example 30
Source Project: inception   Source File: SystemStatusDashlet.java    License: Apache License 2.0 5 votes vote down vote up
public SystemStatusDashlet(String aId)
{
    super(aId);

    add(new Label("activeUsers",
            LoadableDetachableModel.of(() -> sessionRegistry.getAllPrincipals().size())));
}