package de.cismet.beanmill;
import com.traxel.lumbermill.event.Event;
import com.traxel.lumbermill.event.TableView;
import org.apache.log4j.Logger;
import org.openide.util.NbPreferences;
import java.awt.Container;
import java.awt.Dialog;
private static final transient Logger LOG = Logger.getLogger(NetbeansPanel.class);
public static final String PROP_LISTENER_PORT = "listenerPort";
public static final String PROP_SHOW_HTML_MSG = "showHTMLMessage";
public static final String PROP_SHOW_RAW_MSG = "showRawMessage";
public static final String PROP_TOOLTIP_HK = "tooltipHotKey";
public static final String PROP_TOOLTIP_HK_SUBST = "tooltipHotkeySubstitute";
public static final String VAL_HK_NONE = "none";
private int tooltipHotkey;
private javax.swing.JButton btnClearHotkey;
private javax.swing.JCheckBox chkHTMLMessage;
private javax.swing.JCheckBox chkRawMessage;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JTextField txtHotkey;
private javax.swing.JTextField txtPort;
if (LOG.isDebugEnabled()) {
LOG.debug("creating new NetbeansPanel, controller: " + controller);
}
initComponents();
}
jLabel1 = new javax.swing.JLabel();
txtPort = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();
jLabel3 = new javax.swing.JLabel();
txtHotkey = new javax.swing.JTextField();
btnClearHotkey = new javax.swing.JButton();
jSeparator2 = new javax.swing.JSeparator();
chkHTMLMessage = new javax.swing.JCheckBox();
chkRawMessage = new javax.swing.JCheckBox();
setBackground(java.awt.Color.white);
setOpaque(false);
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, "Port:");
txtPort.setText("4446");
txtPort.addActionListener(new java.awt.event.ActionListener() {
@Override
txtPortActionPerformed(evt);
}
});
org.openide.awt.Mnemonics.setLocalizedText(jLabel2, "(Restart required)");
org.openide.awt.Mnemonics.setLocalizedText(jLabel3, "Tooltip Hotkey:");
txtHotkey.setEditable(false);
txtHotkey.setHorizontalAlignment(javax.swing.JTextField.CENTER);
txtHotkey.setText("none");
txtHotkey.setMinimumSize(new java.awt.Dimension(45, 28));
txtHotkey.addMouseListener(new java.awt.event.MouseAdapter() {
@Override
public void mouseClicked(
final java.awt.event.MouseEvent evt) {
txtHotkeyMouseClicked(evt);
}
});
txtHotkey.addActionListener(new java.awt.event.ActionListener() {
@Override
txtHotkeyActionPerformed(evt);
}
});
org.openide.awt.Mnemonics.setLocalizedText(btnClearHotkey, "Clear");
btnClearHotkey.addActionListener(new java.awt.event.ActionListener() {
@Override
btnClearHotkeyActionPerformed(evt);
}
});
org.openide.awt.Mnemonics.setLocalizedText(chkHTMLMessage, "Show HTML message");
org.openide.awt.Mnemonics.setLocalizedText(chkRawMessage, "Show raw message");
final org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
layout.createSequentialGroup().addContainerGap().add(jLabel1).addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED).add(
txtPort,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
212,
Short.MAX_VALUE).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jLabel2)
.addContainerGap()).add(
org.jdesktop.layout.GroupLayout.TRAILING,
jSeparator1,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
409,
Short.MAX_VALUE).add(
layout.createSequentialGroup().addContainerGap().add(jLabel3).addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED).add(
txtHotkey,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
87,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE).addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED).add(btnClearHotkey).addContainerGap(
109,
Short.MAX_VALUE)).add(
layout.createSequentialGroup().add(
jSeparator2,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
389,
Short.MAX_VALUE).addContainerGap()).add(
layout.createSequentialGroup().addContainerGap().add(chkHTMLMessage).addContainerGap(
228,
Short.MAX_VALUE)).add(
layout.createSequentialGroup().addContainerGap().add(chkRawMessage).addContainerGap(
242,
Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
layout.createSequentialGroup().addContainerGap().add(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(jLabel1).add(jLabel2).add(
txtPort,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)).addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED).add(
jSeparator1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
10,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE).addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED).add(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(
txtHotkey,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE).add(jLabel3).add(btnClearHotkey))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(
jSeparator2,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
10,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE).addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED).add(chkHTMLMessage).addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED).add(chkRawMessage).addContainerGap(43, Short.MAX_VALUE)));
}
{
}
{
if (LOG.isDebugEnabled()) {
LOG.debug("creating ChooseHotkeyDialog");
}
final ChooseHotkeyDialog dialog = ChooseHotkeyDialog.showHotkeyDialog(getParentDialog(this));
if (dialog.getHotkey() != -1) {
tooltipHotkey = dialog.getHotkey();
txtHotkey.setText(dialog.getHKSubstitute());
}
}
{
}
{
txtHotkey.setText(VAL_HK_NONE);
tooltipHotkey = -1;
}
if (c == null) {
return null;
} else if (c instanceof Dialog) {
return (Dialog)c;
} else {
return getParentDialog(c.getParent());
}
}
txtPort.setText(String.valueOf(
NbPreferences.forModule(LoggingTopComponent.class).getInt(PROP_LISTENER_PORT, 4445)));
txtHotkey.setText(NbPreferences.forModule(TableView.class).get(PROP_TOOLTIP_HK_SUBST, VAL_HK_NONE));
tooltipHotkey = NbPreferences.forModule(TableView.class).getInt(PROP_TOOLTIP_HK, -1);
chkHTMLMessage.setSelected(NbPreferences.forModule(Event.class).getBoolean(PROP_SHOW_HTML_MSG, true));
chkRawMessage.setSelected(NbPreferences.forModule(Event.class).getBoolean(PROP_SHOW_RAW_MSG, true));
}
try {
NbPreferences.forModule(LoggingTopComponent.class)
.putInt(PROP_LISTENER_PORT, new Integer(txtPort.getText()));
} catch (final Exception e) {
LOG.warn("could not store Beanmill port prefs", e);
NbPreferences.forModule(LoggingTopComponent.class).putInt(PROP_LISTENER_PORT, 4445);
}
try {
NbPreferences.forModule(TableView.class).put(PROP_TOOLTIP_HK_SUBST, txtHotkey.getText());
NbPreferences.forModule(TableView.class).putInt(PROP_TOOLTIP_HK, tooltipHotkey);
} catch (final Exception e) {
LOG.warn("could not store Beanmill hotkey prefs", e);
NbPreferences.forModule(TableView.class).put(PROP_TOOLTIP_HK_SUBST, VAL_HK_NONE);
NbPreferences.forModule(TableView.class).putInt(PROP_TOOLTIP_HK, -1);
}
try {
NbPreferences.forModule(Event.class).putBoolean(PROP_SHOW_HTML_MSG, chkHTMLMessage.isSelected());
} catch (final Exception e) {
LOG.warn("could not store Beanmill showHTMLMessage prefs", e);
NbPreferences.forModule(Event.class).putBoolean(PROP_SHOW_HTML_MSG, true);
}
try {
NbPreferences.forModule(Event.class).putBoolean(PROP_SHOW_RAW_MSG, chkRawMessage.isSelected());
} catch (final Exception e) {
LOG.warn("could not store Beanmill showRawMessage prefs", e);
NbPreferences.forModule(Event.class).putBoolean(PROP_SHOW_RAW_MSG, true);
}
}
return true;
}
}