Example usage for java.awt.event MouseAdapter MouseAdapter

List of usage examples for java.awt.event MouseAdapter MouseAdapter

Introduction

In this page you can find the example usage for java.awt.event MouseAdapter MouseAdapter.

Prototype

MouseAdapter

Source Link

Usage

From source file:edu.ku.brc.specify.tasks.subpane.wb.TemplateEditor.java

@Override
public void createUI() {
    super.createUI();

    databaseSchema = WorkbenchTask.getDatabaseSchema();

    int disciplineeId = AppContextMgr.getInstance().getClassObject(Discipline.class).getDisciplineId();
    SchemaI18NService.getInstance().loadWithLocale(SpLocaleContainer.WORKBENCH_SCHEMA, disciplineeId,
            databaseSchema, SchemaI18NService.getCurrentLocale());

    // Create the Table List
    Vector<TableInfo> tableInfoList = new Vector<TableInfo>();
    for (DBTableInfo ti : databaseSchema.getTables()) {
        if (StringUtils.isNotEmpty(ti.toString())) {
            TableInfo tableInfo = new TableInfo(ti, IconManager.STD_ICON_SIZE);
            tableInfoList.add(tableInfo);

            Vector<FieldInfo> fldList = new Vector<FieldInfo>();
            for (DBFieldInfo fi : ti.getFields()) {
                String fldTitle = fi.getTitle().replace(" ", "");
                if (fldTitle.equalsIgnoreCase(fi.getName())) {
                    //get title from mapped field
                    UploadInfo upInfo = getUploadInfo(fi);
                    DBFieldInfo mInfo = getMappedFieldInfo(fi);
                    if (mInfo != null) {
                        String title = mInfo.getTitle();
                        if (upInfo != null && upInfo.getSequence() != -1) {
                            title += " " + (upInfo.getSequence() + 1);
                        }/* w w w . j a v  a 2 s . c o  m*/
                        //if mapped-to table is different than the container table used
                        // in the wb, add the mapped-to table's title
                        if (mInfo.getTableInfo().getTableId() != ti.getTableId()) {
                            title = mInfo.getTableInfo().getTitle() + " " + title;
                        }
                        fi.setTitle(title);
                    }
                }
                fldList.add(new FieldInfo(ti, fi));
            }
            //Collections.sort(fldList);
            tableInfo.setFieldItems(fldList);
        }
    }
    Collections.sort(tableInfoList);

    fieldModel = new DefaultModifiableListModel<FieldInfo>();
    tableModel = new DefaultModifiableListModel<TableInfo>();
    for (TableInfo ti : tableInfoList) {
        tableModel.add(ti);

        // only added for layout
        for (FieldInfo fi : ti.getFieldItems()) {
            fieldModel.add(fi);
        }
    }

    tableList = new JList(tableModel);
    tableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tableList.setCellRenderer(tableInfoListRenderer = new TableInfoListRenderer(IconManager.STD_ICON_SIZE));
    JScrollPane tableScrollPane = new JScrollPane(tableList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    tableList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                Object selObj = tableList.getSelectedValue();
                if (selObj != null) {
                    fillFieldList((TableInfo) selObj);
                }
                updateEnabledState();
            }
        }
    });

    fieldList = new JList(fieldModel);
    fieldList.setCellRenderer(tableInfoListRenderer = new TableInfoListRenderer(IconManager.STD_ICON_SIZE));
    fieldList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    JScrollPane fieldScrollPane = new JScrollPane(fieldList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    fieldList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                updateEnabledState();
                updateFieldDescription();
            }
        }
    });

    mapModel = new DefaultModifiableListModel<FieldMappingPanel>();
    mapList = new JList(mapModel);
    mapList.setCellRenderer(new MapCellRenderer());
    mapList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    mapScrollPane = new JScrollPane(mapList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    mapList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                FieldMappingPanel fmp = (FieldMappingPanel) mapList.getSelectedValue();
                if (fmp != null) {
                    ignoreMapListUpdate = true;

                    FieldInfo fldInfo = fmp.getFieldInfo();
                    if (fldInfo != null) {
                        for (int i = 0; i < tableModel.size(); i++) {
                            TableInfo tblInfo = (TableInfo) tableModel.get(i);
                            if (fldInfo.getTableinfo() == tblInfo.getTableInfo()) {
                                tableList.setSelectedValue(tblInfo, true);
                                fillFieldList(tblInfo);
                                //System.out.println(fldInfo.hashCode()+" "+fldInfo.getFieldInfo().hashCode());
                                fieldList.setSelectedValue(fldInfo, true);
                                updateFieldDescription();
                                break;
                            }
                        }
                    }
                    ignoreMapListUpdate = false;
                    updateEnabledState();
                }
            }
        }
    });

    upBtn = createIconBtn("ReorderUp", "WB_MOVE_UP", new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int inx = mapList.getSelectedIndex();
            FieldMappingPanel fmp = mapModel.getElementAt(inx);

            mapModel.remove(fmp);
            mapModel.insertElementAt(fmp, inx - 1);
            mapList.setSelectedIndex(inx - 1);
            updateEnabledState();
            setChanged(true);
        }
    });
    downBtn = createIconBtn("ReorderDown", "WB_MOVE_DOWN", new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int inx = mapList.getSelectedIndex();
            FieldMappingPanel fmp = mapModel.getElementAt(inx);

            mapModel.remove(fmp);
            mapModel.insertElementAt(fmp, inx + 1);
            mapList.setSelectedIndex(inx + 1);
            updateEnabledState();
            setChanged(true);
        }
    });

    JButton dumpMappingBtn = createIconBtn("BlankIcon", IconManager.IconSize.Std16, "WB_MAPPING_DUMP",
            new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    dumpMapping();
                }
            });
    dumpMappingBtn.setEnabled(true);
    dumpMappingBtn.setFocusable(false);
    dumpMappingBtn.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent e) {
            ((JButton) e.getSource()).setIcon(IconManager.getIcon("Save", IconManager.IconSize.Std16));
            super.mouseEntered(e);
        }

        @Override
        public void mouseExited(MouseEvent e) {
            ((JButton) e.getSource()).setIcon(IconManager.getIcon("BlankIcon", IconManager.IconSize.Std16));
            super.mouseExited(e);
        }

    });

    mapToBtn = createIconBtn("Map", "WB_ADD_MAPPING_ITEM", new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            map();
        }
    });
    unmapBtn = createIconBtn("Unmap", "WB_REMOVE_MAPPING_ITEM", new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            unmap();
        }
    });

    // Adjust all Labels depending on whether we are creating a new template or not
    // and whether it is from a file or not
    String mapListLeftLabel;
    String mapListRightLabel;

    // Note: if workbenchTemplate is null then it is 
    String dataTypeLabel = getResourceString("WB_DATA_TYPE");
    String fieldsLabel = getResourceString("WB_FIELDS");

    mapListLeftLabel = fieldsLabel;
    mapListRightLabel = getResourceString("WB_COLUMNS");

    CellConstraints cc = new CellConstraints();

    JPanel mainLayoutPanel = new JPanel();

    PanelBuilder labelsBldr = new PanelBuilder(new FormLayout("p, f:p:g, p", "p"));
    labelsBldr.add(createLabel(mapListLeftLabel, SwingConstants.LEFT), cc.xy(1, 1));
    labelsBldr.add(createLabel(mapListRightLabel, SwingConstants.RIGHT), cc.xy(3, 1));

    PanelBuilder upDownPanel = new PanelBuilder(new FormLayout("p", "p,f:p:g, p, 2px, p, f:p:g"));
    upDownPanel.add(dumpMappingBtn, cc.xy(1, 1));
    upDownPanel.add(upBtn, cc.xy(1, 3));
    upDownPanel.add(downBtn, cc.xy(1, 5));

    PanelBuilder middlePanel = new PanelBuilder(new FormLayout("c:p:g", "p, 2px, p"));
    middlePanel.add(mapToBtn, cc.xy(1, 1));
    middlePanel.add(unmapBtn, cc.xy(1, 3));

    btnPanel = middlePanel.getPanel();
    btnPanel.setOpaque(false);

    PanelBuilder outerMiddlePanel = new PanelBuilder(new FormLayout("c:p:g", "f:p:g, p, f:p:g"));
    outerMiddlePanel.add(btnPanel, cc.xy(1, 2));
    outerMiddlePanel.getPanel().setOpaque(false);

    // Main Pane Layout
    PanelBuilder builder = new PanelBuilder(
            new FormLayout("f:max(200px;p):g, 5px, max(200px;p), 5px, p:g, 5px, f:max(250px;p):g, 2px, p",
                    "p, 2px, f:max(350px;p):g"),
            mainLayoutPanel);

    builder.add(createLabel(dataTypeLabel, SwingConstants.CENTER), cc.xy(1, 1));
    builder.add(createLabel(fieldsLabel, SwingConstants.CENTER), cc.xy(3, 1));
    builder.add(labelsBldr.getPanel(), cc.xy(7, 1));

    builder.add(tableScrollPane, cc.xy(1, 3));
    builder.add(fieldScrollPane, cc.xy(3, 3));

    builder.add(outerMiddlePanel.getPanel(), cc.xy(5, 3));

    builder.add(mapScrollPane, cc.xy(7, 3));
    builder.add(upDownPanel.getPanel(), cc.xy(9, 3));

    mainLayoutPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JPanel megaPanel = new JPanel(new BorderLayout());
    megaPanel.add(mainLayoutPanel, BorderLayout.CENTER);
    descriptionLbl = createLabel("  ", SwingConstants.LEFT);
    //PanelBuilder descBuilder = new PanelBuilder(new FormLayout("f:p:g, 3dlu","p"));
    //descBuilder.add(descriptionLbl, cc.xy(1, 1));
    //megaPanel.add(descBuilder.getPanel(), BorderLayout.SOUTH);
    megaPanel.add(descriptionLbl, BorderLayout.SOUTH);
    //contentPanel = mainLayoutPanel;
    contentPanel = megaPanel;

    Color bgColor = btnPanel.getBackground();
    int inc = 16;
    btnPanelColor = new Color(Math.min(255, bgColor.getRed() + inc), Math.min(255, bgColor.getGreen() + inc),
            Math.min(255, bgColor.getBlue() + inc));
    btnPanel.setBackground(btnPanelColor);
    btnPanel.setBorder(BorderFactory.createEmptyBorder(4, 6, 4, 6));

    okBtn.setEnabled(false);

    HelpMgr.registerComponent(helpBtn, helpContext);

    if (dataFileInfo != null) {
        autoMapFromDataFile(dataFileInfo.getColInfo());
    }
    if (workbenchTemplate != null) {
        fillFromTemplate();
        setChanged(false);
    }

    mainPanel.add(contentPanel, BorderLayout.CENTER);

    if (dataFileInfo == null) //can't add new mappings when importing.
    {
        FieldMappingPanel fmp = addMappingItem(null,
                IconManager.getIcon("BlankIcon", IconManager.STD_ICON_SIZE), null);
        fmp.setAdded(true);
        fmp.setNew(true);
    }

    pack();

    SwingUtilities.invokeLater(new Runnable() {
        @SuppressWarnings("synthetic-access")
        public void run() {
            cancelBtn.requestFocus();
            fieldModel.clear();
            fieldList.clearSelection();
            updateFieldDescription();
            updateEnabledState();

            if (mapModel.size() > 1) {
                mapList.clearSelection();
            }
        }
    });
}

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

