Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delta viewer: references shown as icon + link (does nothing for now).
- Loading branch information
Showing
5 changed files
with
150 additions
and
8 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
24 changes: 24 additions & 0 deletions
24
...gui/src/main/java/com/evolveum/midpoint/web/component/prism/show/SceneItemValuePanel.html
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,24 @@ | ||
<!-- | ||
~ Copyright (c) 2010-2016 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. | ||
--> | ||
|
||
<!DOCTYPE html> | ||
<html xmlns:wicket="http://wicket.apache.org"> | ||
<wicket:panel> | ||
<span wicket:id="icon"/> | ||
<span wicket:id="label"/> | ||
<span wicket:id="link"/> | ||
</wicket:panel> | ||
</html> |
117 changes: 117 additions & 0 deletions
117
...gui/src/main/java/com/evolveum/midpoint/web/component/prism/show/SceneItemValuePanel.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,117 @@ | ||
/* | ||
* Copyright (c) 2010-2016 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.web.component.prism.show; | ||
|
||
import com.evolveum.midpoint.gui.api.component.BasePanel; | ||
import com.evolveum.midpoint.model.api.visualizer.SceneItemValue; | ||
import com.evolveum.midpoint.prism.PrismReferenceValue; | ||
import com.evolveum.midpoint.schema.constants.ObjectTypes; | ||
import com.evolveum.midpoint.web.component.data.column.ImagePanel; | ||
import com.evolveum.midpoint.web.component.data.column.LinkPanel; | ||
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour; | ||
import com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor; | ||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
import org.apache.wicket.markup.html.basic.Label; | ||
import org.apache.wicket.model.AbstractReadOnlyModel; | ||
import org.apache.wicket.model.IModel; | ||
|
||
import javax.xml.namespace.QName; | ||
|
||
/** | ||
* TODO make this parametric (along with SceneItemValue) | ||
* @author mederly | ||
*/ | ||
public class SceneItemValuePanel extends BasePanel<SceneItemValue> { | ||
|
||
private static final String ID_ICON = "icon"; | ||
private static final String ID_LABEL = "label"; | ||
private static final String ID_LINK = "link"; | ||
|
||
public SceneItemValuePanel(String id, IModel<SceneItemValue> model) { | ||
super(id, model); | ||
initLayout(); | ||
} | ||
|
||
private void initLayout() { | ||
|
||
final VisibleEnableBehaviour visibleIfReference = new VisibleEnableBehaviour() { | ||
@Override | ||
public boolean isVisible() { | ||
SceneItemValue object = getModelObject(); | ||
return object != null && object.getSourceValue() instanceof PrismReferenceValue; | ||
} | ||
}; | ||
final VisibleEnableBehaviour visibleIfNotReference = new VisibleEnableBehaviour() { | ||
@Override | ||
public boolean isVisible() { | ||
SceneItemValue object = getModelObject(); | ||
return object == null || !(object.getSourceValue() instanceof PrismReferenceValue); | ||
} | ||
}; | ||
|
||
final ImagePanel icon = new ImagePanel(ID_ICON, new IconModel(), new TitleModel()); | ||
icon.add(visibleIfReference); | ||
add(icon); | ||
|
||
final Label label = new Label(ID_LABEL, new LabelModel()); | ||
label.add(visibleIfNotReference); | ||
add(label); | ||
|
||
final LinkPanel<String> link = new LinkPanel<String>(ID_LINK, new LabelModel()) { | ||
@Override | ||
public void onClick(AjaxRequestTarget target) { | ||
System.out.println("Clicked on " + getModelObject().getSourceValue()); | ||
super.onClick(target); | ||
} | ||
}; | ||
link.add(visibleIfReference); | ||
add(link); | ||
} | ||
|
||
private ObjectTypeGuiDescriptor getObjectTypeDescriptor() { | ||
SceneItemValue value = getModelObject(); | ||
if (value.getSourceValue() instanceof PrismReferenceValue) { | ||
QName targetType = ((PrismReferenceValue) value.getSourceValue()).getTargetType(); | ||
return ObjectTypeGuiDescriptor.getDescriptor(ObjectTypes.getObjectTypeFromTypeQName(targetType)); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
private class IconModel extends AbstractReadOnlyModel<String> { | ||
@Override | ||
public String getObject() { | ||
ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor(); | ||
return guiDescriptor != null ? guiDescriptor.getIcon() : ObjectTypeGuiDescriptor.ERROR_ICON; | ||
} | ||
} | ||
|
||
private class TitleModel extends AbstractReadOnlyModel<String> { | ||
@Override | ||
public String getObject() { | ||
ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor(); | ||
return guiDescriptor != null ? createStringResource(guiDescriptor.getLocalizationKey()).getObject() : null; | ||
} | ||
} | ||
|
||
private class LabelModel extends AbstractReadOnlyModel<String> { | ||
@Override | ||
public String getObject() { | ||
return getModelObject() != null ? getModelObject().getText() : null; | ||
} | ||
} | ||
} |