Source Code Cross Referenced for FilterSetsPanel.java in  » IDE-Netbeans » profiler » org » netbeans » modules » profiler » ui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » profiler » org.netbeans.modules.profiler.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003:         *
0004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0005:         *
0006:         * The contents of this file are subject to the terms of either the GNU
0007:         * General Public License Version 2 only ("GPL") or the Common
0008:         * Development and Distribution License("CDDL") (collectively, the
0009:         * "License"). You may not use this file except in compliance with the
0010:         * License. You can obtain a copy of the License at
0011:         * http://www.netbeans.org/cddl-gplv2.html
0012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
0013:         * specific language governing permissions and limitations under the
0014:         * License.  When distributing the software, include this License Header
0015:         * Notice in each file and include the License file at
0016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
0017:         * particular file as subject to the "Classpath" exception as provided
0018:         * by Sun in the GPL Version 2 section of the License file that
0019:         * accompanied this code. If applicable, add the following below the
0020:         * License Header, with the fields enclosed by brackets [] replaced by
0021:         * your own identifying information:
0022:         * "Portions Copyrighted [year] [name of copyright owner]"
0023:         *
0024:         * Contributor(s):
0025:         * The Original Software is NetBeans. The Initial Developer of the Original
0026:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
0027:         * Microsystems, Inc. All Rights Reserved.
0028:         *
0029:         * If you wish your version of this file to be governed by only the CDDL
0030:         * or only the GPL Version 2, indicate your decision by adding
0031:         * "[Contributor] elects to include this software in this distribution
0032:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
0033:         * single choice of license, a recipient has the option to distribute
0034:         * your version of this file under either the CDDL, the GPL Version 2 or
0035:         * to extend the choice of license to its licensees as provided above.
0036:         * However, if you add GPL Version 2 code and therefore, elected the GPL
0037:         * Version 2 license, then the option applies only if the new code is
0038:         * made subject to such option by the copyright holder.
0039:         */
0040:
0041:        package org.netbeans.modules.profiler.ui;
0042:
0043:        import org.netbeans.lib.profiler.common.Profiler;
0044:        import org.netbeans.lib.profiler.common.filters.DefinedFilterSets;
0045:        import org.netbeans.lib.profiler.common.filters.FilterSet;
0046:        import org.netbeans.lib.profiler.ui.UIConstants;
0047:        import org.netbeans.lib.profiler.ui.UIUtils;
0048:        import org.netbeans.lib.profiler.ui.components.HTMLTextArea;
0049:        import org.netbeans.lib.profiler.ui.components.JExtendedTable;
0050:        import org.netbeans.lib.profiler.ui.components.table.BooleanTableCellRenderer;
0051:        import org.netbeans.lib.profiler.ui.components.table.LabelTableCellRenderer;
0052:        import org.netbeans.modules.profiler.NetBeansProfiler;
0053:        import org.openide.DialogDescriptor;
0054:        import org.openide.util.HelpCtx;
0055:        import org.openide.util.NbBundle;
0056:        import java.awt.*;
0057:        import java.awt.event.*;
0058:        import java.util.HashSet;
0059:        import java.util.Set;
0060:        import javax.swing.*;
0061:        import javax.swing.border.TitledBorder;
0062:        import javax.swing.event.*;
0063:        import javax.swing.table.AbstractTableModel;
0064:        import javax.swing.table.JTableHeader;
0065:        import javax.swing.table.TableColumn;
0066:
0067:        /**
0068:         *
0069:         * @author Tomas Hurka
0070:         * @author  Jiri Sedlacek
0071:         */
0072:        public final class FilterSetsPanel extends JPanel implements 
0073:                ActionListener, HelpCtx.Provider {
0074:            //~ Inner Classes ------------------------------------------------------------------------------------------------------------
0075:
0076:            private final class ActiveFiltersTableKeyListener extends
0077:                    KeyAdapter {
0078:                //~ Methods --------------------------------------------------------------------------------------------------------------
0079:
0080:                public void keyPressed(final KeyEvent e) {
0081:                    switch (e.getKeyCode()) {
0082:                    case KeyEvent.VK_SPACE:
0083:                        e.consume();
0084:                        toggleSelectedRowCheck();
0085:
0086:                        break;
0087:                    case KeyEvent.VK_ENTER:
0088:                        toggleSelectedRowCheck();
0089:
0090:                        break;
0091:                    case KeyEvent.VK_ESCAPE:
0092:                        FilterSetsPanel.this .processKeyEvent(e);
0093:
0094:                        break;
0095:                    }
0096:                }
0097:            }
0098:
0099:            private final class ActiveFiltersTableModel extends
0100:                    AbstractTableModel {
0101:                //~ Methods --------------------------------------------------------------------------------------------------------------
0102:
0103:                public boolean isCellEditable(final int rowIndex,
0104:                        final int columnIndex) {
0105:                    if (columnIndex == 0) {
0106:                        return true;
0107:                    } else {
0108:                        return false;
0109:                    }
0110:                }
0111:
0112:                public Class getColumnClass(final int columnIndex) {
0113:                    return columnClasses[columnIndex];
0114:                }
0115:
0116:                public int getColumnCount() {
0117:                    return 3;
0118:                }
0119:
0120:                public String getColumnName(final int columnIndex) {
0121:                    return columnNames[columnIndex];
0122:                }
0123:
0124:                public int getRowCount() {
0125:                    return nbProfiler.getGlobalFilters().getFilterNames().length;
0126:                }
0127:
0128:                public void setValueAt(final Object aValue, final int rowIndex,
0129:                        final int columnIndex) {
0130:                    if (columnIndex == 0) {
0131:                        selectedFilterSetChecks[rowIndex] = (Boolean) aValue;
0132:
0133:                        final boolean selected = ((Boolean) aValue)
0134:                                .booleanValue();
0135:
0136:                        if (selected) {
0137:                            selectedFilterSet
0138:                                    .addActiveGlobalFilter(nbProfiler
0139:                                            .getGlobalFilters()
0140:                                            .getFilterNames()[rowIndex]);
0141:                        } else {
0142:                            selectedFilterSet
0143:                                    .removeActiveGlobalFilter(nbProfiler
0144:                                            .getGlobalFilters()
0145:                                            .getFilterNames()[rowIndex]);
0146:                        }
0147:                    }
0148:                }
0149:
0150:                public Object getValueAt(final int rowIndex,
0151:                        final int columnIndex) {
0152:                    switch (columnIndex) {
0153:                    case 0:
0154:                        return selectedFilterSetChecks[rowIndex];
0155:                    case 1:
0156:                        return nbProfiler.getGlobalFilters().getFilterNames()[rowIndex];
0157:                    case 2:
0158:                        return nbProfiler.getGlobalFilters().getFilterValues()[rowIndex];
0159:                    }
0160:
0161:                    return null;
0162:                }
0163:            }
0164:
0165:            private final class ActiveFiltersTableMouseListener extends
0166:                    MouseAdapter {
0167:                //~ Methods --------------------------------------------------------------------------------------------------------------
0168:
0169:                public void mouseClicked(final MouseEvent e) {
0170:                    if ((e.getModifiers() == InputEvent.BUTTON1_MASK)
0171:                            && ((e.getClickCount() % 2) == 0)) {
0172:                        int selectedColumn = activeFiltersTable
0173:                                .getSelectedColumn();
0174:
0175:                        if (selectedColumn == 0) {
0176:                            return;
0177:                        } else if (selectedColumn == 1) {
0178:                            toggleSelectedRowCheck();
0179:
0180:                            return;
0181:                        } else if (selectedColumn == 2) {
0182:                            SwingUtilities.invokeLater(new Runnable() {
0183:                                public void run() {
0184:                                    editGlobalFilterAtRow(activeFiltersTable
0185:                                            .getSelectedRow());
0186:                                }
0187:                            });
0188:                        }
0189:                    }
0190:                }
0191:
0192:                private void editGlobalFilterAtRow(int row) {
0193:                    final GlobalFiltersPanel globalFiltersPanel = GlobalFiltersPanel
0194:                            .getDefault();
0195:
0196:                    // TODO: implement String getDialogCaption() for FilterSetsPanel, GlobalFiltersPanel and QuickFilterPanel
0197:                    final DialogDescriptor dd = new DialogDescriptor(
0198:                            globalFiltersPanel,
0199:                            EDIT_GLOBAL_FILTERS_DIALOG_CAPTION, true,
0200:                            new Object[] { DialogDescriptor.OK_OPTION,
0201:                                    DialogDescriptor.CANCEL_OPTION },
0202:                            DialogDescriptor.OK_OPTION,
0203:                            DialogDescriptor.BOTTOM_ALIGN, null, null);
0204:                    final Dialog d = ProfilerDialogs.createDialog(dd);
0205:                    globalFiltersPanel.init();
0206:                    d.pack(); // allows correct resizing of textarea in GlobalFiltersPanel
0207:                    globalFiltersPanel.editFilterValueAtRow(row);
0208:                    d.setVisible(true);
0209:
0210:                    if (dd.getValue() == DialogDescriptor.OK_OPTION) {
0211:                        globalFiltersPanel.applyChanges();
0212:                        FilterSetsPanel.getDefault()
0213:                                .processGlobalFiltersChanged();
0214:                    }
0215:                }
0216:            }
0217:
0218:            private final class ActiveFiltersTableViewport extends JViewport
0219:                    implements  TableColumnModelListener {
0220:                //~ Instance fields ------------------------------------------------------------------------------------------------------
0221:
0222:                private final JTableHeader tableHeader;
0223:
0224:                //~ Constructors ---------------------------------------------------------------------------------------------------------
0225:
0226:                public ActiveFiltersTableViewport(final JTable table) {
0227:                    super ();
0228:
0229:                    setView(table);
0230:                    setBackground(table.getBackground());
0231:
0232:                    tableHeader = table.getTableHeader();
0233:                    tableHeader.getColumnModel().addColumnModelListener(this );
0234:                }
0235:
0236:                //~ Methods --------------------------------------------------------------------------------------------------------------
0237:
0238:                public void columnAdded(final TableColumnModelEvent e) {
0239:                    repaint();
0240:                }
0241:
0242:                public void columnMarginChanged(final ChangeEvent e) {
0243:                    repaint();
0244:                }
0245:
0246:                public void columnMoved(final TableColumnModelEvent e) {
0247:                    repaint();
0248:                }
0249:
0250:                public void columnRemoved(final TableColumnModelEvent e) {
0251:                    repaint();
0252:                }
0253:
0254:                public void columnSelectionChanged(final ListSelectionEvent e) {
0255:                }
0256:
0257:                public void paint(final Graphics g) {
0258:                    super .paint(g);
0259:
0260:                    if (UIConstants.SHOW_TABLE_VERTICAL_GRID) {
0261:                        paintVerticalLines(g);
0262:                    }
0263:                }
0264:
0265:                private int getEmptySpaceY() {
0266:                    if (getView() == null) {
0267:                        return 0;
0268:                    }
0269:
0270:                    return getView().getHeight();
0271:                }
0272:
0273:                private void paintVerticalLines(final Graphics g) {
0274:                    final int emptySpaceY = getEmptySpaceY();
0275:                    Rectangle cellRect;
0276:                    g.setColor(UIConstants.TABLE_VERTICAL_GRID_COLOR);
0277:
0278:                    for (int i = 0; i < tableHeader.getColumnModel()
0279:                            .getColumnCount(); i++) {
0280:                        cellRect = tableHeader.getHeaderRect(i);
0281:                        g.drawLine((cellRect.x + cellRect.width) - 1,
0282:                                emptySpaceY, (cellRect.x + cellRect.width) - 1,
0283:                                getHeight() - 1);
0284:                    }
0285:                }
0286:            }
0287:
0288:            private final class DefinedFilterSetsListKeyListener extends
0289:                    KeyAdapter {
0290:                //~ Methods --------------------------------------------------------------------------------------------------------------
0291:
0292:                public void keyPressed(final KeyEvent e) {
0293:                    switch (e.getKeyCode()) {
0294:                    case KeyEvent.VK_DELETE:
0295:                        e.consume();
0296:                        removeSelectedFilterSet();
0297:
0298:                        break;
0299:                    case KeyEvent.VK_N:
0300:
0301:                        if (e.getModifiers() == InputEvent.CTRL_MASK) {
0302:                            e.consume();
0303:                            addNewFilterSet();
0304:
0305:                            break;
0306:                        }
0307:                    case KeyEvent.VK_UP:
0308:
0309:                        if (e.getModifiers() == InputEvent.CTRL_MASK) {
0310:                            e.consume();
0311:
0312:                            if (definedFilterSetsList.getSelectedIndex() > 0) {
0313:                                moveSelectedFilterUp();
0314:                            }
0315:
0316:                            break;
0317:                        }
0318:                    case KeyEvent.VK_DOWN:
0319:
0320:                        if (e.getModifiers() == InputEvent.CTRL_MASK) {
0321:                            e.consume();
0322:
0323:                            if (definedFilterSetsList.getSelectedIndex() < (definedFilterSetsList
0324:                                    .getModel().getSize() - 1)) {
0325:                                moveSelectedFilterDown();
0326:                            }
0327:
0328:                            break;
0329:                        }
0330:                    case KeyEvent.VK_ESCAPE:
0331:                        FilterSetsPanel.this .processKeyEvent(e);
0332:
0333:                        break;
0334:                    }
0335:                }
0336:            }
0337:
0338:            private final class DefinedFilterSetsListModel extends
0339:                    AbstractListModel {
0340:                //~ Methods --------------------------------------------------------------------------------------------------------------
0341:
0342:                public Object getElementAt(final int index) {
0343:                    return filterSets.getFilterSetAt(index).getFilterSetName();
0344:                }
0345:
0346:                public int getSize() {
0347:                    return filterSets.getFilterSetsCount();
0348:                }
0349:
0350:                public void fireContentsChanged(final int index0,
0351:                        final int index1) {
0352:                    fireContentsChanged(this , index0, index1);
0353:                }
0354:
0355:                public void fireIntervalAdded(final int index0, final int index1) {
0356:                    fireIntervalAdded(this , index0, index1);
0357:                }
0358:
0359:                public void fireIntervalRemoved(final int index0,
0360:                        final int index1) {
0361:                    fireIntervalRemoved(this , index0, index1);
0362:                }
0363:            }
0364:
0365:            private final class DefinedFilterSetsListSelectionListener
0366:                    implements  ListSelectionListener {
0367:                //~ Methods --------------------------------------------------------------------------------------------------------------
0368:
0369:                public void valueChanged(final ListSelectionEvent e) {
0370:                    updateSelection();
0371:
0372:                    if (selectedFilterSetIndex == -1) {
0373:                        removeFilterSetButton.setEnabled(false);
0374:                        moveUpButton.setEnabled(false);
0375:                        moveDownButton.setEnabled(false);
0376:                    } else {
0377:                        removeFilterSetButton.setEnabled(true);
0378:
0379:                        if (selectedFilterSetIndex > 0) {
0380:                            moveUpButton.setEnabled(true);
0381:                        } else {
0382:                            moveUpButton.setEnabled(false);
0383:                        }
0384:
0385:                        if (selectedFilterSetIndex < (definedFilterSetsList
0386:                                .getModel().getSize() - 1)) {
0387:                            moveDownButton.setEnabled(true);
0388:                        } else {
0389:                            moveDownButton.setEnabled(false);
0390:                        }
0391:                    }
0392:                }
0393:            }
0394:
0395:            private final class FilterNameTextFieldDocumentListener implements 
0396:                    DocumentListener {
0397:                //~ Methods --------------------------------------------------------------------------------------------------------------
0398:
0399:                public void changedUpdate(final DocumentEvent e) {
0400:                    updateDefinedFilterSetsList();
0401:                }
0402:
0403:                public void insertUpdate(final DocumentEvent e) {
0404:                    updateDefinedFilterSetsList();
0405:                }
0406:
0407:                public void removeUpdate(final DocumentEvent e) {
0408:                    updateDefinedFilterSetsList();
0409:                }
0410:
0411:                private void updateDefinedFilterSetsList() {
0412:                    String selectedFilterSetName = filterNameTextField
0413:                            .getText().trim();
0414:
0415:                    if (selectedFilterSetName.length() == 0) {
0416:                        selectedFilterSet.setFilterSetName(""); //NOI18N
0417:                        selectedFilterSetName = createUniqueFilterSetName();
0418:                    }
0419:
0420:                    selectedFilterSet.setFilterSetName(selectedFilterSetName);
0421:
0422:                    final DefinedFilterSetsListModel listModel = (DefinedFilterSetsListModel) definedFilterSetsList
0423:                            .getModel();
0424:                    listModel.fireContentsChanged(definedFilterSetsList
0425:                            .getSelectedIndex(), definedFilterSetsList
0426:                            .getSelectedIndex());
0427:                }
0428:            }
0429:
0430:            private final class FilterNameTextFieldFocusListener extends
0431:                    FocusAdapter {
0432:                //~ Instance fields ------------------------------------------------------------------------------------------------------
0433:
0434:                private int lastEditedFilterSetIndex;
0435:
0436:                //~ Methods --------------------------------------------------------------------------------------------------------------
0437:
0438:                public void focusGained(final FocusEvent e) {
0439:                    lastEditedFilterSetIndex = definedFilterSetsList
0440:                            .getSelectedIndex();
0441:                    filterSetNameBeforeEditing = filterNameTextField.getText();
0442:                }
0443:
0444:                public void focusLost(final FocusEvent e) {
0445:                    processUniqueFilterSetNameCheckAt(lastEditedFilterSetIndex);
0446:                }
0447:            }
0448:
0449:            private final class FilterNameTextFieldKeyListener extends
0450:                    KeyAdapter {
0451:                //~ Methods --------------------------------------------------------------------------------------------------------------
0452:
0453:                public void keyPressed(final KeyEvent e) {
0454:                    switch (e.getKeyCode()) {
0455:                    case KeyEvent.VK_ENTER:
0456:                        e.consume();
0457:                        processUniqueFilterSetNameCheckAt(definedFilterSetsList
0458:                                .getSelectedIndex());
0459:                        filterNameTextField.setText(selectedFilterSet
0460:                                .getFilterSetName());
0461:                        filterTypeExclusiveRadio.requestFocus();
0462:
0463:                        break;
0464:                    case KeyEvent.VK_ESCAPE:
0465:                        e.consume();
0466:                        filterNameTextField.setText(filterSetNameBeforeEditing);
0467:                        filterNameTextField.selectAll();
0468:
0469:                        break;
0470:                    }
0471:                }
0472:            }
0473:
0474:            //~ Static fields/initializers -----------------------------------------------------------------------------------------------
0475:
0476:            // -----
0477:            // I18N String constants
0478:            private static final String COLUMN_NAME_ACTIVE = NbBundle
0479:                    .getMessage(FilterSetsPanel.class,
0480:                            "FilterSetsPanel_ColumnNameActive"); //NOI18N
0481:            private static final String COLUMN_NAME_NAME = NbBundle.getMessage(
0482:                    FilterSetsPanel.class, "FilterSetsPanel_ColumnNameName"); //NOI18N
0483:            private static final String COLUMN_NAME_VALUE = NbBundle
0484:                    .getMessage(FilterSetsPanel.class,
0485:                            "FilterSetsPanel_ColumnNameValue"); //NOI18N
0486:            private static final String ADD_FILTER_SET_BUTTON_TEXT = NbBundle
0487:                    .getMessage(FilterSetsPanel.class,
0488:                            "FilterSetsPanel_AddFilterSetButtonText"); //NOI18N
0489:            private static final String REMOVE_FILTER_SET_BUTTON_TEXT = NbBundle
0490:                    .getMessage(FilterSetsPanel.class,
0491:                            "FilterSetsPanel_RemoveFilterSetButtonText"); //NOI18N
0492:            private static final String MOVE_UP_BUTTON_TEXT = NbBundle
0493:                    .getMessage(FilterSetsPanel.class,
0494:                            "FilterSetsPanel_MoveUpButtonText"); //NOI18N
0495:            private static final String MOVE_DOWN_BUTTON_TEXT = NbBundle
0496:                    .getMessage(FilterSetsPanel.class,
0497:                            "FilterSetsPanel_MoveDownButtonText"); //NOI18N
0498:            private static final String FILTERSET_NAME_LABEL_TEXT = NbBundle
0499:                    .getMessage(FilterSetsPanel.class,
0500:                            "FilterSetsPanel_FilterSetNameLabelText"); //NOI18N
0501:            private static final String FILTERSET_TYPE_LABEL_TEXT = NbBundle
0502:                    .getMessage(FilterSetsPanel.class,
0503:                            "FilterSetsPanel_FilterSetTypeLabelText"); //NOI18N
0504:            private static final String FILTERSET_TYPE_EXCLUSIVE_RADIO_TEXT = NbBundle
0505:                    .getMessage(FilterSetsPanel.class,
0506:                            "FilterSetsPanel_FilterSetTypeExclusiveRadioText"); //NOI18N
0507:            private static final String FILTERSET_TYPE_INCLUSIVE_RADIO_TEXT = NbBundle
0508:                    .getMessage(FilterSetsPanel.class,
0509:                            "FilterSetsPanel_FilterSetTypeInclusiveRadioText"); //NOI18N
0510:            private static final String ACTIVE_FILTERS_LABEL_TEXT = NbBundle
0511:                    .getMessage(FilterSetsPanel.class,
0512:                            "FilterSetsPanel_ActiveFiltersLabelText"); //NOI18N
0513:            private static final String DEFINED_FILTERSETS_BORDER_CAPTION = NbBundle
0514:                    .getMessage(FilterSetsPanel.class,
0515:                            "FilterSetsPanel_DefinedFilterSetsBorderCaption"); //NOI18N
0516:            private static final String FILTERSET_PROPERTIES_BORDER_CAPTION = NbBundle
0517:                    .getMessage(FilterSetsPanel.class,
0518:                            "FilterSetsPanel_FilterSetPropertiesBorderCaption"); //NOI18N
0519:            private static final String EDIT_GLOBAL_FILTERS_DIALOG_CAPTION = NbBundle
0520:                    .getMessage(FilterSetsPanel.class,
0521:                            "FilterSetsPanel_EditGlobalFiltersDialogCaption"); //NOI18N
0522:            private static final String HINT_MSG = NbBundle.getMessage(
0523:                    FilterSetsPanel.class, "FilterSetsPanel_HintMsg"); //NOI18N
0524:            private static final String DEFINED_FILTER_SETS_LIST_ACCESS_NAME = NbBundle
0525:                    .getMessage(FilterSetsPanel.class,
0526:                            "FilterSetsPanel_DefinedFilterSetsListAccessName"); //NOI18N
0527:            private static final String DEFINED_FILTER_SETS_LIST_ACCESS_DESCR = NbBundle
0528:                    .getMessage(FilterSetsPanel.class,
0529:                            "FilterSetsPanel_DefinedFilterSetsListAccessDescr"); //NOI18N
0530:            private static final String ADD_FILTER_SET_BUTTON_ACCESS_DESCR = NbBundle
0531:                    .getMessage(FilterSetsPanel.class,
0532:                            "FilterSetsPanel_AddFilterSetButtonAccessDescr"); //NOI18N
0533:            private static final String REMOVE_FILTER_SET_BUTTON_ACCESS_DESCR = NbBundle
0534:                    .getMessage(FilterSetsPanel.class,
0535:                            "FilterSetsPanel_RemoveFilterSetButtonAccessDescr"); //NOI18N
0536:            private static final String MOVE_UP_BUTTON_ACCESS_DESCR = NbBundle
0537:                    .getMessage(FilterSetsPanel.class,
0538:                            "FilterSetsPanel_MoveUpButtonAccessDescr"); //NOI18N
0539:            private static final String MOVE_DOWN_BUTTON_ACCESS_DESCR = NbBundle
0540:                    .getMessage(FilterSetsPanel.class,
0541:                            "FilterSetsPanel_MoveDownButtonAccessDescr"); //NOI18N
0542:            private static final String ACTIVE_FILTERS_TABLE_ACCESS_NAME = NbBundle
0543:                    .getMessage(FilterSetsPanel.class,
0544:                            "FilterSetsPanel_ActiveFiltersTableAccessName"); //NOI18N
0545:            private static final String ACTIVE_FILTERS_TABLE_ACCESS_DESCR = NbBundle
0546:                    .getMessage(FilterSetsPanel.class,
0547:                            "FilterSetsPanel_ActiveFiltersTableAccessDescr"); //NOI18N
0548:            private static final String FILTER_TYPE_EXCLUSIVE_RADIO_ACCESS_DESCR = NbBundle
0549:                    .getMessage(FilterSetsPanel.class,
0550:                            "FilterSetsPanel_FilterTypeExclusiveRadioAccessDescr"); //NOI18N
0551:            private static final String FILTER_TYPE_INCLUSIVE_RADIO_ACCESS_DESCR = NbBundle
0552:                    .getMessage(FilterSetsPanel.class,
0553:                            "FilterSetsPanel_FilterTypeInclusiveRadioAccessDescr"); //NOI18N
0554:            // -----
0555:            private static final String HELP_CTX_KEY = "FilterSetsPanel.HelpCtx"; // NOI18N
0556:            private static final HelpCtx HELP_CTX = new HelpCtx(HELP_CTX_KEY);
0557:            private static FilterSetsPanel defaultInstance;
0558:
0559:            //~ Instance fields ----------------------------------------------------------------------------------------------------------
0560:
0561:            public final DefinedFilterSets filterSets;
0562:            private ButtonGroup filterTypeButtonGroup;
0563:            private FilterSet selectedFilterSet;
0564:            private HTMLTextArea hintArea;
0565:            private JButton addFilterSetButton;
0566:            private JButton moveDownButton;
0567:            private JButton moveUpButton;
0568:            private JButton removeFilterSetButton;
0569:            private JExtendedTable activeFiltersTable;
0570:            private JLabel activeFiltersLabel;
0571:            private JLabel filterNameLabel;
0572:            private JLabel filterTypeLabel;
0573:            private JList definedFilterSetsList;
0574:            private JPanel buttonsPanel;
0575:            private JPanel filterSetPropertiesPanel;
0576:            private JPanel filterSetSettingsPanel;
0577:            private JPanel filterSetsPreviewPanel;
0578:            private JRadioButton filterTypeExclusiveRadio;
0579:            private JRadioButton filterTypeInclusiveRadio;
0580:            private JScrollPane activeFiltersScrollPane;
0581:            private JScrollPane definedFilterSetsListScrollPane;
0582:            private JTextField filterNameTextField;
0583:            private final NetBeansProfiler nbProfiler;
0584:            private final Class[] columnClasses;
0585:            private final String[] columnNames;
0586:            private String filterSetNameBeforeEditing;
0587:            private Boolean[] selectedFilterSetChecks = new Boolean[0];
0588:            private int selectedFilterSetIndex;
0589:
0590:            //~ Constructors -------------------------------------------------------------------------------------------------------------
0591:
0592:            /** Creates new form FilterSetsPanel */
0593:            private FilterSetsPanel() {
0594:                nbProfiler = (NetBeansProfiler) Profiler.getDefault();
0595:                filterSets = new DefinedFilterSets();
0596:
0597:                columnNames = new String[] { COLUMN_NAME_ACTIVE,
0598:                        COLUMN_NAME_NAME, COLUMN_NAME_VALUE };
0599:                columnClasses = new Class[] { Boolean.class, String.class,
0600:                        String.class };
0601:
0602:                initComponents();
0603:            }
0604:
0605:            //~ Methods ------------------------------------------------------------------------------------------------------------------
0606:
0607:            public static FilterSetsPanel getDefault() {
0608:                if (defaultInstance == null) {
0609:                    defaultInstance = new FilterSetsPanel();
0610:                }
0611:
0612:                return defaultInstance;
0613:            }
0614:
0615:            public HelpCtx getHelpCtx() {
0616:                return HELP_CTX;
0617:            }
0618:
0619:            public FilterSet getSelectedFilterSet() {
0620:                int selectedIndex = getSelectedFilterSetIndex();
0621:
0622:                if (selectedIndex == -1) {
0623:                    return null;
0624:                } else {
0625:                    return filterSets.getFilterSetAt(selectedIndex);
0626:                }
0627:            }
0628:
0629:            public int getSelectedFilterSetIndex() {
0630:                return definedFilterSetsList.getSelectedIndex();
0631:            }
0632:
0633:            public String getSelectedFilterSetName() {
0634:                return (String) definedFilterSetsList.getSelectedValue();
0635:            }
0636:
0637:            public void actionPerformed(final ActionEvent e) {
0638:                if (e.getSource() == addFilterSetButton) {
0639:                    addNewFilterSet();
0640:                } else if (e.getSource() == removeFilterSetButton) {
0641:                    removeSelectedFilterSet();
0642:                } else if (e.getSource() == moveUpButton) {
0643:                    moveSelectedFilterUp();
0644:                } else if (e.getSource() == moveDownButton) {
0645:                    moveSelectedFilterDown();
0646:                } else if (e.getSource() == filterTypeExclusiveRadio) {
0647:                    if (filterTypeExclusiveRadio.isSelected()) {
0648:                        selectedFilterSet.setExclusive();
0649:                    }
0650:                } else if (e.getSource() == filterTypeInclusiveRadio) {
0651:                    if (filterTypeInclusiveRadio.isSelected()) {
0652:                        selectedFilterSet.setInclusive();
0653:                    }
0654:                }
0655:            }
0656:
0657:            public void applyChanges() {
0658:                nbProfiler.getDefinedFilterSets().setValuesFrom(filterSets);
0659:                nbProfiler.saveGlobalFilters();
0660:            }
0661:
0662:            public void init(final int initialSelectedIndex) {
0663:                filterSets.setValuesFrom(nbProfiler.getDefinedFilterSets());
0664:
0665:                if (initialSelectedIndex < filterSets.getFilterSetsCount()) {
0666:                    definedFilterSetsList
0667:                            .setSelectedIndex(initialSelectedIndex);
0668:                    makeDefinedFilterSetsListSelectionVisible();
0669:                } else {
0670:                    definedFilterSetsList.clearSelection();
0671:                }
0672:
0673:                updateSelection();
0674:            }
0675:
0676:            public void processGlobalFiltersChanged() {
0677:                if (activeFiltersTable != null) {
0678:                    updateSelectedFilterSetProperties();
0679:                    ((AbstractTableModel) (activeFiltersTable.getModel()))
0680:                            .fireTableDataChanged();
0681:                    activeFiltersTable.repaint();
0682:                }
0683:            }
0684:
0685:            private void addNewFilterSet() {
0686:                if (definedFilterSetsList != null) {
0687:                    filterSets.addFilterSet(new FilterSet(
0688:                            createUniqueFilterSetName()));
0689:
0690:                    final DefinedFilterSetsListModel listModel = (DefinedFilterSetsListModel) definedFilterSetsList
0691:                            .getModel();
0692:                    listModel.fireIntervalAdded(listModel.getSize(), listModel
0693:                            .getSize());
0694:                    definedFilterSetsList
0695:                            .setSelectedIndex(listModel.getSize() - 1);
0696:                    makeDefinedFilterSetsListSelectionVisible();
0697:                    filterNameTextField.selectAll();
0698:                    filterNameTextField.requestFocus();
0699:                }
0700:            }
0701:
0702:            private boolean containsFilterSetName(final String filterName) {
0703:                for (int i = 0; i < filterSets.getFilterSetsCount(); i++) {
0704:                    if (filterSets.getFilterSetAt(i).getFilterSetName().equals(
0705:                            filterName)) {
0706:                        return true;
0707:                    }
0708:                }
0709:
0710:                return false;
0711:            }
0712:
0713:            private boolean containsFilterSetNameExceptIndex(
0714:                    final String filterName, final int index) {
0715:                for (int i = 0; i < filterSets.getFilterSetsCount(); i++) {
0716:                    if ((i != index)
0717:                            && (filterSets.getFilterSetAt(i).getFilterSetName()
0718:                                    .equals(filterName))) {
0719:                        return true;
0720:                    }
0721:                }
0722:
0723:                return false;
0724:            }
0725:
0726:            private String createUniqueFilterSetName() {
0727:                return createUniqueFilterSetName(FilterSet.DEFAULT_FILTERSET_NAME);
0728:            }
0729:
0730:            private String createUniqueFilterSetName(
0731:                    final String baseFilterSetName) {
0732:                int index = 1;
0733:                String filterSetNameExt = ""; //NOI18N
0734:
0735:                while (containsFilterSetName(baseFilterSetName
0736:                        + filterSetNameExt)) {
0737:                    filterSetNameExt = " (" + ++index + ")"; //NOI18N
0738:                }
0739:
0740:                return baseFilterSetName + filterSetNameExt;
0741:            }
0742:
0743:            private void initComponents() {
0744:                java.awt.GridBagConstraints gridBagConstraints;
0745:
0746:                filterTypeButtonGroup = new ButtonGroup();
0747:                filterSetsPreviewPanel = new JPanel();
0748:                definedFilterSetsList = new JList();
0749:                definedFilterSetsListScrollPane = new JScrollPane();
0750:                buttonsPanel = new JPanel();
0751:                addFilterSetButton = new JButton();
0752:                removeFilterSetButton = new JButton();
0753:                moveUpButton = new JButton();
0754:                moveDownButton = new JButton();
0755:                filterSetPropertiesPanel = new JPanel();
0756:                //activeFiltersTable = new JExtendedTable(); // Defined later
0757:                filterSetSettingsPanel = new JPanel();
0758:                filterNameLabel = new JLabel();
0759:                filterNameTextField = new JTextField();
0760:                filterTypeLabel = new JLabel();
0761:                filterTypeExclusiveRadio = new JRadioButton();
0762:                filterTypeInclusiveRadio = new JRadioButton();
0763:                activeFiltersLabel = new JLabel();
0764:                hintArea = new HTMLTextArea() {
0765:                    public Dimension getPreferredSize() { // Workaround to force the text area not to consume horizontal space to fit the contents to just one line
0766:
0767:                        return new Dimension(1, super .getPreferredSize().height);
0768:                    }
0769:                };
0770:
0771:                setLayout(new java.awt.BorderLayout());
0772:
0773:                final TitledBorder filterSetsPreviewPanelTitledBorder = BorderFactory
0774:                        .createTitledBorder(DEFINED_FILTERSETS_BORDER_CAPTION);
0775:
0776:                filterSetsPreviewPanel.setLayout(new java.awt.BorderLayout());
0777:                filterSetsPreviewPanel
0778:                        .setBorder(BorderFactory.createCompoundBorder(
0779:                                BorderFactory.createEmptyBorder(7, 5, 5, 5),
0780:                                filterSetsPreviewPanelTitledBorder));
0781:
0782:                definedFilterSetsList.getAccessibleContext().setAccessibleName(
0783:                        DEFINED_FILTER_SETS_LIST_ACCESS_NAME);
0784:                definedFilterSetsList.getAccessibleContext()
0785:                        .setAccessibleDescription(
0786:                                DEFINED_FILTER_SETS_LIST_ACCESS_DESCR);
0787:                definedFilterSetsList
0788:                        .setModel(new DefinedFilterSetsListModel());
0789:                definedFilterSetsList
0790:                        .setCellRenderer(new DefaultListCellRenderer() {
0791:                            public java.awt.Component getListCellRendererComponent(
0792:                                    final JList list, final Object value,
0793:                                    final int index, final boolean isSelected,
0794:                                    final boolean cellHasFocus) {
0795:                                return super .getListCellRendererComponent(list,
0796:                                        value, index, isSelected, false);
0797:                            }
0798:                        });
0799:                definedFilterSetsList
0800:                        .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
0801:                definedFilterSetsList
0802:                        .setSelectionBackground(UIConstants.TABLE_SELECTION_BACKGROUND_COLOR);
0803:                definedFilterSetsList
0804:                        .setSelectionForeground(UIConstants.TABLE_SELECTION_FOREGROUND_COLOR);
0805:                definedFilterSetsList.setVisibleRowCount(5);
0806:                definedFilterSetsList
0807:                        .addListSelectionListener(new DefinedFilterSetsListSelectionListener());
0808:                definedFilterSetsList
0809:                        .addKeyListener(new DefinedFilterSetsListKeyListener());
0810:
0811:                definedFilterSetsListScrollPane
0812:                        .setViewportView(definedFilterSetsList);
0813:                definedFilterSetsListScrollPane.setBorder(BorderFactory
0814:                        .createCompoundBorder(BorderFactory.createEmptyBorder(
0815:                                5, 5, 5, 0), definedFilterSetsListScrollPane
0816:                                .getBorder()));
0817:                definedFilterSetsListScrollPane.setPreferredSize(new Dimension(
0818:                        470, 1));
0819:
0820:                filterSetsPreviewPanel.add(definedFilterSetsListScrollPane,
0821:                        java.awt.BorderLayout.CENTER);
0822:
0823:                //buttonsPanel.setLayout(new java.awt.GridLayout(5, 1, 0, 5));
0824:                buttonsPanel.setLayout(new java.awt.GridLayout(4, 1, 0, 5));
0825:                buttonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 8, 5,
0826:                        5));
0827:
0828:                org.openide.awt.Mnemonics.setLocalizedText(addFilterSetButton,
0829:                        ADD_FILTER_SET_BUTTON_TEXT);
0830:                addFilterSetButton.getAccessibleContext()
0831:                        .setAccessibleDescription(
0832:                                ADD_FILTER_SET_BUTTON_ACCESS_DESCR);
0833:                addFilterSetButton.addActionListener(this );
0834:                buttonsPanel.add(addFilterSetButton);
0835:
0836:                org.openide.awt.Mnemonics.setLocalizedText(
0837:                        removeFilterSetButton, REMOVE_FILTER_SET_BUTTON_TEXT);
0838:                removeFilterSetButton.getAccessibleContext()
0839:                        .setAccessibleDescription(
0840:                                REMOVE_FILTER_SET_BUTTON_ACCESS_DESCR);
0841:                removeFilterSetButton.setEnabled(false);
0842:                removeFilterSetButton.addActionListener(this );
0843:                buttonsPanel.add(removeFilterSetButton);
0844:
0845:                //buttonsPanel.add(new JPanel());
0846:                org.openide.awt.Mnemonics.setLocalizedText(moveUpButton,
0847:                        MOVE_UP_BUTTON_TEXT);
0848:                moveUpButton.getAccessibleContext().setAccessibleDescription(
0849:                        MOVE_UP_BUTTON_ACCESS_DESCR);
0850:                moveUpButton.setEnabled(false);
0851:                moveUpButton.addActionListener(this );
0852:                buttonsPanel.add(moveUpButton);
0853:
0854:                org.openide.awt.Mnemonics.setLocalizedText(moveDownButton,
0855:                        MOVE_DOWN_BUTTON_TEXT);
0856:                moveDownButton.getAccessibleContext().setAccessibleDescription(
0857:                        MOVE_DOWN_BUTTON_ACCESS_DESCR);
0858:                moveDownButton.setEnabled(false);
0859:                moveDownButton.addActionListener(this );
0860:                buttonsPanel.add(moveDownButton);
0861:
0862:                filterSetsPreviewPanel.add(buttonsPanel,
0863:                        java.awt.BorderLayout.EAST);
0864:
0865:                add(filterSetsPreviewPanel, java.awt.BorderLayout.NORTH);
0866:
0867:                final TitledBorder filterSetPropertiesPanelTitledBorder = BorderFactory
0868:                        .createTitledBorder(FILTERSET_PROPERTIES_BORDER_CAPTION);
0869:
0870:                filterSetPropertiesPanel.setLayout(new java.awt.BorderLayout());
0871:                filterSetPropertiesPanel.setBorder(BorderFactory
0872:                        .createCompoundBorder(BorderFactory.createEmptyBorder(
0873:                                2, 5, 5, 5),
0874:                                filterSetPropertiesPanelTitledBorder));
0875:
0876:                // activeFiltersTable renderers
0877:                final LabelTableCellRenderer filterTableCellRenderer = new LabelTableCellRenderer();
0878:                final BooleanTableCellRenderer booleanTableCellRenderer = new BooleanTableCellRenderer();
0879:
0880:                // activeFiltersTable
0881:                activeFiltersTable = new JExtendedTable(
0882:                        new ActiveFiltersTableModel());
0883:                activeFiltersTable.getAccessibleContext().setAccessibleName(
0884:                        ACTIVE_FILTERS_TABLE_ACCESS_NAME);
0885:                activeFiltersTable.getAccessibleContext()
0886:                        .setAccessibleDescription(
0887:                                ACTIVE_FILTERS_TABLE_ACCESS_DESCR);
0888:                activeFiltersTable.setRowSelectionAllowed(true);
0889:                activeFiltersTable
0890:                        .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
0891:                activeFiltersTable
0892:                        .setGridColor(UIConstants.TABLE_VERTICAL_GRID_COLOR);
0893:                activeFiltersTable
0894:                        .setSelectionBackground(UIConstants.TABLE_SELECTION_BACKGROUND_COLOR);
0895:                activeFiltersTable
0896:                        .setSelectionForeground(UIConstants.TABLE_SELECTION_FOREGROUND_COLOR);
0897:                activeFiltersTable
0898:                        .setShowHorizontalLines(UIConstants.SHOW_TABLE_HORIZONTAL_GRID);
0899:                activeFiltersTable
0900:                        .setShowVerticalLines(UIConstants.SHOW_TABLE_VERTICAL_GRID);
0901:                activeFiltersTable.setRowMargin(UIConstants.TABLE_ROW_MARGIN);
0902:                activeFiltersTable.getTableHeader().setReorderingAllowed(false);
0903:                activeFiltersTable.setDefaultRenderer(Boolean.class,
0904:                        booleanTableCellRenderer);
0905:                activeFiltersTable.setDefaultRenderer(String.class,
0906:                        filterTableCellRenderer);
0907:                activeFiltersTable
0908:                        .setRowHeight(UIUtils.getDefaultRowHeight() + 2);
0909:                activeFiltersTable
0910:                        .addKeyListener(new ActiveFiltersTableKeyListener());
0911:                activeFiltersTable
0912:                        .addMouseListener(new ActiveFiltersTableMouseListener());
0913:
0914:                // Disable traversing table cells using TAB and Shift+TAB
0915:                Set keys = new HashSet(
0916:                        activeFiltersTable
0917:                                .getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
0918:                keys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
0919:                activeFiltersTable.setFocusTraversalKeys(
0920:                        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, keys);
0921:
0922:                keys = new HashSet(
0923:                        activeFiltersTable
0924:                                .getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
0925:                keys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
0926:                        InputEvent.SHIFT_MASK));
0927:                activeFiltersTable.setFocusTraversalKeys(
0928:                        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, keys);
0929:
0930:                // filterTable columns
0931:                final TableColumn firstColumn = activeFiltersTable
0932:                        .getColumnModel().getColumn(0);
0933:                final int firstColumnWidth = new JButton(COLUMN_NAME_ACTIVE)
0934:                        .getPreferredSize().width;
0935:                firstColumn.setMinWidth(firstColumnWidth);
0936:                firstColumn.setPreferredWidth(firstColumnWidth);
0937:                firstColumn.setMaxWidth(firstColumnWidth);
0938:
0939:                // filterTableScrollPane
0940:                activeFiltersScrollPane = new JScrollPane(
0941:                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
0942:                        JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
0943:                activeFiltersScrollPane.setBorder(BorderFactory
0944:                        .createCompoundBorder(BorderFactory.createEmptyBorder(
0945:                                5, 5, 5, 5), activeFiltersScrollPane
0946:                                .getBorder()));
0947:                activeFiltersScrollPane.setPreferredSize(new Dimension(1, 200));
0948:
0949:                final ActiveFiltersTableViewport activeFiltersTableViewport = new ActiveFiltersTableViewport(
0950:                        activeFiltersTable);
0951:                activeFiltersScrollPane.setViewport(activeFiltersTableViewport);
0952:                activeFiltersScrollPane
0953:                        .addMouseWheelListener(activeFiltersTable);
0954:                activeFiltersScrollPane.getVerticalScrollBar().getModel()
0955:                        .addChangeListener(new ChangeListener() {
0956:                            public void stateChanged(final ChangeEvent e) {
0957:                                if (activeFiltersScrollPane
0958:                                        .getVerticalScrollBar().getModel()
0959:                                        .getExtent() == activeFiltersScrollPane
0960:                                        .getVerticalScrollBar().getModel()
0961:                                        .getMaximum()) {
0962:                                    activeFiltersScrollPane
0963:                                            .getVerticalScrollBar().setEnabled(
0964:                                                    false);
0965:                                } else {
0966:                                    activeFiltersScrollPane
0967:                                            .getVerticalScrollBar().setEnabled(
0968:                                                    true);
0969:                                }
0970:                            }
0971:                        });
0972:
0973:                filterSetPropertiesPanel.add(activeFiltersScrollPane,
0974:                        java.awt.BorderLayout.CENTER);
0975:
0976:                filterSetSettingsPanel.setLayout(new java.awt.GridBagLayout());
0977:
0978:                org.openide.awt.Mnemonics.setLocalizedText(filterNameLabel,
0979:                        FILTERSET_NAME_LABEL_TEXT);
0980:                filterNameLabel.setLabelFor(filterNameTextField);
0981:                gridBagConstraints = new java.awt.GridBagConstraints();
0982:                gridBagConstraints.gridx = 0;
0983:                gridBagConstraints.gridy = 0;
0984:                gridBagConstraints.gridwidth = 2;
0985:                gridBagConstraints.weightx = 1.0;
0986:                gridBagConstraints.weighty = 1.0;
0987:                gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 10);
0988:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0989:                filterSetSettingsPanel.add(filterNameLabel, gridBagConstraints);
0990:
0991:                filterNameTextField.setText(""); //NOI18N
0992:                filterNameTextField
0993:                        .addKeyListener(new FilterNameTextFieldKeyListener());
0994:                filterNameTextField
0995:                        .addFocusListener(new FilterNameTextFieldFocusListener());
0996:                filterNameTextField.getDocument().addDocumentListener(
0997:                        new FilterNameTextFieldDocumentListener());
0998:                filterNameTextField
0999:                        .setSelectionColor(UIConstants.TABLE_SELECTION_BACKGROUND_COLOR);
1000:                filterNameTextField
1001:                        .setSelectedTextColor(UIConstants.TABLE_SELECTION_FOREGROUND_COLOR);
1002:                gridBagConstraints = new java.awt.GridBagConstraints();
1003:                gridBagConstraints.gridx = 1;
1004:                gridBagConstraints.gridy = 0;
1005:                gridBagConstraints.weightx = 1.0;
1006:                gridBagConstraints.weighty = 1.0;
1007:                gridBagConstraints.insets = new java.awt.Insets(5, 4, 5, 0);
1008:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1009:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1010:                filterSetSettingsPanel.add(filterNameTextField,
1011:                        gridBagConstraints);
1012:
1013:                filterTypeLabel.setText(FILTERSET_TYPE_LABEL_TEXT);
1014:                gridBagConstraints = new java.awt.GridBagConstraints();
1015:                gridBagConstraints.gridx = 0;
1016:                gridBagConstraints.gridy = 1;
1017:                gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 10);
1018:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1019:                filterSetSettingsPanel.add(filterTypeLabel, gridBagConstraints);
1020:
1021:                org.openide.awt.Mnemonics.setLocalizedText(
1022:                        filterTypeExclusiveRadio,
1023:                        FILTERSET_TYPE_EXCLUSIVE_RADIO_TEXT);
1024:                filterTypeExclusiveRadio.getAccessibleContext()
1025:                        .setAccessibleDescription(
1026:                                FILTER_TYPE_EXCLUSIVE_RADIO_ACCESS_DESCR);
1027:                filterTypeExclusiveRadio.addActionListener(this );
1028:                filterTypeButtonGroup.add(filterTypeExclusiveRadio);
1029:                gridBagConstraints = new java.awt.GridBagConstraints();
1030:                gridBagConstraints.gridx = 1;
1031:                gridBagConstraints.gridy = 1;
1032:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1033:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1034:                filterSetSettingsPanel.add(filterTypeExclusiveRadio,
1035:                        gridBagConstraints);
1036:
1037:                org.openide.awt.Mnemonics.setLocalizedText(
1038:                        filterTypeInclusiveRadio,
1039:                        FILTERSET_TYPE_INCLUSIVE_RADIO_TEXT);
1040:                filterTypeInclusiveRadio.getAccessibleContext()
1041:                        .setAccessibleDescription(
1042:                                FILTER_TYPE_INCLUSIVE_RADIO_ACCESS_DESCR);
1043:                filterTypeInclusiveRadio.addActionListener(this );
1044:                filterTypeButtonGroup.add(filterTypeInclusiveRadio);
1045:                gridBagConstraints = new java.awt.GridBagConstraints();
1046:                gridBagConstraints.gridx = 1;
1047:                gridBagConstraints.gridy = 2;
1048:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
1049:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1050:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1051:                filterSetSettingsPanel.add(filterTypeInclusiveRadio,
1052:                        gridBagConstraints);
1053:
1054:                activeFiltersLabel.setLabelFor(activeFiltersTable);
1055:                //    activeFiltersLabel.setFocusable(false);
1056:                org.openide.awt.Mnemonics.setLocalizedText(activeFiltersLabel,
1057:                        ACTIVE_FILTERS_LABEL_TEXT);
1058:                gridBagConstraints = new java.awt.GridBagConstraints();
1059:                gridBagConstraints.gridx = 0;
1060:                gridBagConstraints.gridy = 3;
1061:                gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
1062:                gridBagConstraints.fill = java.awt.GridBagConstraints.NONE;
1063:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1064:                filterSetSettingsPanel.add(activeFiltersLabel,
1065:                        gridBagConstraints);
1066:
1067:                final JPanel expandPanel = new JPanel();
1068:                gridBagConstraints = new java.awt.GridBagConstraints();
1069:                gridBagConstraints.gridx = 2;
1070:                gridBagConstraints.gridy = 0;
1071:                gridBagConstraints.weightx = 2.0;
1072:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
1073:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1074:                filterSetSettingsPanel.add(expandPanel, gridBagConstraints);
1075:
1076:                filterSetPropertiesPanel.add(filterSetSettingsPanel,
1077:                        java.awt.BorderLayout.NORTH);
1078:                filterSetPropertiesPanel.setVisible(false);
1079:
1080:                add(filterSetPropertiesPanel, java.awt.BorderLayout.CENTER);
1081:
1082:                Color panelBackground = UIManager.getColor("Panel.background"); //NOI18N
1083:                Color hintBackground = UIUtils.getSafeColor(panelBackground
1084:                        .getRed() - 10, panelBackground.getGreen() - 10,
1085:                        panelBackground.getBlue() - 10);
1086:                // hintArea
1087:                hintArea.setText(HINT_MSG); // NOI18N
1088:                hintArea.setEnabled(false);
1089:                hintArea.setDisabledTextColor(Color.darkGray);
1090:                hintArea.setBackground(hintBackground);
1091:                hintArea.setBorder(BorderFactory.createCompoundBorder(
1092:                        BorderFactory.createMatteBorder(7, 7, 10, 7, UIManager
1093:                                .getColor("Panel.background")), //NOI18N
1094:                        BorderFactory.createMatteBorder(10, 10, 10, 10,
1095:                                hintBackground)));
1096:                add(hintArea, java.awt.BorderLayout.SOUTH);
1097:            }
1098:
1099:            private void makeDefinedFilterSetsListSelectionVisible() {
1100:                definedFilterSetsList.scrollRectToVisible(definedFilterSetsList
1101:                        .getCellBounds(
1102:                                definedFilterSetsList.getSelectedIndex(),
1103:                                definedFilterSetsList.getSelectedIndex()));
1104:            }
1105:
1106:            private void moveSelectedFilterDown() {
1107:                if (definedFilterSetsList != null) {
1108:                    final int selectedIndex = definedFilterSetsList
1109:                            .getSelectedIndex();
1110:
1111:                    if (selectedIndex < (definedFilterSetsList.getModel()
1112:                            .getSize() - 1)) {
1113:                        filterSets.moveFilterSetDown(selectedIndex);
1114:
1115:                        final DefinedFilterSetsListModel listModel = (DefinedFilterSetsListModel) definedFilterSetsList
1116:                                .getModel();
1117:                        listModel.fireContentsChanged(selectedIndex,
1118:                                selectedIndex + 1);
1119:                        definedFilterSetsList
1120:                                .setSelectedIndex(selectedIndex + 1);
1121:                        makeDefinedFilterSetsListSelectionVisible();
1122:                    }
1123:                }
1124:            }
1125:
1126:            private void moveSelectedFilterUp() {
1127:                if (definedFilterSetsList != null) {
1128:                    final int selectedIndex = definedFilterSetsList
1129:                            .getSelectedIndex();
1130:
1131:                    if (selectedIndex > 0) {
1132:                        filterSets.moveFilterSetUp(selectedIndex);
1133:
1134:                        final DefinedFilterSetsListModel listModel = (DefinedFilterSetsListModel) definedFilterSetsList
1135:                                .getModel();
1136:                        listModel.fireContentsChanged(selectedIndex - 1,
1137:                                selectedIndex);
1138:                        definedFilterSetsList
1139:                                .setSelectedIndex(selectedIndex - 1);
1140:                        makeDefinedFilterSetsListSelectionVisible();
1141:                    }
1142:                }
1143:            }
1144:
1145:            private void processUniqueFilterSetNameCheckAt(final int index) {
1146:                if ((filterSets.getFilterSetAt(index).getFilterSetName().trim()
1147:                        .length() == 0)
1148:                        || (containsFilterSetNameExceptIndex(filterSets
1149:                                .getFilterSetAt(index).getFilterSetName(),
1150:                                index))) {
1151:                    filterSets.getFilterSetAt(index).setFilterSetName(
1152:                            createUniqueFilterSetName(filterSets
1153:                                    .getFilterSetAt(index).getFilterSetName()));
1154:                    ((DefinedFilterSetsListModel) definedFilterSetsList
1155:                            .getModel()).fireContentsChanged(index, index);
1156:                }
1157:
1158:                filterNameTextField.setText(filterSets.getFilterSetAt(
1159:                        definedFilterSetsList.getSelectedIndex())
1160:                        .getFilterSetName());
1161:            }
1162:
1163:            private void removeSelectedFilterSet() {
1164:                if (definedFilterSetsList != null) {
1165:                    final int selectedIndex = definedFilterSetsList
1166:                            .getSelectedIndex();
1167:
1168:                    if (selectedIndex != -1) {
1169:                        filterSets.removeFilterSet(selectedIndex);
1170:
1171:                        final DefinedFilterSetsListModel listModel = (DefinedFilterSetsListModel) definedFilterSetsList
1172:                                .getModel();
1173:                        listModel.fireIntervalRemoved(selectedIndex,
1174:                                selectedIndex);
1175:
1176:                        if (selectedIndex != 0) {
1177:                            definedFilterSetsList
1178:                                    .setSelectedIndex(selectedIndex - 1);
1179:                        } else if (listModel.getSize() > 0) {
1180:                            definedFilterSetsList.setSelectedIndex(0);
1181:                        }
1182:                    }
1183:                }
1184:            }
1185:
1186:            private void toggleSelectedRowCheck() {
1187:                final int selectedIndex = activeFiltersTable.getSelectedRow();
1188:                final boolean selected = !selectedFilterSetChecks[selectedIndex]
1189:                        .booleanValue();
1190:                selectedFilterSetChecks[selectedIndex] = Boolean
1191:                        .valueOf(selected);
1192:
1193:                if (selected) {
1194:                    selectedFilterSet
1195:                            .addActiveGlobalFilter(nbProfiler
1196:                                    .getGlobalFilters().getFilterNames()[selectedIndex]);
1197:                } else {
1198:                    selectedFilterSet
1199:                            .removeActiveGlobalFilter(nbProfiler
1200:                                    .getGlobalFilters().getFilterNames()[selectedIndex]);
1201:                }
1202:
1203:                ((AbstractTableModel) (activeFiltersTable.getModel()))
1204:                        .fireTableDataChanged();
1205:                activeFiltersTable.setRowSelectionInterval(selectedIndex,
1206:                        selectedIndex);
1207:                activeFiltersTable.repaint();
1208:            }
1209:
1210:            private void updateSelectedFilterSetProperties() {
1211:                if (selectedFilterSet == null) {
1212:                    filterSetPropertiesPanel.setVisible(false);
1213:                    selectedFilterSetChecks = new Boolean[0];
1214:                } else {
1215:                    if (!filterSetPropertiesPanel.isVisible()) {
1216:                        filterSetPropertiesPanel.setVisible(true);
1217:                    }
1218:
1219:                    filterNameTextField.setText(selectedFilterSet
1220:                            .getFilterSetName());
1221:
1222:                    if (selectedFilterSet.isExclusive()) {
1223:                        filterTypeExclusiveRadio.setSelected(true);
1224:                    } else {
1225:                        filterTypeInclusiveRadio.setSelected(true);
1226:                    }
1227:
1228:                    selectedFilterSetChecks = new Boolean[nbProfiler
1229:                            .getGlobalFilters().getFilterNames().length];
1230:
1231:                    for (int i = 0; i < selectedFilterSetChecks.length; i++) {
1232:                        if (selectedFilterSet
1233:                                .containsActiveGlobalFilter(nbProfiler
1234:                                        .getGlobalFilters().getFilterNames()[i])) {
1235:                            selectedFilterSetChecks[i] = Boolean.TRUE;
1236:                        } else {
1237:                            selectedFilterSetChecks[i] = Boolean.FALSE;
1238:                        }
1239:                    }
1240:                }
1241:
1242:                ((AbstractTableModel) (activeFiltersTable.getModel()))
1243:                        .fireTableDataChanged();
1244:                activeFiltersTable.repaint();
1245:            }
1246:
1247:            private void updateSelection() {
1248:                selectedFilterSetIndex = definedFilterSetsList
1249:                        .getSelectedIndex();
1250:
1251:                if (selectedFilterSetIndex == -1) {
1252:                    selectedFilterSet = null;
1253:                } else {
1254:                    selectedFilterSet = filterSets
1255:                            .getFilterSetAt(selectedFilterSetIndex);
1256:                }
1257:
1258:                updateSelectedFilterSetProperties();
1259:            }
1260:
1261:            /*  public static void main(String args[]) {
1262:               try {
1263:                 UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); //NOI18N
1264:                 //UIManager.setLookAndFeel("plaf.metal.MetalLookAndFeel"); //NOI18N
1265:                 //UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); //NOI18N
1266:                 //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); //NOI18N
1267:               } catch (Exception e){};
1268:               JFrame frame = new JFrame("FilterSetsPanel Viewer"); //NOI18N
1269:               FilterSetsPanel filterSetsPanel = new FilterSetsPanel();
1270:               filterSetsPanel.setPreferredSize(new Dimension(600, 500));
1271:               frame.getContentPane().add(filterSetsPanel);
1272:               frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
1273:               frame.pack();
1274:               frame.show();
1275:               }
1276:             */
1277:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.