/**
 * Create the frame./*from www . j  a v a2s  . co m*/
 */

@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:de.codesourcery.flocking.KDTree.java

public static void main(String[] args) {
    final KDTree<Vec2d> tree = new KDTree<Vec2d>();

    Random rnd = new Random(System.currentTimeMillis());
    for (int i = 0; i < 100; i++) {
        final double x = rnd.nextDouble() * MODEL_WIDTH;
        final double y = rnd.nextDouble() * MODEL_HEIGHT;
        tree.add(x, y, new Vec2d(x, y));
    }/*from ww w .j a v a 2  s. c  om*/

    final MyPanel panel = new MyPanel(tree);

    panel.setPreferredSize(new Dimension((int) MODEL_WIDTH * 2, (int) MODEL_HEIGHT * 2));

    panel.addMouseListener(new MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent e) {
            final Vec2d p = panel.viewToModel(e.getX(), e.getY());
            panel.mark(p.x, p.y, 55);
        };
    });

    final JFrame frame = new JFrame("KDTreeTest");

    frame.addKeyListener(new KeyAdapter() {

        public void keyTyped(java.awt.event.KeyEvent e) {
        };
    });
    frame.getContentPane().setLayout(new GridBagLayout());
    final GridBagConstraints cnstrs = new GridBagConstraints();
    cnstrs.fill = GridBagConstraints.BOTH;
    cnstrs.gridx = GridBagConstraints.REMAINDER;
    cnstrs.gridy = GridBagConstraints.REMAINDER;
    cnstrs.weightx = 1.0;
    cnstrs.weighty = 1.0;
    frame.getContentPane().add(panel, cnstrs);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}

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  . j av 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();
}

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private void init() {
    Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {

        @Override/* w ww. j  a  va  2s.c  om*/
        public void uncaughtException(Thread arg0, Throwable arg1) {
            GuiUtil.handleProblem(arg1);
        }
    });

    intervalMenu = new IntervalMenu();
    control = new JSynSoundControl();
    masterLevelController = new MasterLevelController(control);
    initMediator();
    wireButtons();
    layoutComponents();
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            exitPressed();
        }
    });

    initButtonIcons();
    createPanner();
    addMenu();
    initSettings();

    addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.isControlDown() && e.getClickCount() == 1) {
                openBrowser(getLocalDocAddress());
            }
        }
    });
}

