use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class AssignTagTabItem method draw.
public Widget draw() {
titleWidget.setText("Add tag");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// menu
TabMenu menu = new TabMenu();
final GetAllResourcesTags tags = new GetAllResourcesTags(PerunEntity.VIRTUAL_ORGANIZATION, resource.getVoId());
final CellTable<ResourceTag> table = tags.getTable();
final TabItem tab = this;
// button
final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignSelectedTagsToResource());
assignButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<ResourceTag> tagsToAssign = tags.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(tagsToAssign)) {
for (int i = 0; i < tagsToAssign.size(); i++) {
if (i != tagsToAssign.size() - 1) {
// call json normaly
AssignResourceTag request = new AssignResourceTag(resourceId, JsonCallbackEvents.disableButtonEvents(assignButton));
request.assignResourceTag(tagsToAssign.get(i));
} else {
// last change - call json with update
AssignResourceTag request = new AssignResourceTag(resourceId, JsonCallbackEvents.closeTabDisableButtonEvents(assignButton, tab));
request.assignResourceTag(tagsToAssign.get(i));
}
}
}
}
});
menu.addWidget(assignButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
menu.addFilterWidget(new ExtendedSuggestBox(tags.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
tags.filterTable(text);
// if single group, select
if (tags.getList().size() == 1) {
table.getSelectionModel().setSelected(tags.getList().get(0), true);
}
}
}, ButtonTranslation.INSTANCE.filterGroup());
vp.add(menu);
vp.setCellHeight(menu, "30px");
assignButton.setEnabled(false);
JsonUtils.addTableManagedButton(tags, table, assignButton);
tags.retrieveData();
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class MembershipExpirationTabItem method draw.
public Widget draw() {
this.titleWidget.setText("Set membership expiration");
VerticalPanel vp = new VerticalPanel();
vp.setSize("350px", "100%");
final FlexTable layout = new FlexTable();
layout.setSize("100%", "100%");
layout.setStyleName("inputFormFlexTable");
layout.setHTML(0, 0, "Current expiration:");
layout.getFlexCellFormatter().setStyleName(0, 0, "itemName");
layout.setHTML(0, 1, member.getStatus());
final Attribute expire = member.getAttribute("urn:perun:member:attribute-def:def:membershipExpiration");
String expirationValue = null;
if (expire != null && !"null".equalsIgnoreCase(expire.getValue())) {
layout.setHTML(0, 1, expire.getValue());
expirationValue = expire.getValue().substring(0, ((expire.getValue().length() > 10) ? 9 : expire.getValue().length() - 1));
} else {
layout.setHTML(0, 1, "<i>never</i>");
}
layout.setHTML(1, 0, "New expiration:");
layout.getFlexCellFormatter().setStyleName(1, 0, "itemName");
final CustomButton changeButton = new CustomButton("Save", "Save changes in membership expiration date", SmallIcons.INSTANCE.diskIcon());
final DatePicker picker = new DatePicker();
picker.setWidth("100%");
layout.getFlexCellFormatter().setColSpan(2, 0, 2);
layout.setWidget(2, 0, picker);
picker.addValueChangeHandler(new ValueChangeHandler<Date>() {
@Override
public void onValueChange(ValueChangeEvent<Date> dateValueChangeEvent) {
layout.setHTML(1, 1, DateTimeFormat.getFormat("yyyy-MM-dd").format(picker.getValue()));
changeButton.setEnabled(true);
changeOrNever = true;
}
});
try {
// set values if possible
picker.setCurrentMonth(DateTimeFormat.getFormat("yyyy-MM-dd").parse(expirationValue));
picker.setValue(DateTimeFormat.getFormat("yyyy-MM-dd").parse(expirationValue));
} catch (Exception ex) {
// if not parseable, display current date
picker.setCurrentMonth(new Date());
picker.setValue(new Date());
}
Anchor anchor = new Anchor("Set expiration to 'never'");
anchor.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
layout.setHTML(1, 1, "<i>never</i>");
changeOrNever = false;
changeButton.setEnabled(true);
}
});
layout.setWidget(3, 0, anchor);
layout.getFlexCellFormatter().setColSpan(3, 0, 2);
layout.getFlexCellFormatter().getElement(3, 0).setAttribute("style", "text-align: right;");
TabMenu menu = new TabMenu();
final TabItem tab = this;
// by default false
changeButton.setEnabled(false);
changeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
if (changeOrNever) {
expire.setValueAsString(DateTimeFormat.getFormat("yyyy-MM-dd").format(picker.getValue()));
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("member", member.getId());
SetAttributes request = new SetAttributes(JsonCallbackEvents.closeTabDisableButtonEvents(changeButton, tab));
ArrayList<Attribute> list = new ArrayList<Attribute>();
list.add(expire);
request.setAttributes(ids, list);
} else {
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("member", member.getId());
RemoveAttributes request = new RemoveAttributes(JsonCallbackEvents.closeTabDisableButtonEvents(changeButton, tab));
ArrayList<Attribute> list = new ArrayList<Attribute>();
list.add(expire);
request.removeAttributes(ids, list);
}
}
});
menu.addWidget(changeButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, ButtonTranslation.INSTANCE.cancelButton(), 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 cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class AuditLogTabItem method draw.
public Widget draw() {
// page main tab
final VerticalPanel mainTab = new VerticalPanel();
mainTab.setSize("100%", "100%");
// number of messages
final TextBox tb = new TextBox();
tb.setText(String.valueOf(count));
tb.setWidth("100px");
// menu panel
TabMenu menu = new TabMenu();
mainTab.add(menu);
mainTab.setCellHeight(menu, "30px");
CustomButton refreshButton = TabMenu.getPredefinedButton(ButtonType.REFRESH, ButtonTranslation.INSTANCE.refreshAuditMessages());
// retrieve messages
final GetAuditMessagesByCount call = new GetAuditMessagesByCount(JsonCallbackEvents.disableButtonEvents(refreshButton));
call.setCount(count);
CellTable<AuditMessage> table = call.getTable();
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
mainTab.add(sp);
// resize perun table to correct size on screen
session.getUiElements().resizePerunTable(sp, 350, this);
// refresh button action
refreshButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (JsonUtils.checkParseInt(tb.getText())) {
call.clearTable();
count = Integer.parseInt(tb.getText());
call.setCount(count);
call.retrieveData();
} else {
JsonUtils.cantParseIntConfirm("Number of messages", tb.getText());
}
}
});
menu.addWidget(refreshButton);
// enter key = refresh on count text box
tb.addKeyPressHandler(new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
if (JsonUtils.checkParseInt(tb.getText())) {
call.clearTable();
count = Integer.parseInt(tb.getText());
call.setCount(count);
call.retrieveData();
} else {
JsonUtils.cantParseIntConfirm("Number of messages", tb.getText());
}
}
}
});
// add textbox into menu
menu.addWidget(new HTML("<strong>Number of messages: </strong>"));
menu.addWidget(tb);
this.contentWidget.setWidget(mainTab);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class CreateOwnerTabItem method draw.
public Widget draw() {
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// textboxes which set the class data when updated
final ExtendedTextBox ownerNameTextBox = new ExtendedTextBox();
final ExtendedTextBox ownerContactTextBox = new ExtendedTextBox();
final ListBox ownerType = new ListBox();
ownerType.addItem(ObjectTranslation.INSTANCE.ownerTypeAdministrative(), "administrative");
ownerType.addItem(ObjectTranslation.INSTANCE.ownerTypeTechnical(), "technical");
final ExtendedTextBox.TextBoxValidator nameValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (ownerNameTextBox.getTextBox().getText().trim().isEmpty()) {
ownerNameTextBox.setError("Name can't be empty.");
return false;
}
ownerNameTextBox.setOk();
return true;
}
};
final ExtendedTextBox.TextBoxValidator contactValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (ownerContactTextBox.getTextBox().getText().trim().isEmpty()) {
ownerContactTextBox.setError("Contact can't be empty.");
return false;
}
ownerContactTextBox.setOk();
return true;
}
};
ownerNameTextBox.setValidator(nameValidator);
ownerContactTextBox.setValidator(contactValidator);
// layout
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
// Add some standard form options
layout.setHTML(0, 0, "Name:");
layout.setWidget(0, 1, ownerNameTextBox);
layout.setHTML(1, 0, "Contact:");
layout.setWidget(1, 1, ownerContactTextBox);
layout.setHTML(2, 0, "Type:");
layout.setWidget(2, 1, ownerType);
for (int i = 0; i < layout.getRowCount(); i++) {
cellFormatter.addStyleName(i, 0, "itemName");
}
// buttons
TabMenu menu = new TabMenu();
final TabItem tab = this;
final CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createOwner());
createButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (nameValidator.validateTextBox() && contactValidator.validateTextBox()) {
CreateOwner request = new CreateOwner(JsonCallbackEvents.closeTabDisableButtonEvents(createButton, tab));
request.createOwner(ownerNameTextBox.getTextBox().getText().trim(), ownerContactTextBox.getTextBox().getText().trim(), ownerType.getValue(ownerType.getSelectedIndex()));
}
}
});
menu.addWidget(createButton);
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 cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class ExtSourcesTabItem method draw.
public Widget draw() {
// create main panel for content
VerticalPanel mainPage = new VerticalPanel();
mainPage.setWidth("100%");
// create new instance for jsonCall getExtSources
final GetExtSources getExtSources = new GetExtSources();
getExtSources.setCheckable(false);
// menu
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
menu.addFilterWidget(new ExtendedSuggestBox(getExtSources.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
getExtSources.filterTable(text);
}
}, "Filter external sources by name or type");
final CustomButton loadButton = new CustomButton("Load ext sources", "Load ext sources definitions from a local file.", SmallIcons.INSTANCE.worldIcon());
loadButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
LoadExtSourcesDefinitions loadCall = new LoadExtSourcesDefinitions(JsonCallbackEvents.disableButtonEvents(loadButton, JsonCallbackEvents.refreshTableEvents(getExtSources)));
loadCall.retrieveData();
}
});
menu.addWidget(loadButton);
// get CellTable from jsonCall
CellTable<ExtSource> extSourcesTable = getExtSources.getTable();
extSourcesTable.setStyleName("perun-table");
ScrollPanel scrollTable = new ScrollPanel(extSourcesTable);
scrollTable.addStyleName("perun-tableScrollPanel");
// put page into scroll panel
mainPage.add(menu);
mainPage.setCellHeight(menu, "30px");
mainPage.add(scrollTable);
session.getUiElements().resizePerunTable(scrollTable, 350, this);
this.contentWidget.setWidget(mainPage);
return getWidget();
}
Aggregations