• R/O
  • SSH
  • HTTPS

chaplet: 提交


Commit MetaInfo

修訂31 (tree)
時間2007-06-28 23:12:04
作者koe

Log Message

GM設定と、プラグインビューのダイアログ表示機能を実装

Change Summary

差異

--- chaplet/trunk/src/nova/jp/sf/chaplet/nova/ui/NovaView.java (revision 30)
+++ chaplet/trunk/src/nova/jp/sf/chaplet/nova/ui/NovaView.java (revision 31)
@@ -519,6 +519,7 @@
519519 if (sceneButton == null) {
520520 sceneButton = new JButton();
521521 sceneButton.setText("次のシーン");
522+ sceneButton.setEnabled(false);
522523 sceneButton.addActionListener(new java.awt.event.ActionListener() {
523524 public void actionPerformed(java.awt.event.ActionEvent e) {
524525 actionMap.get("nextScene").actionPerformed(e);
@@ -600,6 +601,7 @@
600601 if (initButton == null) {
601602 initButton = new JButton();
602603 initButton.setText("初期化");
604+ initButton.setEnabled(false);
603605 initButton.addActionListener(new java.awt.event.ActionListener() {
604606 public void actionPerformed(java.awt.event.ActionEvent e) {
605607 actionMap.get("initServer").actionPerformed(e);
--- chaplet/trunk/src/core/jp/sf/chaplet/UserStatus.java (revision 30)
+++ chaplet/trunk/src/core/jp/sf/chaplet/UserStatus.java (revision 31)
@@ -17,6 +17,8 @@
1717 /** ユーザが生きているかどうか */
1818 private boolean active = true;
1919
20+ private String sessionId;
21+
2022 public UserStatus(){
2123
2224 }
@@ -27,11 +29,12 @@
2729 * @param writing
2830 * @param status
2931 */
30- public UserStatus(String name, boolean writing, String status) {
32+ public UserStatus(String name, boolean writing, String status, String sessionId) {
3133 super();
3234 this.name = name;
3335 this.writing = writing;
3436 this.status.add(status);
37+ this.sessionId = sessionId;
3538 }
3639
3740 /**
@@ -92,4 +95,12 @@
9295 public void setActive(boolean active) {
9396 this.active = active;
9497 }
98+
99+ public String getSessionId() {
100+ return sessionId;
101+ }
102+
103+ public void setSessionId(String sessionId) {
104+ this.sessionId = sessionId;
105+ }
95106 }
--- chaplet/trunk/src/core/jp/sf/chaplet/core/server/ChatServer.java (revision 30)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/server/ChatServer.java (revision 31)
@@ -190,15 +190,16 @@
190190 */
191191 public void sendStatus(ClientProxy proxy) {
192192 User[] users = userManager.getAllUsers();
193- String[] message = new String[users.length * 3 + 1];
193+ String[] message = new String[users.length * 4 + 1];
194194 message[0] = "status";
195195 for (int i = 0; i < users.length; i++) {
196- message[i * 3 + 1] = users[i].getDisplayName();
197- message[i * 3 + 2] = users[i].isWriting() ? "y" : "n";
196+ message[i * 4 + 1] = users[i].getDisplayName();
197+ message[i * 4 + 2] = users[i].isWriting() ? "y" : "n";
198+ message[i * 4 + 3] = users[i].getSessionId();
198199 if(primaryPlugin != null){
199- message[i * 3 + 3] = primaryPlugin.getUserStatus(users[i]);
200- if(message[i * 3 + 3] == null || message[i * 3 + 3].length() == 0){
201- message[i * 3 + 3] = " ";
200+ message[i * 4 + 4] = primaryPlugin.getUserStatus(users[i]);
201+ if(message[i * 4 + 4] == null || message[i * 3 + 3].length() == 0){
202+ message[i * 4 + 4] = " ";
202203 }
203204 }
204205 }
--- chaplet/trunk/src/core/jp/sf/chaplet/core/server/SetGMAction.java (revision 30)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/server/SetGMAction.java (revision 31)
@@ -22,19 +22,18 @@
2222 throws IOException {
2323 if(isOwner(proxy.getSessionId())
2424 && getUserManager().getUser(request[1]) != null){
25- if(getUserManager().getMasterId().equals(proxy.getSessionId())){
26- if(!proxy.getSessionId().equals(request[1])){
27- getUserManager().setMasterId(request[1]);
28- ClientProxy currentUserProxy = getServer().getProxy(request[1]);
29- currentUserProxy.sendMessage(new String[]{request[0], "gm"});
30- }
31- } else {
32- ClientProxy prevUserProxy = getServer().getProxy(getUserManager().getMasterId());
33- prevUserProxy.sendMessage(new String[]{request[0], "nogm"});
34- getUserManager().setMasterId(request[1]);
35- ClientProxy currentUserProxy = getServer().getProxy(request[1]);
36- currentUserProxy.sendMessage(new String[]{request[0], "gm"});
37- }
25+ String prevId = getUserManager().getMasterId();
26+ if(!prevId.equals(getServer().getOwner())){
27+ ClientProxy prevUserProxy = getServer().getProxy(request[1]);
28+ if(prevUserProxy != null){
29+ prevUserProxy.sendMessage(new String[]{request[0], "nogm"});
30+ }
31+ }
32+ getUserManager().setMasterId(request[1]);
33+ ClientProxy nextUserProxy = getServer().getProxy(request[1]);
34+ if(nextUserProxy != null){
35+ nextUserProxy.sendMessage(new String[]{request[0], "gm"});
36+ }
3837 }
3938 return ActionResult.OK_NEXT;
4039 }
--- chaplet/trunk/src/core/jp/sf/chaplet/core/ui/MainWindow.java (revision 30)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/ui/MainWindow.java (revision 31)
@@ -86,8 +86,6 @@
8686
8787 private JMenuItem exitItem = null;
8888
89- private JButton saveButton = null;
90-
9189 private JScrollPane textScrollPane = null;
9290
9391 private JPanel chatPanel = null;
@@ -180,6 +178,12 @@
180178
181179 private JMenuItem saveLogItem = null;
182180
181+ private JPopupMenu userPopupMenu = null; // @jve:decl-index=0:visual-constraint="911,405"
182+
183+ private JMenuItem setGmItem = null;
184+
185+ private HashMap<String, PluginDialog> dialogMap = new HashMap<String, PluginDialog>();
186+
183187 /**
184188 * This is the default constructor
185189 */
@@ -300,7 +304,6 @@
300304 toolBar.add(getDisconnectButton());
301305 toolBar.add(getServerButton());
302306 toolBar.addSeparator();
303- toolBar.add(getSaveButton());
304307 }
305308 return toolBar;
306309 }
@@ -392,18 +395,6 @@
392395 }
393396
394397 /**
395- * This method initializes saveButton
396- *
397- * @return javax.swing.JButton
398- */
399- private JButton getSaveButton() {
400- if (saveButton == null) {
401- saveButton = new JButton();
402- }
403- return saveButton;
404- }
405-
406- /**
407398 * This method initializes textScrollPane
408399 *
409400 * @return javax.swing.JScrollPane
@@ -666,11 +657,19 @@
666657 *
667658 * @return javax.swing.JTable
668659 */
669- private JTable getUserTable() {
660+ public JTable getUserTable() {
670661 if (userTable == null) {
671662 userTable = new JTable();
672663 userTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
673664 userTable.setModel(getUserTableModel());
665+ userTable.addMouseListener(new java.awt.event.MouseAdapter() {
666+ public void mouseClicked(java.awt.event.MouseEvent e) {
667+ int rowIndex = getUserTable().getSelectedRow();
668+ if(rowIndex >= 0 && SwingUtilities.isRightMouseButton(e)){
669+ getUserPopupMenu().show(userTable, e.getX(), e.getY());
670+ }
671+ }
672+ });
674673 TableColumnModel tcm = userTable.getColumnModel();
675674 TableColumn column0 = tcm.getColumn(0);
676675 column0.setPreferredWidth(100);
@@ -705,7 +704,7 @@
705704 *
706705 * @return jp.sf.chaplet.core.ui.UserTableModel
707706 */
708- private UserTableModel getUserTableModel() {
707+ public UserTableModel getUserTableModel() {
709708 if (userTableModel == null) {
710709 userTableModel = new UserTableModel();
711710 }
@@ -737,15 +736,22 @@
737736
738737 public void propertyChange(PropertyChangeEvent evt) {
739738 if(evt.getPropertyName().equals("displayMode")){
739+ ClientPlugin plugin = (ClientPlugin) evt.getSource();
740+ // 新しいビューの追加
741+ if(evt.getNewValue() == DisplayMode.TAB){
742+ showAsTabItem(plugin);
743+ } else if(evt.getNewValue() == DisplayMode.WINDOW){
744+ showAsWindow(plugin);
745+ }
740746 // 古いビューの削除
741747 if(evt.getOldValue() == DisplayMode.TAB){
742- removeTabItem((ClientPlugin) evt.getSource());
748+ removeTabItem(plugin);
749+ } else if(evt.getOldValue() == DisplayMode.WINDOW){
750+ PluginDialog dialog = dialogMap.get(plugin.getPluginId());
751+ if(dialog != null){
752+ dialog.dispose();
753+ }
743754 }
744-
745- // 新しいビューの追加
746- if(evt.getNewValue() == DisplayMode.TAB){
747- showAsTabItem((ClientPlugin) evt.getSource());
748- }
749755 }
750756 }
751757
@@ -867,9 +873,22 @@
867873 getTabbedPane().remove(plugin.getSwingComponent());
868874 }
869875
870- public void showAsWindow(ClientPlugin plugin) {
871- // TODO 自動生成されたメソッド・スタブ
872-
876+ public void showAsWindow(final ClientPlugin plugin) {
877+ final PluginDialog dialog = new PluginDialog(this);
878+ dialog.add(plugin.getSwingComponent(), BorderLayout.CENTER);
879+ dialog.setTitle(plugin.getName());
880+ dialog.addWindowListener(new WindowAdapter(){
881+ public void windowClosing(WindowEvent e) {
882+ plugin.setDisplayMode(DisplayMode.NONE);
883+ getPluginPanel().getPluginTableModel().fireTableDataChanged();
884+ }
885+ });
886+ dialogMap.put(plugin.getPluginId(), dialog);
887+ SwingUtilities.invokeLater(new Runnable() {
888+ public void run() {
889+ dialog.setVisible(true);
890+ }
891+ });
873892 }
874893
875894 public void showStatus(UserStatus[] status) {
@@ -1061,7 +1080,7 @@
10611080 initAllItem.setText("すべて初期化");
10621081 initAllItem.addActionListener(new java.awt.event.ActionListener() {
10631082 public void actionPerformed(java.awt.event.ActionEvent e) {
1064- System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
1083+ actionMap.get("reload").actionPerformed(e);
10651084 }
10661085 });
10671086 }
@@ -1323,4 +1342,35 @@
13231342 }
13241343 return saveLogItem;
13251344 }
1345+
1346+ /**
1347+ * This method initializes userPopupMenu
1348+ *
1349+ * @return javax.swing.JPopupMenu
1350+ */
1351+ private JPopupMenu getUserPopupMenu() {
1352+ if (userPopupMenu == null) {
1353+ userPopupMenu = new JPopupMenu();
1354+ userPopupMenu.add(getSetGmItem());
1355+ }
1356+ return userPopupMenu;
1357+ }
1358+
1359+ /**
1360+ * This method initializes setGmItem
1361+ *
1362+ * @return javax.swing.JMenuItem
1363+ */
1364+ private JMenuItem getSetGmItem() {
1365+ if (setGmItem == null) {
1366+ setGmItem = new JMenuItem();
1367+ setGmItem.setText("GMに選ぶ");
1368+ setGmItem.addActionListener(new java.awt.event.ActionListener() {
1369+ public void actionPerformed(java.awt.event.ActionEvent e) {
1370+ actionMap.get("callSetGM").actionPerformed(e);
1371+ }
1372+ });
1373+ }
1374+ return setGmItem;
1375+ }
13261376 } // @jve:decl-index=0:visual-constraint="10,10"
--- chaplet/trunk/src/core/jp/sf/chaplet/core/ui/PluginPanel.java (revision 30)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/ui/PluginPanel.java (revision 31)
@@ -104,7 +104,7 @@
104104 *
105105 * @return jp.sf.chaplet.core.ui.PluginTableModel
106106 */
107- private PluginTableModel getPluginTableModel() {
107+ public PluginTableModel getPluginTableModel() {
108108 if (pluginTableModel == null) {
109109 pluginTableModel = new PluginTableModel();
110110 }
--- chaplet/trunk/src/core/jp/sf/chaplet/core/ui/PluginDialog.java (nonexistent)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/ui/PluginDialog.java (revision 31)
@@ -0,0 +1,55 @@
1+/**
2+ *
3+ */
4+package jp.sf.chaplet.core.ui;
5+
6+import java.awt.BorderLayout;
7+import java.awt.Frame;
8+
9+import javax.swing.JDialog;
10+import javax.swing.JPanel;
11+import javax.swing.WindowConstants;
12+
13+/**
14+ * PluginDialog<br>
15+ * @version $Id$
16+ */
17+public class PluginDialog extends JDialog {
18+
19+ private static final long serialVersionUID = 1L;
20+
21+ private JPanel jContentPane = null;
22+
23+ /**
24+ * @param owner
25+ */
26+ public PluginDialog(Frame owner) {
27+ super(owner);
28+ initialize();
29+ }
30+
31+ /**
32+ * This method initializes this
33+ *
34+ * @return void
35+ */
36+ private void initialize() {
37+ this.setSize(428, 426);
38+ this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
39+ this.setContentPane(getJContentPane());
40+ }
41+
42+ /**
43+ * This method initializes jContentPane
44+ *
45+ * @return javax.swing.JPanel
46+ */
47+ private JPanel getJContentPane() {
48+ if (jContentPane == null) {
49+ jContentPane = new JPanel();
50+ jContentPane.setLayout(new BorderLayout());
51+ }
52+ return jContentPane;
53+ }
54+
55+} // @jve:decl-index=0:visual-constraint="10,10"
Added: svn:keywords
## -0,0 +1 ##
+" Date Revision Author HeadURL Id "
\ No newline at end of property
--- chaplet/trunk/src/core/jp/sf/chaplet/core/client/ChatClient.java (revision 30)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/client/ChatClient.java (revision 31)
@@ -430,8 +430,13 @@
430430 }
431431 }
432432
433- public void callSetGM(String name) {
434- getConnection().sendMessage(new String[] { "setgm", name });
433+ @Action
434+ public void callSetGM() {
435+ int rowIndex = view.getUserTable().getSelectedRow();
436+ if(rowIndex >= 0){
437+ UserStatus user = view.getUserTableModel().getRow(rowIndex);
438+ getConnection().sendMessage(new String[] { "setgm", user.getSessionId() });
439+ }
435440 }
436441
437442 /**
--- chaplet/trunk/src/core/jp/sf/chaplet/core/client/StatusAction.java (revision 30)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/client/StatusAction.java (revision 31)
@@ -18,12 +18,13 @@
1818 * @see jp.sf.chaplet.core.client.ClientAction#messageRecieved(java.lang.String[])
1919 */
2020 public ActionResult messageRecieved(String[] message) {
21- UserStatus[] status = new UserStatus[(message.length - 1)/ 3];
21+ UserStatus[] status = new UserStatus[(message.length - 1)/ 4];
2222 for(int i = 0; i < status.length; i++){
2323 status[i] = new UserStatus();
24- status[i].setName(message[i * 3 + 1]);
25- status[i].setWriting(message[i * 3 + 2].equals("y"));
26- String[] extStatus = message[i * 3 + 3].split(",");
24+ status[i].setName(message[i * 4 + 1]);
25+ status[i].setWriting(message[i * 4 + 2].equals("y"));
26+ status[i].setSessionId(message[i * 4 + 3]);
27+ String[] extStatus = message[i * 4 + 4].split(",");
2728 for (int j = 0; j < extStatus.length; j++) {
2829 status[i].setStatusOf(j, extStatus[j]);
2930 }
Show on old repository browser