From source file:com.mirth.connect.client.ui.alert.AlertChannelPane.java

private void initComponents() {
    setBackground(UIConstants.BACKGROUND_COLOR);
    setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Channels"));
    setLayout(new MigLayout("insets 0", "[grow][grow]", "[][][grow]"));

    filterLabel = new JLabel("Filter: ");
    filterTextField = new JTextField();
    filterTextField.addKeyListener(new KeyListener() {

        @Override//  ww  w .j a v a  2s  . c  o m
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            updateFilter(filterTextField.getText());
        }

    });

    expandLabel = new JLabel("<html><u>Expand All</u></html>");
    expandLabel.setForeground(Color.blue);
    expandLabel.setToolTipText("Expand all nodes below.");
    expandLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    expandLabel.addMouseListener(new MouseAdapter() {
        public void mouseReleased(MouseEvent evt) {
            channelTreeTable.expandAll();
        }
    });

    collapseLabel = new JLabel("<html><u>Collapse All</u></html>");
    collapseLabel.setForeground(Color.blue);
    collapseLabel.setToolTipText("Collapse all nodes below.");
    collapseLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    collapseLabel.addMouseListener(new MouseAdapter() {
        public void mouseReleased(MouseEvent evt) {
            channelTreeTable.collapseAll();
        }
    });

    enableButton = new JButton("Enable");
    enableButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            toggleSelectedRows(true);
            PlatformUI.MIRTH_FRAME.setSaveEnabled(true);
        }

    });

    disableButton = new JButton("Disable");
    disableButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            toggleSelectedRows(false);
            PlatformUI.MIRTH_FRAME.setSaveEnabled(true);
        }

    });

    channelTreeTable = new MirthTreeTable();

    channelScrollPane = new JScrollPane(channelTreeTable);

    add(filterLabel, "span 2, split");
    add(filterTextField, "growx, span, wrap");
    add(enableButton, "split 2, alignx left, width 50");
    add(disableButton, "alignx left, width 50");
    add(expandLabel, "split 2, alignx right");
    add(collapseLabel, "alignx right, wrap");
    add(channelScrollPane, "height 100:100:, width 100:100:, grow, span");
}

