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

The following are top voted examples for showing how to use org.apache.wicket.model.LoadableDetachableModel. 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: gitplex-mit   File: NumericPropertyEditor.java   Source Code and License 7 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	input = new TextField<Number>("input", Model.of(getModelObject()));
	input.setType(getPropertyDescriptor().getPropertyClass());
	add(input);

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

		@Override
		protected String load() {
			if (hasErrors(true))
				return " has-error";
			else
				return "";
		}
		
	}));
}
 
Example 2
Project: gitplex-mit   File: BlobIcon.java   Source Code and License 7 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 3
Project: gitplex-mit   File: BooleanPropertyEditor.java   Source Code and License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(input = new CheckBox("input", Model.of(getModelObject())));

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

		@Override
		protected String load() {
			if (hasErrors(true))
				return " has-error";
			else
				return "";
		}
		
	}));
	
}
 
Example 4
Project: gitplex-mit   File: PasswordPropertyEditor.java   Source Code and License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	input = new PasswordTextField("input", Model.of(getModelObject()));
	input.setRequired(false);
	input.setResetPassword(false);
	add(input);

	String autocomplete = EditableUtils.getAutocomplete(getPropertyDescriptor().getPropertyGetter());
	if (autocomplete != null)
		input.add(AttributeAppender.append("autocomplete", autocomplete));
	
	add(new AttributeAppender("class", new LoadableDetachableModel<String>() {

		@Override
		protected String load() {
			if (hasErrors(true))
				return " has-error";
			else
				return "";
		}
		
	}));
}
 
Example 5
Project: gitplex-mit   File: BranchSingleChoiceEditor.java   Source Code and License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
   	
   	BranchChoiceProvider branchProvider = new BranchChoiceProvider(new LoadableDetachableModel<Project>() {

		@Override
		protected Project load() {
			ProjectPage page = (ProjectPage) getPage();
			return page.getProject();
		}
   		
   	});

   	input = new BranchSingleChoice("input", getModel(), branchProvider);
   	input.setConvertEmptyInputStringToNull(true);
   	
       // add this to control allowClear flag of select2
   	input.setRequired(propertyDescriptor.isPropertyRequired());
       
       add(input);
}
 
Example 6
Project: gitplex-mit   File: BranchMultiChoiceEditor.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void onInitialize() {
	super.onInitialize();
	
   	BranchChoiceProvider branchProvider = new BranchChoiceProvider(new LoadableDetachableModel<Project>() {

		@Override
		protected Project load() {
			ProjectPage page = (ProjectPage) getPage();
			return page.getProject();
		}
   		
   	});

   	ArrayList<String> projectAndBranches = new ArrayList<>();
	if (getModelObject() != null) 
		projectAndBranches.addAll(getModelObject());
	
	input = new BranchMultiChoice("input", new Model(projectAndBranches), branchProvider);
       
       add(input);
}
 
Example 7
Project: gitplex-mit   File: CommitListPanel.java   Source Code and License 6 votes vote down vote up
public CommitListPanel(String id, IModel<Project> projectModel, IModel<List<RevCommit>> commitsModel) {
	super(id);
	this.projectModel = projectModel;
	this.commitsModel = new LoadableDetachableModel<List<RevCommit>>() {

		@Override
		protected List<RevCommit> load() {
			List<RevCommit> commits = commitsModel.getObject();
			if (commits.size() > WebConstants.MAX_DISPLAY_COMMITS)
				commits = commits.subList(commits.size()-WebConstants.MAX_DISPLAY_COMMITS, commits.size());
			CommitGraphUtils.sort(commits, 0);
			return separateByDate(commits);
		}

		@Override
		protected void onDetach() {
			commitsModel.detach();
			super.onDetach();
		}
		
	};
}
 
Example 8
Project: gitplex-mit   File: CommitMessageLabel.java   Source Code and License 6 votes vote down vote up
public CommitMessageLabel(String id, IModel<Project> projectModel, IModel<String> messageModel) {
	super(id, new LoadableDetachableModel<String>() {

		@Override
		protected String load() {
			String message = HtmlEscape.escapeHtml5(messageModel.getObject());
			for (CommitMessageTransformer transformer: GitPlex.getExtensions(CommitMessageTransformer.class)) {
				message = transformer.transform(projectModel.getObject(), message);
			}
			return message;
		}

		@Override
		protected void onDetach() {
			projectModel.detach();
			messageModel.detach();
			super.onDetach();
		}
		
	});
}
 
Example 9
Project: gitplex-mit   File: PrivilegeSourcePanel.java   Source Code and License 6 votes vote down vote up
public PrivilegeSourcePanel(String id, User user, Project project, ProjectPrivilege privilege) {
	super(id);

	Long userId = user.getId();
	userModel = new LoadableDetachableModel<User>() {

		@Override
		protected User load() {
			return GitPlex.getInstance(UserManager.class).load(userId);
		}
		
	};
	
	Long projectId = project.getId();
	projectModel = new LoadableDetachableModel<Project>() {

		@Override
		protected Project load() {
			return GitPlex.getInstance(ProjectManager.class).load(projectId);
		}
		
	};
	
	this.privilege = privilege;
}
 
Example 10
Project: gitplex-mit   File: RequestDetailPage.java   Source Code and License 6 votes vote down vote up
public RequestDetailPage(PageParameters params) {
	super(params);
	
	if (getProject().getDefaultBranch() == null) 
		throw new RestartResponseException(NoBranchesPage.class, paramsOf(getProject()));

	requestModel = new LoadableDetachableModel<PullRequest>() {

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

	};

	reviewUpdateId = requestModel.getObject().getLatestUpdate().getId();
}
 
Example 11
Project: gitplex-mit   File: SessionFeedbackPanel.java   Source Code and 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 12
Project: vlo-curation   File: ErrorPage.java   Source Code and License 6 votes vote down vote up
public ErrorPage(PageParameters parameters) {
    super(parameters);
    this.errorType = getErrorType(parameters.get(PAGE_PARAMETER_RESPONSE_CODE).toString());

    final PageParameters queryParams = new PageParameters(parameters).remove(PAGE_PARAMETER_RESPONSE_CODE);
    final boolean hasQuery = !queryParams.get(VloWebAppParameters.QUERY).isEmpty() || !queryParams.get(VloWebAppParameters.FILTER_QUERY).isEmpty();
    add(new BookmarkablePageLink("searchPage", FacetedSearchPage.class, queryParams)
            .add(new Label("label", hasQuery ? "Return to query" : "Go to the search page"))
    );

    final IModel<String> errorDescriptionModel = new LoadableDetachableModel<String>() {
        @Override
        protected String load() {
            return getDescriptionForError(errorType);
        }
    };
    add(new Label("description", errorDescriptionModel) {
        @Override
        protected void onConfigure() {
            setVisible(errorDescriptionModel.getObject() != null);
        }

    }.setEscapeModelStrings(false));
}
 
Example 13
Project: Intercloud   File: DiscoverItemsPage.java   Source Code and License 6 votes vote down vote up
public DiscoverItemsPage() {
    super();

    this.add(new DiscoverForm("discoverForm"));

    itemsContainer = new WebMarkupContainer("itemsContainer");
    itemsContainer.setOutputMarkupId(true);
    ComponentUtils.displayNone(itemsContainer);
    itemsContainer.add(new ItemsForm("itemsForm", new LoadableDetachableModel<List<String>>() {
        @Override
        protected List<String> load() {
            return discoItems;
        }
    }));
    this.add(itemsContainer);
}
 
Example 14
Project: Intercloud   File: ExamplePage.java   Source Code and License 6 votes vote down vote up
public ExamplePage() {
    super();

    this.add(new AttributeForm("attributeForm"));
    this.add(new KindRequestPanel("kindPanel",
            new Model<>(new MethodModel(null, null, null, null, null)),
            new LoadableDetachableModel<KindModel>() {
                @Override
                protected KindModel load() {
                    return createExampleKindModel();
                }
            }));
    this.add(new UriResponsePanel("uriResponsePanel", new LoadableDetachableModel<UriListRepresentationModel>() {
        @Override
        protected UriListRepresentationModel load() {
            return createEmapmleUriRepresentationModel();
        }
    }));

}
 
Example 15
Project: owsi-core-parent   File: AdministrationUserGroupPortfolioPage.java   Source Code and License 6 votes vote down vote up
public AdministrationUserGroupPortfolioPage(PageParameters parameters) {
	super(parameters);
	
	addBreadCrumbElement(new BreadCrumbElement(new ResourceModel("navigation.administration.usergroup"),
			AdministrationUserGroupPortfolioPage.linkDescriptor()));
	
	IModel<List<UserGroup>> userGroupListModel = new LoadableDetachableModel<List<UserGroup>>() {
		private static final long serialVersionUID = 1L;
		@Override
		protected List<UserGroup> load() {
			return userGroupService.list();
		}
	};
	
	UserGroupPopup addPopup = new UserGroupPopup("addPopup");
	
	add(
			new UserGroupPortfolioPanel("portfolio", userGroupListModel, propertyService.get(PORTFOLIO_ITEMS_PER_PAGE)),
			
			addPopup,
			new BlankLink("addButton")
					.add(new AjaxModalOpenBehavior(addPopup, MouseEvent.CLICK))
	);
}
 
Example 16
Project: owsi-core-parent   File: AbstractGenericListItemListPanel.java   Source Code and License 6 votes vote down vote up
protected IAddedCoreColumnState<T, S> addActionColumn(IAddedCoreColumnState<T, S> builder) {
	return builder
			.addColumn(new AbstractCoreColumn<T, S>(new Model<String>()) {
				private static final long serialVersionUID = 1L;
				
				@Override
				public void populateItem(Item<ICellPopulator<T>> cellItem, String componentId, final IModel<T> rowModel) {
					Component rowItem = DataTableUtil.getRowItem(cellItem);
					rowItem.add(new ClassAttributeAppender(new LoadableDetachableModel<String>() {
						private static final long serialVersionUID = 1L;
						
						@Override
						protected String load() {
							return rowModel.getObject().isEnabled() ? "enabled" : "disabled";
						}
					}));
					cellItem.add(new ItemActionsFragment(componentId, rowModel));
				}
			})
					.withClass("actions actions-2x");
}
 
