Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticket5811 table bug fixing #1318

Merged
merged 21 commits into from
Aug 20, 2021
Merged

Ticket5811 table bug fixing #1318

merged 21 commits into from
Aug 20, 2021

Conversation

JamesKingWork
Copy link
Contributor

Description of work

  • Correct how we update actions in the script generator actions table so we don't lose and reapply focus
  • Fix some minor bugs discovered whilst playing around

Ticket

ISISComputingGroup/IBEX#5811

Acceptance criteria

To test:

  • Add lots of rows very quickly and then try editing and tabbing between cells whilst the script generator validates and calculates an estimated time for all the actions
  • Confirm that general actions still work such as changing script definitions, adding, removing, moving actions up and down, saving and reloading parameters

Unit tests

Give an overview of unit tests you have added or modified, if applicable. The aim is provide information to help the reviewer

System tests

Mention any automated tests or manual tests that you have added or modified, if applicable. The aim is provide information to help the reviewer

Documentation

Highlight and provide a link to any additions or changes to the documentation, if applicable. The aim is provide information to help the reviewer


Code Review

  • Is the code of an acceptable quality?
  • Do the changes function as described and is it robust?
  • Is there associated PR for the release notes?

Final Steps

// Add new action if tab is pressed by user in the last cell of the table.
if (nextCell.getNeighbor(ViewerCell.BELOW, false).getElement() == null
&& (viewer.getTable().getColumnCount() - NON_EDITABLE_COLUMNS_ON_RIGHT == currentlyFocusedColumn)) {
Optional<ViewerCell> neighbour = Optional.ofNullable(nextCell.getNeighbor(ViewerCell.BELOW, false));
Copy link
Contributor Author

@JamesKingWork JamesKingWork Jun 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes NullPointerException where the ViewerCell from BELOW was null as it doesn't exist (which also means there is no action below the current one. The || is a cut so the call to get() should be fine.

/**
* Sets focus of cell.
* @param row row number of table
* @param column column number of table
*/
public void setCellFocus(int row, int column) {
if (row >= 0) {
viewer.editElement(viewer.getElementAt(row), column);
var element = viewer.getElementAt(row);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes NullPointerException where the element is null so editElement cannot handle it.

@@ -86,16 +82,6 @@
*/
private static final Color CLEAR_COLOR = DISPLAY.getSystemColor(SWT.COLOR_WHITE);

/**
* A light orange to use when validity checks may be incorrect e.g. for when using an unsupported language.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used anywhere so removed

@@ -59,9 +58,6 @@

/**
* The ViewModel for the ScriptGeneratorView.
*
* @author James King
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know when this was added, but certainly hasn't been just me so removed

@@ -324,7 +310,6 @@ private void displayThreadingError() {
protected void addEmptyAction() {
scriptGeneratorModel.addEmptyAction();
// Make sure the table is updated with the new action before selecting it
actionChangeHandler(viewTable, btnGenerateScript, btnSaveParam, btnSaveParamAs, true);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actionChangeHandler should only be called when the action change is propagated from below.

DISPLAY.asyncExec(() -> {
viewTable.setCellFocus(insertionLocation, 0);
viewTable.setCellFocus(insertionLocation, ActionsViewTable.NON_EDITABLE_COLUMNS_ON_LEFT);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set the cell focus to the first editable column

@@ -767,25 +746,6 @@ protected String getFirstNLinesOfInvalidityErrors(int i) {
* @param viewTable The table in the view to update.
*/
protected void updateValidityChecks(ActionsViewTable viewTable) {
List<ScriptGeneratorAction> actions = scriptGeneratorModel.getActions();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved into the update calls in the various columns as this seemed more in-keeping with the swt tables

@LowriJenkins LowriJenkins self-assigned this Jun 30, 2021
Copy link
Contributor

@LowriJenkins LowriJenkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a large number of rows quickly, and then changing the script definition to one with global variables causes the script genderator to crash.

Other than that everything seems to look fine, a couple of comments on the code.

I doubt its just your ticket thats done it, but i was checking various buttons still work when its handling lots of new inputs in the table and it looks like theres a problem with the help button? it seems to link to an empty page.

}
} catch (IllegalArgumentException e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not certain whether this should be a try catch or if it would be better as an exception, its my understanding that if this is non-exceptional flow control its preferred to use an if statement for this instead.

}

@Override
public String getToolTipText(Object element) {
return getScriptGenActionToolTipText(element);
}

@Override
public void update(ViewerCell cell) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the indentation here is off, a few other places as well.

@JamesKingWork
Copy link
Contributor Author

Adding a large number of rows quickly, and then changing the script definition to one with global variables causes the script genderator to crash.

I couldn't cause the script generator to crash doing this, but it did write nasty things to the log that looked like it could be the symptom of what would have caused a crash for you. I have now rewritten the algorithm to prevent this issue, I hope it also corrects the crashing that you saw, let me know if it doesn't so we can look through together to see what is causing it.

Copy link
Contributor

@LowriJenkins LowriJenkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the changes made and handling of the edge case found, this is good to go in.

@LowriJenkins LowriJenkins merged commit 80dba25 into master Aug 20, 2021
@LowriJenkins LowriJenkins deleted the Ticket5811_table_bug_fixing branch August 20, 2021 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants