For example if you have a zoom in action Then you may add a menu entry like so:
actionMenu->Append( kZoomInButtonId , "ZoomIn\tz" , "Click to zoom in on the current location.\n" );
Now if you press z it will execute this action.
Topics for professional software engineers
actionMenu->Append( kZoomInButtonId , "ZoomIn\tz" , "Click to zoom in on the current location.\n" );
#include "signal.h"
templateclass SignalTranslator
{
private:
class SingleTonTranslator
{
public:
SingleTonTranslator()
{
signal(SignalExceptionClass::GetSignalNumber(), SignalHandler);
}
static void SignalHandler(int)
{
std::cout << "Signal handled and logged" << std::endl;
throw SignalExceptionClass();
}
};
public:
SignalTranslator()
{
static SingleTonTranslator s_objTranslator;
}
};
class SegmentationFault : public std::exception
{
public:
virtual const char* what() const throw() {
return "Segmentation Fault";
}
static int GetSignalNumber() {return SIGSEGV;}
};
// Set up signal handleing for Seg Fault. When SegFault occurs it will throw a exception
SignalTranslatorg_objSegmentationFaultTranslator;
public interface IQuoteService extends RemoteService {
public static class Util {
public static IQuoteServiceAsync getInstance() {
IQuoteServiceAsync instance=(IQuoteServiceAsync) GWT.create(IQuoteService.class);
ServiceDefTarget target = (ServiceDefTarget) instance;
target.setServiceEntryPoint("/GWT/quote");
return instance;
}
}
public SuggestOracle.Response getQuote(SuggestOracle.Request req);
}
public interface IQuoteServiceAsync {
public void getQuote(SuggestOracle.Request req, AsyncCallback callback);
}
public class ItemSuggestion implements IsSerializable, Suggestion {
private String s;
// Required for IsSerializable to work
public ItemSuggestion() {
}
// Convenience method for creation of a suggestion
public ItemSuggestion(String s) {
this.s = s;
}
public String getDisplayString() {
return s;
}
public String getReplacementString() {
return s;
}
} // end inner class ItemSuggestion
public class RandomQuoteService extends RemoteServiceServlet implements IQuoteService {Create Suggestion Oracle
public SuggestOracle.Response getQuote(SuggestOracle.Request req) {
// req has request properties that you can use to perform a db search
// or some other query. Then populate the suggestions up to req.getLimit() and
// return in a SuggestOracle.Response object.
SuggestOracle.Response resp = new SuggestOracle.Response();
List<suggestion> suggestions = new ArrayList<suggestion>();
suggestions.add(new ItemSuggestion("It is a good day to die"));
suggestions.add(new ItemSuggestion("I shall return"));
suggestions.add(new ItemSuggestion("There is nothing to fear but fear itself"));
resp.setSuggestions(suggestions);
return resp;
}
}
public class ItemSuggestOracle extends SuggestOracle {
public boolean isDisplayStringHTML() {
return true;
}
public void requestSuggestions(SuggestOracle.Request req,SuggestOracle.Callback callback) {
IQuoteService.Util.getInstance().getQuote(req, new ItemSuggestCallback(req, callback));
}
class ItemSuggestCallback implements AsyncCallback {
private SuggestOracle.Request req;
private SuggestOracle.Callback callback;
public ItemSuggestCallback(SuggestOracle.Request _req,
SuggestOracle.Callback _callback) {
req = _req;
callback = _callback;
}
public void onFailure(Throwable error) {
callback.onSuggestionsReady(req, new SuggestOracle.Response());
}
public void onSuccess(Object retValue) {
callback.onSuggestionsReady(req,
(SuggestOracle.Response) retValue);
}
}
}
public void display() {
ItemSuggestOracle oracle = new ItemSuggestOracle();
SuggestBox sb = new SuggestBox(oracle);
// Add it to the root panel.
RootPanel.get().add(sb);
}
{
"firstName": "John",
"lastName": "Smith",
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
},
"phoneNumbers": [
"212 555-1234",
"646 555-4567"
]
}
MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
oracle.add("foo");
oracle.add("bar");
oracle.add("baz");
oracle.add("toto");
oracle.add("tintin");
SuggestBox sb = new SuggestBox(oracle);
// Add it to the root panel.
RootPanel.get().add(sb);
package com.client.time;
public interface ITimeService extends RemoteService {
public Date getDate();
}
package com.client.time;
public interface ITimeServiceAsync {
public void getDate(AsyncCallback callback);
}
package com.server.time;
public class TimeService extends RemoteServiceServlet implements ITimeService {
public Date getDate() {
return new Date();
}
}
public void loadDate(final Label label) {
ITimeServiceAsync timeService = (ITimeServiceAsync) GWT.create(ITimeService.class);
ServiceDefTarget endpoint = (ServiceDefTarget) timeService;
endpoint.setServiceEntryPoint("/GWT/TimeService");
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
label.setText(result.toString());
}
public void onFailure(Throwable caught) {
label.setText("failure" + caught.getMessage());
}
};
label.setText("pending");
timeService.getDate(callback);
}
* .gwt-DialogBox { the outside of the dialog }
* .gwt-DialogBox .Caption { the caption }
/*
* mcintoshEntryPoint.java
*
* Created on June 29, 2008, 1:46 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTMLTable;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SourcesTableEvents;
import com.google.gwt.user.client.ui.TableListener;
import com.google.gwt.user.client.ui.Widget;
/**
*
* @author avalanche
*/
public class mcintoshEntryPoint implements EntryPoint {
/** Creates a new instance of mcintoshEntryPoint */
public mcintoshEntryPoint() {
}
private static class MyDialog extends DialogBox {
public MyDialog(String text) {
// Set the dialog box's caption.
setText(text);
// DialogBox is a SimplePanel, so you have to set its widget property to
// whatever you want its contents to be.
Button ok = new Button("OK");
ok.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
MyDialog.this.hide();
}
});
setWidget(ok);
}
}
/**
* The entry point method, called automatically by loading a module
* that declares an implementing class as an entry-point
*/
public void onModuleLoad() {
final Label label = new Label("Hello, Chris!!!");
final Button button = new Button("Click me!");
final HTMLTable table = new Grid(5, 5);
// Put some values in the grid cells.
for (int row = 0; row < 5; ++row) {
for (int col = 0; col < 5; ++col) {
table.setText(row, col, "" + row + ", " + col);
}
}
button.addClickListener(new ClickListener() {
public void onClick(Widget w) {
label.setVisible(!label.isVisible());
}
});
table.addTableListener(new TableListener() {
public void onCellClicked(SourcesTableEvents arg0, int arg1, int arg2) {
new MyDialog("You clicked" + arg1 + "," + arg2).show();
}
});
RootPanel.get().add(button);
RootPanel.get().add(label);
RootPanel.get().add(table);
}
}