Example usage for javax.swing JList JList

List of usage examples for javax.swing JList JList

Introduction

In this page you can find the example usage for javax.swing JList JList.

Prototype

public JList(final Vector<? extends E> listData) 

Source Link

Document

Constructs a JList that displays the elements in the specified Vector.

Usage

From source file:md.mclama.com.ModManager.java

/**
 * Create the frame./*w  ww  .  j av a  2  s.  c  om*/
 */

@SuppressWarnings("serial")
public ModManager() throws MalformedURLException {
    setResizable(false);
    setTitle("McLauncher " + McVersion);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 700, 400);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setBounds(0, 0, 694, 372);
    contentPane.add(tabbedPane);

    profileListMdl = new DefaultListModel<String>();
    ModListModel = new DefaultListModel<String>();
    listModel = new DefaultListModel<String>();
    getCurrentMods();

    panelLauncher = new JPanel();
    tabbedPane.addTab("Launcher", null, panelLauncher, null);
    panelLauncher.setLayout(null);
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(556, 36, 132, 248);
    panelLauncher.add(scrollPane);
    profileList = new JList<String>(profileListMdl);
    profileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    scrollPane.setViewportView(profileList);

    btnNewProfile = new JButton("New");
    btnNewProfile.setFont(new Font("SansSerif", Font.PLAIN, 12));
    btnNewProfile.setBounds(479, 4, 76, 20);
    panelLauncher.add(btnNewProfile);
    btnNewProfile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            newProfile(txtProfile.getText());
        }
    });
    btnNewProfile.setToolTipText("Click to create a new profile.");

    JButton btnRenameProfile = new JButton("Rename");
    btnRenameProfile.setBounds(479, 25, 76, 20);
    panelLauncher.add(btnRenameProfile);
    btnRenameProfile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            renameProfile();
        }
    });
    btnRenameProfile.setToolTipText("Click to rename the selected profile");

    JButton btnDelProfile = new JButton("Delete");
    btnDelProfile.setBounds(479, 50, 76, 20);
    panelLauncher.add(btnDelProfile);
    btnDelProfile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            deleteProfile();
        }
    });
    btnDelProfile.setToolTipText("Click to delete the selected profile.");

    JButton btnLaunch = new JButton("Launch");
    btnLaunch.setBounds(605, 319, 89, 23);
    panelLauncher.add(btnLaunch);
    btnLaunch.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (selProfile != null) {
                LaunchFactorioWithSelectedMods(false); //dont ignore
            }
        }
    });
    btnLaunch.setToolTipText("Click to launch factorio with the selected mod profile.");

    lblAvailableMods = new JLabel("Available Mods");
    lblAvailableMods.setBounds(4, 155, 144, 14);
    panelLauncher.add(lblAvailableMods);
    lblAvailableMods.setFont(new Font("SansSerif", Font.PLAIN, 10));

    lblAvailableMods.setText("Available Mods: " + -1);

    txtGamePath = new JTextField();
    txtGamePath.setBounds(4, 5, 211, 23);
    panelLauncher.add(txtGamePath);
    txtGamePath.setToolTipText("Select tha path to your game!");
    txtGamePath.setFont(new Font("Tahoma", Font.PLAIN, 8));
    txtGamePath.setText("Game Path");
    txtGamePath.setColumns(10);

    JButton btnFind = new JButton("find");
    btnFind.setBounds(227, 3, 32, 23);
    panelLauncher.add(btnFind);

    txtProfile = new JTextField();
    txtProfile.setBounds(556, 2, 132, 22);
    panelLauncher.add(txtProfile);
    txtProfile.setToolTipText("The name of NEW or RENAME profiles");
    txtProfile.setText("Profile1");
    txtProfile.setColumns(10);

    lblModsEnabled = new JLabel("Mods Enabled: -1");
    lblModsEnabled.setBounds(335, 155, 95, 16);
    panelLauncher.add(lblModsEnabled);
    lblModsEnabled.setFont(new Font("SansSerif", Font.PLAIN, 10));

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBounds(0, 167, 211, 165);
    panelLauncher.add(scrollPane_1);
    modsList = new JList<String>(listModel);
    modsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    modsList.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            String modName = util.getModVersion(modsList.getSelectedValue());
            lblModVersion.setText("Mod Version: " + modName);
            checkDependency(modsList);
            if (modName.contains(".zip")) {
                new File(System.getProperty("java.io.tmpdir") + modName.replace(".zip", "")).delete();
            }
            if (System.currentTimeMillis() - lastClickTime <= 300) { //Double click
                addMod();
            }
            lastClickTime = System.currentTimeMillis();
        }
    });
    scrollPane_1.setViewportView(modsList);
    modsList.setFont(new Font("Tahoma", Font.PLAIN, 9));

    JScrollPane scrollPane_2 = new JScrollPane();
    scrollPane_2.setBounds(333, 167, 211, 165);
    panelLauncher.add(scrollPane_2);
    enabledModsList = new JList<String>(ModListModel);
    enabledModsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    enabledModsList.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            lblModVersion.setText("Mod Version: " + util.getModVersion(enabledModsList.getSelectedValue()));
            checkDependency(enabledModsList);
            if (System.currentTimeMillis() - lastClickTime <= 300) { //Double click
                removeMod();
            }
            lastClickTime = System.currentTimeMillis();
        }
    });
    enabledModsList.setFont(new Font("SansSerif", Font.PLAIN, 10));
    scrollPane_2.setViewportView(enabledModsList);

    JButton btnEnable = new JButton("Enable");
    btnEnable.setBounds(223, 200, 90, 28);
    panelLauncher.add(btnEnable);
    btnEnable.setToolTipText("Add mod -->");

    JButton btnDisable = new JButton("Disable");
    btnDisable.setBounds(223, 240, 90, 28);
    panelLauncher.add(btnDisable);
    btnDisable.setToolTipText("Disable mod ");

    JLabel lblModsAvailable = new JLabel("Mods available");
    lblModsAvailable.setBounds(4, 329, 89, 14);
    panelLauncher.add(lblModsAvailable);
    lblModsAvailable.setFont(new Font("SansSerif", Font.PLAIN, 10));

    JLabel lblEnabledMods = new JLabel("Enabled Mods");
    lblEnabledMods.setBounds(337, 329, 89, 16);
    panelLauncher.add(lblEnabledMods);
    lblEnabledMods.setFont(new Font("SansSerif", Font.PLAIN, 10));

    lblModVersion = new JLabel("Mod Version: (select a mod first)");
    lblModVersion.setBounds(4, 117, 183, 14);
    panelLauncher.add(lblModVersion);
    lblModVersion.setFont(new Font("SansSerif", Font.PLAIN, 10));

    lblRequiredMods = new JLabel("Required Mods: " + reqModsStr);
    lblRequiredMods.setBounds(6, 143, 538, 14);
    panelLauncher.add(lblRequiredMods);
    lblRequiredMods.setHorizontalAlignment(SwingConstants.RIGHT);
    lblRequiredMods.setFont(new Font("SansSerif", Font.PLAIN, 10));

    JButton btnNewButton = new JButton("TEST");
    btnNewButton.setVisible(testBtnEnabled);
    btnNewButton.setEnabled(testBtnEnabled);
    btnNewButton.setBounds(338, 61, 90, 28);
    panelLauncher.add(btnNewButton);
    btnUpdate.setBounds(218, 322, 103, 20);
    panelLauncher.add(btnUpdate);

    btnUpdate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            util.updateLauncher();
        }
    });
    btnUpdate.setVisible(false);
    btnUpdate.setFont(new Font("SansSerif", Font.PLAIN, 9));

    lblModRequires = new JLabel("Mod Requires: (Select a mod first)");
    lblModRequires.setBounds(4, 127, 317, 16);
    panelLauncher.add(lblModRequires);

    btnLaunchIgnore = new JButton("Launch + ignore");
    btnLaunchIgnore.setToolTipText("Ignore any errors that McLauncher may not correctly account for.");
    btnLaunchIgnore.setFont(new Font("SansSerif", Font.PLAIN, 11));
    btnLaunchIgnore.setBounds(556, 284, 133, 23);
    panelLauncher.add(btnLaunchIgnore);

    JButton btnConsole = new JButton("Console");
    btnConsole.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            boolean changeto = !con.isVisible();
            con.setVisible(changeto);
            con.updateConsole();
        }
    });
    btnConsole.setBounds(335, 0, 90, 28);
    panelLauncher.add(btnConsole);

    JPanel panelDownloadMods = new JPanel();
    tabbedPane.addTab("Download Mods", null, panelDownloadMods, null);
    panelDownloadMods.setLayout(null);

    scrollPane_3 = new JScrollPane();
    scrollPane_3.setBounds(0, 0, 397, 303);
    panelDownloadMods.add(scrollPane_3);

    dlModel = new DefaultTableModel(new Object[][] {},
            new String[] { "Mod Name", "Author", "Version", "Tags" }) {
        Class[] columnTypes = new Class[] { String.class, String.class, String.class, Object.class };

        public Class getColumnClass(int columnIndex) {
            return columnTypes[columnIndex];
        }

        boolean[] columnEditables = new boolean[] { false, false, false, false };

        public boolean isCellEditable(int row, int column) {
            return columnEditables[column];
        };
    };

    tSorter = new TableRowSorter<DefaultTableModel>(dlModel);
    tableDownloads = new JTable();
    tableDownloads.setRowSorter(tSorter);
    tableDownloads.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            trow = tableDownloads.getSelectedRow();
            trow = tableDownloads.getRowSorter().convertRowIndexToModel(trow);
            getDlModData();
            canDownloadMod = true;
        }
    });
    tableDownloads.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            trow = tableDownloads.getSelectedRow();
            trow = tableDownloads.getRowSorter().convertRowIndexToModel(trow);
            getDlModData();
            canDownloadMod = true;
        }
    });
    tableDownloads.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    tableDownloads.setShowVerticalLines(true);
    tableDownloads.setShowHorizontalLines(true);
    tableDownloads.setModel(dlModel);
    tableDownloads.getColumnModel().getColumn(0).setPreferredWidth(218);
    tableDownloads.getColumnModel().getColumn(1).setPreferredWidth(97);
    tableDownloads.getColumnModel().getColumn(2).setPreferredWidth(77);
    scrollPane_3.setViewportView(tableDownloads);

    btnDownload = new JButton("Download");
    btnDownload.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (canDownloadMod && !CurrentlyDownloading) {
                String dlUrl = getModDownloadUrl();
                try {
                    if (dlUrl.equals("") || dlUrl.equals(" ") || dlUrl == null) {
                        con.log("Log", "No download link for mod, got... '" + dlUrl + "'");
                    } else {
                        CurrentlyDownloading = true;
                        CurrentDownload = new Download(new URL(dlUrl), McLauncher);
                    }
                } catch (MalformedURLException e1) {
                    con.log("Log", "Failed to download mod... No download URL?");
                }
            }
        }
    });
    btnDownload.setBounds(307, 308, 90, 28);
    panelDownloadMods.add(btnDownload);

    btnGotoMod = new JButton("Mod Page");
    btnGotoMod.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            util.openWebpage(modPageUrl);
        }
    });
    btnGotoMod.setEnabled(false);
    btnGotoMod.setBounds(134, 308, 90, 28);
    panelDownloadMods.add(btnGotoMod);

    pBarDownloadMod = new JProgressBar();
    pBarDownloadMod.setBounds(538, 308, 150, 10);
    panelDownloadMods.add(pBarDownloadMod);

    pBarExtractMod = new JProgressBar();
    pBarExtractMod.setBounds(538, 314, 150, 10);
    panelDownloadMods.add(pBarExtractMod);

    lblDownloadModInfo = new JLabel("Download progress");
    lblDownloadModInfo.setBounds(489, 326, 199, 16);
    panelDownloadMods.add(lblDownloadModInfo);
    lblDownloadModInfo.setHorizontalAlignment(SwingConstants.TRAILING);

    panelModImg = new JPanel();
    panelModImg.setBounds(566, 0, 128, 128);
    panelDownloadMods.add(panelModImg);

    txtFilterText = new JTextField();
    txtFilterText.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            if (txtFilterText.getText().equals("Filter Text")) {
                txtFilterText.setText("");
                newFilter();
            }
        }
    });
    txtFilterText.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            if (!txtFilterText.getText().equals("Filter Text")) {
                newFilter();
            }
        }
    });
    txtFilterText.setText("Filter Text");
    txtFilterText.setBounds(0, 308, 122, 28);
    panelDownloadMods.add(txtFilterText);
    txtFilterText.setColumns(10);

    comboBox = new JComboBox();
    comboBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            newFilter();
        }
    });
    comboBox.setModel(new DefaultComboBoxModel(new String[] { "No tag filter", "Vanilla", "Machine", "Mechanic",
            "New Ore", "Module", "Big Mod", "Power", "GUI", "Map-Gen", "Must-Have", "Equipment" }));
    comboBox.setBounds(403, 44, 150, 26);
    panelDownloadMods.add(comboBox);

    lblModDlCounter = new JLabel("Mod database: ");
    lblModDlCounter.setFont(new Font("SansSerif", Font.PLAIN, 10));
    lblModDlCounter.setBounds(403, 5, 162, 16);
    panelDownloadMods.add(lblModDlCounter);

    txtrDMModDescription = new JTextArea();
    txtrDMModDescription.setBackground(Color.LIGHT_GRAY);
    txtrDMModDescription.setBorder(new LineBorder(new Color(0, 0, 0)));
    txtrDMModDescription.setFocusable(false);
    txtrDMModDescription.setEditable(false);
    txtrDMModDescription.setLineWrap(true);
    txtrDMModDescription.setWrapStyleWord(true);
    txtrDMModDescription.setText("Mod Description: ");
    txtrDMModDescription.setBounds(403, 132, 285, 75);
    panelDownloadMods.add(txtrDMModDescription);

    lblDMModTags = new JTextArea();
    lblDMModTags.setFocusable(false);
    lblDMModTags.setEditable(false);
    lblDMModTags.setBorder(new LineBorder(new Color(0, 0, 0)));
    lblDMModTags.setWrapStyleWord(true);
    lblDMModTags.setLineWrap(true);
    lblDMModTags.setBackground(Color.LIGHT_GRAY);
    lblDMModTags.setText("Mod Tags: ");
    lblDMModTags.setBounds(403, 71, 160, 60);
    panelDownloadMods.add(lblDMModTags);

    lblDMRequiredMods = new JTextArea();
    lblDMRequiredMods.setFocusable(false);
    lblDMRequiredMods.setEditable(false);
    lblDMRequiredMods.setText("Required Mods: ");
    lblDMRequiredMods.setWrapStyleWord(true);
    lblDMRequiredMods.setLineWrap(true);
    lblDMRequiredMods.setBorder(new LineBorder(new Color(0, 0, 0)));
    lblDMRequiredMods.setBackground(Color.LIGHT_GRAY);
    lblDMRequiredMods.setBounds(403, 208, 285, 57);
    panelDownloadMods.add(lblDMRequiredMods);

    lblDLModLicense = new JLabel("");
    lblDLModLicense.setHorizontalAlignment(SwingConstants.RIGHT);
    lblDLModLicense.setBounds(403, 294, 285, 16);
    panelDownloadMods.add(lblDLModLicense);

    lblWipmod = new JLabel("");
    lblWipmod.setBounds(395, 314, 64, 16);
    panelDownloadMods.add(lblWipmod);

    JButton btnCancel = new JButton("Cancel");
    btnCancel.setToolTipText("Stop downloading");
    btnCancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            CurrentDownload.cancel();
        }
    });
    btnCancel.setBounds(230, 308, 72, 28);
    panelDownloadMods.add(btnCancel);

    panelOptions = new JPanel();
    tabbedPane.addTab("Options", null, panelOptions, null);
    panelOptions.setLayout(null);
    scrollPane_4.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane_4.setBounds(0, 0, 694, 342);
    panelOptions.add(scrollPane_4);

    panel = new JPanel();
    scrollPane_4.setViewportView(panel);
    panel.setLayout(null);

    lblCloseMclauncherAfter = new JLabel("Close McLauncher after launching Factorio?");
    lblCloseMclauncherAfter.setBounds(6, 6, 274, 16);
    panel.add(lblCloseMclauncherAfter);

    lblCloseMclauncherAfter_1 = new JLabel("Close McLauncher after updating?");
    lblCloseMclauncherAfter_1.setBounds(6, 34, 274, 16);
    panel.add(lblCloseMclauncherAfter_1);

    lblSortNewestDownloadable = new JLabel("Sort newest downloadable mods first?");
    lblSortNewestDownloadable.setBounds(6, 62, 274, 16);
    panel.add(lblSortNewestDownloadable);

    tglbtnNewModsFirst = new JToggleButton("Toggle");
    tglbtnNewModsFirst.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            lblNeedrestart.setText("McLauncher needs to restart for that to work");
            writeData();
        }
    });
    tglbtnNewModsFirst.setSelected(true);
    tglbtnNewModsFirst.setBounds(281, 56, 66, 28);
    panel.add(tglbtnNewModsFirst);

    tglbtnCloseAfterUpdate = new JToggleButton("Toggle");
    tglbtnCloseAfterUpdate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            writeData();
        }
    });
    tglbtnCloseAfterUpdate.setBounds(281, 28, 66, 28);
    panel.add(tglbtnCloseAfterUpdate);

    tglbtnCloseAfterLaunch = new JToggleButton("Toggle");
    tglbtnCloseAfterLaunch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            writeData();
        }
    });
    tglbtnCloseAfterLaunch.setBounds(281, 0, 66, 28);
    panel.add(tglbtnCloseAfterLaunch);

    tglbtnDisplayon = new JToggleButton("On");
    tglbtnDisplayon.setFont(new Font("SansSerif", Font.PLAIN, 10));
    tglbtnDisplayon.setSelected(true);
    tglbtnDisplayon.setBounds(588, 308, 44, 28);
    panel.add(tglbtnDisplayon);

    tglbtnDisplayoff = new JToggleButton("Off");
    tglbtnDisplayoff.setFont(new Font("SansSerif", Font.PLAIN, 10));
    tglbtnDisplayoff.setBounds(644, 308, 44, 28);
    panel.add(tglbtnDisplayoff);

    lblInfo = new JLabel("What enabled and disabled look like");
    lblInfo.setFont(new Font("SansSerif", Font.PLAIN, 10));
    lblInfo.setHorizontalAlignment(SwingConstants.TRAILING);
    lblInfo.setBounds(359, 314, 231, 16);
    panel.add(lblInfo);

    JSeparator separator = new JSeparator();
    separator.setBounds(6, 55, 676, 24);
    panel.add(separator);

    JSeparator separator_1 = new JSeparator();
    separator_1.setBounds(6, 27, 676, 18);
    panel.add(separator_1);

    JSeparator separator_2 = new JSeparator();
    separator_2.setBounds(6, 84, 676, 24);
    panel.add(separator_2);

    JSeparator separator_3 = new JSeparator();
    separator_3.setOrientation(SwingConstants.VERTICAL);
    separator_3.setBounds(346, 0, 16, 336);
    panel.add(separator_3);

    lblNeedrestart = new JLabel("");
    lblNeedrestart.setBounds(6, 314, 341, 16);
    panel.add(lblNeedrestart);

    tglbtnSendAnonData = new JToggleButton("Toggle");
    tglbtnSendAnonData.setToolTipText("Information regarding the activity of McLauncher.");
    tglbtnSendAnonData.setSelected(true); //set enabled by default.
    tglbtnSendAnonData.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            writeData();
        }
    });
    tglbtnSendAnonData.setBounds(622, 0, 66, 28);
    panel.add(tglbtnSendAnonData);

    lblSendAnonymousUse = new JLabel("Send anonymous use data?");
    lblSendAnonymousUse.setBounds(359, 6, 251, 16);
    panel.add(lblSendAnonymousUse);

    lblDeleteOldMod = new JLabel("Delete old mod before updating?");
    lblDeleteOldMod.setBounds(359, 34, 251, 16);
    panel.add(lblDeleteOldMod);

    tglbtnDeleteBeforeUpdate = new JToggleButton("Toggle");
    tglbtnDeleteBeforeUpdate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            writeData();
        }
    });
    tglbtnDeleteBeforeUpdate.setBounds(622, 28, 66, 28);
    panel.add(tglbtnDeleteBeforeUpdate);

    tglbtnAlertOnModUpdateAvailable = new JToggleButton("Toggle");
    tglbtnAlertOnModUpdateAvailable.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            writeData();
        }
    });
    tglbtnAlertOnModUpdateAvailable.setSelected(true);
    tglbtnAlertOnModUpdateAvailable.setBounds(281, 86, 66, 28);
    panel.add(tglbtnAlertOnModUpdateAvailable);

    separator_4 = new JSeparator();
    separator_4.setBounds(0, 112, 676, 24);
    panel.add(separator_4);

    JLabel lblAlertModHas = new JLabel("Alert mod has update on launch?");
    lblAlertModHas.setBounds(6, 92, 231, 16);
    panel.add(lblAlertModHas);

    panelChangelog = new JPanel();
    tabbedPane.addTab("Changelog", null, panelChangelog, null);
    panelChangelog.setLayout(new BoxLayout(panelChangelog, BoxLayout.X_AXIS));

    scrollPane_6 = new JScrollPane();
    panelChangelog.add(scrollPane_6);

    textChangelog = new JTextArea();
    scrollPane_6.setViewportView(textChangelog);
    textChangelog.setEditable(false);
    textChangelog.setText(
            "v0.4.6\r\n\r\n+Fix problem where config file would not save in the correct location. (Thanks Arano-kai)\r\n+McLauncher will now save when you select a path, or profile. (Thanks Arano-kai)\r\n+Fixed an issue where McLauncher could not get the version from a .zip mod. (Thanks Arano-kai)\r\n+Added a Cancel button to stop downloading the current mod. (Suggested by  Arano-kai)\r\n\r\n\r\n\r\nv0.4.5\r\n\r\n+McLauncher should now correctly warn you on failed write/read access.\r\n+McLauncher should now work when a user has both zip and installer versions of factorio. (Thanks Jeroon)\r\n+Attempt to fix an error with dependency and .zip files, With versions. (Thanks Arano-kai)\r\n+Fix only allow single selection of mods. (Thanks Arano-kai)\r\n+Fix for the Launch+Ignore button problem on linux being cut off. (Thanks Arano-kai)\r\n+Display download progress.\r\n+Fixed an error that was thrown when clicking on some mods that had a single dependency mod.\r\n+Double clicking on a mod will now enable or disable the mod. (Thanks Arano-kai)");
    btnLaunchIgnore.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (selProfile != null) {
                LaunchFactorioWithSelectedMods(true); //ignore errors, launch.
            }
        }
    });
    btnLaunchIgnore.setVisible(false);
    //This is my test button. I use this to test things then implement them into the swing.
    btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            testButtonCode(e);
        }
    });
    //Disable mods button. (from profile)
    btnDisable.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            removeMod();
        }
    });
    //Enable mods button. (to profile)
    btnEnable.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            addMod();
        }
    });
    //Game path button
    btnFind.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            findPath();
        }
    });
    //mouseClick event lister for when you click on a new profile
    profileList.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            selectedProfile();
        }
    });

    readData(); //Load settings

    init(); //some extra init
    getMods(); //Get the mods the user has installed
}

