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

The following are top voted examples for showing how to use org.apache.wicket.model.AbstractReadOnlyModel. 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: ReferencedPanel.java   Source Code and License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	PullRequestReference reference = getModelObject();
	
	User userForDisplay = User.getForDisplay(reference.getUser(), reference.getUserName());
	add(new AvatarLink("avatar", userForDisplay));
	add(new UserLink("name", userForDisplay));
	add(new Label("age", DateUtils.formatAge(reference.getDate())));
	
	ViewStateAwarePageLink<Void> link = new ViewStateAwarePageLink<Void>("link", 
			RequestOverviewPage.class, RequestOverviewPage.paramsOf(reference.getReferencedBy()));
	link.add(new Label("number", "#" + reference.getReferencedBy().getNumber()));
	link.add(new Label("title", reference.getReferencedBy().getTitle()));
	add(link);
	
	add(new RequestStatusPanel("status", new AbstractReadOnlyModel<PullRequest>() {

		@Override
		public PullRequest getObject() {
			return ReferencedPanel.this.getModelObject().getReferencedBy();
		}
		
	}));
}
 
Example 2
Project: gitplex-mit   File: CommentedPanel.java   Source Code and License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	add(new UserLink("user", User.getForDisplay(getComment().getUser(), getComment().getUserName())));
	add(new Label("age", DateUtils.formatAge(getComment().getDate())));
	
	add(new SinceChangesLink("changes", new AbstractReadOnlyModel<PullRequest>() {

		@Override
		public PullRequest getObject() {
			return getComment().getRequest();
		}

	}, getComment().getDate()));
	
	add(newViewer());

	setOutputMarkupId(true);
}
 
Example 3
Project: engerek   File: TaskResultTabPanel.java   Source Code and License 6 votes vote down vote up
private List<IColumn<OperationResult, String>> initResultColumns() {
	List<IColumn<OperationResult, String>> columns = new ArrayList<IColumn<OperationResult, String>>();
	columns.add(new PropertyColumn<>(createStringResource("pageTaskEdit.opResult.token"), "token"));
	columns.add(new PropertyColumn<>(createStringResource("pageTaskEdit.opResult.operation"), "operation"));
	columns.add(new PropertyColumn<>(createStringResource("pageTaskEdit.opResult.status"), "status"));
	columns.add(new AbstractColumn<OperationResult, String>(createStringResource("pageTaskEdit.opResult.message"), "message") {
		@Override
		public void populateItem(Item<ICellPopulator<OperationResult>> cellItem, String componentId,
				IModel<OperationResult> rowModel) {
			Label label = new Label(componentId, new AbstractReadOnlyModel<String>() {
				@Override
				public String getObject() {
					return WebComponentUtil.nl2br(rowModel.getObject().getMessage());
				}
			});
			label.setEscapeModelStrings(false);
			cellItem.add(label);
		}
	});
	//columns.add(new PropertyColumn(createStringResource("pageTaskEdit.opResult.message"), "message"));
	return columns;
}
 
Example 4
Project: engerek   File: PageTaskEdit.java   Source Code and License 6 votes vote down vote up
protected void initLayout() {
	refreshModel = new Model(new AutoRefreshDto());
	refreshModel.getObject().setInterval(getRefreshInterval());

	IModel<PrismObject<TaskType>> prismObjectModel = new AbstractReadOnlyModel<PrismObject<TaskType>>() {
		@Override
		public PrismObject<TaskType> getObject() {
			return objectWrapperModel.getObject().getObject();
		}
	};
	final TaskSummaryPanel summaryPanel = new TaskSummaryPanel(ID_SUMMARY_PANEL, prismObjectModel, refreshModel, this);
	summaryPanel.setOutputMarkupId(true);
	add(summaryPanel);

	mainPanel = new TaskMainPanel(ID_MAIN_PANEL, objectWrapperModel, taskDtoModel, showAdvancedFeaturesModel, this);
	mainPanel.setOutputMarkupId(true);
	add(mainPanel);

	summaryPanel.getRefreshPanel().startRefreshing(this, null);
}
 
Example 5
Project: engerek   File: PageDebugView.java   Source Code and License 6 votes vote down vote up
@Override
protected IModel<String> createPageTitleModel() {
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (model == null) {
                return "";
            }
            ObjectViewDto object;
            try {
                object = model.getObject();
            } catch (RuntimeException e) {
                // e.g. when the object is unreadable
                LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get object", e);
                return "";
            }
            if (object == null) {
        		return "";
        	} else {
                return createStringResource("PageDebugView.title", object.getName()).getString();
            }
        }
    };
}
 
Example 6
Project: engerek   File: FocusProjectionsTabPanel.java   Source Code and License 6 votes vote down vote up
private Popupable getDeleteProjectionPopupContent() {
	ConfirmationPanel dialog = new ConfirmationPanel(getPageBase().getMainPopupBodyId(),
			new AbstractReadOnlyModel<String>() {
				private static final long serialVersionUID = 1L;

				@Override
				public String getObject() {
					return createStringResource("pageAdminFocus.message.deleteAccountConfirm",
							getSelectedProjections(projectionModel).size()).getString();
				}
			}) {
		private static final long serialVersionUID = 1L;

		@Override
		public void yesPerformed(AjaxRequestTarget target) {
			ModalWindow modalWindow = findParent(ModalWindow.class);
			if (modalWindow != null) {
				modalWindow.close(target);
				deleteAccountConfirmedPerformed(target, getSelectedProjections(projectionModel));
			}
		}
	};
	return dialog;
}
 
Example 7
Project: engerek   File: CountablePanelTab.java   Source Code and License 6 votes vote down vote up
@Override
public IModel<String> getCountModel() {
    // We cannot get the count information from the panel.
    // When we display the tab the panel does not exist yet.
    // The panel is created only when the tab is clicked.

    return new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getCount();
        }
    };
}
 
Example 8
Project: engerek   File: AssignmentEditorPanel.java   Source Code and License 6 votes vote down vote up
protected IModel<String> createAssignmentNameLabelModel(final boolean isManager) {
	return new AbstractReadOnlyModel<String>() {

		@Override
		public String getObject() {
			if (getModel() != null && getModel().getObject() != null) {
				AssignmentEditorDto dto = getModelObject();

				if (dto.getName() != null) {
					StringBuilder name = new StringBuilder(dto.getName());
					if (isManager) {
						name.append(" - Manager");
					}
					return name.toString();
				}

				if (dto.getAltName() != null) {
					return getString("AssignmentEditorPanel.name.focus");
				}
			}

			return getString("AssignmentEditorPanel.name.noTarget");
		}
	};
}
 
Example 9
Project: engerek   File: AssignmentEditorPanel.java   Source Code and License 6 votes vote down vote up
protected IModel<String> createImageTypeModel(final IModel<AssignmentEditorDto> model) {
	return new AbstractReadOnlyModel<String>() {
		private static final long serialVersionUID = 1L;

		@Override
		public String getObject() {
			AssignmentEditorDto assignmentEditorDto = model.getObject();

			PrismObject targetObject = null;
			try {
				targetObject = getTargetObject(assignmentEditorDto);
			} catch (Exception ex) {
				LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object", ex);
				// Otherwise ignore, will be pocessed by the fallback code
				// below
			}

			if (targetObject == null) {
				AssignmentEditorDtoType type = assignmentEditorDto.getType();
				return type.getIconCssClass();
			} else {
				return WebComponentUtil.createDefaultIcon(targetObject);
			}
		}
	};
}
 
Example 10
Project: vlo-curation   File: ContentSearchFormPanel.java   Source Code and License 6 votes vote down vote up
private IModel<String> createJsonModel(final IModel<SolrDocument> model, final IModel<String> endpointModel) {
    // Prepare a JSON object that holds the CQL endpoint and the document self link
    return new AbstractReadOnlyModel<String>() {
        @Override
        public String getObject() {
            final String endPoint = endpointModel.getObject();
            final Object selfLink = model.getObject().getFirstValue(FacetConstants.FIELD_SELF_LINK);
            try {
                final JSONObject json = new JSONObject();
                json.put(endPoint, new JSONArray(new Object[]{selfLink}));
                return json.toString(2);
            } catch (JSONException ex) {
                logger.warn("Could not create JSON for aggregation context with endpoint '{}' and docId '{}'", endPoint, selfLink, ex);
                return null;
            }
        }

        @Override
        public void detach() {
            super.detach();
            endpointModel.detach();
        }

    };
}
 
Example 11
Project: engerek   File: ColumnUtils.java   Source Code and License 6 votes vote down vote up
private static <T extends ObjectType> IColumn<SelectableBean<T>, String> getEmptyIconColumn(){
	return new IconColumn<SelectableBean<T>>(createIconColumnHeaderModel()) {
		private static final long serialVersionUID = 1L;

		@Override
		protected IModel<String> createIconModel(final IModel<SelectableBean<T>> rowModel) {
			return new AbstractReadOnlyModel<String>() {
				private static final long serialVersionUID = 1L;

				@Override
				public String getObject() {
					return "";
				}
			};
		}
	};
}
 
Example 12
Project: engerek   File: ColumnUtils.java   Source Code and License 6 votes vote down vote up
private static <T extends ObjectType> IColumn<SelectableBean<T>, String> getRoleIconColumn(){
	return new IconColumn<SelectableBean<T>>(createIconColumnHeaderModel()) {
		private static final long serialVersionUID = 1L;

		@Override
		protected IModel<String> createIconModel(final IModel<SelectableBean<T>> rowModel) {
			return new AbstractReadOnlyModel<String>() {
				private static final long serialVersionUID = 1L;

				@Override
				public String getObject() {
					T role = rowModel.getObject().getValue();
					return role != null ? WebComponentUtil.createRoleIcon(role.asPrismContainer()) : null;
				}
			};
		}
	};
}
 
Example 13
Project: engerek   File: ColumnUtils.java   Source Code and License 6 votes vote down vote up
private static <T extends ObjectType> IColumn<SelectableBean<T>, String> getServiceIconColumn(){
	return new IconColumn<SelectableBean<T>>(createIconColumnHeaderModel()) {

		/**
		 *
		 */
		private static final long serialVersionUID = 1L;

		@Override
		protected IModel<String> createIconModel(final IModel<SelectableBean<T>> rowModel) {
			return new AbstractReadOnlyModel<String>() {

				/**
				 *
				 */
				private static final long serialVersionUID = 1L;

				@Override
				public String getObject() {
					T service = rowModel.getObject().getValue();
					return service != null ? WebComponentUtil.createServiceIcon(service.asPrismContainer()) : null;
				}
			};
		}
	};
}
 