From source file:com.xtructure.xevolution.gui.XEvolutionGui.java

/**
 * Adds the graph./*from  w  w w  .j av  a  2  s  .c om*/
 * 
 * @param valueId
 *            the value id
 * @return the graph
 */
private Graph addGraph(final XValId<?> valueId) {
    final Graph g = new Graph(valueId.getBase(), bufferSize, bufferCount);
    graphsMap.put(valueId, g);
    g.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getSource() instanceof Graph) {
                Graph g = (Graph) e.getSource();
                int index = g.getHighlightIndex();
                if (index >= 0) {
                    tabbedPane.setSelectedIndex(GENERATIONS_INDEX);
                    populationPanel.getComboBox().setSelectedIndex(index);
                    genomePanel.sortBy(valueId);
                }
            }
        }
    });
    // just show the first graph
    menuBar.addGraphCheckbox(g, graphPanel, graphsMap.size() == 1);
    genomePanel.addSortByAttributeId(valueId);
    return g;
}

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

/**
 * @return/*w  w w. ja v a2s.  c  om*/
 * @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:com.sshtools.sshterm.SshTerminalPanel.java

public void init(SshToolsApplication application) throws SshToolsApplicationException {
    super.init(application);
    boolean kerb_support = false;
    if (PreferencesStore.get(PREF_KRB5_MYPROXY_USE, "NONE").indexOf("true") >= 0)
        kerb_support = true;/*from w  ww  .j  a  v a 2 s. c o m*/

    //  Additional connection tabs
    if (kerb_support == true) {
        additionalTabs = new SshToolsConnectionTab[] { new SshTermCommandTab(), new SshTermTerminalTab(),
                new GSIAuthTab(), new XForwardingTab(), new SshToolsConnectionKerberosTab() };
        SshTerminalPanel.PREF_KRB5_MYPROXY_ENABLED = true;
    } else {
        additionalTabs = new SshToolsConnectionTab[] { new SshTermCommandTab(), new SshTermTerminalTab(),
                new GSIAuthTab(), new XForwardingTab() };
        SshTerminalPanel.PREF_KRB5_MYPROXY_ENABLED = false;

    }
    //
    //portForwardingPane = new PortForwardingPane();

    //  Printing page format
    try {
        if (System.getSecurityManager() != null) {
            AccessController.checkPermission(new RuntimePermission("queuePrintJob"));
        }

        try {
            PrinterJob job = PrinterJob.getPrinterJob();

            if (job == null) {
                throw new IOException("Could not get print page format.");
            }

            pageFormat = job.defaultPage();

            if (PreferencesStore.preferenceExists(PREF_PAGE_FORMAT_ORIENTATION)) {
                pageFormat.setOrientation(
                        PreferencesStore.getInt(PREF_PAGE_FORMAT_ORIENTATION, PageFormat.LANDSCAPE));

                Paper paper = new Paper();
                paper.setImageableArea(PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_X, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_Y, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_W, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_H, 0));
                paper.setSize(PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_W, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_H, 0));
                pageFormat.setPaper(paper);
            }
        } catch (Exception e) {
            showExceptionMessage("Error", e.getMessage());
        }
    } catch (AccessControlException ace) {
        ace.printStackTrace();
    }

    enableEvents(VDU_EVENTS);

    // Set up the actions
    initActions();

    // Create the status bar
    statusBar = new StatusBar();

    dataListener = new DataNotificationListener(statusBar);

    // Create our terminal emulation object
    try {
        emulation = createEmulation();
    } catch (IOException ioe) {
        throw new SshToolsApplicationException(ioe);
    }

    emulation.addTerminalListener(this);

    // Set a scrollbar for the terminal - doesn't seem to be as simple as this
    scrollBar = new JScrollBar(JScrollBar.VERTICAL);
    emulation.setBufferSize(1000);

    // Create our swing terminal and add it to the main frame
    terminal = new TerminalPanel(emulation) {
        public void processEvent(AWTEvent evt) {
            /** We can't add a MouseWheelListener because it was not available in 1.3, so direct processing of events is necessary */
            if (evt instanceof MouseEvent && evt.getID() == 507) {
                try {
                    Method m = evt.getClass().getMethod("getWheelRotation", new Class[] {});
                    SshTerminalPanel.this.scrollBar.setValue(SshTerminalPanel.this.scrollBar.getValue()
                            + (SshTerminalPanel.this.scrollBar.getUnitIncrement()
                                    * ((Integer) m.invoke(evt, new Object[] {})).intValue()
                                    * PreferencesStore.getInt(PREF_MOUSE_WHEEL_INCREMENT, 1)));

                } catch (Throwable t) {
                    //   In theory, this should never happen
                }
            } else {
                super.processEvent(evt);
            }
        }

        public void copyNotify() {
            copyAction.actionPerformed(null);
        }

    };
    terminal.requestFocus();
    terminal.setScrollbar(scrollBar);
    terminal.addMouseMotionListener(this);

    //terminal.addMouseWheelListener(this);
    // Center panel with terminal and scrollbar
    JPanel center = new JPanel(new BorderLayout());
    center.setBackground(Color.red);
    center.add(terminal, BorderLayout.CENTER);
    center.add(scrollBar, BorderLayout.EAST);

    // Show the context menu on mouse button 3 (right click)
    terminal.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            if ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) > 0) {
                getContextMenu()
                        .setLabel((getCurrentConnectionFile() == null) ? getApplication().getApplicationName()
                                : getCurrentConnectionFile().getName());
                getContextMenu().show(terminal, evt.getX(), evt.getY());
            } else if ((evt.getModifiers() & MouseEvent.BUTTON2_MASK) > 0) {
                pasteAction.actionPerformed(null);
            }
        }
    });

    //
    //        JPanel top = new JPanel(new BorderLayout());
    //        top.add(getJMenuBar(), BorderLayout.NORTH);
    //        top.add(north, BorderLayout.SOUTH);
    setLayout(new BorderLayout());
    add(center, BorderLayout.CENTER);

    //        add(top, BorderLayout.NORTH);
    // Make sure that the swing terminal has focus
    terminal.requestFocus();
}