From source file:edu.ku.brc.specify.utilapps.RegisterApp.java

/**
 * @param clsHash/*from  w ww.  j a  va2 s. c  o  m*/
 */
private void showClassList(final Hashtable<String, Boolean> clsHash) {
    boolean wasVisible = false;
    boolean wasCreated = false;
    if (classFrame == null) {
        CellConstraints cc = new CellConstraints();
        PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "f:p:g"));

        classList = new JList(new DefaultListModel());
        //pb.add(UIHelper.createLabel("Unused Classes"), cc.xy(1,1));
        pb.add(UIHelper.createScrollPane(classList), cc.xy(1, 1));

        pb.setDefaultDialogBorder();

        classFrame = new CustomFrame("Used Classes", CustomFrame.OK_BTN, pb.getPanel());
        classFrame.setOkLabel("Close");
        classFrame.createUI();
        wasCreated = true;

    } else {
        wasVisible = classFrame.isVisible();
    }

    Hashtable<String, Boolean> allClassesHash = new Hashtable<String, Boolean>();
    for (DBTableInfo ti : DBTableIdMgr.getInstance().getTables()) {
        allClassesHash.put(ti.getShortClassName(), true);
    }

    for (String key : clsHash.keySet()) {
        allClassesHash.remove(key);
    }

    ((DefaultListModel) classList.getModel()).clear();
    TreeSet<String> keys = new TreeSet<String>(allClassesHash.keySet());
    for (String key : keys) {
        ((DefaultListModel) classList.getModel()).addElement(key);
    }

    // Can't believe I have to do this
    Rectangle r = classFrame.getBounds();
    r.height++;
    classFrame.setBounds(r);
    r.height--;
    //----
    classFrame.setBounds(r);

    if (wasCreated) {
        classFrame.pack();
    }

    if (!wasVisible) {
        UIHelper.centerAndShow(classFrame);
    }
}

