Skip to content

Commit

Permalink
commit before merge
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Aug 6, 2018
1 parent ea9175e commit f4b0339
Show file tree
Hide file tree
Showing 26 changed files with 644 additions and 453 deletions.
Expand Up @@ -98,6 +98,7 @@
import com.evolveum.midpoint.gui.api.model.NonEmptyModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.DefaultReferencableImpl;
import com.evolveum.midpoint.prism.Objectable;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismContainerValue;
Expand Down Expand Up @@ -274,6 +275,21 @@ public static String getReferencedObjectDisplayNamesAndNames(List<ObjectReferenc
.map(ref -> emptyIfNull(getDisplayNameAndName(ref)) + (showTypes ? (" (" + emptyIfNull(getTypeLocalized(ref)) + ")") : ""))
.collect(Collectors.joining(", "));
}

public static String getReferencedObjectDisplayNamesAndNames(DefaultReferencableImpl ref, boolean showTypes) {
String name = ref.getTargetName() == null ? "" : ref.getTargetName().getOrig();
StringBuilder sb = new StringBuilder(name);
if(showTypes) {
sb.append(" (");
ObjectTypes type = ObjectTypes.getObjectTypeFromTypeQName(ref.getType());
ObjectTypeGuiDescriptor descriptor = ObjectTypeGuiDescriptor.getDescriptor(type);
if (descriptor == null) {
return null;
}
sb.append(emptyIfNull(createStringResourceStatic(null, descriptor.getLocalizationKey()).getString())).append(")");
}
return sb.toString();
}

