예제 #1
0
 public AllProperties() {
   super("Properties", true, false, true, true);
   Container contentPane = getContentPane();
   contentPane.setLayout(new GridLayout(2, 1, 10, 10));
   contentPane.add(new PropertyPanel("System Properties", System.getProperties()));
   contentPane.add(new PropertyPanel("Aleph Properties", Aleph.getProperties()));
   setPreferredSize(preferred);
   setBounds(0, 0, preferred.width, preferred.height);
 }
예제 #2
0
    private void getFileList() {
      myMessage.stateChanged("REMOTEFILELIST");
      URL theURL = null;
      ;
      try {
        theURL = new URL(myProperties.getProperty("BASEURL"));
      } catch (MalformedURLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      ;

      String theRemoteBaseDir = myProperties.getProperty("REMOTEBASEDIR");
      Properties props = System.getProperties();
      props.put("http.proxyHost", myProperties.getProperty("PROXYHOST"));
      props.put("http.proxyPort", myProperties.getProperty("PROXYPORT"));
      String data = "";
      try {
        data =
            URLEncoder.encode("filelocation", "UTF-8")
                + "="
                + URLEncoder.encode(theRemoteBaseDir, "UTF-8");
        data +=
            "&"
                + URLEncoder.encode("fileprocess", "UTF-8")
                + "="
                + URLEncoder.encode("REMOTEFILELIST", "UTF-8");

        URLConnection conn = theURL.openConnection();
        conn.setDoOutput(true);
        OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
        wr.write(data);
        wr.flush();
        myMessage.messageChanged(0, "Get the File List");
        // Get the response
        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line2;
        myFileList = new HashMap<String, List>();
        while (((line2 = rd.readLine()) != null) && !isCancelled()) {
          CSV parser = new CSV('|');
          List theFileList = parser.parse(line2);
          // myFileList.put((String)theFileList.get(1), theFileList);
          for (int i = 0; i < theFileList.size(); i++) {
            if (i == 1) {
              myFileList.put((String) theFileList.get(i), theFileList);
            }
          }
        }
        rd.close();
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
예제 #3
0
 public static void printSystemProperties() {
   java.util.Enumeration e = System.getProperties().propertyNames();
   while (e.hasMoreElements()) {
     String prop = (String) e.nextElement();
     String out = prop;
     out += " = ";
     out += System.getProperty(prop);
     out += "\n";
     System.out.println(out);
   }
 }
 public static void main(String[] args) {
   PropertyTableModel model = new PropertyTableModel(System.getProperties());
   JTable table = new JTable();
   table.setModel(model);
   table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   JScrollPane spane = new JScrollPane(table);
   JFrame frame = new JFrame("System Properties");
   frame.getContentPane().add(spane);
   frame.pack();
   frame.setVisible(true);
   frame.addWindowListener(
       new java.awt.event.WindowAdapter() {
         public void windowClosing(java.awt.event.WindowEvent e) {
           System.exit(0);
         };
       });
 }
 public static double getOSVersion() {
   if (osVersion == null) {
     try {
       String ver = System.getProperties().getProperty("os.version");
       String version = "";
       boolean firstPoint = true;
       for (int i = 0; i < ver.length(); i++) {
         if (ver.charAt(i) == '.') {
           if (firstPoint) {
             version += ver.charAt(i);
           }
           firstPoint = false;
         } else if (Character.isDigit(ver.charAt(i))) {
           version += ver.charAt(i);
         }
       }
       osVersion = new Double(version);
     } catch (Exception ex) {
       osVersion = new Double(1.0);
     }
   }
   return osVersion.doubleValue();
 }
예제 #6
0
 /** Print all system property keys and values. */
 public static void printSystemProperties() {
   Properties p = System.getProperties();
   for (Object key : p.keySet()) System.out.println(key + ": " + p.getProperty(key.toString()));
 }
/**
 * The GUI/View for Huffman coding assignment. Clients communicate with this view by attaching a
 * model and then using the menu choices/options that are part of the GUI. Thus client code that
 * fails to call <code>setModel</code> will almost certainly not work and generate null pointer
 * problems because the view/GUI will not have an associated model.
 *
 * <p>
 *
 * @author Owen Astrachan
 */
public class HuffViewer extends JFrame {

  private static String HUFF_SUFFIX = ".hf";
  private static String UNHUFF_SUFFIX = ".unhf";
  private boolean myFast = true;

  protected JTextArea myOutput;
  protected IHuffProcessor myModel;
  protected String myTitle;
  protected JTextField myMessage;
  protected File myFile;
  private boolean myForce;
  private Thread myFirstFileThread;
  private boolean myFirstReadingDone;

  protected static JFileChooser ourChooser =
      new JFileChooser(System.getProperties().getProperty("user.dir"));

  public HuffViewer(String title) {
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    JPanel panel = (JPanel) getContentPane();
    panel.setLayout(new BorderLayout());
    setTitle(title);
    myTitle = title;
    myForce = false;

    panel.add(makeOutput(), BorderLayout.CENTER);
    panel.add(makeMessage(), BorderLayout.SOUTH);
    makeMenus();

    pack();
    setSize(400, 400);
    setVisible(true);
  }

  /**
   * Associates this view with the given model. The GUI/View will attach itself to the model so that
   * communication between the view and the model as well as <em>vice versa</em> is supported.
   *
   * @param model is the model for this view
   */
  public void setModel(IHuffProcessor model) {
    myModel = model;
    myModel.setViewer(this);
  }

  protected JPanel makeMessage() {
    JPanel p = new JPanel(new BorderLayout());
    myMessage = new JTextField(30);
    p.setBorder(BorderFactory.createTitledBorder("message"));
    p.add(myMessage, BorderLayout.CENTER);
    return p;
  }

  protected JPanel makeOutput() {
    JPanel p = new JPanel(new BorderLayout());
    myOutput = new JTextArea(10, 40);
    p.setBorder(BorderFactory.createTitledBorder("output"));
    p.add(new JScrollPane(myOutput), BorderLayout.CENTER);
    return p;
  }

  protected File doRead() {

    int retval = ourChooser.showOpenDialog(null);
    if (retval != JFileChooser.APPROVE_OPTION) {
      return null;
    }
    showMessage("reading/initializing");

    myFile = ourChooser.getSelectedFile();
    ProgressMonitorInputStream temp = null;
    if (myFast) {
      temp = getMonitorableStream(getFastByteReader(myFile), "counting/reading bits ...");
    } else {
      temp = getMonitorableStream(myFile, "counting/reading bits ...");
    }
    final ProgressMonitorInputStream pmis = temp;
    final ProgressMonitor progress = pmis.getProgressMonitor();
    try {

      myFirstFileThread =
          new Thread() {
            public void run() {
              try {
                myFirstReadingDone = false;
                int saved = myModel.preprocessCompress(pmis);
                HuffViewer.this.showMessage("saved: " + saved + " bits");
                myFirstReadingDone = true;
              } catch (IOException e) {
                HuffViewer.this.showError("reading exception\n " + e);
                // e.printStackTrace();
              }
              if (progress.isCanceled()) {
                HuffViewer.this.showError("reading cancelled");
              }
            }
          };
      myFirstFileThread.start();
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    File ret = myFile;
    myFile = null;
    return ret;
  }

  protected JMenu makeOptionsMenu() {
    JMenu menu = new JMenu("Options");

    JCheckBoxMenuItem force =
        new JCheckBoxMenuItem(
            new AbstractAction("Force Compression") {
              public void actionPerformed(ActionEvent ev) {
                myForce = !myForce;
              }
            });
    JCheckBoxMenuItem fast =
        new JCheckBoxMenuItem(
            new AbstractAction("Slow Reading") {
              public void actionPerformed(ActionEvent ev) {
                myFast = !myFast;
              }
            });
    menu.add(force);
    menu.add(fast);
    return menu;
  }

  protected JMenu makeFileMenu() {
    JMenu fileMenu = new JMenu("File");

    fileMenu.add(
        new AbstractAction("Open/Count") {
          public void actionPerformed(ActionEvent ev) {
            doRead();
          }
        });

    fileMenu.add(
        new AbstractAction("Compress") {
          public void actionPerformed(ActionEvent ev) {
            doSave();
          }
        });

    fileMenu.add(
        new AbstractAction("Uncompress") {
          public void actionPerformed(ActionEvent ev) {
            doDecode();
          }
        });

    fileMenu.add(
        new AbstractAction("Quit") {
          public void actionPerformed(ActionEvent ev) {
            System.exit(0);
          }
        });
    return fileMenu;
  }

  protected void makeMenus() {
    JMenuBar bar = new JMenuBar();
    bar.add(makeFileMenu());
    bar.add(makeOptionsMenu());
    setJMenuBar(bar);
  }

  private void doDecode() {
    File file = null;
    showMessage("uncompressing");
    try {
      int retval = ourChooser.showOpenDialog(null);
      if (retval != JFileChooser.APPROVE_OPTION) {
        return;
      }
      file = ourChooser.getSelectedFile();
      String name = file.getName();
      String uname = name;
      if (name.endsWith(HUFF_SUFFIX)) {
        uname = name.substring(0, name.length() - HUFF_SUFFIX.length()) + UNHUFF_SUFFIX;
      } else {
        uname = name + UNHUFF_SUFFIX;
      }
      String newName = JOptionPane.showInputDialog(this, "Name of uncompressed file", uname);
      if (newName == null) {
        return;
      }
      String path = file.getCanonicalPath();

      int pos = path.lastIndexOf(name);
      newName = path.substring(0, pos) + newName;
      final File newFile = new File(newName);
      ProgressMonitorInputStream temp = null;
      if (myFast) {
        temp = getMonitorableStream(getFastByteReader(file), "uncompressing bits ...");
      } else {
        temp = getMonitorableStream(file, "uncompressing bits...");
      }
      final ProgressMonitorInputStream stream = temp;

      final ProgressMonitor progress = stream.getProgressMonitor();
      final OutputStream out = new FileOutputStream(newFile);
      Thread fileReaderThread =
          new Thread() {
            public void run() {
              try {
                myModel.uncompress(stream, out);
              } catch (IOException e) {

                cleanUp(newFile);
                HuffViewer.this.showError("could not uncompress\n " + e);
                // e.printStackTrace();
              }
              if (progress.isCanceled()) {
                cleanUp(newFile);
                HuffViewer.this.showError("reading cancelled");
              }
            }
          };
      fileReaderThread.start();
    } catch (FileNotFoundException e) {
      showError("could not open " + file.getName());
      e.printStackTrace();
    } catch (IOException e) {
      showError("IOException, uncompression halted from viewer");
      e.printStackTrace();
    }
  }

  private void doSave() {
    myFile = doRead();
    if (myFile == null) {
      return;
    }

    String name = myFile.getName();
    showMessage("compressing " + name);
    String newName =
        JOptionPane.showInputDialog(this, "Name of compressed file", name + HUFF_SUFFIX);
    if (newName == null) {
      return;
    }
    String path = null;
    try {
      path = myFile.getCanonicalPath();
    } catch (IOException e) {
      showError("trouble with file canonicalizing");
      return;
    }
    int pos = path.lastIndexOf(name);
    newName = path.substring(0, pos) + newName;
    final File file = new File(newName);
    try {
      final FileOutputStream out = new FileOutputStream(file);
      ProgressMonitorInputStream temp = null;
      if (myFast) {
        temp = getMonitorableStream(getFastByteReader(myFile), "compressing bits...");
      } else {
        temp = getMonitorableStream(myFile, "compressing bits ...");
      }
      final ProgressMonitorInputStream pmis = temp;
      final ProgressMonitor progress = pmis.getProgressMonitor();
      Thread fileWriterThread =
          new Thread() {
            public void run() {
              try {
                while (!myFirstReadingDone) {
                  try {
                    sleep(100);
                  } catch (InterruptedException e) {
                    // what to do?
                    HuffViewer.this.showError("Trouble in Thread " + e);
                  }
                }
                myModel.compress(pmis, out, myForce);
              } catch (IOException e) {
                HuffViewer.this.showError("compression exception\n " + e);
                cleanUp(file);
                // e.printStackTrace();
              }
              if (progress.isCanceled()) {
                HuffViewer.this.showError("compression cancelled");
                cleanUp(file);
              }
            }
          };
      fileWriterThread.start();
    } catch (FileNotFoundException e) {
      showError("could not open " + file.getName());
      e.printStackTrace();
    }
    myFile = null;
  }

  private void cleanUp(File f) {
    if (!f.delete()) {
      showError("trouble deleting " + f.getName());
    } else {
      // do something here?
    }
  }

  private ProgressMonitorInputStream getMonitorableStream(InputStream stream, String message) {

    final ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(this, message, stream);

    ProgressMonitor progress = pmis.getProgressMonitor();
    progress.setMillisToDecideToPopup(1);
    progress.setMillisToPopup(1);

    return pmis;
  }

  private ProgressMonitorInputStream getMonitorableStream(File file, String message) {
    try {
      FileInputStream stream = new FileInputStream(file);
      if (stream == null) {
        System.out.println("null on " + file.getCanonicalPath());
      }
      final ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(this, message, stream);

      ProgressMonitor progress = pmis.getProgressMonitor();
      progress.setMillisToDecideToPopup(1);
      progress.setMillisToPopup(1);

      return pmis;
    } catch (IOException e) {
      showError("could not open " + file.getName());
      e.printStackTrace();
      return null;
    }
  }

  /** Clear the text area, e.g., for a new message. */
  public void clear() {
    showMessage("");
    myOutput.setText("");
  }

  /**
   * To be called by model/client code to display strings in the GUI. Displays string on a single
   * line. Call multiple times with no interleaved clear to show several strings.
   *
   * @param s is string to be displayed
   */
  public void update(String s) {
    myOutput.append(s + "\n");
  }

  /**
   * Display a text message in the view (e.g., in the small text area at the bottom of the GUI),
   * thus a modeless message the user can ignore.
   *
   * @param s is the message displayed
   */
  public void showMessage(String s) {
    myMessage.setText(s);
  }

  /**
   * Show a modal-dialog indicating an error; the user must dismiss the displayed dialog.
   *
   * @param s is the error-message displayed
   */
  public void showError(String s) {
    JOptionPane.showMessageDialog(this, s, "Huff info", JOptionPane.INFORMATION_MESSAGE);
  }

  private ByteArrayInputStream getFastByteReader(File f) {
    ByteBuffer buffer = null;
    try {
      FileChannel channel = new FileInputStream(f).getChannel();
      buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
      byte[] barray = new byte[buffer.limit()];

      if (barray.length != channel.size()) {
        showError(
            String.format(
                "Reading %s error: lengths differ %d %ld\n",
                f.getName(), barray.length, channel.size()));
      }
      buffer.get(barray);
      return new ByteArrayInputStream(barray);
    } catch (IOException e) {
      e.printStackTrace();
    }
    return null;
  }
}
예제 #8
0
  /** Class for testing this. */
  private static class TestClass implements Cloneable {
    private String _String = "This string is my name.";
    private String[] _StringArray = {"one", "two", "three"};
    private int _int = Integer.MIN_VALUE;
    private Integer _Integer = new Integer(Integer.MAX_VALUE);
    private double _double = Double.MIN_VALUE;
    private Double _Double = new Double(Double.MAX_VALUE);
    private Properties _Properties = System.getProperties();
    private File _File = new File("/");
    private Object _Object = new Font("Monospaced", Font.PLAIN, 12);
    private JButton _button = new JButton("I'm a button!");

    public void setName(String string) {
      _String = string;
    }

    public String getName() {
      return _String;
    }

    public void setStringArray(String[] array) {
      _StringArray = array;
    }

    public String[] getStringArray() {
      return _StringArray;
    }

    public void setInt(int val) {
      _int = val;
    }

    public int getInt() {
      return _int;
    }

    public void setInteger(Integer val) {
      _Integer = val;
    }

    public Integer getInteger() {
      return _Integer;
    }

    public void setDoub(double val) {
      _double = val;
    }

    public double getDoub() {
      return _double;
    }

    public void setDouble(Double val) {
      _Double = val;
    }

    public Double getDouble() {
      return _Double;
    }

    public void setProperties(Properties props) {
      _Properties = props;
    }

    public Properties getProperties() {
      return _Properties;
    }

    public void setFile(File f) {
      _File = f;
    }

    public File getFile() {
      return _File;
    }

    public void setButton(JButton button) {
      _button = button;
    }

    public JButton getButton() {
      return _button;
    }

    public void setObject(Object o) {
      _Object = o;
    }

    public Object getObject() {
      return _Object;
    }

    public Object clone() {
      try {
        return super.clone();
      } catch (CloneNotSupportedException ex) {
        return null;
      }
    }
  }
예제 #9
0
  /**
   * Starts the viewe application.
   *
   * @param contentFile URI of a file which will be loaded at runtime, can be null.
   * @param contentURL URL of a file which will be loaded at runtime, can be null.
   * @param contentProperties URI of a properties file which will be used in place of the default
   *     path
   * @param messageBundle messageBundle to pull strings from
   */
  private static void run(
      String contentFile,
      String contentURL,
      String contentProperties,
      ResourceBundle messageBundle) {

    // initiate the properties manager.
    Properties sysProps = System.getProperties();
    propertiesManager = new PropertiesManager(sysProps, contentProperties, messageBundle);

    // initiate font Cache manager, reads system font data and stores summary
    // information in a properties file.  If new font are added to the OS
    // then the properties file can be deleted to initiate a re-read of the
    // font data.
    new FontPropertiesManager(propertiesManager, sysProps, messageBundle);

    // input new System properties
    System.setProperties(sysProps);

    // set look & feel
    setupLookAndFeel(messageBundle);

    ViewModel.setDefaultFilePath(propertiesManager.getDefaultFilePath());
    ViewModel.setDefaultURL(propertiesManager.getDefaultURL());

    // application instance
    windowManager = new WindowManager(propertiesManager, messageBundle);
    if (contentFile != null && contentFile.length() > 0) {
      windowManager.newWindow(contentFile);
      ViewModel.setDefaultFilePath(contentFile);
    }

    // load a url if specified
    if (contentURL != null && contentURL.length() > 0) {
      URLAccess urlAccess = URLAccess.doURLAccess(contentURL);
      urlAccess.closeConnection();
      if (urlAccess.errorMessage != null) {

        // setup a patterned message
        Object[] messageArguments = {urlAccess.errorMessage, urlAccess.urlLocation};
        MessageFormat formatter =
            new MessageFormat(messageBundle.getString("viewer.launcher.URLError.dialog.message"));

        JOptionPane.showMessageDialog(
            null,
            formatter.format(messageArguments),
            messageBundle.getString("viewer.launcher.URLError.dialog.title"),
            JOptionPane.INFORMATION_MESSAGE);
      } else {
        windowManager.newWindow(urlAccess.url);
      }
      ViewModel.setDefaultURL(urlAccess.urlLocation);
      urlAccess.dispose();
    }

    // Start an empy viewer if there was no command line parameters
    if (((contentFile == null || contentFile.length() == 0)
            && (contentURL == null || contentURL.length() == 0))
        || (windowManager.getNumberOfWindows() == 0)) {
      windowManager.newWindow("");
    }
  }
    public void init(GLAutoDrawable glAutoDrawable) {
      StringBuilder sb = new StringBuilder();

      sb.append(gov.nasa.worldwind.Version.getVersion() + "\n");

      sb.append("\nSystem Properties\n");
      sb.append("Processors: " + Runtime.getRuntime().availableProcessors() + "\n");
      sb.append("Free memory: " + Runtime.getRuntime().freeMemory() + " bytes\n");
      sb.append("Max memory: " + Runtime.getRuntime().maxMemory() + " bytes\n");
      sb.append("Total memory: " + Runtime.getRuntime().totalMemory() + " bytes\n");

      for (Map.Entry prop : System.getProperties().entrySet()) {
        sb.append(prop.getKey() + " = " + prop.getValue() + "\n");
      }

      GL gl = glAutoDrawable.getGL();

      sb.append("\nOpenGL Values\n");

      String oglVersion = gl.glGetString(GL.GL_VERSION);
      sb.append("OpenGL version: " + oglVersion + "\n");

      String oglVendor = gl.glGetString(GL.GL_VENDOR);
      sb.append("OpenGL vendor: " + oglVendor + "\n");

      String oglRenderer = gl.glGetString(GL.GL_RENDERER);
      sb.append("OpenGL renderer: " + oglRenderer + "\n");

      int[] intVals = new int[2];
      for (Attr attr : attrs) {
        sb.append(attr.name).append(": ");

        if (attr.attr instanceof Integer) {
          gl.glGetIntegerv((Integer) attr.attr, intVals, 0);
          sb.append(intVals[0]).append(intVals[1] > 0 ? ", " + intVals[1] : "");
        }

        sb.append("\n");
      }

      String extensionString = gl.glGetString(GL.GL_EXTENSIONS);
      String[] extensions = extensionString.split(" ");
      sb.append("Extensions\n");
      for (String ext : extensions) {
        sb.append("    " + ext + "\n");
      }

      sb.append("\nJOGL Values\n");
      String pkgName = "javax.media.opengl";
      try {
        getClass().getClassLoader().loadClass(pkgName + ".GL");

        Package p = Package.getPackage(pkgName);
        if (p == null) {
          sb.append("WARNING: Package.getPackage(" + pkgName + ") is null\n");
        } else {
          sb.append(p + "\n");
          sb.append("Specification Title = " + p.getSpecificationTitle() + "\n");
          sb.append("Specification Vendor = " + p.getSpecificationVendor() + "\n");
          sb.append("Specification Version = " + p.getSpecificationVersion() + "\n");
          sb.append("Implementation Vendor = " + p.getImplementationVendor() + "\n");
          sb.append("Implementation Version = " + p.getImplementationVersion() + "\n");
        }
      } catch (ClassNotFoundException e) {
        sb.append("Unable to load " + pkgName + "\n");
      }

      this.outputArea.setText(sb.toString());
    }
  public static void main(String arg[]) {

    System.getProperties().put("sun.java2d.noddraw", "true");

    // (ulrivo): read all arguments from the command line
    String lowerArg;
    boolean autoConnect = false;

    for (int i = 0; i < arg.length; i++) {
      lowerArg = arg[i].toLowerCase();

      i++;

      bMustExit = true;

      if (lowerArg.equals("-driver")) {
        defDriver = arg[i];
        autoConnect = true;
      } else if (lowerArg.equals("-url")) {
        defURL = arg[i];
        autoConnect = true;
      } else if (lowerArg.equals("-user")) {
        defUser = arg[i];
        autoConnect = true;
      } else if (lowerArg.equals("-password")) {
        defPassword = arg[i];
        autoConnect = true;
      } else if (lowerArg.equals("-dir")) {
        defDirectory = arg[i];
      } else if (lowerArg.equals("-script")) {
        defScript = arg[i];
      } else if (lowerArg.equals("-noexit")) {
        bMustExit = false;

        i--;
      } else {
        showUsage();

        return;
      }
    }

    DatabaseManagerSwing m = new DatabaseManagerSwing();

    m.main();

    Connection c = null;

    try {
      if (autoConnect) {
        c = ConnectionDialogSwing.createConnection(defDriver, defURL, defUser, defPassword);
      } else {
        c = ConnectionDialogSwing.createConnection(m.fMain, "Connect");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (c == null) {
      return;
    }

    m.connect(c);
  }
예제 #12
0
  public ProcessFrame(Properties theProperties) {
    super(new BorderLayout());
    // myFile = theFile;
    myProperties = theProperties;
    Properties props = System.getProperties();
    props.put("http.proxyHost", myProperties.getProperty("PROXYHOST"));
    props.put("http.proxyPort", myProperties.getProperty("PROXYPORT"));

    // Create the demo's UI.
    StartButton = new JButton("Start");
    StartButton.setActionCommand("start");
    StartButton.addActionListener(this);
    cancelButton = new JButton("Cancel");
    cancelButton.setActionCommand("cancel");
    cancelButton.addActionListener(this);
    cancelButton.setEnabled(false);

    myDownloadOptions = new JComboBox(myDownloadOptionsStr);

    progressBar = new JProgressBar(0, 100);
    progressBar.setValue(0);
    progressBar.setStringPainted(true);
    progressBar2 = new JProgressBar(0, 100);
    progressBar2.setValue(0);
    progressBar2.setStringPainted(true);
    progressBar3 = new JProgressBar(0, 100);
    progressBar4 = new JProgressBar(0, 100);
    progressBar5 = new JProgressBar(0, 100);
    progressBar3.setValue(0);
    progressBar3.setStringPainted(true);
    progressBar4.setValue(0);
    progressBar4.setStringPainted(true);
    progressBar5.setValue(0);
    progressBar5.setStringPainted(true);

    taskOutput = new JTextArea(5, 20);

    final JPopupMenu taskPopupMenu = new JPopupMenu();
    JMenuItem clearMenuItem = new JMenuItem("Clear");
    clearMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            if (actionEvent.getActionCommand().equals("Clear")) {
              taskOutput.setText("");
            }
          }
        });
    taskPopupMenu.add(clearMenuItem);
    taskOutput.setMargin(new Insets(5, 5, 5, 5));
    taskOutput.setEditable(false);
    taskOutput.addMouseListener(
        new MouseAdapter() {
          private void showIfPopupTrigger(MouseEvent mouseEvent) {
            if (mouseEvent.isPopupTrigger()) {
              taskPopupMenu.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
            }
          }

          public void mousePressed(MouseEvent mouseEvent) {
            showIfPopupTrigger(mouseEvent);
          }

          public void mouseReleased(MouseEvent mouseEvent) {
            showIfPopupTrigger(mouseEvent);
          }
        });

    JPanel panel = new JPanel();
    JPanel panel2 = new JPanel();
    panel.setLayout(new GridBagLayout());
    panel2.setLayout(new GridBagLayout());
    panel.add(
        progressBar4,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(11, 11, 0, 0),
            0,
            0));
    panel.add(
        new JLabel("TOTAL"),
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 11, 0, 0),
            0,
            0));
    panel.add(
        progressBar,
        new GridBagConstraints(
            2,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(11, 11, 0, 0),
            0,
            0));
    panel.add(
        new JLabel("REMOTE DOWNLOAD"),
        new GridBagConstraints(
            1,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 11, 0, 0),
            0,
            0));
    panel.add(
        progressBar2,
        new GridBagConstraints(
            2,
            3,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(11, 11, 0, 0),
            0,
            0));
    panel.add(
        new JLabel("REMOTE SPLIT"),
        new GridBagConstraints(
            1,
            3,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 11, 0, 0),
            0,
            0));
    panel.add(
        progressBar3,
        new GridBagConstraints(
            2,
            4,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(11, 11, 0, 0),
            0,
            0));
    panel.add(
        new JLabel("LOCAL DOWNLOAD"),
        new GridBagConstraints(
            1,
            4,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 11, 0, 0),
            0,
            0));
    panel.add(
        progressBar5,
        new GridBagConstraints(
            2,
            5,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(11, 11, 0, 0),
            0,
            0));
    panel.add(
        new JLabel("LOCAL JOIN"),
        new GridBagConstraints(
            1,
            5,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 11, 0, 0),
            0,
            0));
    panel2.add(
        myDownloadOptions,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(4, 13, 4, 0),
            0,
            0));
    panel2.add(
        StartButton,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(4, 13, 4, 0),
            0,
            0));
    panel2.add(
        cancelButton,
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(4, 13, 4, 0),
            0,
            0));

    add(panel, BorderLayout.PAGE_START);
    add(panel2, BorderLayout.CENTER);
    add(new JScrollPane(taskOutput), BorderLayout.PAGE_END);

    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
  }
