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:corelyzer.ui.CorelyzerApp.java

private void setupUI() {
    String versionNumber = CorelyzerApp.getApp().getCorelyzerVersion();
    if ((versionNumber == null) || versionNumber.equals("")) {
        versionNumber = "undetermined";
    }//from  w w  w .  j av  a  2  s .c o m

    this.baseTitle = "Corelyzer " + versionNumber;

    mainFrame = new JFrame(baseTitle);
    mainFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    mainFrame.setSize(320, 100);
    mainFrame.setLocation(600, 100);
    mainFrame.addWindowListener(this);

    GridLayout layout = new GridLayout(1, 1);
    mainFrame.getContentPane().setLayout(layout);

    rootPanel = new JPanel(new GridLayout(1, 5));
    rootPanel.setBorder(BorderFactory.createTitledBorder("Main Panel"));

    // add lists/panels
    JPanel sessionPanel = new JPanel(new GridLayout(1, 1));
    sessionPanel.setBorder(BorderFactory.createTitledBorder("Session"));
    sessionList = new JList(getSessionListModel());
    sessionList.setName("SessionList");
    sessionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    sessionList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(final ListSelectionEvent event) {
            int idx = sessionList.getSelectedIndex();
            if (idx >= 0) {
                CoreGraph cg = CoreGraph.getInstance();
                cg.setCurrentSessionIdx(idx);
            }
        }
    });
    sessionList.addMouseListener(this);
    JScrollPane sessionScrollPane = new JScrollPane(sessionList);
    sessionPanel.add(sessionScrollPane);
    rootPanel.add(sessionPanel);

    JPanel trackPanel = new JPanel(new GridLayout(1, 1));
    trackPanel.setBorder(BorderFactory.createTitledBorder("Track"));
    trackList = new JList(getTrackListModel());
    trackList.setName("TrackList");
    trackList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    trackList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(final ListSelectionEvent event) {
            int idx = trackList.getSelectedIndex();
            if (idx >= 0) {
                CoreGraph cg = CoreGraph.getInstance();
                cg.setCurrentTrackIdx(idx);
                updateHighlightedSections();
            }
        }
    });
    trackList.addMouseListener(this);
    JScrollPane trackScrollPane = new JScrollPane(trackList);
    trackPanel.add(trackScrollPane);
    rootPanel.add(trackPanel);

    JPanel sectionsPanel = new JPanel(new GridLayout(1, 1));
    sectionsPanel.setBorder(BorderFactory.createTitledBorder("Sections"));
    sectionList = new JList(getSectionListModel());
    sectionList.setName("SectionList");
    sectionList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(final ListSelectionEvent event) {
            if (event.getValueIsAdjusting())
                return;
            updateHighlightedSections();
        }
    });
    sectionList.addMouseListener(this);
    JScrollPane sectionsScrollPane = new JScrollPane(sectionList);
    sectionsPanel.add(sectionsScrollPane);
    rootPanel.add(sectionsPanel);

    JPanel dataFilesPanel = new JPanel(new GridLayout(1, 1));
    dataFilesPanel.setBorder(BorderFactory.createTitledBorder("Data Files"));
    dataFileList = new JList(getDataFileListModel());
    dataFileList.setName("DatafileList");
    dataFileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dataFileList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(final ListSelectionEvent event) {
            int idx = dataFileList.getSelectedIndex();
            if (idx >= 0) {
                CoreGraph cg = CoreGraph.getInstance();
                cg.setCurrentDatasetIdx(idx);
            }
        }
    });
    dataFileList.addMouseListener(this);
    JScrollPane dataFilesScrollPane = new JScrollPane(dataFileList);
    dataFilesPanel.add(dataFilesScrollPane);
    rootPanel.add(dataFilesPanel);

    JPanel fieldsPanel = new JPanel(new GridLayout(1, 1));
    fieldsPanel.setBorder(BorderFactory.createTitledBorder("Fields"));
    fieldList = new JList(getFieldListModel());
    fieldList.setName("FieldList");
    fieldList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    fieldList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(final ListSelectionEvent event) {
            int idx = fieldList.getSelectedIndex();
            if (idx >= 0) {
                CoreGraph cg = CoreGraph.getInstance();
                cg.setCurrentFieldIdx(idx);
            }
        }
    });
    JScrollPane fieldsScrollPane = new JScrollPane(fieldList);
    fieldsPanel.add(fieldsScrollPane);
    rootPanel.add(fieldsPanel);

    mainFrame.getContentPane().add(rootPanel);

    setupMenuStuff();
    setupPopupMenu();

    // init new mode tool frame
    toolFrame = new CRToolPalette();
    toolFrame.pack();
    int canvasWidth = preferences().screenWidth;
    Dimension mydim = toolFrame.getSize();
    int myLocX = canvasWidth / 2 - mydim.width / 2;
    toolFrame.setLocation(myLocX, 0);
    toolFrame.setVisible(true);

    // delete key listener on track and section list
    KeyListener listKeyListener = new KeyListener() {
        public void keyPressed(final KeyEvent keyEvent) {
        }

        public void keyReleased(final KeyEvent keyEvent) {

            int keyCode = keyEvent.getKeyCode();

            if (keyCode == KeyEvent.VK_DELETE) {
                Object actionSource = keyEvent.getSource();

                if (actionSource.equals(trackList)) {
                    controller.deleteSelectedTrack();
                } else if (actionSource.equals(sectionList)) {
                    int[] rows = getSectionList().getSelectedIndices();
                    onDeleteSelectedSections(rows);
                }
            }
        }

        public void keyTyped(final KeyEvent keyEvent) {
        }
    };

    trackList.addKeyListener(listKeyListener);
    sectionList.addKeyListener(listKeyListener);
}

From source file:edu.ku.brc.ui.UIHelper.java

public static JList createList(final ListModel model) {
    @SuppressWarnings("unchecked")
    JList lst = new JList(model);
    if (isMacOS_10_5_X) {
        lst.putClientProperty("JComboBox.isPopDown", Boolean.TRUE);
    }//from w  w w. j av  a  2  s .co  m
    return lst;
}

From source file:edu.ku.brc.ui.UIHelper.java

public static JList createList(final Vector<?> items) {
    @SuppressWarnings("unchecked")
    JList lst = new JList(items);
    if (isMacOS_10_5_X) {
        lst.putClientProperty("JComboBox.isPopDown", Boolean.TRUE);
    }/* ww  w.java2s.  c om*/
    return lst;
}

From source file:fs.MainWindow.java

public void GenerateTable(Object[][] data, String title, String subtitle, final String[] titles) {
    JFrame window = new JFrame(title);
    window.setLayout(new java.awt.BorderLayout(5, 5));
    JLabel label = new JLabel(subtitle);
    label.setFont(new java.awt.Font("Tahoma", 1, 12));
    label.setForeground(new java.awt.Color(0, 0, 255));
    label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    label.setOpaque(true);//w w w.  ja v  a 2  s  . c o  m
    label.setPreferredSize(new java.awt.Dimension(50, 30));

    ListModel lm = new AbstractListModel() {

        String headers[] = titles;

        @Override
        public int getSize() {
            return headers.length;
        }

        @Override
        public Object getElementAt(int index) {
            return headers[index];
        }
    };

    //        String[] titles = getClasses();
    JList rowHeader = new JList(lm);
    rowHeader.setFixedCellWidth(50);
    JTable jTable = new JTable(data, titles);
    rowHeader.setFixedCellHeight(jTable.getRowHeight());
    rowHeader.setCellRenderer(new RowHeaderRenderer(jTable));
    JScrollPane scroll = new JScrollPane(jTable);
    scroll.setRowHeaderView(rowHeader);
    getContentPane().add(scroll, BorderLayout.CENTER);

    jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    jTable.setAlignmentX(JTable.CENTER_ALIGNMENT);

    window.add(label, java.awt.BorderLayout.NORTH);
    window.add(scroll, java.awt.BorderLayout.CENTER);

    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    window.setBounds((screenSize.width - 800) / 2, (screenSize.height - 270) / 2, 800, 270);
    window.setVisible(true);
}

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

/**
 * @return/*from ww  w  .  j av a  2  s .c  o m*/
 * @throws SQLException
 */
