zheng
6 years ago
10 changed files with 235 additions and 196 deletions
@ -0,0 +1,45 @@
|
||||
package com.fr.design.chartx.component.correlation; |
||||
|
||||
import com.fr.design.gui.frpane.UICorrelationPane; |
||||
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; |
||||
|
||||
import javax.swing.JTable; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/10. |
||||
*/ |
||||
public class CalculateComboBoxEditorComponent extends AbstractEditorComponent<CalculateComboBox> { |
||||
|
||||
public CalculateComboBoxEditorComponent(String header) { |
||||
super(header); |
||||
} |
||||
|
||||
@Override |
||||
public CalculateComboBox getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, int row, int column) { |
||||
|
||||
CalculateComboBox calculateComboBox = new CalculateComboBox(); |
||||
|
||||
calculateComboBox.addItemListener(new ItemListener() { |
||||
public void itemStateChanged(ItemEvent e) { |
||||
parent.stopCellEditing(); |
||||
parent.fireTargetChanged(); |
||||
} |
||||
}); |
||||
return calculateComboBox; |
||||
} |
||||
|
||||
@Override |
||||
public Object getValue(CalculateComboBox calculateComboBox) { |
||||
return calculateComboBox.getSelectedItem(); |
||||
} |
||||
|
||||
@Override |
||||
public void setValue(CalculateComboBox calculateComboBox, Object o) { |
||||
|
||||
if (o != null) { |
||||
calculateComboBox.setSelectedItem(o); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,55 @@
|
||||
package com.fr.design.chartx.component.correlation; |
||||
|
||||
import com.fr.design.gui.frpane.UICorrelationPane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.itable.UITable; |
||||
|
||||
import javax.swing.JTable; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/10. |
||||
*/ |
||||
public class UIComboBoxEditorComponent extends AbstractEditorComponent<UIComboBox> { |
||||
|
||||
public UIComboBoxEditorComponent(String header) { |
||||
super(header); |
||||
} |
||||
|
||||
protected List<String> items() { |
||||
return new ArrayList<String>(); |
||||
} |
||||
|
||||
@Override |
||||
public UIComboBox getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, final int row, int column) { |
||||
UIComboBox uiComboBox = new UIComboBox(items().toArray()); |
||||
|
||||
uiComboBox.addItemListener(new ItemListener() { |
||||
public void itemStateChanged(ItemEvent e) { |
||||
parent.stopCellEditing(); |
||||
parent.fireTargetChanged(); |
||||
UITable table = parent.getTable(); |
||||
Object object = table.getValueAt(row, 0); |
||||
if (object != null) { |
||||
table.setValueAt(object, row, 1); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
return uiComboBox; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public Object getValue(UIComboBox uiComboBox) { |
||||
return uiComboBox.getSelectedItem(); |
||||
} |
||||
|
||||
@Override |
||||
public void setValue(UIComboBox uiComboBox, Object o) { |
||||
uiComboBox.getModel().setSelectedItem(o); |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
package com.fr.design.chartx.component.correlation; |
||||
|
||||
import com.fr.design.event.UIObserverListener; |
||||
import com.fr.design.gui.frpane.UICorrelationPane; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.general.GeneralUtils; |
||||
|
||||
import javax.swing.JTable; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/10. |
||||
*/ |
||||
public class UITextFieldEditorComponent extends AbstractEditorComponent<UITextField> { |
||||
public UITextFieldEditorComponent(String header) { |
||||
super(header); |
||||
} |
||||
|
||||
@Override |
||||
public UITextField getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, int row, int column) { |
||||
UITextField uiTextField = new UITextField(); |
||||
|
||||
uiTextField.registerChangeListener(new UIObserverListener() { |
||||
@Override |
||||
public void doChange() { |
||||
parent.fireTargetChanged(); |
||||
} |
||||
}); |
||||
|
||||
return uiTextField; |
||||
} |
||||
|
||||
@Override |
||||
public Object getValue(UITextField uiTextField) { |
||||
return uiTextField.getText(); |
||||
} |
||||
|
||||
@Override |
||||
public void setValue(UITextField uiTextField, Object o) { |
||||
uiTextField.setText(GeneralUtils.objectToString(o)); |
||||
} |
||||
} |
Loading…
Reference in new issue