Skip to content

Commit

Permalink
Refactor to not link to test code
Browse files Browse the repository at this point in the history
  • Loading branch information
arigesher committed Jan 20, 2012
1 parent 45940ac commit bdc9a36
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
20 changes: 20 additions & 0 deletions example/com/palantir/ptoss/cinch/example/dynamic/BooleanModel.java
@@ -0,0 +1,20 @@
package com.palantir.ptoss.cinch.example.dynamic;

import com.palantir.ptoss.cinch.core.DefaultBindableModel;

/**
* Simple model for a boolean field.
*/
public class BooleanModel extends DefaultBindableModel {
boolean state = false;

public boolean isState() {
return state;
}

public void setState(boolean state) {
this.state = state;
update();
}
}

Expand Up @@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.palantir.ptoss.cinch.example;
package com.palantir.ptoss.cinch.example.dynamic;

import java.awt.BorderLayout;
import java.awt.Dimension;
Expand All @@ -29,10 +29,10 @@
import javax.swing.JSlider;

import com.google.common.collect.Lists;
import com.palantir.ptoss.cinch.BooleanModel;
import com.palantir.ptoss.cinch.core.Bindings;
import com.palantir.ptoss.cinch.core.CallOnUpdate;
import com.palantir.ptoss.cinch.core.DefaultBindableModel;
import com.palantir.ptoss.cinch.example.Examples;
import com.palantir.ptoss.cinch.swing.Bound;

/**
Expand All @@ -41,6 +41,19 @@
*/
public class DynamicControls {

public static class BooleanModel extends DefaultBindableModel {
boolean state = false;

public boolean isState() {
return state;
}

public void setState(boolean state) {
this.state = state;
update();
}
}

public static class DynamicModel extends DefaultBindableModel {
// The number of dynamic controls
int count;
Expand Down Expand Up @@ -102,7 +115,7 @@ public void dispose() {
bindings.release(model);
}
}

private final DynamicModel model = new DynamicModel();

private final JPanel panel = new JPanel();
Expand Down Expand Up @@ -137,7 +150,8 @@ private void initializeInterface() {
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
}

@CallOnUpdate
@SuppressWarnings("unused")
@CallOnUpdate
private void synchCheckboxes() {
// It's important to remove transient listeners to long-lived models
for (BooleanComponent component : checkboxComponents) {
Expand Down

0 comments on commit bdc9a36

Please sign in to comment.