forked from VatsalBhuva11/OOM-MiniProject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Delete.java
231 lines (182 loc) · 7.32 KB
/
Delete.java
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
import java.io.*;
import java.util.*;
import java.applet.*;
import java.awt.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Scanner;
@SuppressWarnings("serial")
public class Delete extends JPanel {
JTextField t;
JTextArea t1;
JTextField t2;
JTextField t3;
JTextField t4;
JTextField t5;
JTextField t6;
JTextField t7;
public Delete() {
Topic tops = new Topic();
Category c = new Category();
Tag g = new Tag();
setLayout(new GridLayout(4, 3));
if (Document.counter == 0) {
System.out.println("There are no Documents currently for deletion ");
JLabel label = new JLabel("There are no Documents currently for deletion ");
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 DOCUMENT ID");
t2.setSize(300, 300);
t2.setEditable(true);
t3 = new JTextField("DELETED DOCUMENT: ");
t3.setSize(300, 300);
t3.setEditable(true);
JButton j2 = new JButton("DELETE");
t4 = new JTextField("UPDATED LIST: ");
t4.setSize(300, 300);
t4.setEditable(true);
t5 = new JTextField("UPDATED LIST: ");
t5.setSize(300, 300);
t5.setEditable(true);
JButton j3 = new JButton("UPDATE");
t6 = new JTextField("CLICK TO GO TO MAIN PAGE");
t6.setSize(300, 300);
t6.setEditable(true);
t7 = new JTextField("CLICK TO GO TO MAIN PAGE");
t7.setSize(300, 300);
t7.setEditable(true);
JButton j4 = 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();
int j = Integer.parseInt(s1);
t3.setText("THE DELETED DOCUMENT IS: " + Document.doc_name[j - 1]);
String[] doc = new String[100]; // Creating new array for document name
String[] top = new String[100]; // Creating new array for topic
String[] cat = new String[100]; // Creating new array for category
String[] gat = new String[100]; // Creating new array for tags
int count = 0;
for (int i = 0; i < Document.counter; i++) // Deleteing the document name at specified index
{
if (i == j - 1)
continue;
else {
doc[count] = Document.doc_name[i];
count++;
}
}
for (int i = 0; i < count; i++) {
Document.doc_name[i] = doc[i];
}
count = 0;
for (int i = 0; i < Document.counter; i++) // Deleteing the topic at specified index
{
if (i == j - 1)
continue;
else {
top[count] = tops.topic[i];
count++;
}
}
for (int i = 0; i < count; i++) {
tops.topic[i] = top[i];
}
count = 0;
for (int i = 0; i < Document.counter; i++) // Deleteing the category at specified index
{
if (i == j - 1)
continue;
else {
cat[count] = c.category[i];
count++;
}
}
for (int i = 0; i < count; i++) {
c.category[i] = cat[i];
}
count = 0;
for (int i = 0; i < Document.counter; i++) // Deleteing the tags at specified index
{
if (i == j - 1)
continue;
else {
gat[count] = g.tags[i];
count++;
}
}
for (int i = 0; i < count; i++) {
g.tags[i] = gat[i];
}
count = 0;
Document.counter--;
}
});
j3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String s1 = " ";
for (int i = 0; i < Document.counter; i++) {
int x = i + 1;
s1 = s1 + "id: " + x + " Document Name: " + Document.doc_name[i] + " ";
}
t5.setText(s1);
}
});
j4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFrame jFrame = new JFrame();
jFrame.setTitle("Deleting 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);
}
}
}