[svn r345] WIP for editor support
This commit is contained in:
parent
4643057b7f
commit
5d64bde0bd
48 changed files with 1071 additions and 268 deletions
|
|
@ -70,6 +70,7 @@ import com.idcanet.fff.SwingImageHelper;
|
|||
import com.idcanet.vasc.core.AbstractVascFrontend;
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.VascFrontendData;
|
||||
import com.idcanet.vasc.core.actions.GlobalVascAction;
|
||||
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||
import com.idcanet.vasc.core.entry.VascEntryExporter;
|
||||
|
|
@ -77,6 +78,12 @@ import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
|
|||
import com.idcanet.vasc.core.ui.VascColumnValueModelListener;
|
||||
import com.idcanet.vasc.core.ui.VascUIComponent;
|
||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||
import com.idcanet.vasc.frontends.swing.ui.SwingBoolean;
|
||||
import com.idcanet.vasc.frontends.swing.ui.SwingDate;
|
||||
import com.idcanet.vasc.frontends.swing.ui.SwingLabel;
|
||||
import com.idcanet.vasc.frontends.swing.ui.SwingList;
|
||||
import com.idcanet.vasc.frontends.swing.ui.SwingText;
|
||||
import com.idcanet.vasc.frontends.swing.ui.SwingTextArea;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -92,28 +99,23 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
logger = Logger.getLogger(SwingVascFrontend.class.getName());
|
||||
this.parent=parent;
|
||||
}
|
||||
|
||||
/*
|
||||
public void initEntry(VascEntry entry) throws Exception {
|
||||
if (entry.getVascFrontendData().getVascFrontend()==null) {
|
||||
entry.getVascFrontendData().setVascFrontend(this);
|
||||
} else {
|
||||
if (entry.getVascFrontendData().getVascFrontend()!=this) {
|
||||
throw new IllegalArgumentException("VascEntry has already a differtent VascViewRenderer attected");
|
||||
}
|
||||
}
|
||||
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
|
||||
/*
|
||||
entry.putUIComponent(VascTextField.class, SwingTextField.class);
|
||||
entry.putUIComponent(VascList.class, SwingList.class);
|
||||
entry.putUIComponent(VascToggle.class, SwingToggle.class);
|
||||
entry.putUIComponent(VascDate.class, SwingDate.class);
|
||||
entry.putUIComponent(VascColorChooser.class, SwingColorChooser.class);
|
||||
|
||||
this.entry=entry;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add swing implmented ui components
|
||||
*/
|
||||
protected void addUiComponents() {
|
||||
VascFrontendData vfd = getVascEntry().getVascFrontendData();
|
||||
|
||||
// required UI components
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_LABEL,SwingLabel.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_TEXT, SwingText.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_LIST, SwingList.class.getName());
|
||||
|
||||
// optional UI components
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_BOOLEAN , SwingBoolean.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_DATE , SwingDate.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_TEXTAREA, SwingTextArea.class.getName());
|
||||
}
|
||||
|
||||
public ImageIcon getImageIcon(String imageResource) {
|
||||
/// TODO hack beter
|
||||
|
|
@ -255,16 +257,32 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
public void createBody(JPanel body) throws Exception {
|
||||
body.setLayout(new SpringLayout());
|
||||
int column = 0;
|
||||
for(VascEntryField c:entry.getVascEntryFields()) {
|
||||
for (VascEntryField c:entry.getVascEntryFields()) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().initEditObjectColumn(c, bean);
|
||||
if (c.isEdit()==false) {
|
||||
continue;
|
||||
}
|
||||
column++;
|
||||
|
||||
for (int i=0;i<c.getVascEntryFieldType().getUIComponentCount();i++) {
|
||||
|
||||
VascUIComponent label = c.getVascEntryFieldType().provideLabelUIComponent(i,c);
|
||||
VascValueModel model = new VascValueModel();
|
||||
model.setValue(i18n(c.getName()));
|
||||
label.createComponent(entry,c,model,body);
|
||||
|
||||
VascUIComponent editor = c.getVascEntryFieldType().provideEditorUIComponent(i,c);
|
||||
model = new VascValueModel();
|
||||
model.setValue(c.getVascEntryFieldValue().getValue(c, bean));
|
||||
model.addListener(new VascColumnValueModelListener(c,bean));
|
||||
editor.createComponent(entry,c,model,body);
|
||||
}
|
||||
|
||||
/* OLD OLD OLD
|
||||
*
|
||||
*
|
||||
JLabel l = new JLabel();
|
||||
l.setHorizontalAlignment(JLabel.TRAILING);
|
||||
|
||||
l.setText(i18n(c.getName()));
|
||||
if(c.getDescription()!=null) {
|
||||
l.setToolTipText(i18n(c.getDescription()));
|
||||
|
|
@ -279,7 +297,8 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
continue;
|
||||
}
|
||||
|
||||
if(c.getVascEntryFieldType().getVascUIComponent()==null) {
|
||||
|
||||
if (c.getVascEntryFieldType().getVascUIComponent()==null) {
|
||||
JLabel valueLabel = new JLabel();
|
||||
valueLabel.setText(""+c.getVascEntryFieldValue().getValue(c, bean));
|
||||
//c.setColumnEditor(valueLabel);
|
||||
|
|
@ -292,6 +311,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
comp.createComponent(entry, model, body);
|
||||
//c.setColumnEditor(comp);
|
||||
}
|
||||
*/
|
||||
}
|
||||
//JComponent, rows, cols, initX, initY ,xPad, yPad
|
||||
SpringUtilities.makeCompactGrid(body, column,2, 6,6, 6,6);
|
||||
|
|
@ -469,7 +489,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
}
|
||||
table.revalidate();
|
||||
|
||||
TableCellRenderer renderer = new JComponententryCellRenderer();
|
||||
TableCellRenderer renderer = new JComponentTableHeaderCellRenderer();
|
||||
int counter=0;
|
||||
for(VascEntryField c:entry.getVascEntryFields()) {
|
||||
if (c.isList()==false) {
|
||||
|
|
@ -530,9 +550,10 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
}
|
||||
}
|
||||
}
|
||||
class JComponententryCellRenderer extends DefaultTableCellRenderer {
|
||||
class JComponentTableHeaderCellRenderer extends DefaultTableCellRenderer {
|
||||
private static final long serialVersionUID = 10L;
|
||||
public Component getentryCellRendererComponent(JTable table, Object value, boolean isSelected,boolean hasFocus, int row, int column) {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,boolean hasFocus, int row, int column) {
|
||||
VascEntryField c = (VascEntryField)value;
|
||||
setText(i18n(c.getName()));
|
||||
setToolTipText(i18n(c.getDescription()));
|
||||
|
|
@ -551,7 +572,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
setFont(header.getFont());
|
||||
}
|
||||
}
|
||||
setBorder(UIManager.getBorder("entryHeader.cellBorder"));
|
||||
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue