use of cz.metacentrum.perun.webgui.widgets.Confirm in project perun by CESNET.
the class DeleteVo method testDeleting.
/**
* Tests the values, if the process can continue
*
* @return true/false for continue/stop
*/
private boolean testDeleting() {
boolean result = true;
String errorMsg = "";
if (voId == 0) {
errorMsg += "Wrong parameter <strong>VO ID</strong>.\n";
result = false;
}
if (errorMsg.length() > 0) {
Confirm c = new Confirm("Error while deleting VO", new HTML(errorMsg), true);
c.show();
}
return result;
}
use of cz.metacentrum.perun.webgui.widgets.Confirm in project perun by CESNET.
the class JsonErrorHandler method reportBox.
/**
* Creates and display a report box used for reporting errors
*
* @param error Error object returned from RPC
*/
public static void reportBox(final PerunError error) {
// clear password fields if present
final JSONObject postObject = new JSONObject(JsonUtils.parseJson(error.getPostData()));
if (postObject.getJavaScriptObject() != null) {
clearPasswords(postObject);
}
String s = "unknown";
if (PerunWebSession.getInstance().getTabManager() != null) {
s = PerunWebSession.getInstance().getTabManager().getCurrentUrl(true);
}
final String status = s;
final TextBox boxSubject = new TextBox();
boxSubject.setValue("Reported error: " + error.getRequest().getManager() + "/" + error.getRequest().getMethod() + " (" + error.getErrorId() + ")");
boxSubject.setWidth("100%");
final TextArea messageTextBox = new TextArea();
messageTextBox.setSize("335px", "100px");
// ok click - report
ClickHandler sendReportHandler = new ClickHandler() {
public void onClick(ClickEvent event) {
String text = getErrorFullMessage(messageTextBox, error, postObject, status);
final String finalText = text;
// request itself
SendMessageToRt msg = new SendMessageToRt(new JsonCallbackEvents() {
@Override
public void onError(PerunError error) {
FlexTable layout = new FlexTable();
TextArea scrollPanel = new TextArea();
scrollPanel.setText(finalText);
layout.setWidget(0, 0, new HTML("<p>" + new Image(LargeIcons.INSTANCE.errorIcon())));
layout.setHTML(0, 1, "<p>Reporting errors is not working at the moment. We are sorry for inconvenience. <p>Please send following text to <strong>perun@cesnet.cz</strong>.");
layout.getFlexCellFormatter().setColSpan(1, 0, 2);
layout.setWidget(1, 0, scrollPanel);
scrollPanel.setSize("350px", "150px");
layout.getFlexCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP);
layout.getFlexCellFormatter().setAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP);
layout.getFlexCellFormatter().setStyleName(0, 0, "alert-box-image");
Confirm c = new Confirm("Error report is not working", layout, true);
c.setNonScrollable(true);
c.setAutoHide(false);
c.show();
}
});
if (boxSubject.getValue().isEmpty()) {
msg.sendMessage(SendMessageToRt.DEFAULT_QUEUE, "Reported error: " + error.getRequest().getManager() + "/" + error.getRequest().getMethod() + " (" + error.getErrorId() + ")", text);
} else {
msg.sendMessage(SendMessageToRt.DEFAULT_QUEUE, boxSubject.getValue(), text);
}
}
};
FlexTable baseLayout = new FlexTable();
baseLayout.setStyleName("alert-box-table");
baseLayout.setWidth("350px");
baseLayout.setHTML(0, 0, "<p>You can provide any message for this error report (e.g. describing what you tried to do). When you are done, click on send button.");
baseLayout.setHTML(1, 0, "<strong>Subject:</strong>");
baseLayout.setWidget(2, 0, boxSubject);
baseLayout.setHTML(3, 0, "<strong>Message:</strong>");
baseLayout.setWidget(4, 0, messageTextBox);
final Anchor showDetails = new Anchor("Show message preview");
final TextArea fullMessage = new TextArea();
fullMessage.setReadOnly(true);
fullMessage.setVisible(false);
fullMessage.setSize("335px", "100px");
showDetails.addClickHandler(new ClickHandler() {
boolean pressed = false;
@Override
public void onClick(ClickEvent clickEvent) {
if (pressed) {
showDetails.setText("Show message preview");
fullMessage.setVisible(false);
} else {
showDetails.setText("Hide preview");
fullMessage.setText(getErrorFullMessage(messageTextBox, error, postObject, status));
fullMessage.setVisible(true);
}
pressed = !pressed;
}
});
messageTextBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
if (fullMessage.isVisible()) {
fullMessage.setText(getErrorFullMessage(messageTextBox, error, postObject, status));
}
}
});
baseLayout.setWidget(5, 0, showDetails);
baseLayout.setWidget(6, 0, fullMessage);
// box definition
final Confirm conf = new Confirm(WidgetTranslation.INSTANCE.jsonClientSendErrorButton(), baseLayout, sendReportHandler, WidgetTranslation.INSTANCE.jsonClientSendErrorButton(), true);
conf.setOkIcon(SmallIcons.INSTANCE.emailIcon());
conf.setNonScrollable(true);
conf.setAutoHide(false);
conf.setFocusOkButton(true);
conf.show();
messageTextBox.setFocus(true);
}
use of cz.metacentrum.perun.webgui.widgets.Confirm in project perun by CESNET.
the class FindSimilarPublications method getEmptyTable.
/**
* Returns table of users publications
* @return table
*/
public CellTable<Publication> getEmptyTable() {
// Table data provider.
dataProvider = new ListDataProvider<Publication>(list);
// Cell table
table = new PerunTable<Publication>(list);
// display row-count for perun admin only
if (!session.isPerunAdmin()) {
table.removeRowCountChangeHandler();
}
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<Publication> columnSortHandler = new ListHandler<Publication>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Publication>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
loaderImage.setEmptyResultMessage("No similar publications found.");
// show checkbox column
if (this.checkable) {
// checkbox column column
table.addCheckBoxColumn();
}
// ID COLUMN
table.addIdColumn("Publication ID", tableFieldUpdater, 60);
Column<Publication, ImageResource> lockedColumn = new Column<Publication, ImageResource>(new CustomImageResourceCell("click")) {
public ImageResource getValue(Publication object) {
if (object.isLocked()) {
return SmallIcons.INSTANCE.lockIcon();
} else {
return SmallIcons.INSTANCE.lockOpenIcon();
}
}
public void onBrowserEvent(final Context context, final Element elem, final Publication object, NativeEvent event) {
// on click and for perun admin
if ("click".equals(event.getType()) && session.isPerunAdmin()) {
final ImageResource value;
if (object.isLocked()) {
value = SmallIcons.INSTANCE.lockOpenIcon();
object.setLocked(false);
} else {
value = SmallIcons.INSTANCE.lockIcon();
object.setLocked(true);
}
LockUnlockPublications request = new LockUnlockPublications(new JsonCallbackEvents() {
@Override
public void onLoadingStart() {
getCell().setValue(context, elem, SmallIcons.INSTANCE.updateIcon());
}
@Override
public void onFinished(JavaScriptObject jso) {
// change picture (object already changed)
getCell().setValue(context, elem, value);
}
@Override
public void onError(PerunError error) {
// on error switch object back
if (object.isLocked()) {
object.setLocked(false);
getCell().setValue(context, elem, SmallIcons.INSTANCE.lockOpenIcon());
} else {
object.setLocked(true);
getCell().setValue(context, elem, SmallIcons.INSTANCE.lockIcon());
}
}
});
// send request
ArrayList<Publication> list = new ArrayList<Publication>();
list.add(object);
request.lockUnlockPublications(object.isLocked(), list);
}
}
};
table.addColumn(lockedColumn, "Lock");
// TITLE COLUMN
Column<Publication, String> titleColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {
public String getValue(Publication object) {
return object.getTitle();
}
}, this.tableFieldUpdater);
titleColumn.setSortable(true);
columnSortHandler.setComparator(titleColumn, new PublicationComparator(PublicationComparator.Column.TITLE));
table.addColumn(titleColumn, "Title");
// if display authors
if (ids.containsKey("authors")) {
if ((Integer) ids.get("authors") == 1) {
// AUTHORS COLUMN
Column<Publication, String> authorColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {
public String getValue(Publication object) {
return object.getAuthorsFormatted();
}
}, this.tableFieldUpdater);
authorColumn.setSortable(true);
columnSortHandler.setComparator(authorColumn, new PublicationComparator(PublicationComparator.Column.AUTHORS));
table.addColumn(authorColumn, "Reported by");
}
}
// YEAR COLUMN
Column<Publication, String> yearColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {
public String getValue(Publication object) {
return String.valueOf(object.getYear());
}
}, this.tableFieldUpdater);
yearColumn.setSortable(true);
columnSortHandler.setComparator(yearColumn, new PublicationComparator(PublicationComparator.Column.YEAR));
table.addColumn(yearColumn, "Year");
// CATEGORY COLUMN
Column<Publication, String> categoryColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {
public String getValue(Publication object) {
return object.getCategoryName();
}
}, this.tableFieldUpdater);
categoryColumn.setSortable(true);
columnSortHandler.setComparator(categoryColumn, new PublicationComparator(PublicationComparator.Column.CATEGORY));
table.addColumn(categoryColumn, "Category");
// THANKS COLUMN
Column<Publication, String> thanksColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {
public String getValue(Publication object) {
String result = "";
JsArray<Thanks> thks = object.getThanks();
for (int i = 0; i < thks.length(); i++) {
result += thks.get(i).getOwnerName() + ", ";
}
if (result.length() >= 2) {
result = result.substring(0, result.length() - 2);
}
return result;
}
}, this.tableFieldUpdater);
thanksColumn.setSortable(true);
columnSortHandler.setComparator(thanksColumn, new PublicationComparator(PublicationComparator.Column.THANKS));
table.addColumn(thanksColumn, "Thanked to");
// CITE COLUMN
Column<Publication, String> citaceColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {
public String getValue(Publication object) {
return "Cite";
}
}, new FieldUpdater<Publication, String>() {
public void update(int index, Publication object, String value) {
SimplePanel sp = new SimplePanel();
sp.add(new HTML(object.getMain()));
Confirm cf = new Confirm("Cite publication", sp, true);
cf.show();
}
});
table.addColumn(citaceColumn, "Cite");
return table;
}
use of cz.metacentrum.perun.webgui.widgets.Confirm in project perun by CESNET.
the class FindExternalPublications method getEmptyTable.
/**
* Returns table with publications
* @return table
*/
public CellTable<Publication> getEmptyTable() {
// Table data provider.
dataProvider = new ListDataProvider<Publication>(list);
// Cell table
table = new PerunTable<Publication>(list);
table.removeRowCountChangeHandler();
table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<Publication> columnSortHandler = new ListHandler<Publication>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Publication>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage.prepareToSearch("Please select external pub. system and year range to search for publications for import."));
loaderImage.setEmptyResultMessage("No publications found in external system.");
// show checkbox column
if (this.checkable) {
table.addCheckBoxColumn();
}
/*
// CATEGORY COLUMN
ArrayList<String> categories = new ArrayList<String>();
categories.add("Bodované v RIVu");
categories.add("Nebodované v RIVu");
categories.add("Příspěvek do ročenky");
categories.add("Výjimečné výsledky");
categories.add("Jiné");
Column<Publication, String> categoryColumn = new Column<Publication, String>(new SelectionCell(categories)){
@Override
public String getValue(Publication object) {
// category ID as string, 0 if not set
int id = object.getCategoryId();
if (id == 0) {
// set default == 21/Bodované v RIVu to object
object.setCategoryId(21);
}
if (id == 21) {
return "Bodované v RIVu";
} else if (id == 22) {
return "Nebodované v RIVu";
} else if (id == 23) {
return "Výjimečné výsledky";
} else if (id == 24) {
return "Příspěvek do ročenky";
} else if (id == 25) {
return "Jiné";
} else {
return String.valueOf(id); // return ID if no match
}
}
};
categoryColumn.setFieldUpdater(new FieldUpdater<Publication, String>() {
public void update(int index, Publication object, String value) {
int id = 0;
if (value.equalsIgnoreCase("Bodované v RIVu")) {
id = 21;
} else if (value.equalsIgnoreCase("Nebodované v RIVu")) {
id = 22;
} else if (value.equalsIgnoreCase("Příspěvek do ročenky")) {
id = 24;
} else if (value.equalsIgnoreCase("Výjimečné výsledky")) {
id = 23;
} else if (value.equalsIgnoreCase("Jiné")) {
id = 25;
}
object.setCategoryId(id);
selectionModel.setSelected(object, true);
}
});
table.addColumn(categoryColumn, "Category");
// NOT USEFULL => DISABLED
// EXTERNAL ID
TextColumn<Publication> externalIdColumn = new TextColumn<Publication>() {
public String getValue(Publication object) {
return String.valueOf(object.getExternalId());
};
};
externalIdColumn.setSortable(true);
columnSortHandler.setComparator(externalIdColumn, new PublicationComparator(PublicationComparator.Column.EXTERNAL_ID));
table.addColumn(externalIdColumn, "External Id");
*/
// TITLE COLUMN
TextColumn<Publication> titleColumn = new TextColumn<Publication>() {
public String getValue(Publication object) {
return object.getTitle();
}
};
titleColumn.setSortable(true);
columnSortHandler.setComparator(titleColumn, new PublicationComparator(PublicationComparator.Column.TITLE));
table.addColumn(titleColumn, "Title");
// AUTHORS COLUMN
TextColumn<Publication> authorColumn = new TextColumn<Publication>() {
public String getValue(Publication object) {
return object.getAuthorsFormatted();
}
};
authorColumn.setSortable(true);
columnSortHandler.setComparator(authorColumn, new PublicationComparator(PublicationComparator.Column.AUTHORS));
table.addColumn(authorColumn, "Authors");
// YEAR COLUMN
TextColumn<Publication> yearColumn = new TextColumn<Publication>() {
public String getValue(Publication object) {
return String.valueOf(object.getYear());
}
};
yearColumn.setSortable(true);
columnSortHandler.setComparator(yearColumn, new PublicationComparator(PublicationComparator.Column.YEAR));
table.addColumn(yearColumn, "Year");
// ISBN COLUMN
TextColumn<Publication> isbnColumn = new TextColumn<Publication>() {
public String getValue(Publication object) {
return object.getIsbn();
}
};
isbnColumn.setSortable(true);
columnSortHandler.setComparator(isbnColumn, new PublicationComparator(PublicationComparator.Column.ISBN));
table.addColumn(isbnColumn, "ISBN");
// CITE COLUMN
Column<Publication, String> citaceColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {
public String getValue(Publication object) {
return "Cite";
}
}, new FieldUpdater<Publication, String>() {
public void update(int index, Publication object, String value) {
SimplePanel sp = new SimplePanel();
sp.add(new HTML(object.getMain()));
Confirm cf = new Confirm("Cite publication", sp, true);
cf.show();
}
});
table.addColumn(citaceColumn, "Cite");
return table;
}
use of cz.metacentrum.perun.webgui.widgets.Confirm in project perun by CESNET.
the class ConvertAttributeToUnique method testDeleting.
/**
* Tests the values, if the process can continue
*
* @return true/false for continue/stop
*/
private boolean testDeleting() {
boolean result = true;
String errorMsg = "";
if (attrDefId == 0) {
errorMsg += "Wrong Attribute definition ID parameter.\n";
result = false;
}
if (errorMsg.length() > 0) {
Confirm c = new Confirm("Error while modifying attribute", new Label(errorMsg), true);
c.show();
}
return result;
}
Aggregations