use of cz.metacentrum.perun.webgui.model.Attribute in project perun by CESNET.
the class TestAttributeTableTabItem method draw.
public Widget draw() {
PerunAttributeTableWidget.SaveEvent saveEvent = new PerunAttributeTableWidget.SaveEvent() {
public void save(ArrayList<Attribute> attrs) {
for (Attribute attr : attrs) {
session.getUiElements().setLogText("New value OK: " + attr.getValue().toString());
}
}
};
PerunAttributeTableWidget table = new PerunAttributeTableWidget(null, saveEvent, false, listOfAttributes());
this.contentWidget.setWidget(table);
return getWidget();
}
use of cz.metacentrum.perun.webgui.model.Attribute in project perun by CESNET.
the class UserExtSourceSettingsTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(userExtSource.getLogin().trim()));
// MAIN TAB PANEL
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// MENU
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
final GetAttributesV2 callback = new GetAttributesV2(true);
callback.getUserExtSourceAttributes(userExtSource.getId());
final CellTable<Attribute> table = callback.getEmptyTable();
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(sp, 350, this);
menu.addWidget(UiElements.getRefreshButton(this));
// save changes in attributes
final CustomButton saveChangesButton = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveChangesInAttributes());
saveChangesButton.setEnabled(false);
saveChangesButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (UiElements.cantSaveEmptyListDialogBox(callback.getTableSelectedList())) {
SetAttributes request = new SetAttributes(JsonCallbackEvents.disableButtonEvents(saveChangesButton, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
callback.clearTable();
callback.getUserExtSourceAttributes(userExtSourceId);
callback.retrieveData();
}
}));
final Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("userExtSource", userExtSourceId);
request.setAttributes(ids, callback.getTableSelectedList());
}
}
});
menu.addWidget(saveChangesButton);
// buttons
CustomButton setNewMemberAttributeButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.setNewAttributes(), new ClickHandler() {
public void onClick(ClickEvent event) {
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("userExtSource", userExtSource.getId());
session.getTabManager().addTabToCurrentTab(new SetNewAttributeTabItem(ids), true);
}
});
menu.addWidget(setNewMemberAttributeButton);
// REMOVE ATTRIBUTES BUTTON
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeAttributes());
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// if selected
if (UiElements.cantSaveEmptyListDialogBox(callback.getTableSelectedList())) {
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("userExtSource", userExtSource.getId());
RemoveAttributes request = new RemoveAttributes(JsonCallbackEvents.disableButtonEvents(removeButton, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
callback.clearTable();
callback.getUserExtSourceAttributes(userExtSource.getId());
callback.retrieveData();
}
}));
// make removeAttributes call
request.removeAttributes(ids, callback.getTableSelectedList());
}
}
});
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(callback, table, removeButton);
menu.addWidget(removeButton);
callback.retrieveData();
// ATTRIBUTES TABLE
vp.add(sp);
vp.setCellHeight(sp, "100%");
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.model.Attribute in project perun by CESNET.
the class GetAttributes method getEmptyTable.
/**
* Returns empty table widget with attributes
*
* @return table widget
*/
public CellTable<Attribute> getEmptyTable() {
// Table data provider.
dataProvider = new ListDataProvider<Attribute>(list);
// Cell table
table = new PerunTable<Attribute>(list);
// remove row count change handler
table.removeRowCountChangeHandler();
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<Attribute> columnSortHandler = new ListHandler<Attribute>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Attribute>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
// because of tabindex
table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
if (checkable) {
// checkbox column column
Column<Attribute, Attribute> checkBoxColumn = new Column<Attribute, Attribute>(new PerunCheckboxCell<Attribute>(true, false, false)) {
@Override
public Attribute getValue(Attribute object) {
// Get the value from the selection model.
GeneralObject go = object.cast();
go.setChecked(selectionModel.isSelected(object));
return go.cast();
}
};
// updates the columns size
table.setColumnWidth(checkBoxColumn, 40.0, Unit.PX);
// Add the columns
// Checkbox column header
CheckboxCell cb = new CheckboxCell();
Header<Boolean> checkBoxHeader = new Header<Boolean>(cb) {
public Boolean getValue() {
//return true to see a checked checkbox.
return false;
}
};
checkBoxHeader.setUpdater(new ValueUpdater<Boolean>() {
public void update(Boolean value) {
// sets selected to all, if value = true, unselect otherwise
for (Attribute obj : list) {
if (obj.isWritable()) {
selectionModel.setSelected(obj, value);
}
}
}
});
table.addColumn(checkBoxColumn, checkBoxHeader);
}
// Create ID column.
table.addIdColumn("Attribute ID", this.tableFieldUpdater);
// Name column
Column<Attribute, String> nameColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {
public String getValue(Attribute attribute) {
return attribute.getFriendlyName();
}
}, this.tableFieldUpdater);
// Create ENTITY column
Column<Attribute, String> entityColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {
public String getValue(Attribute a) {
return a.getEntity();
}
}, this.tableFieldUpdater);
// Create def type column
Column<Attribute, String> defTypeColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {
public String getValue(Attribute a) {
return a.getDefinition();
}
}, this.tableFieldUpdater);
// Create type column.
Column<Attribute, String> typeColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {
public String getValue(Attribute attribute) {
return renameContent(attribute.getType());
}
}, this.tableFieldUpdater);
Column<Attribute, String> valueColumn;
if (editable) {
valueColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {
public String getValue(Attribute attribute) {
return attribute.getValue();
}
}, new FieldUpdater<Attribute, String>() {
public void update(int index, Attribute object, String newText) {
if (object.setValue(newText)) {
selectionModel.setSelected(object, true);
} else {
selectionModel.setSelected(object, false);
UiElements.cantSaveAttributeValueDialogBox(object);
}
}
});
} else {
valueColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {
public String getValue(Attribute attribute) {
return attribute.getValue();
}
}, this.tableFieldUpdater);
}
// Create description column.
Column<Attribute, String> descriptionColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {
public String getValue(Attribute attribute) {
return attribute.getDescription();
}
}, this.tableFieldUpdater);
// Sorting name column
nameColumn.setSortable(true);
columnSortHandler.setComparator(nameColumn, new Comparator<Attribute>() {
public int compare(Attribute o1, Attribute o2) {
return o1.getFriendlyName().compareToIgnoreCase(o2.getFriendlyName());
}
});
// Sorting type column
typeColumn.setSortable(true);
columnSortHandler.setComparator(typeColumn, new Comparator<Attribute>() {
public int compare(Attribute o1, Attribute o2) {
return o1.getType().compareToIgnoreCase(o2.getType());
}
});
// Sorting description column
descriptionColumn.setSortable(true);
columnSortHandler.setComparator(descriptionColumn, new Comparator<Attribute>() {
public int compare(Attribute o1, Attribute o2) {
return o1.getDescription().compareToIgnoreCase(o2.getDescription());
}
});
// Sorting value column
valueColumn.setSortable(true);
columnSortHandler.setComparator(valueColumn, new Comparator<Attribute>() {
public int compare(Attribute o1, Attribute o2) {
return o1.getValue().compareToIgnoreCase(o2.getValue());
}
});
// Sorting value column
entityColumn.setSortable(true);
columnSortHandler.setComparator(entityColumn, new Comparator<Attribute>() {
public int compare(Attribute o1, Attribute o2) {
return o1.getEntity().compareToIgnoreCase(o2.getEntity());
}
});
// Sorting value column
defTypeColumn.setSortable(true);
columnSortHandler.setComparator(defTypeColumn, new Comparator<Attribute>() {
public int compare(Attribute o1, Attribute o2) {
return o1.getDefinition().compareToIgnoreCase(o2.getDefinition());
}
});
// column size
this.table.setColumnWidth(typeColumn, 120.0, Unit.PX);
this.table.setColumnWidth(entityColumn, 100.0, Unit.PX);
this.table.setColumnWidth(defTypeColumn, 110.0, Unit.PX);
this.table.setColumnWidth(nameColumn, 200.0, Unit.PX);
this.table.setColumnWidth(valueColumn, 200.0, Unit.PX);
// Add the columns.
this.table.addColumn(nameColumn, "Name");
this.table.addColumn(entityColumn, "Entity");
this.table.addColumn(defTypeColumn, "Definition");
this.table.addColumn(typeColumn, "Value type");
this.table.addColumn(valueColumn, "Value");
this.table.addColumn(descriptionColumn, "Description");
return table;
}
use of cz.metacentrum.perun.webgui.model.Attribute in project perun by CESNET.
the class GetAttributes method onFinished.
/**
* Called, when operation finishes successfully.
*/
public void onFinished(JavaScriptObject jso) {
clearTable();
friendlyTable.clear();
int counter = 0;
for (Attribute a : JsonUtils.<Attribute>jsoAsList(jso)) {
if (!a.getDefinition().equals("core")) {
addToTable(a);
}
friendlyTable.setWidget(counter, 0, new HTML("<strong>" + a.getFriendlyName() + "</strong>"));
friendlyTable.setText(counter, 1, a.getValue());
counter++;
}
sortTable();
session.getUiElements().setLogText("Attributes loaded: " + list.size());
events.onFinished(jso);
loaderImage.loadingFinished();
}
use of cz.metacentrum.perun.webgui.model.Attribute in project perun by CESNET.
the class GetAttributesDefinitionV2 method setList.
public void setList(ArrayList<Attribute> list) {
clearTable();
this.list.addAll(list);
for (Attribute a : list) {
oracle.add(a.getFriendlyName());
}
dataProvider.flush();
dataProvider.refresh();
}
Aggregations