use of com.sun.messaging.jmq.admin.apps.console.util.LabelledComponent in project openmq by eclipse-ee4j.
the class BrokerPasswdDialog method createWorkPanel.
@Override
public JPanel createWorkPanel() {
JPanel workPanel = new JPanel();
GridBagLayout gridbag = new GridBagLayout();
workPanel.setLayout(gridbag);
GridBagConstraints c = new GridBagConstraints();
LabelledComponent[] items = new LabelledComponent[2];
username = new JTextField(20);
username.addActionListener(this);
items[0] = new LabelledComponent(acr.getString(acr.I_BROKER_USERNAME), username);
password = new JPasswordField(20);
password.addActionListener(this);
items[1] = new LabelledComponent(acr.getString(acr.I_BROKER_PASSWD), password);
LabelValuePanel lvp = new LabelValuePanel(items, 5, 5);
c.gridx = 0;
c.gridy = 0;
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(lvp, c);
workPanel.add(lvp);
return (workPanel);
}
use of com.sun.messaging.jmq.admin.apps.console.util.LabelledComponent in project openmq by eclipse-ee4j.
the class AboutDialog method makeRightPanel.
private JPanel makeRightPanel() {
Version version;
JPanel rightPanel;
GridBagLayout gridbag;
GridBagConstraints c;
JLabel label;
JSeparator sep;
LabelValuePanel lvp;
LabelledComponent[] lvpItems;
LabelledComponent tmpLabelC;
JTextArea ta;
JScrollPane sp;
int gridy = 0, width;
version = new Version(false);
rightPanel = new JPanel();
gridbag = new GridBagLayout();
rightPanel.setLayout(gridbag);
c = new GridBagConstraints();
label = new JLabel(version.getProductName() + " " + version.getReleaseQID());
c.gridx = 0;
c.gridy = gridy++;
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(label, c);
rightPanel.add(label);
label = new JLabel(acr.getString(acr.I_VERSION, version.getBuildVersion()));
c.gridx = 0;
c.gridy = gridy++;
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(label, c);
rightPanel.add(label);
label = new JLabel(acr.getString(acr.I_COMPILE, version.getBuildDate()));
c.gridx = 0;
c.gridy = gridy++;
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(label, c);
rightPanel.add(label);
sep = new JSeparator();
c.gridx = 0;
c.gridy = gridy++;
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(5, 0, 5, 0);
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(sep, c);
rightPanel.add(sep);
/*
* Reset
*/
c.fill = GridBagConstraints.NONE;
c.insets = new Insets(0, 0, 0, 0);
label = new JLabel(acr.getString(acr.I_VERSION_INFO, version.getVersionPackageName()));
c.gridx = 0;
gridy++;
c.gridy = gridy++;
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(label, c);
rightPanel.add(label);
/*
* Reset
*/
c.insets = new Insets(0, 0, 0, 0);
String[] patchids = version.getPatchIds();
if (patchids == null || patchids.length < 1) {
lvpItems = new LabelledComponent[3];
} else {
lvpItems = new LabelledComponent[4];
}
tmpLabelC = new LabelledComponent(acr.getString(acr.I_IMPLEMENTATION), new JLabel(version.getImplementationVersion()));
lvpItems[0] = tmpLabelC;
tmpLabelC = new LabelledComponent(acr.getString(acr.I_PROTOCOL_VERSION), new JLabel(version.getProtocolVersion()));
lvpItems[1] = tmpLabelC;
tmpLabelC = new LabelledComponent(acr.getString(acr.I_TARGET_JMS_VERSION), new JLabel(version.getTargetJMSVersion()));
lvpItems[2] = tmpLabelC;
// The Patchids are listed in a panel on the right.
if (patchids != null && patchids.length >= 1) {
JPanel patchPanel = new JPanel();
GridBagLayout gb = new GridBagLayout();
patchPanel.setLayout(gb);
GridBagConstraints c2 = new GridBagConstraints();
for (int p = 0; p < patchids.length; p++) {
c2.gridx = 0;
c2.gridy = p;
c2.ipadx = 0;
c2.ipady = 0;
c2.anchor = GridBagConstraints.WEST;
JLabel patchLabel = new JLabel(patchids[p]);
gb.setConstraints(patchLabel, c2);
patchPanel.add(patchLabel);
}
tmpLabelC = new LabelledComponent(acr.getString(acr.I_PATCHES), patchPanel, LabelledComponent.NORTH);
lvpItems[3] = tmpLabelC;
}
lvp = new LabelValuePanel(lvpItems, 4, 0);
c.gridx = 0;
c.gridy = gridy++;
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(lvp, c);
rightPanel.add(lvp);
label = new JLabel(acr.getString(acr.I_JAVA_VERSION) + System.getProperty("java.version") + " " + System.getProperty("java.vendor") + " " + System.getProperty("java.home"));
c.gridx = 0;
c.gridy = gridy++;
c.insets = new Insets(5, 0, 0, 0);
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(label, c);
rightPanel.add(label);
String classpathStr = System.getProperty("java.class.path");
classpathStr = classpathStr.replace(File.pathSeparatorChar, '\n');
ta = new JTextArea(classpathStr);
ta.setEditable(false);
ta.setLineWrap(true);
ta.setWrapStyleWord(true);
Color bgColor = rightPanel.getBackground();
ta.setBackground(bgColor);
Color fgColor = label.getForeground();
ta.setForeground(fgColor);
ta.setFont(label.getFont());
width = label.getPreferredSize().width;
ta.setSize(width, 1);
tmpLabelC = new LabelledComponent(acr.getString(acr.I_JAVA_CLASSPATH), ta, LabelledComponent.NORTH);
c.gridx = 0;
c.gridy = gridy++;
c.insets = new Insets(0, 0, 0, 0);
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(tmpLabelC, c);
rightPanel.add(tmpLabelC);
sep = new JSeparator();
c.gridx = 0;
c.gridy = gridy++;
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(5, 0, 5, 0);
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(sep, c);
rightPanel.add(sep);
/*
* Reset
*/
c.fill = GridBagConstraints.NONE;
c.insets = new Insets(0, 0, 0, 0);
ta = new JTextArea(version.getCopyright(Version.SHORT_COPYRIGHT), 8, 0);
ta.setEditable(false);
ta.setLineWrap(true);
ta.setWrapStyleWord(true);
bgColor = rightPanel.getBackground();
ta.setBackground(bgColor);
fgColor = label.getForeground();
ta.setForeground(fgColor);
ta.setFont(label.getFont());
// width = label.getPreferredSize().width;
width = rightPanel.getPreferredSize().width;
ta.setSize(width, 1);
sp = new JScrollPane(ta);
c.gridx = 0;
c.gridy = gridy++;
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(sp, c);
rightPanel.add(sp);
label = new JLabel(acr.getString(acr.I_RSA_CREDIT));
c.gridx = 0;
c.gridy = gridy++;
c.ipady = 10;
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(label, c);
rightPanel.add(label);
return rightPanel;
}
use of com.sun.messaging.jmq.admin.apps.console.util.LabelledComponent in project openmq by eclipse-ee4j.
the class ObjStoreConFactoryAddDialog method doOK.
@Override
public void doOK() {
/*
* Lookup Name
*/
String lookupName = lookupText.getText();
lookupName = lookupName.trim();
if (lookupName == null || lookupName.equals("")) {
JOptionPane.showOptionDialog(this, acr.getString(acr.E_NO_LOOKUP_NAME), acr.getString(acr.I_ADD_OBJSTORE_CF) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_NO_LOOKUP_NAME), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return;
}
/*
* Factory Type
*/
int type = ObjAdminEvent.CF;
AdministeredObject tempObj = null;
String factory = (String) factoryCombo.getSelectedItem();
if (factory.equals(acr.getString(acr.I_QCF))) {
type = ObjAdminEvent.QCF;
tempObj = new com.sun.messaging.QueueConnectionFactory();
} else if (factory.equals(acr.getString(acr.I_TCF))) {
type = ObjAdminEvent.TCF;
tempObj = new com.sun.messaging.TopicConnectionFactory();
} else if (factory.equals(acr.getString(acr.I_CF))) {
type = ObjAdminEvent.CF;
tempObj = new com.sun.messaging.ConnectionFactory();
} else if (factory.equals(acr.getString(acr.I_XAQCF))) {
type = ObjAdminEvent.XAQCF;
tempObj = new com.sun.messaging.XAQueueConnectionFactory();
} else if (factory.equals(acr.getString(acr.I_XATCF))) {
type = ObjAdminEvent.XATCF;
tempObj = new com.sun.messaging.XATopicConnectionFactory();
} else if (factory.equals(acr.getString(acr.I_XACF))) {
type = ObjAdminEvent.XACF;
tempObj = new com.sun.messaging.XAConnectionFactory();
}
/*
* Conn Factory Object Properties. Go through each of the cfProps, get the userdata which is the property name, get the
* value, set it in props.
*/
Properties props = tempObj.getConfiguration();
String propName, propValue, propType = null, propLabel = null;
for (int i = 0; i < cfProps.size(); i++) {
LabelledComponent cfItem = (LabelledComponent) cfProps.elementAt(i);
propName = (String) cfItem.getClientData();
if (propName == null) {
continue;
}
if (!(cfItem.getComponent().isEnabled())) {
props.remove(propName);
continue;
}
// associated properties or exception will occur.
try {
propType = tempObj.getPropertyType(propName);
propLabel = tempObj.getPropertyLabel(propName);
} catch (jakarta.jms.JMSException jmsex) {
JOptionPane.showOptionDialog(this, jmsex.toString(), acr.getString(acr.I_ADD_OBJSTORE_CF), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return;
}
if (propType == null) {
continue;
}
propValue = getValue(cfItem.getComponent(), propType).trim();
// so no need to set to "".
if (propValue.equals("")) {
continue;
}
try {
// Calling setProperty() will verify if this value is valid.
tempObj.setProperty(propName, propValue);
props.put(propName, propValue);
} catch (jakarta.jms.JMSException jmsex) {
if (jmsex instanceof com.sun.messaging.InvalidPropertyValueException) {
JOptionPane.showOptionDialog(this, acr.getString(acr.E_INVALID_VALUE, propLabel), acr.getString(acr.I_ADD_OBJSTORE_CF) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_INVALID_VALUE), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
} else {
JOptionPane.showOptionDialog(this, jmsex.toString(), acr.getString(acr.I_ADD_OBJSTORE_CF), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
}
return;
}
}
ObjAdminEvent oae = new ObjAdminEvent(this, ObjAdminEvent.ADD_CONN_FACTORY);
ObjStore os = osCObj.getObjStore();
/*
* Set values in the event.
*/
oae.setLookupName(lookupName);
oae.setObjStore(os);
oae.setFactoryType(type);
oae.setObjProperties(props);
if (checkBox.isSelected()) {
oae.setReadOnly(true);
} else {
oae.setReadOnly(false);
}
oae.setOKAction(true);
fireAdminEventDispatched(oae);
}
use of com.sun.messaging.jmq.admin.apps.console.util.LabelledComponent in project openmq by eclipse-ee4j.
the class ObjStoreConFactoryAddDialog method doReset.
@Override
public void doReset() {
// Reset the look up name and factory type.
lookupText.setText("");
factoryCombo.setSelectedItem(acr.getString(acr.I_CF));
checkBox.setSelected(false);
//
// Go through each of the items, get the userData which is
// the property name, then get the default value from a
// temporary object.
//
AdministeredObject tempObj = new com.sun.messaging.QueueConnectionFactory();
// Properties props = tempObj.getConfiguration();
String propName = null, propType = null;
String defaultValue = null;
for (int i = 0; i < cfProps.size(); i++) {
LabelledComponent cfItem = (LabelledComponent) cfProps.elementAt(i);
JComponent comp = cfItem.getComponent();
propName = (String) cfItem.getClientData();
if (propName != null) {
try {
// gets, InvalidPropertyException.
if (comp.isEnabled()) {
propType = tempObj.getPropertyType(propName);
defaultValue = tempObj.getProperty(propName);
setValue(comp, propType, defaultValue);
// setting.
if (comp instanceof JComboBox) {
doComboBox((JComboBox) comp);
}
}
} catch (Exception e) {
System.err.println(e.toString() + ": " + propName);
}
}
}
// XXX Bad
AdministeredObject tempObj2 = new com.sun.messaging.QueueConnectionFactory();
setOtherValues(tempObj2, false);
lookupText.requestFocus();
}
use of com.sun.messaging.jmq.admin.apps.console.util.LabelledComponent in project openmq by eclipse-ee4j.
the class ObjStoreDialog method createWorkPanel.
@SuppressWarnings("deprecation")
@Override
public JPanel createWorkPanel() {
String[] jndiPropNames = { Context.INITIAL_CONTEXT_FACTORY, Context.OBJECT_FACTORIES, Context.STATE_FACTORIES, Context.URL_PKG_PREFIXES, Context.PROVIDER_URL, Context.DNS_URL, Context.AUTHORITATIVE, Context.BATCHSIZE, Context.REFERRAL, Context.SECURITY_PROTOCOL, Context.SECURITY_AUTHENTICATION, Context.SECURITY_PRINCIPAL, Context.SECURITY_CREDENTIALS, Context.LANGUAGE, Context.APPLET };
boolean propsDlg = false;
if (getTitle().equals(acr.getString(acr.I_OBJSTORE_PROPS))) {
propsDlg = true;
}
JPanel workPanel = new JPanel();
workPanel.setLayout(new BorderLayout());
JPanel panel1 = new JPanel();
GridBagLayout gridbag = new GridBagLayout();
panel1.setLayout(gridbag);
GridBagConstraints c = new GridBagConstraints();
JPanel osPanel = new JPanel();
GridBagLayout gb = new GridBagLayout();
osPanel.setLayout(gb);
GridBagConstraints c1 = new GridBagConstraints();
JLabel storeLabel = new JLabel(acr.getString(acr.I_OBJSTORE_NAME) + ":");
c1.gridx = 0;
c1.gridy = 0;
c1.anchor = GridBagConstraints.NORTHEAST;
gridbag.setConstraints(storeLabel, c1);
osPanel.add(storeLabel);
osText = new JTextField(25);
DocumentListener docListener = new ObjStoreDocumentListener();
osText.getDocument().addDocumentListener(docListener);
c1.gridx = 1;
c1.gridy = 0;
c1.anchor = GridBagConstraints.WEST;
c1.insets = new Insets(0, 5, 0, 0);
gb.setConstraints(osText, c1);
osPanel.add(osText);
c.gridx = 0;
c.gridy = 0;
c1.anchor = GridBagConstraints.WEST;
panel1.add(osPanel);
if (propsDlg) {
checkBox = new JCheckBox(acr.getString(acr.I_CONNECT_AFTER_UPDATES), true);
} else {
checkBox = new JCheckBox(acr.getString(acr.I_CONNECT_UPON_ADDING), true);
}
checkBox.addActionListener(this);
c.gridx = 0;
c.gridy = 1;
c.gridwidth = 3;
// reset
c.insets = new Insets(0, 0, 0, 0);
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(checkBox, c);
JSeparator separator = new JSeparator();
c.gridx = 0;
c.gridy = 2;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(5, 0, 5, 0);
gridbag.setConstraints(separator, c);
panel1.add(separator);
JLabel jndiLabel = new JLabel(acr.getString(acr.I_OBJSTORE_JNDI_PROPS));
c.gridx = 0;
c.gridy = 3;
c.gridwidth = 3;
// reset
c.anchor = GridBagConstraints.WEST;
// reset
c.insets = new Insets(0, 0, 0, 0);
// reset c.anchor = GridBagConstraints.WEST;
c.fill = GridBagConstraints.NONE;
gridbag.setConstraints(jndiLabel, c);
panel1.add(jndiLabel);
LabelledComponent[] items = new LabelledComponent[3];
comboBox = new JComboBox(jndiPropNames);
comboBox.addActionListener(this);
items[0] = new LabelledComponent(acr.getString(acr.I_NAME) + ":", comboBox);
valueText = new JTextField(40);
valueText.getDocument().addDocumentListener(docListener);
items[1] = new LabelledComponent(acr.getString(acr.I_VALUE) + ":", valueText);
model = new PropsTableModel();
table = new JTable(model);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ListSelectionModel lsm = table.getSelectionModel();
lsm.addListSelectionListener(this);
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
items[2] = new LabelledComponent(" ", scrollPane);
lvp = new LabelValuePanel(items, 5, 5);
c.gridx = 0;
c.gridy = 4;
c.gridwidth = 2;
c.anchor = GridBagConstraints.CENTER;
gridbag.setConstraints(lvp, c);
panel1.add(lvp);
//
// Make width of list the same as width of text field and
// 8 rows in height.
//
int width = valueText.getPreferredSize().width;
table.getRowHeight();
table.setPreferredScrollableViewportSize(new Dimension(width, 8 * table.getRowHeight()));
JPanel buttonPanel = new JPanel();
addButton = new JButton(acr.getString(acr.I_DIALOG_ADD));
addButton.addActionListener(this);
delButton = new JButton(acr.getString(acr.I_DIALOG_DELETE));
delButton.addActionListener(this);
delButton.setEnabled(false);
chgButton = new JButton(acr.getString(acr.I_DIALOG_CHANGE));
chgButton.addActionListener(this);
chgButton.setEnabled(false);
buttonPanel.setLayout(new GridLayout(3, 1, 5, 5));
buttonPanel.add(addButton);
buttonPanel.add(delButton);
buttonPanel.add(chgButton);
c.gridx = 2;
c.gridy = 4;
c.gridwidth = 1;
c.anchor = GridBagConstraints.NORTHWEST;
c.insets = new Insets(items[0].getPreferredSize().height + items[1].getPreferredSize().height + 20, 0, 0, 0);
gridbag.setConstraints(buttonPanel, c);
panel1.add(buttonPanel);
String s = acr.getString(acr.W_SAVE_AS_CLEAR_TEXT);
ta = new JTextArea(s);
ta.setLineWrap(true);
ta.setWrapStyleWord(true);
Color bgColor = panel1.getBackground();
ta.setBackground(bgColor);
Color fgColor = jndiLabel.getForeground();
ta.setForeground(fgColor);
ta.setFont(jndiLabel.getFont());
// Find longer length to set length of text area:
// Either 1) ObjectStoreLabel: ___ OR
// 2) Width of LabelValuePanel
int width1 = storeLabel.getPreferredSize().width + 5 + osText.getPreferredSize().width;
int width2 = lvp.getPreferredSize().width;
if (width1 >= width2) {
ta.setSize(width1, 1);
} else {
ta.setSize(width2, 1);
}
ta.setEditable(false);
Dimension textSize = ta.getPreferredSize();
ta.setSize(textSize);
c.gridx = 0;
c.gridy = 5;
c.gridwidth = 3;
c.anchor = GridBagConstraints.WEST;
c.insets = new Insets(5, 0, 5, 0);
gridbag.setConstraints(ta, c);
panel1.add(ta);
workPanel.add(panel1, BorderLayout.NORTH);
return (workPanel);
}
Aggregations