private Pair<String, String> chooseTable() throws SQLException {
    MySQLDMBSUserMgr mgr = new MySQLDMBSUserMgr();

    final Vector<DBNamePair> availOldPairs = new Vector<DBNamePair>();
    final Vector<DBNamePair> availNewPairs = new Vector<DBNamePair>();

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

            Connection conn = mgr.getConnection();
            Vector<Object[]> dbNames = BasicSQLUtils.query(conn, "show databases");
            for (Object[] row : dbNames) {
                System.err.println("Setting [" + row[0].toString() + "] ");
                conn.setCatalog(row[0].toString());

                boolean isSp5 = false;
                boolean isSp6 = false;

                Vector<Object[]> tables = BasicSQLUtils.query(conn, "show tables");
                for (Object[] tblRow : tables) {
                    if (row[0].toString().equals("debugdb")) {
                        System.err.println(tblRow[0].toString());
                    }
                    if (tblRow[0].toString().equals("usysversion")) {
                        isSp5 = true;
                        break;

                    } else if (tblRow[0].toString().equals("gift")) {
                        isSp6 = true;
                        break;
                    }
                }

                if (isSp5 || isSp6) {
                    String collName = null;
                    Vector<Object[]> tableDesc = BasicSQLUtils.query(conn,
                            "SELECT CollectionName FROM collection");
                    if (tableDesc.size() > 0) {
                        collName = tableDesc.get(0)[0].toString();
                    }

                    if (collName == null) {
                        continue;
                    }

                    if (isSp5) {
                        availOldPairs.add(new DBNamePair(collName, row[0].toString()));
                    } else {
                        availNewPairs.add(new DBNamePair(collName, row[0].toString()));
                    }
                }

                System.err.println("isSp5 [" + isSp5 + "] isSp6 [" + isSp6 + "] ");
            }

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

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

            final JList oldlist = new JList(availOldPairs);
            final JList newList = new JList(availNewPairs);
            CellConstraints cc = new CellConstraints();
            PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g,10px,f:p:g", "p,2px,f:p:g,4px,p"));
            pb.addSeparator("Specify 5 Databases", cc.xy(1, 1));
            pb.add(UIHelper.createScrollPane(oldlist), cc.xy(1, 3));

            pb.addSeparator("Specify 6 Databases", cc.xy(3, 1));
            pb.add(UIHelper.createScrollPane(newList), cc.xy(3, 3));

            ArrayList<String> list = new ArrayList<String>(labels.length);
            for (String s : labels) {
                list.add(s);
            }
            chkPanel = new ToggleButtonChooserPanel<String>(list, Type.Checkbox);
            chkPanel.setUseScrollPane(true);
            chkPanel.createUI();
            //pb.add(chkPanel, cc.xyw(1, 5, 3));

            /*ActionListener al = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e)
            {
                boolean isSelected = chkPanel.getButtons().get(0).isSelected();
                int inx = chkPanel.getSelectedIndex();
                if (inx == 0)
                {
                    Vector<JToggleButton> btns = chkPanel.getButtons();
                    for (int i=1;i<btns.size();i++)
                    {
                        btns.get(i).setEnabled(!isSelected);
                    }
                } 
            }
            };
                    
            chkPanel.getButtons().get(0).addActionListener(al);
            chkPanel.getButtons().get(chkPanel.getButtons().size()-1).addActionListener(al);*/

            ListSelectionListener oldDBListener = new ListSelectionListener() {
                @Override
                public void valueChanged(ListSelectionEvent e) {
                    if (!e.getValueIsAdjusting()) {
                        DBNamePair pair = (DBNamePair) oldlist.getSelectedValue();
                        if (pair != null) {
                            int index = 0;
                            for (DBNamePair p : availNewPairs) {
                                if (p.second.startsWith(pair.second)) {
                                    final int inx = index;
                                    SwingUtilities.invokeLater(new Runnable() {
                                        @Override
                                        public void run() {
                                            newList.setSelectedIndex(inx);
                                            newList.ensureIndexIsVisible(inx);
                                        }
                                    });
                                }
                                index++;
                            }
                        }
                    }
                }
            };

            oldlist.getSelectionModel().addListSelectionListener(oldDBListener);

            MouseAdapter ma = new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    super.mouseClicked(e);

                    Vector<JToggleButton> btns = chkPanel.getButtons();
                    if (e.getSource() == btns.get(0)) {
                        boolean isSelected = btns.get(0).isSelected();

                        for (int i = 1; i < btns.size(); i++) {
                            btns.get(i).setEnabled(!isSelected);
                        }
                    } else if (e.getSource() == btns.get(btns.size() - 1)) {
                        boolean isSelected = btns.get(btns.size() - 1).isSelected();
                        for (int i = 0; i < btns.size() - 1; i++) {
                            if (i > 0)
                                btns.get(i).setSelected(!isSelected);
                            btns.get(i).setEnabled(!isSelected);
                        }
                    }
                }
            };
            chkPanel.getButtons().get(0).addMouseListener(ma);
            chkPanel.getButtons().get(chkPanel.getButtons().size() - 1).addMouseListener(ma);

            /*ChangeListener cl = new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e)
            {
                Vector<JToggleButton> btns = chkPanel.getButtons();
                if (e.getSource() == btns.get(0))
                {
                    boolean isSelected = btns.get(0).isSelected();
                    System.out.println(isSelected);
                            
                    for (int i=1;i<btns.size();i++)
                    {
                        btns.get(i).setEnabled(!isSelected);
                    }
                } else if (e.getSource() == btns.get(btns.size()-1))
                {
                    boolean isSelected = btns.get(0).isSelected();
                    System.out.println(isSelected);
                            
                    for (int i=0;i<btns.size()-1;i++)
                    {
                        btns.get(i).setEnabled(!isSelected);
                    }
                }
            }
            };
            chkPanel.getButtons().get(0).addChangeListener(cl);
            chkPanel.getButtons().get(chkPanel.getButtons().size()-1).addChangeListener(cl);*/

            pb.setDefaultDialogBorder();

            final CustomDialog dlg = new CustomDialog(null, "Select a DB to Verify", true, pb.getPanel());

            ListSelectionListener lsl = new ListSelectionListener() {
                @Override
                public void valueChanged(ListSelectionEvent e) {
                    if (!e.getValueIsAdjusting()) {
                        dlg.getOkBtn().setEnabled(oldlist.getSelectedIndex() > -1);
                    }
                }
            };
            oldlist.addListSelectionListener(lsl);
            newList.addListSelectionListener(lsl);

            oldlist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            newList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

            MouseAdapter listMA = new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    if (e.getClickCount() == 2) {
                        dlg.getOkBtn()
                                .setEnabled(oldlist.getSelectedIndex() > -1 && newList.getSelectedIndex() > -1);
                        dlg.getOkBtn().doClick();
                    }
                }
            };
            oldlist.addMouseListener(listMA);
            newList.addMouseListener(listMA);

            dlg.createUI();
            dlg.pack();
            //dlg.setSize(300, 800);
            dlg.pack();
            dlg.setVisible(true);
            if (dlg.isCancelled()) {
                return null;
            }

            DBNamePair oldPair = (DBNamePair) oldlist.getSelectedValue();
            namePairToConvert = (DBNamePair) newList.getSelectedValue();
            namePairToConvert.first = oldPair.second;
            return namePairToConvert;
        }
    } catch (Exception ex) {

    }
    return null;
}