Example 14
Project: engerek   File: ColumnUtils.java   Source Code and License 6 votes vote down vote up
private static <T extends ObjectType> IColumn<SelectableBean<T>, String> getTaskIconColumn(){
	return new IconColumn<SelectableBean<T>>(createIconColumnHeaderModel()) {

		/**
		 *
		 */
		private static final long serialVersionUID = 1L;

		@Override
		protected IModel<String> createIconModel(final IModel<SelectableBean<T>> rowModel) {
			return new AbstractReadOnlyModel<String>() {

				private static final long serialVersionUID = 1L;

				@Override
				public String getObject() {
					T task = rowModel.getObject().getValue();
					return task != null ? WebComponentUtil.createTaskIcon(task.asPrismContainer()) : null;
				}
			};
		}
	};
}
 
Example 15
Project: engerek   File: ColumnUtils.java   Source Code and License 6 votes vote down vote up
private static <T extends ObjectType> IColumn<SelectableBean<T>, String> getAccessCertificationDefinitionIconColumn(){
	return new IconColumn<SelectableBean<T>>(createIconColumnHeaderModel()) {
		private static final long serialVersionUID = 1L;

		@Override
		protected IModel<String> createIconModel(final IModel<SelectableBean<T>> rowModel) {
			return new AbstractReadOnlyModel<String>() {
				private static final long serialVersionUID = 1L;

				@Override
				public String getObject() {
					return GuiStyleConstants.CLASS_OBJECT_CERT_DEF_ICON + " " + GuiStyleConstants.CLASS_ICON_STYLE_NORMAL;
				}
			};
		}
	};
}
 
Example 16
Project: engerek   File: ItemApprovalHistoryPanel.java   Source Code and License 6 votes vote down vote up
private void initLayout(UserProfileStorage.TableId tableId, int pageSize) {

        add(new DecisionsPanel(ID_DECISIONS_DONE, new AbstractReadOnlyModel<List<DecisionDto>>() {
            @Override
            public List<DecisionDto> getObject() {
                List<DecisionDto> rv = new ArrayList<>();
                WfContextType wfContextType = getModelObject();
				if (wfContextType == null) {
					return rv;
				}
				if (!wfContextType.getEvent().isEmpty()) {
					wfContextType.getEvent().forEach(e -> addIgnoreNull(rv, DecisionDto.create(e, getPageBase())));
				} else {
					ItemApprovalProcessStateType instanceState = WfContextUtil.getItemApprovalProcessInfo(wfContextType);
					if (instanceState != null) {
						instanceState.getDecisions().forEach(d -> addIgnoreNull(rv, DecisionDto.create(d)));
					}
				}
                return rv;
            }
        }, tableId, pageSize));

    }
 
Example 17
Project: engerek   File: LoggingConfigPanel.java   Source Code and License 6 votes vote down vote up
private IModel<List<String>> createNewLoggerAppendersListModel(){
    return new AbstractReadOnlyModel<List<String>>() {

        @Override
        public List<String> getObject() {
            List<String> list = new ArrayList<>();

            LoggingDto dto = getModel().getObject();

            for (AppenderConfiguration appender : dto.getAppenders()) {
                list.add(appender.getName());
            }

            return list;
        }
    };
}
 
Example 18
Project: engerek   File: PageCertCampaigns.java   Source Code and License 6 votes vote down vote up
private IModel<String> createDeleteSelectedCampaignsConfirmString() {
	return new AbstractReadOnlyModel<String>() {

		@Override
		public String getObject() {
			final List<Selectable> selectedData = WebComponentUtil.getSelectedData(getCampaignsTable());
			if (selectedData.size() > 1) {
				return createStringResource("PageCertCampaigns.message.deleteCampaignConfirmMultiple",
						selectedData.size()).getString();
			} else if (selectedData.size() == 1) {
				return createStringResource("PageCertCampaigns.message.deleteCampaignConfirmSingle",
						((CertCampaignListItemDto) selectedData.get(0)).getName()).getString();
			} else {
				return "EMPTY";
			}
		}
	};
}
 
Example 19
Project: engerek   File: BootstrapLabel.java   Source Code and License 6 votes vote down vote up
public BootstrapLabel(String id, IModel<String> model, final IModel<State> state) {
    super(id, model);

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

        @Override
        public String getObject() {
            StringBuilder sb = new StringBuilder();
            sb.append("label label-");

            State s = state.getObject();
            if (s == null) {
                s = State.DEFAULT;
            }
            sb.append(s.name().toLowerCase());

            return sb.toString();
        }
    }));
}
 
Example 20
Project: engerek   File: SynchronizationStep.java   Source Code and License 6 votes vote down vote up
private IModel<String> createObjectSyncTypeDisplayModel(final ObjectSynchronizationType syncObject){
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            StringBuilder sb = new StringBuilder();

            if (syncObject != null) {
                sb.append(syncObject.getName() != null ? syncObject.getName() + " " : "");
	SchemaHandlingStep.addKindAndIntent(sb, syncObject.getKind(), syncObject.getIntent());
	sb.append(" => ");
	sb.append(getTypeDisplayName(ResourceTypeUtil.fillDefaultFocusType(syncObject.getFocusType())));
            }

            return sb.toString();
        }
    };
}
 