From source file:com.eviware.soapui.impl.wsdl.panels.mock.WsdlMockServiceDesktopPanel.java

protected JComponent buildLog() {
    JPanel panel = new JPanel(new BorderLayout());
    JXToolBar builder = UISupport.createToolbar();

    enableLogCheckBox = new JCheckBox(" ", true);
    enableLogCheckBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            testLogList.setEnabled(enableLogCheckBox.isSelected());
            if (mockRunner != null)
                mockRunner.setLogEnabled(enableLogCheckBox.isSelected());

            // border needs to be repainted..
            logScrollPane.repaint();//w  w w  .  j a v a 2  s . co m
        }
    });
    enableLogCheckBox.setOpaque(false);

    builder.addFixed(enableLogCheckBox);
    builder.addRelatedGap();
    builder.addFixed(new JLabel("Enable"));
    builder.addRelatedGap();
    addLogActions(builder);

    builder.addGlue();
    builder.setBorder(BorderFactory.createEmptyBorder(2, 3, 3, 3));

    panel.add(builder, BorderLayout.NORTH);

    logListModel = new LogListModel();
    testLogList = new JList(logListModel);
    testLogList.setCellRenderer(new LogCellRenderer());
    // testLogList.setPrototypeCellValue( "Testing 123" );
    // testLogList.setFixedCellWidth( -1 );
    testLogList.addMouseListener(new LogListMouseListener());
    testLogList.setBorder(BorderFactory.createLineBorder(Color.GRAY));

    logScrollPane = new JScrollPane(testLogList);

    panel.add(logScrollPane, BorderLayout.CENTER);

    return panel;
}

From source file:es.emergya.ui.gis.popups.ConsultaHistoricos.java

private JPanel getElementos() {
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEADING));
    panel.setOpaque(false);//ww  w . ja  va 2  s .c om
    panel.setBorder(new TitledBorder("Elementos a Consultar"));

    JLabel jLabel = new JLabel("Recursos", SwingConstants.RIGHT);
    jLabel.setPreferredSize(ConsultaHistoricos.DIMENSION_LABEL);
    panel.add(jLabel);
    recursos = new JList(new DefaultListModel());
    recursos.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK), "selectAll");
    recursos.getActionMap().put("selectAll", new AbstractAction() {

        private static final long serialVersionUID = -5515338515763292526L;

        @Override
        public void actionPerformed(ActionEvent e) {
            recursos.setSelectionInterval(0, recursos.getModel().getSize() - 1);
        }
    });
    recursos.addListSelectionListener(listSelectionListener);
    final JScrollPane jScrollPaneR = new JScrollPane(recursos, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jScrollPaneR.getViewport().setPreferredSize(DIMENSION_JLIST);
    panel.add(jScrollPaneR);

    jLabel = new JLabel("Incidencias", SwingConstants.RIGHT);
    jLabel.setPreferredSize(ConsultaHistoricos.DIMENSION_LABEL);
    panel.add(jLabel);
    incidencias = new JList(new DefaultListModel());
    incidencias.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK), "selectAll");
    incidencias.getActionMap().put("selectAll", new AbstractAction() {

        private static final long serialVersionUID = -5515338515763292526L;

        @Override
        public void actionPerformed(ActionEvent e) {
            incidencias.setSelectionInterval(0, incidencias.getModel().getSize() - 1);
        }
    });
    incidencias.addListSelectionListener(listSelectionListener);
    final JScrollPane jScrollPaneI = new JScrollPane(incidencias, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jScrollPaneI.getViewport().setPreferredSize(DIMENSION_JLIST);
    panel.setPreferredSize(DIMENSION_2JLIST);
    panel.add(jScrollPaneI);
    return panel;
}

From source file:ca.sqlpower.swingui.enterprise.client.ServerProjectsManagerPanel.java

