You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
191 lines
6.3 KiB
191 lines
6.3 KiB
package de.superx.transfer; |
|
|
|
import java.awt.FlowLayout; |
|
import java.awt.Font; |
|
import java.awt.event.ActionEvent; |
|
import java.awt.event.ActionListener; |
|
import java.io.File; |
|
import java.io.IOException; |
|
import java.util.Observer; |
|
import java.util.Vector; |
|
|
|
import javax.swing.BorderFactory; |
|
import javax.swing.DefaultListModel; |
|
import javax.swing.JButton; |
|
import javax.swing.JEditorPane; |
|
import javax.swing.JFileChooser; |
|
import javax.swing.JFrame; |
|
import javax.swing.JLabel; |
|
import javax.swing.JList; |
|
import javax.swing.JPanel; |
|
import javax.swing.JScrollPane; |
|
import javax.swing.border.Border; |
|
import javax.swing.event.HyperlinkEvent; |
|
import javax.swing.event.HyperlinkListener; |
|
import javax.swing.text.html.HTMLDocument; |
|
import javax.swing.text.html.HTMLFrameHyperlinkEvent; |
|
|
|
import de.memtext.icons.MBStandardIcons; |
|
import de.memtext.util.IconUtils; |
|
import de.memtext.util.WindowUtils; |
|
import de.memtext.widgets.FileOrDirSelectionPanel; |
|
import de.memtext.widgets.InfoMessage; |
|
import de.memtext.widgets.MBFrame; |
|
import de.memtext.widgets.VerticalBox; |
|
|
|
public class ActionPanel extends VerticalBox implements ActionListener { |
|
private FileOrDirSelectionPanel unloadPathPanel; |
|
|
|
private Vector files = new Vector(); |
|
|
|
private DefaultListModel fileListModel = new DefaultListModel(); |
|
|
|
private JLabel lblDir = new JLabel("Dateiliste"); |
|
|
|
private Font btnFont = new Font("Serif", Font.BOLD, 14); |
|
|
|
public ActionPanel() { |
|
super(); |
|
this.addStrut(40); |
|
JLabel lblTitle = new JLabel("Lokal"); |
|
lblTitle.setFont(new Font("SansSerif", Font.BOLD, 16)); |
|
this.addWithCenterAlignment(lblTitle); |
|
unloadPathPanel = new FileOrDirSelectionPanel("Unload Pfad"); |
|
unloadPathPanel.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
|
addWithCenterAlignment(unloadPathPanel); |
|
|
|
this.addStrut(40); |
|
JButton btnUnload = new JButton("entladen", IconUtils.get("de/superx/transfer/unload.gif")); |
|
|
|
btnUnload.setFont(btnFont); |
|
btnUnload.addActionListener(this); |
|
JPanel pUnload = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
|
pUnload.setBackground(null); |
|
|
|
pUnload.add(new JLabel(IconUtils.get("de/superx/transfer/pfeil-gruen.gif"))); |
|
pUnload.add(btnUnload); |
|
this.add(pUnload); |
|
JLabel lblArrowDown = new JLabel(IconUtils.get("de/superx/transfer/pfeil-down-gruen.gif")); |
|
lblArrowDown.setBackground(null); |
|
//this.addWithCenterAlignment(lblArrowDown); |
|
this.addStrut(20); |
|
this.add(lblDir); |
|
JList fileList = new JList(fileListModel); |
|
fileList.setVisibleRowCount(7); |
|
this.add(new JScrollPane(fileList)); |
|
JButton btnPreview = new JButton("Vorschau", MBStandardIcons.getViewingGlass()); |
|
this.addWithCenterAlignment(btnPreview); |
|
btnPreview.addActionListener(this); |
|
this.addStrut(20); |
|
JButton btnUpload = new JButton("abschicken", IconUtils.get("de/superx/transfer/upload.gif")); |
|
btnUpload.setFont(btnFont); |
|
this.addStrut(20); |
|
JPanel p2 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); |
|
p2.add(btnUpload); |
|
btnUpload.addActionListener(this); |
|
p2.add(new JLabel(IconUtils.get("de/superx/transfer/pfeil-blau.gif"))); |
|
this.add(p2); |
|
Border border = BorderFactory.createEtchedBorder(); |
|
this.addGlue(); |
|
//this.setBorder(border); |
|
} |
|
|
|
@Override |
|
public void actionPerformed(ActionEvent e) { |
|
if (e.getActionCommand().equals("entladen")) { |
|
unload(); |
|
} |
|
if (e.getActionCommand().equals("Vorschau")) { |
|
preview(); |
|
} |
|
if (e.getActionCommand().equals("abschicken")) { |
|
upload(); |
|
} |
|
} |
|
|
|
private void upload() { |
|
try { |
|
Thread.sleep(1000); |
|
} catch (InterruptedException e) { |
|
e.printStackTrace(); |
|
} |
|
InfoMessage.show(this, "Übertragung erfolgreich", TransferTool.TITLE); |
|
} |
|
|
|
private void unload() { |
|
try { |
|
Thread.sleep(500); |
|
} catch (InterruptedException e) { |
|
e.printStackTrace(); |
|
} |
|
|
|
fileListModel.removeAllElements(); |
|
|
|
fileListModel.addElement("k_abint.xml"); |
|
fileListModel.addElement("k_abext.xml"); |
|
fileListModel.addElement("k_stg.xml"); |
|
fileListModel.addElement("k_pvers.xml"); |
|
fileListModel.addElement("k_vert.xml"); |
|
fileListModel.addElement("k_schwp.xml"); |
|
fileListModel.addElement("k_nc.xml"); |
|
fileListModel.addElement("k_abstgv.xml"); |
|
|
|
} |
|
|
|
private void preview() { |
|
JEditorPane pane; |
|
try { |
|
File startFile = new File("index.htm"); |
|
pane = new JEditorPane("file://" + startFile.getAbsolutePath()); |
|
pane.setEditable(false); |
|
MBFrame f = new MBFrame("Vorschau"); |
|
f.setIconImage(IconUtils.get("de/superx/transfer/transferIcon.gif").getImage()); |
|
pane.addHyperlinkListener(new Hyperactive(f)); |
|
|
|
f.setSystemExitOnClose(false); |
|
f.setCenter(new JScrollPane(pane)); |
|
|
|
WindowUtils.maximize(f); |
|
f.show(); |
|
} catch (IOException e) { |
|
e.printStackTrace(); |
|
} |
|
|
|
} |
|
|
|
class Hyperactive implements HyperlinkListener { |
|
private JFrame parentFrame; |
|
|
|
Hyperactive(JFrame parentFrame) { |
|
this.parentFrame = parentFrame; |
|
} |
|
|
|
@Override |
|
public void hyperlinkUpdate(HyperlinkEvent e) { |
|
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { |
|
JEditorPane pane = (JEditorPane) e.getSource(); |
|
if (e instanceof HTMLFrameHyperlinkEvent) { |
|
HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e; |
|
HTMLDocument doc = (HTMLDocument) pane.getDocument(); |
|
doc.processHTMLFrameHyperlinkEvent(evt); |
|
} else { |
|
try { |
|
WindowUtils.setWaitCursor(parentFrame, true); |
|
pane.setPage(e.getURL()); |
|
WindowUtils.setWaitCursor(parentFrame, false); |
|
} catch (Throwable t) { |
|
t.printStackTrace(); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
public void addObserver(Observer observer) { |
|
|
|
unloadPathPanel.addObserver(observer); |
|
} |
|
|
|
} |
|
|
|
//Created on 17.04.2004 at 19:59:37
|