Example 21
Project: engerek   File: SchemaHandlingStep.java   Source Code and License 6 votes vote down vote up
private IModel<String> createObjectTypeDisplayModel(final ResourceObjectTypeDefinitionTypeDto objectType){
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            StringBuilder sb = new StringBuilder();

            if (objectType != null) {
                ResourceObjectTypeDefinitionType object = objectType.getObjectType();
                sb.append(object.getDisplayName() != null ? object.getDisplayName() + " " : "");
	addKindAndIntent(sb, object.getKind(), object.getIntent());
	sb.append(" -> ");
	sb.append(object.getObjectClass() != null ? object.getObjectClass().getLocalPart() : "");
}
            return sb.toString();
        }
    };
}
 
Example 22
Project: engerek   File: ResourceDependencyEditor.java   Source Code and License 6 votes vote down vote up
private IModel<String> createCollapseItemId(final ListItem<ResourceObjectTypeDependencyType> item, final boolean appendSelector){
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            StringBuilder sb = new StringBuilder();

            if(appendSelector){
                sb.append("#");
            }

            sb.append("collapse").append(item.getId());

            return sb.toString();
        }
    };
}
 
Example 23
Project: engerek   File: ResourceProtectedEditor.java   Source Code and License 6 votes vote down vote up
private IModel<String> createCollapseItemId(final ListItem<ResourceObjectPatternType> item,final boolean includeSelector){
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            StringBuilder sb = new StringBuilder();

            if(includeSelector){
                sb.append("#");
            }

            sb.append("collapse").append(item.getId());

            return sb.toString();
        }
    };
}
 
Example 24
Project: engerek   File: WizardHelpDialog.java   Source Code and License 6 votes vote down vote up
public void initLayout(WebMarkupContainer content){
    Label helpLabel = new Label(ID_HELP, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getString(determineHelpKey());
        }
    });
    helpLabel.setEscapeModelStrings(false);
    content.add(helpLabel);

    AjaxLink ok = new AjaxLink(ID_BUTTON_OK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            closePerformed(target);
        }
    };
    content.add(ok);
}
 
Example 25
Project: engerek   File: FocusSummaryPanel.java   Source Code and License 6 votes vote down vote up
@Override
protected IModel<AbstractResource> getPhotoModel() {
	return new AbstractReadOnlyModel<AbstractResource>() {
		private static final long serialVersionUID = 1L;
		
		@Override
		public AbstractResource getObject() {
			byte[] jpegPhoto = null;
			O object = getModel().getObject();
			if (object instanceof FocusType) {
				jpegPhoto = ((FocusType) object).getJpegPhoto();
			}
			if (jpegPhoto == null) {
				return null;
			} else {
				return new ByteArrayResource("image/jpeg", jpegPhoto);
			}
		}
	};
}
 
Example 26
Project: engerek   File: TextDetailsPanel.java   Source Code and License 6 votes vote down vote up
public TextDetailsPanel(String id, IModel<T> model, Class clazz){
    super(id);

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

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

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

        @Override
        public String getDataPlacement(){
            return "bottom";
        }
    });
    add(details);
}
 
Example 27
Project: engerek   File: PageInternals.java   Source Code and License 6 votes vote down vote up
private void initCounters() {
   	
   	ListView<InternalCounters> countersTable = new ListView<InternalCounters>(ID_COUNTERS_TABLE, Arrays.asList(InternalCounters.values())) {
		private static final long serialVersionUID = 1L;

		@Override
		protected void populateItem(ListItem<InternalCounters> item) {
			InternalCounters counter = item.getModelObject();
			Label label = new Label(ID_COUNTER_LABEL, createStringResource("InternalCounters."+counter.getKey()));
			item.add(label);
	    	
	    	Label valueLabel = new Label(ID_COUNTER_VALUE, new AbstractReadOnlyModel<String>() {
				private static final long serialVersionUID = 1L;

				@Override
				public String getObject() {
					long val = InternalMonitor.getCount(counter);
					return Long.toString(val);
				}
			});
	    	item.add(valueLabel);
		}
   		
   	};
   	add(countersTable);
}
 
Example 28
Project: engerek   File: Breadcrumb.java   Source Code and License 6 votes vote down vote up
private <T extends Serializable> IModel<T> wrapModel(final IModel<T> model) {
     if (model == null) {
         return null;
     }

     return new AbstractReadOnlyModel<T>() {

         @Override
         public T getObject() {
             try {
                 return model.getObject();
             } catch (Exception ex) {
                 LOG.warn("Couldn't load breadcrumb model value", ex);
                 return null;
             }
         }

@Override
public void detach() {
	super.detach();
	model.getObject();
}
         
     };
 }
 
Example 29
Project: engerek   File: SystemInfoPanel.java   Source Code and License 6 votes vote down vote up
private IModel<String> createMemoryModel(final boolean heap) {
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            SystemInfoDto dto = getModelObject();
            Long[] memory = heap ? dto.heapMemory : dto.nonHeapMemory;

            StringBuilder sb = new StringBuilder();
            sb.append(WebComponentUtil.createHumanReadableByteCount(memory[0])).append(" / ");
            sb.append(WebComponentUtil.createHumanReadableByteCount(memory[1])).append(" / ");
            sb.append(WebComponentUtil.createHumanReadableByteCount(memory[2]));

            return sb.toString();
        }
    };
}
 