From source file:de.main.sessioncreator.DesktopApplication1View.java

public void getAreasBacgroundW(File f) {
    fileHelper.getAreas(f);//from   w ww. j  a  va  2s .  co  m
    Iterator<Map.Entry<String, List>> it = fileHelper.areaMap.entrySet().iterator();
    while (it.hasNext()) {
        DefaultListModel dlm = new DefaultListModel();
        JList list = new JList(dlm);
        list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        JScrollPane scrollPane = new JScrollPane(list);
        scrollPane.getViewport().setView(list);
        Map.Entry en = it.next();
        wizardtabpAreas.addTab(en.getKey().toString().substring(3), scrollPane);
        for (Object o : fileHelper.areaMap.get(en.getKey().toString())) {
            dlm.addElement(o);
        }
        MouseListener mouseListener = new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent mouseEvent) {
                JList tabList = (JList) mouseEvent.getSource();
                if (mouseEvent.getClickCount() == 2) {
                    int index = tabList.locationToIndex(mouseEvent.getPoint());
                    if (index >= 0) {
                        Object o = tabList.getModel().getElementAt(index);
                        wizardtaChoosenAreas.append(o.toString() + "\n");
                    }
                }
            }
        };
        list.addMouseListener(mouseListener);
        ListSelectionListener listListener = new ListSelectionListener() {

            public void valueChanged(ListSelectionEvent e) {
                JList list = (JList) e.getSource();
                if (e.getValueIsAdjusting() == false) {

                    if (list.getSelectedIndex() == -1) {
                        //No selection, disable add button.
                        wizardbtnAddAreas.setEnabled(false);

                    } else {
                        //Selection, enable the add button.
                        wizardbtnAddAreas.setEnabled(true);
                    }
                }
            }
        };
        list.addListSelectionListener(listListener);
    }
}

