use of com.google.gwt.core.client.JavaScriptObject in project perun by CESNET.
the class CreateFacilityResourceTabItem method draw.
public Widget draw() {
titleWidget.setText("Create resource");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// form inputs
final ExtendedTextBox nameTextBox = new ExtendedTextBox();
final TextBox descriptionTextBox = new TextBox();
final ListBoxWithObjects<VirtualOrganization> vosDropDown = new ListBoxWithObjects<VirtualOrganization>();
// send button
final CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createResource());
// local events fills the listbox of Vos and Slds
JsonCallbackEvents event = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// fill VOs listbox
vosDropDown.clear();
ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso);
vos = new TableSorter<VirtualOrganization>().sortByName(vos);
for (VirtualOrganization vo : vos) {
vosDropDown.addItem(vo);
}
if (!vos.isEmpty())
createButton.setEnabled(true);
}
@Override
public void onLoadingStart() {
vosDropDown.clear();
vosDropDown.addItem("Loading...");
createButton.setEnabled(false);
}
@Override
public void onError(PerunError error) {
vosDropDown.clear();
vosDropDown.addItem("Error while loading");
createButton.setEnabled(false);
}
};
// load available VOs
final GetVos vos = new GetVos(event);
vos.setForceAll(true);
vos.retrieveData();
// layout
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
// Add some standard form options
layout.setHTML(0, 0, "On facility:");
layout.setHTML(0, 1, facility.getName());
layout.setHTML(1, 0, "For VO:");
layout.setWidget(1, 1, vosDropDown);
layout.setHTML(2, 0, "Name:");
layout.setWidget(2, 1, nameTextBox);
layout.setHTML(3, 0, "Description:");
layout.setWidget(3, 1, descriptionTextBox);
for (int i = 0; i < layout.getRowCount(); i++) {
cellFormatter.addStyleName(i, 0, "itemName");
}
layout.setWidth("350px");
TabMenu menu = new TabMenu();
final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (nameTextBox.getTextBox().getText().trim().isEmpty()) {
nameTextBox.setError("Name can't be empty.");
return false;
}
nameTextBox.setOk();
return true;
}
};
nameTextBox.setValidator(validator);
createButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// loads new tab when creating successful, also disable button
JsonCallbackEvents localEvents = new JsonCallbackEvents() {
public void onLoadingStart() {
(JsonCallbackEvents.disableButtonEvents(createButton)).onLoadingStart();
}
public void onFinished(JavaScriptObject jso) {
(JsonCallbackEvents.disableButtonEvents(createButton)).onFinished(jso);
Resource res = (Resource) jso;
session.getTabManager().addTabToCurrentTab(new CreateFacilityResourceManageServicesTabItem(facility, res), true);
}
public void onError(PerunError error) {
(JsonCallbackEvents.disableButtonEvents(createButton)).onError(error);
}
};
if (validator.validateTextBox()) {
// request
CreateResource request = new CreateResource(localEvents);
request.createResource(nameTextBox.getTextBox().getText().trim(), descriptionTextBox.getText().trim(), facility.getId(), vosDropDown.getSelectedObject().getId());
}
}
});
menu.addWidget(createButton);
final TabItem tab = this;
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
vp.add(layout);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of com.google.gwt.core.client.JavaScriptObject 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() + " / " + resource.getVo().getShortName() + "</span>");
column++;
menu.setHTML(0, column, " ");
menu.getFlexCellFormatter().setWidth(0, column, "25px");
column++;
}
menu.setHTML(0, column, "<strong>Description:</strong><br/><span class=\"inputFormInlineComment\">" + resource.getDescription() + " </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 com.google.gwt.core.client.JavaScriptObject in project perun by CESNET.
the class StatisticsTabItem method draw.
public Widget draw() {
// PAGE CONTENTS
ScrollPanel scroll = new ScrollPanel();
final VerticalPanel vp = new VerticalPanel();
vp.setStyleName("perun-table");
vp.setSpacing(5);
scroll.setWidget(vp);
scroll.setStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(scroll, 350, this);
final DisclosurePanel vosStatistics = new DisclosurePanel();
vosStatistics.setWidth("100%");
//vosStatistics.setOpen(true);
FlexTable vosHeader = new FlexTable();
vosHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.buildingIcon()));
vosHeader.setWidget(0, 1, new HTML("<h3>Virtual Organizations</h3>"));
vosHeader.setTitle("Click to show/hide VOs statistics");
vosStatistics.setHeader(vosHeader);
vp.add(vosStatistics);
// the general statistics table
final FlexTable statisticsTable = new FlexTable();
statisticsTable.addStyleName("statisticsTable");
// the VOs table
final FlexTable vosTable = new FlexTable();
vosTable.addStyleName("statisticsTable");
vosTable.setWidget(0, 0, new HTML("<strong>" + "VO name" + "</strong>"));
vosTable.setWidget(0, 1, new HTML("<strong>" + "Members" + "</strong>"));
vosTable.setWidget(0, 2, new HTML("<strong>" + "Valid members" + "</strong>"));
vosTable.setWidget(0, 3, new HTML("<strong>" + "Invalid members" + "</strong>"));
vosTable.setWidget(0, 4, new HTML("<strong>" + "Suspended members" + "</strong>"));
vosTable.setWidget(0, 5, new HTML("<strong>" + "Expired members" + "</strong>"));
vosTable.setWidget(0, 6, new HTML("<strong>" + "Disabled members" + "</strong>"));
vosTable.setWidget(0, 7, new HTML("<strong>" + "Groups" + "</strong>"));
vosTable.setWidget(0, 8, new HTML("<strong>" + "Resources" + "</strong>"));
// vos events - adds the VOs to the table and calls how many members the VO has
JsonCallbackEvents vosEvents = new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
// conversion
ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso);
vos = new TableSorter<VirtualOrganization>().sortByName(vos);
// iterating VOs
for (int i = 0; i < vos.size(); i++) {
VirtualOrganization vo = vos.get(i);
// call the request for number of members
GetMembersCount countMembers = new GetMembersCount(vo.getId(), null);
countMembers.retrieveData();
GetMembersCount countValidMembers = new GetMembersCount(vo.getId(), PerunStatus.VALID);
countValidMembers.retrieveData();
GetMembersCount countInvalidMembers = new GetMembersCount(vo.getId(), PerunStatus.INVALID);
countInvalidMembers.retrieveData();
GetMembersCount countSuspendedMembers = new GetMembersCount(vo.getId(), PerunStatus.SUSPENDED);
countSuspendedMembers.retrieveData();
GetMembersCount countExpiredMembers = new GetMembersCount(vo.getId(), PerunStatus.EXPIRED);
countExpiredMembers.retrieveData();
GetMembersCount countDisabledMembers = new GetMembersCount(vo.getId(), PerunStatus.DISABLED);
countDisabledMembers.retrieveData();
// call the request for number of resources
GetResourcesCount countResources = new GetResourcesCount(vo.getId());
countResources.retrieveData();
GetGroupsCount countGroups = new GetGroupsCount(vo.getId());
countGroups.retrieveData();
//adds the VO to the table
vosTable.setText(i + 1, 0, vo.getName());
vosTable.setWidget(i + 1, 1, countMembers.getMembersCountHyperlink());
vosTable.setWidget(i + 1, 2, countValidMembers.getMembersCountHyperlink());
vosTable.setWidget(i + 1, 3, countInvalidMembers.getMembersCountHyperlink());
vosTable.setWidget(i + 1, 4, countSuspendedMembers.getMembersCountHyperlink());
vosTable.setWidget(i + 1, 5, countExpiredMembers.getMembersCountHyperlink());
vosTable.setWidget(i + 1, 6, countDisabledMembers.getMembersCountHyperlink());
vosTable.setWidget(i + 1, 7, countGroups.getGroupsCountHyperlink());
vosTable.setWidget(i + 1, 8, countResources.getResourcesCountHyperlink());
}
}
};
// requests
final GetVos vos = new GetVos(vosEvents);
vosHeader.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (vosStatistics.getContent() == null) {
// retrieve data
vosStatistics.setContent(vosTable);
vos.retrieveData();
}
}
});
this.contentWidget.setWidget(scroll);
return getWidget();
}
use of com.google.gwt.core.client.JavaScriptObject in project perun by CESNET.
the class VoDetailTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()));
// main panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// The table
AbsolutePanel dp = new AbsolutePanel();
//dp.setStyleName("decoration");
final FlexTable menu = new FlexTable();
menu.setCellSpacing(5);
// Add VO information
menu.setWidget(0, 0, new Image(LargeIcons.INSTANCE.buildingIcon()));
Label voName = new Label();
voName.setText(Utils.getStrippedStringWithEllipsis(vo.getName(), 40));
voName.setStyleName("now-managing");
voName.setTitle(vo.getName());
menu.setWidget(0, 1, voName);
menu.setHTML(0, 2, " ");
menu.getFlexCellFormatter().setWidth(0, 2, "25px");
int column = 3;
if (session.isVoAdmin(voId)) {
final JsonCallbackEvents events = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// set VO and redraw tab
vo = jso.cast();
open();
draw();
}
};
CustomButton change = new CustomButton("", "Edit VO name", SmallIcons.INSTANCE.applicationFormEditIcon());
change.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new EditVoDetailsTabItem(vo, 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\">" + vo.getId() + "</span>");
column++;
menu.setHTML(0, column, " ");
menu.getFlexCellFormatter().setWidth(0, column, "25px");
column++;
menu.setHTML(0, column, "<strong>Short name:</strong><br/><span class=\"inputFormInlineComment\">" + vo.getShortName() + "</span>");
}
/*
CustomButton cb = new CustomButton("", "Refresh page content", SmallIcons.INSTANCE.updateIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
tabPanel.getSelectedTabItem().draw();
}
});
dp.add(cb);
cb.getElement().setAttribute("style", "position: absolute; right: 50px; top: 5px;");
final JsonCallbackEvents events = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// set VO and redraw tab
vo = jso.cast();
open();
draw();
}
};
CustomButton change = new CustomButton("", "Edit VO name", SmallIcons.INSTANCE.applicationFormEditIcon());
change.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new EditVoDetailsTabItem(vo, events));
}
});
if (!session.isVoAdmin(voId)) change.setEnabled(false);
dp.add(change);
change.getElement().setAttribute("style", "position: absolute; right: 5px; top: 5px;");
*/
dp.add(menu);
vp.add(dp);
vp.setCellHeight(dp, "30px");
tabPanel.clear();
tabPanel.add(new VoOverviewTabItem(vo), "Overview");
tabPanel.add(new VoMembersTabItem(vo), "Members");
tabPanel.add(new VoGroupsTabItem(vo), "Groups");
tabPanel.add(new VoResourcesTabItem(vo), "Resources");
tabPanel.add(new VoApplicationsTabItem(vo), "Applications");
tabPanel.add(new VoApplicationFormSettingsTabItem(vo), "Application form");
tabPanel.add(new VoSettingsTabItem(vo), "Settings");
tabPanel.add(new VoManagersTabItem(vo), "Managers");
tabPanel.add(new VoExtSourcesTabItem(vo), "External sources");
//tabPanel.add(new VoFacilitiesPropagationsTabItem(session, vo), "Facilities states");
// 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 com.google.gwt.core.client.JavaScriptObject in project perun by CESNET.
the class LogoutButton method logout.
/**
* Logout method, erases the cookies and calls RPC logout to invalidate session.
*/
private void logout() {
Logout call = new Logout(JsonCallbackEvents.disableButtonEvents(button, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
Utils.clearFederationCookies();
History.newItem("logout");
RootLayoutPanel.get().clear();
RootLayoutPanel.get().add(new LogoutWidget());
}
}));
// do the logout
call.retrieveData();
}
Aggregations