Search in sources :

Example 1 with FileField

use of com.sk89q.mclauncher.util.FileField in project SKMCLauncher by SKCraft.

the class UpdateBuilderGUI method addComponents.

private void addComponents() {
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    panel.setLayout(new GridBagLayout());
    GridBagConstraints fieldConstraints = new GridBagConstraints();
    fieldConstraints.fill = GridBagConstraints.HORIZONTAL;
    fieldConstraints.weightx = 1.0;
    fieldConstraints.gridwidth = GridBagConstraints.REMAINDER;
    fieldConstraints.insets = new Insets(2, 1, 2, 1);
    GridBagConstraints labelConstraints = (GridBagConstraints) fieldConstraints.clone();
    labelConstraints.weightx = 0.0;
    labelConstraints.gridwidth = 1;
    labelConstraints.insets = new Insets(1, 1, 1, 10);
    GridBagConstraints fullFieldConstraints = (GridBagConstraints) fieldConstraints.clone();
    fullFieldConstraints.insets = new Insets(5, 2, 1, 2);
    final JLabel buildConfigLabel = new JLabel("Build configuration:");
    panel.add(buildConfigLabel, labelConstraints);
    configField = new FileField("Select builder configuration", "Builder configuration");
    buildConfigLabel.setLabelFor(configField);
    panel.add(configField, fieldConstraints);
    configField.setVisible(false);
    buildConfigLabel.setVisible(false);
    final JButton useConfigBtn = new JButton("Use Builder Configuration");
    final JPanel useConfigPanel = new JPanel();
    useConfigPanel.add(new JLabel("Have a configuration file? "));
    useConfigPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
    useConfigPanel.add(useConfigBtn);
    useConfigBtn.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            buildConfigLabel.setVisible(true);
            configField.setVisible(true);
            useConfigPanel.setVisible(false);
        }
    });
    panel.add(useConfigPanel, fullFieldConstraints);
    panel.add(Box.createVerticalStrut(3), fullFieldConstraints);
    JLabel label;
    label = new JLabel("Package ID:");
    panel.add(label, labelConstraints);
    idText = new JTextField();
    idText.setText("my-mod-pack");
    label.setLabelFor(idText);
    panel.add(idText, fieldConstraints);
    label = new JLabel("Package name:");
    panel.add(label, labelConstraints);
    nameText = new JTextField();
    nameText.setText("My Mod Pack");
    label.setLabelFor(nameText);
    panel.add(nameText, fieldConstraints);
    label = new JLabel("Version:");
    panel.add(label, labelConstraints);
    versionText = new JTextField();
    versionText.setText(new Date().toString());
    label.setLabelFor(versionText);
    panel.add(versionText, fieldConstraints);
    label = new JLabel("Source directory:");
    panel.add(label, labelConstraints);
    sourceField = new DirectoryField();
    label.setLabelFor(sourceField);
    panel.add(sourceField, fieldConstraints);
    panel.add(Box.createGlue(), labelConstraints);
    includeLibsCheck = new JCheckBox("Add Mojang's LWJGL into package");
    includeLibsCheck.setBorder(null);
    includeLibsCheck.setSelected(true);
    panel.add(includeLibsCheck, fieldConstraints);
    panel.add(Box.createGlue(), labelConstraints);
    zipConfigsCheck = new JCheckBox("Put files from config/ into one .zip");
    zipConfigsCheck.setBorder(null);
    zipConfigsCheck.setSelected(true);
    panel.add(zipConfigsCheck, fieldConstraints);
    label = new JLabel("Output directory:");
    panel.add(label, labelConstraints);
    outputField = new DirectoryField();
    label.setLabelFor(outputField);
    panel.add(outputField, fieldConstraints);
    panel.add(Box.createGlue(), labelConstraints);
    cleanCheck = new JCheckBox("Delete everything in the output directory first");
    cleanCheck.setBorder(null);
    cleanCheck.setSelected(true);
    panel.add(cleanCheck, fieldConstraints);
    label = new JLabel("Package filename:");
    panel.add(label, labelConstraints);
    packageText = new JTextField();
    packageText.setText("package.xml");
    label.setLabelFor(packageText);
    panel.add(packageText, fieldConstraints);
    label = new JLabel("Update filename:");
    panel.add(label, labelConstraints);
    updateText = new JTextField();
    updateText.setText("update.xml");
    label.setLabelFor(updateText);
    panel.add(updateText, fieldConstraints);
    add(panel, BorderLayout.NORTH);
    add(messageLog, BorderLayout.CENTER);
    Box buttonsPanel = Box.createHorizontalBox();
    buttonsPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    LinkButton helpButton = new LinkButton("Help! What do I do?");
    buildButton = new JButton("Build Package...");
    JButton closeButton = new JButton("Close");
    buttonsPanel.add(helpButton);
    buttonsPanel.add(Box.createHorizontalGlue());
    buttonsPanel.add(buildButton);
    buttonsPanel.add(Box.createHorizontalStrut(6));
    buttonsPanel.add(closeButton);
    add(buttonsPanel, BorderLayout.SOUTH);
    helpButton.addActionListener(ActionListeners.openURL(this, "https://github.com/sk89q/skmclauncher/blob/master/README.md"));
    buildButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            build();
        }
    });
    closeButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            close();
        }
    });
    SwingHelper.focusLater(idText);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) FileField(com.sk89q.mclauncher.util.FileField) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) JTextField(javax.swing.JTextField) Date(java.util.Date) LinkButton(com.sk89q.mclauncher.util.LinkButton) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) DirectoryField(com.sk89q.mclauncher.util.DirectoryField)

Aggregations

DirectoryField (com.sk89q.mclauncher.util.DirectoryField)1 FileField (com.sk89q.mclauncher.util.FileField)1 LinkButton (com.sk89q.mclauncher.util.LinkButton)1 FlowLayout (java.awt.FlowLayout)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 Date (java.util.Date)1 Box (javax.swing.Box)1 JButton (javax.swing.JButton)1 JCheckBox (javax.swing.JCheckBox)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JTextField (javax.swing.JTextField)1