Example 17
Project: owsi-core-parent   File: SortableListPage.java   Source Code and License 6 votes vote down vote up
public SortableListPage(PageParameters parameters) {
	super(parameters);
	
	addBreadCrumbElement(new BreadCrumbElement(new ResourceModel("widgets.menu.sortable"), SortableListPage.linkDescriptor()));
	
	IModel<List<User>> userListModel = new LoadableDetachableModel<List<User>>() {
		private static final long serialVersionUID = 9076101423574115944L;
		
		@Override
		protected List<User> load() {
			List<User> userList = userService.list();
			Collections.sort(userList, new Comparator<User>() {
				@Override
				public int compare(User o1, User o2) {
					return o1.getPosition().compareTo(o2.getPosition());
				}
			});
			
			return userList;
		}
	};
	
	SortableUserListPanel sortablePanel = new SortableUserListPanel("sortableUserPanel", userListModel);
	add(sortablePanel);
}
 
Example 18
Project: owsi-core-parent   File: GenericSelect2AjaxDropDownSingleChoice.java   Source Code and License 6 votes vote down vote up
@Override
protected void onInitialize() {
	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 19
Project: owsi-core-parent   File: GenericSelect2AjaxDropDownMultipleChoice.java   Source Code and License 6 votes vote down vote up
@Override
protected void onInitialize() {
	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 20
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 21
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 22
Project: owsi-core-parent   File: BooleanIcon.java   Source Code and License 6 votes vote down vote up
public BooleanIcon(String id, IModel<Boolean> booleanModel,
		IModel<String> trueIconClassModel, IModel<String> falseIconClassModel) {
	super(id, booleanModel);
	this.booleanModel = booleanModel;
	this.trueIconClassModel = trueIconClassModel;
	this.falseIconClassModel = falseIconClassModel;
	
	add(new ClassAttributeAppender(BOOLEAN_ICON_BASE_CLASS));
	add(new ClassAttributeAppender(new LoadableDetachableModel<String>() {
		private static final long serialVersionUID = 1L;
		
		@Override
		protected String load() {
			return Boolean.TRUE.equals(getBooleanModelObject()) ? getTrueIconClass() : getFalseIconClass();
		}
	}));
}
 
Example 23
Project: owsi-core-parent   File: NodeDropDownSingleChoice.java   Source Code and License 6 votes vote down vote up
protected NodeDropDownSingleChoice(String id, IModel<INode> model) {
	super(
			id,
			model,
			new ListModel<>(),
			CHOICE_RENDERER
	);
	setChoices(
			new LoadableDetachableModel<List<INode>>() {
				private static final long serialVersionUID = 1L;
				@Override
				protected List<INode> load() {
					return infinispanClusterService.getNodes();
				}
			}
	);
}
 
Example 24
Project: owsi-core-parent   File: ConsoleMaintenanceInfinispanLocksPanel.java   Source Code and License 6 votes vote down vote up
public LockAttributionFragment(String id, IModel<ILock> lockModel) {
	super(id, "lockAttribution", ConsoleMaintenanceInfinispanLocksPanel.this, lockModel);
	
	lockAttributionModel = new LoadableDetachableModel<ILockAttribution>() {
		private static final long serialVersionUID = 1L;
		@Override
		protected ILockAttribution load() {
			return infinispanClusterService.getLockAttribution(lockModel.getObject());
		}
	};
	
	add(
			new CoreLabel("address", BindingModel.of(lockAttributionModel, CoreWicketMoreBindings.iLockAttribution().owner())),
			new DateLabel("attributionDate", BindingModel.of(lockAttributionModel, CoreWicketMoreBindings.iLockAttribution().attributionDate()), DatePattern.REALLY_SHORT_DATETIME)
	);
}
 
Example 25
Project: owsi-core-parent   File: ConsoleMaintenanceInfinispanRolesRequestsPanel.java   Source Code and License 6 votes vote down vote up
public RoleAddressFragment(String id, IModel<IRole> roleModel) {
	super(id, "roleAddress", ConsoleMaintenanceInfinispanRolesRequestsPanel.this, roleModel);
	
	attributionModel = new LoadableDetachableModel<IAttribution>() {
		private static final long serialVersionUID = 1L;
		@Override
		protected IAttribution load() {
			return infinispanClusterService.getRoleRequestAttribution(roleModel.getObject());
		}
		
	};
	
	add(
			new CoreLabel("address", BindingModel.of(attributionModel, CoreWicketMoreBindings.iAttribution().owner()))
	);
}
 
Example 26
Project: owsi-core-parent   File: ConsoleMaintenanceInfinispanRolesRequestsPanel.java   Source Code and License 6 votes vote down vote up
public RoleAttributionDateFragment(String id, IModel<IRole> roleModel) {
	super(id, "roleAttributionDate", ConsoleMaintenanceInfinispanRolesRequestsPanel.this, roleModel);
	
	attributionModel = new LoadableDetachableModel<IAttribution>() {
		private static final long serialVersionUID = 1L;
		@Override
		protected IAttribution load() {
			return infinispanClusterService.getRoleRequestAttribution(roleModel.getObject());
		}
		
	};
	
	add(
			new DateLabel("attributionDate", BindingModel.of(attributionModel, CoreWicketMoreBindings.iAttribution().attributionDate()), DatePattern.REALLY_SHORT_DATETIME)
	);
}
 
Example 27
Project: owsi-core-parent   File: ConsoleMaintenanceInfinispanRolesPanel.java   Source Code and License 6 votes vote down vote up
public RoleAddressFragment(String id, IModel<IRole> roleModel) {
	super(id, "roleAddress", ConsoleMaintenanceInfinispanRolesPanel.this, roleModel);
	
	roleAttributionModel = new LoadableDetachableModel<IRoleAttribution>() {
		private static final long serialVersionUID = 1L;
		@Override
		protected IRoleAttribution load() {
			return infinispanClusterService.getRoleAttribution(roleModel.getObject());
		}
		
	};
	
	add(
			new CoreLabel("address", BindingModel.of(roleAttributionModel, CoreWicketMoreBindings.iRoleAttribution().owner()))
	);
}
 
Example 28
Project: owsi-core-parent   File: ConsoleMaintenanceInfinispanRolesPanel.java   Source Code and License 6 votes vote down vote up
public RoleAttributionDateFragment(String id, IModel<IRole> roleModel) {
	super(id, "roleAttributionDate", ConsoleMaintenanceInfinispanRolesPanel.this, roleModel);
	
	roleAttributionModel = new LoadableDetachableModel<IRoleAttribution>() {
		private static final long serialVersionUID = 1L;
		@Override
		protected IRoleAttribution load() {
			return infinispanClusterService.getRoleAttribution(roleModel.getObject());
		}
		
	};
	
	add(
			new DateLabel("attributionDate", BindingModel.of(roleAttributionModel, CoreWicketMoreBindings.iRoleAttribution().attributionDate()), DatePattern.REALLY_SHORT_DATETIME)
	);
}
 
Example 29
Project: owsi-core-parent   File: ConsoleMaintenanceQueueManagerNodePanel.java   Source Code and License 6 votes vote down vote up
public ConsoleMaintenanceQueueManagerNodePanel(String id) {
	super(id);
	setOutputMarkupId(true);

	nodesModel = new LoadableDetachableModel<List<INode>>() {
		private static final long serialVersionUID = 1L;
		@Override
		protected List<INode> load() {
			return infinispanClusterService.getAllNodes();
		}
	};

	add(
			new CollectionView<INode>("nodes", nodesModel, Models.<INode>serializableModelFactory()) {
				private static final long serialVersionUID = 1L;
				@Override
				protected void populateItem(Item<INode> item) {
					IModel<INode> nodeModel = item.getModel();
					item.add(
							new NodeFragment("node", nodeModel)
					);
				}
			}
	);
}
 
Example 30
Project: owsi-core-parent   File: ConsoleMaintenanceQueueManagerNodePanel.java   Source Code and License 6 votes vote down vote up
public QueueThreadsFragment(String id, String markupId, int nbThreads) {
	super(id, markupId, ConsoleMaintenanceQueueManagerNodePanel.this);
	setOutputMarkupId(true);

	nbThreadsModel = new LoadableDetachableModel<Integer>(){
		private static final long serialVersionUID = 1L;
		@Override
		protected Integer load() {
			return nbThreads;
		}
	};

	add(
			new CoreLabel("thread", nbThreadsModel)
	);
}
 
Example 31
Project: owsi-core-parent   File: AbstractOptGroupDropDownChoice.java   Source Code and License 6 votes vote down vote up
protected AbstractOptGroupDropDownChoice(String id, IModel<E> model, final IModel<? extends List<? extends E>> choicesModel,
			IChoiceRenderer<? super E> renderer, final Comparator<E> sorter) {
	super(id, model, choicesModel, renderer);
	setChoices(new LoadableDetachableModel<List<? extends E>>() {
		private static final long serialVersionUID = 1L;
		@Override
		protected List<? extends E> load() {
			List<? extends E> result = choicesModel.getObject();
			Collections.sort(result, sorter);
			return result;
		};
		@Override
		public void detach() {
			super.detach();
			choicesModel.detach();
		}
	});
}
 
Example 32
Project: webanno   File: CorrectionPage.java   Source Code and License 6 votes vote down vote up
private IModel<List<DecoratedObject<Project>>> getAllowedProjects()
{
    return new LoadableDetachableModel<List<DecoratedObject<Project>>>()
    {
        private static final long serialVersionUID = -2518743298741342852L;

        @Override
        protected List<DecoratedObject<Project>> load()
        {
            User user = userRepository.get(
                    SecurityContextHolder.getContext().getAuthentication().getName());
            List<DecoratedObject<Project>> allowedProject = new ArrayList<>();
            for (Project project : projectService.listProjects()) {
                if (SecurityUtil.isAnnotator(project, projectService, user)
                        && WebAnnoConst.PROJECT_TYPE_CORRECTION.equals(project.getMode())) {
                    allowedProject.add(DecoratedObject.of(project));
                }
            }
            return allowedProject;
        }
    };
}
 
Example 33
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 34
Project: ontopia   File: StartPage.java   Source Code and License 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 35
Project: ontopia   File: FieldsEditorExistingPanel.java   Source Code and License 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 36
Project: AppStash   File: ProductCatalogPage.java   Source Code and License 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 37
Project: syncope   File: ResourceProvisionPanel.java   Source Code and License 6 votes vote down vote up
private LoadableDetachableModel<List<String>> getAnyTypes() {
    return new LoadableDetachableModel<List<String>>() {

        private static final long serialVersionUID = 5275935387613157437L;

        @Override
        protected List<String> load() {
            List<String> anyTypes = new AnyTypeRestClient().list().stream().
                    filter(anyType -> !resourceTO.getProvision(anyType).isPresent()).
                    collect(Collectors.toList());
            if (resourceTO.getOrgUnit() == null) {
                anyTypes.add(SyncopeConstants.REALM_ANYTYPE);
            }

            Collections.sort(anyTypes, new AnyTypeRestClient.AnyTypeKeyComparator());
            return anyTypes;
        }
    };
}
 
Example 38
Project: nocket   File: DMDOnClickIndicatorAttributeModifier.java   Source Code and License 6 votes vote down vote up
/**
 * Constructor of the DMDOnClickIndicatorAttributeModifier. Just create a
 * new instance and attach it to a AjaxLink, AjaxSubmitLink or AjaxButton.
 * 
 * @param parent
 *            A parent component is needed to load the indicator text from a
 *            property file attached to the main page. We use the component
 *            to finde the page.
 */
public DMDOnClickIndicatorAttributeModifier(final Component parent) {
    super(ONCLICK, new LoadableDetachableModel<String>() {
        private static final long serialVersionUID = 1L;

        /**
         * @see org.apache.wicket.model.LoadableDetachableModel#load()
         */
        @Override
        protected String load() {
            return String.format(BLOCKER_SCRIPT, parent.getMarkupId(), getIndicatorUrl(),
                    parent.getString(LOADING_TITLE));
        }

        /**
         * @return url of the animated indicator image
         */
        private CharSequence getIndicatorUrl() {
            return RequestCycle.get().urlFor(new ResourceReferenceRequestHandler(INDICATOR));
        }
    });
}
 
Example 39
Project: wicket-crudifier   File: ObjectChoiceControlGroup.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("serial")
public ObjectChoiceControlGroup(String id, IModel<T> model) {
	super(id, model);
	
	IModel<List<? extends T>> modelList = new LoadableDetachableModel<List<? extends T>>() {
		private static final long serialVersionUID = -3995535290067544541L;

		@Override
		protected List<T> load() {
			if(entityProvider==null) throw new RuntimeException("no entity provider for '"+getPropertyName()+"'");
			return (List<T>) entityProvider.load();
		}
		
		
	};

	dropDown = new DropDownChoice<T>("input", getModel(), modelList){
		@Override
		public void error(IValidationError error) {
			MessageSource source = new MessageSource();
			Serializable message = error.getErrorMessage(source);
			
			super.error(message);
		}
	};
}
 
Example 40
Project: flex-ui   File: SortableRepositoryDataProvider.java   Source Code and License 6 votes vote down vote up
@Override
public IModel<T> model(final T object) {
    final Object id = object.getId();

    if (id == null) {
        return Model.of(object);
    }

    return new LoadableDetachableModel<T>() {
        private static final long serialVersionUID = 1L;

        @Override
        protected T load() {
            return getRepository().get(id);
        }
    };
}
 
Example 41
Project: gizmo-v3   File: SummaryPanel.java   Source Code and License 6 votes vote down vote up
public SummaryPanel(String id, final SummaryDataProvider provider, final IModel<WorkFilterDto> model) {
    super(id);

    add(new CssClassNameModifier("table-responsive"));

    setModel(new LoadableDetachableModel<SummaryPanelDto>() {

        @Override
        protected SummaryPanelDto load() {
            return provider.createSummary(model.getObject());
        }
    });

    setOutputMarkupId(true);
    initPanelLayout();
}
 
Example 42
Project: Jouve-Project   File: FacetFoldableSectionPanel.java   Source Code and License 6 votes vote down vote up
@Override
protected WebMarkupContainer newFoldableSectionContainer(String id) {
    WebMarkupContainer foldableSectionContainer = new WebMarkupContainer(id);
    foldableSectionContainer.add(new AttributeModifier("style", true, new LoadableDetachableModel() {
        @Override
        protected Object load() {
            String display;
            if (isOpened()) {
                display = "inline";
            } else {
                display = "none";
            }
            return "display:" + display;
        }
    }));
    return foldableSectionContainer;
}
 
Example 43
Project: Jouve-Project   File: AdminSearchResultFieldsPanel.java   Source Code and License 6 votes vote down vote up
public AdminSearchResultFieldsPanel(String id) {
    super(id);
    
    IModel collectionsModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
            return collectionServices.list();
        }
    };
    ListView collectionsListView = new ListView("collections", collectionsModel) {
        @Override
        protected void populateItem(ListItem item) {
            RecordCollection collection = (RecordCollection) item.getModelObject();
            Locale displayLocale = collection.getDisplayLocale(getLocale());
            item.add(new Label("collection", collection.getTitle(displayLocale)));
            item.add(new SearchResultFieldListPanel("crudPanel", collection));
        }
    };
    add(collectionsListView);
}
 
Example 44
Project: Jouve-Project   File: ConnectorResultClassesPanel.java   Source Code and License 6 votes vote down vote up
public ConnectorResultClassesPanel(String id) {
	super(id);
	IModel collectionsModel = new LoadableDetachableModel() {
		@Override
		protected Object load() {
			return ConstellioSpringUtils.getRecordCollectionServices().list();
		}
	};
	ListView collections = new ListView("collections", collectionsModel) {
		@Override
		protected void populateItem(ListItem item) {
			RecordCollection collection = (RecordCollection) item.getModelObject();
               Locale displayLocale = collection.getDisplayLocale(getLocale());
               String collectionTitle = collection.getTitle(displayLocale);
			item.add(new Label("name", collectionTitle));
			item.add(new ConnectorResultClassesListPanel("connectors", collection));
		}
	};
	add(collections);
}
 
Example 45
Project: Jouve-Project   File: CopyFieldListPanel.java   Source Code and License 6 votes vote down vote up
public CopyFieldListPanel(String id, final boolean dest) {
	super(id);

	this.dest = dest;
	setModel(new LoadableDetachableModel() {
		@Override
		protected Object load() {
			List<CopyFieldDTO> copyFields;
			AddEditIndexFieldPanel addEditIndexFieldPanel = 
				(AddEditIndexFieldPanel) findParent(AddEditIndexFieldPanel.class);
			if (dest) {
				copyFields = addEditIndexFieldPanel.getCopyFieldsDest();
			} else {
				copyFields = addEditIndexFieldPanel.getCopyFieldsSource();
			}
			return copyFields;
		}
	});
}
 
