Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Dec 15, 2014
2 parents 24b5a0b + 08503ae commit bf8ce2e
Show file tree
Hide file tree
Showing 58 changed files with 3,694 additions and 384 deletions.
7 changes: 6 additions & 1 deletion gui/admin-gui/pom.xml
Expand Up @@ -526,14 +526,19 @@
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.7.0-e1</version>
<version>6.0.0</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-javaflow</groupId>
<artifactId>commons-javaflow</artifactId>
<version>20060411</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
Expand Down
Expand Up @@ -21,6 +21,7 @@
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings;
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.list.ListItem;
Expand Down Expand Up @@ -77,30 +78,14 @@ private void initLayout(final boolean inputEnabled, boolean prepareModel){
@Override
protected void populateItem(final ListItem<T> item) {

AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
autoCompleteSettings.setShowListOnEmptyInput(true);
AutoCompleteTextField<String> autoCompleteEditor = new AutoCompleteTextField<String>(ID_TEXT,
createTextModel(item.getModel())) {
createTextModel(item.getModel()), autoCompleteSettings) {

@Override
protected Iterator<String> getChoices(String input) {
if(Strings.isEmpty(input)){
List<String> emptyList = Collections.emptyList();
return emptyList.iterator();
}

List<T> list = createObjectList();
List<String> choices = new ArrayList<>(AUTO_COMPLETE_LIST_SIZE);

for(T object: list){
if(createAutoCompleteObjectLabel(object).toLowerCase().startsWith(input.toLowerCase())){
choices.add(createAutoCompleteObjectLabel(object));

if(choices.size() == AUTO_COMPLETE_LIST_SIZE){
break;
}
}
}

return choices.iterator();
return createAutocompleteObjectList(input);
}
};
autoCompleteEditor.add(createAutoCompleteValidator());
Expand All @@ -121,6 +106,35 @@ protected Iterator<String> getChoices(String input) {
add(repeater);
}

private Iterator<String> createAutocompleteObjectList(String input) {
List<T> list = createObjectList();
List<String> choices = new ArrayList<>(AUTO_COMPLETE_LIST_SIZE);

if(Strings.isEmpty(input)){
for(T object: list){
choices.add(createAutoCompleteObjectLabel(object));

if(choices.size() == AUTO_COMPLETE_LIST_SIZE){
break;
}
}

return choices.iterator();
}

for(T object: list){
if(createAutoCompleteObjectLabel(object).toLowerCase().startsWith(input.toLowerCase())){
choices.add(createAutoCompleteObjectLabel(object));

if(choices.size() == AUTO_COMPLETE_LIST_SIZE){
break;
}
}
}

return choices.iterator();
}

private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item) {
AjaxLink add = new AjaxLink(ID_ADD) {

Expand Down
Expand Up @@ -20,6 +20,8 @@
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.DiffUtil;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.logging.LoggingUtils;
Expand All @@ -45,6 +47,8 @@
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import java.util.Collection;

/**
* @author lazyman
*/
Expand All @@ -61,10 +65,13 @@ public class ConfigurationStep extends WizardStep {
private static final String ID_TEST_CONNECTION = "testConnection";

private IModel<PrismObject<ResourceType>> resourceModel;
private boolean isNewResource;
private IModel<ObjectWrapper> configurationProperties;

public ConfigurationStep(IModel<PrismObject<ResourceType>> resourceModel) {
public ConfigurationStep(IModel<PrismObject<ResourceType>> resourceModel, boolean isNewResource) {
this.resourceModel = resourceModel;
this.isNewResource = isNewResource;

this.configurationProperties = new LoadableModel<ObjectWrapper>(false) {

@Override
Expand Down Expand Up @@ -155,8 +162,14 @@ private void saveChanges() {

page.getPrismContext().adopt(newResource);

PrismObject<ResourceType> oldResource = WebModelUtils.loadObject(ResourceType.class, newResource.getOid(),
result, page);
PrismObject<ResourceType> oldResource;

if(isNewResource){
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createRaw());
oldResource = WebModelUtils.loadObject(ResourceType.class, newResource.getOid(), options, result, page);
} else {
oldResource = WebModelUtils.loadObject(ResourceType.class, newResource.getOid(), result, page);
}

delta = DiffUtil.diff(oldResource, newResource);

Expand Down
Expand Up @@ -395,10 +395,20 @@ public void applyState() {

try {
PrismObject<ResourceType> resource = resourceModel.getObject();

if(StringUtils.isNotEmpty(resource.getOid())){
newResource = false;
} else {
newResource = true;
}

page.getPrismContext().adopt(resource);
resource.findOrCreateContainer(ResourceType.F_CONNECTOR_CONFIGURATION)
.findOrCreateContainer(SchemaConstants.ICF_CONFIGURATION_PROPERTIES)
.createNewValue();

if(newResource){
resource.findOrCreateContainer(ResourceType.F_CONNECTOR_CONFIGURATION)
.findOrCreateContainer(SchemaConstants.ICF_CONFIGURATION_PROPERTIES)
.createNewValue();
}

DropDownFormGroup connectorTypeDropDown = ((DropDownFormGroup)get(ID_CONNECTOR_TYPE));
if(connectorTypeDropDown != null && connectorTypeDropDown.getInput() != null){
Expand All @@ -417,12 +427,6 @@ public void applyState() {
}
}

if(StringUtils.isNotEmpty(resource.getOid())){
newResource = false;
} else {
newResource = true;
}

ObjectDelta delta;
if (!newResource) {
PrismObject<ResourceType> oldResource = WebModelUtils.loadObject(ResourceType.class, resource.getOid(),
Expand Down
Expand Up @@ -45,6 +45,7 @@
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings;
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
Expand Down Expand Up @@ -337,30 +338,14 @@ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
addDisabledClassModifier(editorDependency);
editor.add(editorDependency);

AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
autoCompleteSettings.setShowListOnEmptyInput(true);
AutoCompleteTextField<String> editorObjectClass = new AutoCompleteTextField<String>(ID_EDITOR_OBJECT_CLASS,
new PropertyModel<String>(model, SchemaHandlingDto.F_SELECTED_OBJECT_CLASS)) {
new PropertyModel<String>(model, SchemaHandlingDto.F_SELECTED_OBJECT_CLASS), autoCompleteSettings) {

@Override
protected Iterator<String> getChoices(String input) {
if(Strings.isEmpty(input)){
List<String> emptyList = Collections.emptyList();
return emptyList.iterator();
}

List<QName> resourceObjectClassList = model.getObject().getObjectClassList();
List<String> choices = new ArrayList<>(AUTO_COMPLETE_LIST_SIZE);

for(QName q: resourceObjectClassList){
if(q.getLocalPart().toLowerCase().startsWith(input.toLowerCase())){
choices.add(q.getLocalPart());

if(choices.size() == AUTO_COMPLETE_LIST_SIZE){
break;
}
}
}

return choices.iterator();
return getObjectClassChoices(input);
}
};
editorObjectClass.add(createObjectClassValidator(new LoadableModel<List<QName>>(false) {
Expand Down Expand Up @@ -556,6 +541,35 @@ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
editor.add(credentialsTooltip);
}

private Iterator<String> getObjectClassChoices(String input) {
List<QName> resourceObjectClassList = model.getObject().getObjectClassList();
List<String> choices = new ArrayList<>(AUTO_COMPLETE_LIST_SIZE);

if(Strings.isEmpty(input)){
for(QName q: resourceObjectClassList){
choices.add(q.getLocalPart());

if(choices.size() == AUTO_COMPLETE_LIST_SIZE){
break;
}
}

return choices.iterator();
}

for(QName q: resourceObjectClassList){
if(q.getLocalPart().toLowerCase().startsWith(input.toLowerCase())){
choices.add(q.getLocalPart());

if(choices.size() == AUTO_COMPLETE_LIST_SIZE){
break;
}
}
}

return choices.iterator();
}

private void addDisabledClassModifier(Component component){
component.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

Expand Down
Expand Up @@ -54,10 +54,15 @@ public class PageResourceWizard extends PageAdminResources {
private static final String ID_WIZARD = "wizard";
private IModel<PrismObject<ResourceType>> model;
private PageParameters parameters;
private boolean isNewResource;

public PageResourceWizard(PageParameters parameters) {
this.parameters = parameters;

if(!isResourceOidAvailable()){
isNewResource = true;
}

model = new LoadableModel<PrismObject<ResourceType>>(false) {

@Override
Expand All @@ -66,7 +71,6 @@ protected PrismObject<ResourceType> load() {
if (!isResourceOidAvailable()) {
ResourceType resource = new ResourceType();
PageResourceWizard.this.getPrismContext().adopt(resource);

return resource.asPrismObject();
}

Expand Down Expand Up @@ -140,7 +144,7 @@ protected String load() {
private void initLayout() {
WizardModel wizardModel = new WizardModel();
wizardModel.add(new NameStep(model));
wizardModel.add(new ConfigurationStep(model));
wizardModel.add(new ConfigurationStep(model, isNewResource));
wizardModel.add(new SchemaStep(model));
wizardModel.add(new SchemaHandlingStep(model));
wizardModel.add(new CapabilityStep(model));
Expand Down
Expand Up @@ -16,6 +16,10 @@

package com.evolveum.midpoint.web.util;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.evolveum.midpoint.model.api.ModelExecuteOptions;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
Expand All @@ -32,14 +36,11 @@
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.page.PageBase;
import com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsDto;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.poi.hssf.record.formula.functions.T;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

/**
* @author lazyman
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit bf8ce2e

Please sign in to comment.