public static void addAjaxOnUpdateBehavior(WebMarkupContainer container) {
container.visitChildren(new IVisitor<Component, Object>() {
Expand Down
Expand Up @@ -26,6 +26,10 @@
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.task.api.TaskManager;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.web.component.prism.ContainerStatus;
import com.evolveum.midpoint.web.component.prism.ObjectWrapper;
import com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory;
import com.evolveum.midpoint.web.page.error.PageError;
import com.evolveum.midpoint.web.page.login.PageLogin;
import com.evolveum.midpoint.web.security.MidPointApplication;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
Expand Down Expand Up @@ -81,6 +85,7 @@ public class WebModelServiceUtils {
private static final String OPERATION_COUNT_OBJECT = DOT_CLASS + "countObjects";
private static final String OPERATION_ASSUME_POWER_OF_ATTORNEY = DOT_CLASS + "assumePowerOfAttorney";
private static final String OPERATION_DROP_POWER_OF_ATTORNEY = DOT_CLASS + "dropPowerOfAttorney";
private static final String OPERATION_GET_SYSTEM_CONFIG = DOT_CLASS + "getSystemConfiguration";

public static String resolveReferenceName(ObjectReferenceType ref, PageBase page) {
Task task = page.createSimpleTask(WebModelServiceUtils.class.getName() + ".resolveReferenceName");
Expand Down Expand Up @@ -798,4 +803,36 @@ public static boolean isPostAuthenticationEnabled(TaskManager taskManager, Model
}
return false;
}

public static ObjectWrapper<SystemConfigurationType> loadSystemConfigurationAsObjectWrapper(PageBase pageBase) {
Task task = pageBase.createSimpleTask(OPERATION_GET_SYSTEM_CONFIG);
OperationResult result = new OperationResult(OPERATION_GET_SYSTEM_CONFIG);

Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(
GetOperationOptions.createResolve(), SystemConfigurationType.F_DEFAULT_USER_TEMPLATE,
SystemConfigurationType.F_GLOBAL_PASSWORD_POLICY);

ObjectWrapper<SystemConfigurationType> wrapper = null;
try {
PrismObject<SystemConfigurationType> systemConfig = loadObject(
SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), options,
pageBase, task, result);

ObjectWrapperFactory owf = new ObjectWrapperFactory(pageBase);

wrapper = owf.createObjectWrapper("adminPage.systemConfiguration", null, systemConfig, ContainerStatus.MODIFYING, task);

result.recordSuccess();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load system configuration", ex);
result.recordFatalError("Couldn't load system configuration.", ex);
}

if (!WebComponentUtil.isSuccessOrHandledError(result) || wrapper == null) {
pageBase.showResult(result, false);
throw pageBase.getRestartResponseException(PageError.class);
}

return wrapper;
}
}
Expand Up @@ -15,6 +15,7 @@
*/
package com.evolveum.midpoint.gui.impl.component;

import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.model.IModel;

Expand Down Expand Up @@ -64,13 +65,14 @@ protected void initLayout(){
add(getSpecificContainers(ID_SPECIFIC_CONTAINERS_PANEL));
}

protected abstract Fragment getSpecificContainers(String contentAreaId);
protected WebMarkupContainer getSpecificContainers(String contentAreaId) {
return new WebMarkupContainer(contentAreaId);
}

protected void getBasicContainerValuePanel(String idPanel){
Form form = new Form<>("form");
ItemPath itemPath = getModelObject().getPath();
IModel<ContainerValueWrapper<C>> model = getModel();
model.getObject().setShowEmpty(true, true);
model.getObject().getContainer().setShowOnTopLevel(true);
add(new ContainerValuePanel<C>(idPanel, getModel(), true, form,
itemWrapper -> getBasicTabVisibity(itemWrapper, itemPath), getPageBase()));
Expand Down
Expand Up @@ -30,9 +30,9 @@
<div class="row" >
<div class="col-md-12" wicket:id="itemsTable" style="margin: 5px 0;"/>
</div>
<div>
<!-- <div>
<div class="btn btn-success btn-sm" wicket:id="newItemButton"/>
</div>
</div> -->
</div>
</wicket:panel>
</html>
Expand Up @@ -36,6 +36,8 @@

import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.impl.model.PropertyWrapperFromContainerValueWrapperModel;
import com.evolveum.midpoint.gui.impl.util.GuiImplUtil;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.PrismContainerValue;
Expand All @@ -56,11 +58,14 @@
import com.evolveum.midpoint.web.component.prism.ContainerValueWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapperFactory;
import com.evolveum.midpoint.web.component.prism.ObjectWrapper;
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.midpoint.web.component.prism.ValueWrapper;
import com.evolveum.midpoint.web.component.util.MultivalueContainerListDataProvider;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.session.PageStorage;
import com.evolveum.midpoint.web.session.UserProfileStorage.TableId;
import com.evolveum.midpoint.xml.ns._public.common.common_3.GlobalPolicyRuleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyRuleType;

/**
Expand Down Expand Up @@ -120,28 +125,28 @@ private void initListPanel() {
BoxedTablePanel<ContainerValueWrapper<C>> itemTable = initItemTable();
itemsContainer.add(itemTable);

AjaxIconButton newObjectIcon = new AjaxIconButton(ID_NEW_ITEM_BUTTON, new Model<>("fa fa-plus"),
createStringResource("MainObjectListPanel.newObject")) {

private static final long serialVersionUID = 1L;

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

newObjectIcon.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;

@Override
public boolean isVisible() {
return enableActionNewObject();
}
});
itemsContainer.add(newObjectIcon);
// AjaxIconButton newObjectIcon = new AjaxIconButton(ID_NEW_ITEM_BUTTON, new Model<>("fa fa-plus"),
// createStringResource("MainObjectListPanel.newObject")) {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// public void onClick(AjaxRequestTarget target) {
// newItemPerformed(target);
// }
// };
//
// newObjectIcon.add(new VisibleEnableBehaviour() {
// private static final long serialVersionUID = 1L;
//
// @Override
// public boolean isVisible() {
// return enableActionNewObject();
// }
// });
// itemsContainer.add(newObjectIcon);

Fragment searchContainer = getSearchPanel(ID_SEARCH_ITEM_PANEL);
WebMarkupContainer searchContainer = getSearchPanel(ID_SEARCH_ITEM_PANEL);
itemsContainer.add(searchContainer);
itemsContainer.add(new VisibleEnableBehaviour() {

Expand All @@ -159,7 +164,9 @@ protected boolean isListPanelVisible() {
return true;
}

protected abstract Fragment getSearchPanel(String contentAreaId);
protected WebMarkupContainer getSearchPanel(String contentAreaId) {
return new WebMarkupContainer(contentAreaId);
}

protected abstract boolean enableActionNewObject();

Expand Down Expand Up @@ -212,6 +219,31 @@ public String getObject() {
}));
return item;
}

@Override
protected WebMarkupContainer createButtonToolbar(String id) {
AjaxIconButton newObjectIcon = new AjaxIconButton(id, new Model<>("fa fa-plus"),
createStringResource("MainObjectListPanel.newObject")) {

private static final long serialVersionUID = 1L;

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

newObjectIcon.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;

@Override
public boolean isVisible() {
return enableActionNewObject();
}
});
newObjectIcon.add(AttributeModifier.append("class", createStyleClassModelForNewObjectIcon()));
return newObjectIcon;
}

};
itemTable.setOutputMarkupId(true);
Expand All @@ -220,6 +252,17 @@ public String getObject() {

}

private IModel<String> createStyleClassModelForNewObjectIcon() {
return new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;

@Override
public String getObject() {
return "btn btn-success btn-sm";
}
};
}

protected abstract List<ContainerValueWrapper<C>> postSearch(List<ContainerValueWrapper<C>> items);

protected abstract ObjectQuery createQuery();
Expand All @@ -233,6 +276,14 @@ public BoxedTablePanel<ContainerValueWrapper<C>> getItemTable() {
}

public void refreshTable(AjaxRequestTarget ajaxRequestTarget) {
IModel objectModel = new LoadableModel<ContainerValueWrapper<GlobalPolicyRuleType>>(false) {
private static final long serialVersionUID = 1L;

@Override
protected ContainerValueWrapper<GlobalPolicyRuleType> load() {
return ((ContainerValueWrapper<GlobalPolicyRuleType>)getModelObject().getValues().get(0));
}
};
ajaxRequestTarget.add(getItemContainer().addOrReplace(initItemTable()));
}

Expand Down Expand Up @@ -269,7 +320,7 @@ public ContainerValueWrapper<C> createNewItemContainerValueWrapper(
Task task = getPageBase().createSimpleTask("Creating new object policy");
ContainerValueWrapper<C> valueWrapper = factory.createContainerValueWrapper(model.getObject(), newItem,
model.getObject().getObjectStatus(), ValueStatus.ADDED, model.getObject().getPath(), task);
valueWrapper.setShowEmpty(true, false);
valueWrapper.setShowEmpty(true, true);
model.getObject().getValues().add(valueWrapper);
return valueWrapper;
}
Expand Down
Expand Up @@ -30,9 +30,9 @@
<div class="row" >
<div class="col-md-12" wicket:id="itemsTable" style="margin: 5px 0;"/>
</div>
<div>
<!-- <div>
<div class="btn btn-success btn-sm" wicket:id="newItemButton"/>
</div>
</div> -->
</div>
<div wicket:id="details">
<div wicket:id="itemsDetails">
Expand Down
@@ -0,0 +1,97 @@
/*
* Copyright (c) 2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.evolveum.midpoint.gui.impl.component.data.column;

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.impl.model.PropertyWrapperFromContainerValueWrapperModel;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.data.column.LinkColumn;
import com.evolveum.midpoint.web.component.form.Form;

import javax.xml.namespace.QName;

import org.apache.wicket.Component;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import com.evolveum.midpoint.web.component.prism.ContainerValueWrapper;
import com.evolveum.midpoint.web.component.prism.PrismPropertyColumn;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType;

/**
* @author skublik
*/
public class EditableLinkPropertyWrapperColumn<C extends Containerable> extends LinkColumn<ContainerValueWrapper<C>> {

private static final long serialVersionUID = 1L;

private static final Trace LOGGER = TraceManager.getTrace(EditableLinkPropertyWrapperColumn.class);

private QName qNameOfProperty;
private PageBase page;

public EditableLinkPropertyWrapperColumn(IModel<String> displayModel, QName item, PageBase page) {
super(displayModel);
this.qNameOfProperty = item;
this.page = page;
}

public EditableLinkPropertyWrapperColumn(IModel<String> displayModel, String propertyExpression, QName item, PageBase page) {
super(displayModel, propertyExpression);
this.qNameOfProperty = item;
this.page = page;
}

public EditableLinkPropertyWrapperColumn(IModel<String> displayModel, String sortProperty, String propertyExpression, QName item, PageBase page) {
super(displayModel, sortProperty, propertyExpression);
this.qNameOfProperty = item;
this.page = page;
}

@Override
public void populateItem(Item<ICellPopulator<ContainerValueWrapper<C>>> cellItem, String componentId,
final IModel<ContainerValueWrapper<C>> rowModel) {
if (!rowModel.getObject().isSelected()) {
super.populateItem(cellItem, componentId, rowModel);
} else {
cellItem.add(createInputPanel(componentId, rowModel));
rowModel.getObject().setSelected(true);
}
}

protected Component createInputPanel(String componentId, IModel<ContainerValueWrapper<C>> rowModel) {
Form form= new Form("form");
PropertyWrapperFromContainerValueWrapperModel model = new PropertyWrapperFromContainerValueWrapperModel<>(rowModel, qNameOfProperty);
PrismPropertyColumn panel = new PrismPropertyColumn<>(componentId, model, form, getPageBase());
return panel;
}

@Override
protected IModel createLinkModel(IModel<ContainerValueWrapper<C>> rowModel) {
Form form= new Form("form");
PropertyWrapperFromContainerValueWrapperModel model = new PropertyWrapperFromContainerValueWrapperModel<>(rowModel, qNameOfProperty);
return Model.of(String.valueOf(model.getObject().getItem().getRealValue()));
}

private PageBase getPageBase() {
return page;
}
}

0 comments on commit f4b0339

Please sign in to comment.