Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Changing the selection of a Table during execRowsSelected(rows)
Changing the selection of a Table during execRowsSelected(rows) [message #1383924] Tue, 27 May 2014 08:41 Go to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
In the application I am working on, we have some use cases that imply changing the selection of the Table during execRowSelected(rows):

Use-Case 1/ If the rows parameter is an empty list, restore the selection to the default selection.
Something like:
@Override
protected void execRowsSelected(List<? extends ITableRow> rows) throws ProcessingException {
  if (rows.isEmpty()) {
    restoreSelection();
  }
}


Where restoreSelection() selects row given an variable on the form (assuming PersonNrColumn is a not displayable column marked as primary key)

public void restoreSelection() {
  ITableRow row = findRowByKey(Collections.singletonList(m_selectedPersonNr));
  if (row != null) {
    selectRow(row);
  }
}


Use-Case 2/
We have implemented some master/detail behavior on our tables.
When the user selects another row in the table, we need to ask him something (bringing a MessageBoxshowYesNoMessage(..) question). If he answers "no" we need to selects back the previous row.


In both cases, it is not possible to influence the selection of the Table during execRowsSelected(..). How can I implement the use cases? Thank you in advance.

.

[Updated on: Tue, 27 May 2014 08:45]

Report message to a moderator

Re: Changing the selection of a Table during execRowsSelected(rows) [message #1386643 is a reply to message #1383924] Thu, 19 June 2014 04:16 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I got from Ivan Motsch following input:

An idea is to modify selectRows()

@Override
public void selectRows(List<? extends ITableRow> rows, boolean append) {
  //modify rows.
  super.selectRows(rows, append);
}


This idea is not working at all.

For my use case (1) "ensure that a row is always selected", I tried this implementation:

@Override
public void selectRows(List<? extends ITableRow> rows, boolean append) {
  List<ITableRow> allRows = getRows();
  if (rows.size() == 0 && allRows.size() > 0) {
    super.selectRows(Collections.singletonList(allRows.get(0)), false);
  }
  else {
    super.selectRows(rows, append);
  }
}


For my use case (2) "ask if the user is sure he wants to change the selected row", I tried this implementation:

@Override
public void selectRows(List<? extends ITableRow> rows, boolean append) {
  List<? extends ITableRow> selection;
  if (rows.size() == 1 && rows.get(0) != getSelectedRow()) {
    int r = MessageBox.showYesNoMessage(null, "Are you sure?", null);
    if (r == MessageBox.YES_OPTION) {
      selection = Collections.singletonList(rows.get(0));
    }
    else {
      selection = Collections.singletonList(getSelectedRow());
    }
  }
  else {
    selection = Collections.singletonList(getSelectedRow());
  }
  super.selectRows(selection, false);
}


index.php/fa/18320/0/

I think that one of the problems is that the UI do not care of what the model indicates as selected row.

In case of a value field we have really:
User input => transfert the in the model with setTextFromUI() => parse, set, format value => set the computed displayText back in the UI.

It doesn't seem to be the case with the Table selection.
Re: Changing the selection of a Table during execRowsSelected(rows) [message #1388604 is a reply to message #1386643] Thu, 26 June 2014 17:45 Go to previous message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Quick update. We solve this with an input from Claudio Guglielmo: use a Job do change the selection.

final ITableRow row
ClientSyncJob job = new ClientSyncJob("selectRowDelayed", ClientSession.get()) {

    @Override
    protected void runVoid(IProgressMonitor monitor) throws ProcessingException {
        selectRow(row);
    }

};
job.setSystem(true);
job.schedule();


It is not really nice, but it works. Thank you a lot.


PS: I just saw this forum Post from BSH. It is related. Same solution for a similar problem.

.

[Updated on: Fri, 27 June 2014 06:54]

Report message to a moderator

Previous Topic:Is there a DropdownBox?
Next Topic:Problem after adding Rayo Swing Look and Feel
Goto Forum:
  


Current Time: Tue Apr 16 07:26:04 GMT 2024

Powered by FUDForum. Page generated in 0.24854 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top