From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java

/**
 * Creates new form TribeTribeAttackFrame
 *//*from   w w  w  .  j av a 2s.com*/
public TribeTribeAttackFrame() {
    initComponents();
    centerPanel = new GenericTestPanel();
    jMainPanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.setChildComponent(jxAttackPlanerPanel);
    buildMenu();
    capabilityInfoPanel1.addActionListener(this, jSourcesTable);
    capabilityInfoPanel2.addActionListener(this, jResultsTable);

    KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false);
    KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
    KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false);
    KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK, false);
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    jSourcesTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Copy", copy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jVictimTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Copy", copy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jResultsTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Copy", copy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jSourcesTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Paste", paste,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jVictimTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Paste", paste,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jSourcesTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Cut", cut,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jVictimTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Cut", cut,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jSourcesTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Delete", delete,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jVictimTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Delete", delete,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jResultsTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Delete", delete,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    jResultsTable.registerKeyboardAction(TribeTribeAttackFrame.this, "BBCopy", bbCopy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    Action noFind = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //no find
        }
    };
    jSourcesTable.getActionMap().put("find", noFind);
    jVictimTable.getActionMap().put("find", noFind);
    jResultsTable.getActionMap().put("find", noFind);

    jSourcesTable.getSelectionModel().addListSelectionListener(TribeTribeAttackFrame.this);
    jVictimTable.getSelectionModel().addListSelectionListener(TribeTribeAttackFrame.this);
    jResultsTable.getSelectionModel().addListSelectionListener(TribeTribeAttackFrame.this);

    jideTabbedPane1.setTabShape(JideTabbedPane.SHAPE_OFFICE2003);
    jideTabbedPane1.setTabColorProvider(JideTabbedPane.ONENOTE_COLOR_PROVIDER);
    jideTabbedPane1.setBoldActiveTab(true);
    TagManager.getSingleton().addManagerListener(TribeTribeAttackFrame.this);
    logPanel = new AlgorithmLogPanel();
    mLogFrame = new JFrame("Informationen zur Berechnung");
    mLogFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    mLogFrame.setLayout(new BorderLayout());
    mLogFrame.add(logPanel);
    mLogFrame.pack();
    mTroopSplitDialog = new TroopSplitDialog(TribeTribeAttackFrame.this, true);
    mSettingsPanel = new SettingsPanel(this);
    jSettingsContentPanel.add(mSettingsPanel, BorderLayout.CENTER);
    jAttackResultDetailsFrame.pack();
    jTargetResultDetailsFrame.pack();
    dragSource = DragSource.getDefaultDragSource();
    dragSource.createDefaultDragGestureRecognizer(TribeTribeAttackFrame.this, DnDConstants.ACTION_COPY_OR_MOVE,
            TribeTribeAttackFrame.this);
    new DropTarget(jSourcesTable, TribeTribeAttackFrame.this);
    new DropTarget(jVictimTable, TribeTribeAttackFrame.this);
    for (MouseListener l : jAllTargetsComboBox.getMouseListeners()) {
        jAllTargetsComboBox.removeMouseListener(l);
    }
    jAllTargetsComboBox.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            fireAddFilteredTargetVillages();
        }
    });

    filterDialog = new TroopFilterDialog(this, true);

    // <editor-fold defaultstate="collapsed" desc="Add selection listeners">
    jVillageGroupList.addListSelectionListener(new ListSelectionListener() {

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

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

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

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                fireFilterTargetByContinentEvent();
            }
        }
    });

    jTargetAllyList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                fireFilterTargetByAllyEvent();
            }
        }
    });
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelp(jSourcePanel, "pages.attack_planer_source",
                GlobalOptions.getHelpBroker().getHelpSet());
        GlobalOptions.getHelpBroker().enableHelp(jTargetPanel, "pages.attack_planer_target",
                GlobalOptions.getHelpBroker().getHelpSet());
        GlobalOptions.getHelpBroker().enableHelp(mSettingsPanel, "pages.attack_planer_settings",
                GlobalOptions.getHelpBroker().getHelpSet());
        GlobalOptions.getHelpBroker().enableHelpKey(jResultFrame.getRootPane(), "pages.attack_planer_results",
                GlobalOptions.getHelpBroker().getHelpSet());
        GlobalOptions.getHelpBroker().enableHelpKey(jTargetResultDetailsFrame.getRootPane(),
                "pages.attack_planer_results_details_targets", GlobalOptions.getHelpBroker().getHelpSet());
        GlobalOptions.getHelpBroker().enableHelpKey(jAttackResultDetailsFrame.getRootPane(),
                "pages.attack_planer_results_details_sources", GlobalOptions.getHelpBroker().getHelpSet());
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.attack_planer",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    // </editor-fold>
}