-
Notifications
You must be signed in to change notification settings - Fork 188
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
6 changed files
with
141 additions
and
75 deletions.
There are no files selected for viewing
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
42 changes: 42 additions & 0 deletions
42
gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/model/DisplayableModel.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,42 @@ | ||
/* | ||
* Copyright (C) 2022 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.gui.impl.model; | ||
|
||
import com.evolveum.midpoint.util.DisplayableValue; | ||
|
||
import org.apache.wicket.model.IModel; | ||
|
||
import java.util.Collection; | ||
|
||
public class DisplayableModel<T> implements IModel<DisplayableValue<T>> { | ||
|
||
private IModel<T> realValueModel; | ||
private Collection<? extends DisplayableValue<T>> choices; | ||
|
||
public DisplayableModel(IModel<T> realValueModel, Collection<? extends DisplayableValue<T>> choices) { | ||
this.realValueModel = realValueModel; | ||
this.choices = choices; | ||
} | ||
|
||
@Override | ||
public DisplayableValue<T> getObject() { | ||
Object value = realValueModel.getObject(); | ||
for (DisplayableValue<T> dispValue : choices) { | ||
if (dispValue.getValue().equals(value)) { | ||
return dispValue; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setObject(DisplayableValue<T> object) { | ||
realValueModel.setObject(object.getValue()); | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
.../src/main/java/com/evolveum/midpoint/gui/impl/prism/panel/GenericUploadDownloadPanel.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,47 @@ | ||
/* | ||
* Copyright (C) 2022 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.gui.impl.prism.panel; | ||
|
||
import com.evolveum.midpoint.gui.api.page.PageBase; | ||
import com.evolveum.midpoint.web.component.input.UploadDownloadPanel; | ||
|
||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
import org.apache.wicket.model.IModel; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.InputStream; | ||
|
||
public class GenericUploadDownloadPanel<T> extends UploadDownloadPanel { | ||
|
||
private IModel<T> realValueModel; | ||
|
||
public GenericUploadDownloadPanel(String id, IModel<T> realValueModel, boolean isReadOnly) { | ||
super(id, isReadOnly); | ||
this.realValueModel = realValueModel; | ||
} | ||
|
||
@Override | ||
public InputStream getStream() { | ||
T object = realValueModel.getObject(); | ||
if (object instanceof String) { | ||
return new ByteArrayInputStream(((String) object).getBytes()); | ||
} | ||
return object != null ? new ByteArrayInputStream((byte[]) object) : new ByteArrayInputStream(new byte[0]); | ||
} | ||
|
||
@Override | ||
public void updateValue(byte[] file) { | ||
realValueModel.setObject((T) file); | ||
} | ||
|
||
@Override | ||
public void uploadFileFailed(AjaxRequestTarget target) { | ||
super.uploadFileFailed(target); | ||
target.add(((PageBase) getPage()).getFeedbackPanel()); | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
...gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/panel/LookupAutocompletePanel.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,37 @@ | ||
/* | ||
* Copyright (C) 2022 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.gui.impl.prism.panel; | ||
|
||
import com.evolveum.midpoint.common.LocalizationService; | ||
import com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel; | ||
import com.evolveum.midpoint.gui.api.page.PageBase; | ||
import com.evolveum.midpoint.gui.api.util.WebComponentUtil; | ||
import com.evolveum.midpoint.gui.impl.factory.panel.TextPanelFactory; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType; | ||
|
||
import org.apache.wicket.model.IModel; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
public class LookupAutocompletePanel<T> extends AutoCompleteTextPanel<T> { | ||
|
||
|
||
public LookupAutocompletePanel(String id, IModel<T> model, Class<T> type, boolean strict, LookupTableType lookupTable) { | ||
super(id, model, type, strict, lookupTable); | ||
} | ||
|
||
@Override | ||
public Iterator<T> getIterator(String input) { | ||
return (Iterator<T>) prepareAutoCompleteList(input, getLookupTable(), ((PageBase) getPage()).getLocalizationService()).iterator(); | ||
} | ||
|
||
protected List<String> prepareAutoCompleteList(String input, LookupTableType lookupTable, LocalizationService localizationService) { | ||
return WebComponentUtil.prepareAutoCompleteList(lookupTable, input, localizationService); | ||
} | ||
|
||
} |