View Javadoc
1 /* 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/client/browser/InternationalStringPanel.java,v 1.1 2003/08/10 09:33:18 doballve Exp $ 3 * 4 * ==================================================================== 5 * 6 * This code is subject to the freebxml License, Version 1.1 7 * 8 * Copyright (c) 2003 freebxml.org. All rights reserved. 9 * 10 * ==================================================================== 11 */ 12 package com.sun.xml.registry.client.browser; 13 14 import java.awt.*; 15 import java.awt.event.*; 16 import java.util.*; 17 import java.util.Collection; 18 import javax.swing.*; 19 import javax.swing.DefaultComboBoxModel; 20 import javax.xml.registry.*; 21 import javax.xml.registry.infomodel.*; 22 23 /*** 24 * Panel to edit/inspect an InternationalString. 25 * 26 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 27 * <a href="mailto:diego.ballve@republica.fi">Diego Ballve</a> 28 */ 29 public class InternationalStringPanel extends JBPanel { 30 31 LocalizedStringsList localizedStringsList = null; 32 33 protected GridBagConstraints c = null; 34 protected GridBagLayout gbl = null; 35 36 37 /*** 38 * Creates new LocalizedStringsPanel 39 */ 40 public InternationalStringPanel() { 41 setBorder(BorderFactory.createTitledBorder("InternationalString Details")); 42 43 gbl = new GridBagLayout(); 44 c = new GridBagConstraints(); 45 setLayout(gbl); 46 47 //LocalizedStrings 48 JLabel localizedStringsLabel = new JLabel("LocalizedStrings:", SwingConstants.LEFT); 49 c.gridx = 0; 50 c.gridy = 0; 51 c.gridwidth = 1; 52 c.gridheight = 1; 53 c.weightx = 0.0; 54 c.weighty = 0.0; 55 c.fill = GridBagConstraints.NONE; 56 c.anchor = GridBagConstraints.WEST; 57 c.insets = new Insets(4, 4, 0, 4); 58 gbl.setConstraints(localizedStringsLabel, c); 59 add(localizedStringsLabel); 60 61 localizedStringsList = new LocalizedStringsList(); 62 localizedStringsList.setVisibleRowCount(3); 63 JScrollPane localizedStringsListScrollPane = new JScrollPane(localizedStringsList); 64 65 c.gridx = 0; 66 c.gridy = 1; 67 c.gridwidth = 1; 68 c.gridheight = 1; 69 c.weightx = 1; 70 c.weighty = 1; 71 c.fill = GridBagConstraints.HORIZONTAL; 72 c.anchor = GridBagConstraints.WEST; 73 c.insets = new Insets(4, 4, 4, 4); 74 gbl.setConstraints(localizedStringsListScrollPane, c); 75 add(localizedStringsListScrollPane); 76 } 77 78 public void setModel(Object obj) throws JAXRException { 79 if (!(obj instanceof InternationalString)) { 80 throw new InvalidRequestException("Expecting an InternationalString. Got a " + obj.getClass().getName()); 81 } 82 super.setModel(obj); 83 84 InternationalString iString = (InternationalString)obj; 85 86 try { 87 88 LocalizedStringsListModel localizedStringsListModel = (LocalizedStringsListModel)localizedStringsList.getModel(); 89 90 if (iString != null) { 91 Collection c = iString.getLocalizedStrings(); 92 localizedStringsListModel.setModels(new ArrayList(c)); 93 } 94 } 95 catch (JAXRException e) { 96 RegistryBrowser.displayError(e); 97 } 98 } 99 100 public Object getModel() throws JAXRException { 101 super.getModel(); 102 if (model != null) { 103 InternationalString iString = (InternationalString)model; 104 105 LocalizedStringsListModel localizedStringsListModel = (LocalizedStringsListModel)localizedStringsList.getModel(); 106 iString.addLocalizedStrings(Arrays.asList(localizedStringsListModel.toArray())); 107 108 RegistryBrowser.getInstance().getRootPane().updateUI(); 109 } 110 111 return model; 112 } 113 114 protected void validateInput() throws JAXRException { 115 super.validateInput(); 116 } 117 118 public void clear() throws JAXRException { 119 super.clear(); 120 // TO DO: clear localizedStringsList? 121 } 122 123 124 } 125

This page was automatically generated by Maven