use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class CreateMailTabItem method draw.
public Widget draw() {
String title = "";
if (group != null) {
title = group.getName();
entity = PerunEntity.GROUP;
entityId = groupId;
} else {
title = vo.getName();
entity = PerunEntity.VIRTUAL_ORGANIZATION;
entityId = voId;
}
this.titleWidget.setText("Add email notification");
// languages
ArrayList<String> languages = new ArrayList<String>();
if (!Utils.getNativeLanguage().isEmpty()) {
languages.add(Utils.getNativeLanguage().get(0));
}
languages.add(0, "en");
// vertical panel
VerticalPanel vp = new VerticalPanel();
vp.setWidth("500px");
vp.setHeight("350px");
// tab panel
tabPanel.addStyleName("smallTabPanel");
tabPanel.addStyleName("smallTabPanelWithBorder");
tabPanel.setHeight("350px");
// basic settings
tabPanel.add(basicInformationTab(), "Basic settings");
// for each locale add tab
for (String locale : languages) {
tabPanel.add(messageTab(locale), "Lang: " + locale);
}
tabPanel.add(availableTagsTab(), "Available tags");
// add menu
final TabItem tab = this;
TabMenu tabMenu = new TabMenu();
saveButton = TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createEmailNotificationForApplication(), new ClickHandler() {
public void onClick(ClickEvent event) {
String appType = applicationTypeListbox.getValue(applicationTypeListbox.getSelectedIndex());
String mailType = mailTypeListbox.getValue(mailTypeListbox.getSelectedIndex());
boolean send = sendingEnabledCheckBox.getValue();
HashMap<String, MailText> messages = new HashMap<String, MailText>();
// messages
for (Map.Entry<String, TextArea> entry : messagesTextAreas.entrySet()) {
String locale = entry.getKey();
String subject = messagesSubjects.get(entry.getKey()).getValue();
String text = entry.getValue().getText();
MailText mt = MailText.construct(locale, subject, text);
messages.put(locale, mt);
}
// create object
ApplicationMail appMail = ApplicationMail.construct(appType, form.getId(), mailType, send, messages);
// request
AddApplicationMail req = new AddApplicationMail(entity, JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab));
req.addMail(appMail, entityId);
}
});
tabMenu.addWidget(saveButton);
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
// add tab panel to main panel
vp.add(tabPanel);
vp.setCellWidth(tabPanel, "500px");
vp.setCellHeight(tabPanel, "350px");
vp.add(tabMenu);
vp.setCellHeight(tabMenu, "30px");
vp.setCellHorizontalAlignment(tabMenu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class EditMailFooterTabItem method draw.
public Widget draw() {
final FlexTable content = new FlexTable();
content.setStyleName("inputFormFlexTable");
content.setWidth("360px");
final TextArea footer = new TextArea();
footer.setSize("340px", "200px");
content.setHTML(0, 0, "Footer text:");
content.getFlexCellFormatter().setStyleName(0, 0, "itemName");
content.setWidget(1, 0, footer);
content.setHTML(2, 0, "This text will be added as footer for all email notifications (replacing {mailFooter} tag in mail definition).");
content.getFlexCellFormatter().setStyleName(2, 0, "inputFormInlineComment");
final Map<String, Integer> ids = new HashMap<String, Integer>();
if (group == null) {
ids.put("vo", voId);
} else {
ids.put("group", groupId);
}
final ArrayList<Attribute> list = new ArrayList<Attribute>();
final GetListOfAttributes call = new GetListOfAttributes(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
list.addAll(JsonUtils.<Attribute>jsoAsList(jso));
// only if attribute exists
if (list != null && !list.isEmpty()) {
for (Attribute a : list) {
if (a.getFriendlyName().equalsIgnoreCase("mailFooter")) {
// if value not null - enter
if (!a.getValue().equalsIgnoreCase("null")) {
footer.setText(a.getValue());
}
}
}
}
}
});
ArrayList<String> l = new ArrayList<String>();
if (group == null) {
l.add("urn:perun:vo:attribute-def:def:mailFooter");
} else {
l.add("urn:perun:group:attribute-def:def:mailFooter");
}
call.getListOfAttributes(ids, l);
final TabItem tab = this;
VerticalPanel vp = new VerticalPanel();
TabMenu menu = new TabMenu();
final CustomButton save = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveMailFooter());
save.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// will be set
ArrayList<Attribute> toSend = new ArrayList<Attribute>();
// will be removed
ArrayList<Attribute> toRemove = new ArrayList<Attribute>();
for (Attribute a : list) {
String oldValue = a.getValue();
String newValue = "";
if (a.getFriendlyName().equalsIgnoreCase("mailFooter")) {
newValue = footer.getText();
} else {
// other than mailFooter attributes must be skipped
continue;
}
if (oldValue.equalsIgnoreCase(newValue) || (oldValue.equalsIgnoreCase("null") && newValue.equalsIgnoreCase(""))) {
// skip this cycle
continue;
} else {
if (newValue.equalsIgnoreCase("")) {
// value was cleared
toRemove.add(a);
} else {
// set value
a.setValue(newValue);
// value was changed / added
toSend.add(a);
}
}
}
// requests
SetAttributes request = new SetAttributes(JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
RemoveAttributes removeRequest = new RemoveAttributes(JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
// send if not empty
if (!toRemove.isEmpty()) {
removeRequest.removeAttributes(ids, toRemove);
}
if (!toSend.isEmpty()) {
request.setAttributes(ids, toSend);
}
}
});
menu.addWidget(save);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
vp.add(content);
vp.add(menu);
vp.setCellHeight(menu, "30px");
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 EditMailTabItem method draw.
public Widget draw() {
this.titleWidget.setText("Edit notification");
// languages
ArrayList<String> languages = appMail.getLocales();
if (!Utils.getNativeLanguage().isEmpty() && !languages.contains(Utils.getNativeLanguage().get(0))) {
languages.add(Utils.getNativeLanguage().get(0));
}
if (!languages.contains("en"))
languages.add(0, "en");
// vertical panel
VerticalPanel vp = new VerticalPanel();
vp.setWidth("500px");
vp.setHeight("350px");
// tab panel
tabPanel.addStyleName("smallTabPanel");
tabPanel.addStyleName("smallTabPanelWithBorder");
tabPanel.setHeight("350px");
// basic settings
tabPanel.add(basicInformationTab(), "Basic settings");
// for each locale add tab
for (String locale : languages) {
tabPanel.add(messageTab(locale), "Lang: " + locale);
}
tabPanel.add(availableTagsTab(), "Available tags");
// add menu
final TabItem tab = this;
TabMenu tabMenu = new TabMenu();
saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveEmailNotificationForApplication(), new ClickHandler() {
public void onClick(ClickEvent event) {
// values
boolean send = sendingEnabledCheckBox.getValue();
appMail.setSend(send);
// messages
for (Map.Entry<String, TextArea> entry : messagesTextAreas.entrySet()) {
String locale = entry.getKey();
String subject = messagesSubjects.get(entry.getKey()).getValue();
String text = entry.getValue().getText();
MailText mt = MailText.construct(locale, subject, text);
appMail.setMessage(locale, mt);
}
// request
UpdateApplicationMail req = new UpdateApplicationMail(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab));
req.updateMail(appMail);
}
});
tabMenu.addWidget(saveButton);
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
// add tab panel to main panel
vp.add(tabPanel);
vp.setCellWidth(tabPanel, "500px");
vp.setCellHeight(tabPanel, "350px");
vp.add(tabMenu);
vp.setCellHeight(tabMenu, "30px");
vp.setCellHorizontalAlignment(tabMenu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class PreviewFormTabItem method draw.
public Widget draw() {
if (form.getGroup() != null) {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(form.getGroup().getShortName()) + ": form preview");
} else {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(form.getVo().getName()) + ": form preview");
}
final TabItem tab = this;
final VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
final ScrollPanel sp = new ScrollPanel();
final CustomButton switchType = new CustomButton(ButtonTranslation.INSTANCE.switchToExtensionButton(), ButtonTranslation.INSTANCE.switchBetweenInitialAndExtension(), SmallIcons.INSTANCE.applicationFormIcon());
switchType.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// switch type
if (appType.equalsIgnoreCase("EXTENSION")) {
appType = "INITIAL";
switchType.setText(ButtonTranslation.INSTANCE.switchToExtensionButton());
} else {
appType = "EXTENSION";
switchType.setText(ButtonTranslation.INSTANCE.switchToInitialButton());
}
// prepare new
prepareApplicationForm(sp);
}
});
menu.addWidget(switchType);
if (!Utils.getNativeLanguage().isEmpty()) {
final CustomButton switchLocale = new CustomButton(ButtonTranslation.INSTANCE.switchToCzechButton(Utils.getNativeLanguage().get(1)), ButtonTranslation.INSTANCE.switchBetweenCzechAndEnglish(), SmallIcons.INSTANCE.locateIcon());
menu.addWidget(switchLocale);
switchLocale.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// switch type
if (locale.equalsIgnoreCase("en")) {
locale = Utils.getNativeLanguage().get(0);
switchLocale.setText(ButtonTranslation.INSTANCE.switchToEnglishButton());
} else {
locale = "en";
switchLocale.setText(ButtonTranslation.INSTANCE.switchToCzechButton(Utils.getNativeLanguage().get(1)));
}
// prepare new
prepareApplicationForm(sp);
}
});
}
vp.add(menu);
vp.setCellHeight(menu, "30px");
vp.add(sp);
vp.setCellHeight(sp, "100%");
prepareApplicationForm(sp);
session.getUiElements().resizeSmallTabPanel(sp, 350, tab);
contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem 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();
}
Aggregations