/**
 * This constructor creates a dialog for modifying and loading a project
 * from a single server designated by the given serverInfo parameter.
 * /*from   www .  j a v  a  2s. c o  m*/
 * @param serverInfo
 *            Projects will be retrieved from this server based on the
 *            information and displayed. The dialog will allow editing the
 *            security as well as creating and deleting projects on this
 *            server.
 * @param dialogOwner
 *            The dialog to parent new dialogs to.
 * @param upf
 *            A user prompter factory for displaying error and warning
 *            messages to users.
 * @param closeAction
 *            An action that will close the dialog or frame that this dialog
 *            is contained in.
 * @param defaultFileDirectory
 *            A default file directory to start looking for files in if the
 *            user wants to upload a project. If null this will default to
 *            the user's home directory.
 * @param cookieStore
 *            A cookie store for HTTP requests. Used by the
 *            {@link ClientSideSessionUtils}.
 */
public ServerProjectsManagerPanel(SPServerInfo serverInfo, Component dialogOwner, UserPrompterFactory upf,
        Action closeAction, File defaultFileDirectory, CookieStore cookieStore) {
    this.serverInfo = serverInfo;
    this.dialogOwner = dialogOwner;
    this.upf = upf;
    this.closeAction = closeAction;
    this.defaultFileDirectory = defaultFileDirectory;
    this.cookieStore = cookieStore;

    cookieStore.clear();

    DefaultFormBuilder builder = new DefaultFormBuilder(
            new FormLayout("pref:grow, 5dlu, pref", "pref, pref, pref"));

    servers = null;

    projects = new JList(new DefaultListModel());
    projects.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            refreshPanel();
            if (e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(e)) {
                getOpenAction().actionPerformed(null);
            }
        }
    });

    JScrollPane projectsPane = new JScrollPane(projects);
    projectsPane.setPreferredSize(new Dimension(250, 300));

    CellConstraints cc = new CellConstraints();
    builder.add(new JLabel(serverInfo.getName() + "'s projects:"), cc.xyw(1, 1, 2));
    builder.nextLine();
    builder.add(projectsPane, cc.xywh(1, 2, 1, 2));

    DefaultFormBuilder buttonBarBuilder = new DefaultFormBuilder(new FormLayout("pref"));
    buttonBarBuilder.append(new JButton(refreshAction));
    buttonBarBuilder.append(securityButton);
    buttonBarBuilder.append(new JButton(newAction));
    buttonBarBuilder.append(openButton);
    buttonBarBuilder.append(new JButton(deleteAction));
    buttonBarBuilder.append(new JButton(closeAction));
    builder.add(buttonBarBuilder.getPanel(), cc.xy(3, 2));
    builder.setDefaultDialogBorder();
    panel = builder.getPanel();
}

From source file:edu.ku.brc.specify.tools.l10nios.StrLocalizerAppForiOS.java

/**
 * /*w ww.  jav  a 2  s.  co  m*/
 */
private void createUI() {
    IconManager.setApplicationClass(Specify.class);
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_datamodel.xml")); //$NON-NLS-1$
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_plugins.xml")); //$NON-NLS-1$
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_disciplines.xml")); //$NON-NLS-1$

    System.setProperty("edu.ku.brc.ui.db.PickListDBAdapterFactory", //$NON-NLS-1$
            "edu.ku.brc.specify.tools.StrLocPickListFactory"); // Needed By the Auto Cosmplete UI  //$NON-NLS-1$

    CellConstraints cc = new CellConstraints();

    fileList = new JList(fileModel = new DefaultListModel());
    termList = new JList(model = new ItemModel(null));

    srcLbl = setTAReadOnly(UIHelper.createTextArea(3, 40));
    //srcLbl.setBorder(new LineBorder(srcLbl.getForeground()));
    textField = UIHelper.createTextField(40);

    comment = setTAReadOnly(UIHelper.createTextArea(3, 40));

    /*textField.getDocument().addDocumentListener(new DocumentAdaptor() {
    @Override
    protected void changed(DocumentEvent e)
    {
        hasChanged = true;
    }
    });*/

    statusBar = new JStatusBar();
    statusBar.setSectionText(1, "     "); //$NON-NLS-1$ //$NON-NLS-2$
    UIRegistry.setStatusBar(statusBar);

    srcLbl.setEditable(false);

    rsController = new ResultSetController(null, false, false, false, "", 1, true);

    transBtn = UIHelper.createButton(getResourceString("StrLocalizerApp.Translate"));
    transBtn.setVisible(false);

    PanelBuilder pbr = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p,4px,p,4px,p,4px,p,4px,p,4px,p"));

    //pbr.add(UIHelper.createLabel(getResourceString("StrLocalizerApp.FileLbl")), cc.xy(1, 1));
    //fileLbl = UIHelper.createLabel("   ");
    //pbr.add(fileLbl, cc.xy(3, 1));

    int y = 1;
    pbr.addSeparator("Item", cc.xyw(1, y, 3));
    y += 2;

    pbr.add(UIHelper.createLabel("English:", SwingConstants.RIGHT), cc.xy(1, y));
    pbr.add(srcLbl, cc.xy(3, y));
    y += 2;

    pbr.add(UIHelper.createFormLabel("Comment", SwingConstants.RIGHT), cc.xy(1, y));
    pbr.add(comment, cc.xy(3, y));
    y += 2;

    destLbl = UIHelper.createFormLabel("", SwingConstants.RIGHT);//destLanguage.getDisplayName());
    pbr.add(destLbl, cc.xy(1, y));
    pbr.add(textField, cc.xy(3, y));
    y += 2;

    pbr.add(rsController.getPanel(), cc.xyw(1, y, 3));
    y += 2;
    pbr.add(transBtn, cc.xy(1, y));

    JScrollPane sp = UIHelper.createScrollPane(termList);

    PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,4px,f:p:g,10px,p"));
    pb.addSeparator("Localize", cc.xy(1, 1));
    pb.add(sp, cc.xy(1, 3));
    pb.add(pbr.getPanel(), cc.xy(1, 5));
    pb.setDefaultDialogBorder();

    ResultSetController.setBackStopRS(rsController);

    PanelBuilder fpb = new PanelBuilder(new FormLayout("8px,f:p:g", "p,4px,f:p:g"));
    JScrollPane filesp = UIHelper.createScrollPane(fileList);
    fpb.add(UIHelper.createLabel("Files", SwingConstants.CENTER), cc.xy(2, 1));
    fpb.add(filesp, cc.xy(2, 3));

    setLayout(new BorderLayout());
    add(fpb.getPanel(), BorderLayout.WEST);
    add(pb.getPanel(), BorderLayout.CENTER);
    add(statusBar, BorderLayout.SOUTH);

    mainPane = this;

    textField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            checkForChange();
        }
    });

    termList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                itemSelected();
            }
        }
    });

    fileList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                fileSelected();
            }
        }
    });

    transBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String txt = srcLbl.getText();
            String newText = translate(txt);
            if (StringUtils.isNotEmpty(newText)) {
                newText = newText.replace("&#039;", "'");
                textField.setText(newText);
                L10NItem entry = (L10NItem) termList.getSelectedValue();
                entry.setValue(textField.getText());
            }
        }
    });

    rscListener = new ResultSetControllerListener() {
        @Override
        public void newRecordAdded() {
        }

        @Override
        public void indexChanged(int newIndex) {
            termList.setSelectedIndex(newIndex);
        }

        @Override
        public boolean indexAboutToChange(int oldIndex, int newIndex) {
            return true;
        }
    };

    rsController.addListener(rscListener);
}

