package ps.exalt.client; import java.util.Date; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.DataSourceField; import com.smartgwt.client.types.FieldType; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.VLayout; /** * Entry point classes define onModuleLoad(). */ public class SampleProject3_1 implements EntryPoint { public void onModuleLoad() { VLayout canvas = new VLayout(); final ListGrid countryGrid = new ListGrid(); countryGrid.setWidth(500); countryGrid.setHeight(224); countryGrid.setShowAllRecords(true); countryGrid.setShowFilterEditor(true); countryGrid.setCanDragRecordsOut(true); countryGrid.setCanReorderRecords(true); countryGrid.setCanAcceptDroppedRecords(true); countryGrid.setAutoFetchData(true); DataSourceField d1 = new DataSourceField("countryName", FieldType.TEXT); DataSourceField d2 = new DataSourceField("capital", FieldType.TEXT); DataSource dd = new DataSource(); dd.setClientOnly(true); dd.setTestData(CountryData.getRecords()); dd.setFields(d1, d2); countryGrid.setAutoFetchData(true); countryGrid.setDataSource(dd); canvas.addMember(countryGrid); canvas.draw(); // // if (!GWT.isScript()) { // KeyIdentifier debugKey = new KeyIdentifier(); // debugKey.setCtrlKey(true); // debugKey.setKeyName("D"); // Page.registerKey(debugKey, new KeyCallback() { // public void execute(String keyName) { // SC.showConsole(); // } // }); // } } } class CountryData { private static CountryRecord[] records; public static CountryRecord[] getRecords() { if (records == null) { records = getNewRecords(); } return records; } public static CountryRecord[] getNewRecords() { return new CountryRecord[] { new CountryRecord( "North America", "User1", "US", 9631420, 298444215, 12360, new Date(1776 - 1900, 6, 4), "federal republic", 2, "2", true, "http://en.wikipedia.org/wiki/United_states", "Britain's American colonies broke with the mother country in 1776 and were recognized as the new nation of the United States of America following the Treaty of Paris in 1783. During the 19th and 20th centuries, 37 new states were added to the original 13 as the nation expanded across the North American continent and acquired a number of overseas possessions. The two most traumatic experiences in the nation's history were the Civil War (1861-65) and the Great Depression of the 1930s. Buoyed by victories in World Wars I and II and the end of the Cold War in 1991, the US remains the world's most powerful nation state. The economy is marked by steady growth, low unemployment and inflation, and rapid advances in technology."), new CountryRecord( "Asia", "User2", "CH", 9596960, 1313973713, 8859, null, "Communist state", 0, "1", false, "http://en.wikipedia.org/wiki/China", "For centuries China stood as a leading civilization, outpacing the rest of the world in the arts and sciences, but in the 19th and early 20th centuries, the country was beset by civil unrest, major famines, military defeats, and foreign occupation. After World War II, the Communists under MAO Zedong established an autocratic socialist system that, while ensuring China's sovereignty, imposed strict controls over everyday life and cost the lives of tens of millions of people. After 1978, his successor DENG Xiaoping and other leaders focused on market-oriented economic development and by 2000 output had quadrupled. For much of the population, living standards have improved dramatically and the room for personal choice has expanded, yet political controls remain tight."), new CountryRecord( "Asia", "User3", "JA", 377835, 127463611, 4018, null, "constitutional monarchy with parliamentary government", 1, "1", true, "http://en.wikipedia.org/wiki/Japan", "In 1603, a Tokugawa shogunate (military dictatorship) ushered in a long period of isolation from foreign influence in order to secure its power. For 250 years this policy enabled Japan to enjoy stability and a flowering of its indigenous culture. Following the Treaty of Kanagawa with the US in 1854, Japan opened its ports and began to intensively modernize and industrialize. During the late 19th and early 20th centuries, Japan became a regional power that was able to defeat the forces of both China and Russia. It occupied Korea, Formosa (Taiwan), and southern Sakhalin Island. In 1931-32 Japan occupied Manchuria, and in 1937 it launched a full-scale invasion of China. Japan attacked US forces in 1941 - triggering America's entry into World War II - and soon occupied much of East and Southeast Asia. After its defeat in World War II, Japan recovered to become an economic power and a staunch ally of the US. While the emperor retains his throne as a symbol of national unity, actual power rests in networks of powerful politicians, bureaucrats, and business executives. The economy experienced a major slowdown starting in the 1990s following three decades of unprecedented growth, but Japan still remains a major economic power, both in Asia and globally. In 2005, Japan began a two-year term as a non-permanent member of the UN Security Council."), new CountryRecord( "Asia", "User4", "IN", 3287590, 1095351995, 3611, new Date(1947 - 1900, 7, 15), "federal republic", 2, "2", false, "http://en.wikipedia.org/wiki/India", "The Indus Valley civilization, one of the oldest in the world, dates back at least 5,000 years. Aryan tribes from the northwest infiltrated onto Indian lands about 1500 B.C.; their merger with the earlier Dravidian inhabitants created the classical Indian culture. Arab incursions starting in the 8th century and Turkish in the 12th were followed by those of European traders, beginning in the late 15th century. By the 19th century, Britain had assumed political control of virtually all Indian lands. Indian armed forces in the British army played a vital role in both World Wars. Nonviolent resistance to British colonialism led by Mohandas GANDHI and Jawaharlal NEHRU brought independence in 1947. The subcontinent was divided into the secular state of India and the smaller Muslim state of Pakistan. A third war between the two countries in 1971 resulted in East Pakistan becoming the separate nation of Bangladesh. Despite impressive gains in economic investment and output, India faces pressing problems such as the ongoing dispute with Pakistan over Kashmir, massive overpopulation, environmental degradation, extensive poverty, and ethnic and religious strife."), new CountryRecord( "Europe", "User5", "GM", 357021, 82422299, 2504, new Date(1871 - 1900, 0, 18), "federal republic", 2, "0", true, "http://en.wikipedia.org/wiki/Germany", "As Europe's largest economy and second most populous nation, Germany remains a key member of the continent's economic, political, and defense organizations. European power struggles immersed Germany in two devastating World Wars in the first half of the 20th century and left the country occupied by the victorious Allied powers of the US, UK, France, and the Soviet Union in 1945. With the advent of the Cold War, two German states were formed in 1949: the western Federal Republic of Germany (FRG) and the eastern German Democratic Republic (GDR). The democratic FRG embedded itself in key Western economic and security organizations, the EC, which became the EU, and NATO, while the Communist GDR was on the front line of the Soviet-led Warsaw Pact. The decline of the USSR and the end of the Cold War allowed for German unification in 1990. Since then, Germany has expended considerable funds to bring Eastern productivity and wages up to Western standards. In January 1999, Germany and 10 other EU countries introduced a common European exchange currency, the euro.") }; } } class CountryRecord extends ListGridRecord { public CountryRecord() { } public CountryRecord(String countryCode, String countryName, String capital, String continent) { setCountryCode(countryCode); setCountryName(countryName); setCapital(capital); } public CountryRecord(String countryCode, String countryName, int population) { setCountryCode(countryCode); setCountryName(countryName); setPopulation(population); } public CountryRecord(String continent, String countryName, String countryCode, int area, int population, double gdp, Date independence, String government, int governmentDesc, String capital, boolean memberG8, String article, String background) { setContinent(continent); setCountryName(countryName); setCountryCode(countryCode); setArea(area); setPopulation(population); setGdp(gdp); setIndependence(independence); setGovernment(government); setGovernmentDesc(governmentDesc); setCapital(capital); setMemberG8(memberG8); setArticle(article); setBackground(background); } public void setContinent(String continent) { setAttribute("continent", continent); } public String getContinent() { return getAttributeAsString("continent"); } public void setCountryName(String countryName) { setAttribute("countryName", countryName); } public String getCountryName() { return getAttributeAsString("countryName"); } public void setCountryCode(String countryCode) { setAttribute("countryCode", countryCode); } public String getCountryCode() { return getAttributeAsString("countryCode"); } public void setArea(int area) { setAttribute("area", area); } public int getArea() { return getAttributeAsInt("area"); } public void setPopulation(int population) { setAttribute("population", population); } public int getPopulation() { return getAttributeAsInt("population"); } public void setGdp(double gdp) { setAttribute("gdp", gdp); } public double getGdp() { return getAttributeAsDouble("gdp"); } public void setIndependence(Date independence) { setAttribute("independence", independence); } public Date getIndependence() { return getAttributeAsDate("independence"); } public void setGovernment(String government) { setAttribute("government", government); } public String getGovernment() { return getAttributeAsString("government"); } public void setGovernmentDesc(int governmentDesc) { setAttribute("government_desc", governmentDesc); } public int getGovernmentDesc() { return getAttributeAsInt("government_desc"); } public void setCapital(String capital) { setAttribute("capital", capital); } public String getCapital() { return getAttributeAsString("capital"); } public void setMemberG8(boolean memberG8) { setAttribute("member_g8", memberG8); } public boolean getMemberG8() { return getAttributeAsBoolean("member_g8"); } public void setArticle(String article) { setAttribute("article", article); } public String getArticle() { return getAttributeAsString("article"); } public void setBackground(String background) { setAttribute("background", background); } public String getBackground() { return getAttributeAsString("background"); } public String getFieldValue(String field) { return getAttributeAsString(field); } }