Example 46
Project: Jouve-Project   File: CollectionListPanel.java   Source Code and License 6 votes vote down vote up
public CollectionListPanel(String id) {
    super(id);
    setModel(new LoadableDetachableModel() {
        @Override
        protected Object load() {
            ConstellioUser currentUser = ConstellioSession.get().getUser();
            RecordCollectionServices collectionServices = ConstellioSpringUtils
                .getRecordCollectionServices();
            List<RecordCollection> collections = collectionServices.list();
            for (Iterator<RecordCollection> it = collections.iterator(); it.hasNext();) {
                RecordCollection collection = it.next();
                if (!currentUser.hasCollaborationPermission(collection) && 
                        !currentUser.hasAdminPermission(collection)) {
                    it.remove();
                }
            }
            return collections;
        }
    });
}
 
Example 47
Project: Jouve-Project   File: LoggingTextArea.java   Source Code and License 6 votes vote down vote up
public LoggingTextArea(String id, final IModel loggedLinesModel, long refreshDelayMillis) {
    super(id);
    setModel(new LoadableDetachableModel() {
        @SuppressWarnings("unchecked")
        @Override
        protected Object load() {
            StringBuffer sb = new StringBuffer();
            List<String> loggedLines = (List<String>) loggedLinesModel.getObject();
            for (String loggedLine : loggedLines) {
                sb.append(loggedLine + "\n");
            }
            return sb.toString();
        }

        @Override
        protected void onDetach() {
            loggedLinesModel.detach();
            super.onDetach();
        }
    });
    initComponents(refreshDelayMillis);
}
 
