1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 package com.sun.star.wizards.ui.event; 24 25 public class SimpleDataAware extends DataAware 26 { 27 28 protected Object control; 29 protected Object[] disableObjects = new Object[0]; 30 protected Value controlValue; 31 SimpleDataAware(Object dataObject, Value value, Object control_, Value controlValue_)32 public SimpleDataAware(Object dataObject, Value value, Object control_, Value controlValue_) 33 { 34 super(dataObject, value); 35 control = control_; 36 controlValue = controlValue_; 37 } 38 39 /* 40 protected void enableControls(Object value) { 41 Boolean b = getBoolean(value); 42 for (int i = 0; i<disableObjects.length; i++) 43 UIHelper.setEnabled(disableObjects[i],b); 44 } 45 */ setToUI(Object value)46 protected void setToUI(Object value) 47 { 48 controlValue.set(value, control); 49 } 50 51 /** 52 * Try to get from an arbitrary object a boolean value. 53 * Null returns Boolean.FALSE; 54 * A Boolean object returns itself. 55 * An Array returns true if it not empty. 56 * An Empty String returns Boolean.FALSE. 57 * everything else returns a Boolean.TRUE. 58 * @param value 59 * @return 60 */ 61 /*protected Boolean getBoolean(Object value) { 62 if (value==null) 63 return Boolean.FALSE; 64 if (value instanceof Boolean) 65 return (Boolean)value; 66 else if (value.getClass().isArray()) 67 return ((short[])value).length != 0 ? Boolean.TRUE : Boolean.FALSE; 68 else if (value.equals(PropertyNames.EMPTY_STRING)) return Boolean.FALSE; 69 else return Boolean.TRUE; 70 } 71 72 public void disableControls(Object[] controls) { 73 disableObjects = controls; 74 } 75 */ getFromUI()76 protected Object getFromUI() 77 { 78 return controlValue.get(control); 79 } 80 } 81