예제 #13
0
  ///////////////////////////////////
  // member functions
  //////////////////////////////////
  protected final void initForm() {
    thisPanel = new JPanel();
    thisPanel.setName("Import Range Data");
    thisPanel.setLayout(new java.awt.BorderLayout());

    _thePanel.add(thisPanel);

    _theWarning = new JTextArea();
    _theWarning.setEditable(false);
    String theMessage = "Warning, data imported through this panel has";
    theMessage += " speed and course calculated as over the ground.";
    theMessage += System.getProperties().getProperty("line.separator");
    theMessage += "Debrief recognises PC Argos (RAO) and PMRF (PRN) files.";
    theMessage += System.getProperties().getProperty("line.separator");
    theMessage += "See Debrief Help File for file format and details.";

    _theWarning.setText(theMessage);
    _theWarning.setLineWrap(true);
    _theWarning.setBorder(BorderFactory.createLoweredBevelBorder());
    _theWarning.setWrapStyleWord(true);
    thisPanel.add("North", _theWarning);
    ////////////////////////////////////////////
    // auto generated stuff
    ////////////////////////////////////////////

    ButtonPanel = new javax.swing.JPanel();
    importBtn = new javax.swing.JButton();
    closeBtn = new javax.swing.JButton();
    PropertiesList = new javax.swing.JPanel();
    FilenamePanel = new javax.swing.JPanel();
    jLabel3 = new javax.swing.JLabel();
    FilenameLabel = new javax.swing.JLabel();
    selectFileBtn = new javax.swing.JButton();
    FrequencyPanel = new javax.swing.JPanel();
    FrequencyLabel = new javax.swing.JLabel();
    FrequencyCombo = new TimeFrequencyCombo();
    OriginPanel = new javax.swing.JPanel();
    jLabel7 = new javax.swing.JLabel();
    OriginLabel = new javax.swing.JLabel();
    selectOriginBtn = new javax.swing.JButton();
    DTGPanel = new javax.swing.JPanel();
    jLabel9 = new javax.swing.JLabel();
    _theDate = new javax.swing.JTextField("2001/01/30");

    /////////////////////////////////////////////////
    // button panel first
    //////////////////////////////////////////////////

    importBtn.setText("Import");
    ButtonPanel.add(importBtn);
    closeBtn.setText("Close");
    ButtonPanel.add(closeBtn);
    thisPanel.add(ButtonPanel, java.awt.BorderLayout.SOUTH);
    closeBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            doClose();
          }
        });
    importBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            doImport();
          }
        });

    ///////////////////////////////////////////////////
    // now the properties panel
    ///////////////////////////////////////////////////

    PropertiesList.setLayout(new java.awt.GridLayout(0, 1));

    jLabel3.setText("Filename:");
    FilenamePanel.add(jLabel3);
    FilenameLabel.setText("    blank    ");
    FilenamePanel.add(FilenameLabel);
    selectFileBtn.setPreferredSize(new java.awt.Dimension(33, 27));
    selectFileBtn.setToolTipText("Select file");
    selectFileBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    selectFileBtn.setText("...");
    selectFileBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            doEditFilename();
          }
        });
    FilenamePanel.add(selectFileBtn);
    PropertiesList.add(FilenamePanel);

    FrequencyLabel.setText("Frequency:");
    FrequencyPanel.add(FrequencyLabel);
    FrequencyCombo.setPreferredSize(new java.awt.Dimension(100, 25));
    FrequencyPanel.add(FrequencyCombo);
    PropertiesList.add(FrequencyPanel);

    jLabel7.setText("Origin:");
    OriginPanel.add(jLabel7);
    OriginLabel.setText("    blank    ");
    OriginPanel.add(OriginLabel);
    selectOriginBtn.setPreferredSize(new java.awt.Dimension(33, 27));
    selectOriginBtn.setToolTipText("Select file");
    selectOriginBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    selectOriginBtn.setText("...");
    selectOriginBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            editOrigin();
          }
        });
    OriginPanel.add(selectOriginBtn);
    PropertiesList.add(OriginPanel);

    //////////////////////////////////////////////////////
    // DTG
    /////////////////////////////////////////////////////

    jLabel9.setText("DTG (yyyy/mm/dd):");
    _theDate.setText("2001/01/30");
    _theDate.addFocusListener(
        new FocusAdapter() {
          public void focusLost(final FocusEvent e) {
            checkDTG();
          }
        });
    DTGPanel.add(jLabel9);
    DTGPanel.add(_theDate);
    PropertiesList.add(DTGPanel);

    final JPanel jp = new JPanel();
    jp.setLayout(new FlowLayout());
    jp.add(PropertiesList);

    thisPanel.add(jp, java.awt.BorderLayout.CENTER);
  }