Example 30
Project: engerek   File: SystemInfoPanel.java   Source Code and License 6 votes vote down vote up
private IModel<String> createThreadModel() {
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            SystemInfoDto dto = getModelObject();

            StringBuilder sb = new StringBuilder();
            sb.append(dto.threads[0]).append(" / ");
            sb.append(dto.threads[1]).append(" / ");
            sb.append(dto.threads[2]);

            return sb.toString();
        }
    };
}
 
Example 31
Project: engerek   File: LoggingConfigPanel.java   Source Code and License 6 votes vote down vote up
private IModel<List<String>> createAppendersListModel() {
    return new AbstractReadOnlyModel<List<String>>() {

        @Override
        public List<String> getObject() {
            List<String> list = new ArrayList<>();

            LoggingDto dto = getModel().getObject();
            for (AppenderConfiguration appender : dto.getAppenders()) {
                list.add(appender.getName());
            }

            return list;
        }
    };
}
 
Example 32
Project: engerek   File: PageCertCampaigns.java   Source Code and License 6 votes vote down vote up
@Override
protected IModel<String> createPageTitleModel() {
	return new AbstractReadOnlyModel<String>() {

		@Override
		public String getObject() {
			if (definitionOid == null) {
				return createStringResource("PageCertCampaigns.title", "").getString();
			}

			Task task = createSimpleTask("dummy");
			PrismObject<AccessCertificationDefinitionType> definitionPrismObject = WebModelServiceUtils
					.loadObject(AccessCertificationDefinitionType.class, definitionOid,
							PageCertCampaigns.this, task, task.getResult());

			String name = definitionPrismObject == null ? ""
					: WebComponentUtil.getName(definitionPrismObject);

			return createStringResource("PageCertCampaigns.title", name).getString();
		}
	};
}
 
Example 33
Project: engerek   File: PageCertCampaigns.java   Source Code and License 6 votes vote down vote up
private IModel<String> createCloseSelectedCampaignsConfirmString() {
	return new AbstractReadOnlyModel<String>() {

		@Override
		public String getObject() {

			final List<Selectable> selectedData = WebComponentUtil.getSelectedData(getCampaignsTable());
			if (selectedData.size() > 1) {
				return createStringResource("PageCertCampaigns.message.closeCampaignConfirmMultiple",
						selectedData.size()).getString();
			} else if (selectedData.size() == 1) {
				return createStringResource("PageCertCampaigns.message.closeCampaignConfirmSingle",
						((CertCampaignListItemDto) selectedData.get(0)).getName()).getString();
			} else {
				return "EMPTY";
			}
		}
	};
}
 
Example 34
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 35
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 36
Project: gitplex-mit   File: PathPatternEditor.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 PathPatternAssistBehavior(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 37
Project: gitplex-mit   File: ReviewAppointmentEditor.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
   	
   	input = new ReviewAppointmentInput("input", new AbstractReadOnlyModel<Project>() {

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

		@Override
		protected String load() {
			if (hasErrors(true))
				return " has-error";
			else
				return "";
		}
		
	}));
       
}
 
Example 38
Project: gitplex-mit   File: CommitOptionPanel.java   Source Code and License 5 votes vote down vote up
private void newChangedContainer(@Nullable AjaxRequestTarget target) {
	WebMarkupContainer changedContainer = new WebMarkupContainer("changed");
	changedContainer.setVisible(change != null);
	changedContainer.setOutputMarkupPlaceholderTag(true);
	if (change != null) {
		changedContainer.add(new BlobDiffPanel("changes", new AbstractReadOnlyModel<Project>() {

			@Override
			public Project getObject() {
				return context.getProject();
			}
			
		}, new Model<PullRequest>(null), change, DiffViewMode.UNIFIED, null, null));
	} else {
		changedContainer.add(new WebMarkupContainer("changes"));
	}
	if (target != null) {
		replace(changedContainer);
		target.add(changedContainer);
		if (change != null) {
			String script = String.format("$('#%s .commit-option input[type=submit]').val('Commit and overwrite');", 
					getMarkupId());
			target.appendJavaScript(script);
		}
	} else {
		add(changedContainer);		
	}
}
 
Example 39
Project: wicket-stream-download-example   File: HomePageInputStream.java   Source Code and License 5 votes vote down vote up
public HomePageInputStream(final PageParameters parameters) throws IOException {
	super(parameters);
	setVersioned(false);

	// add a new download link named 'download'
	add(new InputStreamDownloadLink("download", new AbstractReadOnlyModel<InputStream>() {
		@Override
		public InputStream getObject() {
			return WicketApplication.getInMemoryStream();
		}
		// provide a file name / display name for the link
	}, Model.of("google.html")));
}
 
Example 40
Project: engerek   File: WebComponentUtil.java   Source Code and License 5 votes vote down vote up
public static <T extends Enum> IModel<List<T>> createReadonlyModelFromEnum(final Class<T> type) {
	return new AbstractReadOnlyModel<List<T>>() {

		@Override
		public List<T> getObject() {
			List<T> list = new ArrayList<T>();
			Collections.addAll(list, type.getEnumConstants());

			return list;
		}
	};
}
 
