Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
416 additions
and
7 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
...-gui/src/main/java/com/evolveum/midpoint/gui/api/factory/AbstractGuiComponentFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright (c) 2010-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.api.factory; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import com.evolveum.midpoint.gui.api.util.WebComponentUtil; | ||
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils; | ||
import com.evolveum.midpoint.gui.impl.factory.PanelContext; | ||
import com.evolveum.midpoint.prism.PrismObject; | ||
import com.evolveum.midpoint.prism.PrismReferenceValue; | ||
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.xml.ns._public.common.common_3.LookupTableRowType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType; | ||
|
||
public abstract class AbstractGuiComponentFactory implements GuiComponentFactory { | ||
|
||
|
||
protected LookupTableType loadLookupTable(PanelContext panelCtx) { | ||
|
||
PrismReferenceValue valueEnumerationRef = panelCtx.getValueEnumerationRef(); | ||
if (valueEnumerationRef == null) { | ||
return null; | ||
} | ||
|
||
String lookupTableUid = valueEnumerationRef.getOid(); | ||
Task task = panelCtx.getPageBase().createSimpleTask("loadLookupTable"); | ||
OperationResult result = task.getResult(); | ||
|
||
Collection<SelectorOptions<GetOperationOptions>> options = WebModelServiceUtils | ||
.createLookupTableRetrieveOptions(); | ||
PrismObject<LookupTableType> lookupTable = WebModelServiceUtils.loadObject(LookupTableType.class, | ||
lookupTableUid, options, panelCtx.getPageBase(), task, result); | ||
if (lookupTable == null) { | ||
return null; | ||
} | ||
|
||
return lookupTable.asObjectable(); | ||
|
||
} | ||
|
||
|
||
protected List<String> prepareAutoCompleteList(String input, LookupTableType lookupTable) { | ||
List<String> values = new ArrayList<>(); | ||
|
||
if (lookupTable == null) { | ||
return values; | ||
} | ||
|
||
List<LookupTableRowType> rows = lookupTable.getRow(); | ||
|
||
if (input == null || input.isEmpty()) { | ||
for (LookupTableRowType row : rows) { | ||
values.add(WebComponentUtil.getOrigStringFromPoly(row.getLabel())); | ||
} | ||
} else { | ||
for (LookupTableRowType row : rows) { | ||
if (WebComponentUtil.getOrigStringFromPoly(row.getLabel()) != null | ||
&& WebComponentUtil.getOrigStringFromPoly(row.getLabel()).toLowerCase().contains(input.toLowerCase())) { | ||
values.add(WebComponentUtil.getOrigStringFromPoly(row.getLabel())); | ||
} | ||
} | ||
} | ||
|
||
return values; | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/factory/GuiComponentFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2010-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.api.factory; | ||
|
||
import org.apache.wicket.markup.html.panel.Panel; | ||
|
||
import com.evolveum.midpoint.gui.impl.factory.PanelContext; | ||
import com.evolveum.midpoint.web.component.prism.ValueWrapper; | ||
|
||
public interface GuiComponentFactory { | ||
|
||
// public void register(); | ||
|
||
<T> boolean match(ValueWrapper<T> valueWrapper); | ||
|
||
<T> Panel createPanel(PanelContext<T> panelCtx); | ||
|
||
// Panel build(PanelContext panelContext); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/registry/GuiComponentRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2010-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.api.registry; | ||
|
||
import com.evolveum.midpoint.gui.api.factory.GuiComponentFactory; | ||
import com.evolveum.midpoint.web.component.prism.ItemWrapper; | ||
import com.evolveum.midpoint.web.component.prism.ValueWrapper; | ||
|
||
public interface GuiComponentRegistry { | ||
|
||
public void addToRegistry(GuiComponentFactory factory); | ||
|
||
public <T> GuiComponentFactory findFactory(ValueWrapper<T> valueWrapper); | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/converter/DurationConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2010-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.converter; | ||
|
||
import java.util.Locale; | ||
|
||
import javax.xml.datatype.Duration; | ||
|
||
import org.apache.wicket.util.convert.ConversionException; | ||
import org.apache.wicket.util.convert.IConverter; | ||
|
||
import com.evolveum.midpoint.prism.xml.XmlTypeConverter; | ||
import com.evolveum.midpoint.util.MiscUtil; | ||
|
||
public class DurationConverter implements IConverter<Duration>{ | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public Duration convertToObject(String value, Locale locale) throws ConversionException { | ||
return XmlTypeConverter.createDuration(MiscUtil.nullIfEmpty(value)); | ||
} | ||
|
||
@Override | ||
public String convertToString(Duration value, Locale locale) { | ||
return value.toString(); | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
...admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/converter/PolyStringConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) 2010-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.converter; | ||
|
||
import java.util.Locale; | ||
|
||
import org.apache.wicket.util.convert.ConversionException; | ||
import org.apache.wicket.util.convert.IConverter; | ||
|
||
import com.evolveum.midpoint.prism.polystring.PolyString; | ||
|
||
public class PolyStringConverter implements IConverter<PolyString> { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public PolyString convertToObject(String value, Locale locale) throws ConversionException { | ||
if (value == null) { | ||
return null; | ||
} | ||
return new PolyString(value); | ||
} | ||
|
||
@Override | ||
public String convertToString(PolyString value, Locale locale) { | ||
if (value == null) { | ||
return null; | ||
} | ||
|
||
return value.getOrig(); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ItemRealValueModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.