|
|
|
Re: Where does TableViewer select an entry? [message #537446 is a reply to message #537434] |
Wed, 02 June 2010 13:29 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
I am referring to the doSave handler in DetailsView. I have the equivalent, the 2 methods here:
public void doSave(@Optional IProgressMonitor monitor) throws IOException, InterruptedException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
persistChange(PersistType.UPDATE);
dirtyable.setDirty(false);
}
private void persistChange(final PersistType type) throws IOException, InterruptedException {
// Uses this format 'testcase name'|'Inbound meta filename'|
// 'Outbound meta filename'|'Mapping meta filename'|
// 'Inbound data filename'|'Outbound data filename'
// maps to Testcase object
Display display = parent.getDisplay();
if (!(display==null || display.isDisposed())) {
display.asyncExec(new Runnable () {
public void run() {
FileWriter outputStream = null;
try {
outputStream = new FileWriter("../workspace/com.hsbcib.grds.testui/grdstestcase.dat");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
TestCase original = testCaseComposite.getOriginalTestCase();
TestCase modified = testCaseComposite.getModifiedTestCase();
List<TestCase> testcases = TestCaseRepositoryFactory.getTestCaseRepository().getAllTestCases();
BufferedWriter writer = new BufferedWriter(outputStream);
try {
boolean madeChange = false;
String record = "";
for(int i=0; i<testcases.size(); i++){
TestCase aCase = testcases.get(i);
if(original==null) {
TestCase aNewCase = new TestCase();
aNewCase.setName("New Case");
record = makeTestCaseRecord(aNewCase);
TestCaseRepositoryFactory.getTestCaseRepository().getAllTestCases().add(aNewCase);
writer.write(record);
break;
} else if(original != null && original.getName().equals(aCase.getName())) {
if(type==PersistType.DELETE) {
TestCaseRepositoryFactory.getTestCaseRepository().getAllTestCases().remove(i);
continue;
} else if (type==PersistType.UPDATE) {
if(!madeChange) {
record = makeTestCaseRecord(modified);
TestCaseRepositoryFactory.getTestCaseRepository().getAllTestCases().set(i, modified);
madeChange=true;
} else {
record = makeTestCaseRecord(aCase);
TestCaseRepositoryFactory.getTestCaseRepository().getAllTestCases().set(i, aCase);
}
}
} else {
record = makeTestCaseRecord(aCase);
}
writer.write(record);
}
if (type==PersistType.CLONE) {
String name = modified.getName();
// This only works up to 10 clone names, but not unique on name anyway
if(name.substring(name.length()-1, name.length()).matches("\\d")) {
int cloneno = Integer.parseInt(name.substring(name.length()-1, name.length()));
modified.setName(name.substring(0,name.length()-1)+Integer.valueOf(++cloneno));
} else {
modified.setName(name+"0");
}
record = makeTestCaseRecord(modified);
TestCaseRepositoryFactory.getTestCaseRepository().getAllTestCases().add(modified);
writer.write(record);
} else if (type==PersistType.CREATE) {
TestCase aNewCase = new TestCase();
aNewCase.setName("New Case");
record = makeTestCaseRecord(aNewCase);
TestCaseRepositoryFactory.getTestCaseRepository().getAllTestCases().add(aNewCase);
writer.write(record);
}
writer.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
}
The difference is that when Contacts finishes its equivalent of the persistance of the data in the doSave the current contact in DetailsView remains the same and the ListView also maintains the same selected contact. In my app, the current element is unselected in my equivalent of ListView and the Detail view has no TestCase selected.
I think it might be the fact that I call this
TestCaseRepositoryFactory.getTestCaseRepository().getAllTestCases().set
and that is the IObservableList. Am I on the right path here?
Thx.
David
[Updated on: Wed, 02 June 2010 13:30] Report message to a moderator
|
|
|
|
|
|
|
|
Re: Where does TableViewer select an entry? [message #577008 is a reply to message #537434] |
Wed, 02 June 2010 13:29 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
I am referring to the doSave handler in DetailsView. I have the equivalent, the 2 methods here:
public void doSave(@Optional IProgressMonitor monitor) throws IOException, InterruptedException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
persistChange(PersistType.UPDATE);
dirtyable.setDirty(false);
}
private void persistChange(final PersistType type) throws IOException, InterruptedException {
// Uses this format 'testcase name'|'Inbound meta filename'|
// 'Outbound meta filename'|'Mapping meta filename'|
// 'Inbound data filename'|'Outbound data filename'
// maps to Testcase object
Display display = parent.getDisplay();
if (!(display==null || display.isDisposed())) {
display.asyncExec(new Runnable () {
public void run() {
FileWriter outputStream = null;
try {
outputStream = new FileWriter("../workspace/com.hsbcib.grds.testui/grdstestcase.dat ");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
TestCase original = testCaseComposite.getOriginalTestCase();
TestCase modified = testCaseComposite.getModifiedTestCase();
List<TestCase> testcases = TestCaseRepositoryFactory.getTestCaseRepository().getAllTest Cases();
BufferedWriter writer = new BufferedWriter(outputStream);
try {
boolean madeChange = false;
String record = "";
for(int i=0; i<testcases.size(); i++){
TestCase aCase = testcases.get(i);
if(original==null) {
TestCase aNewCase = new TestCase();
aNewCase.setName("New Case");
record = makeTestCaseRecord(aNewCase);
TestCaseRepositoryFactory.getTestCaseRepository().getAllTest Cases().add(aNewCase);
writer.write(record);
break;
} else if(original != null && original.getName().equals(aCase.getName())) {
if(type==PersistType.DELETE) {
TestCaseRepositoryFactory.getTestCaseRepository().getAllTest Cases().remove(i);
continue;
} else if (type==PersistType.UPDATE) {
if(!madeChange) {
record = makeTestCaseRecord(modified);
TestCaseRepositoryFactory.getTestCaseRepository().getAllTest Cases().set(i, modified);
madeChange=true;
} else {
record = makeTestCaseRecord(aCase);
TestCaseRepositoryFactory.getTestCaseRepository().getAllTest Cases().set(i, aCase);
}
}
} else {
record = makeTestCaseRecord(aCase);
}
writer.write(record);
}
if (type==PersistType.CLONE) {
String name = modified.getName();
// This only works up to 10 clone names, but not unique on name anyway
if(name.substring(name.length()-1, name.length()).matches("\\d")) {
int cloneno = Integer.parseInt(name.substring(name.length()-1, name.length()));
modified.setName(name.substring(0,name.length()-1)+Integer.v alueOf(++cloneno));
} else {
modified.setName(name+"0");
}
record = makeTestCaseRecord(modified);
TestCaseRepositoryFactory.getTestCaseRepository().getAllTest Cases().add(modified);
writer.write(record);
} else if (type==PersistType.CREATE) {
TestCase aNewCase = new TestCase();
aNewCase.setName("New Case");
record = makeTestCaseRecord(aNewCase);
TestCaseRepositoryFactory.getTestCaseRepository().getAllTest Cases().add(aNewCase);
writer.write(record);
}
writer.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
}
The difference is that when Contacts finishes its equivalent of the persistance of the data in the doSave the current contact in DetailsView reamins the same and the ListView also maintains the same selected contact. In my app, the current element is unselected in my equivalent of ListView and the Detail view has no TestCase selected.
I think it might be the fact that I call this
TestCaseRepositoryFactory.getTestCaseRepository().getAllTest Cases().set
and that is the IObservableList. Am I on the right path here?
Thx.
David
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04001 seconds