Example 41
Project: engerek   File: FocusMainPanel.java   Source Code and License 5 votes vote down vote up
protected IModel<PrismObject<F>> unwrapModel() {
	return new AbstractReadOnlyModel<PrismObject<F>>() {

			@Override
		public PrismObject<F> getObject() {
			return getObjectWrapper().getObject();
		}
	};
}
 
Example 42
Project: vlo-curation   File: SearchResultItemExpandedPanel.java   Source Code and License 5 votes vote down vote up
private WebMarkupContainer createResourcesView(String id, final IModel<SearchContext> selectionModel) {
    final SolrFieldModel<String> resourceModel = new SolrFieldModel<>(getModel(), FacetConstants.FIELD_RESOURCE);
    // create a container for the list view that is only visible if there actually are resources
    final WebMarkupContainer container = new WebMarkupContainer(id) {
        @Override
        protected void onConfigure() {
            super.onConfigure();
            setVisible(resourceModel.getObject() != null);
        }

    };

    final PageableListView resourcesView = createResourcesList("resource", resourceModel);
    container.add(resourcesView);

    // create a link to the record page that is only visible when there are more resources than shown
    final RecordPageLink moreLink = new RecordPageLink("more", getModel(), selectionModel, RecordPage.RESOURCES_SECTION) {

        @Override
        protected void onConfigure() {
            super.onConfigure();
            setVisible(resourcesView.getPageCount() > 1);
        }

    };
    // add a record page link that shows the number of resources not shown
    moreLink.add(new Label("moreLabel", StringResourceModelMigration.of("resources.more", new AbstractReadOnlyModel<Integer>() {

        @Override
        public Integer getObject() {
            return resourceModel.getObject().size() - MAX_RESOURCES_TO_SHOW;
        }

    }, "more...")));
    container.add(moreLink);

    return container;
}
 
Example 43
Project: engerek   File: PageAccounts.java   Source Code and License 5 votes vote down vote up
private IModel<List<String>> createIntentChoices(){
    return new AbstractReadOnlyModel<List<String>>() {

        @Override
        public List<String> getObject() {
            List<String> intentList = new ArrayList<>();
            ResourceItemDto dto = resourceModel.getObject();
            PrismObject<ResourceType> resourcePrism;

            if(dto == null){
                return intentList;
            }

            String oid = dto.getOid();
            OperationResult result = new OperationResult(OPERATION_GET_INTENTS);

            try {
                resourcePrism = getModelService().getObject(ResourceType.class, oid, null,
                        createSimpleTask(OPERATION_GET_INTENTS), result);
                ResourceType resource = resourcePrism.asObjectable();
                SchemaHandlingType schemaHandling = resource.getSchemaHandling();

                for(ResourceObjectTypeDefinitionType r: schemaHandling.getObjectType()){
                    intentList.add(r.getIntent());
                }

            } catch (Exception e){
                LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load intents from resource.", e);
                error("Couldn't load intents from resource.");
                return null;
            }

            return intentList;
        }
    };
}
 
Example 44
Project: engerek   File: CertDecisionHelper.java   Source Code and License 5 votes vote down vote up
<T extends CertCaseOrWorkItemDto> IColumn<T, String> createDetailedInfoColumn(final PageBase page) {
    IColumn column;
    column = new IconColumn<CertCaseOrWorkItemDto>(page.createStringResource("")) {

        @Override
        protected IModel<String> createIconModel(final IModel<CertCaseOrWorkItemDto> rowModel) {
            return new AbstractReadOnlyModel<String>() {
                @Override
                public String getObject() {
                    return "fa fa-fw fa-info-circle text-info";
                }
            };
        }

        @Override
        public void populateItem(Item<ICellPopulator<CertCaseOrWorkItemDto>> item, String componentId, IModel<CertCaseOrWorkItemDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            CertCaseOrWorkItemDto aCase = rowModel.getObject();
            String handlerUri;
            if (aCase instanceof CertWorkItemDto) {
                handlerUri = aCase.getHandlerUri();
            } else {
                handlerUri = ((PageCertCampaign) page).getCampaignHandlerUri();
            }
            CertGuiHandler handler = CertGuiHandlerRegistry.instance().getHandler(handlerUri);
            if (handler != null) {
                String title = handler.getCaseInfoButtonTitle(rowModel, page);
                item.add(AttributeModifier.replace("title", title));
                item.add(new TooltipBehavior());
            }
        }
    };
    return column;
}
 
Example 45
Project: engerek   File: AssignmentEditorPanel.java   Source Code and License 5 votes vote down vote up
private IModel<String> createShowEmptyLabel() {
	return new AbstractReadOnlyModel<String>() {

		@Override
		public String getObject() {
			AssignmentEditorDto dto = AssignmentEditorPanel.this.getModel().getObject();

			if (dto.isShowEmpty()) {
				return getString("AssignmentEditorPanel.hideEmpty");
			} else {
				return getString("AssignmentEditorPanel.showEmpty");
			}
		}
	};
}
 
