Blame view

circus/src/circusRefine/gui/CommentsFrame.java 6.69 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
  package circusRefine.gui;
  
  import java.awt.BorderLayout;
  import java.awt.Color;
  import java.awt.FlowLayout;
  import java.awt.Font;
  import java.awt.GridLayout;
  import java.awt.event.ActionEvent;
  
  import javax.swing.JButton;
  import javax.swing.JDialog;
  import javax.swing.JLabel;
  import javax.swing.JOptionPane;
  import javax.swing.JPanel;
  import javax.swing.JScrollPane;
  import javax.swing.JTextArea;
  
  import circusRefine.core.ExternalManager;
  import circusRefine.util.CommentsMode;
  
  /**
   * Janela que permite o usuario digitar o comentario! Bastante
   * Parecida com a Tela Parametro
   * @author Alessandro
   *
   */
  public class CommentsFrame extends JDialog {
  
  	/**
  	 * 
  	 */
  	private static final long serialVersionUID = 1L;
  
  	private ExternalManager gerInterface;
  
  	protected static String Space = " ";
  
  	JPanel panel1 = new JPanel();
  	JButton btnOK = new JButton();
  	JButton btnCancel = new JButton();
  
  	/*
  	 * Me diz se a janela devera ser exibida para uma digitacao
  	 * uma visualizacao ou uma edicao
  	 */
  	CommentsMode modo;
  
  	/*
  	 * Area de digitacao do Comentario
  	 */
  	JTextArea tfEspec = new JTextArea();
  	JScrollPane rolagem;
  
  	JLabel labelEntrada = new JLabel();
  	JPanel panel2 = new JPanel();
  	BorderLayout borderLayout1 = new BorderLayout();
  	BorderLayout borderLayout2 = new BorderLayout();
  	JPanel panel3 = new JPanel();
  	GridLayout gridLayout1 = new GridLayout();
  	JPanel panel4 = new JPanel();
  	BorderLayout borderLayout3 = new BorderLayout();
  	FlowLayout flowLayout1 = new FlowLayout();
  
  	JPanel panel5 = new JPanel();
  	JPanel panel6 = new JPanel();
  	JPanel panel7 = new JPanel();
  	JPanel panel8 = new JPanel();
  	JPanel panel9 = new JPanel();
  
  	private String textTarget = null;
  
  	/**
  	 * Construtor da classe TelaPredParametro.
  	 *
  	 * @param telaLeis           Um objeto da classe FLeis.
  	 * @param gerInterface       Gerenciador de todas as telas do sistema.
  	 *
  	 */
  	public CommentsFrame(ExternalManager gerInterface, CommentsMode mod) {
  		super(gerInterface.retornarTelaPrincipal());
  		modo = mod;
  
  		try  {
  			this.gerInterface = gerInterface;
  			jbInit();
  		}
  		catch (Exception e) {
  			e.printStackTrace();
  		}
  
  
  	}
  
  	/**
  	 * 
  	 * @param gerInterface referencia ao gerenciador Externo
  	 * @param txt Texto a ser exibido referente ao termo de um target
  	 * de um subdesenvolvimento
  	 */
  	public CommentsFrame(ExternalManager gerInterface, String txt) {
  		super(gerInterface.retornarTelaPrincipal());
  		modo = CommentsMode.VISUALIZANDO;
  		textTarget = txt;
  
  		try  {
  			this.gerInterface = gerInterface;
  			jbInit();
  		}
  		catch (Exception e) {
  			e.printStackTrace();
  		}
  
  
  	}
  
  
  
  	/**
  	 * Metodo que inicializar a gui
  	 *
  	 */
  	private void jbInit() {
  
  		this.setLocation(240,220);
  		this.setSize(320, 160);
  		this.setTitle(this.retornarMensagem("COD0276"));
  		this.setModal( true );
  
  		tfEspec.setFont(new Font ("CZT", Font.PLAIN, 12));
  		tfEspec.setText("");
  
  
  		rolagem = new JScrollPane(tfEspec);
  
  		btnOK.setForeground(Color.green);
  		btnOK.setFont(new Font("Dialog", 1, 12));
  		btnOK.setText(this.retornarMensagem("COD0072"));
  		btnOK.addActionListener(new java.awt.event.ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				btnOK_actionPerformed();
  			}
  		});
  
  		btnCancel.setForeground(Color.red);
  		btnCancel.setFont(new Font("Dialog", 1, 12));
  		btnCancel.setText(this.retornarMensagem("COD0078"));
  		btnCancel.addActionListener(new java.awt.event.ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				btnCancel_actionPerformed();
  			}
  		});
  
  		labelEntrada.setText(" " + this.retornarMensagem("COD0275"));
  		
  		ConfigurarTfEspec();
  		
  		panel1.setLayout(borderLayout1);
  		panel2.setLayout(borderLayout2);
  		panel3.setLayout(gridLayout1);
  		panel4.setLayout(borderLayout3);
  		panel9.setLayout(flowLayout1);
  
  		this.getContentPane().add(panel1, BorderLayout.CENTER);
  		panel1.add(panel2, BorderLayout.CENTER);
  		panel2.add(rolagem,  BorderLayout.CENTER);
  		panel2.add(panel5, BorderLayout.WEST);
  		panel2.add(panel6,  BorderLayout.SOUTH);
  		panel2.add(panel7,  BorderLayout.EAST);
  		panel2.add(panel8, BorderLayout.NORTH);
  		panel1.add(panel3,  BorderLayout.SOUTH);
  		panel3.add(btnOK, null);
  		panel3.add(btnCancel, null);
  		panel1.add(panel4, BorderLayout.NORTH);
  		panel4.add(labelEntrada,  BorderLayout.CENTER);
  		panel4.add(panel9,  BorderLayout.EAST);
  
  	} 
  
  
  	private void ConfigurarTfEspec() {
  		if ( modo.equals(CommentsMode.VISUALIZANDO)) {
  			labelEntrada.setText(" " + this.retornarMensagem("COD0285"));
  			if (textTarget == null) {
  				tfEspec.setEditable(false);
  				int[] selectedIndices = this.gerInterface.retornarLinhasSelecionadas();
  				Comentario comment = this.gerInterface
  				.getComentario(selectedIndices[0],selectedIndices[1]);
  				this.tfEspec.setText(comment.getTexto());
  				this.tfEspec.setEditable(false);
  			}
  			else{
  				this.setTitle(this.gerInterface.getMessage("COD0738").toUpperCase());
  				this.tfEspec.setText(textTarget);
  				this.labelEntrada.setText(this.gerInterface.getMessage("COD0738"));
  				this.tfEspec.setEditable(false);
  			}
  		}
  		else if ( modo.equals(CommentsMode.EDITANDO)) {
  			tfEspec.setEditable(true);
  			int[] selectedIndices = this.gerInterface.retornarLinhasSelecionadas();
  			Comentario comment = this.gerInterface.retornarTelaDesenvolvimento()
  			.getComentario(selectedIndices[0],selectedIndices[1]);
  			this.tfEspec.setText(comment.getTexto());
  
  		}
  		else{
  			tfEspec.setText("");
  		}
  
  	}
  
  	/**
  	 * Metodo chamado para cancelar o que foi digitado como Comentario
  	 *
  	 */
  	private void btnCancel_actionPerformed() {
  		this.setVisible(false);
  	}
  
  	/**
  	 * Metodo que ir� inserir o comentario  na Lista Interna de Comentarios
  	 */
  	private void btnOK_actionPerformed() {
  
  		if (modo.equals(CommentsMode.INSERINDO)) {
  			String text = tfEspec.getText();
  			this.gerInterface.insertComment(text);
  		}
  		else if (modo.equals(CommentsMode.EDITANDO)) {
  			this.gerInterface.editComment(tfEspec.getText());
  		}
  
  		this.setVisible(false);
  	}
  
  	/**
  	 * M�todo que retorna uma mensagem que ser� impressa na tela, tanto na forma
  	 * de t�tulo quanto na forma de mensagem de erro.
  	 *
  	 * @param codigo     O c�digo da mensagem que ser� retornada.
  	 *
  	 * @return           Uma String que representa a mensagem de retorno.
  	 *
  	 */
  	public String retornarMensagem(String codigo) {
  		String mensagem = gerInterface.getMessage(codigo);
  		return mensagem;
  	}
  
  	/**
  	 * M�todo que seta o label da tela.
  	 *
  	 * @param label      String que representa o label que ser� exibido.
  	 *
  	 */
  	public void setarLabel(String label){
  		labelEntrada.setText(label);
  	}
  
  }