propertyViewer.refresh();
}
});
SashForm listGroup = new SashForm(comp, SWT.HORIZONTAL | SWT.SMOOTH);
listGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
// listGroup.setLayout(new GridLayout(2, false));
listGroup.setLayout(new FillLayout());
{
{
// property list
propertyTable = new Table(listGroup, SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER);
// propertyTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
propertyTable.setLinesVisible(true);
propertyTable.setHeaderVisible(true);
propertyViewer = new TableViewer(propertyTable);
TableColumnLayout colLayout = new TableColumnLayout();
TableViewerColumn vCol;
TableColumn col;
vCol = new TableViewerColumn(propertyViewer, SWT.LEFT);
col = vCol.getColumn();
col.setText("");
col.setToolTipText(Messages
.getString("object.template.editor.property_list.table.column.marker.tooltip"));
col.setResizable(false);
col.setMoveable(false);
col.setWidth(25);
colLayout.setColumnData(col, new ColumnWeightData(5, 25, false));
vCol = new TableViewerColumn(propertyViewer, SWT.LEFT);
col = vCol.getColumn();
col.setText(Messages.getString("object.template.editor.property_list.table.column.name.label"));
col
.setToolTipText(Messages
.getString("object.template.editor.property_list.table.column.name.tooltip"));
col.setResizable(true);
col.setMoveable(false);
col.setWidth(225);
colLayout.setColumnData(col, new ColumnWeightData(50, 200, true));
// vCol.setEditingSupport(new DefaultObjectPropertyEditingSupport(propertyViewer) {
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.jface.viewers.EditingSupport#getValue(java.lang.Object)
// */
// @Override
// protected Object getValue(Object obj) {
// if(obj instanceof ObjectProperty) {
// return ((ObjectProperty)obj).getName();
// }
//
// return null;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.jface.viewers.EditingSupport#setValue(java.lang.Object, java.lang.Object)
// */
// @Override
// protected void setValue(Object obj, Object value) {
// if(obj instanceof ObjectProperty) {
// ((ObjectProperty)obj).setName(value.toString());
// getViewer().update(obj, null);
// }
// }
// });
vCol = new TableViewerColumn(propertyViewer, SWT.LEFT);
col = vCol.getColumn();
col.setText(Messages.getString("object.template.editor.property_list.table.column.template.label"));
col.setToolTipText(Messages
.getString("object.template.editor.property_list.table.column.template.tooltip"));
col.setResizable(true);
col.setMoveable(false);
col.setWidth(75);
colLayout.setColumnData(col, new ColumnWeightData(10, 25, true));
// vCol = new TableViewerColumn(propertyViewer, SWT.LEFT);
// col = vCol.getColumn();
// col.setText(Messages.getString("object.template.editor.property_list.table.column.sequence.label"));
// col.setToolTipText(Messages
// .getString("object.template.editor.property_list.table.column.sequence.tooltip"));
// col.setResizable(true);
// col.setMoveable(false);
// col.setWidth(75);
// colLayout.setColumnData(col, new ColumnWeightData(10, 50, true));
// vCol.setEditingSupport(new DefaultObjectPropertyEditingSupport(propertyViewer) {
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.jface.viewers.EditingSupport#getValue(java.lang.Object)
// */
// @Override
// protected Object getValue(Object obj) {
// if(obj instanceof ObjectProperty) {
// return ((ObjectProperty)obj).getSequence();
// }
//
// return null;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.jface.viewers.EditingSupport#setValue(java.lang.Object, java.lang.Object)
// */
// @Override
// protected void setValue(Object obj, Object value) {
// if(obj instanceof ObjectProperty) {
// if(StringUtils.isNumeric(value.toString())) {
// ((ObjectProperty)obj).setSequence(Integer.parseInt(value.toString()));
// getViewer().update(obj, null);
// }
// }
// }
// });
vCol = new TableViewerColumn(propertyViewer, SWT.LEFT);
col = vCol.getColumn();
col.setText(Messages.getString("object.template.editor.property_list.table.column.limit.label"));
col.setToolTipText(Messages
.getString("object.template.editor.property_list.table.column.limit.tooltip"));
col.setResizable(true);
col.setMoveable(false);
col.setWidth(50);
colLayout.setColumnData(col, new ColumnWeightData(5, 50, true));
// vCol.setEditingSupport(new DefaultObjectPropertyEditingSupport(propertyViewer) {
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.jface.viewers.EditingSupport#getValue(java.lang.Object)
// */
// @Override
// protected Object getValue(Object obj) {
// if(obj instanceof ObjectProperty) {
// return ((ObjectProperty)obj).getInstanceLimit();
// }
//
// return null;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.jface.viewers.EditingSupport#setValue(java.lang.Object, java.lang.Object)
// */
// @Override
// protected void setValue(Object obj, Object value) {
// if(obj instanceof ObjectProperty) {
// if(StringUtils.isNumeric(value.toString())) {
// ((ObjectProperty)obj).setInstanceLimit(Integer.parseInt(value.toString()));
// getViewer().update(obj, null);
// }
// }
// }
// });
vCol = new TableViewerColumn(propertyViewer, SWT.LEFT);
col = vCol.getColumn();
col.setText(Messages.getString("object.template.editor.property_list.table.column.calculator.label"));
col.setToolTipText(Messages
.getString("object.template.editor.property_list.table.column.calculator.tooltip"));
col.setResizable(true);
col.setMoveable(false);
col.setWidth(100);
colLayout.setColumnData(col, new ColumnWeightData(10, 100, false));
vCol = new TableViewerColumn(propertyViewer, SWT.LEFT);
col = vCol.getColumn();
col.setText(Messages.getString("object.template.editor.property_list.table.column.validator.label"));
col.setToolTipText(Messages
.getString("object.template.editor.property_list.table.column.validator.tooltip"));
col.setResizable(true);
col.setMoveable(false);
col.setWidth(100);
colLayout.setColumnData(col, new ColumnWeightData(10, 100, false));
vCol = new TableViewerColumn(propertyViewer, SWT.LEFT);
col = vCol.getColumn();
col.setText(Messages.getString("object.template.editor.property_list.table.column.formatter.label"));
col.setToolTipText(Messages
.getString("object.template.editor.property_list.table.column.formatter.tooltip"));
col.setResizable(true);
col.setMoveable(false);
col.setWidth(100);
colLayout.setColumnData(col, new ColumnWeightData(10, 100, false));
propertyViewer.setContentProvider(new ObjectTemplateEditorPropertyListContentProvider(objectTemplate));
propertyViewer.setLabelProvider(new ObjectTemplateEditorPropertyListLabelProvider());
propertyViewer.setComparator(new ObjectTemplateEditorPropertyListComparator());
propertyViewer.addSelectionChangedListener(this);
propertyViewer.setInput(this);
propertyViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
logger.debug("got double-click event: " + event);
IStructuredSelection ss = (IStructuredSelection)event.getSelection();
if(!ss.isEmpty()) {
Object obj = ss.getFirstElement();
if(obj instanceof ObjectProperty) {
objectTemplate.setLabelProperty(((ObjectProperty)obj).getName());
doSave(null);
}
}
}
});
getSite().setSelectionProvider(propertyViewer);
}
{
// property editor
propertyGroup = new Group(listGroup, SWT.NONE);
// propertyGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
propertyGroup.setLayout(new GridLayout(3, false));
// propertyGroup.setText(Messages.getString("object.template.editor.property.group.label"));
{
// property name
label = new Label(propertyGroup, SWT.RIGHT);
label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
label.setText(Messages.getString("object.template.editor.property.name.label"));
label.setToolTipText(Messages.getString("object.template.editor.property.name.tooltip"));
propertyNameText = new Text(propertyGroup, SWT.SINGLE | SWT.BORDER);
propertyNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
propertyNameText.setToolTipText(Messages.getString("object.template.editor.property.name.tooltip"));
propertyNameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
logger.trace("got modify event: " + event);
}
});
propertyNameText.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent event) {
}
public void focusLost(FocusEvent event) {
logger.debug("got focus lost event: " + event);
Object obj = event.widget.getData();
logger.trace("obj: " + obj);
if(obj instanceof ObjectProperty) {
logger.debug("setting name on object property: " + obj);
((ObjectProperty)obj).setName(propertyNameText.getText());
}
doSave(null);
}
});
// property template (label)
label = new Label(propertyGroup, SWT.LEFT);
label.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false));
label.setText(Messages.getString("object.template.editor.property.template.label"));
label.setToolTipText(Messages.getString("object.template.editor.property.template.tooltip"));
// // property sequence (label)
// label = new Label(propertyGroup, SWT.LEFT);
// label.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false));
// label.setText(Messages.getString("object.template.editor.property.sequence.label"));
// label.setToolTipText(Messages.getString("object.template.editor.property.sequence.tooltip"));
// property instance limit (label)
label = new Label(propertyGroup, SWT.LEFT);
label.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false));
label.setText(Messages.getString("object.template.editor.property.limit.label"));
label.setToolTipText(Messages.getString("object.template.editor.property.limit.tooltip"));
// property template (widget)
propertyTemplateCheckbox = new Button(propertyGroup, SWT.CHECK);
propertyTemplateCheckbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
propertyTemplateCheckbox.setToolTipText(Messages
.getString("object.template.editor.property.template.tooltip"));
propertyTemplateCheckbox.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent event) {
widgetSelected(event);
}
public void widgetSelected(SelectionEvent event) {
logger.debug("got selection event: " + event);
Object obj = event.widget.getData();
logger.trace("obj: " + obj);
if(obj instanceof ObjectProperty) {
logger.debug("setting template on object property: " + obj);
((ObjectProperty)obj).setTemplate(((Button)event.widget).getSelection());
doSave(null);
}
}
});
// // property sequence (widget)
// propertySequenceSpinner = new Spinner(propertyGroup, SWT.NONE);
// propertySequenceSpinner.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false));
// propertySequenceSpinner.setToolTipText(Messages
// .getString("object.template.editor.property.sequence.tooltip"));
// propertySequenceSpinner.setIncrement(1);
// propertySequenceSpinner.setMinimum(0);
// propertySequenceSpinner.setMaximum(Integer.MAX_VALUE);
// propertySequenceSpinner.setPageIncrement(10);
// propertySequenceSpinner.setDigits(0);
// propertySequenceSpinner.addModifyListener(new ModifyListener() {
// public void modifyText(ModifyEvent event) {
// logger.trace("got modify event: " + event);
// }
// });
// propertySequenceSpinner.addFocusListener(new FocusListener() {
// public void focusGained(FocusEvent event) {
// }
//
// public void focusLost(FocusEvent event) {
// logger.debug("got focus lost event: " + event);
//
// Object obj = event.widget.getData();
// logger.trace("obj: " + obj);
// if(obj instanceof ObjectProperty) {
// logger.debug("setting sequence on object property: " + obj);
// ((ObjectProperty)obj).setSequence(propertySequenceSpinner.getSelection());
// }
//
// doSave(null);
// }
// });
// property instance limit (widget)
propertyLimitSpinner = new Spinner(propertyGroup, SWT.NONE);
propertyLimitSpinner.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false));
propertyLimitSpinner.setToolTipText(Messages
.getString("object.template.editor.property.limit.tooltip"));
propertyLimitSpinner.setIncrement(1);
propertyLimitSpinner.setMinimum(0);
propertyLimitSpinner.setMaximum(Integer.MAX_VALUE);
propertyLimitSpinner.setPageIncrement(10);
propertyLimitSpinner.setDigits(0);
propertyLimitSpinner.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
logger.trace("got modify event: " + event);
}
});
propertyLimitSpinner.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent event) {
}
public void focusLost(FocusEvent event) {
logger.debug("got focus lost event: " + event);
Object obj = event.widget.getData();
logger.trace("obj: " + obj);
if(obj instanceof ObjectProperty) {
logger.debug("setting instance limit on object property: " + obj);
((ObjectProperty)obj).setInstanceValueLimit(propertyLimitSpinner.getSelection());
}
doSave(null);
}
});
// property calculator (type, inputs, body)
Group calculatorGroup = new Group(propertyGroup, SWT.NONE);
calculatorGroup.setLayout(new GridLayout(2, false));
// label = new Label(propertyGroup, SWT.LEFT);
calculatorGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
calculatorGroup.setText(Messages.getString("object.template.editor.property.calculator.label"));
// label.setToolTipText(Messages.getString("object.template.editor.property.calculator.tooltip"));
{
label = new Label(calculatorGroup, SWT.RIGHT);
label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
label.setText(Messages.getString("object.template.editor.property.calculator.type.label"));
label.setToolTipText(Messages
.getString("object.template.editor.property.calculator.type.tooltip"));
propertyCalculatorTypeCombo = new Combo(calculatorGroup, SWT.DROP_DOWN);
propertyCalculatorTypeCombo
.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
propertyCalculatorTypeCombo.setToolTipText(Messages
.getString("object.template.editor.property.calculator.type.tooltip"));
propertyCalculatorTypeCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
logger.trace("got modify event: " + event);
}
});
propertyCalculatorTypeCombo.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent event) {
}
public void focusLost(FocusEvent event) {
logger.debug("got focus lost event: " + event);
Object obj = event.widget.getData();
logger.trace("obj: " + obj);
if(obj instanceof ObjectProperty) {
logger.debug("setting instance limit on object property: " + obj);
((ObjectProperty)obj).setCalculatorType(propertyCalculatorTypeCombo.getText());
}
doSave(null);
}
});
// TODO
propertyCalculatorInputsText = new Text(calculatorGroup, SWT.MULTI | SWT.BORDER);
propertyCalculatorInputsText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
propertyCalculatorInputsText.setToolTipText(Messages
.getString("object.template.editor.property.calculator.inputs.tooltip"));
propertyCalculatorInputsText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
logger.trace("got modify event: " + event);
}
});
propertyCalculatorInputsText.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent event) {
}
public void focusLost(FocusEvent event) {
logger.debug("got focus lost event: " + event);
Object obj = event.widget.getData();
logger.trace("obj: " + obj);
if(obj instanceof ObjectProperty) {
logger.debug("setting instance limit on object property: " + obj);
((ObjectProperty)obj).setCalculatorInputs(propertyCalculatorInputsText.getText());
}
doSave(null);
}
});
// TODO
propertyCalculatorBodyText = new Text(calculatorGroup, SWT.MULTI | SWT.BORDER);
propertyCalculatorBodyText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
propertyCalculatorBodyText.setToolTipText(Messages
.getString("object.template.editor.property.calculator.body.tooltip"));
propertyCalculatorBodyText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
logger.trace("got modify event: " + event);
}
});
propertyCalculatorBodyText.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent event) {
}
public void focusLost(FocusEvent event) {
logger.debug("got focus lost event: " + event);
Object obj = event.widget.getData();
logger.trace("obj: " + obj);
if(obj instanceof ObjectProperty) {
logger.debug("setting instance limit on object property: " + obj);
((ObjectProperty)obj).setCalculatorBody(propertyCalculatorBodyText.getText());
}
doSave(null);
}
});
// TODO
}
// property validator (type, body)
Group validatorGroup = new Group(propertyGroup, SWT.NONE);
validatorGroup.setLayout(new GridLayout(2, false));
// label = new Label(propertyGroup, SWT.LEFT);
validatorGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
validatorGroup.setText(Messages.getString("object.template.editor.property.validator.label"));
// label.setToolTipText(Messages.getString("object.template.editor.property.validator.tooltip"));
{
label = new Label(validatorGroup, SWT.RIGHT);
label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
label.setText(Messages.getString("object.template.editor.property.validator.type.label"));
label.setToolTipText(Messages
.getString("object.template.editor.property.validator.type.tooltip"));
propertyValidatorTypeCombo = new Combo(validatorGroup, SWT.DROP_DOWN);
propertyValidatorTypeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
propertyValidatorTypeCombo.setToolTipText(Messages
.getString("object.template.editor.property.validator.type.tooltip"));
propertyValidatorTypeCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
logger.trace("got modify event: " + event);
}
});
propertyValidatorTypeCombo.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent event) {
}
public void focusLost(FocusEvent event) {
logger.debug("got focus lost event: " + event);
Object obj = event.widget.getData();
logger.trace("obj: " + obj);
if(obj instanceof ObjectProperty) {
logger.debug("setting validator type on object property: " + obj);
((ObjectProperty)obj).setValidatorType(propertyValidatorTypeCombo.getText());
}
doSave(null);
}
});
// TODO
propertyValidatorBodyText = new Text(validatorGroup, SWT.MULTI | SWT.BORDER);
propertyValidatorBodyText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
propertyValidatorBodyText.setToolTipText(Messages
.getString("object.template.editor.property.validator.body.tooltip"));
propertyValidatorBodyText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
logger.trace("got modify event: " + event);
}
});
propertyValidatorBodyText.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent event) {
}
public void focusLost(FocusEvent event) {
logger.debug("got focus lost event: " + event);
Object obj = event.widget.getData();
logger.trace("obj: " + obj);
if(obj instanceof ObjectProperty) {
logger.debug("setting validator body on object property: " + obj);
((ObjectProperty)obj).setValidatorBody(propertyValidatorBodyText.getText());
}
doSave(null);
}
});
// TODO
}
// property formatter (type, body)
Group formatterGroup = new Group(propertyGroup, SWT.NONE);
formatterGroup.setLayout(new GridLayout(2, false));
// label = new Label(propertyGroup, SWT.LEFT);
formatterGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
formatterGroup.setText(Messages.getString("object.template.editor.property.formatter.label"));
// label.setToolTipText(Messages.getString("object.template.editor.property.formatter.tooltip"));
{
label = new Label(formatterGroup, SWT.RIGHT);
label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
label.setText(Messages.getString("object.template.editor.property.formatter.type.label"));
label.setToolTipText(Messages
.getString("object.template.editor.property.formatter.type.tooltip"));
propertyFormatterTypeCombo = new Combo(formatterGroup, SWT.DROP_DOWN);
propertyFormatterTypeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
propertyFormatterTypeCombo.setToolTipText(Messages
.getString("object.template.editor.property.formatter.type.tooltip"));
propertyFormatterTypeCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
logger.trace("got modify event: " + event);
}
});
propertyFormatterTypeCombo.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent event) {
}
public void focusLost(FocusEvent event) {
logger.debug("got focus lost event: " + event);
Object obj = event.widget.getData();
logger.trace("obj: " + obj);
if(obj instanceof ObjectProperty) {
logger.debug("setting formatter type on object property: " + obj);
((ObjectProperty)obj).setFormatterType(propertyFormatterTypeCombo.getText());
}
doSave(null);
}
});
// TODO
propertyFormatterBodyText = new Text(formatterGroup, SWT.MULTI | SWT.BORDER);
propertyFormatterBodyText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
propertyFormatterBodyText.setToolTipText(Messages
.getString("object.template.editor.property.formatter.body.tooltip"));
propertyFormatterBodyText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
logger.trace("got modify event: " + event);
}
});
propertyFormatterBodyText.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent event) {
}
public void focusLost(FocusEvent event) {
logger.debug("got focus lost event: " + event);
Object obj = event.widget.getData();
logger.trace("obj: " + obj);
if(obj instanceof ObjectProperty) {
logger.debug("setting formatter body on object property: " + obj);
((ObjectProperty)obj).setFormatterBody(propertyFormatterBodyText.getText());
}
doSave(null);
}
});
// TODO
}
}
}
}
listGroup.setWeights(new int[] { 70, 30 });
updateLabelPropertiesCombo();
// updateCampaignCombo();
populatePropertyToolbar();