Example 48
Project: Jouve-Project   File: ConnectorInstanceConfigFormSnippet.java   Source Code and License 6 votes vote down vote up
private IModel getDefaultFormSnippetTextModel() {
    return new LoadableDetachableModel() {
        @Override
        protected Object load() {
            String configFormSnippetText;
            String connectorTypeName = (String) connectorTypeNameModel.getObject();
            if (connectorTypeName != null) {
                ConnectorManagerServices connectorManagerServices = ConstellioSpringUtils
                    .getConnectorManagerServices();
                Locale locale = getLocale();
                ConnectorManager connectorManager = connectorManagerServices.getDefaultConnectorManager();
                configFormSnippetText = connectorManagerServices.getConfigFormSnippet(connectorManager,
                    connectorTypeName, connectorName, locale);
            } else {
                configFormSnippetText = null;
            }
            return configFormSnippetText;
        }
    };
}
 
Example 49
Project: nextreports-server   File: PivotAreaPanel.java   Source Code and License 6 votes vote down vote up
@Override
	protected void onBeforeRender() {
//		System.out.println("PivotAreaPanel.onBeforeRender() " + getMarkupId());
		IModel<List<PivotField>> model = new LoadableDetachableModel<List<PivotField>>() {

			private static final long serialVersionUID = 1L;

			@Override
			protected List<PivotField> load() {
				return getPivotModel().getFields(area);
			}
			
		};

		values.setModel(model);
		
		super.onBeforeRender();
	}
 
