From 94ae08701bbd7585a0b7e5a92d1975965a503c03 Mon Sep 17 00:00:00 2001 From: Dennis Kao <ulysseskao@gmail.com> Date: Wed, 15 Jan 2014 11:28:52 +0800 Subject: [PATCH] Merge branch 'origin/2.1.x' --- xdgnjobs/ximple-jobcarrier/src/main/java/com/ximple/eofms/XQuartzJobWizard.java | 166 ++++++++++++++++++++----------------------------------- 1 files changed, 60 insertions(+), 106 deletions(-) diff --git a/xdgnjobs/ximple-jobcarrier/src/main/java/com/ximple/eofms/XQuartzJobWizard.java b/xdgnjobs/ximple-jobcarrier/src/main/java/com/ximple/eofms/XQuartzJobWizard.java index 659c739..3b5015e 100644 --- a/xdgnjobs/ximple-jobcarrier/src/main/java/com/ximple/eofms/XQuartzJobWizard.java +++ b/xdgnjobs/ximple-jobcarrier/src/main/java/com/ximple/eofms/XQuartzJobWizard.java @@ -1,14 +1,5 @@ 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; @@ -32,6 +23,15 @@ 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; @@ -45,8 +45,7 @@ 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); /** @@ -87,8 +86,7 @@ /** * Creates a new instance of AwlDemo */ - public XQuartzJobWizard(JFrame frame) - { + public XQuartzJobWizard(JFrame frame) { super(frame); AbstractWizardHeader header = new EclipseWizardHeader(); @@ -119,28 +117,22 @@ 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"); } @@ -155,13 +147,11 @@ 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); } }; @@ -210,52 +200,42 @@ /** 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 @@ -264,13 +244,10 @@ } } }; - 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); } } @@ -278,25 +255,20 @@ 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); } }); @@ -350,38 +322,27 @@ 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); @@ -389,10 +350,8 @@ } } - 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); @@ -429,12 +388,9 @@ 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(); @@ -442,12 +398,10 @@ } }; - try - { + try { SwingUtilities.invokeLater(runnable); } - catch (Exception ex) - { + catch (Exception ex) { ex.printStackTrace(); } } -- Gitblit v0.0.0-SNAPSHOT