| | |
| | | package com.ximple.eofms; |
| | | |
| | | import java.awt.Dimension; |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.GridBagLayout; |
| | | import java.awt.event.ActionEvent; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.net.MalformedURLException; |
| | | import java.net.URL; |
| | | import java.util.ResourceBundle; |
| | | import javax.swing.AbstractAction; |
| | | import javax.swing.Action; |
| | | import javax.swing.BorderFactory; |
| | |
| | | import javax.swing.event.ChangeListener; |
| | | import javax.swing.event.DocumentEvent; |
| | | import javax.swing.event.DocumentListener; |
| | | import java.awt.Dimension; |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.GridBagLayout; |
| | | import java.awt.event.ActionEvent; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.net.MalformedURLException; |
| | | import java.net.URL; |
| | | import java.util.ResourceBundle; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | |
| | | import org.awl.header.EclipseWizardHeader; |
| | | import org.awl.message.MessageLevel; |
| | | |
| | | public class XQuartzJobWizard extends DefaultWizard |
| | | { |
| | | public class XQuartzJobWizard extends DefaultWizard { |
| | | static Log logger = LogFactory.getLog(XQuartzJobWizard.class); |
| | | |
| | | /** |
| | |
| | | /** |
| | | * Creates a new instance of AwlDemo |
| | | */ |
| | | public XQuartzJobWizard(JFrame frame) |
| | | { |
| | | public XQuartzJobWizard(JFrame frame) { |
| | | super(frame); |
| | | |
| | | AbstractWizardHeader header = new EclipseWizardHeader(); |
| | |
| | | secondPage.setMessage(rb.getString("second.messageContent"), MessageLevel.INFO); |
| | | |
| | | URL licenseUrl = null; |
| | | try |
| | | { |
| | | try { |
| | | licenseUrl = new URL("http://www.gnu.org/licenses/lgpl-2.1.txt"); |
| | | } |
| | | catch (MalformedURLException e) |
| | | { |
| | | catch (MalformedURLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | JEditorPane licensePane = null; |
| | | if (licenseUrl == null) |
| | | { |
| | | if (licenseUrl == null) { |
| | | licensePane = new JEditorPane(); |
| | | licensePane.setText("license LGPL 2.1"); |
| | | } else |
| | | { |
| | | try |
| | | { |
| | | } else { |
| | | try { |
| | | licensePane = new JEditorPane(licenseUrl); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | catch (IOException e) { |
| | | licensePane = new JEditorPane(); |
| | | licensePane.setText("license LGPL 2.1"); |
| | | } |
| | |
| | | licenseButtonGroup.add(radioAcceptLicense); |
| | | licenseButtonGroup.add(radioRefuseLicense); |
| | | |
| | | ChangeListener changeListener = new ChangeListener() |
| | | { |
| | | public void stateChanged(ChangeEvent e) |
| | | { |
| | | ChangeListener changeListener = new ChangeListener() { |
| | | public void stateChanged(ChangeEvent e) { |
| | | secondPage.setNextPageAuthorization( |
| | | radioAcceptLicense.isSelected() ? NavigationAuthorization.DEFAULT : |
| | | NavigationAuthorization.FORBIDDEN); |
| | | radioAcceptLicense.isSelected() ? NavigationAuthorization.DEFAULT : |
| | | NavigationAuthorization.FORBIDDEN); |
| | | } |
| | | }; |
| | | |
| | |
| | | |
| | | /** third page */ |
| | | final JTextField locationField = new JTextField(20); |
| | | final Action chooseLocation = new AbstractAction() |
| | | { |
| | | public void actionPerformed(ActionEvent e) |
| | | { |
| | | final Action chooseLocation = new AbstractAction() { |
| | | public void actionPerformed(ActionEvent e) { |
| | | File current = null; |
| | | String text = locationField.getText(); |
| | | if (text != null && text.trim().length() > 0) |
| | | { |
| | | try |
| | | { |
| | | if (text != null && text.trim().length() > 0) { |
| | | try { |
| | | current = new File(text); |
| | | if (!current.exists()) |
| | | { |
| | | if (!current.exists()) { |
| | | current = null; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { } |
| | | catch (Exception ex) { |
| | | } |
| | | } |
| | | |
| | | JFileChooser chooser = new JFileChooser(current); |
| | | chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
| | | chooser.setFileFilter(new javax.swing.filechooser.FileFilter() |
| | | { |
| | | public boolean accept(File f) |
| | | { |
| | | chooser.setFileFilter(new javax.swing.filechooser.FileFilter() { |
| | | public boolean accept(File f) { |
| | | boolean result = false; |
| | | |
| | | if (f != null && f.isDirectory()) |
| | | { |
| | | if (f != null && f.isDirectory()) { |
| | | result = true; |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | public String getDescription() |
| | | { |
| | | public String getDescription() { |
| | | return rb.getString("third.fileChooser.description"); |
| | | } |
| | | }); |
| | | chooser.setMultiSelectionEnabled(false); |
| | | int answer = chooser.showDialog(XQuartzJobWizard.this, rb.getString("third.fileChooser.selectLabel")); |
| | | |
| | | if (answer == JFileChooser.CANCEL_OPTION) |
| | | { |
| | | if (answer == JFileChooser.CANCEL_OPTION) { |
| | | locationField.setText(""); |
| | | thirdPage.setMessage(rb.getString("third.messageContent"), MessageLevel.WARN); |
| | | } else // aprove |
| | |
| | | } |
| | | } |
| | | }; |
| | | this.thirdPage = new DefaultWizardPageDescriptor() |
| | | { |
| | | public void displayingPanel(Wizard wizard) |
| | | { |
| | | this.thirdPage = new DefaultWizardPageDescriptor() { |
| | | public void displayingPanel(Wizard wizard) { |
| | | /** open file dialog box */ |
| | | if (locationField.getText().trim().length() == 0) |
| | | { |
| | | if (locationField.getText().trim().length() == 0) { |
| | | chooseLocation.actionPerformed(null); |
| | | } |
| | | } |
| | |
| | | chooseLocation.putValue(Action.SMALL_ICON, new ImageIcon(AwlDemo.class.getResource("/org/awl/rc/folder.png"))); |
| | | thirdPage.setNextPageAuthorization(NavigationAuthorization.FORBIDDEN); |
| | | |
| | | locationField.getDocument().addDocumentListener(new DocumentListener() |
| | | { |
| | | public void changedUpdate(DocumentEvent e) |
| | | { } |
| | | locationField.getDocument().addDocumentListener(new DocumentListener() { |
| | | public void changedUpdate(DocumentEvent e) { } |
| | | |
| | | public void insertUpdate(DocumentEvent e) |
| | | { |
| | | public void insertUpdate(DocumentEvent e) { |
| | | this.changeNavigation(); |
| | | } |
| | | |
| | | public void removeUpdate(DocumentEvent e) |
| | | { |
| | | public void removeUpdate(DocumentEvent e) { |
| | | this.changeNavigation(); |
| | | } |
| | | |
| | | private void changeNavigation() |
| | | { |
| | | private void changeNavigation() { |
| | | thirdPage.setNextPageAuthorization(locationField.getText().trim().length() > 0 ? NavigationAuthorization.DEFAULT : |
| | | NavigationAuthorization.FORBIDDEN); |
| | | NavigationAuthorization.FORBIDDEN); |
| | | } |
| | | }); |
| | | |
| | |
| | | final JProgressBar installProgressBar = new JProgressBar(); |
| | | final JLabel progressLabel = new JLabel(rb.getString("fourth.inProgress.text")); |
| | | |
| | | this.fourthPage = new DefaultWizardPageDescriptor() |
| | | { |
| | | public void displayingPanel(Wizard wizard) |
| | | { |
| | | this.fourthPage = new DefaultWizardPageDescriptor() { |
| | | public void displayingPanel(Wizard wizard) { |
| | | /* begin installation */ |
| | | this.setPreviousPageAuthorization(NavigationAuthorization.FORBIDDEN); |
| | | this.setFinishAuthorization(NavigationAuthorization.FORBIDDEN); |
| | | |
| | | /* begin new thread */ |
| | | Runnable runnable = new Runnable() |
| | | { |
| | | public void run() |
| | | { |
| | | while (installProgressBar.getValue() < installProgressBar.getMaximum()) |
| | | { |
| | | Runnable r = new Runnable() |
| | | { |
| | | public void run() |
| | | { installProgressBar.setValue(installProgressBar.getValue() + 1); } |
| | | Runnable runnable = new Runnable() { |
| | | public void run() { |
| | | while (installProgressBar.getValue() < installProgressBar.getMaximum()) { |
| | | Runnable r = new Runnable() { |
| | | public void run() { installProgressBar.setValue(installProgressBar.getValue() + 1); } |
| | | }; |
| | | SwingUtilities.invokeLater(r); |
| | | |
| | | try |
| | | { |
| | | try { |
| | | Thread.sleep(50); |
| | | } |
| | | catch (InterruptedException e) |
| | | { |
| | | Runnable r1 = new Runnable() |
| | | { |
| | | public void run() |
| | | { installProgressBar.setValue(installProgressBar.getMaximum()); } |
| | | catch (InterruptedException e) { |
| | | Runnable r1 = new Runnable() { |
| | | public void run() { installProgressBar.setValue(installProgressBar.getMaximum()); } |
| | | }; |
| | | SwingUtilities.invokeLater(r1); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | Runnable r2 = new Runnable() |
| | | { |
| | | public void run() |
| | | { progressLabel.setText(rb.getString("fourth.finished.text")); } |
| | | Runnable r2 = new Runnable() { |
| | | public void run() { progressLabel.setText(rb.getString("fourth.finished.text")); } |
| | | }; |
| | | SwingUtilities.invokeLater(r2); |
| | | |
| | |
| | | this.addPage(fourthPage, "4"); |
| | | } |
| | | |
| | | public static void main(String[] args) |
| | | { |
| | | Runnable runnable = new Runnable() |
| | | { |
| | | public void run() |
| | | { |
| | | public static void main(String[] args) { |
| | | Runnable runnable = new Runnable() { |
| | | public void run() { |
| | | Wizard wizard = new XQuartzJobWizard((JFrame) null); |
| | | |
| | | wizard.pack(); |
| | |
| | | } |
| | | }; |
| | | |
| | | try |
| | | { |
| | | try { |
| | | SwingUtilities.invokeLater(runnable); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | } |