use of com.google.gwt.event.dom.client.ClickHandler in project gwt-cs by iSergio.
the class CZML method buildPanel.
@Override
public void buildPanel() {
csVPanel = new ViewerPanel();
csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/simple.czml"));
csVPanel.getViewer().camera.flyHome(0);
Button satellitesBtn = new Button("Satellites");
satellitesBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
reset();
csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/simple.czml"));
csVPanel.getViewer().camera.flyHome(0);
}
});
Button vehicleBtn = new Button("Vehicle");
vehicleBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
reset();
csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/Vehicle.czml"));
ViewOptions viewOptions = new ViewOptions();
viewOptions.destinationPos = Cartesian3.fromDegrees(-116.52, 35.02, 95000);
viewOptions.orientation = new HeadingPitchRoll(6, -Math.PI_OVER_TWO());
csVPanel.getViewer().scene().camera().setView(viewOptions);
}
});
HorizontalPanel hPanel = new HorizontalPanel();
hPanel.setSpacing(10);
hPanel.add(satellitesBtn);
hPanel.add(vehicleBtn);
AbsolutePanel aPanel = new AbsolutePanel();
aPanel.add(csVPanel);
aPanel.add(hPanel, 20, 20);
contentPanel.add(new HTML("<p>A simple CZML example showing four satellites in orbit around the Earth, and some ground objects.</p>"));
contentPanel.add(aPanel);
initWidget(contentPanel);
}
use of com.google.gwt.event.dom.client.ClickHandler in project google-gin by gwtplus.
the class DefaultGameDialogs method show.
public void show(String title) {
final DialogBox box = new DialogBox();
box.setAnimationEnabled(true);
box.setText(title);
// It's an higherlower, folks!
box.setWidth("200px");
VerticalPanel verticalPanel = new VerticalPanel();
Button higher = new Button("Higher, higher!");
higher.addStyleName("centered");
higher.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
box.hide();
gameHost.get().playerGuess(RelationshipToPreviousCard.HIGHER);
}
});
verticalPanel.add(higher);
Button lower = new Button("Down, boy!");
lower.addStyleName("centered");
lower.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
box.hide();
gameHost.get().playerGuess(RelationshipToPreviousCard.LOWER);
}
});
verticalPanel.add(lower);
HorizontalPanel hp = new HorizontalPanel();
hp.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
hp.add(verticalPanel);
box.setWidget(hp);
box.center();
box.show();
}
use of com.google.gwt.event.dom.client.ClickHandler in project perun by CESNET.
the class CreateAttributeDefinitionTabItem method draw.
public Widget draw() {
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// creates HTML elements
final ExtendedTextBox attributeDisplayName = new ExtendedTextBox();
final ExtendedTextBox attributeName = new ExtendedTextBox();
final ExtendedTextBox attributeDescription = new ExtendedTextBox();
final ExtendedTextBox.TextBoxValidator nameValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (attributeName.getTextBox().getText().trim().isEmpty()) {
attributeName.setError("Name of attribute can't be empty.");
} else if (!attributeName.getTextBox().getText().trim().matches(Utils.ATTRIBUTE_FRIENDLY_NAME_MATCHER)) {
attributeName.setError("Name of attribute can contain only letters, numbers, dash and colon.");
} else {
attributeName.setOk();
return true;
}
return false;
}
};
final ExtendedTextBox.TextBoxValidator descriptionValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (!attributeDescription.getTextBox().getText().trim().isEmpty()) {
attributeDescription.setOk();
return true;
} else {
attributeDescription.setError("Description of attribute can't be empty.");
return false;
}
}
};
final ExtendedTextBox.TextBoxValidator displayNameValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (!attributeDisplayName.getTextBox().getText().trim().isEmpty()) {
attributeDisplayName.setOk();
return true;
} else {
attributeDisplayName.setError("Display name of attribute can't be empty.");
return false;
}
}
};
attributeName.setValidator(nameValidator);
attributeDisplayName.setValidator(displayNameValidator);
attributeDescription.setValidator(descriptionValidator);
final ListBox entityListBox = new ListBox();
final ListBox definitionListBox = new ListBox();
final ListBox typeListBox = new ListBox();
// fill listboxs with pre-defined values
entityListBox.addItem("facility", "urn:perun:facility:");
entityListBox.addItem("resource", "urn:perun:resource:");
entityListBox.addItem("group", "urn:perun:group:");
entityListBox.addItem("group_resource", "urn:perun:group_resource:");
entityListBox.addItem("host", "urn:perun:host:");
entityListBox.addItem("member", "urn:perun:member:");
entityListBox.addItem("member_group", "urn:perun:member_group:");
entityListBox.addItem("member_resource", "urn:perun:member_resource:");
entityListBox.addItem("user", "urn:perun:user:");
entityListBox.addItem("user_ext_source", "urn:perun:ues:");
entityListBox.addItem("user_facility", "urn:perun:user_facility:");
entityListBox.addItem("vo", "urn:perun:vo:");
entityListBox.addItem("entityless", "urn:perun:entityless:");
definitionListBox.addItem("def", "attribute-def:def");
definitionListBox.addItem("opt", "attribute-def:opt");
definitionListBox.addItem("virt", "attribute-def:virt");
definitionListBox.addItem("core", "attribute-def:core");
typeListBox.addItem("String", "java.lang.String");
typeListBox.addItem("Integer", "java.lang.Integer");
typeListBox.addItem("Boolean", "java.lang.Boolean");
typeListBox.addItem("Array", "java.util.ArrayList");
typeListBox.addItem("LinkedHashMap", "java.util.LinkedHashMap");
// prepare layout for this tab
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
TabMenu menu = new TabMenu();
// BUTTONS
final CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, buttonTranslation.createAttributeDefinition());
menu.addWidget(createButton);
// close tab events & enable, disable buttons
final JsonCallbackEvents closeTabEvents = JsonCallbackEvents.closeTabDisableButtonEvents(createButton, this, true);
createButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (nameValidator.validateTextBox() && descriptionValidator.validateTextBox() && displayNameValidator.validateTextBox()) {
String displayName = attributeDisplayName.getTextBox().getText().trim();
String friendlyName = attributeName.getTextBox().getText().trim();
String description = attributeDescription.getTextBox().getText().trim();
String namespace = entityListBox.getValue(entityListBox.getSelectedIndex()) + definitionListBox.getValue(definitionListBox.getSelectedIndex());
String type = typeListBox.getValue(typeListBox.getSelectedIndex());
boolean isUnique = unique.getValue();
CreateAttribute request = new CreateAttribute(JsonCallbackEvents.disableButtonEvents(createButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
AttributeDefinition a = jso.cast();
ArrayList<AttributeRights> list = new ArrayList<AttributeRights>();
AttributeRights right = AttributeRights.create(a.getId(), "SELF");
list.add(getRightsFromWidgets(selfRead, selfWrite, selfReadPublic, selfWritePublic, selfReadVo, selfWriteVo, right));
AttributeRights right2 = AttributeRights.create(a.getId(), "VOADMIN");
list.add(getRightsFromWidgets(voRead, voWrite, right2));
AttributeRights right3 = AttributeRights.create(a.getId(), "GROUPADMIN");
list.add(getRightsFromWidgets(groupRead, groupWrite, right3));
AttributeRights right4 = AttributeRights.create(a.getId(), "FACILITYADMIN");
list.add(getRightsFromWidgets(facilityRead, facilityWrite, right4));
// after update - update rights
SetAttributeRights request = new SetAttributeRights(JsonCallbackEvents.disableButtonEvents(createButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
enableDisableWidgets(true);
closeTabEvents.onFinished(jso);
}
@Override
public void onLoadingStart() {
enableDisableWidgets(false);
}
@Override
public void onError(PerunError error) {
enableDisableWidgets(true);
}
}));
request.setAttributeRights(list);
}
}));
request.createAttributeDefinition(displayName, friendlyName, description, namespace, type, isUnique);
}
}
});
// insert layout
layout.setHTML(0, 0, "Friendly name:");
layout.setWidget(0, 1, attributeName);
layout.setHTML(1, 0, "Display name:");
layout.setWidget(1, 1, attributeDisplayName);
layout.setHTML(2, 0, "Description:");
layout.setWidget(2, 1, attributeDescription);
layout.setHTML(3, 0, "Entity:");
layout.setWidget(3, 1, entityListBox);
layout.setHTML(4, 0, "Definition type:");
layout.setWidget(4, 1, definitionListBox);
layout.setHTML(5, 0, "Value type:");
layout.setWidget(5, 1, typeListBox);
layout.setHTML(6, 0, "Unique:");
layout.setWidget(6, 1, unique);
for (int i = 0; i < layout.getRowCount(); i++) {
cellFormatter.addStyleName(i, 0, "itemName");
}
final TabItem tab = this;
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, isRefreshParentOnClose());
}
}));
final FlexTable rightsTable = new FlexTable();
rightsTable.setStyleName("inputFormFlexTable");
rightsTable.setHTML(0, 1, "<strong>SELF</strong>");
rightsTable.setHTML(0, 2, "<strong>SELF_PUBLIC</strong>");
rightsTable.setHTML(0, 3, "<strong>SELF_VO</strong>");
rightsTable.setHTML(0, 4, "<strong>VO</strong>");
rightsTable.setHTML(0, 5, "<strong>GROUP</strong>");
rightsTable.setHTML(0, 6, "<strong>FACILITY</strong>");
rightsTable.setHTML(1, 0, "<strong>READ</strong>");
rightsTable.setHTML(2, 0, "<strong>WRITE</strong>");
rightsTable.setWidget(1, 1, selfRead);
rightsTable.setWidget(2, 1, selfWrite);
rightsTable.setWidget(1, 2, selfReadPublic);
rightsTable.setWidget(2, 2, selfWritePublic);
rightsTable.setWidget(1, 3, selfReadVo);
rightsTable.setWidget(2, 3, selfWriteVo);
rightsTable.setWidget(1, 4, voRead);
rightsTable.setWidget(2, 4, voWrite);
rightsTable.setWidget(1, 5, groupRead);
rightsTable.setWidget(2, 5, groupWrite);
rightsTable.setWidget(1, 6, facilityRead);
rightsTable.setWidget(2, 6, facilityWrite);
rightsTable.addStyleName("centeredTable");
vp.add(layout);
vp.add(rightsTable);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of com.google.gwt.event.dom.client.ClickHandler in project perun by CESNET.
the class AddAuthorTabItem method draw.
public Widget draw() {
titleWidget.setText("Add author");
this.users = new FindNewAuthors("");
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// PUB-INFO
TabMenu info = new TabMenu();
info.addWidget(new HTML("<strong>FULL CITE: </strong>" + publication.getMain()));
firstTabPanel.add(info);
// HORIZONTAL MENU
TabMenu tabMenu = new TabMenu();
// get the table
final CellTable<Author> table;
if (session.isPerunAdmin()) {
table = users.getEmptyTable(new FieldUpdater<Author, String>() {
public void update(int index, Author object, String value) {
session.getTabManager().addTab(new UserDetailTabItem(object.getId()));
}
});
} else {
table = users.getEmptyTable();
}
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, "Add selected user(s) as author(s) of publication: " + publication.getTitle());
tabMenu.addWidget(addButton);
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(users, table, addButton);
final TabItem tab = this;
addButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
ArrayList<Author> list = users.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// proceed
for (int i = 0; i < list.size(); i++) {
final String name = list.get(i).getDisplayName();
// add name events
JsonCallbackEvents authorshipEvents = new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
updateAlreadyAdded(name);
}
};
// merge with refresh?
if (i == list.size() - 1 && events != null) {
authorshipEvents = JsonCallbackEvents.mergeEvents(authorshipEvents, events);
}
// call
CreateAuthorship request = new CreateAuthorship(JsonCallbackEvents.disableButtonEvents(addButton, authorshipEvents));
request.createAuthorship(publicationId, list.get(i).getId());
if (i == list.size() - 1) {
users.clearTableSelectedSet();
}
}
}
}
});
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().closeTab(tab, isRefreshParentOnClose());
}
}));
tabMenu.addSearchWidget(new PerunSearchEvent() {
@Override
public void searchFor(String text) {
users.searchFor(text);
searchString = text;
}
}, ButtonTranslation.INSTANCE.searchUsers());
// 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 menu to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
// add already added
firstTabPanel.add(alreadyAddedAuthors);
firstTabPanel.setCellHeight(alreadyAddedAuthors, "30px");
// add table to the main panel
firstTabPanel.add(sp);
// do not resize like perun table to prevent wrong width in inner tab
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of com.google.gwt.event.dom.client.ClickHandler 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);
}
Aggregations