PageRenderTime 64ms CodeModel.GetById 60ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

/ui/src/com/bluemarsh/jswat/ui/breakpoint/AbstractAdapter.java

http://jswat.googlecode.com/
Java | 85 lines | 31 code | 8 blank | 46 comment | 2 complexity | 6c6874ad3b9fa39402bf7be607c8168e MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception
 1/*
 2 * The contents of this file are subject to the terms of the Common Development
 3 * and Distribution License (the License). You may not use this file except in
 4 * compliance with the License.
 5 *
 6 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
 7 * or http://www.netbeans.org/cddl.txt.
 8 *
 9 * When distributing Covered Code, include this CDDL Header Notice in each file
10 * and include the License file at http://www.netbeans.org/cddl.txt.
11 * If applicable, add the following below the CDDL Header, with the fields
12 * enclosed by brackets [] replaced by your own identifying information:
13 * "Portions Copyrighted [year] [name of copyright owner]"
14 *
15 * The Original Software is JSwat. The Initial Developer of the Original
16 * Software is Nathan L. Fiedler. Portions created by Nathan L. Fiedler
17 * are Copyright (C) 2006-2010. All Rights Reserved.
18 *
19 * Contributor(s): Nathan L. Fiedler.
20 *
21 * $Id: AbstractAdapter.java 288 2010-11-21 02:59:13Z nathanfiedler $
22 */
23package com.bluemarsh.jswat.ui.breakpoint;
24
25import java.beans.PropertyChangeListener;
26import java.beans.PropertyChangeSupport;
27import javax.swing.JPanel;
28
29/**
30 * An abstract implementation of a BreakpointAdapter.
31 *
32 * @author Nathan Fiedler
33 */
34public abstract class AbstractAdapter extends JPanel implements BreakpointAdapter {
35
36    /** silence compiler warnings */
37    private static final long serialVersionUID = 1L;
38    /** Manages property change listeners. */
39    private PropertyChangeSupport propSupport;
40
41    /**
42     * Creates a new instance of AbstractAdapter.
43     */
44    public AbstractAdapter() {
45    }
46
47    @Override
48    public void addPropertyChangeListener(PropertyChangeListener listener) {
49        super.addPropertyChangeListener(listener);
50        initPropSupport();
51        propSupport.addPropertyChangeListener(listener);
52    }
53
54    /**
55     * Fires the validInput property change in which the new property value
56     * is that given in the parameter. If that value is null, then the
57     * input is considered to be valid. Otherwise, the message will be made
58     * visible to the user.
59     *
60     * @param  msg  invalid input message, or null if input is valid.
61     */
62    protected void fireInputPropertyChange(String msg) {
63        initPropSupport();
64        propSupport.firePropertyChange(PROP_INPUTVALID, "DummyValue", msg);
65    }
66
67    /**
68     * Create the PropertyChangeSupport instance on demand.
69     */
70    private synchronized void initPropSupport() {
71        // For some reason, the Synth LAF causes problems with invoking
72        // methods before the object is completely constructed, so need
73        // to ensure propery support is built on demand.
74        if (propSupport == null) {
75            propSupport = new PropertyChangeSupport(this);
76        }
77    }
78
79    @Override
80    public void removePropertyChangeListener(PropertyChangeListener listener) {
81        super.removePropertyChangeListener(listener);
82        initPropSupport();
83        propSupport.removePropertyChangeListener(listener);
84    }
85}