Blame view

circus/src/circusRefine/gui/InfoLei.java 7.2 KB
8d0dc533f   Madiel de Souza Conserva Filho   first
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
  package circusRefine.gui;
  
  import java.awt.Font;
  import java.awt.SystemColor;
  
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JScrollPane;
  import javax.swing.JTextArea;
  import javax.swing.JTextField;
  
  import circusRefine.core.ExternalManager;
  
  import net.sourceforge.czt.circus.ast.Transformation;
  import net.sourceforge.czt.circuspatt.util.CircusLaw;
  import net.sourceforge.czt.circus.util.CircusString;
  import net.sourceforge.czt.z.util.ZString;
  
  /**
   * Janela de exibição de detalhes de leis, é chamada através de um pop-up menu
   * na caixa de Leis. Mostra o nome da lei, seu tipo, as obrigações, detalhes e 
   * 
   * @author Alessandro
   *
   */
  public class InfoLei extends JFrame{
  	
  	/**
  	 * 
  	 */
  	private static final long serialVersionUID = 1L;
  
  	/* gerenciador de interface */
  	private ExternalManager gerInterface;
  	
  	private JLabel nome;
  	private JLabel obrigacoes;
  	private JLabel observacoes;
  	private JLabel termoAntes;
  	private JLabel termoDepois;
  	
  	private JTextField campoNome;
  	private JTextField simbolo;
  	
  	private JTextArea campoObrigacoes;
  	private JTextArea campoObservacoes;
  	private JTextArea antes;
  	private JTextArea depois;
  	
  	private static final String BRANCO = "     ";
  	private boolean first = true; /*utilizado na inserção do campoObrigações */
  	
  	
  	
  	public InfoLei(CircusLaw law, ExternalManager gerExt) {
  		/*Nome da Lei inseriado na parte superior do Frame*/
  		super(gerExt.getMessage("COD0483") + law.getName());
  		gerInterface = gerExt;
  		jbInit(law);
  	}
  	
  	/**
  	 * Metodo que inicializa os componentes do frame
  	 *
  	 */
  	private void jbInit(CircusLaw lei){
  		
  		this.setResizable(false);
  		this.setLayout(null);
  		
  		this.setSize(470, 540);
  		this.setLocation(400, 50);
  		
  		/*Setando o Text dos Labels -> ver Internacionalização*/
  		nome = new JLabel(gerInterface.getMessage("COD0484"));
  		obrigacoes = new JLabel(gerInterface.getMessage("COD0485"));
  		observacoes = new JLabel(gerInterface.getMessage("COD0486"));
  		termoAntes = new JLabel(gerInterface.getMessage("COD0487"));
  		termoDepois = new JLabel(gerInterface.getMessage("COD0488"));
  		
  		/* JTextFields*/
  		campoNome = new JTextField(35);
  		simbolo = new JTextField(2);
  		
  		/*JTextArea*/
  		
  		campoObrigacoes = new JTextArea(6,35);
  		campoObservacoes = new JTextArea(5,35);
  		antes = new JTextArea(5,10);
  		depois = new JTextArea(5,10);
  		
  		/* Setando o simbolo de acordo com o tipo de lei*/
  		setTexts(lei);
  				
  		/* Setando Fonts*/
  		
  		campoNome.setFont(new Font("CZT",Font.ITALIC,12));
  		campoObrigacoes.setFont(new Font("CZT",Font.PLAIN,12));
  		campoObservacoes.setFont(new Font("CZT",Font.ITALIC,12));
  		antes.setFont(new Font("CZT",Font.PLAIN,12));
  		depois.setFont(new Font("CZT",Font.PLAIN,12));
  		simbolo.setFont(new Font("CZT", Font.ROMAN_BASELINE,16));
  		
  		
  		/* Configurando JTextAreas*/
  		
  		campoNome.setEditable(false);
  		campoObrigacoes.setEditable(false);
  		campoObservacoes.setEditable(false);
  		antes.setEditable(false);
  		depois.setEditable(false);
  		simbolo.setEditable(false);
  		
  		campoNome.setBackground(SystemColor.WHITE);
  		campoObrigacoes.setBackground(SystemColor.WHITE);
  		campoObservacoes.setBackground(SystemColor.WHITE);
  		antes.setBackground(SystemColor.WHITE);
  		depois.setBackground(SystemColor.WHITE);
  		simbolo.setBackground(SystemColor.WHITE);
  		
  		
  		/* Setando JScrollPanes*/
  
  		JScrollPane obri = new JScrollPane(campoObrigacoes);
  		JScrollPane obs = new JScrollPane(campoObservacoes);
  		JScrollPane before = new JScrollPane(antes);
  		JScrollPane after = new JScrollPane(depois);
  		
  		/* Confogurando Tamanhos e adicionando ao Frame*/
  		
  		nome.setBounds(10, 10, 60, 20);
  		campoNome.setBounds(10, 35, 445, 25);
  		obrigacoes.setBounds(10, 70, 90,20 );
  		obri.setBounds(10, 95, 445, 110);
  		observacoes.setBounds(10, 215, 90, 20);
  		obs.setBounds(10, 240, 445, 75);
  		termoAntes.setBounds(10, 315, 50, 20);
  		termoDepois.setBounds(255,315,50,20);
  		before.setBounds(10, 350, 190, 145);
  		after.setBounds(265, 350, 190, 145);
  		simbolo.setBounds(217,415,30,30 );
  		
  		add(nome);
  		add(campoNome);
  		add(obrigacoes);
  		add(obri);
  		add(observacoes);
  		add(obs);
  		add(termoAntes);
  		add(termoDepois);
  		add(before);
  		add(after);
  		add(simbolo);
  		
  	}
  	
  	/**
  	 * Metodo que determina se o simbolo sera um simbolo de refinamento, 
  	 * de simulacao ou de equivalencia
  	 * @param law Lei corrente na janela
  	 */
  	private void setSymbol(CircusLaw law) {
  		
  		Transformation res = this.gerInterface.getType(law);
  		if (res.equals(Transformation.Equivalence)){
  			simbolo.setText( " " + CircusString.EQUALS);
  		}
  		else if (res.equals(Transformation.Refinement)){
  			simbolo.setText("  " + CircusString.CIRCREFINES);
  		}
  		else {
  			simbolo.setText( " " + CircusString.CIRCSIMULATES);
  		}
  	}
  	
  	/**
  	 * Metodo que ira setar o texto dos diversos componenetes dentro
  	 * do frame de informação da lei
  	 * @param law a Lei base desse container
  	 */
  	public void setTexts (CircusLaw law) {
  		this.campoNome.setText(law.getName());
  		setSymbol(law);
  		this.gerInterface.setarObrigacoesDaLei(law, this);
  		this.gerInterface.setarObservacaoDaLei(law, this);
  		this.gerInterface.setarAntesDaLei(law,this);
  		this.gerInterface.setarDepoisDaLei(law,this);
  		this.repaint();
  	}
  	
  	/**
  	 * Metodo que seta o conteudo do JTextArea observacoes
  	 * @param str Vetor de Strings que sera as observacoes a respeito
  	 * da lei corrente na InfoLei
  	 */
  	public void setarObservacoes(String[] str) {
  		String result = "";
  		for (int i=0;i< str.length;i++) {
  			result+= ZString.SPOT + " " + str[i] + "
  ";
  		}
  		this.campoObservacoes.setText(result);
  	}
  	/**
  	 * Metodo que seta as obrigacoes no campo de Obrigacoes
  	 * @param str A string obtida atraves do visitor de printer no Gerenciador
  	 * Externo 
  	 * @param identificador Identificador para saber em qual posicao sera 
  	 * setada a String. É o simbolo romano a frente da obrigação de prova.
  	 */
  	public void setObrigacoes (String[] str, int identificador) {
  		String romano =this.gerInterface.natToRom(identificador, 0);
  		String result = "";
  		String space = "";
  		for (int i =0;i< romano.length();i++) {
  			space += " ";
  		}
  
  		result = romano + BRANCO + str[0] + "
  ";
  
  		for (int i=1;i<str.length;i++) {
  			result+= space + BRANCO + str[i] + "
  "; 
  		}
  		
  		if (first) {
  			this.campoObrigacoes.setText(result);
  			first = false;
  		}
  		else {
  			String originalText = this.campoObrigacoes.getText();
  			originalText += "
  " + result;
  			this.campoObrigacoes.setText(originalText);
  		}
  		identificador++;
  	}
  	/**
  	 * Metoto Set do campo Antes
  	 * @param str String a ser setada, representa a situação anterior a aplicação
  	 * da lei
  	 */
  	public void setAntes (String[] str) {
  		
  		String result = "";
  		for (int i=0;i<str.length;i++) {
  			result += str[i] + "
  ";
  		}
  		this.antes.setText(result);
  	}
  	
  	/**
  	 * Metoto Set do campo Depois
  	 * @param str String a ser setada, representa a situação posterior a aplicação
  	 * da lei
  	 */
  	public void setDepois (String[] str) {
  		
  		String result = "";
  		for (int i=0;i<str.length;i++) {
  			result += str[i] + "
  ";
  		}
  		this.depois.setText(result);
  	}
  	
  	
  	
  }