請先至 Eclipse 官網,依照您的作業系統下載安裝檔,並執行安裝,安裝過程相當容易,請依照安裝套件下一步即可。
若您的系統為 Ubuntu 即可使用以下指令直接安裝即可。
apt-get install eclipse
開啟 Eclipse ,於上排功能列,選擇[Help -> Install New Software] 將會開啟如下圖操作畫面,並於 Work with 欄位輸入以下網址 [ https://dl.google.com/eclipse/plugin/3.6 ]
https://dl.google.com/eclipse/plugin/3.5
private final GreetingServiceAsync greetingService = GWT .create(GreetingService.class);
package com.kent.app.client; import com.kent.app.shared.FieldVerifier; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.DialogBox; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; /** * Entry point classes define onModuleLoad(). */ public class Test implements EntryPoint {
/** * The message displayed to the user when the server cannot be reached or * returns an error. */ private static final String SERVER_ERROR = "An error occurred while " + "attempting to contact the server. Please check your network " + "connection and try again."; /** * Create a remote service proxy to talk to the server-side Greeting service. */ private final GreetingServiceAsync greetingService = GWT .create(GreetingService.class); /** * This is the entry point method. */ public void onModuleLoad() {
final Button sendButton = new Button("Send"); final TextBox nameField = new TextBox(); nameField.setText("GWT User"); final Label errorLabel = new Label(); // We can add style names to widgets sendButton.addStyleName("sendButton"); // Add the nameField and sendButton to the RootPanel // Use RootPanel.get() to get the entire body element RootPanel.get("nameFieldContainer").add(nameField); RootPanel.get("sendButtonContainer").add(sendButton); RootPanel.get("errorLabelContainer").add(errorLabel); // Focus the cursor on the name field when the app loads nameField.setFocus(true); nameField.selectAll(); // Create the popup dialog box final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Remote Procedure Call"); dialogBox.setAnimationEnabled(true); final Button closeButton = new Button("Close"); // We can set the id of a widget by accessing its Element closeButton.getElement().setId("closeButton"); final Label textToServerLabel = new Label(); final HTML serverResponseLabel = new HTML(); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.addStyleName("dialogVPanel"); dialogVPanel.add(new HTML("Sending name to the server:")); dialogVPanel.add(textToServerLabel); dialogVPanel.add(new HTML("Server replies:")); dialogVPanel.add(serverResponseLabel); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); // Add a handler to close the DialogBox closeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
dialogBox.hide(); sendButton.setEnabled(true); sendButton.setFocus(true); } }); // Create a handler for the sendButton and nameField class MyHandler implements ClickHandler, KeyUpHandler { /** * Fired when the user clicks on the sendButton. */ public void onClick(ClickEvent event) {
sendNameToServer(); } /** * Fired when the user types in the nameField. */ public void onKeyUp(KeyUpEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
sendNameToServer(); } } /** * Send the name from the nameField to the server and wait for a response. */ private void sendNameToServer() {
// First, we validate the input. errorLabel.setText(""); String textToServer = nameField.getText(); if (!FieldVerifier.isValidName(textToServer)) {
errorLabel.setText("Please enter at least four characters"); return; } // Then, we send the input to the server. sendButton.setEnabled(false); textToServerLabel.setText(textToServer); serverResponseLabel.setText(""); greetingService.greetServer(textToServer, new AsyncCallback() { public void onFailure(Throwable caught) {
// Show the RPC error message to the user dialogBox .setText("Remote Procedure Call - Failure"); serverResponseLabel .addStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(SERVER_ERROR); dialogBox.center(); closeButton.setFocus(true); } public void onSuccess(String result) {
dialogBox.setText("Remote Procedure Call"); serverResponseLabel .removeStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(result); dialogBox.center(); closeButton.setFocus(true); } }); } } // Add a handler to send the name to the server MyHandler handler = new MyHandler(); sendButton.addClickHandler(handler); nameField.addKeyUpHandler(handler); } }
<div id="container"> <div id="left-container"> </div> <div id="center-container"> <table align="center"> <tbody><tr> <td id="nameFieldContainer"></td> <td id="sendButtonContainer"></td> </tr> <tr> <td colspan="2" style="color:red;" id="errorLabelContainer"></td> </tr> </tbody></table> <div id="infovis"></div> </div> <div id="right-container"> </div> </div>
<!--?xml version="1.0" encoding="UTF-8"?--> <app> <user> <id>1</id> <name>John</name> <email>[email protected]</email> <age>20</age> <gender>m</gender> <circle> <name>Friends</name> <containsfriend>2</containsfriend> </circle> <circle> <name>workers</name> <containsfriend>3</containsfriend> </circle> <photo> <photoid>1</photoid> <rating>6</rating> <url>https://www.instablogsimages.com/images/2006/11/27/miraculous-russian-gazprom-building_4_49.jpg</url> <tag>building</tag> </photo> <photo> <photoid>2</photoid> <rating>7</rating> <url>https://detroit1701.org/Graphics/Dime%20Building.jpg</url> <tag>building</tag> </photo> <photo> <photoid>3</photoid> <rating>8</rating> <url>https://gram4u.files.wordpress.com/2009/10/modern-building1.jpg</url> <tag>building</tag> </photo> </user> <user> <id>2</id> <name>Cathy</name> <email>[email protected]</email> <age>20</age> <gender>f</gender> <circle> <name>Friends</name> <containsfriend>1</containsfriend> <containsfriend>3</containsfriend> </circle> <photo> <photoid>4</photoid> <rating>10</rating> <url>https://www.baycounty-mi.gov/Images/BuildingAuthority/CountyBuilding.jpg</url> <tag>building</tag> </photo> <photo> <photoid>5</photoid> <rating>10</rating> <url>https://www.mccullagh.org/db9/1ds2-4/fbi-headquarters-building.jpg</url> <tag>building</tag> </photo> </user> <user> <id>3</id> <name>Luke</name> <email>[email protected]</email> <age>20</age> <gender>m</gender> <circle> <name>Friends</name> <containsfriend>2</containsfriend> </circle> <circle> <name>Family</name> <containsfriend>1</containsfriend> </circle> <photo> <photoid>6 <rating>10 <url>https://wiki.urbandead.com/images/c/cd/Foto3.jpg <tag>building</tag> </photo> </user> </app>
public void onModuleLoad()
});
photos.setWidget(photoCount, 0, hp);
RootPanel.get("right-container").add(photos);
info = new VerticalPanel();
RootPanel.get("left-container").add(info);
final DialogBox d = new DialogBox();
d.setText("Paste XML fragment");
VerticalPanel vp = new VerticalPanel();
vp.add(new HTML("<P> <P>");
vp.add(new Label("Please paste your XML fragment here:"));
final TextArea ta = new TextArea();
ta.setHeight(Window.getClientHeight() * 3 / 4 + "px");
ta.setWidth(Window.getClientWidth() * 3 / 4 + "px");
vp.add(ta);
Button OK = new Button("OK");
vp.add(OK);
d.setWidget(vp);
d.show();
OK.addClickHandler(new ClickHandler()
});
}
private final QueryXMLAsync queryService = GWT
.create(QueryXML.class);
public void visualizeInitialPerson()
@Override
public void onSuccess(final Integer person)
@Override
public void onSuccess(String result)
} catch (Exception e)
}
});
// Request the person's photos
loadPhotos();
}
});
}
public static JSONObject getJsonForUser(final Node doc) else if (child.getNodeName().equals("circle")) else if (circle.getNodeName().equals("containsFriend")) else if (friendInfo.getNodeName().equals("id")) else if (friendInfo.getNodeName().equals("name"))
}
JSONObject thisFriend = new JSONObject();
thisFriend.put("id", new JSONNumber(fid));
thisFriend.put("name", new JSONString(fname));
circles.set(circles.size(), thisFriend);
}
}
} else if (child.getNodeName().equals("name")) else if (child.getNodeName().equals("age")) else if (child.getNodeName().equals("gender")) else if (child.getNodeName().equals("email")) else if (child.getNodeName().equals("photo"))
}
}
JSONObject obj = new JSONObject();
obj.put("id", new JSONNumber(id));
obj.put("name", new JSONString(name));
obj.put("children", circles);
obj.put("data", data);
data.put("photos", photos);
System.out.println(obj.toString());
return obj;
}