From source file:cnu.eslab.fileTest.NewJFrame.java

private void initGUI() {
    try {/* www.  java2s.c  om*/
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(null);
        {
            jPanel1 = new JPanel();
            FlowLayout jPanel1Layout = new FlowLayout();
            jPanel1.setLayout(jPanel1Layout);
            getContentPane().add(jPanel1, "North");
            jPanel1.setBounds(12, 434, 590, 66);
            jPanel1.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            {
                mParsingBtn = new JButton();
                jPanel1.add(mParsingBtn);
                mParsingBtn.setText("Parsing");
                mParsingBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mTotalPowerBtn = new JButton();
                jPanel1.add(mTotalPowerBtn);
                mTotalPowerBtn.setText("Phone Total Power");
                mTotalPowerBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mBatteryCapacityBtn = new JButton();
                jPanel1.add(mBatteryCapacityBtn);
                mBatteryCapacityBtn.setText("Battery Capacity");
                mBatteryCapacityBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mTotalCompareBtn = new JButton();
                jPanel1.add(mTotalCompareBtn);
                mTotalCompareBtn.setText("Total Compare");
                mTotalCompareBtn.setPreferredSize(new java.awt.Dimension(124, 24));
            }
            {
                mPhoneTotalStackPowerBtn = new JButton();
                jPanel1.add(mPhoneTotalStackPowerBtn);
                mPhoneTotalStackPowerBtn.setText("Phone Total Stack Power");
            }
            {
                mDevicesPowerButton = new JButton();
                jPanel1.add(mDevicesPowerButton);
                mDevicesPowerButton.setText("Hardware Component Max Power");
                mDevicesPowerButton.setPreferredSize(new java.awt.Dimension(280, 24));
            }
            {
                mCompareAppPowerBtn = new JButton();
                jPanel1.add(mCompareAppPowerBtn);
                mCompareAppPowerBtn.setText("Compare");
            }
        }
        {
            jPanel2 = new JPanel();
            getContentPane().add(jPanel2, "West");
            jPanel2.setBounds(12, 25, 589, 67);
            jPanel2.setLayout(null);
            jPanel2.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            {
                mFilePathLabel = new JLabel();
                jPanel2.add(mFilePathLabel);
                mFilePathLabel.setText("File Path");
                mFilePathLabel.setPreferredSize(new java.awt.Dimension(48, 17));
                mFilePathLabel.setBounds(8, 8, 48, 17);
            }
            {
                mFilePathTextField = new JTextField();
                jPanel2.add(mFilePathTextField);
                mFilePathTextField.setText("None");
                mFilePathTextField.setEditable(false);
                mFilePathTextField.setBounds(68, 4, 430, 24);
            }
            {
                mFileBtn = new JButton();
                jPanel2.add(mFileBtn);
                mFileBtn.setText("OPEN");
                mFileBtn.setBounds(503, 6, 81, 24);
            }
            {
                LOGTimeLabel = new JLabel();
                jPanel2.add(LOGTimeLabel);
                LOGTimeLabel.setText("LOG Time");
                LOGTimeLabel.setBounds(8, 37, 60, 17);
            }
            {
                mLogScaleTextFiled = new JTextField();
                jPanel2.add(mLogScaleTextFiled);
                mLogScaleTextFiled.setText("None");
                mLogScaleTextFiled.setEditable(false);
                mLogScaleTextFiled.setBounds(68, 34, 430, 24);
            }
        }
        {
            jScrollPane1 = new JScrollPane();
            getContentPane().add(jScrollPane1);
            jScrollPane1.setBounds(13, 122, 424, 228);
            {
                listModel = new DefaultListModel();// List? ??  ??.
                mUidList = new JList(listModel);
                mUidList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // 
                // ?
                // ?
                // .
                jScrollPane1.setViewportView(mUidList);
                jScrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

                mUidList.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
                //mUidList.setPreferredSize(new java.awt.Dimension(586, 222));   /?  ?.
            }
        }
        {
            jPanel3 = new JPanel();
            getContentPane().add(jPanel3);
            jPanel3.setBounds(12, 0, 579, 31);
            {
                dd = new JLabel();
                jPanel3.add(dd);
                dd.setText("Power Tutor Trace");
                dd.setPreferredSize(new java.awt.Dimension(106, 17));
            }
        }
        {
            jPanel5 = new JPanel();
            getContentPane().add(jPanel5, "West");
            jPanel5.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jPanel5.setBounds(12, 356, 304, 58);
            jPanel5.setLayout(null);
            {
                Range = new JLabel();
                jPanel5.add(Range);
                Range.setText("Range");
                Range.setBounds(14, 10, 46, 17);
            }
            {
                mFirstRangeText = new JTextField();
                jPanel5.add(mFirstRangeText);
                mFirstRangeText.setBounds(59, 7, 63, 24);
            }
            {
                mUidPieDiagramBtn = new JButton();
                jPanel5.add(mUidPieDiagramBtn);
                mUidPieDiagramBtn.setText("UID Pie");
                mUidPieDiagramBtn.setBounds(207, 7, 90, 24);
            }
            {
                jLabel3 = new JLabel();
                jPanel5.add(jLabel3);
                jLabel3.setText("-");
                jLabel3.setBounds(128, 10, 10, 17);
            }
            {
                mSecondRangeText = new JTextField();
                jPanel5.add(mSecondRangeText);
                mSecondRangeText.setBounds(138, 7, 63, 24);
            }
            {
                mComponentPieBtn = new JButton();
                jPanel5.add(mComponentPieBtn);
                mComponentPieBtn.setText("PHONE Pie");
                mComponentPieBtn.setBounds(59, 36, 238, 16);
            }
        }
        {
            jPanel6 = new JPanel();
            getContentPane().add(jPanel6, "West");
            jPanel6.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jPanel6.setBounds(322, 356, 275, 66);
            jPanel6.setLayout(null);
            {
                jLabel4 = new JLabel();
                jPanel6.add(jLabel4);
                jLabel4.setText("TotalPM");
                jLabel4.setBounds(16, 10, 56, 26);
            }
            {
                mChartMeanUnitTextField = new JTextField();
                jPanel6.add(mChartMeanUnitTextField);
                mChartMeanUnitTextField.setBounds(77, 7, 135, 29);
            }
            {
                m3DBarChartMean = new JButton();
                jPanel6.add(m3DBarChartMean);
                m3DBarChartMean.setText("ok");
                m3DBarChartMean.setBounds(218, 7, 49, 24);
            }
            {
                mAudioCheckBox = new JCheckBox();
                jPanel6.add(mAudioCheckBox);
                mAudioCheckBox.setText("AUDIO");
                mAudioCheckBox.setBounds(79, 40, 65, 21);
            }
            {
                mGPSCheckBox = new JCheckBox();
                jPanel6.add(mGPSCheckBox);
                mGPSCheckBox.setText("GPS");
                mGPSCheckBox.setBounds(151, 40, 56, 21);
            }
        }
        {
            jPanel4 = new JPanel();
            getContentPane().add(jPanel4, "North");
            FlowLayout jPanel4Layout = new FlowLayout();
            jPanel4.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jPanel4.setLayout(jPanel4Layout);
            jPanel4.setBounds(12, 523, 590, 66);
            {
                mAppTotalPowerBtn = new JButton();
                jPanel4.add(mAppTotalPowerBtn);
                mAppTotalPowerBtn.setText("UID Line Total Power");
                mAppTotalPowerBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mAppStackedPower = new JButton();
                jPanel4.add(mAppStackedPower);
                mAppStackedPower.setText("UID Stack Total Power");
                mAppStackedPower.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mLedBtn = new JButton();
                jPanel4.add(mLedBtn);
                mLedBtn.setText("UID LED Power");
                mLedBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mCpuBtn = new JButton();
                jPanel4.add(mCpuBtn);
                mCpuBtn.setText("UID CPU Power");
                mCpuBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mWifiBtn = new JButton();
                jPanel4.add(mWifiBtn);
                mWifiBtn.setText("UID WIFI Power");
                mWifiBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                m3GBtn = new JButton();
                jPanel4.add(m3GBtn);
                m3GBtn.setText("UID ThreeG Power");
                m3GBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
        }
        {
            jPanel7 = new JPanel();
            getContentPane().add(jPanel7, "North");
            FlowLayout jPanel7Layout = new FlowLayout();
            jPanel7.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jPanel7.setLayout(jPanel7Layout);
            jPanel7.setBounds(12, 618, 590, 63);
            {
                mComponentLEDBtn = new JButton();
                jPanel7.add(mComponentLEDBtn);
                mComponentLEDBtn.setText("LED Power");
                mComponentLEDBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mComponentWIFIBtn = new JButton();
                jPanel7.add(mComponentWIFIBtn);
                mComponentWIFIBtn.setText("WIFI Power");
                mComponentWIFIBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mGpsBtn = new JButton();
                jPanel7.add(mGpsBtn);
                mGpsBtn.setText("GPS Power");
                mGpsBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mComponentCPUBtn = new JButton();
                jPanel7.add(mComponentCPUBtn);
                mComponentCPUBtn.setText("CPU Power");
                mComponentCPUBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mComponentThreeGBtn = new JButton();
                jPanel7.add(mComponentThreeGBtn);
                mComponentThreeGBtn.setText("ThreeG Power");
                mComponentThreeGBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mAudioBtn = new JButton();
                jPanel7.add(mAudioBtn);
                mAudioBtn.setText("AUDIO Power");
                mAudioBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
        }
        {
            jLabel1 = new JLabel();
            getContentPane().add(jLabel1);
            jLabel1.setText("Individual App component Power");
            jLabel1.setBounds(12, 506, 202, 17);
        }
        {
            jLabel2 = new JLabel();
            getContentPane().add(jLabel2);
            jLabel2.setText("Function Button");
            jLabel2.setBounds(12, 411, 181, 17);
        }
        {
            jLabel5 = new JLabel();
            getContentPane().add(jLabel5);
            jLabel5.setText("Individual H/W Component Power");
            jLabel5.setBounds(12, 601, 223, 17);
        }
        {
            jScrollPane2 = new JScrollPane();
            getContentPane().add(jScrollPane2);
            jScrollPane2.setBounds(493, 122, 108, 194);
            {
                listModelUidDelte = new DefaultListModel();// List? ??  ??.
                mDeleteList = new JList(listModelUidDelte);
                jScrollPane2.setViewportView(mDeleteList);
            }
        }
        {
            mDeleteAllBtn = new JButton();
            getContentPane().add(mDeleteAllBtn);
            mDeleteAllBtn.setText("A");
            mDeleteAllBtn.setBounds(493, 321, 51, 24);
        }
        {
            mDeleteOneBtn = new JButton();
            getContentPane().add(mDeleteOneBtn);
            mDeleteOneBtn.setText("O");
            mDeleteOneBtn.setBounds(549, 321, 48, 24);
        }
        {
            mDeleteUidMoveBtn = new JButton();
            getContentPane().add(mDeleteUidMoveBtn);
            mDeleteUidMoveBtn.setText(">");
            mDeleteUidMoveBtn.setBounds(443, 169, 45, 95);
        }
        {
            jLabel6 = new JLabel();
            getContentPane().add(jLabel6);
            jLabel6.setText("Package Name List");
            jLabel6.setBounds(13, 99, 139, 17);
        }
        {
            jLabel7 = new JLabel();
            getContentPane().add(jLabel7);
            jLabel7.setText("Remove Uid");
            jLabel7.setBounds(493, 100, 139, 17);
        }
        pack();
        this.setSize(623, 725);
        // setVisible(true);
    } catch (Exception e) {
        // add your error handling code here
        e.printStackTrace();
    }
}

From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerFrame.java

/**
 * Export data //  w  w  w  .  j  a  v a 2s.  c o m
 */
protected void exportSingleLocale() {
    statusBar.setText(getResourceString("SchemaLocalizerFrame.EXPORTING")); //$NON-NLS-1$
    statusBar.paintImmediately(statusBar.getBounds());

    schemaLocPanel.getAllDataFromUI();

    if (localizableIO.hasChanged()) {
        if (UIRegistry.askYesNoLocalized("SAVE", "CANCEL",
                UIRegistry.getResourceString("SchemaLocalizerFrame.NEEDS_SAVING"),
                "SAVE") == JOptionPane.YES_NO_OPTION) {
            localizableIO.save();
        } else {
            return;
        }
    }

    Vector<Locale> stdLocales = SchemaI18NService.getInstance().getStdLocaleList(false);
    final JList list = new JList(stdLocales);
    list.setCellRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value != null) {
                setText(((Locale) value).getDisplayName());
            }
            return this;
        }
    });

    PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "f:p:g"));
    pb.add(UIHelper.createScrollPane(list), (new CellConstraints()).xy(1, 1));
    pb.setDefaultDialogBorder();

    final CustomDialog dlg = new CustomDialog((Frame) UIRegistry.getTopWindow(),
            getResourceString("SchemaLocalizerFrame.CHOOSE_LOCALE"), true, pb.getPanel());
    list.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                dlg.getOkBtn().setEnabled(list.getSelectedValue() != null);
            }
        }
    });
    dlg.createUI();
    dlg.getOkBtn().setEnabled(false);

    UIHelper.centerAndShow(dlg);
    if (!dlg.isCancelled()) {
        Locale locale = (Locale) list.getSelectedValue();
        if (locale != null) {
            FileDialog fileDlg = new FileDialog((Frame) UIRegistry.getTopWindow(),
                    getResourceString("SchemaLocalizerFrame.SVFILENAME"), FileDialog.SAVE);
            fileDlg.setVisible(true);
            String fileName = fileDlg.getFile();
            if (StringUtils.isNotEmpty(fileName)) {
                File outFile = new File(fileDlg.getDirectory() + File.separator + fileName);
                boolean savedOK = localizableIO.exportSingleLanguageToDirectory(outFile, locale);
                if (savedOK) {
                    String msg = UIRegistry.getLocalizedMessage("SchemaLocalizerFrame.EXPORTEDTO",
                            locale.getDisplayName(), outFile.getAbsolutePath());
                    UIRegistry.displayInfoMsgDlg(msg);
                } else {
                    String msg = UIRegistry.getLocalizedMessage("SchemaLocalizerFrame.EXPORTING_ERR",
                            outFile.getAbsolutePath());
                    UIRegistry.showError(msg);
                }

            }
        }
    }
}

From source file:edu.ku.brc.specify.conversion.SpecifyDBConverter.java

/**
 * @return/*ww  w. j  a va2 s. c  o m*/
 * @throws SQLException
 */
public Pair<String, String> chooseTable(final String title, final String subTitle, final boolean doSp5DBs)
        throws SQLException {
    MySQLDMBSUserMgr mgr = new MySQLDMBSUserMgr();

    Vector<DBNamePair> availPairs = new Vector<DBNamePair>();

    if (mgr.connectToDBMS(itUsrPwd.first, itUsrPwd.second, hostName)) {
        BasicSQLUtils.setSkipTrackExceptions(true);

        //String sql = String.format("SELECT DISTINCT `COLUMNS`.TABLE_SCHEMA FROM `COLUMNS` WHERE `COLUMNS`.TABLE_NAME = '%s'", doSp5DBs ? "collectionobjectcatalog" : "taxon");
        Connection conn = mgr.getConnection();
        Vector<Object[]> dbNames = BasicSQLUtils.query(conn, "show databases");
        for (Object[] row : dbNames) {
            String dbName = row[0].toString();

            //System.out.print("Database Found ["+dbName+"]  ");
            conn.setCatalog(dbName);

            boolean isSp5DB = false;
            Vector<Object[]> tables = BasicSQLUtils.query(conn, "show tables");
            for (Object[] tblRow : tables) {
                String tableName = tblRow[0].toString();
                if (tableName.equalsIgnoreCase("usysversion")) {
                    isSp5DB = true;
                    break;
                }
            }

            if ((!isSp5DB && doSp5DBs) || (isSp5DB && !doSp5DBs)) {
                continue;
            }

            // make all table names lowercase
            try {
                Integer count = BasicSQLUtils.getCount(conn, "select COUNT(*) FROM collection");
                if (count == null) {
                    for (Object[] tblRow : tables) {
                        String tableName = tblRow[0].toString();
                        if (!tableName.equals(tableName.toLowerCase())) {
                            BasicSQLUtils.update(conn,
                                    "RENAME TABLE " + tableName + " TO " + tableName.toLowerCase());
                        }
                    }
                }

            } catch (Exception ex) {
                ex.printStackTrace();
            }

            Vector<Object> tableDesc = BasicSQLUtils.querySingleCol(conn,
                    "select CollectionName FROM collection");
            if (tableDesc.size() > 0) {
                String collName = tableDesc.get(0).toString();
                availPairs.add(new DBNamePair(collName, row[0].toString()));
            }
        }

        Collections.sort(availPairs, new Comparator<Pair<String, String>>() {
            @Override
            public int compare(Pair<String, String> o1, Pair<String, String> o2) {
                return o1.second.compareTo(o2.second);
            }
        });

        mgr.close();
        BasicSQLUtils.setSkipTrackExceptions(false);

        final JList list = new JList(availPairs);
        CellConstraints cc = new CellConstraints();
        PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,4px,f:p:g"));
        pb.add(UIHelper.createLabel(subTitle), cc.xy(1, 1));
        pb.add(UIHelper.createScrollPane(list, true), cc.xy(1, 3));
        pb.setDefaultDialogBorder();

        final CustomDialog dlg = new CustomDialog(null, title, true, pb.getPanel());
        list.addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    dlg.getOkBtn().setEnabled(list.getSelectedIndex() > -1);
                }
            }
        });

        list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        list.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    dlg.getOkBtn().setEnabled(list.getSelectedIndex() > -1);
                    dlg.getOkBtn().doClick();
                }
            }
        });

        dlg.createUI();
        dlg.pack();
        Dimension d = dlg.getPreferredSize();
        d.height = 700;
        dlg.setSize(d);
        UIHelper.centerAndShow(dlg);

        if (dlg.isCancelled()) {
            return null;
        }

        return namePairToConvert = (DBNamePair) list.getSelectedValue();
    }

    return null;
}

From source file:ca.sqlpower.swingui.enterprise.client.ServerProjectsManagerPanel.java

/**
 * Creates a dialog that lets the user choose a server connection and then a
 * project./*from  w  w w .jav  a 2 s.  c o  m*/
 * 
 * @param serverManager
 *            This object contains all of the server information objects
 *            known and the servers based on their information will be
 *            displayed in a list so a user can navigate to different
 *            projects in different servers.
 * @param dialogOwner
 *            The dialog to parent new dialogs to.
 * @param upf
 *            A user prompter factory for displaying error and warning
 *            messages to users.
 * @param closeAction
 *            An action that will close the dialog or frame that this dialog
 *            is contained in.
 * @param defaultFileDirectory
 *            A default file directory to start looking for files in if the
 *            user wants to upload a project. If null this will default to
 *            the user's home directory.
 * @param cookieStore
 *            A cookie store for HTTP requests. Used by the
 *            {@link ClientSideSessionUtils}.
 */
public ServerProjectsManagerPanel(SPServerInfoManager serverManager, Component dialogOwner,
        UserPrompterFactory upf, Action closeAction, File defaultFileDirectory, CookieStore cookieStore) {
    this.dialogOwner = dialogOwner;
    this.upf = upf;
    this.closeAction = closeAction;
    this.defaultFileDirectory = defaultFileDirectory;
    this.cookieStore = cookieStore;

    cookieStore.clear();

    DefaultFormBuilder builder = new DefaultFormBuilder(
            new FormLayout("pref:grow, 5dlu, pref:grow, 5dlu, pref", "pref, pref, pref"));

    servers = new JList(new DefaultListModel());
    servers.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e)) {
                refreshInfoList();
            }
        }
    });

    DefaultListModel serversModel = (DefaultListModel) servers.getModel();
    serversModel.removeAllElements();
    if (serverManager.getServers(false).size() > 0) {
        for (SPServerInfo serverInfo : serverManager.getServers(false)) {
            serversModel.addElement(serverInfo);
        }
    } else {
        serversModel.addElement("No Servers");
        servers.setEnabled(false);
    }

    projects = new JList(new DefaultListModel());
    projects.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            refreshPanel();
            if (e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(e)) {
                getOpenAction().actionPerformed(null);
            }
        }
    });

    JScrollPane projectsPane = new JScrollPane(projects);
    projectsPane.setPreferredSize(new Dimension(250, 300));

    JScrollPane serverPane = new JScrollPane(servers);
    serverPane.setPreferredSize(new Dimension(250, 300));

    CellConstraints cc = new CellConstraints();
    builder.add(new JLabel("Servers:"), cc.xyw(1, 1, 2));
    builder.add(new JLabel("Projects:"), cc.xyw(3, 1, 2));
    builder.nextLine();
    builder.add(serverPane, cc.xywh(1, 2, 1, 2));
    builder.add(projectsPane, cc.xywh(3, 2, 1, 2));

    DefaultFormBuilder buttonBarBuilder = new DefaultFormBuilder(new FormLayout("pref"));
    buttonBarBuilder.append(new JButton(refreshAction));
    buttonBarBuilder.append(securityButton);
    buttonBarBuilder.append(new JButton(newAction));
    buttonBarBuilder.append(openButton);
    buttonBarBuilder.append(new JButton(uploadAction));
    buttonBarBuilder.append(new JButton(deleteAction));
    buttonBarBuilder.append(new JButton(closeAction));
    builder.add(buttonBarBuilder.getPanel(), cc.xy(5, 2));
    builder.setDefaultDialogBorder();
    panel = builder.getPanel();
}