Example 50
Project: nextreports-server   File: RunHistoryDetailPanel.java   Source Code and License 6 votes vote down vote up
public RunHistoryDetailPanel(String id, final RunReportHistory runHistory) {
      super(id);
                             
      add(new ContextImage("image", new LoadableDetachableModel<String>() {
	@Override
	protected String load() {
		String theme = settings.getSettings().getColorTheme();				
		return runHistory.isSuccess() ? "images/" + ThemesManager.getTickImage(theme, (NextServerApplication)getApplication()) : "images/delete.gif";
	}
}));

      add(new Label("messageTitle", new Model<String>(getString("ActionContributor.RunHistory.message"))));
      
      add(new MultiLineLabel("messageContent", new Model<String>(runHistory.getMessage())));
      
      add(new Label("valuesTitle", new Model<String>(getString("ActionContributor.RunHistory.runtime"))));

      String values = ReportUtil.getDebugParameters(runHistory.getParametersValues(), runHistory.getParametersDisplayNames());
      //values = values.replaceAll("\r\n", "<br>");

      add(new MultiLineLabel("valuesContent", new Model<String>(values)));               
  }
 
Example 51
Project: nextreports-server   File: AjaxCheckTablePanel.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void populateItem(final Item<ICellPopulator<T>> item, String componentId, IModel<T> rowModel) {
      	final HighlitableDataItem highlitableDataItem = item.findParent(HighlitableDataItem.class);
      	IModel<Boolean> checkBoxModel = new LoadableDetachableModel<Boolean>() {

		private static final long serialVersionUID = 1L;

		@Override
		protected Boolean load() {
			return highlitableDataItem.isHighlite();
		}
      		
      	};
      	if (isCheckable(rowModel)) {
      		item.add(new CheckBoxColumnPanel(componentId, checkBoxModel));
      		item.add(AttributeModifier.replace("class", "checkboxColumn"));
      	} else {
      		item.add(new EmptyPanel(componentId));
      	}
}
 
Example 52
Project: artifact-listener   File: ArtifactPortfolioPanel.java   Source Code and License 6 votes vote down vote up
@Override
protected void addItemColumns(Item<Artifact> item, IModel<? extends Artifact> artifactModel) {
	item.add(new Label("groupId", BindingModel.of(artifactModel, Binding.artifact().group().groupId())));
	Link<Void> artifactLink = AdministrationArtifactDescriptionPage.linkDescriptor(ReadOnlyModel.of(artifactModel))
			.link("artifactLink");
	artifactLink.add(new Label("artifactId", BindingModel.of(artifactModel, Binding.artifact().artifactId())));
	item.add(artifactLink);
	item.add(new Label("nbVersions", BindingModel.of(artifactModel, Binding.artifact().versions().size())));
	
	final IModel<ArtifactDeprecationStatus> deprecatedModel = BindingModel.of(artifactModel, Binding.artifact().deprecationStatus());
	item.add(new BooleanIcon("deprecated", new LoadableDetachableModel<Boolean>() {
		private static final long serialVersionUID = 1L;

		@Override
		protected Boolean load() {
			return ArtifactDeprecationStatus.DEPRECATED.equals(deprecatedModel.getObject());
		}
	}));
}
 
Example 53
Project: artifact-listener   File: DashboardPage.java   Source Code and License 6 votes vote down vote up
public DashboardPage(PageParameters parameters) {
	super(parameters);
	
	addBodyCssClass("force-vertical-scroll");
	
	addHeadPageTitleElement(new BreadCrumbElement(new ResourceModel("dashboard.pageTitle")));
	addBreadCrumbElement(new BreadCrumbElement(new ResourceModel("dashboard.pageTitle"), DashboardPage.linkDescriptor()));
	
	add(new Label("pageTitle", new ResourceModel("dashboard.pageTitle")));
	
	DashboardNotificationListViewPanel notificationsPanel = new DashboardNotificationListViewPanel("notificationPanel",
			new NotificationsModel(MavenArtifactNotifierSession.get().getUserModel()));
	add(notificationsPanel);
	
	DashboardArtifactPortfolioPanel artifactPanel = new DashboardArtifactPortfolioPanel("artifactPanel",
			new LoadableDetachableModel<Collection<FollowedArtifact>>() {
		private static final long serialVersionUID = -8484961470906264804L;

		@Override
		protected Collection<FollowedArtifact> load() {
			return userService.listFollowedArtifacts(MavenArtifactNotifierSession.get().getUser());
		}
	});
	add(artifactPanel);
}
 
