contentPane.add(gbl.getProduct(), BorderLayout.CENTER);
contentPane.add(cmdPanel, BorderLayout.SOUTH);
contentPane.setBorder(BorderFactory.createEmptyBorder(12, 12, 11, 11));
// PublishState に応じて振り分ける
IStampTreeModel stmpTree = stampBox.getUserStampBox().getStampTreeModel();
FacilityModel facility = Project.getUserModel().getFacilityModel();
String facilityId = facility.getFacilityId();
long treeId = stmpTree.getId();
String publishTypeStr = stmpTree.getPublishType();
if (treeId == 0L && publishTypeStr == null) {
//
// Stamptree非保存(最初のログイン時)
//
publishState = PublishedState.NONE;
} else if (treeId != 0L && publishTypeStr == null) {
//
// 保存されているStamptreeで非公開のケース
//
publishState = PublishedState.SAVED_NONE;
} else if (treeId != 0L && publishTypeStr != null && publishTypeStr.equals(facilityId)) {
//
// publishType=facilityId ローカルに公開されている
//
publishState = PublishedState.LOCAL;
} else if (treeId != 0L && publishTypeStr != null && publishTypeStr.equals(IInfoModel.PUBLISHED_TYPE_GLOBAL)) {
//
// publishType=global グローバルに公開されている
//
publishState = PublishedState.GLOBAL;
}
// GUIコンポーネントに初期値を入力する
switch (publishState) {
case NONE:
instLabel.setText("このスタンプは公開されていません。");
partyName.setText(facility.getFacilityName());
String url = facility.getUrl();
if (url != null) {
contact.setText(url);
}
String dateStr = ModelUtils.getDateAsString(new Date());
publishedDate.setText(dateStr);
publish.setText("公開する");
break;
case SAVED_NONE:
instLabel.setText("このスタンプは公開されていません。");
partyName.setText(stmpTree.getPartyName());
url = facility.getUrl();
if (url != null) {
contact.setText(url);
}
dateStr = ModelUtils.getDateAsString(new Date());
publishedDate.setText(dateStr);
publish.setText("公開する");
break;
case LOCAL:
instLabel.setText("このスタンプは院内に公開されています。");
stampBoxName.setText(stmpTree.getName());
local.setSelected(true);
publc.setSelected(false);
publishType = TT_LOCAL;
//
// Publish している Entity をチェックする
//
String published = ((StampTreeModel) stmpTree).getPublished();
if (published != null) {
StringTokenizer st = new StringTokenizer(published, ",");
while (st.hasMoreTokens()) {
String entity = st.nextToken();
for (int i = 0; i < IInfoModel.STAMP_ENTITIES.length; i++) {
if (entity.equals(IInfoModel.STAMP_ENTITIES[i])) {
entities[i].setSelected(true);
break;
}
}
}
}
category.setSelectedItem(stmpTree.getCategory());
partyName.setText(stmpTree.getPartyName());
contact.setText(stmpTree.getUrl());
description.setText(stmpTree.getDescription());
StringBuilder sb = new StringBuilder();
sb.append(ModelUtils.getDateAsString(stmpTree.getPublishedDate()));
sb.append(" 最終更新日( ");
sb.append(ModelUtils.getDateAsString(stmpTree.getLastUpdated()));
sb.append(" )");
publishedDate.setText(sb.toString());
publish.setText("更新する");
publish.setEnabled(true);
cancelPublish.setEnabled(true);
break;
case GLOBAL:
instLabel.setText("このスタンプはグローバルに公開されています。");
stampBoxName.setText(stmpTree.getName());
local.setSelected(false);
publc.setSelected(true);
category.setSelectedItem(stmpTree.getCategory());
partyName.setText(stmpTree.getPartyName());
contact.setText(stmpTree.getUrl());
description.setText(stmpTree.getDescription());
publishType = TT_PUBLIC;
published = ((StampTreeModel) stmpTree).getPublished();
if (published != null) {
StringTokenizer st = new StringTokenizer(published, ",");
while (st.hasMoreTokens()) {
String entity = st.nextToken();
for (int i = 0; i < IInfoModel.STAMP_ENTITIES.length; i++) {
if (entity.equals(IInfoModel.STAMP_ENTITIES[i])) {
entities[i].setSelected(true);
break;
}
}
}
}
sb = new StringBuilder();
sb.append(ModelUtils.getDateAsString(stmpTree.getPublishedDate()));
sb.append(" 最終更新日( ");
sb.append(ModelUtils.getDateAsString(stmpTree.getLastUpdated()));
sb.append(" )");
publishedDate.setText(sb.toString());
publish.setText("更新する");
publish.setEnabled(true);
cancelPublish.setEnabled(true);