Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Review response uses MultiButtonPanel instead of three DoubleButtonPa…
…nels.
- Loading branch information
Showing
9 changed files
with
308 additions
and
254 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/data/MultiButtonPanel.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,21 @@ | ||
<!-- | ||
~ Copyright (c) 2010-2015 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="buttons" /> | ||
</wicket:panel> | ||
</html> |
95 changes: 95 additions & 0 deletions
95
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/data/MultiButtonPanel.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,95 @@ | ||
/* | ||
* Copyright (c) 2010-2015 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.data; | ||
|
||
import com.evolveum.midpoint.web.component.AjaxButton; | ||
import com.evolveum.midpoint.web.component.data.column.DoubleButtonColumn; | ||
import com.evolveum.midpoint.web.component.util.SimplePanel; | ||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
import org.apache.wicket.behavior.AttributeAppender; | ||
import org.apache.wicket.markup.html.basic.Label; | ||
import org.apache.wicket.markup.repeater.RepeatingView; | ||
import org.apache.wicket.model.IModel; | ||
|
||
/** | ||
* @author shood | ||
* @author mederly | ||
*/ | ||
public class MultiButtonPanel<T> extends SimplePanel<T> { | ||
|
||
private static final String ID_BUTTONS = "buttons"; | ||
|
||
int numberOfButtons; | ||
|
||
public MultiButtonPanel(String id, int numberOfButtons, IModel<T> model) { | ||
super(id, model); | ||
this.numberOfButtons = numberOfButtons; | ||
createLayout(); | ||
} | ||
|
||
private void createLayout() { | ||
RepeatingView buttons = new RepeatingView(ID_BUTTONS); | ||
add(buttons); | ||
for (int id = 0; id < numberOfButtons; id++) { | ||
final int finalId = id; | ||
AjaxButton button = new AjaxButton(String.valueOf(finalId), createStringResource(getCaption(finalId))) { | ||
@Override | ||
public void onClick(AjaxRequestTarget target) { | ||
clickPerformed(finalId, target, MultiButtonPanel.this.getModel()); | ||
} | ||
@Override | ||
public boolean isEnabled(){ | ||
return MultiButtonPanel.this.isButtonEnabled(finalId, MultiButtonPanel.this.getModel()); | ||
} | ||
}; | ||
button.add(new AttributeAppender("class", getButtonCssClass(finalId))); | ||
buttons.add(button); | ||
buttons.add(new Label("label"+finalId, " ")); | ||
} | ||
} | ||
|
||
public String getCaption(int id) { | ||
return String.valueOf(id); | ||
} | ||
|
||
public boolean isButtonEnabled(int id, IModel<T> model) { | ||
return true; | ||
} | ||
|
||
private String getButtonCssClass(int id) { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(DoubleButtonColumn.BUTTON_BASE_CLASS).append(" "); | ||
sb.append(getButtonColorCssClass(id)).append(" ").append(getButtonSizeCssClass(id)); | ||
return sb.toString(); | ||
} | ||
|
||
public String getButtonSizeCssClass(int id) { | ||
return DoubleButtonColumn.BUTTON_SIZE_CLASS.DEFAULT.toString(); | ||
} | ||
|
||
public String getButtonColorCssClass(int id) { | ||
return DoubleButtonColumn.BUTTON_COLOR_CLASS.DEFAULT.toString(); | ||
} | ||
|
||
public void clickPerformed(int id, AjaxRequestTarget target, IModel<T> model) { | ||
} | ||
|
||
public AjaxButton getButton(int id){ | ||
return (AjaxButton) get(ID_BUTTONS).get(String.valueOf(id)); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...in-gui/src/main/java/com/evolveum/midpoint/web/component/data/MultiButtonPanel.properties
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,16 @@ | ||
# | ||
# Copyright (c) 2010-2015 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. | ||
# | ||
|
108 changes: 108 additions & 0 deletions
108
...-gui/src/main/java/com/evolveum/midpoint/web/component/data/column/MultiButtonColumn.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,108 @@ | ||
/* | ||
* Copyright (c) 2010-2015 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.data.column; | ||
|
||
import com.evolveum.midpoint.web.component.data.MultiButtonPanel; | ||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; | ||
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn; | ||
import org.apache.wicket.markup.repeater.Item; | ||
import org.apache.wicket.model.IModel; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
/** | ||
* @author shood | ||
* @author mederly | ||
*/ | ||
public class MultiButtonColumn<T extends Serializable> extends AbstractColumn<T, String> { | ||
|
||
private MultiButtonPanel panel; | ||
|
||
private List<String> captions; | ||
private IModel<T> rowModel; | ||
private int numberOfButtons; | ||
|
||
public MultiButtonColumn(IModel<String> displayModel, int numberOfButtons) { | ||
super(displayModel); | ||
this.numberOfButtons = numberOfButtons; | ||
} | ||
|
||
@Override | ||
public void populateItem(final Item<ICellPopulator<T>> cellItem, String componentId, | ||
final IModel<T> rowModel) { | ||
this.rowModel = rowModel; | ||
|
||
panel = new MultiButtonPanel<T>(componentId, numberOfButtons, rowModel) { | ||
|
||
@Override | ||
public String getCaption(int id) { | ||
return MultiButtonColumn.this.getCaption(id); | ||
} | ||
|
||
@Override | ||
public boolean isButtonEnabled(int id, IModel<T> model) { | ||
return MultiButtonColumn.this.isButtonEnabled(id, model); | ||
} | ||
|
||
@Override | ||
public String getButtonSizeCssClass(int id) { | ||
return MultiButtonColumn.this.getButtonSizeCssClass(id); | ||
} | ||
|
||
@Override | ||
public String getButtonColorCssClass(int id) { | ||
return MultiButtonColumn.this.getButtonColorCssClass(id); | ||
} | ||
|
||
@Override | ||
public void clickPerformed(int id, AjaxRequestTarget target, IModel<T> model) { | ||
MultiButtonColumn.this.clickPerformed(id, target, model); | ||
} | ||
|
||
|
||
}; | ||
cellItem.add(panel); | ||
} | ||
|
||
public boolean isButtonEnabled(int id, IModel<T> model) { | ||
return true; | ||
} | ||
|
||
public String getCaption(int id) { | ||
return String.valueOf(id); | ||
} | ||
|
||
public void clickPerformed(int id, AjaxRequestTarget target, IModel<T> model) { | ||
} | ||
|
||
public String getButtonColorCssClass(int id) { | ||
return DoubleButtonColumn.BUTTON_COLOR_CLASS.DEFAULT.toString(); | ||
} | ||
|
||
public String getButtonSizeCssClass(int id) { | ||
return DoubleButtonColumn.BUTTON_SIZE_CLASS.SMALL.toString(); | ||
} | ||
|
||
public MultiButtonPanel getButtonPanel(){ | ||
return panel; | ||
} | ||
|
||
public IModel<T> getRowModel(){ | ||
return rowModel; | ||
} | ||
} |
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.