blob: 7211a7c2d14b1a46a102132fe0d9532cc4702138 (
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
|
package org.openslx.dozmod.gui.window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.apache.log4j.Logger;
import org.openslx.bwlp.thrift.iface.ImagePermissions;
import org.openslx.bwlp.thrift.iface.ImageSummaryRead;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.MainWindow;
import org.openslx.dozmod.gui.window.layout.ImageListWindowLayout;
import org.openslx.dozmod.thrift.ImageCache;
import org.openslx.dozmod.thrift.UserCache;
import org.openslx.dozmod.util.FormatHelper;
import org.openslx.util.QuickTimer;
import org.openslx.util.QuickTimer.Task;
public class ImageListWindow extends ImageListWindowLayout {
private final static Logger LOGGER = Logger.getLogger(ImageListWindow.class);
public final ImageListWindow me = this;
public ImageListWindow() {
super();
// filter the objects in the table depending on the search field
searchTextField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
changedUpdate(e);
}
@Override
public void insertUpdate(DocumentEvent e) {
changedUpdate(e);
}
@Override
public void changedUpdate(DocumentEvent e) {
// TODO: Set filter
}
});
// Selection listener for the table to update the details panel when an image is clicked
imageTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
ImageSummaryRead image = imageTable.getSelectedItem();
if (image == null)
return;
// Fill detail information fields
// Image name
setFieldText(imageSelectedNameLabel, image.getImageName());
// id of the lecture
setFieldText(idInfo, image.getImageBaseId());
// version of the image TODO last? current?
setFieldText(versionInfo, image.getCurrentVersionId());
// last update of image
setFieldText(lastUpdateInfo, FormatHelper.longDate(image.getUpdateTime()));
// permissions of this image
ImagePermissions perms = image.getUserPermissions();
if (perms == null)
perms = image.getDefaultPermissions();
if (perms != null)
setFieldText(permissionInfo, perms.toString());
// the owner of the selected lecture
setFieldText(ownerInfo, FormatHelper.userName(UserCache.find(image.getOwnerId())));
// is it a template?
if (image.isTemplate)
templateInfo.setText("Ja");
else
templateInfo.setText("Nein");
me.invalidate();
me.validate();
}
private void setFieldText(JTextField control, String content) {
if (content == null) {
control.setText("<null>");
} else {
control.setText(content);
}
}
});
imageTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
// TODO open details popup
ImageDetailsWindow.open(MainWindow.getMainWin());
}
}
});
newButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO open wizard for image creation
}
});
downloadButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO open download popup
}
});
// delete lecture
deleteButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO delete the image
}
});
// return to mainMenu
backButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
MainWindow.showPage(MainMenuWindow.class);
}
});
}
private void refreshList(final boolean forceRefresh) {
QuickTimer.scheduleOnce(new Task() {
@Override
public void fire() {
final List<ImageSummaryRead> imageList = ImageCache.get(forceRefresh);
Gui.asyncExec(new Runnable() {
@Override
public void run() {
imageTable.setData(imageList);
}
});
}
});
}
@Override
public boolean requestHide() {
return true;
}
@Override
public void requestShow() {
refreshList(false);
}
}
|