/
GRAppletSlideshow.java
143 lines (113 loc) · 4.48 KB
/
GRAppletSlideshow.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
package com.gallery.GalleryRemote;
import com.gallery.GalleryRemote.util.DialogUtil;
import com.gallery.GalleryRemote.util.GRI18n;
import com.gallery.GalleryRemote.util.ImageUtils;
import com.gallery.GalleryRemote.model.Album;
import com.gallery.GalleryRemote.model.Gallery;
import com.gallery.GalleryRemote.model.Picture;
import com.gallery.GalleryRemote.prefs.SlideshowPanel;
import com.gallery.GalleryRemote.prefs.PreferenceNames;
import javax.swing.*;
import javax.swing.event.ListDataListener;
import javax.swing.event.ListDataEvent;
import javax.swing.border.TitledBorder;
import java.applet.Applet;
import java.io.FilePermission;
import java.io.File;
import java.util.Iterator;
import java.util.Arrays;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
import HTTPClient.CookieModule;
import HTTPClient.Cookie;
/**
* Created by IntelliJ IDEA.
* User: paour
* Date: Oct 30, 2003
*/
public class GRAppletSlideshow extends GRAppletMini implements GalleryRemoteCore, ActionListener, ListDataListener,
PreferenceNames {
public static final String MODULE = "AppletSlideshow";
JButton jStart;
SlideshowPanel jSlidePanel;
SlideshowFrame slideshowFrame = null;
public GRAppletSlideshow() {
coreClass = "com.gallery.GalleryRemote.GalleryRemoteMini";
}
public void startup() {
galleries = new DefaultComboBoxModel();
AppletInfo info = getGRAppletInfo();
gallery = info.gallery;
galleries.addElement(gallery);
ImageUtils.deferredTasks();
album = new Album(gallery);
album.setName(info.albumName);
album.addListDataListener(this);
album.fetchAlbumImages(jStatusBar,
GalleryRemote._().properties.getBooleanProperty(SLIDESHOW_RECURSIVE, true),
GalleryRemote._().properties.getIntProperty(SLIDESHOW_MAX_PICTURES, 0));
}
protected void jbInit() {
getContentPane().setLayout(new GridBagLayout());
jStart = new JButton(GRI18n.getString(MODULE, "Start"));
jStatusBar = new StatusBar(75);
jSlidePanel = new SlideshowPanel();
getContentPane().add(jSlidePanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0
, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
getContentPane().add(new JLabel(GRI18n.getString(MODULE, "Disabled")), new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0
, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 3, 0, 3), 0, 0));
getContentPane().add(jStart, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 0));
getContentPane().add(jStatusBar, new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
jSlidePanel.buildUI();
jSlidePanel.remove(jSlidePanel.spacerPanel);
jSlidePanel.readProperties(GalleryRemote._().properties);
jStart.addActionListener(this);
jStart.setEnabled(false);
jPicturesList = new DroppableList();
}
public void setInProgress(boolean inProgress) {
jStart.setEnabled(!inProgress && album.getSize() > 0);
this.inProgress = inProgress;
}
public void actionPerformed(ActionEvent e) {
jSlidePanel.writeProperties(GalleryRemote._().properties);
if (slideshowFrame == null) {
slideshowFrame = new SlideshowFrame();
}
slideshowFrame.showSlideshow();
slideshowFrame.start(album.getPicturesList());
// null slideshowFrame so that next time the user clicks the button
// they get a blank one, in case they changed positioning
slideshowFrame = null;
}
public void shutdown() {
if (hasStarted && GalleryRemote._() != null) {
jSlidePanel.writeProperties(GalleryRemote._().properties);
//GalleryRemote._().properties.write();
}
super.shutdown();
}
public void contentsChanged(ListDataEvent e) {
if (album.isHasFetchedImages()) {
Log.log(Log.LEVEL_TRACE, MODULE, "Pictures were just added to the album. Preload the first one.");
new Thread() {
public void run() {
slideshowFrame = new SlideshowFrame();
if (album.getSize() > 0) {
ImageUtils.download((Picture) album.getPicturesList().get(0), getGraphicsConfiguration().getBounds().getSize(), GalleryRemote._().getCore().getMainStatusUpdate(), null);
} else {
JOptionPane.showMessageDialog(GRAppletSlideshow.this, GRI18n.getString(MODULE, "emptyAlbum"));
}
}
}.start();
}
}
public void intervalAdded(ListDataEvent e) {}
public void intervalRemoved(ListDataEvent e) {}
}