From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java

/**
 * @param parentList//from w  w w  .  j av a  2s .co  m
 */
protected void fillNextList(final JList parentList) {
    if (processingLists) {
        return;
    }

    processingLists = true;

    final int curInx = listBoxList.indexOf(parentList);
    if (curInx > -1) {
        int startSize = listBoxPanel.getComponentCount();
        for (int i = curInx + 1; i < listBoxList.size(); i++) {
            listBoxPanel.remove(spList.get(i));
        }
        int removed = startSize - listBoxPanel.getComponentCount();
        for (int i = 0; i < removed; i++) {
            tableTreeList.remove(tableTreeList.size() - 1);
        }

    } else {
        listBoxPanel.removeAll();
        tableTreeList.clear();
    }

    QryListRendererIFace item = (QryListRendererIFace) parentList.getSelectedValue();
    if (item instanceof ExpandableQRI) {
        JList newList;
        DefaultListModel model;
        JScrollPane sp;

        if (curInx == listBoxList.size() - 1) {
            newList = new JList(model = new DefaultListModel());
            newList.addMouseListener(new MouseAdapter() {

                /* (non-Javadoc)
                 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
                 */
                @Override
                public void mouseClicked(MouseEvent e) {
                    if (e.getClickCount() == 2) {
                        if (currentInx != -1) {
                            JList list = (JList) e.getSource();
                            QryListRendererIFace qriFace = (QryListRendererIFace) list.getSelectedValue();
                            if (BaseQRI.class.isAssignableFrom(qriFace.getClass())) {
                                BaseQRI qri = (BaseQRI) qriFace;
                                if (qri.isInUse()) {
                                    //remove the field
                                    for (QueryFieldPanel qfp : QueryBldrPane.this.queryFieldItems) {
                                        FieldQRI fqri = qfp.getFieldQRI();
                                        if (fqri == qri || (fqri instanceof RelQRI && fqri.getTable() == qri)) {
                                            boolean clearIt = qfp.getSchemaItem() != null;
                                            QueryBldrPane.this.removeQueryFieldItem(qfp);
                                            if (clearIt) {
                                                qfp.setField(null, null);
                                            }
                                            break;
                                        }
                                    }
                                } else {
                                    // add the field
                                    try {
                                        FieldQRI fieldQRI = buildFieldQRI(qri);
                                        if (fieldQRI == null) {
                                            throw new Exception("null FieldQRI");
                                        }
                                        SpQueryField qf = new SpQueryField();
                                        qf.initialize();
                                        qf.setFieldName(fieldQRI.getFieldName());
                                        qf.setStringId(fieldQRI.getStringId());
                                        query.addReference(qf, "fields");
                                        if (!isExportMapping) {
                                            addQueryFieldItem(fieldQRI, qf, false);
                                        } else {
                                            addNewMapping(fieldQRI, qf, null, false);
                                        }
                                    } catch (Exception ex) {
                                        log.error(ex);
                                        UsageTracker.incrHandledUsageCount();
                                        edu.ku.brc.exceptions.ExceptionTracker.getInstance()
                                                .capture(QueryBldrPane.class, ex);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            });
            newList.setCellRenderer(qryRenderer);
            listBoxList.add(newList);
            sp = new JScrollPane(newList, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            JLabel colHeader = UIHelper.createLabel(item.getTitle());
            colHeader.setHorizontalAlignment(SwingConstants.CENTER);
            colHeader.setBackground(listBoxPanel.getBackground());
            colHeader.setOpaque(true);

            sp.setColumnHeaderView(colHeader);

            spList.add(sp);

            newList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
                public void valueChanged(ListSelectionEvent e) {
                    if (!e.getValueIsAdjusting()) {
                        fillNextList(listBoxList.get(curInx + 1));
                    }
                }
            });

        } else {
            newList = listBoxList.get(curInx + 1);
            model = (DefaultListModel) newList.getModel();
            sp = spList.get(curInx + 1);
            JLabel colHeaderLbl = (JLabel) sp.getColumnHeader().getComponent(0);
            if (item instanceof TableQRI) {
                colHeaderLbl.setText(((TableQRI) item).getTitle());
            } else {
                colHeaderLbl.setText(getResourceString("QueryBldrPane.QueryFields"));
            }
        }

        createNewList((TableQRI) item, model);

        listBoxPanel.remove(addBtn);
        listBoxPanel.add(sp);
        tableTreeList.add(((ExpandableQRI) item).getTableTree());
        listBoxPanel.add(addBtn);
        currentInx = -1;

    } else {
        listBoxPanel.add(addBtn);
    }

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            updateAddBtnState();

            // Is all this really necessary
            listBoxPanel.validate();
            listBoxPanel.repaint();
            scrollPane.validate();
            scrollPane.invalidate();
            scrollPane.doLayout();
            scrollPane.repaint();
            validate();
            invalidate();
            doLayout();
            repaint();
            UIRegistry.forceTopFrameRepaint();
        }
    });

    processingLists = false;
    currentInx = curInx;

}

From source file:src.gui.ItSIMPLE.java

/**
 * @return the planListFramePanel/* w  w  w.ja v a  2  s  . c om*/
 */
private ItFramePanel getPlanListFramePanel() {
    if (planListFramePanel == null) {
        planListFramePanel = new ItFramePanel(":: Plan", ItFramePanel.MINIMIZE_MAXIMIZE);
        planListFramePanel.setParentSplitPane(planDetailsSplitPane);

        planListModel = new DefaultListModel();
        planList = new JList(planListModel);
        planList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                // this is done to enable or disable the remove plan action button
                if (planList.getSelectedIndex() < 0) {
                    removePlanActionButton.setEnabled(false);
                    editPlanActionButton.setEnabled(false);
                } else {
                    removePlanActionButton.setEnabled(true);
                    editPlanActionButton.setEnabled(true);
                }
            }
        });

        planList.addMouseListener(new MouseListener() {
            public void mouseClicked(MouseEvent e) {
                if (planList.getSelectedIndex() > 0 && e.getClickCount() == 2) {
                    editPlanAction.actionPerformed(null);
                }
            }

            public void mouseEntered(MouseEvent arg0) {
            }

            public void mouseExited(MouseEvent arg0) {
            }

            public void mousePressed(MouseEvent arg0) {
            }

            public void mouseReleased(MouseEvent arg0) {
            }

        });

        // initialize the buttons
        addPlanActionButton = new JButton(addPlanAction);
        addPlanActionButton.setToolTipText("Add an action to the plan");

        removePlanActionButton = new JButton(removePlanAction);
        removePlanActionButton.setToolTipText("Remove selected action");

        editPlanActionButton = new JButton(editPlanAction);
        editPlanActionButton.setToolTipText("Edit selected action");

        importPlanButton = new JButton(importPlanAction);
        importPlanButton.setToolTipText("Import plan from xml file");

        exportPlanButton = new JButton(exportPlanAction);
        exportPlanButton.setToolTipText("Export current plan");

        checkPlanValidityButton = new JButton(checkPlanValidity);
        checkPlanValidityButton.setToolTipText(
                "<html>Validate plan with validator VAL <br>(based on the generated PDDL model).</html>");

        //quickEvaluateButton = new JButton(quickEvaluation);
        //quickEvaluateButton.setToolTipText("Quick evaluation of the selected plan");

        //fullEvaluationButton = new JButton(generateEvaluatioReport);
        //fullEvaluationButton.setToolTipText("<html>Full evaluation of the selected plan. <br> Generate a plan evaluation in the planReport. <br> This is restricted to non-time-based domain only.</html>");
        //fullEvaluationButton.setText("");

        addPlanActionButton.setEnabled(false);
        removePlanActionButton.setEnabled(false);
        editPlanActionButton.setEnabled(false);
        checkPlanValidityButton.setEnabled(false);
        //quickEvaluateButton.setEnabled(false);
        //fullEvaluationButton.setEnabled(false);
        importPlanButton.setEnabled(false);
        exportPlanButton.setEnabled(false);

        JToolBar planListToolBar = new JToolBar();
        planListToolBar.add(addPlanActionButton);
        planListToolBar.add(removePlanActionButton);
        planListToolBar.add(editPlanActionButton);
        planListToolBar.addSeparator();
        planListToolBar.add(checkPlanValidityButton);
        //planListToolBar.add(quickEvaluateButton);
        //planListToolBar.add(fullEvaluationButton);
        planListToolBar.addSeparator();
        planListToolBar.add(importPlanButton);
        planListToolBar.add(exportPlanButton);

        JScrollPane listScrollPane = new JScrollPane(planList);

        JPanel listPanel = new JPanel(new BorderLayout());
        listPanel.add(listScrollPane, BorderLayout.CENTER);
        listPanel.add(planListToolBar, BorderLayout.SOUTH);

        planListFramePanel.setContent(listPanel, false);

    }

    return planListFramePanel;
}

