Merge Upstream

thobaben_diagram
Harald Wolff 2016-11-17 20:04:18 +01:00
parent 9da6af56e4
commit 74a3486a84
3 changed files with 66 additions and 8 deletions

View File

@ -389,8 +389,6 @@ public class TableMapper extends AbstractTableModel
}
}
};
table.addMouseListener(mouseAdapter);
if (InteractiveObjectHelper.isInteractiveObject(editorObjectClass))
setEditorEnabled(true);
@ -484,6 +482,10 @@ public class TableMapper extends AbstractTableModel
for (TableMapperListener listener: tableMapperListeners)
listener.ValueChanged(row, column);
}
protected void fireTableRowChanged(Object row){
for (TableMapperListener listener: tableMapperListeners)
listener.tableRowChanged(this, row);
}
private Object getEditorObject()
{
@ -525,6 +527,8 @@ public class TableMapper extends AbstractTableModel
System.err.println("TableMapper.openEditor()");
for (TableMapperListener listener: this.tableMapperListeners){
if (listener.editorRequest(this, getSelectedRow())){
fireTableRowsUpdated(jTable.getSelectedRow(), jTable.getSelectedRow());
fireTableRowChanged(getSelectedRow());
return;
}
}
@ -537,6 +541,7 @@ public class TableMapper extends AbstractTableModel
if (ObjectEditorUIHelper.edit(editorObject)){
fireTableDataChanged();
fireTableRowChanged(getSelectedRow());
}
}

View File

@ -3,7 +3,7 @@ package org.hwo.models.TableMapper;
public interface TableMapperListener {
public void ValueChanged(int row,int column);
public void tableRowChanged(TableMapper sender,Object row);
public boolean editorRequest(TableMapper tableMapper,Object row);
}

View File

@ -1,6 +1,7 @@
package org.hwo.ui;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import javax.swing.JButton;
@ -26,7 +27,7 @@ public class JInputDialog extends JDialog {
public static String show(String title,String message,String preload){
return show(null,title,message,preload);
}
public static String show(JFrame parent,String title,String message,String preload){
public static String show(Component parent,String title,String message,String preload){
JInputDialog jid = new JInputDialog();
if (parent != null){
@ -43,10 +44,33 @@ public class JInputDialog extends JDialog {
return null;
}
public static <T> T show(Component parent,EditorComponent editor,String title,String message,T preload){
JInputDialog jid = new JInputDialog();
if (parent != null){
jid.setLocationRelativeTo(parent);
}
jid.setTitle(title);
jid.lMessage.setText(message);
jid.setEditor(editor);
jid.setValue(preload);
jid.setVisible(true);
if (jid.accepted)
return (T)jid.getValue();
return null;
}
private final JPanel contentPanel = new JPanel();
private JTextField tfInputText;
private JLabel lMessage;
private EditorComponent
editorComponent;
private GridBagLayout gbl_contentPanel;
private GridBagConstraints gbc_tfInputText;
private boolean accepted;
/**
@ -55,12 +79,14 @@ public class JInputDialog extends JDialog {
public JInputDialog() {
setModalityType(ModalityType.APPLICATION_MODAL);
setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
setVisible(false);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setModal(true);
setBounds(100, 100, 661, 222);
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
GridBagLayout gbl_contentPanel = new GridBagLayout();
gbl_contentPanel = new GridBagLayout();
gbl_contentPanel.columnWidths = new int[]{0, 0};
gbl_contentPanel.rowHeights = new int[]{0, 0, 0};
gbl_contentPanel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
@ -76,7 +102,7 @@ public class JInputDialog extends JDialog {
}
{
tfInputText = new JTextField();
GridBagConstraints gbc_tfInputText = new GridBagConstraints();
gbc_tfInputText = new GridBagConstraints();
gbc_tfInputText.fill = GridBagConstraints.BOTH;
gbc_tfInputText.gridx = 0;
gbc_tfInputText.gridy = 1;
@ -109,14 +135,41 @@ public class JInputDialog extends JDialog {
buttonPane.add(cancelButton);
}
}
editorComponent = new EditorComponent() {
@Override
public void setEditorValue(Object value) {
tfInputText.setText(value.toString());
}
@Override
public Object getEditorValue() {
return tfInputText.getText();
}
@Override
public Component asComponent() {
return tfInputText;
}
};
}
public String getInputText(){
return tfInputText.getText();
return editorComponent.getEditorValue().toString();
}
public void setInputText(String inputText){
tfInputText.setText(inputText);
editorComponent.setEditorValue(inputText);
}
public Object getValue(){
return editorComponent.getEditorValue();
}
public void setValue(Object value){
editorComponent.setEditorValue(value);
}
public void setEditor(EditorComponent editorComponent){
contentPanel.remove(this.editorComponent.asComponent());
this.editorComponent = editorComponent;
contentPanel.add(this.editorComponent.asComponent(),gbc_tfInputText);
}
private void accept(){