summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/DialogAction.java
blob: c1c14fd0d79f103c288cd21c31d70dccb3c08e7a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*     */ package NET.worlds.scape;
/*     */ 
/*     */ import NET.worlds.console.Console;
/*     */ import NET.worlds.console.DialogReceiver;
/*     */ import NET.worlds.console.PolledDialog;
/*     */ import java.io.IOException;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public abstract class DialogAction
/*     */   extends Action
/*     */   implements DialogReceiver
/*     */ {
/*  28 */   boolean showDialog = true;
/*  29 */   boolean cancelOnly = false;
/*     */   
/*  31 */   private static PolledDialog dialogUp = null;
/*     */   private PolledDialog thisDialog;
/*  33 */   protected static boolean doCancel = false;
/*     */   
/*     */ 
/*     */ 
/*     */   public void dialogDone(Object who, boolean confirmed)
/*     */   {
/*  39 */     if (dialogUp == who) {
/*  40 */       doCancel = true;
/*  41 */       if (confirmed) {
/*  42 */         doIt();
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public abstract void doIt();
/*     */   
/*     */ 
/*     */ 
/*     */   public abstract PolledDialog getDialog();
/*     */   
/*     */ 
/*     */ 
/*     */   public Persister trigger(Event e, Persister seqID)
/*     */   {
/*  59 */     Console console = Console.getActive();
/*     */     
/*     */ 
/*  62 */     if (console == null) {
/*  63 */       return null;
/*     */     }
/*     */     
/*  66 */     if ((!this.showDialog) && (!this.cancelOnly)) {
/*  67 */       if (console != null)
/*  68 */         doIt();
/*  69 */       return null;
/*     */     }
/*     */     
/*  72 */     if (dialogUp != null)
/*     */     {
/*     */ 
/*     */ 
/*  76 */       if ((this.thisDialog != dialogUp) || (seqID == null)) {
/*  77 */         doCancel = true;
/*  78 */       } else if (doCancel) {
/*  79 */         dialogUp.closeIt(false);
/*  80 */         dialogUp = null;
/*  81 */         this.thisDialog = null;
/*  82 */         return null;
/*     */       }
/*  84 */       return this;
/*     */     }
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*  90 */     if (this.cancelOnly) {
/*  91 */       return null;
/*     */     }
/*  93 */     this.thisDialog = (dialogUp = getDialog());
/*  94 */     doCancel = false;
/*  95 */     return this;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public Object properties(int index, int offset, int mode, Object value)
/*     */     throws NoSuchPropertyException
/*     */   {
/* 103 */     Object ret = null;
/* 104 */     switch (index - offset) {
/*     */     case 0: 
/* 106 */       if (mode == 0) {
/* 107 */         ret = BooleanPropertyEditor.make(
/* 108 */           new Property(this, index, "Display Dialog Box"), 
/* 109 */           "Don't ask", 
/* 110 */           "Ask user to ok choice");
/*     */       }
/* 112 */       else if (mode == 1) {
/* 113 */         ret = new Boolean(this.showDialog);
/*     */       }
/* 115 */       else if (mode == 2) {
/* 116 */         this.showDialog = ((Boolean)value).booleanValue();
/*     */       }
/* 118 */       break;
/*     */     case 1: 
/* 120 */       if (mode == 0) {
/* 121 */         ret = BooleanPropertyEditor.make(
/* 122 */           new Property(this, index, "Cancel only"), 
/* 123 */           "Regular operation", 
/* 124 */           "Cancels dialog, doesn't do action");
/* 125 */       } else if (mode == 1) {
/* 126 */         ret = new Boolean(this.cancelOnly);
/* 127 */       } else if (mode == 2)
/* 128 */         this.cancelOnly = ((Boolean)value).booleanValue();
/* 129 */       break;
/*     */     default: 
/* 131 */       ret = super.properties(index, offset + 2, mode, value);
/*     */     }
/* 133 */     return ret;
/*     */   }
/*     */   
/*     */ 
/* 137 */   private static Object classCookie = new Object();
/*     */   
/*     */   public void saveState(Saver s) throws IOException {
/* 140 */     s.saveVersion(0, classCookie);
/* 141 */     super.saveState(s);
/*     */     
/* 143 */     s.saveBoolean(this.showDialog);
/* 144 */     s.saveBoolean(this.cancelOnly);
/*     */   }
/*     */   
/*     */   protected void dialogActionSkipRestore(Restorer r)
/*     */     throws IOException, TooNewException
/*     */   {
/* 150 */     super.restoreState(r);
/*     */   }
/*     */   
/*     */   public void restoreState(Restorer r) throws IOException, TooNewException {
/* 154 */     switch (r.restoreVersion(classCookie)) {
/*     */     case 0: 
/* 156 */       super.restoreState(r);
/* 157 */       this.showDialog = r.restoreBoolean();
/* 158 */       this.cancelOnly = r.restoreBoolean();
/* 159 */       break;
/*     */     
/*     */     default: 
/* 162 */       throw new TooNewException();
/*     */     }
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\DialogAction.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */