1 /*
2 * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
372 public void viewed(XOpenTypeViewer viewer) throws Exception {
373 viewer.setOpenType(this);
374 updateColumnWidth();
375 }
376
377 public String toString() {
378 return composite == null ? "" :
379 composite.getCompositeType().getTypeName();
380 }
381
382 protected Object formatKey(String key) {
383 return key;
384 }
385
386 private void load(CompositeData data) {
387 CompositeType type = data.getCompositeType();
388 Set<String> keys = type.keySet();
389 Iterator<String> it = keys.iterator();
390 Object[] rowData = new Object[2];
391 while (it.hasNext()) {
392 String key = (String) it.next();
393 Object val = data.get(key);
394 rowData[0] = formatKey(key);
395 if (val == null) {
396 rowData[1] = "";
397 } else {
398 OpenType<?> openType = type.getType(key);
399 if (openType instanceof CompositeType) {
400 rowData[1] =
401 new XCompositeData(this, (CompositeData) val);
402 } else if (openType instanceof ArrayType) {
403 rowData[1] =
404 new XArrayData(this, (ArrayType<?>) openType, val);
405 } else if (openType instanceof SimpleType) {
406 rowData[1] = val;
407 } else if (openType instanceof TabularType) {
408 rowData[1] = new XTabularData(this, (TabularData) val);
409 }
410 }
411 // Update column width
412 String str = null;
|
1 /*
2 * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
372 public void viewed(XOpenTypeViewer viewer) throws Exception {
373 viewer.setOpenType(this);
374 updateColumnWidth();
375 }
376
377 public String toString() {
378 return composite == null ? "" :
379 composite.getCompositeType().getTypeName();
380 }
381
382 protected Object formatKey(String key) {
383 return key;
384 }
385
386 private void load(CompositeData data) {
387 CompositeType type = data.getCompositeType();
388 Set<String> keys = type.keySet();
389 Iterator<String> it = keys.iterator();
390 Object[] rowData = new Object[2];
391 while (it.hasNext()) {
392 String key = it.next();
393 Object val = data.get(key);
394 rowData[0] = formatKey(key);
395 if (val == null) {
396 rowData[1] = "";
397 } else {
398 OpenType<?> openType = type.getType(key);
399 if (openType instanceof CompositeType) {
400 rowData[1] =
401 new XCompositeData(this, (CompositeData) val);
402 } else if (openType instanceof ArrayType) {
403 rowData[1] =
404 new XArrayData(this, (ArrayType<?>) openType, val);
405 } else if (openType instanceof SimpleType) {
406 rowData[1] = val;
407 } else if (openType instanceof TabularType) {
408 rowData[1] = new XTabularData(this, (TabularData) val);
409 }
410 }
411 // Update column width
412 String str = null;
|