use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.
the class AssignServiceTabItem method draw.
public Widget draw() {
titleWidget.setText("Assign service");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// menu
TabMenu menu = new TabMenu();
final GetServices services = new GetServices();
final CellTable<Service> table = services.getEmptyTable(new FieldUpdater<Service, String>() {
public void update(int index, Service object, String value) {
session.getTabManager().addTab(new ResourceSettingsTabItem(resource, object));
}
});
// remove already assigned services from offering
JsonCallbackEvents localEvents = new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
// second callback
final GetAssignedServices alreadyAssigned = new GetAssignedServices(resourceId, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
JsArray<Service> srvToRemove = JsonUtils.jsoAsArray(jso);
for (int i = 0; i < srvToRemove.length(); i++) {
services.removeFromTable(srvToRemove.get(i));
}
if (services.getList().size() == 1) {
table.getSelectionModel().setSelected(services.getList().get(0), true);
}
}
});
alreadyAssigned.retrieveData();
}
};
services.setEvents(localEvents);
final TabItem tab = this;
// button
final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignSelectedServicesToResource());
assignButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Service> servicesToAssign = services.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(servicesToAssign)) {
for (int i = 0; i < servicesToAssign.size(); i++) {
if (i != servicesToAssign.size() - 1) {
// call json normaly
AssignService request = new AssignService(JsonCallbackEvents.disableButtonEvents(assignButton));
request.assignService(servicesToAssign.get(i).getId(), resourceId);
} else {
// last change - call json with update
AssignService request = new AssignService(JsonCallbackEvents.closeTabDisableButtonEvents(assignButton, tab));
request.assignService(servicesToAssign.get(i).getId(), resourceId);
}
}
}
}
});
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(services.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
services.filterTable(text);
if (services.getList().size() == 1) {
table.getSelectionModel().setSelected(services.getList().get(0), true);
}
}
}, "Filter services by name");
vp.add(menu);
vp.setCellHeight(menu, "30px");
services.retrieveData();
assignButton.setEnabled(false);
JsonUtils.addTableManagedButton(services, table, assignButton);
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 com.google.gwt.event.dom.client.ClickEvent 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 com.google.gwt.event.dom.client.ClickEvent 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 com.google.gwt.event.dom.client.ClickEvent 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 com.google.gwt.event.dom.client.ClickEvent 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