/*
* #%L
* gitools-ui-app
* %%
* Copyright (C) 2013 Universitat Pompeu Fabra - Biomedical Genomics group
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
package org.gitools.ui.app.heatmap.header.wizard.heatmapheader;
import org.gitools.heatmap.header.HeatmapDecoratorHeader;
import org.gitools.ui.core.utils.DocumentChangeListener;
import org.gitools.ui.platform.dialog.MessageStatus;
import org.gitools.ui.platform.wizard.AbstractWizardPage;
import javax.swing.event.DocumentEvent;
public class HeatmapHeaderConfigPage extends AbstractWizardPage {
private HeatmapDecoratorHeader header;
public HeatmapHeaderConfigPage() {
this(new HeatmapDecoratorHeader(null));
}
/**
* Creates new form ColoredClustersConfigPage
*/
public HeatmapHeaderConfigPage(HeatmapDecoratorHeader header) {
super();
this.header = header;
initComponents();
setTitle("Header configuration");
setComplete(true);
titleField.getDocument().addDocumentListener(new DocumentChangeListener() {
@Override
protected void update(DocumentEvent e) {
if (titleField.getText().length() > 20) {
setMessage(MessageStatus.WARN, "Try to shorten the title");
} else {
setMessage(MessageStatus.INFO, "");
}
if (titleField.getText().length() == 0) {
setComplete(false);
setMessage(MessageStatus.ERROR, "Choose a title");
return;
} else {
setComplete(true);
}
updateModel();
}
});
}
@Override
public void updateControls() {
super.updateControls();
titleField.setText(header.getTitle());
marginSpin.setValue(header.getMargin());
}
@Override
public void updateModel() {
super.updateModel();
header.setTitle(titleField.getText());
header.setMargin((Integer) marginSpin.getValue());
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
labelPositionBtnGroup = new javax.swing.ButtonGroup();
jLabel1 = new javax.swing.JLabel();
titleField = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
marginSpin = new javax.swing.JSpinner();
jLabel1.setText("Title");
jLabel3.setText("Margin");
marginSpin.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(0), null, Integer.valueOf(1)));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(titleField, javax.swing.GroupLayout.DEFAULT_SIZE, 588, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(marginSpin, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(titleField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(marginSpin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(217, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel3;
private javax.swing.ButtonGroup labelPositionBtnGroup;
private javax.swing.JSpinner marginSpin;
private javax.swing.JTextField titleField;
// End of variables declaration//GEN-END:variables
public HeatmapDecoratorHeader getHeader() {
return header;
}
public void setHeader(HeatmapDecoratorHeader header) {
this.header = header;
}
}