.setPreferredSize(new java.awt.Dimension(
110, 25));
jMetricsIDTextField.setEditable(false);
jMetricsIDTextField.setBackground(COLOR_DEACTIVATED);
jMetricsIDTextField.setForeground(Color.DARK_GRAY);
jMetricsIDTextField.setTransferHandler(new TransferHandler() {
private static final long serialVersionUID = 8700297967169121889L;
public boolean canImport(
TransferHandler.TransferSupport support) {
return false;
}
});
jMetricsIDTextField.getDocument().addDocumentListener(new MetricsBuilderListener());
}
{
jMetricsNameTextField = new WatermarkedJTextField(Messages.getString("MetricsBuilder.Watermarks.Name"));
jPanelMBNorth.add(jMetricsNameTextField);
jMetricsNameTextField
.setPreferredSize(new java.awt.Dimension(
236, 25));
jMetricsNameTextField.setTransferHandler(new TransferHandler(){
private static final long serialVersionUID = 973043666511565759L;
public boolean canImport(
TransferHandler.TransferSupport support) {
return false;
}
});
jMetricsNameTextField.getDocument().addDocumentListener(new MetricsBuilderListener());
}
}
}
{
jPanelMBNorthCenter = new JPanel();
BorderLayout jPanelMBNorthCenterLayout = new BorderLayout();
jPanelMBNorthCenterLayout.setVgap(3);
jPanelMBNorthCenterLayout.setHgap(5);
jPanelMBNorthCenter.setLayout(jPanelMBNorthCenterLayout);
jPanelId.add(jPanelMBNorthCenter,
BorderLayout.SOUTH);
jPanelMBNorthCenter.setPreferredSize(new java.awt.Dimension(395, 123));
jPanelMBNorthCenter.setSize(395, 120);
{
jMetricsDescriptionTextField = new WatermarkedJTextField(Messages.getString("MetricsBuilder.Watermarks.Description"));
jPanelMBNorthCenter.add(jMetricsDescriptionTextField, BorderLayout.NORTH);
jMetricsDescriptionTextField.setPreferredSize(new java.awt.Dimension(395, 68));
jMetricsDescriptionTextField.setSize(395, 68);
jMetricsDescriptionTextField.setTransferHandler(new TransferHandler() {
private static final long serialVersionUID = 8700297967169121889L;
public boolean canImport(
TransferHandler.TransferSupport support) {
return false;
}
});
jMetricsDescriptionTextField.getDocument().addDocumentListener(new MetricsBuilderListener());
}
{
jMetricsFormulaTextField = new WatermarkedJTextField(Messages.getString("MetricsBuilder.Watermarks.Formula"));
jPanelMBNorthCenter.add(jMetricsFormulaTextField, BorderLayout.CENTER);
jMetricsFormulaTextField.setPreferredSize(new java.awt.Dimension(395, 25));
jMetricsFormulaTextField
.setDropMode(DropMode.USE_SELECTION);
jMetricsFormulaTextField
.setTransferHandler(new TransferHandler() {
private static final long serialVersionUID = -5435327025028911097L;
public boolean canImport(
TransferHandler.TransferSupport support) {
if (!support
.isDataFlavorSupported(DataFlavor.stringFlavor) ||
!jMetricsFormulaTextField.isEditable())
return false;
else if(!support.getDropLocation().equals(jMetricsDescriptionTextField))
return true;
else
return false;
}
public boolean importData(
TransferHandler.TransferSupport support) {
if (!canImport(support))
return false;
Transferable transferable = support
.getTransferable();
String data;
try {
data = (String) transferable
.getTransferData(DataFlavor.stringFlavor);
} catch (Exception e) {
return false;
}
if(ConfigurationManager.getConfiguration().isShowNamesInBuilder())
data = MetricsUIRequestHandler.algorithmNameToID(data);
JTextField.DropLocation dl = (JTextField.DropLocation) support
.getDropLocation();
int index = dl.getIndex();
String oldText = jMetricsFormulaTextField.getText();
if(!oldText.equals(Messages.getString("MetricsBuilder.Watermarks.Formula"))) {
String firstPart = oldText.substring(0, index);
// If the last character is a blank remove it
if(firstPart.length() > 0 && firstPart.substring(firstPart.length() - 1, firstPart.length()).equals(" "))
firstPart = firstPart.substring(0, firstPart.length() - 1);
String secondPart = oldText.substring(index, oldText.length());
// If the first character is a blank remove it
if(secondPart.length() > 0 && secondPart.substring(0, 1).equals(" "))
secondPart = secondPart.substring(1);
jMetricsFormulaTextField
.setText(firstPart
+ " "
+ data
+ " "
+ secondPart);
// If formula now starts with a blank remove that blank
if(jMetricsFormulaTextField.getText().length() > 0 &&
jMetricsFormulaTextField.getText().substring(0, 1).equals(" "))
jMetricsFormulaTextField.setText(jMetricsFormulaTextField.getText().substring(1));
return true;
} else {
jMetricsFormulaTextField.setText(data);
return true;
}
}
});
jMetricsFormulaTextField.getDocument().addDocumentListener(new MetricsBuilderListener());
}
{
jPanel8 = new JPanel();
GridBagLayout jPanel8Layout = new GridBagLayout();
jPanelMBNorthCenter.add(jPanel8, BorderLayout.SOUTH);
jPanel8.setPreferredSize(new java.awt.Dimension(395, 25));
jPanel8Layout.rowWeights = new double[] {0.1};
jPanel8Layout.rowHeights = new int[] {1};
jPanel8Layout.columnWeights = new double[] {1.0, 0.01};
jPanel8Layout.columnWidths = new int[] {7, 1};
jPanel8.setLayout(jPanel8Layout);
{
jOpenFileChooserButton = new JButton();
jPanel8.add(jOpenFileChooserButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
jOpenFileChooserButton.setText("...");
}
{
jMetricsFilePathTextField = new JTextField();
jPanel8.add(jMetricsFilePathTextField, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
// jMetricsFilePathTextField.setText("C:\\");
jMetricsFilePathTextField.setPreferredSize(new java.awt.Dimension(391, 25));
jMetricsFilePathTextField.setSize(338, 25);
jMetricsFilePathTextField.setEnabled(false);
jMetricsFilePathTextField.setTransferHandler(new TransferHandler() {
private static final long serialVersionUID = 6507240735372523805L;
public boolean canImport(
TransferHandler.TransferSupport support) {
return false;