use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class SecurityTeamMembersTabItem method draw.
public Widget draw() {
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(securityTeam.getName()) + ": " + "members");
// Get vos request
final GetAdmins teams = new GetAdmins(PerunEntity.SECURITY_TEAM, securityTeamId);
// Events for reloading when finished
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(teams);
TabMenu tabMenu = new TabMenu();
// add menu to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
tabMenu.addWidget(UiElements.getRefreshButton(this));
// do not display to sec admins only
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addMemberToSecurityTeam(), new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddSecurityTeamManagerTabItem(securityTeam), true);
}
}));
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, buttonTranslation.removeMemberOfSecurityTeam());
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<User> itemsToRemove = teams.getTableSelectedList();
UiElements.showDeleteConfirm(itemsToRemove, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < itemsToRemove.size(); i++) {
RemoveAdmin request;
if (i == itemsToRemove.size() - 1) {
request = new RemoveAdmin(PerunEntity.SECURITY_TEAM, JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new RemoveAdmin(PerunEntity.SECURITY_TEAM, JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.removeSecurityTeamAdmin(securityTeam, itemsToRemove.get(i));
}
}
});
}
});
tabMenu.addWidget(removeButton);
final TabItem tab = this;
CellTable<User> table;
if (session.isPerunAdmin()) {
// get the table with custom onclick
table = teams.getTable(new FieldUpdater<User, String>() {
@Override
public void update(int i, User user, String string) {
session.getTabManager().addTab(new UserDetailTabItem(user));
session.getTabManager().closeTab(tab, false);
}
});
} else {
table = teams.getTable();
}
// 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 the table to the main panel
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, 0, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class ViewExecServiceTabItem method draw.
public Widget draw() {
// TITLE
this.titleWidget.setText("Exec of " + Utils.getStrippedStringWithEllipsis(execService.getService().getName()) + " (" + execService.getType() + ")");
// CONTENT
final VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
AbsolutePanel dp = new AbsolutePanel();
final FlexTable menu = new FlexTable();
menu.setCellSpacing(5);
// Add service information
menu.setWidget(0, 0, new Image(LargeIcons.INSTANCE.trafficLightsIcon()));
Label serviceName = new Label();
serviceName.setText("Exec of " + Utils.getStrippedStringWithEllipsis(execService.getService().getName(), 40));
serviceName.setStyleName("now-managing");
serviceName.setTitle(execService.getService().getName());
menu.setWidget(0, 1, serviceName);
menu.setHTML(0, 2, " ");
menu.getFlexCellFormatter().setWidth(0, 2, "25px");
int column = 3;
CustomButton cb = new CustomButton("", "Edit exec service", SmallIcons.INSTANCE.applicationFormEditIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new EditExecServiceTabItem(execService, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
execService = jso.cast();
open();
draw();
}
}));
}
});
menu.setWidget(0, column, cb);
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\">" + execService.getId() + "</span>");
column++;
menu.setHTML(0, column, " ");
menu.getFlexCellFormatter().setWidth(0, column, "25px");
column++;
}
menu.setHTML(0, column, "<strong>Type:</strong><br/><span class=\"inputFormInlineComment\">" + execService.getType() + "</span>");
column++;
menu.setHTML(0, column, " ");
menu.getFlexCellFormatter().setWidth(0, column, "25px");
column++;
menu.setHTML(0, column, "<strong>Enabled:</strong><br/><span class=\"inputFormInlineComment\">" + execService.isEnabled() + "</span>");
column++;
menu.setHTML(0, column, " ");
menu.getFlexCellFormatter().setWidth(0, column, "25px");
column++;
menu.setHTML(0, column, "<strong>Script path:</strong><br/><span class=\"inputFormInlineComment\">" + execService.getScriptPath() + "</span>");
column++;
menu.setHTML(0, column, " ");
menu.getFlexCellFormatter().setWidth(0, column, "25px");
column++;
menu.setHTML(0, column, "<strong>Delay:</strong><br/><span class=\"inputFormInlineComment\">" + execService.getDefaultDelay() + "</span>");
// TODO - waiting for time, when service will have description param
//menu.setHTML(0, 3, "<strong>Short name:</strong><br/><span class=\"inputFormInlineComment\">"+service.getDescription()+"</span>");
dp.add(menu);
vp.add(dp);
vp.setCellHeight(dp, "30px");
// tab panel
TabLayoutPanel tabPanel = new TabLayoutPanel(33, Style.Unit.PX);
tabPanel.addStyleName("smallTabPanel");
final TabItem tab = this;
tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
public void onSelection(SelectionEvent<Integer> event) {
UiElements.runResizeCommands(tab);
}
});
// information overview
final SimplePanel sp0 = new SimplePanel();
sp0.setWidget(getDependencyContent());
session.getUiElements().resizeSmallTabPanel(tabPanel, 100, this);
tabPanel.add(sp0, "Dependencies");
session.getUiElements().resizePerunTable(tabPanel, 100, this);
// add tabs to the main panel
vp.add(tabPanel);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class EditUserDetailsTabItem method draw.
public Widget draw() {
titleWidget = new Label("Edit user");
VerticalPanel vp = new VerticalPanel();
final TextBox beforeName = new TextBox();
final TextBox afterName = new TextBox();
final TextBox firstName = new TextBox();
final TextBox middleName = new TextBox();
final TextBox lastName = new TextBox();
// prepares layout
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
// set values from user
beforeName.setText(user.getTitleBefore());
afterName.setText(user.getTitleAfter());
firstName.setText(user.getFirstName());
lastName.setText(user.getLastName());
middleName.setText(user.getMiddleName());
// service users can have only first and last name (first is fixed as "(Service)"
if (user.isServiceUser()) {
beforeName.setEnabled(false);
afterName.setEnabled(false);
firstName.setEnabled(false);
middleName.setEnabled(false);
}
// close tab events
final TabItem tab = this;
TabMenu menu = new TabMenu();
// send button
final CustomButton saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, buttonTranslation.saveResourceDetails());
if (session.isPerunAdmin()) {
saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
User u = JsonUtils.clone(user).cast();
u.setFirstName(firstName.getText().trim());
u.setMiddleName(middleName.getText().trim());
u.setLastName(lastName.getText().trim());
u.setTitleBefore(beforeName.getText().trim());
u.setTitleAfter(afterName.getText().trim());
UpdateUser request = new UpdateUser(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab, events));
request.updateUser(u);
}
});
} else {
saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
User u = JsonUtils.clone(user).cast();
u.setTitleBefore(beforeName.getText().trim());
u.setTitleAfter(afterName.getText().trim());
UpdateNameTitles request = new UpdateNameTitles(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab, events));
request.updateUserTitles(u);
}
});
}
// 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, "Title before name:");
layout.setWidget(0, 1, beforeName);
layout.setHTML(1, 0, "Title after name:");
layout.setWidget(1, 1, afterName);
if (session.isPerunAdmin()) {
layout.setHTML(2, 0, "First name:");
layout.setWidget(2, 1, firstName);
layout.setHTML(3, 0, "Middle name:");
layout.setWidget(3, 1, middleName);
layout.setHTML(4, 0, "Last name:");
layout.setWidget(4, 1, lastName);
}
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.tabs.TabItem in project perun by CESNET.
the class IdentitySelectorTabItem method draw.
public Widget draw() {
final TabItem tab = this;
HorizontalPanel horizontalSplitter = new HorizontalPanel();
horizontalSplitter.setHeight("500px");
horizontalSplitter.setWidth("100%");
// BASE LAYOUT
DecoratorPanel dp = new DecoratorPanel();
FlexTable baseLayout = new FlexTable();
baseLayout.setCellSpacing(10);
dp.add(baseLayout);
baseLayout.setHTML(0, 0, "<p class=\"subsection-heading\">Select base identity</p>");
baseLayout.setHTML(1, 0, "Your base identity you are currently logged in.");
baseLayout.getFlexCellFormatter().setStyleName(1, 0, "inputFormInlineComment");
Anchor userName = new Anchor();
userName.setText(session.getUser().getFullNameWithTitles());
userName.addStyleName("now-managing");
userName.addStyleName("pointer");
userName.setTitle(session.getUser().getFullNameWithTitles());
userName.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTab(new SelfDetailTabItem(session.getUser()));
session.getTabManager().closeTab(tab, false);
}
});
baseLayout.setWidget(2, 0, new Image(LargeIcons.INSTANCE.userGrayIcon()));
baseLayout.setWidget(2, 1, userName);
baseLayout.getFlexCellFormatter().setColSpan(0, 0, 2);
baseLayout.getFlexCellFormatter().setColSpan(1, 0, 2);
// SERVICE IDENTITIES LAYOUT
DecoratorPanel dp2 = new DecoratorPanel();
final FlexTable serviceLayout = new FlexTable();
serviceLayout.setCellSpacing(10);
dp2.add(serviceLayout);
serviceLayout.setHTML(0, 0, "<p class=\"subsection-heading\">Select service identity</p>");
serviceLayout.setHTML(1, 0, "Service identities you have access to.");
serviceLayout.getFlexCellFormatter().setStyleName(1, 0, "inputFormInlineComment");
horizontalSplitter.add(dp);
horizontalSplitter.setCellWidth(dp, "50%");
horizontalSplitter.setCellVerticalAlignment(dp, HasVerticalAlignment.ALIGN_MIDDLE);
horizontalSplitter.setCellHorizontalAlignment(dp, HasHorizontalAlignment.ALIGN_CENTER);
ScrollPanel sp = new ScrollPanel();
final FlexTable innerTable = new FlexTable();
sp.setWidget(innerTable);
sp.setStyleName("scroll-max-height");
serviceLayout.setWidget(2, 0, sp);
if (session.getEditableUsers().size() > 1) {
// user has service identities
GetSpecificUsersByUser call = new GetSpecificUsersByUser(session.getUser().getId(), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
ArrayList<User> list = JsonUtils.jsoAsList(jso);
if (list != null && !list.isEmpty()) {
int row = 0;
for (User u : list) {
if (u.isSponsoredUser())
continue;
final User u2 = u;
innerTable.setWidget(row, 0, new Image(LargeIcons.INSTANCE.userRedIcon()));
Anchor userName = new Anchor();
userName.setText(u2.getFullNameWithTitles());
userName.addStyleName("now-managing");
userName.addStyleName("pointer");
userName.setTitle(u2.getFullNameWithTitles());
userName.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTab(new SelfDetailTabItem(u2));
session.getTabManager().closeTab(tab, false);
}
});
innerTable.setWidget(row, 1, userName);
row++;
}
} else {
innerTable.setHTML(0, 0, "You have no service identities");
}
}
@Override
public void onLoadingStart() {
innerTable.setWidget(0, 0, new AjaxLoaderImage().loadingStart());
}
@Override
public void onError(PerunError error) {
innerTable.setWidget(0, 0, new AjaxLoaderImage().loadingError(error));
}
});
call.retrieveData();
horizontalSplitter.add(dp2);
horizontalSplitter.setCellWidth(dp2, "50%");
horizontalSplitter.setCellHorizontalAlignment(dp2, HasHorizontalAlignment.ALIGN_CENTER);
horizontalSplitter.setCellVerticalAlignment(dp2, HasVerticalAlignment.ALIGN_MIDDLE);
}
this.contentWidget.setWidget(horizontalSplitter);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class RequestQuotaChangeTabItem method draw.
public Widget draw() {
new GetEntityById(PerunEntity.VIRTUAL_ORGANIZATION, resource.getVoId(), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
vo = jso.cast();
}
}).retrieveData();
VerticalPanel vp = new VerticalPanel();
// set tab name
this.titleWidget.setText(getQuotaTypeAsString() + " quota change request");
// quota string
//String quotaStr = getQuotaTypeAsString();
// new quota input
final ExtendedTextBox newQuota = new ExtendedTextBox();
final ExtendedTextArea reason = new ExtendedTextArea();
final ListBox units = new ListBox();
units.addItem("M");
units.addItem("G");
units.addItem("T");
// default G
units.setSelectedIndex(1);
FlexTable ft = new FlexTable();
ft.setStyleName("inputFormFlexTable");
ft.setWidget(0, 0, new HTML("Resource:"));
ft.setWidget(1, 0, new HTML("Current quota:"));
ft.setWidget(2, 0, new HTML("Requested quota:"));
ft.setWidget(3, 0, new HTML("Reason:"));
for (int i = 0; i < ft.getRowCount(); i++) {
ft.getFlexCellFormatter().setStyleName(i, 0, "itemName");
}
ft.setText(0, 1, resource.getName());
ft.setText(1, 1, oldQuota + " (default: " + defaultQuota + ")");
ft.setWidget(2, 1, newQuota);
ft.getFlexCellFormatter().setColSpan(3, 1, 2);
ft.setWidget(3, 1, reason);
final CustomButton requestQuotaButton = new CustomButton("Send request", "Send quota change request", SmallIcons.INSTANCE.emailIcon());
if (this.quotaType.equals(QuotaType.DATA)) {
ft.setWidget(2, 2, units);
ft.getFlexCellFormatter().setColSpan(4, 0, 3);
} else {
ft.getFlexCellFormatter().setColSpan(4, 0, 2);
}
final ExtendedTextBox.TextBoxValidator quotaValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (newQuota.getTextBox().getValue().trim().isEmpty()) {
newQuota.setError("You must enter requested quota!");
} else if (!JsonUtils.checkParseInt(newQuota.getTextBox().getValue().trim())) {
newQuota.setError("Requested quota must be a number!");
} else {
newQuota.setOk();
return true;
}
return false;
}
};
newQuota.setValidator(quotaValidator);
final ExtendedTextArea.TextAreaValidator reasonValidator = new ExtendedTextArea.TextAreaValidator() {
@Override
public boolean validateTextArea() {
if (reason.getTextArea().getValue().trim().isEmpty()) {
reason.setError("You must specify reason for quota change!");
return false;
}
reason.setOk();
return true;
}
};
reason.setValidator(reasonValidator);
reason.getTextArea().setSize("205px", "100px");
requestQuotaButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (!quotaValidator.validateTextBox() && !reasonValidator.validateTextArea())
return;
if (quotaType.equals(QuotaType.DATA)) {
requestQuotaChange(newQuota.getTextBox().getValue().trim() + units.getItemText(units.getSelectedIndex()), reason.getTextArea().getText());
} else {
requestQuotaChange(newQuota.getTextBox().getValue().trim(), reason.getTextArea().getText());
}
}
});
vp.add(ft);
TabMenu menu = new TabMenu();
menu.addWidget(requestQuotaButton);
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(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations