2 * Land information panel
4 * License : The MIT License
5 * Copyright(c) 2009 olyutorskii
8 package jp.sfjp.jindolf.view;
10 import java.awt.GridBagConstraints;
11 import java.awt.GridBagLayout;
12 import java.awt.Insets;
13 import java.text.DateFormat;
14 import java.util.Date;
15 import javax.swing.JComponent;
16 import javax.swing.JLabel;
17 import javax.swing.JPanel;
18 import jp.sfjp.jindolf.data.Land;
19 import jp.sfjp.jindolf.dxchg.WebButton;
20 import jp.sfjp.jindolf.util.Monodizer;
21 import jp.sourceforge.jindolf.corelib.LandDef;
22 import jp.sourceforge.jindolf.corelib.LandState;
27 @SuppressWarnings("serial")
28 public class LandInfoPanel extends JPanel{
30 private final JLabel landName = new JLabel();
31 private final JLabel landIdentifier = new JLabel();
32 private final WebButton webURL = new WebButton();
33 private final JLabel startDate = new JLabel();
34 private final JLabel endDate = new JLabel();
35 private final JLabel landState = new JLabel();
36 private final JLabel locale = new JLabel();
37 private final JLabel timezone = new JLabel();
38 private final WebButton contact = new WebButton();
39 private final JLabel description = new JLabel();
45 public LandInfoPanel(){
48 Monodizer.monodize(this.landIdentifier);
49 Monodizer.monodize(this.locale);
62 private static String getStatusMark(LandState state){
66 case CLOSED: result = "サービス終了"; break;
67 case HISTORICAL: result = "過去ログ提供のみ"; break;
68 case ACTIVE: result = "稼動中"; break;
83 private void layoutRow(String item, JComponent comp){
84 GridBagConstraints constraints = new GridBagConstraints();
85 constraints.insets = new Insets(2, 2, 2, 2);
87 String itemCaption = item + " : ";
88 JLabel itemLabel = new JLabel(itemCaption);
90 constraints.anchor = GridBagConstraints.EAST;
91 constraints.gridwidth = 1;
92 add(itemLabel, constraints);
94 constraints.anchor = GridBagConstraints.WEST;
95 constraints.gridwidth = GridBagConstraints.REMAINDER;
96 add(comp, constraints);
103 private void design(){
104 GridBagLayout layout = new GridBagLayout();
107 layoutRow("国名", this.landName);
108 layoutRow("識別名", this.landIdentifier);
109 layoutRow("Webサイト", this.webURL);
110 layoutRow("建国", this.startDate);
111 layoutRow("亡国", this.endDate);
112 layoutRow("状態", this.landState);
113 layoutRow("ロケール", this.locale);
114 layoutRow("時間帯", this.timezone);
115 layoutRow("連絡先", this.contact);
116 layoutRow("説明", this.description);
118 GridBagConstraints constraints = new GridBagConstraints();
119 constraints.fill = GridBagConstraints.BOTH;
120 constraints.weightx = 1.0;
121 constraints.weighty = 1.0;
122 constraints.gridwidth = GridBagConstraints.REMAINDER;
123 constraints.gridheight = GridBagConstraints.REMAINDER;
124 add(new JPanel(), constraints); // ダミー詰め物
133 public void update(Land land){
134 LandDef landDef = land.getLandDef();
137 DateFormat.getDateTimeInstance(DateFormat.FULL,
140 long start = landDef.getStartDateTime();
141 String startStr = dform.format(new Date(start));
146 long end = landDef.getEndDateTime();
147 String endStr = dform.format(new Date(end));
152 String status = getStatusMark(land.getLandDef().getLandState());
154 this.landName .setText(landDef.getLandName());
155 this.landIdentifier .setText(landDef.getLandId());
156 this.webURL .setURI(land.getLandDef().getWebURI());
157 this.startDate .setText(startStr);
158 this.endDate .setText(endStr);
159 this.landState .setText(status);
160 this.locale .setText(landDef.getLocale().toString());
161 this.timezone .setText(landDef.getTimeZone().getDisplayName());
162 this.contact .setURLText(landDef.getContactInfo());
163 this.description .setText(landDef.getDescription());