This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 228909
Collapse All | Expand All

(-)a/spi.viewmodel/apichanges.xml (+33 lines)
Lines 399-404 Link Here
399
        <class package="org.netbeans.spi.viewmodel" name="TableRendererModelFilter" />
399
        <class package="org.netbeans.spi.viewmodel" name="TableRendererModelFilter" />
400
        <issue number="186672"/>
400
        <issue number="186672"/>
401
    </change>
401
    </change>
402
    <change>
403
        <api name="ViewModelAPI"/>
404
        <summary>Separate the value and HTML value and allow custom property editors.</summary>
405
        <version major="1" minor="42"/>
406
        <date day="30" month="4" year="2013"/>
407
        <author login="mentlicher"/>
408
        <compatibility binary="compatible" source="compatible" deletion="no" addition="yes" modification="no"/>
409
        <description>
410
            So far the HTML value is automatically retrieved from the value provided
411
            by the <code>TableModel</code> when the value is a <code>String</code>
412
            and contains HTML code. This is not flexible enough and therefore
413
            we separate the value and HTML value by introduction of <code>TableHTMLModel</code>
414
            and <code>TableHTMLModelFilter</code>.<br/>
415
            In addition to that, this API change also brings a prossibility
416
            to provide custom property editor, separately for every value.
417
            Two interfaces are introduced for this purpose: <code>TablePropertyEditorsModel</code>
418
            and <code>TablePropertyEditorsModelFilter</code>.<br/>
419
            This also implies, that <code>Models.CompoundModel</code> now implements
420
            <code>TableHTMLModel</code> and <code>TablePropertyEditorsModel</code>.<br/>
421
            In order to be able to fire changes in HTML value and also in r/w state,
422
            an additional constructor of <code>ModelEvent.TableValueChanged</code>
423
            is added, which takes the change mask. Three change masks are defined:
424
            <code>VALUE_MASK</code>, <code>HTML_VALUE_MASK</code> and <code>IS_READ_ONLY_MASK</code>.
425
            To get the change mask, <code>ModelEvent.TableValueChanged.getChange()</code>
426
            method is added.
427
        </description>
428
        <class package="org.netbeans.spi.viewmodel" name="TableHTMLModel" />
429
        <class package="org.netbeans.spi.viewmodel" name="TableHTMLModelFilter" />
430
        <class package="org.netbeans.spi.viewmodel" name="TablePropertyEditorsModel" />
431
        <class package="org.netbeans.spi.viewmodel" name="TablePropertyEditorsModelFilter" />
432
        <class package="org.netbeans.spi.viewmodel" name="ModelEvent" />
433
        <issue number="228909"/>
434
    </change>
402
435
403
436
404
</changes>
437
</changes>
(-)a/spi.viewmodel/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.spi.viewmodel/2
2
OpenIDE-Module: org.netbeans.spi.viewmodel/2
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/viewmodel/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/viewmodel/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.41
4
OpenIDE-Module-Specification-Version: 1.42
5
5
(-)a/spi.viewmodel/src/org/netbeans/modules/viewmodel/TreeModelNode.java (-29 / +51 lines)
Lines 951-961 Link Here
951
        firePropertyChange(null, null, null);
951
        firePropertyChange(null, null, null);
952
    }
952
    }
953
    
953
    
954
    void refreshColumn(String column) {
954
    void refreshColumn(String column, int changeMask) {
955
        synchronized (properties) {
955
        synchronized (properties) {
956
            properties.remove(column);
956
            if ((ModelEvent.TableValueChanged.VALUE_MASK & changeMask) != 0) {
957
            properties.remove(column + "#html");
957
                properties.remove(column);
958
            properties.remove(column + "#canWrite");
958
            }
959
            if ((ModelEvent.TableValueChanged.HTML_VALUE_MASK & changeMask) != 0) {
960
                properties.remove(column + "#html");
961
            }
962
            if ((ModelEvent.TableValueChanged.IS_READ_ONLY_MASK & changeMask) != 0) {
963
                properties.remove(column + "#canWrite");
964
            }
959
        }
965
        }
960
        firePropertyChange(column, null, null);
966
        firePropertyChange(column, null, null);
961
    }
967
    }