From source file:src.gui.ItSIMPLE.java

/**
 * @return Returns the PetriContainer./* w w w.j a v a2  s. c  om*/
 */
private JXTaskPaneContainer getPetriContainer() {
    if (projectPetriContainer == null) {
        projectPetriContainer = new JXTaskPaneContainer();

        //project
        projectPetriTaskPane = new JXTaskPane();
        projectPetriTaskPane.setTitle("Project");
        projectPetriTaskPane.setIcon(new ImageIcon("resources/images/projects.png"));
        projectPetriTaskPane.setSpecial(true);

        //state chart diagrams
        stateMachinePetriTaskPane = new JXTaskPane();
        stateMachinePetriTaskPane.setTitle("State Chart Diagrams");
        stateMachinePetriTaskPane.setIcon(new ImageIcon("resources/images/planningProblem.png"));
        stateMachinePetriTaskPane.setLayout(new BorderLayout());
        stateMachinePetriPanel = new JPanel(new BorderLayout());

        stateMachineJList = new JList(new DefaultListModel());
        ItListRenderer renderer = new ItListRenderer();
        renderer.setIcon(new ImageIcon("resources/images/stateMachineDiagram.png"));
        stateMachineJList.setCellRenderer(renderer);

        stateMachinePetriPanel.add(stateMachineJList, BorderLayout.CENTER);
        JToolBar toolBar = new JToolBar();
        toolBar.setRollover(true);
        stateMachineButton = new JButton(openPetriNetGroup);
        toolBar.add(stateMachineButton);

        stateMachinePetriTaskPane.add(stateMachinePetriPanel, BorderLayout.CENTER);
        stateMachinePetriTaskPane.add(toolBar, BorderLayout.SOUTH);
        /*petriCheckBoxList = new CheckBoxList();
        stateMachinePetriTaskPane.add(petriCheckBoxList, BorderLayout.CENTER);*/

        //details
        detailPetriTaskPane = new JXTaskPane();
        detailPetriTaskPane.setTitle("Details");
        detailPetriTaskPane.setIcon(new ImageIcon("resources/images/details.png"));

        detailPetriTaskPane.add(getPetriDetailsTextPane());
        petriDetailsTextPane.setBackground(petriDetailsTextPane.getParent().getBackground());

        projectPetriContainer.add(projectPetriTaskPane);
        projectPetriContainer.add(stateMachinePetriTaskPane);
        projectPetriContainer.add(detailPetriTaskPane);

    }

    return projectPetriContainer;
}