2 * Land information panel
\r
4 * License : The MIT License
\r
5 * Copyright(c) 2009 olyutorskii
\r
8 package jp.sourceforge.jindolf;
\r
10 import java.awt.GridBagConstraints;
\r
11 import java.awt.GridBagLayout;
\r
12 import java.awt.Insets;
\r
13 import java.text.DateFormat;
\r
14 import java.util.Date;
\r
15 import javax.swing.JComponent;
\r
16 import javax.swing.JLabel;
\r
17 import javax.swing.JPanel;
\r
18 import jp.sourceforge.jindolf.corelib.LandDef;
\r
19 import jp.sourceforge.jindolf.corelib.LandState;
\r
24 @SuppressWarnings("serial")
\r
25 public class LandInfoPanel extends JPanel{
\r
27 private final JLabel landName = new JLabel();
\r
28 private final JLabel landIdentifier = new JLabel();
\r
29 private final WebButton webURL = new WebButton();
\r
30 private final JLabel startDate = new JLabel();
\r
31 private final JLabel endDate = new JLabel();
\r
32 private final JLabel landState = new JLabel();
\r
33 private final JLabel locale = new JLabel();
\r
34 private final JLabel timezone = new JLabel();
\r
35 private final WebButton contact = new WebButton();
\r
36 private final JLabel description = new JLabel();
\r
42 public LandInfoPanel(){
\r
45 Monodizer.monodize(this.landIdentifier);
\r
46 Monodizer.monodize(this.locale);
\r
57 * @return 文字列化された国状態
\r
59 private static String getStatusMark(LandState state){
\r
63 case CLOSED: result = "サービス終了"; break;
\r
64 case HISTORICAL: result = "過去ログ提供のみ"; break;
\r
65 case ACTIVE: result = "稼動中"; break;
\r
78 * @param comp コンポーネント
\r
80 private void layoutRow(String item, JComponent comp){
\r
81 GridBagConstraints constraints = new GridBagConstraints();
\r
82 constraints.insets = new Insets(2, 2, 2, 2);
\r
84 String itemCaption = item + " : ";
\r
85 JLabel itemLabel = new JLabel(itemCaption);
\r
87 constraints.anchor = GridBagConstraints.EAST;
\r
88 constraints.gridwidth = 1;
\r
89 add(itemLabel, constraints);
\r
91 constraints.anchor = GridBagConstraints.WEST;
\r
92 constraints.gridwidth = GridBagConstraints.REMAINDER;
\r
93 add(comp, constraints);
\r
100 private void design(){
\r
101 GridBagLayout layout = new GridBagLayout();
\r
104 layoutRow("国名", this.landName);
\r
105 layoutRow("識別名", this.landIdentifier);
\r
106 layoutRow("Webサイト", this.webURL);
\r
107 layoutRow("建国", this.startDate);
\r
108 layoutRow("亡国", this.endDate);
\r
109 layoutRow("状態", this.landState);
\r
110 layoutRow("ロケール", this.locale);
\r
111 layoutRow("時間帯", this.timezone);
\r
112 layoutRow("連絡先", this.contact);
\r
113 layoutRow("説明", this.description);
\r
115 GridBagConstraints constraints = new GridBagConstraints();
\r
116 constraints.fill = GridBagConstraints.BOTH;
\r
117 constraints.weightx = 1.0;
\r
118 constraints.weighty = 1.0;
\r
119 constraints.gridwidth = GridBagConstraints.REMAINDER;
\r
120 constraints.gridheight = GridBagConstraints.REMAINDER;
\r
121 add(new JPanel(), constraints); // ダミー詰め物
\r
130 public void update(Land land){
\r
131 LandDef landDef = land.getLandDef();
\r
134 DateFormat.getDateTimeInstance(DateFormat.FULL,
\r
137 long start = landDef.getStartDateTime();
\r
138 String startStr = dform.format(new Date(start));
\r
143 long end = landDef.getEndDateTime();
\r
144 String endStr = dform.format(new Date(end));
\r
149 String status = getStatusMark(land.getLandDef().getLandState());
\r
151 this.landName .setText(landDef.getLandName());
\r
152 this.landIdentifier .setText(landDef.getLandId());
\r
153 this.webURL .setURI(land.getLandDef().getWebURI());
\r
154 this.startDate .setText(startStr);
\r
155 this.endDate .setText(endStr);
\r
156 this.landState .setText(status);
\r
157 this.locale .setText(landDef.getLocale().toString());
\r
158 this.timezone .setText(landDef.getTimeZone().getDisplayName());
\r
159 this.contact .setURLText(landDef.getContactInfo());
\r
160 this.description .setText(landDef.getDescription());
\r