我创造了一个怪物,它应该是一个更优雅的解决方案,但它逃脱了我的控制。
问题如下:
我有一个带有表格的对话窗口。第一次显示对话框时,表中包含SQL查询的不可编辑内容。内容已填充(例如)
item.setText(j, d2e.get(i)[j]);
表有一个双击监听器。单击某个项目时,不可编辑的项目将替换为可编辑的等效项目。这个新的可编辑TableItem
内置了文本字段和组合。问题是:
当我从组合中选择时,我无法编辑文本字段。
我不知道为什么。
这是怪物:
import java.util.ArrayList;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
public class TariffEditDialog2 extends DialogWindow {
static final int RESIZE = -1;
static final int NO_RESIZE = -2;
Boolean isConstant;
ContentData tariffConstants;
ContentData tariffVariables;
ContentData tariffConstantsOfType;
ContentData tariffVariablesOfType;
Combo cRates;
Table mt;
ArrayList<String[]> data2edit;
ArrayList<String[]> edited;
ArrayList<Editable> editable;
ArrayList<Integer> updateSorter;
int variableIDresizeCount = -1;
int defQuerySize = 0;
public TariffEditDialog2(Shell parent_in, ContentProvider cp, Boolean isConstant_in, ContentData tariffConstants_in, ContentData tariffVariables_in) {
super(parent_in, cp);
// TODO Auto-generated constructor stub
childWindow.setText("edit dialog");
isConstant = isConstant_in;
tariffVariables = tariffVariables_in;
tariffConstants = tariffConstants_in;
mt = new Table(mainContainer, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
mt.setLinesVisible(true);
mt.setHeaderVisible(true);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = 200;
mt.setLayoutData(gd);
mt.addListener(SWT.MouseDoubleClick, new Listener() {
@Override
public void handleEvent(Event arg0) {
// TODO Auto-generated method stub
populateMain(data2edit, isConstant, mt.getSelectionIndex());
}
});
populateHeader(isConstant);
data2edit = new ArrayList<String[]>();
edited = new ArrayList<String[]>();
editable = new ArrayList<Editable>();
updateSorter = new ArrayList<Integer>();
if (isConstant) {
ContentData query = contentProvider.getTariffConstantsOfType(Integer.parseInt(tariffConstants.getSelectedData()[1].toString()), Integer.parseInt(tariffConstants.getSelectedData()[2].toString()));
for (int i = 1; i < query.getQueryRowCount(); i++) {
data2edit.add(new String[tariffConstants.getColumnNamesCount()-1]);
for (int j = 1; j < tariffConstants.getColumnNamesCount(); j++) {
data2edit.get(i-1)[j-1] = query.getQueryData()[i][j].toString();
updateSorter.add(i-1);
}
}
//defQuerySize = data2edit.size();
populateMain(data2edit, isConstant, NO_RESIZE);
ok.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
convertEdited();
if (editable.size() > 0) {
//contentProvider.dbLicznikInsertAndReaload(cmd.updateOperatorsConstantDescriptions(editable.get(0).getData().get(0), editable.get(0).getData().get(1), cRates.getText(), data2edit.get(editable.get(0).getIndex())[0], data2edit.get(editable.get(0).getIndex())[1]));
contentProvider.dbLicznikInsertAndReaload(cmd.updateOperatorsConstantDescriptions(edited.get(0)[0], edited.get(0)[1], cRates.getText(), data2edit.get(editable.get(0).getIndex())[0], data2edit.get(editable.get(0).getIndex())[1]));
//contentProvider.dbLicznikInsertAndReaload(cmd.updateOperatorsConstantPricesDates(editable.get(0).getData().get(0), editable.get(0).getData().get(1), editable.get(0).getData().get(9), editable.get(0).getData().get(10), editable.get(0).getData().get(8), editable.get(0).getData().get(6), data2edit.get(editable.get(0).getIndex())[0], data2edit.get(editable.get(0).getIndex())[1]));
contentProvider.dbLicznikInsertAndReaload(cmd.updateOperatorsConstantPricesDates(edited.get(0)[0], edited.get(0)[1], edited.get(0)[9], edited.get(0)[10], edited.get(0)[8], edited.get(0)[6], data2edit.get(editable.get(0).getIndex())[0], data2edit.get(editable.get(0).getIndex())[1]));
for (int index = 0; index < editable.size(); index ++) {
if (updateSorter.contains(editable.get(index).getIndex())) {
contentProvider.dbLicznikInsertAndReaload(cmd.updateOperatorsConstantPricesValues(edited.get(index)[8], edited.get(index)[3], edited.get(index)[4], edited.get(index)[5], edited.get(index)[7], data2edit.get(editable.get(index).getIndex())[8], data2edit.get(editable.get(index).getIndex())[3]));
} else {
contentProvider.dbLicznikInsertAndReaload(cmd.insertConstantPricesValues(edited.get(index)[8], edited.get(index)[3], edited.get(index)[4], edited.get(index)[5], edited.get(index)[7]));
}
}
//System.out.println("edited: " + editable.size());
}
childWindow.close();
}
});
} else { // variable
ContentData query = contentProvider.getTariffVariablesOfType(Integer.parseInt(tariffVariables.getSelectedData()[1].toString()), Integer.parseInt(tariffVariables.getSelectedData()[8].toString()));
for (int i = 1; i < query.getQueryRowCount(); i++) {
data2edit.add(new String[tariffVariables.getColumnNamesCount()-1]);
updateSorter.add(i-1);
for (int j = 1; j < tariffVariables.getColumnNamesCount(); j++) {
if ( j < 7) {
data2edit.get(i-1)[j-1] = query.getQueryData()[i][j].toString();
} else if ( j >= 7 && j < 12) {
data2edit.get(i-1)[j-1] = query.getQueryData()[i][j+1].toString();
} else if ( j == 1) {
data2edit.get(i-1)[j-1] = "b";
}
}
}
defQuerySize = data2edit.size();
populateMain(data2edit, isConstant, NO_RESIZE);
ok.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// out.add(tVariable.getText()); //0
// out.add(tStart.getText()); //1
// out.add(tStop.getText()); //2
// out.add(tWeekdays.getText()); //3
// out.add(tDay_tariff_id.getText()); //4
// out.add(tType.getText()); //5
// out.add(d2e.get(edit)[6]); //6
// out.add(tSubgroup_id.getText()); //7
// out.add(tId.getText()); //8
// out.add(tStart2.getText()); //9
// out.add(tPrice.getText()); //10
// out.add(cUnit.getText()); //11
convertEdited();
if (editable.size() > 0) {
contentProvider.dbLicznikInsertAndReaload(cmd.updateTariffsCalendar(edited.get(0)[0], edited.get(0)[1], edited.get(0)[2], edited.get(0)[3], edited.get(0)[4], data2edit.get(0)[0]));
for (int index = 0; index < editable.size(); index ++) {
if (updateSorter.contains(editable.get(index).getIndex())) {
contentProvider.dbLicznikInsertAndReaload(cmd.updateTariffsParts(edited.get(index)[4], edited.get(index)[5], edited.get(index)[6], edited.get(index)[7], data2edit.get(index)[4], data2edit.get(index)[5]));
contentProvider.dbLicznikInsertAndReaload(cmd.updateTariffs(edited.get(index)[8], edited.get(index)[7], edited.get(index)[9], edited.get(index)[10], edited.get(index)[11], data2edit.get(index)[8]));
} else {
contentProvider.dbLicznikInsertAndReaload(cmd.insertTariffs(edited.get(index)[8], edited.get(index)[7], edited.get(index)[9], edited.get(index)[10], edited.get(index)[11]));
}
}
}
System.out.println("edited: " + editable.size());
//childWindow.close();
}
});
}
childWindow.pack();
childWindow.open();
}
private void populateHeader(final Boolean isConstant) {
Composite header = new Composite(headerContainer, SWT.NONE);
header.setLayout(new GridLayout(3, false));
cRates = new Combo(header, SWT.READ_ONLY);
Button bEditRates = new Button(header, SWT.PUSH);
bEditRates.setText("e");
if (isConstant) {
bEditRates.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
new EditRates(parent, contentProvider,true);
}
});
Button addDesc = new Button(header, SWT.PUSH);
addDesc.setText("+");
addDesc.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
populateMain(data2edit, isConstant, RESIZE);
}
});
GridData buttonWidth = new GridData();
buttonWidth.widthHint = 43;
addDesc.setLayoutData(buttonWidth);
int rateIndex = Integer.MAX_VALUE;
ContentData constantRateNames = contentProvider.getConstantRateNames();
for (int i = 1; i < constantRateNames.getQueryRowCount(); i++ ) {
cRates.add(constantRateNames.getQueryData()[i][2].toString());
if (constantRateNames.getQueryData()[i][2].toString().trim().equals(tariffConstants.getSelectedData()[3].toString().trim())) {
rateIndex = i-1;
}
}
if (rateIndex != Integer.MAX_VALUE) {
cRates.select(rateIndex);
}
} else { // is variable
bEditRates.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
new EditRates(parent, contentProvider,false);
}
});
Button addDesc = new Button(header, SWT.PUSH);
addDesc.setText("+");
addDesc.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (variableIDresizeCount == -1) {
variableIDresizeCount = contentProvider.getNextVariableId();
} else {
variableIDresizeCount++;
}
populateMain(data2edit, isConstant, RESIZE);
}
});
GridData buttonWidth = new GridData();
buttonWidth.widthHint = 43;
addDesc.setLayoutData(buttonWidth);
int rateIndex = Integer.MAX_VALUE;
ContentData variableRateNames = contentProvider.getVariableRateNames();
for (int i = 1; i < variableRateNames.getQueryRowCount(); i++ ) {
cRates.add(variableRateNames.getQueryData()[i][2].toString());
if (variableRateNames.getQueryData()[i][2].toString().trim().equals(tariffVariables.getSelectedData()[7].toString().trim())) {
rateIndex = i-1;
}
}
if (rateIndex != Integer.MAX_VALUE) {
cRates.select(rateIndex);
}
}
}
private void convertEdited() {
for (int i = 0; i < editable.size(); i++) {
String[] tmp = new String[editable.get(i).getData().size()];
for (int j = 0; j < tmp.length; j++) {
tmp[j] = editable.get(i).getData().get(j);
}
edited.add(tmp);
}
}
private void populateMain(ArrayList<String[]> d2e, Boolean isConstant, int edit) {
if (isConstant) {
if (mt.getColumnCount() == 0) {
for (int i = 1; i < tariffConstants.getColumnNamesCount()+1; i++) {
TableColumn column = new TableColumn(mt, SWT.NONE);
if (( i < 3) || ( i == 6 ) || ( i == 7) ) {
column.setText(tariffConstants.getColumnNames()[i].toString());
} else if ( (i == 3) || (i == 4) ) {
column.setText(tariffConstants.getColumnNames()[i+1].toString());
} else if ( (i == 5) || (i == 8) ) {
column.setText("e");
} else if ( i > 8) {
column.setText(tariffConstants.getColumnNames()[i-1].toString());
}
}
}
if (edit == RESIZE) {
d2e.add(d2e.get(d2e.size()-1).clone());
d2e.get(d2e.size()-1)[3] = Integer.toString(Integer.parseInt(d2e.get(d2e.size()-1)[3]) +1);
d2e.get(d2e.size()-1)[4] = "";
d2e.get(d2e.size()-1)[5] = "";
}
for (int i = 0; i < d2e.size(); i++) {
if ((i == edit) && (mt.getItemCount() > 0)) {
editable.add(new Editable(contentProvider, mt, mt.getItems()[i], isConstant, tariffVariables, tariffConstants, edit, d2e));
} else if( (edit == RESIZE) && ( i == d2e.size() - 1 ) && (d2e.size() > 1) ) {
editable.add(new Editable(contentProvider, mt, mt.getItems()[i], isConstant, tariffVariables, tariffConstants, i, d2e));
} else if (mt.getItemCount() < d2e.size()){
TableItem item = new TableItem(mt, SWT.NONE);
for (int j = 0; j < d2e.get(i).length +1; j++) {
if (( j < 2) || ( j == 5 ) || ( j == 6) ) {
item.setText(j, d2e.get(i)[j]);
} else if ( (j == 2) || (j == 3) ) {
item.setText(j, d2e.get(i)[j+1]);
} else if ( (j == 4) || (j == 7) ) {
item.setText(j, "");
} else if ( j > 7) {
item.setText(j, d2e.get(i)[j-1]);
}
}
}
}
for (int i = 0; i < mt.getColumnCount(); i++) {
if ( (i == 4) || (i == 7) ) {
mt.getColumn(i).setWidth(30);
} else if (i == 3) {
mt.getColumn(i).setWidth(400);
} else if (i == 6) {
mt.getColumn(i).setWidth(100);
} else {
mt.getColumn(i).pack();
}
}
} else { // is variable
if (mt.getColumnCount() == 0) {
for (int i = 1; i <tariffVariables.getColumnNamesCount(); i++) {
TableColumn column = new TableColumn(mt, SWT.NONE);
if ( i < 7 ) {
column.setText(tariffVariables.getColumnNames()[i].toString());
} else if ( (i >= 7) && (i < 12) ) {
column.setText(tariffVariables.getColumnNames()[i+1].toString());
} else if ( i == 12 ) {
column.setText("e");
}
}
}
if (edit == RESIZE) {
d2e.add(d2e.get(d2e.size()-1).clone());
d2e.get(d2e.size()-1)[7] = Integer.toString(variableIDresizeCount);
d2e.get(d2e.size()-1)[8] = "";
d2e.get(d2e.size()-1)[9] = "";
}
for (int i = 0; i < d2e.size(); i++) {
if ((i == edit) && (mt.getItemCount() > 0)) {
editable.add(new Editable(contentProvider, mt, mt.getItems()[i], isConstant, tariffVariables, tariffConstants, edit, d2e));
} else if( (edit == RESIZE) && ( i == d2e.size() - 1 ) && (d2e.size() > 1) ) {
editable.add(new Editable(contentProvider, mt, mt.getItems()[i], isConstant, tariffVariables, tariffConstants, i, d2e));
} else if (mt.getItemCount() < d2e.size()){
TableItem item = new TableItem(mt, SWT.NONE);
for (int j = 0; j < d2e.get(i).length; j++) {
if ( j < 11) {
item.setText(j, d2e.get(i)[j]);
} else {
item.setText(j, "");
}
}
}
}
for (int i = 0; i < mt.getColumnCount(); i++) {
if (i == 7) {
mt.getColumn(i).setWidth(75);
} else if (i == 10 ) {
mt.getColumn(i).setWidth(100);
} else if ( i == 11) {
mt.getColumn(i).setWidth(30);
} else {
mt.getColumn(i).pack();
}
}
}
mt.update();
}
private class Editable {
static final int BUT_WIDTH = 30;
Text tConstant;
Text tVariable;
Text tWeekdays;
Text tDay_tariff_id;
Text tType;
Text tSubgroup_id;
Text tId;
Text tPrice;
Text tMultip;
Text tPrices;
Text tStart;
Text tStart2;
Text tStop;
Combo cDescription;
Combo cUnit;
Button bEditUnits;
Button bEditDescr;
TableEditor[] tEditors;
Color green = new Color(parent.getDisplay(), 153, 242, 184);
ContentData descriptions;
ContentData units;
private TableItem item;
int selected;
int edit;
ArrayList<String[]> d2e;
public Editable (ContentProvider cp, Table mt, TableItem item_, Boolean isConstant, ContentData tariffVariables, ContentData tariffConstants, int edit_, ArrayList<String[]> d2e_ ) {
descriptions = cp.getConstantRateDescriptions();
units = cp.getRateUnits();
item = item_;
d2e = d2e_;
edit = edit_;
if (isConstant == true) {
tEditors = new TableEditor[12];
for (int i = 0; i < tEditors.length; i ++) {
tEditors[i] = new TableEditor(mt);
tEditors[i].horizontalAlignment = SWT.LEFT;
tEditors[i].grabHorizontal = true;
}
tConstant = new Text(mt, SWT.NONE);
tConstant.setText(d2e.get(edit)[0]);
tConstant.setBackground(green);
tConstant.addModifyListener(new myListener(tConstant));
tEditors[0].setEditor(tConstant, item, 0);
tType = new Text(mt, SWT.NONE);
tType.setText(d2e.get(edit)[1]);
tType.setBackground(green);
tType.addModifyListener(new myListener(tType));
tEditors[1].setEditor(tType, item, 1);
tId = new Text(mt, SWT.NONE);
tId.setText(d2e.get(edit)[3]);
tId.setBackground(green);
tId.addModifyListener(new myListener(tId));
tEditors[2].setEditor(tId, item, 2);
//------------------------------------------------------------------------------------
cDescription = new Combo(mt, SWT.NONE);
cDescription.setBackground(green);
selected = Integer.MAX_VALUE;
for (int i = 1; i < descriptions.getQueryRowCount(); i++) {
cDescription.add(descriptions.getQueryData()[i][2].toString());
if (descriptions.getQueryData()[i][2].toString().trim().equals(d2e.get(edit)[4].trim())) {
selected = i - 1;
}
}
if (selected != Integer.MAX_VALUE) {
cDescription.select(selected);
}
cDescription.addModifyListener(new myListener(cDescription));
tEditors[3].minimumWidth = cDescription.getSize().x;
tEditors[3].setEditor(cDescription, item, 3);
//------------------------------------------------------------------------------------
bEditDescr = new Button(mt, SWT.NONE);
bEditDescr.setText("e");
bEditDescr.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
new EditDescriptions(parent, contentProvider);
}
});
tEditors[4].minimumWidth = bEditDescr.getSize().x;
//tEditors[4].minimumWidth = BUT_WIDTH;
tEditors[4].setEditor(bEditDescr, item, 4);
tPrice = new Text(mt, SWT.NONE);
tPrice.setText(d2e.get(edit)[5]);
tPrice.setBackground(green);
tPrice.addModifyListener(new myListener(tPrice));
tEditors[5].setEditor(tPrice, item, 5);
//------------------------------------------------------------------------------------
cUnit = new Combo(mt, SWT.NONE);
cUnit.setBackground(green);
selected = Integer.MAX_VALUE;
for (int i = 1; i < units.getQueryRowCount(); i++) {
cUnit.add(units.getQueryData()[i][2].toString());
if (units.getQueryData()[i][2].toString().trim().equals(d2e.get(edit)[6].trim())) {
selected = i - 1;
}
}
if (selected != Integer.MAX_VALUE) {
cUnit.select(selected);
}
cUnit.addModifyListener(new myListener(cUnit));
tEditors[6].minimumWidth = cUnit.getSize().x;
tEditors[6].setEditor(cUnit, item, 6);
//------------------------------------------------------------------------------------
bEditUnits = new Button(mt, SWT.NONE);
bEditUnits.setText("e");
bEditUnits.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
new EditUnits(parent, contentProvider);
}
});
tEditors[7].minimumWidth = bEditUnits.getSize().x;
//tEditors[7].minimumWidth = BUT_WIDTH;
tEditors[7].setEditor(bEditUnits, item, 7);
tMultip = new Text(mt, SWT.NONE);
tMultip.setText(d2e.get(edit)[7]);
tMultip.setBackground(green);
tMultip.addModifyListener(new myListener(tMultip));
tEditors[8].setEditor(tMultip, item, 8);
tPrices = new Text(mt, SWT.NONE);
tPrices.setText(d2e.get(edit)[8]);
tPrices.setBackground(green);
tPrices.addModifyListener(new myListener(tPrices));
tEditors[9].setEditor(tPrices, item, 9);
tStart = new Text(mt, SWT.NONE);
tStart.setText(d2e.get(edit)[9]);
tStart.setBackground(green);
tStart.addModifyListener(new myListener(tStart));
tEditors[10].setEditor(tStart, item, 10);
tStop = new Text(mt, SWT.NONE);
tStop.setText(d2e.get(edit)[10]);
tStop.setBackground(green);
tStop.addModifyListener(new myListener(tStop));
tEditors[11].setEditor(tStop, item, 11);
} else { //variables
tEditors = new TableEditor[12];
for (int i = 0; i < tEditors.length; i ++) {
tEditors[i] = new TableEditor(mt);
tEditors[i].horizontalAlignment = SWT.LEFT;
tEditors[i].grabHorizontal = true;
}
tVariable = new Text(mt, SWT.NONE);
tVariable.setText(d2e.get(edit)[0]);
tVariable.setBackground(green);
tVariable.addModifyListener(new myListener(tVariable));
tEditors[0].setEditor(tVariable, item, 0);
tStart = new Text(mt, SWT.NONE);
tStart.setText(d2e.get(edit)[1]);
tStart.setBackground(green);
tStart.addModifyListener(new myListener(tStart));
tEditors[1].setEditor(tStart, item, 1);
tStop = new Text(mt, SWT.NONE);
tStop.setText(d2e.get(edit)[2]);
tStop.setBackground(green);
tStop.addModifyListener(new myListener(tStop));
tEditors[2].setEditor(tStop, item, 2);
tWeekdays = new Text(mt, SWT.NONE);
tWeekdays.setText(d2e.get(edit)[3]);
tWeekdays.setBackground(green);
tWeekdays.addModifyListener(new myListener(tWeekdays));
tEditors[3].setEditor(tWeekdays, item, 3);
tDay_tariff_id = new Text(mt, SWT.NONE);
tDay_tariff_id.setText(d2e.get(edit)[4]);
tDay_tariff_id.setBackground(green);
tDay_tariff_id.addModifyListener(new myListener(tDay_tariff_id));
tEditors[4].setEditor(tDay_tariff_id, item, 4);
tType = new Text(mt, SWT.NONE);
tType.setText(d2e.get(edit)[5]);
tType.setBackground(green);
tType.addModifyListener(new myListener(tType));
tEditors[5].setEditor(tType, item, 5);
tSubgroup_id = new Text(mt, SWT.NONE);
tSubgroup_id.setText(d2e.get(edit)[6]);
tSubgroup_id.setBackground(green);
tSubgroup_id.addModifyListener(new myListener(tSubgroup_id));
tEditors[6].setEditor(tSubgroup_id, item, 6);
tId = new Text(mt, SWT.NONE);
tId.setText(d2e.get(edit)[7]);
tId.setBackground(green);
tId.addModifyListener(new myListener(tId));
tEditors[7].setEditor(tId, item, 7);
tStart2 = new Text(mt, SWT.NONE);
tStart2.setText(d2e.get(edit)[8]);
tStart2.setBackground(green);
tStart2.addModifyListener(new myListener(tStart2));
tEditors[8].setEditor(tStart2, item, 8);
tPrice = new Text(mt, SWT.NONE);
tPrice.setText(d2e.get(edit)[9]);
tPrice.setBackground(green);
tPrice.addModifyListener(new myListener(tPrice));
tEditors[9].setEditor(tPrice, item, 9);
//------------------------------------------------------------------------------------
cUnit = new Combo(mt, SWT.NONE);
cUnit.setBackground(green);
selected = Integer.MAX_VALUE;
for (int i = 1; i < units.getQueryRowCount(); i++) {
cUnit.add(units.getQueryData()[i][2].toString());
if (units.getQueryData()[i][2].toString().trim().equals(d2e.get(edit)[10].trim())) {
selected = i - 1;
}
}
if (selected != Integer.MAX_VALUE) {
cUnit.select(selected);
}
cUnit.addModifyListener(new myListener(cUnit));
tEditors[10].minimumWidth = cUnit.getSize().x;
tEditors[10].setEditor(cUnit, item, 10);
//------------------------------------------------------------------------------------
bEditUnits = new Button(mt, SWT.NONE);
bEditUnits.setText("e");
bEditUnits.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
new EditUnits(parent, contentProvider);
}
});
tEditors[11].minimumWidth = BUT_WIDTH;
tEditors[11].setEditor(bEditUnits, item, 11);
}
}
public ArrayList<String> getData() {
ArrayList<String> out = new ArrayList<String>();
if (isConstant) {
out.add(tConstant.getText()); //0
out.add(tType.getText()); //1
out.add(d2e.get(edit)[2]); //2
out.add(tId.getText()); //3
out.add(cDescription.getText()); //4
out.add(tPrice.getText()); //5
out.add(cUnit.getText()); //6
out.add(tMultip.getText()); //7
out.add(tPrices.getText()); //8
out.add(tStart.getText()); //9
out.add(tStop.getText()); //10
} else {
out.add(tVariable.getText()); //0
out.add(tStart.getText()); //1
out.add(tStop.getText()); //2
out.add(tWeekdays.getText()); //3
out.add(tDay_tariff_id.getText()); //4
out.add(tType.getText()); //5
out.add(d2e.get(edit)[6]); //6
out.add(tSubgroup_id.getText()); //7
out.add(tId.getText()); //8
out.add(tStart2.getText()); //9
out.add(tPrice.getText()); //10
out.add(cUnit.getText()); //11
}
return out;
}
public int getIndex() {
return edit;
}
class myListener implements ModifyListener {
Text txt;
Combo cmb;
Color mod = new Color(parent.getDisplay(), 245, 149, 86);
public myListener(Text text) {
txt = text;
}
public myListener(Combo combo) {
cmb = combo;
}
@Override
public void modifyText(ModifyEvent arg0) {
// TODO Auto-generated method stub
if (cmb != null)
cmb.setBackground(mod);
if (txt != null)
txt.setBackground(mod);
}
}
}
}