Example 54
Project: artifact-listener   File: ArtifactVersionTagPanel.java   Source Code and License 6 votes vote down vote up
public ArtifactVersionTagPanel(String id, IModel<? extends String> model, boolean showPlaceholder) {
	super(id, model);
	IModel<String> cssClassModel = new LoadableDetachableModel<String>() {
		private static final long serialVersionUID = 1L;

		@Override
		protected String load() {
			String version = getModelObject();
			if (isFinalVersion(version)) {
				return CSS_FINAL_VERSION_TAG;
			}
			return CSS_NON_FINAL_VERSION_TAG;
		}
	};
	
	LabelWithPlaceholder latestVersionLabel = new LabelWithPlaceholder("latestVersion", model);
	latestVersionLabel.setHideIfEmpty(!showPlaceholder);
	latestVersionLabel.add(new ClassAttributeAppender(cssClassModel));
	add(latestVersionLabel);
}
 
Example 55
Project: artifact-listener   File: CustomArtifactVersionTagPanel.java   Source Code and License 6 votes vote down vote up
public CustomArtifactVersionTagPanel(String id, IModel<? extends String> model) {
	super(id, model);
	IModel<String> cssStyleModel = new LoadableDetachableModel<String>() {
		private static final long serialVersionUID = 1L;

		@Override
		protected String load() {
			String version = getModelObject();
			if (isFinalVersion(version)) {
				return STYLE_FINAL_VERSION_TAG;
			}
			return STYLE_NON_FINAL_VERSION_TAG;
		}
	};
	
	add(new CustomLabel("latestVersion", model, cssStyleModel.getObject()));
}
 
Example 56
Project: gitplex-mit   File: TagPatternEditor.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
   	
   	input = new TextField<String>("input", getModel());
   	
   	input.add(new TagPatternAssistBehavior(new AbstractReadOnlyModel<Project>() {

		@Override
		public Project getObject() {
			return ((ProjectPage) getPage()).getProject();
		}
   		
   	}));
       
       add(input);
       
	add(new AttributeAppender("class", new LoadableDetachableModel<String>() {

		@Override
		protected String load() {
			if (hasErrors(true))
				return " has-error";
			else
				return "";
		}
		
	}));
       
}
 
Example 57
Project: gitplex-mit   File: NullableBooleanPropertyEditor.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	String stringValue;
	if (getModelObject() != null) {
		if (getModelObject())
			stringValue = "yes";
		else
			stringValue = "no";
	} else {
		stringValue = null;
	}
	input = new DropDownChoice<String>("input", Model.of(stringValue), Lists.newArrayList("yes", "no"));
	
	input.setNullValid(true);
	
	add(input);

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

		@Override
		protected String load() {
			if (hasErrors(true))
				return " has-error";
			else
				return "";
		}
		
	}));
}
 
Example 58
Project: gitplex-mit   File: BranchPatternEditor.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
   	
   	input = new TextField<String>("input", getModel());
   	input.add(new BranchPatternAssistBehavior(new AbstractReadOnlyModel<Project>() {

		@Override
		public Project getObject() {
			return ((ProjectPage)getPage()).getProject();
		}
   		
   	}));
       
       add(input);
       
	add(new AttributeAppender("class", new LoadableDetachableModel<String>() {

		@Override
		protected String load() {
			if (hasErrors(true))
				return " has-error";
			else
				return "";
		}
		
	}));
       
}
 
Example 59
Project: gitplex-mit   File: PropertyContext.java   Source Code and License 5 votes vote down vote up
public static Component viewModel(String componentId, final IModel<Serializable> beanModel, String propertyName) {
	final PropertyContext<Serializable> editContext = of(beanModel.getObject().getClass(), propertyName);
	return editContext.renderForView(componentId, new LoadableDetachableModel<Serializable>() {

		@Override
		protected Serializable load() {
			return (Serializable) editContext.getPropertyValue(beanModel.getObject());
		}
		
	});
}
 
Example 60
Project: gitplex-mit   File: ConfirmativePasswordPropertyEditor.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	input = new PasswordTextField("input", Model.of(getModelObject()));
	input.setResetPassword(true);
	input.setRequired(false);
	add(input);
	
	inputAgain = new PasswordTextField("inputAgain", Model.of(getModelObject()));
	inputAgain.setResetPassword(true);
	inputAgain.setRequired(false);
	add(inputAgain);
	
	String autocomplete = EditableUtils.getAutocomplete(getPropertyDescriptor().getPropertyGetter());
	if (autocomplete != null) {
		input.add(AttributeAppender.append("autocomplete", autocomplete));
		inputAgain.add(AttributeAppender.append("autocomplete", autocomplete));
	}
	
	add(new AttributeAppender("class", new LoadableDetachableModel<String>() {

		@Override
		protected String load() {
			if (hasErrors(true))
				return " has-error";
			else
				return "";
		}
		
	}));
	
}