Search in sources :

Example 1 with DirectoryField

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

the class ConfigurationDialog method buildConfigurationPanel.

/**
 * Build the main configuration tab.
 *
 * @return panel
 */
private JPanel buildConfigurationPanel() {
    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);
    if (configuration != null && configuration.isBuiltIn()) {
        panel.add(new JLabel("This is a built-in configuration and editing is restricted."), fullFieldConstraints);
        panel.add(Box.createVerticalStrut(10), fullFieldConstraints);
    }
    JLabel nameLabel = new JLabel("Name:");
    panel.add(nameLabel, labelConstraints);
    nameText = new JTextField(30);
    nameLabel.setLabelFor(nameText);
    panel.add(nameText, fieldConstraints);
    JLabel pathLabel = new JLabel("Path:");
    panel.add(pathLabel, labelConstraints);
    customPathCheck = new JCheckBox("Use a custom path");
    customPathCheck.setBorder(null);
    panel.add(customPathCheck, fieldConstraints);
    panel.add(Box.createGlue(), labelConstraints);
    pathField = new DirectoryField();
    pathField.getTextField().setMaximumSize(pathField.getTextField().getPreferredSize());
    nameLabel.setLabelFor(pathField.getTextField());
    panel.add(pathField, fieldConstraints);
    panel.add(Box.createVerticalStrut(10), fullFieldConstraints);
    JLabel urlLabel = new JLabel("Update URL:");
    panel.add(urlLabel, labelConstraints);
    customUpdateCheck = new JCheckBox("Use a custom update URL");
    customUpdateCheck.setBorder(null);
    panel.add(customUpdateCheck, fieldConstraints);
    panel.add(Box.createGlue(), labelConstraints);
    urlText = new JTextField("http://");
    urlLabel.setLabelFor(urlText);
    panel.add(urlText, fieldConstraints);
    pathField.setEnabled(false);
    customPathCheck.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            pathField.setEnabled(((JCheckBox) e.getSource()).isSelected());
        }
    });
    urlText.setEnabled(false);
    customUpdateCheck.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            urlText.setEnabled(((JCheckBox) e.getSource()).isSelected());
        }
    });
    JPanel container = new JPanel();
    container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
    container.add(panel);
    container.add(new Box.Filler(new Dimension(0, 0), new Dimension(0, 10000), new Dimension(0, 10000)));
    SwingHelper.removeOpaqueness(container);
    return container;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) ChangeEvent(javax.swing.event.ChangeEvent) DirectoryField(com.sk89q.mclauncher.util.DirectoryField) ChangeListener(javax.swing.event.ChangeListener)

Example 2 with DirectoryField

use of com.sk89q.mclauncher.util.DirectoryField 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)2 GridBagConstraints (java.awt.GridBagConstraints)2 GridBagLayout (java.awt.GridBagLayout)2 Insets (java.awt.Insets)2 Box (javax.swing.Box)2 JCheckBox (javax.swing.JCheckBox)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 JTextField (javax.swing.JTextField)2 FileField (com.sk89q.mclauncher.util.FileField)1 LinkButton (com.sk89q.mclauncher.util.LinkButton)1 Dimension (java.awt.Dimension)1 FlowLayout (java.awt.FlowLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 Date (java.util.Date)1 BoxLayout (javax.swing.BoxLayout)1 JButton (javax.swing.JButton)1 ChangeEvent (javax.swing.event.ChangeEvent)1 ChangeListener (javax.swing.event.ChangeListener)1