use of com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel in project midpoint by Evolveum.
the class OrgTreePanel method initLayout.
private void initLayout(ModelServiceLocator serviceLocator) {
WebMarkupContainer treeHeader = new WebMarkupContainer(ID_TREE_HEADER);
treeHeader.setOutputMarkupId(true);
add(treeHeader);
String title = StringUtils.isEmpty(treeTitleKey) ? "TreeTablePanel.hierarchy" : treeTitleKey;
Label treeTitle = new Label(ID_TREE_TITLE, createStringResource(title));
treeHeader.add(treeTitle);
List<InlineMenuItem> actions = createTreeMenu();
DropdownButtonDto model = new DropdownButtonDto(null, "fa fa-cog", null, actions);
DropdownButtonPanel treeMenu = new DropdownButtonPanel(ID_TREE_MENU, model) {
private static final long serialVersionUID = 1L;
@Override
protected String getSpecialButtonClass() {
return "btn-default";
}
@Override
protected boolean visibleCaret() {
return false;
}
};
treeMenu.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !actions.isEmpty();
}
});
treeMenu.setOutputMarkupId(true);
treeMenu.setOutputMarkupPlaceholderTag(true);
treeHeader.add(treeMenu);
ISortableTreeProvider provider = new OrgTreeProvider(this, getModel(), preselecteOrgsList) {
@Override
protected ObjectFilter getCustomFilter() {
return OrgTreePanel.this.getCustomFilter();
}
};
WebMarkupContainer treeContainer = new WebMarkupContainer(ID_TREE_CONTAINER) {
private static final long serialVersionUID = 1L;
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
// method computes height based on document.innerHeight() -
// screen height;
Component form = OrgTreePanel.this.getParent().get("memberPanel");
if (form != null) {
// TODO fix
// response.render(OnDomReadyHeaderItem.forScript(
// "updateHeight('" + getMarkupId() + "', ['#" + form.getMarkupId() + "'], ['#"
// + OrgTreePanel.this.get(ID_TREE_HEADER).getMarkupId() + "'])"));
}
}
};
add(treeContainer);
TreeStateModel treeStateMode = new TreeStateModel(this, provider, getOrgTreeStateStorage()) {
private static final long serialVersionUID = 1L;
@Override
public Set<TreeSelectableBean<OrgType>> getExpandedItems() {
return OrgTreePanel.this.getExpandedItems(getOrgTreeStateStorage());
}
@Override
public Set<TreeSelectableBean<OrgType>> getCollapsedItems() {
return OrgTreePanel.this.getCollapsedItems(getOrgTreeStateStorage());
}
@Override
public void setCollapsedItems(TreeStateSet items) {
OrgTreePanel.this.setCollapsedItems(null, getOrgTreeStateStorage());
}
};
contentPannels = new ArrayList<OrgTreeFolderContent>();
MidpointNestedTree tree = new MidpointNestedTree(ID_TREE, provider, treeStateMode) {
@Override
protected Component newContentComponent(String id, IModel<TreeSelectableBean<OrgType>> model) {
OrgTreeFolderContent contentPannel = new OrgTreeFolderContent(id, model, selectable, selected, this, getOrgTreeStateStorage()) {
@Override
protected void selectTreeItemPerformed(TreeSelectableBean<OrgType> selected, AjaxRequestTarget target) {
OrgTreePanel.this.selectTreeItemPerformed(selected, target);
}
@Override
protected IModel<Boolean> getCheckboxModel(IModel<TreeSelectableBean<OrgType>> org) {
return OrgTreePanel.this.getCheckBoxValueModel(org);
}
@Override
protected void onUpdateCheckbox(AjaxRequestTarget target) {
selected = getModel();
onOrgTreeCheckBoxSelectionPerformed(target, selected);
}
@Override
protected IModel<List<InlineMenuItem>> createInlineMenuItemsModel() {
return new ReadOnlyModel<>(() -> createTreeChildrenMenuInternal(model.getObject(), serviceLocator.getCompiledGuiProfile()));
}
};
contentPannels.add(contentPannel);
return contentPannel;
}
@Override
public void collapse(TreeSelectableBean<OrgType> collapsedItem) {
super.collapse(collapsedItem);
Set<TreeSelectableBean<OrgType>> items = OrgTreePanel.this.getExpandedItems(getOrgTreeStateStorage());
if (items != null && items.contains(collapsedItem)) {
items.remove(collapsedItem);
}
OrgTreePanel.this.setExpandedItems((TreeStateSet) items, getOrgTreeStateStorage());
OrgTreePanel.this.addCollapsedItem(collapsedItem, getOrgTreeStateStorage());
}
@Override
public void expand(TreeSelectableBean<OrgType> expandedItem) {
super.expand(expandedItem);
Set<TreeSelectableBean<OrgType>> items = OrgTreePanel.this.getCollapsedItems(getOrgTreeStateStorage());
if (items != null && items.contains(expandedItem)) {
items.remove(expandedItem);
}
OrgTreePanel.this.setCollapsedItems((TreeStateSet) items, getOrgTreeStateStorage());
OrgTreePanel.this.addExpandedItem(expandedItem, getOrgTreeStateStorage());
}
};
tree.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());
tree.setOutputMarkupId(true);
tree.add(new WindowsTheme());
treeContainer.add(tree);
}
use of com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel in project midpoint by Evolveum.
the class ResourceContentPanel method initButton.
private void initButton(String id, String label, String icon, String archetypeOid) {
ObjectQuery existingTasksQuery = getExistingTasksQuery(archetypeOid);
OperationResult result = new OperationResult(OPERATION_SEARCH_TASKS_FOR_RESOURCE);
List<PrismObject<TaskType>> tasksList = WebModelServiceUtils.searchObjects(TaskType.class, existingTasksQuery, result, getPageBase());
List<InlineMenuItem> items = new ArrayList<>();
InlineMenuItem item = new InlineMenuItem(getPageBase().createStringResource("ResourceContentResourcePanel.showExisting")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<TaskType> filteredByKindIntentTasks = getTasksForKind(tasksList);
redirectToTasksListPage(createInTaskOidQuery(filteredByKindIntentTasks), archetypeOid);
}
};
}
};
items.add(item);
item = new InlineMenuItem(getPageBase().createStringResource("ResourceContentResourcePanel.newTask")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
newTaskPerformed(archetypeOid);
}
};
}
};
items.add(item);
DropdownButtonPanel button = new DropdownButtonPanel(id, new DropdownButtonDto(String.valueOf(tasksList.size()), icon, label, items)) {
@Override
protected String getSpecialDropdownMenuClass() {
return "pull-left";
}
};
add(button);
}
use of com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel in project midpoint by Evolveum.
the class ExecuteChangeOptionsPanel method createOptionsDropdownButton.
private void createOptionsDropdownButton(List<InlineMenuItem> items) {
DropdownButtonDto model = new DropdownButtonDto(null, GuiStyleConstants.CLASS_OPTIONS_BUTTON_ICON, getPageBase().createStringResource("ExecuteChangeOptionsPanel.options").getString(), items);
DropdownButtonPanel dropdownButtonPanel = new DropdownButtonPanel(ID_OPTIONS, model) {
@Override
protected void populateMenuItem(String componentId, ListItem<InlineMenuItem> menuItem) {
InlineMenuItem item = menuItem.getModelObject();
if (!(item instanceof CheckboxMenuItem)) {
super.populateMenuItem(componentId, menuItem);
return;
}
CheckboxMenuItem checkboxMenuItem = (CheckboxMenuItem) item;
CheckBoxPanel panel = new CheckBoxPanel(componentId, checkboxMenuItem.getCheckBoxModel(), checkboxMenuItem.getLabel(), null) {
@Override
public void onUpdate(AjaxRequestTarget target) {
// checkboxMenuItem.getCheckBoxModel().setObject(!checkboxMenuItem.getCheckBoxModel().getObject());
}
};
panel.setOutputMarkupId(true);
menuItem.add(panel);
}
@Override
protected String getSpecialButtonClass() {
return "btn-sm btn-default btn-margin-right";
}
@Override
protected String getSpecialDropdownMenuClass() {
return "execute-options";
}
@Override
protected String getSpecialLabelClass() {
return "execute-options-label";
}
};
add(dropdownButtonPanel);
dropdownButtonPanel.setOutputMarkupId(true);
}
use of com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel in project midpoint by Evolveum.
the class AssignmentTablePanel method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
final WebMarkupContainer assignments = new WebMarkupContainer(ID_ASSIGNMENTS);
assignments.setOutputMarkupId(true);
add(assignments);
Label label = new Label(ID_HEADER, getLabel());
assignments.add(label);
DropdownButtonDto model = new DropdownButtonDto(null, null, null, createAssignmentMenu());
DropdownButtonPanel assignmentMenu = new DropdownButtonPanel(ID_MENU, model) {
private static final long serialVersionUID = 1L;
@Override
protected String getSpecialButtonClass() {
return "btn-xs btn-default";
}
};
assignmentMenu.setVisible(getAssignmentMenuVisibility());
assignments.add(assignmentMenu);
ListView<AssignmentEditorDto> list = new ListView<AssignmentEditorDto>(ID_LIST, getModel()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<AssignmentEditorDto> item) {
AssignmentTablePanel.this.populateAssignmentDetailsPanel(item);
}
};
list.setOutputMarkupId(true);
assignments.add(list);
AjaxCheckBox checkAll = new AjaxCheckBox(ID_CHECK_ALL, new Model()) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
List<AssignmentEditorDto> assignmentsList = getAssignmentModel().getObject();
for (AssignmentEditorDto dto : assignmentsList) {
dto.setSelected(this.getModelObject());
}
target.add(assignments);
}
};
checkAll.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
int count = 0;
for (AssignmentEditorDto dto : getModelObject()) {
if (dto.isSimpleView()) {
count++;
}
}
return count != getModelObject().size();
}
});
assignments.add(checkAll);
}
Aggregations