Lines 1869-1882 Link Here
1869
        public void run() {
1875
        public void run() {
1870
            Object value = "";
1876
            Object value = "";
1871
            String htmlValue = null;
1877
            String htmlValue = null;
1872
            String nonHtmlValue = null;
1878
            Object nonHtmlValue = null;
1873
            try {
1879
            try {
1874
                //System.err.println("getValueAt("+object+", "+id+") of node "+TreeModelNode.this);
1880
                //System.err.println("getValueAt("+object+", "+id+") of node "+TreeModelNode.this);
1875
                value = model.getValueAt (object, id);
1881
                value = model.getValueAt (object, id);
1882
                nonHtmlValue = value;
1883
                boolean hasHTML = model.hasHTMLValueAt(object, id);
1884
                if (hasHTML) {
1885
                    htmlValue = model.getHTMLValueAt(object, id);
1886
                }
1876
                //System.err.println("  Value of ("+object+") executed in "+Thread.currentThread()+" is "+value);
1887
                //System.err.println("  Value of ("+object+") executed in "+Thread.currentThread()+" is "+value);
1877
                //System.out.println("  evaluateLazily("+TreeModelNode.this.getDisplayName()+", "+id+"): have value = "+value);
1888
                //System.out.println("  evaluateLazily("+TreeModelNode.this.getDisplayName()+", "+id+"): have value = "+value);
1878
                //System.out.println("      object = "+object+" class = "+((object != null) ? object.getClass().toString() : "null"));
1889
                //System.out.println("      object = "+object+" class = "+((object != null) ? object.getClass().toString() : "null"));
1879
                if (value instanceof String) {
1890
                if (!hasHTML && (value instanceof String)) { // For backward compatibility
1880
                    htmlValue = htmlValue ((String) value);
1891
                    htmlValue = htmlValue ((String) value);
1881
                    nonHtmlValue = removeHTML ((String) value);
1892
                    nonHtmlValue = removeHTML ((String) value);
1882
                }
1893
                }
Lines 1893-1904 Link Here
1893
                //evaluatedNotify.run();
1904
                //evaluatedNotify.run();
1894
                boolean fire;
1905
                boolean fire;
1895
                synchronized (properties) {
1906
                synchronized (properties) {
1896
                    if (value instanceof String) {
1907
                    properties.put (id, nonHtmlValue);
1897
                        properties.put (id, nonHtmlValue);
1908
                    properties.put (id + "#html", htmlValue);
1898
                        properties.put (id + "#html", htmlValue);
1899
                    } else {
1900
                        properties.put (id, value);
1901
                    }
1902
                    synchronized (evaluated) {
1909
                    synchronized (evaluated) {
1903
                        fire = evaluated[0] == -1;
1910
                        fire = evaluated[0] == -1;
1904
                        evaluated[0] = 1;
1911
                        evaluated[0] = 1;
Lines 1992-2004 Link Here
1992
        private Object getTheValue() {
1999
        private Object getTheValue() {
1993
            Object value = "";
2000
            Object value = "";
1994
            String htmlValue = null;
2001
            String htmlValue = null;
1995
            String nonHtmlValue = null;
2002
            Object nonHtmlValue = null;
1996
            try {
2003
            try {
1997
                value = model.getValueAt (object, id);
2004
                value = model.getValueAt (object, id);
2005
                nonHtmlValue = value;
2006
                boolean hasHTML = model.hasHTMLValueAt(object, id);
2007
                if (hasHTML) {
2008
                    htmlValue = model.getHTMLValueAt(object, id);
2009
                }
1998
                //System.err.println("  Value of ("+object+") executed in "+Thread.currentThread()+" is "+value);
2010
                //System.err.println("  Value of ("+object+") executed in "+Thread.currentThread()+" is "+value);
1999
                //System.out.println("  evaluateLazily("+TreeModelNode.this.getDisplayName()+", "+id+"): have value = "+value);
2011
                //System.out.println("  evaluateLazily("+TreeModelNode.this.getDisplayName()+", "+id+"): have value = "+value);
2000
                //System.out.println("      object = "+object+" class = "+((object != null) ? object.getClass().toString() : "null"));
2012
                //System.out.println("      object = "+object+" class = "+((object != null) ? object.getClass().toString() : "null"));
2001
                if (value instanceof String) {
2013
                if (!hasHTML && (value instanceof String)) { // For backward compatibility
2002
                    htmlValue = htmlValue ((String) value);
2014
                    htmlValue = htmlValue ((String) value);
2003
                    nonHtmlValue = removeHTML ((String) value);
2015
                    nonHtmlValue = removeHTML ((String) value);
2004
                }
2016
                }
Lines 2008-2019 Link Here
2008
                }
2020
                }
2009
            } finally {
2021
            } finally {
2010
                synchronized (properties) {
2022
                synchronized (properties) {
2011
                    if (value instanceof String) {
2023
                    properties.put (id, nonHtmlValue);
2012
                        properties.put (id, nonHtmlValue);
2024
                    properties.put (id + "#html", htmlValue);
2013
                        properties.put (id + "#html", htmlValue);
2014
                    } else {
2015
                        properties.put (id, value);
2016
                    }
2017
                }
2025
                }
2018
            }
2026
            }
2019
            return value;
2027
            return value;
Lines 2124-2136 Link Here
2124
                Object v = value;
2132
                Object v = value;
2125
                model.setValueAt (object, id, v);
2133
                model.setValueAt (object, id, v);
2126
                v = model.getValueAt(object, id); // Store the new value
2134
                v = model.getValueAt(object, id); // Store the new value
2135
                String htmlValue = null;
2136
                Object nonHtmlValue = v;
2137
                boolean hasHTML = model.hasHTMLValueAt(object, id);
2138
                if (hasHTML) {
2139
                    htmlValue = model.getHTMLValueAt(object, id);
2140
                }
2141
                if (!hasHTML && (v instanceof String)) { // For backward compatibility
2142
                    htmlValue = htmlValue ((String) v);
2143
                    nonHtmlValue = removeHTML ((String) v);
2144
                }
2127
                synchronized (properties) {
2145
                synchronized (properties) {
2128
                    if (v instanceof String) {
2146
                    properties.put (id, nonHtmlValue);
2129
                        properties.put (id, removeHTML ((String) v));
2147
                    properties.put (id + "#html", htmlValue);
2130
                        properties.put (id + "#html", htmlValue ((String) v));
2131
                    } else {
2132
                        properties.put (id, v);
2133
                    }
2134
                }
2148
                }
2135
                firePropertyChange (propertyId, null, null);
2149
                firePropertyChange (propertyId, null, null);
2136
            } catch (UnknownTypeException e) {
2150
            } catch (UnknownTypeException e) {
Lines 2140-2150 Link Here
2140
        
2154
        
2141
        @Override
2155
        @Override
2142
        public PropertyEditor getPropertyEditor () {
2156
        public PropertyEditor getPropertyEditor () {
2143
            PropertyEditor pe = columnModel.getPropertyEditor ();
2157
            PropertyEditor pe = null;
2158
            try {
2159
                pe = model.getPropertyEditor(object, id);
2160
            } catch (UnknownTypeException ex) {
2161
                Logger.getLogger(TreeModelNode.class.getName()).log(Level.CONFIG, "Column id:" + columnModel.getID ()+"\nModel: "+model, ex);
2162
            }
2144
            if (pe == null) {
2163
            if (pe == null) {
2164
                pe = columnModel.getPropertyEditor ();
2165
            }
2166
            if (pe != null) {
2167
                return pe;
2168
            } else {
2145
                return super.getPropertyEditor();
2169
                return super.getPropertyEditor();
2146
            } else {
2147
                return pe;
2148
            }
2170
            }
2149
        }
2171
        }
2150
2172
(-)a/spi.viewmodel/src/org/netbeans/modules/viewmodel/TreeModelRoot.java (-1 / +2 lines)
Lines 334-343 Link Here
334
                        if (node != null) {
334
                        if (node != null) {
335
                            TreeModelNode[] tmNodes = findNode(node);
335
                            TreeModelNode[] tmNodes = findNode(node);
336
                            //System.err.println("  nodes = "+Arrays.toString(tmNodes));
336
                            //System.err.println("  nodes = "+Arrays.toString(tmNodes));
337
                            int change = tvEvent.getChange();
337
                            for (TreeModelNode tmNode : tmNodes) {
338
                            for (TreeModelNode tmNode : tmNodes) {
338
                                String column = tvEvent.getColumnID();
339
                                String column = tvEvent.getColumnID();
339
                                if (column != null) {
340
                                if (column != null) {
340
                                    tmNode.refreshColumn(column);
341
                                    tmNode.refreshColumn(column, change);
341
                                } else {
342
                                } else {
342
                                    tmNode.refresh(model);
343
                                    tmNode.refresh(model);
343
                                }
344
                                }
(-)a/spi.viewmodel/src/org/netbeans/spi/viewmodel/ModelEvent.java (+46 lines)
Lines 87-94 Link Here
87
     */
87
     */
88
    public static class TableValueChanged extends ModelEvent {
88
    public static class TableValueChanged extends ModelEvent {
89
        
89
        
90
        /**
91
         * The mask for value change.
92
         * @since 1.42
93
         */
94
        public static final int VALUE_MASK = 1;
95
        /**
96
         * The mask for HTML value change.
97
         * @since 1.42
98
         */
99
        public static final int HTML_VALUE_MASK = 2;
100
        /**
101
         * The mask for change of the read only state.
102
         * @since 1.42
103
         */
104
        public static final int IS_READ_ONLY_MASK = 4;
105
        
90
        private Object node;
106
        private Object node;
91
        private String columnID;
107
        private String columnID;
108
        private int change;
92
        
109
        
93
        /**
110
        /**
94
         * Creates a new instance of TableValueChanged event.
111
         * Creates a new instance of TableValueChanged event.
Lines 104-112 Link Here
104
            Object node,
121
            Object node,
105
            String columnID
122
            String columnID
106
        ) {
123
        ) {
124
            this(source, node, columnID, 0xffffffff);
125
        }
126
        
127
        /**
128
         * Creates a new instance of TableValueChanged event.
129
         *
130
         * @param source a source if event.
131
         * @param node a changed node instance
132
         * @param columnID a changed column name
133
         * @param change one of the *_MASK constants or their aggregation.
134
         * @since 1.42
135
         */
136
        public TableValueChanged (
137
            Object source, 
138
            Object node,
139
            String columnID,
140
            int change
141
        ) {
107
            super (source);
142
            super (source);
108
            this.node = node;
143
            this.node = node;
109
            this.columnID = columnID;
144
            this.columnID = columnID;
145
            this.change = change;
110
        }
146
        }
111
        
147
        
112
        /**
148
        /**
Lines 130-135 Link Here
130
        public String getColumnID () {
166
        public String getColumnID () {
131
            return columnID;
167
            return columnID;
132
        }
168
        }
169
        
170
        /**
171
         * Get the change mask.
172
         *
173
         * @return the change mask, one of the *_MASK constants or their aggregation.
174
         * @since 1.42
175
         */
176
        public int getChange() {
177
            return change;
178
        }
133
    }
179
    }
134
    
180
    
135
    /**
181
    /**
(-)a/spi.viewmodel/src/org/netbeans/spi/viewmodel/Models.java (-26 / +365 lines)
Lines 48-53 Link Here
48
import java.awt.datatransfer.Transferable;
48
import java.awt.datatransfer.Transferable;
49
import java.awt.dnd.DnDConstants;
49
import java.awt.dnd.DnDConstants;
50
import java.awt.event.ActionEvent;
50
import java.awt.event.ActionEvent;
51
import java.beans.PropertyEditor;
51
import java.io.IOException;
52
import java.io.IOException;
52
import java.lang.ref.Reference;
53
import java.lang.ref.Reference;
53
import java.lang.ref.WeakReference;
54
import java.lang.ref.WeakReference;
Lines 266-272 Link Here
266
        // ; or the models directly
267
        // ; or the models directly
267
        boolean hasLists = false;
268
        boolean hasLists = false;
268
        int modelsSize = models.size();
269
        int modelsSize = models.size();
269
        if (11 <= modelsSize && modelsSize <= 15) {
270
        if (11 <= modelsSize && modelsSize <= 18) {
270
            Iterator it = models.iterator ();
271
            Iterator it = models.iterator ();
271
            boolean failure = false;
272
            boolean failure = false;
272
            while (it.hasNext ()) {
273
            while (it.hasNext ()) {
Lines 306-311 Link Here
306
                            ml.tableRendererModels = (List<TableRendererModel>) models.get(13);
307
                            ml.tableRendererModels = (List<TableRendererModel>) models.get(13);
307
                            if (modelsSize > 14) {
308
                            if (modelsSize > 14) {
308
                                ml.tableRendererModelFilters = (List<TableRendererModelFilter>) models.get(14);
309
                                ml.tableRendererModelFilters = (List<TableRendererModelFilter>) models.get(14);
310
                                //if (modelsSize > 15) {
311
                                //    ml.tableHtmlModels = (List<TableHTMLModel>) models.get(15);
312
                                    if (modelsSize > 15) {
313
                                        ml.tableHtmlModelFilters = (List<TableHTMLModelFilter>) models.get(15);
314
                                        if (modelsSize > 16) {
315
                                            ml.tablePropertyEditorsModels = (List<TablePropertyEditorsModel>) models.get(16);
316
                                            if (modelsSize > 17) {
317
                                                ml.tablePropertyEditorsModelFilters = (List<TablePropertyEditorsModelFilter>) models.get(17);
318
                                            }
319
                                        }
320
                                    }
321
                                //}
309
                            }
322
                            }
310
                        }
323
                        }
311
                    }
324
                    }
Lines 400-406 Link Here
400
                new DefaultAsynchronousModel(),//new DelegatingAsynchronousModel (ml.asynchModels),
413
                new DefaultAsynchronousModel(),//new DelegatingAsynchronousModel (ml.asynchModels),
401
                ml.asynchModelFilters
414
                ml.asynchModelFilters
402
            ),
415
            ),
403
            null,
416
            null, null,
404
            propertiesHelpID
417
            propertiesHelpID
405
        );
418
        );
406
        } else {
419
        } else {
Lines 424-430 Link Here
424
            ml.columnModels,
437
            ml.columnModels,
425
            createCompoundTableModel (
438
            createCompoundTableModel (
426
                new DelegatingTableModel (ml.tableModels),
439
                new DelegatingTableModel (ml.tableModels),
427
                ml.tableModelFilters
440
                ml.tableModelFilters,
441
                ml.tableHtmlModelFilters
428
            ),
442
            ),
429
            createCompoundAsynchronousModel (
443
            createCompoundAsynchronousModel (
430
                new DefaultAsynchronousModel(),//new DelegatingAsynchronousModel (ml.asynchModels),
444
                new DefaultAsynchronousModel(),//new DelegatingAsynchronousModel (ml.asynchModels),
Lines 434-439 Link Here
434
                new DelegatingTableRendererModel(ml.tableRendererModels),
448
                new DelegatingTableRendererModel(ml.tableRendererModels),
435
                ml.tableRendererModelFilters
449
                ml.tableRendererModelFilters
436
            ),
450
            ),
451
            /*createCompoundTableHTMLModel (
452
                new DelegatingTableHTMLModel(ml.tableHtmlModels),
453
                ml.tableHtmlModelFilters
454
            ),*/
455
            createCompoundTablePropertyEditorModel (
456
                new DelegatingTablePropertyEditorsModel(ml.tablePropertyEditorsModels),
457
                ml.tablePropertyEditorsModelFilters
458
            ),
437
            propertiesHelpID
459
            propertiesHelpID
438
        );
460
        );
439
        }
461
        }
Lines 557-567 Link Here
557
     *
579
     *
558
     * @returns compound table model
580
     * @returns compound table model
559
     */
581
     */
560
    private static TableModel createCompoundTableModel (
582
    private static TableHTMLModel createCompoundTableModel (
561
        TableModel originalTableModel,
583
        TableHTMLModel originalTableModel,
562
        List tableModelFilters
584
        List tableModelFilters,
585
        List tableHtmlModelFilters
563
    ) {
586
    ) {
564
        TableModel tm = originalTableModel;
587
        TableHTMLModel tm = originalTableModel;
565
        int i, k = tableModelFilters.size ();
588
        int i, k = tableModelFilters.size ();
566
        for (i = 0; i < k; i++) {
589
        for (i = 0; i < k; i++) {
567
            tm = new CompoundTableModel (
590
            tm = new CompoundTableModel (
Lines 569-574 Link Here
569
                (TableModelFilter) tableModelFilters.get (i)
592
                (TableModelFilter) tableModelFilters.get (i)
570
            );
593
            );
571
        }
594
        }
595
        k = tableHtmlModelFilters.size ();
596
        for (i = 0; i < k; i++) {
597
            tm = new CompoundTableModel (
598
                tm,
599
                (TableHTMLModelFilter) tableHtmlModelFilters.get (i)
600
            );
601
        }
572
        return tm;
602
        return tm;
573
    }
603
    }
574
    
604
    
Lines 595-600 Link Here
595
        }
625
        }
596
        return tm;
626
        return tm;
597
    }
627
    }
628
    
629
    private static TablePropertyEditorsModel createCompoundTablePropertyEditorModel (
630
        TablePropertyEditorsModel originalTableModel,
631
        List tableModelFilters
632
    ) {
633
        TablePropertyEditorsModel tm = originalTableModel;
634
        int i, k = tableModelFilters.size ();
635
        for (i = 0; i < k; i++) {
636
            tm = new CompoundTablePropertyEditorsModel (
637
                tm,
638
                (TablePropertyEditorsModelFilter) tableModelFilters.get (i)
639
            );
640
        }
641
        return tm;
642
    }
598
643
599
    /**
644
    /**
600
     * Creates {@link org.netbeans.spi.viewmodel.NodeActionsProvider} for given NodeActionsProvider and
645
     * Creates {@link org.netbeans.spi.viewmodel.NodeActionsProvider} for given NodeActionsProvider and
Lines 1031-1037 Link Here
1031
        } else if (event instanceof ModelEvent.TableValueChanged) {
1076
        } else if (event instanceof ModelEvent.TableValueChanged) {
1032
            newEvent = new ModelEvent.TableValueChanged(newSource,
1077
            newEvent = new ModelEvent.TableValueChanged(newSource,
1033
                    ((ModelEvent.TableValueChanged) event).getNode(),
1078
                    ((ModelEvent.TableValueChanged) event).getNode(),
1034
                    ((ModelEvent.TableValueChanged) event).getColumnID());
1079
                    ((ModelEvent.TableValueChanged) event).getColumnID(),
1080
                    ((ModelEvent.TableValueChanged) event).getChange());
1035
        } else if (event instanceof ModelEvent.TreeChanged) {
1081
        } else if (event instanceof ModelEvent.TreeChanged) {
1036
            newEvent = new ModelEvent.TreeChanged(newSource);
1082
            newEvent = new ModelEvent.TreeChanged(newSource);
1037
        } else {
1083
        } else {
Lines 1357-1367 Link Here
1357
     * 
1403
     * 
1358
     * @author   Jan Jancura
1404
     * @author   Jan Jancura
1359
     */
1405
     */
1360
    private final static class CompoundTableModel implements TableModel, ModelListener {
1406
    private final static class CompoundTableModel implements TableHTMLModel, ModelListener {
1361
1407
1362
1408
1363
        private TableModel model;
1409
        private TableHTMLModel model;
1364
        private TableModelFilter filter;
1410
        private TableModelFilter filter;
1411
        private TableHTMLModelFilter htmlFilter;
1365
1412
1366
        private final Collection<ModelListener> modelListeners = new HashSet<ModelListener>();
1413
        private final Collection<ModelListener> modelListeners = new HashSet<ModelListener>();
1367
1414
Lines 1370-1380 Link Here
1370
         * Creates {@link org.netbeans.spi.viewmodel.TableModel} for given TableModel and
1417
         * Creates {@link org.netbeans.spi.viewmodel.TableModel} for given TableModel and
1371
         * {@link org.netbeans.spi.viewmodel.TableModelFilter}.
1418
         * {@link org.netbeans.spi.viewmodel.TableModelFilter}.
1372
         */
1419
         */
1373
        CompoundTableModel (TableModel model, TableModelFilter filter) {
1420
        CompoundTableModel (TableHTMLModel model, TableModelFilter filter) {
1374
            this.model = model;
1421
            this.model = model;
1375
            this.filter = filter;
1422
            this.filter = filter;
1376
        }
1423
        }
1377
    
1424
    
1425
        CompoundTableModel (TableHTMLModel model, TableHTMLModelFilter htmlFilter) {
1426
            this.model = model;
1427
            this.htmlFilter = htmlFilter;
1428
        }
1429
    
1378
        /**
1430
        /**
1379
         * Returns value to be displayed in column <code>columnID</code>
1431
         * Returns value to be displayed in column <code>columnID</code>
1380
         * and row <code>node</code>. Column ID is defined in by 
1432
         * and row <code>node</code>. Column ID is defined in by 
Lines 1391-1397 Link Here
1391
        @Override
1443
        @Override
1392
        public Object getValueAt (Object node, String columnID) throws 
1444
        public Object getValueAt (Object node, String columnID) throws 
1393
        UnknownTypeException {
1445
        UnknownTypeException {
1394
            return filter.getValueAt (model, node, columnID);
1446
            if (filter != null) {
1447
                return filter.getValueAt (model, node, columnID);
1448
            } else {
1449
                return model.getValueAt(node, columnID);
1450
            }
1451
        }
1452
1453
        @Override
1454
        public boolean hasHTMLValueAt(Object node, String columnID) throws UnknownTypeException {
1455
            if (htmlFilter != null) {
1456
                return htmlFilter.hasHTMLValueAt(model, node, columnID);
1457
            } else {
1458
                return model.hasHTMLValueAt(node, columnID);
1459
            }
1460
        }
1461
1462
        @Override
1463
        public String getHTMLValueAt(Object node, String columnID) throws UnknownTypeException {
1464
            if (htmlFilter != null) {
1465
                return htmlFilter.getHTMLValueAt(model, node, columnID);
1466
            } else {
1467
                return model.getHTMLValueAt(node, columnID);
1468
            }
1395
        }
1469
        }
1396
1470
1397
        /**
1471
        /**
Lines 1410-1416 Link Here
1410
        @Override
1484
        @Override
1411
        public boolean isReadOnly (Object node, String columnID) throws 
1485
        public boolean isReadOnly (Object node, String columnID) throws 
1412
        UnknownTypeException {
1486
        UnknownTypeException {
1413
            return filter.isReadOnly (model, node, columnID);
1487
            if (filter != null) {
1488
                return filter.isReadOnly (model, node, columnID);
1489
            } else {
1490
                return model.isReadOnly(node, columnID);
1491
            }
1414
        }
1492
        }
1415
1493
1416
        /**
1494
        /**
Lines 1428-1434 Link Here
1428
        @Override
1506
        @Override
1429
        public void setValueAt (Object node, String columnID, Object value) 
1507
        public void setValueAt (Object node, String columnID, Object value) 
1430
        throws UnknownTypeException {
1508
        throws UnknownTypeException {
1431
            filter.setValueAt (model, node, columnID, value);
1509
            if (filter != null) {
1510
                filter.setValueAt (model, node, columnID, value);
1511
            } else {
1512
                model.setValueAt(node, columnID, value);
1513
            }
1432
        }
1514
        }
1433
1515
1434
        /** 
1516
        /** 
Lines 1440-1446 Link Here
1440
        public void addModelListener (ModelListener l) {
1522
        public void addModelListener (ModelListener l) {
1441
            synchronized (modelListeners) {
1523
            synchronized (modelListeners) {
1442
                if (modelListeners.isEmpty()) {
1524
                if (modelListeners.isEmpty()) {
1443
                    filter.addModelListener (this);
1525
                    if (filter != null) {
1526
                        filter.addModelListener (this);
1527
                    }
1444
                    model.addModelListener (this);
1528
                    model.addModelListener (this);
1445
                }
1529
                }
1446
                modelListeners.add(l);
1530
                modelListeners.add(l);
Lines 1457-1463 Link Here
1457
            synchronized (modelListeners) {
1541
            synchronized (modelListeners) {
1458
                modelListeners.remove(l);
1542
                modelListeners.remove(l);
1459
                if (modelListeners.isEmpty()) {
1543
                if (modelListeners.isEmpty()) {
1460
                    filter.removeModelListener (this);
1544
                    if (filter != null) {
1545
                        filter.removeModelListener (this);
1546
                    }
1461
                    model.removeModelListener (this);
1547
                    model.removeModelListener (this);
1462
                }
1548
                }
1463
            }
1549
            }
Lines 1490-1504 Link Here
1490
        }
1576
        }
1491
        
1577
        
1492
        public String toString (String n) {
1578
        public String toString (String n) {
1579
            Model theFilter = (filter != null) ? filter : htmlFilter;
1493
            if (model instanceof CompoundTableModel) {
1580
            if (model instanceof CompoundTableModel) {
1494
                return n + filter + "\n" +
1581
                return n + theFilter + "\n" +
1495
                    ((CompoundTableModel) model).toString (n + "  ");
1582
                    ((CompoundTableModel) model).toString (n + "  ");
1496
            }
1583
            }
1497
            if (model instanceof DelegatingTableModel) {
1584
            if (model instanceof DelegatingTableModel) {
1498
                return n + filter + "\n" +
1585
                return n + theFilter + "\n" +
1499
                    ((DelegatingTableModel) model).toString (n + "  ");
1586
                    ((DelegatingTableModel) model).toString (n + "  ");
1500
            }
1587
            }
1501
            return n + filter + "\n" + 
1588
            return n + theFilter + "\n" + 
1502
                   n + "  " + model;
1589
                   n + "  " + model;
1503
        }
1590
        }
1504
    }
1591
    }
Lines 1899-1904 Link Here
1899
        }
1986
        }
1900
    }
1987
    }
1901
    
1988
    
1989
    private final static class CompoundTablePropertyEditorsModel implements TablePropertyEditorsModel {
1990
        
1991
        private TablePropertyEditorsModel model;
1992
        private TablePropertyEditorsModelFilter filter;
1993
        
1994
        CompoundTablePropertyEditorsModel(TablePropertyEditorsModel model, TablePropertyEditorsModelFilter filter) {
1995
            this.model = model;
1996
            this.filter = filter;
1997
        }
1998
1999
        @Override
2000
        public PropertyEditor getPropertyEditor(Object node, String columnID) throws UnknownTypeException {
2001
            return filter.getPropertyEditor(model, node, columnID);
2002
        }
2003
        
2004
        @Override
2005
        public String toString () {
2006
            return super.toString () + "\n" + toString ("    ");
2007
        }
2008
2009
        public String toString (String n) {
2010
            if (model instanceof CompoundTablePropertyEditorsModel) {
2011
                return n + filter + "\n" +
2012
                    ((CompoundTablePropertyEditorsModel) model).toString (n + "  ");
2013
            }
2014
            if (model instanceof DelegatingTablePropertyEditorsModel) {
2015
                return n + filter + "\n" +
2016
                    ((DelegatingTablePropertyEditorsModel) model).toString (n + "  ");
2017
            }
2018
            return n + filter + "\n" +
2019
                   n + "  " + model;
2020
        }
2021
    }
2022
    
1902
    /**
2023
    /**
1903
     * Creates {@link org.netbeans.spi.viewmodel.NodeActionsProvider} 
2024
     * Creates {@link org.netbeans.spi.viewmodel.NodeActionsProvider} 
1904
     * for given NodeActionsProvider and
2025
     * for given NodeActionsProvider and
Lines 2078-2084 Link Here
2078
     *
2199
     *
2079
     * @author   Jan Jancura
2200
     * @author   Jan Jancura
2080
     */
2201
     */
2081
    private final static class DelegatingTableModel implements TableModel {
2202
    private final static class DelegatingTableModel implements TableModel, TableHTMLModel {
2082
2203
2083
        private TableModel[] models;
2204
        private TableModel[] models;
2084
        private HashMap<String, TableModel> classNameToModel = new HashMap<String, TableModel>();
2205
        private HashMap<String, TableModel> classNameToModel = new HashMap<String, TableModel>();
Lines 2286-2291 Link Here
2286
            sb.append (models [i]);
2407
            sb.append (models [i]);
2287
            return new String (sb);
2408
            return new String (sb);
2288
        }
2409
        }
2410
        
2411
        // HTML extension:
2412
2413
        private boolean defaultHasHTMLValueAt() {
2414
            return false;
2415
        }
2416
        
2417
        @Override
2418
        public boolean hasHTMLValueAt(Object node, String columnID) throws UnknownTypeException {
2419
            UnknownTypeException uex = null;
2420
            TableModel model = classNameToModel.get (
2421
                node.getClass ().getName ()
2422
            );
2423
            if (model != null) {
2424
                if (model instanceof TableHTMLModel) {
2425
                    try {
2426
                        return ((TableHTMLModel) model).hasHTMLValueAt(node, columnID);
2427
                    } catch (UnknownTypeException e) {
2428
                        uex = e;
2429
                    }
2430
                } else {
2431
                    return defaultHasHTMLValueAt();
2432
                }
2433
            }
2434
            int i, k = models.length;
2435
            boolean isHTML = false;
2436
            for (i = 0; i < k; i++) {
2437
                if (models[i] instanceof TableHTMLModel) {
2438
                    try {
2439
                        boolean has = ((TableHTMLModel) models [i]).hasHTMLValueAt(node, columnID);
2440
                        classNameToModel.put (node.getClass ().getName (), models [i]);
2441
                        return has;
2442
                    } catch (UnknownTypeException e) {
2443
                        uex = e;
2444
                    }
2445
                    isHTML = true;
2446
                }
2447
            }
2448
            if (!isHTML) {
2449
                return defaultHasHTMLValueAt();
2450
            }
2451
            if (uex != null) {
2452
                throw uex;
2453
            } else {
2454
                throw new UnknownTypeException (node);
2455
            }
2456
        }
2457
2458
        @Override
2459
        public String getHTMLValueAt(Object node, String columnID) throws UnknownTypeException {
2460
            UnknownTypeException uex = null;
2461
            TableModel model = classNameToModel.get (
2462
                node.getClass ().getName ()
2463
            );
2464
            if (model != null) {
2465
                if (model instanceof TableHTMLModel) {
2466
                    try {
2467
                        return ((TableHTMLModel) model).getHTMLValueAt(node, columnID);
2468
                    } catch (UnknownTypeException e) {
2469
                        uex = e;
2470
                    }
2471
                } else {
2472
                    return null;
2473
                }
2474
            }
2475
            int i, k = models.length;
2476
            boolean isHTML = false;
2477
            for (i = 0; i < k; i++) {
2478
                if (models[i] instanceof TableHTMLModel) {
2479
                    try {
2480
                        String htmlValue = ((TableHTMLModel) models [i]).getHTMLValueAt(node, columnID);
2481
                        classNameToModel.put (node.getClass ().getName (), models [i]);
2482
                        return htmlValue;
2483
                    } catch (UnknownTypeException e) {
2484
                        uex = e;
2485
                    }
2486
                    isHTML = true;
2487
                }
2488
            }
2489
            if (!isHTML) {
2490
                return null;
2491
            }
2492
            if (uex != null) {
2493
                throw uex;
2494
            } else {
2495
                throw new UnknownTypeException (node);
2496
            }
2497
        }
2289
    }
2498
    }
2290
2499
2291
    /**
2500
    /**
Lines 2484-2489 Link Here
2484
        }
2693
        }
2485
2694
2486
    }
2695
    }
2696
    
2697
    private final static class DelegatingTablePropertyEditorsModel implements TablePropertyEditorsModel {
2698
        
2699
        private TablePropertyEditorsModel[] models;
2700
        private HashMap<String, TablePropertyEditorsModel> classNameToModel = new HashMap<String, TablePropertyEditorsModel>();
2701
        
2702
        DelegatingTablePropertyEditorsModel(List<TablePropertyEditorsModel> models) {
2703
            this(convert(models));
2704
        }
2705
        
2706
        private static TablePropertyEditorsModel[] convert(List<TablePropertyEditorsModel> l) {
2707
            TablePropertyEditorsModel[] models = new TablePropertyEditorsModel[l.size()];
2708
            return l.toArray(models);
2709
        }
2710
        
2711
        DelegatingTablePropertyEditorsModel(TablePropertyEditorsModel[] models) {
2712
            this.models = models;
2713
        }
2714
2715
        @Override
2716
        public PropertyEditor getPropertyEditor(Object node, String columnID) throws UnknownTypeException {
2717
            UnknownTypeException utex = null;
2718
            TablePropertyEditorsModel model = classNameToModel.get(
2719
                    node.getClass().getName()
2720
            );
2721
            if (model != null) {
2722
                try {
2723
                    return model.getPropertyEditor(node, columnID);
2724
                } catch (UnknownTypeException e) {
2725
                    utex = e;
2726
                }
2727
            }
2728
            int i, k = models.length;
2729
            for (i = 0; i < k; i++) {
2730
                try {
2731
                    PropertyEditor pe = models [i].getPropertyEditor(node, columnID);
2732
                    classNameToModel.put (node.getClass ().getName (), models [i]);
2733
                    return pe;
2734
                } catch (UnknownTypeException e) {
2735
                    utex = e;
2736
                }
2737
            }
2738
            if (k == 0) {
2739
                return null;
2740
            }
2741
            if (utex != null) {
2742
                throw utex;
2743
            } else {
2744
                throw new UnknownTypeException (node);
2745
            }
2746
        }
2747
2748
        @Override
2749
        public String toString () {
2750
            return super.toString () + "\n" + toString ("    ");
2751
        }
2752
2753
        public String toString (String n) {
2754
            int i, k = models.length - 1;
2755
            if (k == -1) {
2756
                return "";
2757
            }
2758
            StringBuffer sb = new StringBuffer ();
2759
            for (i = 0; i < k; i++) {
2760
                sb.append (n);
2761
                sb.append (models [i]);
2762
                sb.append ('\n');
2763
            }
2764
            sb.append (n);
2765
            sb.append (models [i]);
2766
            return new String (sb);
2767
        }
2768
    }
2487
2769
2488
    /**
2770
    /**
2489
     * Creates one {@link org.netbeans.spi.viewmodel.TableModel}
2771
     * Creates one {@link org.netbeans.spi.viewmodel.TableModel}
Lines 3955-3963 Link Here
3955
                                                       CheckNodeModel,
4237
                                                       CheckNodeModel,
3956
                                                       DnDNodeModel,
4238
                                                       DnDNodeModel,
3957
                                                       NodeActionsProvider,
4239
                                                       NodeActionsProvider,
3958
                                                       TableModel,
4240
                                                       TableHTMLModel,
3959
                                                       TreeExpansionModel,
4241
                                                       TreeExpansionModel,
3960
                                                       TableRendererModel {
4242
                                                       TableRendererModel,
4243
                                                       TablePropertyEditorsModel {
3961
4244
3962
        private ReorderableTreeModel treeModel;
4245
        private ReorderableTreeModel treeModel;
3963
        private ExtendedNodeModel nodeModel;
4246
        private ExtendedNodeModel nodeModel;
Lines 3965-3972 Link Here
3965
        private DnDNodeModel    dndNodeModel;
4248
        private DnDNodeModel    dndNodeModel;
3966
        private NodeActionsProvider nodeActionsProvider;
4249
        private NodeActionsProvider nodeActionsProvider;
3967
        private ColumnModel[]   columnModels;
4250
        private ColumnModel[]   columnModels;
3968
        private TableModel      tableModel;
4251
        private TableHTMLModel  tableModel;
3969
        private TableRendererModel tableRendererModel;
4252
        private TableRendererModel tableRendererModel;
4253
        private TablePropertyEditorsModel tablePropertyEditorsModel;
3970
        private TreeExpansionModel treeExpansionModel;
4254
        private TreeExpansionModel treeExpansionModel;
3971
        private AsynchronousModel asynchModel;
4255
        private AsynchronousModel asynchModel;
3972
4256
Lines 3997-4005 Link Here
3997
            ExtendedNodeModel nodeModel, 
4281
            ExtendedNodeModel nodeModel, 
3998
            NodeActionsProvider nodeActionsProvider,
4282
            NodeActionsProvider nodeActionsProvider,
3999
            List<ColumnModel> columnModels,
4283
            List<ColumnModel> columnModels,
4000
            TableModel tableModel,
4284
            TableHTMLModel tableModel,
4001
            AsynchronousModel asynchModel,
4285
            AsynchronousModel asynchModel,
4002
            TableRendererModel tableRendererModel,
4286
            TableRendererModel tableRendererModel,
4287
            TablePropertyEditorsModel tablePropertyEditorsModel,
4003
            String propertiesHelpID
4288
            String propertiesHelpID
4004
        ) {
4289
        ) {
4005
            if (treeModel == null || nodeModel == null || tableModel == null ||
4290
            if (treeModel == null || nodeModel == null || tableModel == null ||
Lines 4024-4029 Link Here
4024
            }
4309
            }
4025
            this.tableModel = tableModel;
4310
            this.tableModel = tableModel;
4026
            this.tableRendererModel = tableRendererModel;
4311
            this.tableRendererModel = tableRendererModel;
4312
            this.tablePropertyEditorsModel = tablePropertyEditorsModel;
4027
            this.nodeActionsProvider = nodeActionsProvider;
4313
            this.nodeActionsProvider = nodeActionsProvider;
4028
            this.columnModels = columnModels.toArray (
4314
            this.columnModels = columnModels.toArray (
4029
                new ColumnModel [columnModels.size ()]
4315
                new ColumnModel [columnModels.size ()]
Lines 4582-4587 Link Here
4582
                return null;
4868
                return null;
4583
            }
4869
            }
4584
        }
4870
        }
4871
        
4872
        // TableHTMLModel
4873
4874
        @Override
4875
        public boolean hasHTMLValueAt(Object node, String columnID) throws UnknownTypeException {
4876
            return tableModel.hasHTMLValueAt(node, columnID);
4877
        }
4878
4879
        @Override
4880
        public String getHTMLValueAt(Object node, String columnID) throws UnknownTypeException {
4881
            return tableModel.getHTMLValueAt(node, columnID);
4882
        }
4883
        
4884
        // TablePropertyEditorsModel
4885
4886
        @Override
4887
        public PropertyEditor getPropertyEditor(Object node, String columnID) throws UnknownTypeException {
4888
            if (tablePropertyEditorsModel != null) {
4889
                return tablePropertyEditorsModel.getPropertyEditor(node, columnID);
4890
            } else {
4891
                return null;
4892
            }
4893
        }
4894
        
4895
        
4585
4896
4586
    }
4897
    }
4587
4898
Lines 4602-4607 Link Here
4602
        public List<AsynchronousModelFilter>   asynchModelFilters = Collections.emptyList();
4913
        public List<AsynchronousModelFilter>   asynchModelFilters = Collections.emptyList();
4603
        public List<TableRendererModel>        tableRendererModels = Collections.emptyList();
4914
        public List<TableRendererModel>        tableRendererModels = Collections.emptyList();
4604
        public List<TableRendererModelFilter>  tableRendererModelFilters = Collections.emptyList();
4915
        public List<TableRendererModelFilter>  tableRendererModelFilters = Collections.emptyList();
4916
        public List<TableHTMLModel>            tableHtmlModels = Collections.emptyList();
4917
        public List<TableHTMLModelFilter>      tableHtmlModelFilters = Collections.emptyList();
4918
        public List<TablePropertyEditorsModel> tablePropertyEditorsModels = Collections.emptyList();
4919
        public List<TablePropertyEditorsModelFilter> tablePropertyEditorsModelFilters = Collections.emptyList();
4605
4920
4606
        public void addOtherModels(List<? extends Model> otherModels) {
4921
        public void addOtherModels(List<? extends Model> otherModels) {
4607
            Iterator it = otherModels.iterator ();
4922
            Iterator it = otherModels.iterator ();
Lines 4668-4673 Link Here
4668
                        tableRendererModelFilters.add(0, (TableRendererModelFilter) model);
4983
                        tableRendererModelFilters.add(0, (TableRendererModelFilter) model);
4669
                    }
4984
                    }
4670
                }
4985
                }
4986
                if (model instanceof TableHTMLModel && !tableHtmlModels.contains((TableHTMLModel) model)) {
4987
                    tableHtmlModels = new ArrayList<TableHTMLModel>(tableHtmlModels);
4988
                    tableHtmlModels.add((TableHTMLModel) model);
4989
                }
4990
                if (model instanceof TableHTMLModelFilter && !tableHtmlModelFilters.contains((TableHTMLModelFilter) model)) {
4991
                    tableHtmlModelFilters = new ArrayList<TableHTMLModelFilter>(tableHtmlModelFilters);
4992
                    if (first) {
4993
                        tableHtmlModelFilters.add((TableHTMLModelFilter) model);
4994
                    } else {
4995
                        tableHtmlModelFilters.add(0, (TableHTMLModelFilter) model);
4996
                    }
4997
                }
4998
                if (model instanceof TablePropertyEditorsModel && !tablePropertyEditorsModels.contains((TablePropertyEditorsModel) model)) {
4999
                    tablePropertyEditorsModels = new ArrayList<TablePropertyEditorsModel>(tablePropertyEditorsModels);
5000
                    tablePropertyEditorsModels.add((TablePropertyEditorsModel) model);
5001
                }
5002
                if (model instanceof TablePropertyEditorsModelFilter && !tablePropertyEditorsModelFilters.contains((TablePropertyEditorsModelFilter) model)) {
5003
                    tablePropertyEditorsModelFilters = new ArrayList<TablePropertyEditorsModelFilter>(tablePropertyEditorsModelFilters);
5004
                    if (first) {
5005
                        tablePropertyEditorsModelFilters.add((TablePropertyEditorsModelFilter) model);
5006
                    } else {
5007
                        tablePropertyEditorsModelFilters.add(0, (TablePropertyEditorsModelFilter) model);
5008
                    }
5009
                }
4671
                if (model instanceof NodeActionsProvider && !nodeActionsProviders.contains((NodeActionsProvider) model)) {
5010
                if (model instanceof NodeActionsProvider && !nodeActionsProviders.contains((NodeActionsProvider) model)) {
4672
                    nodeActionsProviders = new ArrayList<NodeActionsProvider>(nodeActionsProviders);
5011
                    nodeActionsProviders = new ArrayList<NodeActionsProvider>(nodeActionsProviders);
4673
                    nodeActionsProviders.add((NodeActionsProvider) model);
5012
                    nodeActionsProviders.add((NodeActionsProvider) model);
(-)a/spi.viewmodel/src/org/netbeans/spi/viewmodel/TableHTMLModel.java (+90 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.spi.viewmodel;
43
44
/**
45
 * Use this to separate value and the HTML value.
46
 * When displaying a property value, then if the value is a String and if it contains
47
 * a HTML code, it's automatically rendered as HTML. The HTML code is then
48
 * stripped out to get the raw value.
49
 * If this is not desired or if it's necessary to provide a value and HTML code
50
 * that differs from each other, implement this model.
51
 * 
52
 * @author Martin Entlicher
53
 * @since 1.42
54
 * @see TableHTMLModelFilter
55
 */
56
public interface TableHTMLModel extends TableModel {
57
    
58
    /**
59
     * Test if the model has a HTML value.
60
     * For backward compatibility, if it returns <code>false</code>,
61
     * HTML value is is taken from the String value, if it contains some.
62
     * If this is not desired, return true here and null from
63
     * {@link #getHTMLValueAt(java.lang.Object, java.lang.String)}.
64
     * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) }
65
     *             for this row
66
     * @param columnID an id of column defined by {@link ColumnModel#getID()}
67
     * @return <code>true</code> if there is some HTML value to be returned
68
     *         from {@link #getHTMLValueAt(java.lang.Object, java.lang.String)},
69
     *         <code>false</code> otherwise.
70
     *         When <code>false</code> is returned,
71
     *         {@link #getHTMLValueAt(java.lang.Object, java.lang.String)} is not called.
72
     * @throws UnknownTypeException if there is nothing to be provided for the given
73
     *         parameter type
74
     */
75
    boolean hasHTMLValueAt(Object node, String columnID) throws UnknownTypeException;
76
    
77
    /**
78
     * Get the HTML value.
79
     * 
80
     * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) }
81
     *             for this row
82
     * @param columnID an id of column defined by {@link ColumnModel#getID()}
83
     * @return The HTML value, or <code>null</code> when no HTML value is provided.
84
     * @throws UnknownTypeException if there is nothing to be provided for the given
85
     *         parameter type
86
     * @see #hasHTMLValueAt(java.lang.Object, java.lang.String)
87
     */
88
    String getHTMLValueAt(Object node, String columnID) throws UnknownTypeException;
89
90
}
(-)a/spi.viewmodel/src/org/netbeans/spi/viewmodel/TableHTMLModelFilter.java (+102 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.spi.viewmodel;
43
44
/**
45
 * Use this to separate value and the HTML value.
46
 * Implement this filter to override the behavior of any registered {@link TableHTMLModel}s.
47
 * 
48
 * @author Martin Entlicher
49
 * @since 1.42
50
 * @see TableHTMLModel
51
 */
52
public interface TableHTMLModelFilter extends Model {
53
    
54
    /**
55
     * Test if the model has a HTML value.
56
     * For backward compatibility, if it returns <code>false</code>,
57
     * HTML value is is taken from the String value, if it contains some.
58
     * If this is not desired, return true here and null from
59
     * {@link #getHTMLValueAt(org.netbeans.spi.viewmodel.TableHTMLModel, java.lang.Object, java.lang.String)}.
60
     * @param original The original {@link TableHTMLModel}
61
     * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) }
62
     *             for this row
63
     * @param columnID an id of column defined by {@link ColumnModel#getID()}
64
     * @return <code>true</code> if there is some HTML value to be returned
65
     *         from {@link #getHTMLValueAt(org.netbeans.spi.viewmodel.TableHTMLModel, java.lang.Object, java.lang.String)},
66
     *         <code>false</code> otherwise.
67
     *         When <code>false</code> is returned,
68
     *         {@link #getHTMLValueAt(org.netbeans.spi.viewmodel.TableHTMLModel, java.lang.Object, java.lang.String)}
69
     *         is not called.
70
     * @throws UnknownTypeException if there is nothing to be provided for the given
71
     *         parameter type
72
     */
73
    boolean hasHTMLValueAt(TableHTMLModel original, Object node, String columnID) throws UnknownTypeException;
74
    
75
    /**
76
     * Get the HTML value.
77
     * 
78
     * @param original The original {@link TableHTMLModel}
79
     * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) }
80
     *             for this row
81
     * @param columnID an id of column defined by {@link ColumnModel#getID()}
82
     * @return The HTML value, or <code>null</code> when no HTML value is provided.
83
     * @throws UnknownTypeException if there is nothing to be provided for the given
84
     *         parameter type
85
     * @see #hasHTMLValueAt(org.netbeans.spi.viewmodel.TableHTMLModel, java.lang.Object, java.lang.String)
86
     */
87
    String getHTMLValueAt(TableHTMLModel original, Object node, String columnID) throws UnknownTypeException;
88
    
89
    /**
90
     * Registers given listener.
91
     *
92
     * @param l the listener to add
93
     */
94
    public abstract void addModelListener (ModelListener l);
95
96
    /**
97
     * Unregisters given listener.
98
     *
99
     * @param l the listener to remove
100
     */
101
    public abstract void removeModelListener (ModelListener l);
102
}
(-)a/spi.viewmodel/src/org/netbeans/spi/viewmodel/TablePropertyEditorsModel.java (+67 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.spi.viewmodel;
43
44
import java.beans.PropertyEditor;
45
46
/**
47
 * Use this to provide different property editors for different table cells.
48
 * 
49
 * @author Martin Entlicher
50
 * @since 1.42
51
 * @see TablePropertyEditorsModelFilter
52
 */
53
public interface TablePropertyEditorsModel extends Model {
54
    
55
    /**
56
     * Get the property editor for the given table cell.
57
     * 
58
     * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) }
59
     *             for this row
60
     * @param columnID an id of column defined by {@link ColumnModel#getID()}
61
     * @return The property editor or <code>null</code> to use the column default one.
62
     * @throws UnknownTypeException if there is nothing to be provided for the given
63
     *         parameter type
64
     */
65
    PropertyEditor getPropertyEditor(Object node, String columnID) throws UnknownTypeException;
66
    
67
}
(-)a/spi.viewmodel/src/org/netbeans/spi/viewmodel/TablePropertyEditorsModelFilter.java (+70 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.spi.viewmodel;
43
44
import java.beans.PropertyEditor;
45
46
/**
47
 * Use this to provide different property editors for different table cells.
48
 * Implement this filter to override the behavior of any registered {@link TablePropertyEditorsModel}s.
49
 *
50
 * @author Martin Entlicher
51
 * @since 1.42
52
 * @see TablePropertyEditorsModel
53
 */
54
public interface TablePropertyEditorsModelFilter extends Model {
55
    
56
    /**
57
     * Get the property editor for the given table cell.
58
     * 
59
     * @param original The original {@link TablePropertyEditorsModel}
60
     * @param node an object returned from {@link TreeModel#getChildren(java.lang.Object, int, int) }
61
     *             for this row
62
     * @param columnID an id of column defined by {@link ColumnModel#getID()}
63
     * @return The property editor or <code>null</code> to use the column default one.
64
     * @throws UnknownTypeException if there is nothing to be provided for the given
65
     *         parameter type
66
     */
67
    PropertyEditor getPropertyEditor(TablePropertyEditorsModel original,
68
                                     Object node, String columnID) throws UnknownTypeException;
69
    
70
}

Return to bug 228909