Skip to content
Snippets Groups Projects
Commit 255b913b authored by Katy Saintin's avatar Katy Saintin
Browse files

Pb d'interface avec ITable

parent 4c6b60eb
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,6 @@ import fr.soleil.data.container.matrix.StringMatrix;
public class DemoTable {
public DemoTable(Composite parent) {
initGUI(parent);
}
......@@ -43,15 +42,18 @@ public class DemoTable {
componentPanel.setLayoutData(componentGridData);
// set a background to let user see limits of the component
componentPanel.setBackground(new Color(Display.getCurrent(), 255, 175, 175));// PINK as in awt
componentPanel.setBackground(new Color(Display.getCurrent(), 255, 175, 175));// PINK as in
// awt
final Table<String> theComponent = new Table<String>(componentPanel, SWT.NONE);
theComponent.setLayoutData(new RowData(275, 150));
// ----------
Group testPanelIComponent = IComponentTestPanel.getTestPanel(mainComposite, theComponent);
Group testPanelIEditableComponent = IEditableComponentTestPanel.getTestPanel(mainComposite, theComponent);
Group testIFormatabletargetComponent = IFormatableTargetTestPanel.getTestPanel(mainComposite, theComponent);
Group testPanelIEditableComponent = IEditableComponentTestPanel.getTestPanel(mainComposite,
theComponent);
Group testIFormatabletargetComponent = IFormatableTargetTestPanel.getTestPanel(
mainComposite, theComponent);
Group testTablePanel = ITableTestPanel.getTestPanel(mainComposite, theComponent);
GridData iComponentGridData = new GridData();
......@@ -62,7 +64,6 @@ public class DemoTable {
iComponentGridData.verticalAlignment = SWT.FILL;
testPanelIComponent.setLayoutData(iComponentGridData);
Group optionGroup = new Group(componentPanel, SWT.NONE);
optionGroup.setText("SetMatrixData");
optionGroup.setLayout(new RowLayout(SWT.HORIZONTAL));
......@@ -85,11 +86,10 @@ public class DemoTable {
StringMatrix result = new StringMatrix();
result.setValue(matrixTable);
theComponent.setMatrixData(result);
theComponent.setData(result);
}
});
GridData iEditableComponentGridData = new GridData();
iEditableComponentGridData.verticalAlignment = SWT.BEGINNING;
testPanelIEditableComponent.setLayoutData(iEditableComponentGridData);
......@@ -127,5 +127,4 @@ public class DemoTable {
System.exit(0);
}
}
......@@ -26,14 +26,12 @@ public class IFormatableTargetTestPanel extends AbstractTestPanel<IFormatableTar
super(parent, theComponent);
}
@Override
protected void setMethodTestPanels(IFormatableTarget theComponent) {
addSetFormatTest(theComponent);
addGetFormatTest(theComponent);
}
// Set format
private void addSetFormatTest(final IFormatableTarget theComponent) {
Group optionGroup = new Group(this, SWT.NONE);
......@@ -71,7 +69,8 @@ public class IFormatableTargetTestPanel extends AbstractTestPanel<IFormatableTar
public void widgetSelected(SelectionEvent arg0) {
String message = theComponent.getFormat();
MessageBox mb = new MessageBox(IFormatableTargetTestPanel.this.getShell(), SWT.ICON_INFORMATION | SWT.OK);
MessageBox mb = new MessageBox(IFormatableTargetTestPanel.this.getShell(),
SWT.ICON_INFORMATION | SWT.OK);
mb.setText("Current format");
mb.setMessage(message != null ? message : "(null)");
mb.open();
......@@ -125,11 +124,12 @@ public class IFormatableTargetTestPanel extends AbstractTestPanel<IFormatableTar
componentPanel.setLayoutData(componentGridData);
// set a background to let user see limits of the component
componentPanel.setBackground(new Color(Display.getCurrent(), 255, 175, 175));// PINK as in awt
componentPanel.setBackground(new Color(Display.getCurrent(), 255, 175, 175));// PINK as in
// awt
// TABLE
final Table<String> theComponent = new Table<String>(componentPanel, SWT.NONE);
theComponent.setMatrixData(initStringData());
theComponent.setData(initStringData());
theComponent.setLayoutData(new RowData(300, 300));
// ----------
......
......@@ -23,16 +23,16 @@ import fr.soleil.comete.swt.Table;
import fr.soleil.data.container.matrix.AbstractMatrix;
import fr.soleil.data.container.matrix.StringMatrix;
public class ITableTestPanel<T> extends AbstractTestPanel<ITable<AbstractMatrix<T>>>{
public class ITableTestPanel<T> extends AbstractTestPanel<ITable<T>> {
private ITableListener<AbstractMatrix<T>> listener;
private ITableListener<T> listener;
public ITableTestPanel(Composite parent, ITable<AbstractMatrix<T>> theComponent) {
public ITableTestPanel(Composite parent, ITable<T> theComponent) {
super(parent, theComponent);
}
@Override
protected void setMethodTestPanels(ITable<AbstractMatrix<T>> theComponent) {
protected void setMethodTestPanels(ITable<T> theComponent) {
addAddTableListenerTest(theComponent);
addRemoveTableListenerTest(theComponent);
addFireValueChangedTest(theComponent);
......@@ -41,11 +41,11 @@ public class ITableTestPanel<T> extends AbstractTestPanel<ITable<AbstractMatrix<
}
// add table listener
private void addAddTableListenerTest(final ITable<AbstractMatrix<T>> theComponent) {
private void addAddTableListenerTest(final ITable<T> theComponent) {
final Label labelText = new Label(this, SWT.LEFT);
labelText.setText("Table listener ");
listener = new ITableListener<AbstractMatrix<T>>() {
listener = new ITableListener<T>() {
@Override
public void selectedColumnChanged(int arg0) {
......@@ -67,7 +67,7 @@ public class ITableTestPanel<T> extends AbstractTestPanel<ITable<AbstractMatrix<
}
@Override
public void valueChanged(AbstractMatrix<T> arg0) {
public void valueChanged(T arg0) {
labelText.setText("Value changed ");
ITableTestPanel.this.layout();
}
......@@ -76,7 +76,7 @@ public class ITableTestPanel<T> extends AbstractTestPanel<ITable<AbstractMatrix<
}
// remove table listener
private void addRemoveTableListenerTest(final ITable<AbstractMatrix<T>> theComponent) {
private void addRemoveTableListenerTest(final ITable<T> theComponent) {
// Group
Group optionGroup = new Group(this, SWT.NONE);
......@@ -95,7 +95,7 @@ public class ITableTestPanel<T> extends AbstractTestPanel<ITable<AbstractMatrix<
});
}
private void addFireValueChangedTest(final ITable<AbstractMatrix<T>> theComponent) {
private void addFireValueChangedTest(final ITable<T> theComponent) {
// Group
Group optionGroup = new Group(this, SWT.NONE);
......@@ -109,13 +109,13 @@ public class ITableTestPanel<T> extends AbstractTestPanel<ITable<AbstractMatrix<
fireValueChangeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
theComponent.fireValueChanged(theComponent.getMatrixData());
theComponent.fireValueChanged(theComponent.getData());
}
});
}
private void addGetMatrixDataTest(final ITable<AbstractMatrix<T>> theComponent) {
private void addGetMatrixDataTest(final ITable<T> theComponent) {
Group optionGroup = new Group(this, SWT.NONE);
optionGroup.setText("GetMatrixData");
optionGroup.setLayout(new RowLayout(SWT.HORIZONTAL));
......@@ -126,8 +126,11 @@ public class ITableTestPanel<T> extends AbstractTestPanel<ITable<AbstractMatrix<
getMatrixDataButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
AbstractMatrix<T> data = theComponent.getMatrixData();
T simpledata = theComponent.getData();
AbstractMatrix<T> data = null;
if (simpledata != null && simpledata instanceof AbstractMatrix<?>) {
data = (AbstractMatrix<T>) simpledata;
StringBuilder message = new StringBuilder();
for (int j = 0; j < data.getHeight(); j++) {
for (int i = 0; i < data.getWidth(); i++) {
......@@ -137,16 +140,17 @@ public class ITableTestPanel<T> extends AbstractTestPanel<ITable<AbstractMatrix<
message.append("\n");
}
MessageBox mb = new MessageBox(ITableTestPanel.this.getShell(), SWT.ICON_INFORMATION | SWT.OK);
MessageBox mb = new MessageBox(ITableTestPanel.this.getShell(),
SWT.ICON_INFORMATION | SWT.OK);
mb.setText("Current data");
mb.setMessage(message.toString());
mb.open();
}
}
});
}
private void addSetMatrixDataTest(final ITable<AbstractMatrix<T>> theComponent) {
private void addSetMatrixDataTest(final ITable<T> theComponent) {
// Group optionGroup = new Group(null, 0);
// optionGroup.setText("SetMatrixData");
......@@ -175,7 +179,6 @@ public class ITableTestPanel<T> extends AbstractTestPanel<ITable<AbstractMatrix<
}
private static StringMatrix initStringData() {
String[][] matrixTable = new String[5][4];
for (int i = 0; i < 5; i++) {
......@@ -188,7 +191,7 @@ public class ITableTestPanel<T> extends AbstractTestPanel<ITable<AbstractMatrix<
return result;
}
public static <U> Group getTestPanel(Composite parent, ITable<AbstractMatrix<U>> theComponent) {
public static <U> Group getTestPanel(Composite parent, ITable<U> theComponent) {
Group group = new Group(parent, SWT.NONE);
group.setText("ITable");
group.setLayout(new FillLayout());
......@@ -222,14 +225,14 @@ public class ITableTestPanel<T> extends AbstractTestPanel<ITable<AbstractMatrix<
componentPanel.setLayoutData(componentGridData);
// set a background to let user see limits of the component
componentPanel.setBackground(new Color(Display.getCurrent(), 255, 175, 175));// PINK as in awt
componentPanel.setBackground(new Color(Display.getCurrent(), 255, 175, 175));// PINK as in
// awt
// TABLE
final Table<String> theComponent = new Table<String>(componentPanel, SWT.NONE);
theComponent.setMatrixData(initStringData());
theComponent.setData(initStringData());
theComponent.setLayoutData(new RowData(275, 150));
Group optionGroup = new Group(componentPanel, SWT.NONE);
optionGroup.setText("SetMatrixData");
optionGroup.setLayout(new RowLayout(SWT.HORIZONTAL));
......@@ -252,7 +255,7 @@ public class ITableTestPanel<T> extends AbstractTestPanel<ITable<AbstractMatrix<
StringMatrix result = new StringMatrix();
result.setValue(matrixTable);
theComponent.setMatrixData(result);
theComponent.setData(result);
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment