use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class AddFacilityManagerGroupTabItem method draw.
public Widget draw() {
titleWidget.setText("Add manager group");
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
final TabMenu tabMenu = new TabMenu();
final ListBoxWithObjects<VirtualOrganization> box = new ListBoxWithObjects<VirtualOrganization>();
// pass empty items to menu to ensure drawing of rest
tabMenu.addWidget(new HTML(""));
tabMenu.addWidget(new HTML(""));
tabMenu.addWidget(2, new HTML("<strong>Select VO:</strong>"));
tabMenu.addWidget(3, box);
// get the table
final ScrollPanel sp = new ScrollPanel();
sp.addStyleName("perun-tableScrollPanel");
box.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
sp.setWidget(fillGroupsContent(new GetAllGroups(box.getSelectedObject().getId()), tabMenu, box));
}
});
if (box.getAllObjects().isEmpty()) {
GetVos vos = new GetVos(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
box.clear();
ArrayList<VirtualOrganization> list = new TableSorter<VirtualOrganization>().sortByName(JsonUtils.<VirtualOrganization>jsoAsList(jso));
if (list != null && !list.isEmpty()) {
box.addAllItems(list);
sp.setWidget(fillGroupsContent(new GetAllGroups(box.getSelectedObject().getId()), tabMenu, box));
} else {
box.addItem("No VOs found");
}
}
@Override
public void onError(PerunError error) {
box.clear();
box.addItem("Error while loading");
}
@Override
public void onLoadingStart() {
box.clear();
box.addItem("Loading...");
}
});
vos.retrieveData();
}
final TabItem tab = this;
tabMenu.addWidget(1, TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
if (refreshEvents != null)
refreshEvents.onFinished(null);
session.getTabManager().closeTab(tab, false);
}
}));
// add menu and the table to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class AddFacilityManagerTabItem method draw.
public Widget draw() {
titleWidget.setText("Add manager");
final CustomButton searchButton = new CustomButton("Search", ButtonTranslation.INSTANCE.searchUsers(), SmallIcons.INSTANCE.findIcon());
this.users = new FindCompleteRichUsers("", null, JsonCallbackEvents.disableButtonEvents(searchButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// if found 1 item, select
ArrayList<User> list = JsonUtils.jsoAsList(jso);
if (list != null && list.size() == 1) {
users.getSelectionModel().setSelected(list.get(0), true);
}
}
}));
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu tabMenu = new TabMenu();
// get the table
final CellTable<User> table;
if (session.isPerunAdmin()) {
table = users.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new UserDetailTabItem(user));
}
});
} else {
table = users.getTable();
}
final TabItem tab = this;
// already added
rebuildAlreadyAddedWidget();
// search textbox
final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {
@Override
public void searchFor(String text) {
startSearching(text);
searchString = text;
}
}, searchButton);
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersToFacility());
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<User> list = users.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// proceed
for (int i = 0; i < list.size(); i++) {
final int n = i;
AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// put names to already added
alreadyAddedList.add(list.get(n));
rebuildAlreadyAddedWidget();
// unselect added person
users.getSelectionModel().setSelected(list.get(n), false);
// clear search
searchBox.getTextBox().setText("");
}
}));
request.addFacilityAdmin(facility, list.get(i));
}
}
}
});
tabMenu.addWidget(addButton);
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
}
}));
// if some text has been searched before
if (!searchString.equals("")) {
searchBox.getTextBox().setText(searchString);
startSearching(searchString);
}
// add a class to the table and wrap it into scroll panel
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
// add menu and the table to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(alreadyAdded);
firstTabPanel.add(sp);
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(users, table, addButton);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class AddFacilityOwnerTabItem method draw.
public Widget draw() {
// TITLE
titleWidget.setText("Add owner");
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu tabMenu = new TabMenu();
// CALLBACK
final GetOwners owners = new GetOwners();
CellTable<Owner> table = owners.getTable();
// ADD BUTTON
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addOwners());
// tab to be closed
final TabItem tab = this;
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// get
ArrayList<Owner> list = owners.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < list.size(); i++) {
if (i == list.size() - 1) {
AddOwner request = new AddOwner(JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab));
request.addOwner(facilityId, list.get(i).getId());
} else {
AddOwner request = new AddOwner(JsonCallbackEvents.disableButtonEvents(addButton));
request.addOwner(facilityId, list.get(i).getId());
}
}
}
}
});
tabMenu.addWidget(addButton);
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
tabMenu.addFilterWidget(new ExtendedSuggestBox(owners.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
owners.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterOwners());
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(owners, table, addButton);
// add a class to the table and wrap it into scroll panel
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
// add menu and the table to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(sp);
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class AssignSecurityTeamTabItem method draw.
public Widget draw() {
// TITLE
titleWidget.setText("Add security team");
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu tabMenu = new TabMenu();
// CALLBACK
final GetSecurityTeams secTeams = new GetSecurityTeams();
secTeams.setEvents(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
if (secTeams.getList().size() == 1) {
secTeams.getSelectionModel().setSelected(secTeams.getList().get(0), true);
}
}
});
secTeams.setForceAll(true);
CellTable<SecurityTeam> table = secTeams.getTable();
// ADD BUTTON
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignSecurityTeam());
// tab to be closed
final TabItem tab = this;
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// get
ArrayList<SecurityTeam> list = secTeams.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < list.size(); i++) {
if (i == list.size() - 1) {
AssignSecurityTeam request = new AssignSecurityTeam(JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab));
request.assignSecurityTeam(facilityId, list.get(i).getId());
} else {
AssignSecurityTeam request = new AssignSecurityTeam(JsonCallbackEvents.disableButtonEvents(addButton));
request.assignSecurityTeam(facilityId, list.get(i).getId());
}
}
}
}
});
tabMenu.addWidget(addButton);
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
tabMenu.addFilterWidget(new ExtendedSuggestBox(secTeams.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
secTeams.filterTable(text);
if (secTeams.getList().size() == 1) {
secTeams.getSelectionModel().setSelected(secTeams.getList().get(0), true);
}
}
}, ButtonTranslation.INSTANCE.filterSecurityTeam());
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(secTeams, table, addButton);
// add a class to the table and wrap it into scroll panel
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
// add menu and the table to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(sp);
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class CreateAttributeDefinitionTabItem method draw.
public Widget draw() {
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// creates HTML elements
final ExtendedTextBox attributeDisplayName = new ExtendedTextBox();
final ExtendedTextBox attributeName = new ExtendedTextBox();
final ExtendedTextBox attributeDescription = new ExtendedTextBox();
final ExtendedTextBox.TextBoxValidator nameValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (attributeName.getTextBox().getText().trim().isEmpty()) {
attributeName.setError("Name of attribute can't be empty.");
} else if (!attributeName.getTextBox().getText().trim().matches(Utils.ATTRIBUTE_FRIENDLY_NAME_MATCHER)) {
attributeName.setError("Name of attribute can contain only letters, numbers, dash and colon.");
} else {
attributeName.setOk();
return true;
}
return false;
}
};
final ExtendedTextBox.TextBoxValidator descriptionValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (!attributeDescription.getTextBox().getText().trim().isEmpty()) {
attributeDescription.setOk();
return true;
} else {
attributeDescription.setError("Description of attribute can't be empty.");
return false;
}
}
};
final ExtendedTextBox.TextBoxValidator displayNameValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (!attributeDisplayName.getTextBox().getText().trim().isEmpty()) {
attributeDisplayName.setOk();
return true;
} else {
attributeDisplayName.setError("Display name of attribute can't be empty.");
return false;
}
}
};
attributeName.setValidator(nameValidator);
attributeDisplayName.setValidator(displayNameValidator);
attributeDescription.setValidator(descriptionValidator);
final ListBox entityListBox = new ListBox();
final ListBox definitionListBox = new ListBox();
final ListBox typeListBox = new ListBox();
// fill listboxs with pre-defined values
entityListBox.addItem("facility", "urn:perun:facility:");
entityListBox.addItem("resource", "urn:perun:resource:");
entityListBox.addItem("group", "urn:perun:group:");
entityListBox.addItem("group_resource", "urn:perun:group_resource:");
entityListBox.addItem("host", "urn:perun:host:");
entityListBox.addItem("member", "urn:perun:member:");
entityListBox.addItem("member_group", "urn:perun:member_group:");
entityListBox.addItem("member_resource", "urn:perun:member_resource:");
entityListBox.addItem("user", "urn:perun:user:");
entityListBox.addItem("user_ext_source", "urn:perun:ues:");
entityListBox.addItem("user_facility", "urn:perun:user_facility:");
entityListBox.addItem("vo", "urn:perun:vo:");
entityListBox.addItem("entityless", "urn:perun:entityless:");
definitionListBox.addItem("def", "attribute-def:def");
definitionListBox.addItem("opt", "attribute-def:opt");
definitionListBox.addItem("virt", "attribute-def:virt");
definitionListBox.addItem("core", "attribute-def:core");
typeListBox.addItem("String", "java.lang.String");
typeListBox.addItem("Integer", "java.lang.Integer");
typeListBox.addItem("Boolean", "java.lang.Boolean");
typeListBox.addItem("Array", "java.util.ArrayList");
typeListBox.addItem("LinkedHashMap", "java.util.LinkedHashMap");
typeListBox.addItem("LargeString", Utils.largeStringClassName);
typeListBox.addItem("LargeArrayList", Utils.largeArrayListClassName);
// prepare layout for this tab
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
TabMenu menu = new TabMenu();
// BUTTONS
final CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, buttonTranslation.createAttributeDefinition());
menu.addWidget(createButton);
// close tab events & enable, disable buttons
final JsonCallbackEvents closeTabEvents = JsonCallbackEvents.closeTabDisableButtonEvents(createButton, this);
createButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (nameValidator.validateTextBox() && descriptionValidator.validateTextBox() && displayNameValidator.validateTextBox()) {
String displayName = attributeDisplayName.getTextBox().getText().trim();
String friendlyName = attributeName.getTextBox().getText().trim();
String description = attributeDescription.getTextBox().getText().trim();
String namespace = entityListBox.getValue(entityListBox.getSelectedIndex()) + definitionListBox.getValue(definitionListBox.getSelectedIndex());
String type = typeListBox.getValue(typeListBox.getSelectedIndex());
CreateAttribute request = new CreateAttribute(JsonCallbackEvents.disableButtonEvents(createButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
AttributeDefinition a = jso.cast();
ArrayList<AttributeRights> list = new ArrayList<AttributeRights>();
AttributeRights right = AttributeRights.create(a.getId(), "SELF");
list.add(getRightsFromWidgets(selfRead, selfWrite, right));
AttributeRights right2 = AttributeRights.create(a.getId(), "VOADMIN");
list.add(getRightsFromWidgets(voRead, voWrite, right2));
AttributeRights right3 = AttributeRights.create(a.getId(), "GROUPADMIN");
list.add(getRightsFromWidgets(groupRead, groupWrite, right3));
AttributeRights right4 = AttributeRights.create(a.getId(), "FACILITYADMIN");
list.add(getRightsFromWidgets(facilityRead, facilityWrite, right4));
// after update - update rights
SetAttributeRights request = new SetAttributeRights(JsonCallbackEvents.disableButtonEvents(createButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
enableDisableWidgets(true);
closeTabEvents.onFinished(jso);
}
@Override
public void onLoadingStart() {
enableDisableWidgets(false);
}
@Override
public void onError(PerunError error) {
enableDisableWidgets(true);
}
}));
request.setAttributeRights(list);
}
}));
request.createAttributeDefinition(displayName, friendlyName, description, namespace, type);
}
}
});
// insert layout
layout.setHTML(0, 0, "Friendly name:");
layout.setWidget(0, 1, attributeName);
layout.setHTML(1, 0, "Display name:");
layout.setWidget(1, 1, attributeDisplayName);
layout.setHTML(2, 0, "Description:");
layout.setWidget(2, 1, attributeDescription);
layout.setHTML(3, 0, "Entity:");
layout.setWidget(3, 1, entityListBox);
layout.setHTML(4, 0, "Definition type:");
layout.setWidget(4, 1, definitionListBox);
layout.setHTML(5, 0, "Value type:");
layout.setWidget(5, 1, typeListBox);
for (int i = 0; i < layout.getRowCount(); i++) {
cellFormatter.addStyleName(i, 0, "itemName");
}
final TabItem tab = this;
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
final FlexTable rightsTable = new FlexTable();
rightsTable.setStyleName("inputFormFlexTable");
rightsTable.setHTML(0, 1, "<strong>SELF</strong>");
rightsTable.setHTML(0, 2, "<strong>VO</strong>");
rightsTable.setHTML(0, 3, "<strong>GROUP</strong>");
rightsTable.setHTML(0, 4, "<strong>FACILITY</strong>");
rightsTable.setHTML(1, 0, "<strong>READ</strong>");
rightsTable.setHTML(2, 0, "<strong>WRITE</strong>");
rightsTable.setWidget(1, 1, selfRead);
rightsTable.setWidget(2, 1, selfWrite);
rightsTable.setWidget(1, 2, voRead);
rightsTable.setWidget(2, 2, voWrite);
rightsTable.setWidget(1, 3, groupRead);
rightsTable.setWidget(2, 3, groupWrite);
rightsTable.setWidget(1, 4, facilityRead);
rightsTable.setWidget(2, 4, facilityWrite);
rightsTable.addStyleName("centeredTable");
vp.add(layout);
vp.add(rightsTable);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations