use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class FacilityStatusTabItem method draw.
public Widget draw() {
// title
titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Services status");
// main content
final VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// get empty table
final GetFacilityServicesState callback = new GetFacilityServicesState(facility.getId());
CustomButton refreshButton = UiElements.getRefreshButton(this);
//callback.setEvents(JsonCallbackEvents.disableButtonEvents(refreshButton));
final CellTable<ServiceState> table = callback.getTable(new FieldUpdater<ServiceState, String>() {
// on row click
public void update(int index, final ServiceState object, String value) {
// show results if any present
if (object.getSendTask() != null) {
session.getTabManager().addTab(new TaskResultsTabItem(object.getSendTask()));
}
}
});
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
final CustomButton forceButton = new CustomButton(ButtonTranslation.INSTANCE.forcePropagationButton(), ButtonTranslation.INSTANCE.forcePropagation(), SmallIcons.INSTANCE.arrowRightIcon());
forceButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<ServiceState> forceList = callback.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(forceList)) {
// TODO - translated Widget
boolean denied = false;
VerticalPanel vp = new VerticalPanel();
vp.add(new HTML("<p>Some services can't be forcefully propagated, because they are <strong>blocked on facility</strong>. Please change their state to 'Allowed' before starting force propagation.</p>"));
for (int i = 0; i < forceList.size(); i++) {
if (forceList.get(i).isBlockedOnFacility() || forceList.get(i).isBlockedGlobally()) {
vp.add(new Label(" - " + forceList.get(i).getService().getName()));
denied = true;
}
}
if (denied) {
// show conf
Confirm c = new Confirm("Can't propagated blocked services", vp, true);
c.show();
return;
}
}
// show propagation status page on last call start
JsonCallbackEvents events = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// unselect all services
for (ServiceState service : forceList) {
callback.getSelectionModel().setSelected(service, false);
}
}
};
// starts propagation for all selected services
for (int i = 0; i < forceList.size(); i++) {
if (i != forceList.size() - 1) {
// force propagation
ForceServicePropagation request = new ForceServicePropagation(JsonCallbackEvents.disableButtonEvents(forceButton));
request.forcePropagation(facility.getId(), forceList.get(i).getService().getId());
} else {
// force propagation with show status page
ForceServicePropagation request = new ForceServicePropagation(JsonCallbackEvents.disableButtonEvents(forceButton, events));
request.forcePropagation(facility.getId(), forceList.get(i).getService().getId());
}
}
}
});
final CustomButton blockButton = new CustomButton(ButtonTranslation.INSTANCE.blockPropagationButton(), ButtonTranslation.INSTANCE.blockServicesOnFacility(), SmallIcons.INSTANCE.stopIcon());
final CustomButton allowButton = new CustomButton(ButtonTranslation.INSTANCE.allowPropagationButton(), ButtonTranslation.INSTANCE.allowServicesOnFacility(), SmallIcons.INSTANCE.acceptIcon());
final CustomButton deleteButton = new CustomButton(ButtonTranslation.INSTANCE.deleteButton(), ButtonTranslation.INSTANCE.deleteTasks(), SmallIcons.INSTANCE.deleteIcon());
blockButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<ServiceState> list = callback.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i = 0; i < list.size(); i++) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
BanExecServiceOnFacility request = new BanExecServiceOnFacility(facilityId, JsonCallbackEvents.disableButtonEvents(blockButton));
if (list.get(i).getGenTask() != null)
request.banExecService(list.get(i).getGenTask().getExecService().getId());
// last event
BanExecServiceOnFacility sendRequest = new BanExecServiceOnFacility(facilityId, JsonCallbackEvents.disableButtonEvents(blockButton));
JsonCallbackEvents events = JsonCallbackEvents.disableButtonEvents(blockButton, JsonCallbackEvents.refreshTableEvents(callback));
if (i == list.size() - 1)
sendRequest.setEvents(events);
if (list.get(i).getSendTask() != null)
sendRequest.banExecService(list.get(i).getSendTask().getExecService().getId());
}
}
}
});
allowButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<ServiceState> list = callback.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i = 0; i < list.size(); i++) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
FreeDenialOfExecServiceOnFacility request = new FreeDenialOfExecServiceOnFacility(facilityId, JsonCallbackEvents.disableButtonEvents(allowButton));
if (list.get(i).getGenTask() != null)
request.freeDenialOfExecService(list.get(i).getGenTask().getExecService().getId());
// last event
FreeDenialOfExecServiceOnFacility sendRequest = new FreeDenialOfExecServiceOnFacility(facilityId, JsonCallbackEvents.disableButtonEvents(allowButton));
JsonCallbackEvents events = JsonCallbackEvents.disableButtonEvents(allowButton, JsonCallbackEvents.refreshTableEvents(callback));
if (i == list.size() - 1)
sendRequest.setEvents(events);
if (list.get(i).getSendTask() != null)
sendRequest.freeDenialOfExecService(list.get(i).getSendTask().getExecService().getId());
}
}
}
});
TabMenu menu = new TabMenu();
menu.addWidget(refreshButton);
menu.addWidget(forceButton);
menu.addWidget(allowButton);
menu.addWidget(blockButton);
if (session.isPerunAdmin()) {
menu.addWidget(deleteButton);
deleteButton.setEnabled(false);
JsonUtils.addTableManagedButton(callback, table, deleteButton);
deleteButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<ServiceState> list = callback.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
UiElements.generateAlert("", "This action will also delete all propagation results. <p>If service is still assigned to any resource, it will be listed in a table.", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
for (ServiceState ss : list) {
DeleteTask deleteTask = new DeleteTask(JsonCallbackEvents.disableButtonEvents(deleteButton));
if (ss.getGenTask() != null)
deleteTask.deleteTask(ss.getGenTask().getId());
deleteTask.setEvents(JsonCallbackEvents.disableButtonEvents(deleteButton, JsonCallbackEvents.refreshTableEvents(callback)));
if (ss.getSendTask() != null)
deleteTask.deleteTask(ss.getSendTask().getId());
}
}
});
}
}
});
}
forceButton.setEnabled(false);
allowButton.setEnabled(false);
blockButton.setEnabled(false);
JsonUtils.addTableManagedButton(callback, table, forceButton);
JsonUtils.addTableManagedButton(callback, table, allowButton);
JsonUtils.addTableManagedButton(callback, table, blockButton);
vp.add(menu);
vp.setCellHeight(menu, "30px");
vp.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class EditGroupDetailsTabItem method draw.
public Widget draw() {
titleWidget = new Label("Edit group");
VerticalPanel vp = new VerticalPanel();
// textboxes which set the class data when updated
final ExtendedTextBox descriptionTextBox = new ExtendedTextBox();
descriptionTextBox.getTextBox().setText(group.getDescription());
final ExtendedTextBox nameTextBox = new ExtendedTextBox();
nameTextBox.getTextBox().setText(group.getShortName());
// disable name change for core groups
nameTextBox.getTextBox().setEnabled(!group.isCoreGroup());
// prepares layout
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
// close tab events
final TabItem tab = this;
TabMenu menu = new TabMenu();
// send button
final CustomButton saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, buttonTranslation.saveGroupDetails());
final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (nameTextBox.getTextBox().getText().trim().isEmpty()) {
nameTextBox.setError("Name can't be empty.");
} else if (!nameTextBox.getTextBox().getText().trim().matches(Utils.GROUP_SHORT_NAME_MATCHER)) {
nameTextBox.setError("Name can contain only a-z, A-Z, numbers, spaces, dots, '_' and '-'.");
} else {
nameTextBox.setOk();
return true;
}
return false;
}
};
nameTextBox.setValidator(validator);
saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (!validator.validateTextBox())
return;
Group g = JsonUtils.clone(group).cast();
g.setDescription(descriptionTextBox.getTextBox().getText().trim());
String value = nameTextBox.getTextBox().getText().trim();
g.setShortName(value);
int index = g.getName().lastIndexOf(":");
if (index > 0) {
// short name append to base name
String baseName = g.getName().substring(0, index);
baseName += ":" + g.getShortName();
g.setName(baseName);
} else {
// short name is whole name
g.setName(value);
}
;
UpdateGroup request = new UpdateGroup(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab, events));
request.updateGroup(g);
}
});
// cancel button
final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
});
// Add some standard form options
layout.setHTML(0, 0, "Name:");
layout.setWidget(0, 1, nameTextBox);
layout.setHTML(1, 0, "Description:");
layout.setWidget(1, 1, descriptionTextBox);
for (int i = 0; i < layout.getRowCount(); i++) {
cellFormatter.addStyleName(i, 0, "itemName");
}
menu.addWidget(saveButton);
menu.addWidget(cancelButton);
vp.add(layout);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class GroupApplicationsTabItem method draw.
public Widget draw() {
// request
final GetApplicationsForGroup applicationsRequest = new GetApplicationsForGroup(group.getId());
final JsonCallbackEvents refreshEvent = JsonCallbackEvents.refreshTableEvents(applicationsRequest);
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": " + "applications");
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
firstTabPanel.add(menu);
firstTabPanel.setCellHeight(menu, "30px");
/*
// verify button
final CustomButton verify = TabMenu.getPredefinedButton(ButtonType.VERIFY, ButtonTranslation.INSTANCE.verifyApplication());
verify.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify));
request.verifyApplication(list.get(i).getId());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify, refreshEvent));
request.verifyApplication(list.get(i).getId());
}
}
}
}
});
// accept button
final CustomButton approve = TabMenu.getPredefinedButton(ButtonType.APPROVE, ButtonTranslation.INSTANCE.approveApplication());
approve.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve));
request.approveApplication(list.get(i));
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve, refreshEvent));
request.approveApplication(list.get(i));
}
}
}
}
});
//reject button
final CustomButton reject = TabMenu.getPredefinedButton(ButtonType.REJECT, ButtonTranslation.INSTANCE.rejectApplication());
reject.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// confirm content
FlexTable content = new FlexTable();
content.setCellSpacing(10);
content.setHTML(0, 0, "Please specify reason of rejection to let user know why was application rejected.");
content.getFlexCellFormatter().setColSpan(0, 0, 2);
final TextArea reason = new TextArea();
reason.setSize("300px", "150px");
content.setHTML(1, 0, "<strong>Reason: </strong>");
content.setWidget(1, 1, reason);
Confirm c = new Confirm("Specify reason", content, new ClickHandler(){
public void onClick(ClickEvent event) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject));
request.rejectApplication(list.get(i).getId(), reason.getText());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject, refreshEvent));
request.rejectApplication(list.get(i).getId(), reason.getText());
}
}
}
}, true);
c.show();
}
}
});
// delete button
final CustomButton delete = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteApplication());
delete.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete));
request.deleteApplication(list.get(i).getId());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete, refreshEvent));
request.deleteApplication(list.get(i).getId());
}
}
}
}
});
menu.addWidget(verify);
menu.addWidget(approve);
menu.addWidget(reject);
menu.addWidget(delete);
*/
// FILTER
menu.addWidget(new HTML("<strong>State: </strong>"));
// state
final ListBox stateListBox = new ListBox();
stateListBox.addItem(WidgetTranslation.INSTANCE.listboxAll(), "");
stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateNew(), "NEW");
stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateVerified(), "VERIFIED");
stateListBox.addItem("Pending", "NEW,VERIFIED");
stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateApproved(), "APPROVED");
stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateRejected(), "REJECTED");
stateListBox.setSelectedIndex(selectedIndex);
menu.addWidget(stateListBox);
stateListBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
selectedIndex = stateListBox.getSelectedIndex();
applicationsRequest.setState(stateListBox.getValue(stateListBox.getSelectedIndex()));
applicationsRequest.clearTable();
applicationsRequest.retrieveData();
}
});
// FILTER 2
menu.addWidget(new HTML("<strong>Submitted by: </strong>"));
menu.addFilterWidget(new ExtendedSuggestBox(applicationsRequest.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
applicationsRequest.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterApplications());
// TABLE
applicationsRequest.setState(stateListBox.getValue(stateListBox.getSelectedIndex()));
CellTable<Application> table = applicationsRequest.getTable(new FieldUpdater<Application, String>() {
public void update(int index, Application object, String value) {
session.getTabManager().addTabToCurrentTab(new ApplicationDetailTabItem(object), true);
}
});
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(sp, 100);
firstTabPanel.add(sp);
/*
verify.setEnabled(false);
approve.setEnabled(false);
reject.setEnabled(false);
delete.setEnabled(false);
if (session.isGroupAdmin(groupId) || session.isVoAdmin(group.getVoId())) {
JsonUtils.addTableManagedButton(applicationsRequest, table, approve);
JsonUtils.addTableManagedButton(applicationsRequest, table, reject);
JsonUtils.addTableManagedButton(applicationsRequest, table, delete);
if (session.isPerunAdmin()) {
JsonUtils.addTableManagedButton(applicationsRequest, table, verify);
}
} else {
}
*/
applicationsRequest.setCheckable(false);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class AddHostsTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": add hosts");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
final ExtendedTextArea newHosts = new ExtendedTextArea();
newHosts.getTextArea().setSize("335px", "150px");
final ExtendedTextArea.TextAreaValidator validator = new ExtendedTextArea.TextAreaValidator() {
@Override
public boolean validateTextArea() {
if (newHosts.getTextArea().getText().trim().isEmpty()) {
newHosts.setError("Please enter at least one hostname to add it to facility.");
return false;
} else {
newHosts.setOk();
return true;
}
}
};
newHosts.setValidator(validator);
final CustomButton addHostsButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addHost());
// close tab, disable button
final TabItem tab = this;
addHostsButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (validator.validateTextArea()) {
String hostnames = newHosts.getTextArea().getText().trim();
String[] hosts = hostnames.split("\n");
// trim whitespace
for (int i = 0; i < hosts.length; i++) {
hosts[i] = hosts[i].trim();
}
AddHosts request = new AddHosts(facility.getId(), JsonCallbackEvents.closeTabDisableButtonEvents(addHostsButton, tab));
request.addHosts(hosts);
}
}
});
TabMenu menu = new TabMenu();
menu.addWidget(addHostsButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
// layout
final FlexTable layout = new FlexTable();
layout.setWidth("350px");
layout.setStyleName("inputFormFlexTable");
FlexTable.FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
layout.setHTML(0, 0, "Hostnames:");
layout.setWidget(1, 0, newHosts);
cellFormatter.addStyleName(0, 0, "itemName");
layout.setHTML(2, 0, "Enter one host per line. You can use \"[x-y]\" in hostname to generate hosts with numbers from x to y. This replacer can be specified multiple times in one hostname to generate MxN combinations.");
cellFormatter.addStyleName(2, 0, "inputFormInlineComment");
vp.add(layout);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class DestinationResultsTabItem method draw.
public Widget draw() {
this.titleWidget.setText("Tasks results: " + destination);
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
menu.addWidget(UiElements.getRefreshButton(this));
final ListBoxWithObjects<RichService> listbox = new ListBoxWithObjects<RichService>();
final CustomButton cb = new CustomButton(ButtonTranslation.INSTANCE.forcePropagationButton(), ButtonTranslation.INSTANCE.forcePropagation(), SmallIcons.INSTANCE.arrowRightIcon());
GetFacilityAssignedServicesForGUI servCall = new GetFacilityAssignedServicesForGUI(facilityId);
servCall.setEvents(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
listbox.clear();
ArrayList<RichService> list = JsonUtils.jsoAsList(jso);
list = new TableSorter<RichService>().sortByName(list);
for (RichService s : list) {
if (s.getAllowedOnFacility().equalsIgnoreCase("allowed") && (s.getGenExecService() != null && s.getGenExecService().isEnabled()) && (s.getSendExecService() != null && s.getSendExecService().isEnabled())) {
listbox.addItem(s);
}
}
if (listbox.isEmpty()) {
listbox.addItem("No service available");
cb.setEnabled(false);
}
}
@Override
public void onError(PerunError error) {
listbox.clear();
listbox.addItem("Error while loading");
cb.setEnabled(false);
}
@Override
public void onLoadingStart() {
listbox.clear();
listbox.addItem("Loading...");
}
});
if (facilityId != 0) {
servCall.retrieveData();
}
cb.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
ForceServicePropagation force = new ForceServicePropagation(JsonCallbackEvents.disableButtonEvents(cb));
force.forcePropagation(facilityId, listbox.getSelectedObject().getId());
}
});
menu.addWidget(cb);
menu.addWidget(new HTML("<strong>Service: </strong>"));
menu.addWidget(listbox);
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(facility));
}
});
menu.addWidget(a);
ArrayList<String> dest = new ArrayList<String>();
dest.add(destination);
final GetTaskResultsByDestinations callback = new GetTaskResultsByDestinations(dest);
CellTable<TaskResult> table = callback.getTable();
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations