forked from VatsalBhuva11/OOM-MiniProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRetreive.java
More file actions
235 lines (180 loc) · 7.13 KB
/
Copy pathRetreive.java
File metadata and controls
235 lines (180 loc) · 7.13 KB
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
import javax.swing.JPanel;
import javax.swing.JTextArea;
import java.io.*;
import java.util.*;
import java.applet.*;
import java.awt.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Scanner;
@SuppressWarnings("serial")
public class Retreive extends JPanel {
JTextField t;
JTextArea t1;
JTextField t2;
JTextField t3;
JTextField t4;
JTextField t5;
JTextField t6;
JTextField t7;
JTextField t8;
JTextField t9;
String topicOP;
String categoryOP;
public static Document[] getAllDocs() {
Document[] docs = new Document[Document.counter];
for (int i = 0; i < Document.counter; i++) {
int x = i + 1;
docs[i] = new Document(Document.doc_name[i], x, Topic.topic[i], Category.category[i], Tag.tags[i]);
}
return docs;
}
public Retreive() {
Topic tops = new Topic();
Category c = new Category();
Tag g = new Tag();
setLayout(new GridLayout(5, 3));
if (Document.counter == 0) {
System.out.println("There are no Documents currently for retreival ");
JLabel label = new JLabel("There are no Documents currently for retreival ");
this.add(label);
}
else {
t = new JTextField("DOCUMENT LIST: ");
t.setSize(300, 300);
t.setEditable(true);
t1 = new JTextArea(" ");
t1.setSize(300, 300);
t1.setEditable(true);
JButton j1 = new JButton("PROCEED");
t2 = new JTextField("ENTER TOPIC");
t2.setSize(300, 300);
t2.setEditable(true);
t3 = new JTextField("TOPIC: ");
t3.setSize(300, 300);
t3.setEditable(true);
JButton j2 = new JButton("SPECIFY");
t4 = new JTextField("ENTER CATEGORY");
t4.setSize(300, 300);
t4.setEditable(true);
t5 = new JTextField("CATEGORY: ");
t5.setSize(300, 300);
t5.setEditable(true);
JButton j3 = new JButton("SPECIFY");
t6 = new JTextField("CLICK TO RETREIVE");
t6.setSize(300, 300);
t6.setEditable(true);
t7 = new JTextField("RETRIEVED DOCUMENT: ");
t7.setSize(300, 300);
t7.setEditable(true);
JButton j4 = new JButton("RETREIVE");
t8 = new JTextField("CLICK TO GO TO MAIN PAGE");
t8.setSize(300, 300);
t8.setEditable(true);
t9 = new JTextField("CLICK TO GO TO MAIN PAGE");
t9.setSize(300, 300);
t9.setEditable(true);
JButton j5 = new JButton("MAIN PAGE");
j1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
StringBuilder s1 = new StringBuilder();
for (int i = 0; i < Document.counter; i++) {
int x = i + 1;
s1 = s1.append("id: ").append(x).append(" Document Name: ").append(Document.doc_name[i])
.append("\n");
}
t1.setText(s1.toString());
}
});
j2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String s1 = t2.getText();
topicOP = s1;
t3.setText("TOPIC: " + topicOP);
}
});
j3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String s1 = t4.getText();
categoryOP = s1;
t5.setText("CATEGORY: " + categoryOP);
}
});
j4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int j = -1, k = -1;
for (int i = 0; i < Document.counter; i++) {
String s = tops.topic[i];
if (topicOP.equals(s)) {
j = i;
}
}
if (j < 0) {
System.out.println("Couldn't find the specified topic");
t7.setText("UNABLE TO FIND GIVEN TOPIC");
}
for (int i = 0; i < Document.counter; i++) {
String p = c.category[i];
if (categoryOP.equals(p)) {
k = i;
}
}
if (k < 0) {
System.out.println("Couldn't find the specified category");
t7.setText("UNABLE TO FIND GIVEN CATEGORY");
}
if (j == k) {
System.out.println("Retrieved the document successfully ");
System.out.println("Here is your document: ");
int g = j + 1;
System.out.println("ID: " + g + " Document Name: " + Document.doc_name[j]);
t7.setText("RETREIEVED DOCUMENT: ID: " + g + " Document Name: " + Document.doc_name[j]);
} else {
System.out.println("Unable to retrieve the document ");
t7.setText("UNABLE TO FIND DOCUMENT");
}
}
});
j5.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFrame jFrame = new JFrame();
jFrame.setTitle("Retrieving Document");
Add a = new Add();
Container cPane = jFrame.getContentPane();
Newclass template = new Newclass(a, cPane);
jFrame.setSize(template.getSize());
jFrame.setResizable(false);
cPane.add(template);
jFrame.setVisible(true);
jFrame.setLocationRelativeTo(null);
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
});
this.add(t);
this.add(j1);
this.add(t1);
this.add(t2);
this.add(j2);
this.add(t3);
this.add(t4);
this.add(j3);
this.add(t5);
this.add(t6);
this.add(j4);
this.add(t7);
this.add(t8);
this.add(j5);
this.add(t9);
}
}
}