use of cz.metacentrum.perun.webgui.tabs.facilitiestabs.FacilityDetailTabItem in project perun by CESNET.
the class ResourceDetailTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(resource.getName()));
// main widget panel
final VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
AbsolutePanel dp = new AbsolutePanel();
// dp.setStyleName("decoration");
final FlexTable menu = new FlexTable();
menu.setCellSpacing(5);
// MAIN INFO PANEL
// resource info
menu.setWidget(0, 0, new Image(LargeIcons.INSTANCE.serverGroupIcon()));
Label resourceName = new Label();
resourceName.setText(Utils.getStrippedStringWithEllipsis(resource.getName(), 40));
resourceName.setStyleName("now-managing");
resourceName.setTitle(resource.getName());
menu.setWidget(0, 1, resourceName);
menu.setHTML(0, 2, " ");
menu.getFlexCellFormatter().setWidth(0, 2, "25px");
int column = 3;
final JsonCallbackEvents events = new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
new GetEntityById(PerunEntity.RICH_RESOURCE, resourceId, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
resource = jso.cast();
open();
draw();
}
}).retrieveData();
}
};
CustomButton change = new CustomButton("", ButtonTranslation.INSTANCE.editResourceDetails(), SmallIcons.INSTANCE.applicationFormEditIcon());
if (!session.isVoAdmin(resource.getVoId()) && !session.isFacilityAdmin(resource.getFacilityId()))
change.setEnabled(false);
change.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// prepare confirm content
Resource r = resource.cast();
session.getTabManager().addTabToCurrentTab(new EditResourceDetailsTabItem(r, events));
}
});
menu.setWidget(0, column, change);
column++;
menu.setHTML(0, column, " ");
menu.getFlexCellFormatter().setWidth(0, column, "25px");
column++;
if (JsonUtils.isExtendedInfoVisible()) {
menu.setHTML(0, column, "<strong>ID:</strong><br/><span class=\"inputFormInlineComment\">" + resource.getId() + "</span>");
column++;
menu.setHTML(0, column, " ");
menu.getFlexCellFormatter().setWidth(0, column, "25px");
column++;
}
if (facilityId > 0) {
// facility admin view
menu.setHTML(0, column, "<strong>VO:</strong><br/><span class=\"inputFormInlineComment\">" + resource.getVoId() + " / " + SafeHtmlUtils.fromString(resource.getVo().getShortName()).asString() + "</span>");
column++;
menu.setHTML(0, column, " ");
menu.getFlexCellFormatter().setWidth(0, column, "25px");
column++;
}
menu.setHTML(0, column, "<strong>Description:</strong><br/><span class=\"inputFormInlineComment\">" + SafeHtmlUtils.fromString((resource.getDescription() != null) ? resource.getDescription() : "").asString() + " </span>");
if (session.isFacilityAdmin(resource.getFacilityId())) {
column++;
menu.setHTML(0, column, " ");
menu.getFlexCellFormatter().setWidth(0, column, "25px");
column++;
Anchor a = new Anchor("View facility details >>");
a.setStyleName("pointer");
a.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTab(new FacilityDetailTabItem(resource.getFacility()));
}
});
menu.setWidget(0, column, a);
}
dp.add(menu);
vp.add(dp);
vp.setCellHeight(dp, "30px");
// TAB PANEL WITH INNER TABS
tabPanel.clear();
Resource r = resource.cast();
tabPanel.add(new ResourceAssignedGroupsTabItem(r), "Assigned groups");
tabPanel.add(new ResourceAssignedServicesTabItem(r), "Assigned services");
tabPanel.add(new ResourceSettingsTabItem(r, null), "Service settings");
tabPanel.add(new ResourceGroupSettingsTabItem(r), "Group settings");
tabPanel.add(new ResourceMemberSettingsTabItem(resource), "Member settings");
if (session.isVoAdmin(r.getVoId()) || session.isVoObserver(r.getVoId())) {
tabPanel.add(new ResourceTagsTabItem(r), "Tags");
}
// Resize must be called after page fully displays
Scheduler.get().scheduleDeferred(new Command() {
@Override
public void execute() {
tabPanel.finishAdding();
}
});
vp.add(tabPanel);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.facilitiestabs.FacilityDetailTabItem in project perun by CESNET.
the class FacilitiesTabItem method draw.
public Widget draw() {
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// TAB MENU
TabMenu tabMenu = new TabMenu();
tabMenu.addWidget(UiElements.getRefreshButton(this));
// get RICH facilities request
final GetFacilities facilities = new GetFacilities(true);
// retrieve data (table)
final CellTable<Facility> table = facilities.getTable(new FieldUpdater<Facility, String>() {
public void update(int index, Facility object, String value) {
session.getTabManager().addTab(new FacilityDetailTabItem(object));
}
});
// add new facility button
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createFacility(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTab(new CreateFacilityTabItem());
}
}));
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(facilities);
// add delete facilities button
final CustomButton deleteButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteFacilities());
tabMenu.addWidget(deleteButton);
deleteButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<Facility> list = facilities.getTableSelectedList();
String text = "Following facilities will be deleted.";
UiElements.showDeleteConfirm(list, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < list.size(); i++) {
if (i == list.size() - 1) {
DeleteFacility request = new DeleteFacility(JsonCallbackEvents.disableButtonEvents(deleteButton, events));
request.deleteFacility(list.get(i).getId());
} else {
DeleteFacility request = new DeleteFacility(JsonCallbackEvents.disableButtonEvents(deleteButton));
request.deleteFacility(list.get(i).getId());
}
}
}
});
}
});
// filter box
tabMenu.addFilterWidget(new ExtendedSuggestBox(facilities.getOracle()), new PerunSearchEvent() {
public void searchFor(String text) {
facilities.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterFacilities());
deleteButton.setEnabled(false);
JsonUtils.addTableManagedButton(facilities, table, deleteButton);
// 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);
firstTabPanel.setCellHeight(sp, "100%");
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.facilitiestabs.FacilityDetailTabItem in project perun by CESNET.
the class GetFacility method onFinished.
/**
* When successfully finishes
*
* @param jso javascript objects (array) returned from RPC
*/
public void onFinished(JavaScriptObject jso) {
this.facility = (Facility) jso;
session.getUiElements().setLogText("Loading facility for resource : " + this.resourceId + " finished.");
// creates the link
Hyperlink link = new Hyperlink(facility.getName(), session.getTabManager().getLinkForTab(new FacilityDetailTabItem(facility)));
facilityLinkWrapper.setWidget(link);
// custom on finished
events.onFinished(facility);
}
use of cz.metacentrum.perun.webgui.tabs.facilitiestabs.FacilityDetailTabItem in project perun by CESNET.
the class UserDetailTabItem method loadFacilitySubContent.
private void loadFacilitySubContent(final SimplePanel subContent, final Hyperlink facilityLabel, final ListBoxWithObjects<Facility> listbox) {
final VerticalPanel entryPanel = new VerticalPanel();
entryPanel.setSize("100%", "100%");
subContent.setWidget(entryPanel);
facilityLabel.setHTML(SafeHtmlUtils.fromSafeConstant("<h2>" + SafeHtmlUtils.fromString((listbox.getSelectedObject().getName() != null) ? listbox.getSelectedObject().getName() : "").asString() + "</h2>"));
facilityLabel.setTargetHistoryToken(session.getTabManager().getLinkForTab(new FacilityDetailTabItem(listbox.getSelectedObject())));
final GetAttributesV2 attributes = new GetAttributesV2();
attributes.getUserFacilityAttributes(listbox.getSelectedObject().getId(), user.getId());
TabMenu menu = new TabMenu();
final CustomButton saveAttrButton = TabMenu.getPredefinedButton(ButtonType.SAVE, "Save changes in attributes");
saveAttrButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Attribute> list = attributes.getTableSelectedList();
if (list == null || list.isEmpty()) {
Confirm c = new Confirm("No changes to save", new Label("You must select some attributes to save."), true);
c.show();
return;
}
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("user", userId);
ids.put("facility", listbox.getSelectedObject().getId());
SetAttributes request = new SetAttributes(JsonCallbackEvents.disableButtonEvents(saveAttrButton, JsonCallbackEvents.refreshTableEvents(attributes)));
request.setAttributes(ids, list);
}
});
menu.addWidget(saveAttrButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, "Set new attributes", new ClickHandler() {
public void onClick(ClickEvent event) {
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("user", userId);
ids.put("facility", listbox.getSelectedObject().getId());
session.getTabManager().addTabToCurrentTab(new SetNewAttributeTabItem(ids, attributes.getList()), true);
}
}));
final CustomButton removeAttrButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, "Remove attributes");
removeAttrButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Attribute> list = attributes.getTableSelectedList();
if (list == null || list.isEmpty()) {
Confirm c = new Confirm("No changes to save", new Label("You must select some attributes to save."), true);
c.show();
return;
}
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("user", userId);
ids.put("facility", listbox.getSelectedObject().getId());
RemoveAttributes request = new RemoveAttributes(JsonCallbackEvents.disableButtonEvents(removeAttrButton, JsonCallbackEvents.refreshTableEvents(attributes)));
request.removeAttributes(ids, list);
}
});
menu.addWidget(removeAttrButton);
entryPanel.add(menu);
CellTable<Attribute> table = attributes.getTable();
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
entryPanel.add(sp);
// better format
entryPanel.add(new SimplePanel());
entryPanel.setCellHeight(entryPanel.getWidget(entryPanel.getWidgetCount() - 1), "100%");
session.getUiElements().resizeSmallTabPanel(sp, 320, this);
}
use of cz.metacentrum.perun.webgui.tabs.facilitiestabs.FacilityDetailTabItem in project perun by CESNET.
the class PerunWebSession method setActiveFacility.
/**
* Sets currently active Facility (refresh links in menu)
*
* @param facility Facility which user is editing now
*/
public void setActiveFacility(Facility facility) {
this.activeFacility = facility;
addObjectToEntitiesHistory(facility.cast());
getUiElements().getMenu().setMenuTabItem(MainMenu.FACILITY_ADMIN, new FacilityDetailTabItem(facility));
getUiElements().getMenu().updateLinks(MainMenu.FACILITY_ADMIN);
}
Aggregations