Example 46
Project: engerek   File: AssignmentsUtil.java   Source Code and License 5 votes vote down vote up
public static IModel<String> createActivationTitleModel(IModel<AssignmentEditorDto> model, String defaultTitle, BasePanel basePanel) {
    return new AbstractReadOnlyModel<String>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            AssignmentEditorDto dto = model.getObject();
            ActivationType activation = dto.getActivation();
            if (activation == null) {
                return defaultTitle;
            }

            ActivationStatusType status = activation.getAdministrativeStatus();
            String strEnabled = basePanel.createStringResource(status, "lower", "ActivationStatusType.null")
                    .getString();

            if (activation.getValidFrom() != null && activation.getValidTo() != null) {
                return basePanel.getString("AssignmentEditorPanel.enabledFromTo", strEnabled,
                        MiscUtil.asDate(activation.getValidFrom()),
                        MiscUtil.asDate(activation.getValidTo()));
            } else if (activation.getValidFrom() != null) {
                return basePanel.getString("AssignmentEditorPanel.enabledFrom", strEnabled,
                        MiscUtil.asDate(activation.getValidFrom()));
            } else if (activation.getValidTo() != null) {
                return basePanel.getString("AssignmentEditorPanel.enabledTo", strEnabled,
                        MiscUtil.asDate(activation.getValidTo()));
            }

            return strEnabled;
        }
    };
}
 
Example 47
Project: engerek   File: AssignmentsUtil.java   Source Code and License 5 votes vote down vote up
public static IModel<String> createAssignmentStatusClassModel(final IModel<AssignmentEditorDto> model) {
    return new AbstractReadOnlyModel<String>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            AssignmentEditorDto dto = model.getObject();
            return dto.getStatus().name().toLowerCase();
        }
    };
}
 
Example 48
Project: engerek   File: AssignmentsUtil.java   Source Code and License 5 votes vote down vote up
public static IModel<String> createAssignmentIconTitleModel(BasePanel panel, AssignmentEditorDtoType type){
    return new AbstractReadOnlyModel<String>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            if (type == null) {
                return "";
            }

            switch (type) {
                case CONSTRUCTION:
                    return panel.getString("MyAssignmentsPanel.type.accountConstruction");
                case ORG_UNIT:
                    return panel.getString("MyAssignmentsPanel.type.orgUnit");
                case ROLE:
                    return panel.getString("MyAssignmentsPanel.type.role");
                case SERVICE:
                    return panel.getString("MyAssignmentsPanel.type.service");
                case USER:
                    return panel.getString("MyAssignmentsPanel.type.user");
                case POLICY_RULE:
                    return panel.getString("MyAssignmentsPanel.type.policyRule");
                default:
                    return panel.getString("MyAssignmentsPanel.type.error");
            }
        }
    };
}
 
Example 49
Project: engerek   File: CatalogItemsPanel.java   Source Code and License 5 votes vote down vote up
private void initLayout(final CatalogItemsPanel catalogItemsPanel) {
    WebMarkupContainer footerContainer = new WebMarkupContainer(ID_FOOTER_CONTAINER);
    footerContainer.setOutputMarkupId(true);

    final Label count = new Label(ID_COUNT, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return "";
        }
    });
    count.setOutputMarkupId(true);
    footerContainer.add(count);

    BoxedPagingPanel nb2 = new BoxedPagingPanel(ID_PAGING, catalogItemsPanel, true) {

        @Override
        protected void onPageChanged(AjaxRequestTarget target, long page) {
            CatalogItemsPanel catalogPanel = PagingFooter.this.findParent(CatalogItemsPanel.class);
            catalogPanel.refreshItemsPanel();
            target.add(catalogPanel);
            target.add(count);
        }
    };
    footerContainer.add(nb2);

    add(footerContainer);
}
 
Example 50
Project: engerek   File: AbstractAssignmentListPanel.java   Source Code and License 5 votes vote down vote up
public Popupable getDeleteAssignmentPopupContent(AssignmentEditorDto dto) {
    return new ConfirmationPanel(pageBase.getMainPopupBodyId(), new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getAssignmentsDeleteMessage(dto, getSelectedAssignments().size());
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        public void yesPerformed(AjaxRequestTarget target) {
            ModalWindow modalWindow = findParent(ModalWindow.class);
            if (modalWindow != null) {
                modalWindow.close(target);
                List<AssignmentEditorDto> assignmentsListToDelete;
                if (dto != null){
                    assignmentsListToDelete = new ArrayList<>();
                    assignmentsListToDelete.add(dto);
                } else {
                    assignmentsListToDelete = getSelectedAssignments();
                }
                deleteAssignmentConfirmedPerformed(target, assignmentsListToDelete);
                reloadMainFormButtons(target);
            }
        }
    };
}
 
Example 51
Project: engerek   File: ReportConfigurationPanel.java   Source Code and License 5 votes vote down vote up
private IModel<List<String>> createVirtualizerListModel() {
    final List<String> virtualizerList = new ArrayList();

    virtualizerList.add("JRFileVirtualizer");
    virtualizerList.add("JRSwapFileVirtualizer");
    virtualizerList.add("JRGzipVirtualizer");

    return new AbstractReadOnlyModel<List<String>>() {

        @Override
        public List<String> getObject() {
            return virtualizerList;
        }
    };
}
 
Example 52
Project: vlo-curation   File: TogglePanel.java   Source Code and License 5 votes vote down vote up
/**
 *
 * @param id component id
 * @param showTextModel model for text to show when collapsed ('show
 * content')
 * @param hideTextModel model for text to show when expanded ('hide
 * content')
 */
public TogglePanel(String id, final IModel<String> showTextModel, final IModel<String> hideTextModel) {
    super(id);

    // add the actual toggle link
    final Component toggler = new ToggleLink("toggler", visibilityModel, showTextModel, hideTextModel) {
        @Override
        protected void onClick(AjaxRequestTarget target) {
            if (target != null) {
                target.add(TogglePanel.this);
            }
        }
    };
    add(toggler);

    // make 'class' attribute depend on toggle state
    add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (visibilityModel.getObject()) {
                return getExpandedClass();
            } else {
                return getCollapsedClass();
            }
        }
    }));

    // add the toggled content
    content = createContent("toggleContent");
    add(content);

    setOutputMarkupId(true);
}
 
Example 53
Project: engerek   File: SelectableFolderContent.java   Source Code and License 5 votes vote down vote up
@Override
protected IModel<?> newLabelModel(final IModel<SelectableBean<OrgType>> model) {
    return new AbstractReadOnlyModel<String>() {
    	private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
        	SelectableBean<OrgType> dto = model.getObject();
        	return WebComponentUtil.getEffectiveName(dto.getValue(), OrgType.F_DISPLAY_NAME);
        
        }
    };
}
 
Example 54
Project: engerek   File: TaskSummaryPanel.java   Source Code and License 5 votes vote down vote up
@Override
	protected IModel<String> getTitleModel() {
		return new AbstractReadOnlyModel<String>() {
			@Override
			public String getObject() {
				TaskDto taskDto = parentPage.getTaskDto();
				if (taskDto.isWorkflow()) {
					return getString("TaskSummaryPanel.requestedBy", parentPage.getTaskDto().getRequestedBy());
//						return getString("TaskSummaryPanel.requestedByAndOn",
//								parentPage.getTaskDto().getRequestedBy(), getRequestedOn());
				} else {
					TaskType taskType = getModelObject();
					String rv;
					if (taskType.getExpectedTotal() != null) {
						rv = createStringResource("TaskSummaryPanel.progressWithTotalKnown", taskType.getProgress(), taskType.getExpectedTotal())
								.getString();
					} else {
						rv = createStringResource("TaskSummaryPanel.progressWithTotalUnknown", taskType.getProgress()).getString();
					}
					if (taskDto.isSuspended()) {
						rv += " " + getString("TaskSummaryPanel.progressIfSuspended");
					} else if (taskDto.isClosed()) {
						rv += " " + getString("TaskSummaryPanel.progressIfClosed");
					} else if (taskDto.isWaiting()) {
						rv += " " + getString("TaskSummaryPanel.progressIfWaiting");
					} else if (taskDto.getStalledSince() != null) {
						rv += " " + getString("TaskSummaryPanel.progressIfStalled", WebComponentUtil.formatDate(new Date(parentPage.getTaskDto().getStalledSince())));
					}
					return rv;
				}
			}
		};
	}
 
Example 55
Project: engerek   File: ObjectPolicyPanel.java   Source Code and License 5 votes vote down vote up
protected IModel<List<ObjectTemplateConfigTypeReferenceDto>> createObjectTemplateList() {
	return new AbstractReadOnlyModel<List<ObjectTemplateConfigTypeReferenceDto>>() {

		@Override
		public List<ObjectTemplateConfigTypeReferenceDto> getObject() {
			List<PrismObject<ObjectTemplateType>> templateList = null;
			List<ObjectTemplateConfigTypeReferenceDto> list = new ArrayList<>();
			OperationResult result = new OperationResult(OPERATION_LOAD_ALL_OBJECT_TEMPLATES);
			Task task = getPageBase().createSimpleTask(OPERATION_LOAD_ALL_OBJECT_TEMPLATES);

			try {
				templateList = getPageBase().getModelService().searchObjects(ObjectTemplateType.class,
						new ObjectQuery(), null, task, result);
				result.recomputeStatus();
			} catch (Exception e) {
				result.recordFatalError("Could not get list of object templates", e);
				LoggingUtils.logUnexpectedException(LOGGER, "Could not get list of object templates", e);
				// TODO - show this error in GUI
			}

			if (templateList != null) {
				ObjectTemplateType template;
				for (PrismObject<ObjectTemplateType> obj : templateList) {
					template = obj.asObjectable();
					list.add(new ObjectTemplateConfigTypeReferenceDto(template.getOid(),
							WebComponentUtil.getName(template)));
				}
			}
			return list;
		}
	};
}
 
Example 56
Project: engerek   File: TablePanel.java   Source Code and License 5 votes vote down vote up
private IModel<Boolean> showPagedPagingModel(ISortableDataProvider provider) {
    if (!(provider instanceof BaseSortableDataProvider)) {
        return new AbstractReadOnlyModel<Boolean>() {
            @Override
            public Boolean getObject() {
                return true;
            }
        };
    }

    BaseSortableDataProvider baseProvider = (BaseSortableDataProvider) provider;
    return baseProvider.isSizeAvailableModel();
}
 
Example 57
Project: engerek   File: CountToolbar.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
    super.onInitialize();

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

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

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

    PageSizePopover popover = new PageSizePopover(ID_PAGE_SIZE) {

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

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

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

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

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

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

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

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

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

        @Override
        public boolean isEnabled() {
            return BooleanUtils.isTrue(showPageListingModel.getObject()) && isFirstEnabled();
        }
    });
    first.add(firstLink);
}