Page MenuHomePhabricator

Abstract away Selection handling from the surface
Closed, ResolvedPublic1 Estimated Story Points

Description

Anywhere in the surface that we check selection type we should probably be passing that functionality off to a handler, for example instead of:

if ( selection instanceof ve.dm.LinearSelection ) {
  doSomethingLinear();
} else if ( selection instanceof ve.dm.TableSelection ) {
  doSomethingTabular();
} else {
  doNothing(); // selection type is probably null?? 
}

use

handler = doSomethingHandlerRegistry.lookup( selection.getName() );
handler.doSomething();

This removes a ton of switch-like statements and would also allow a user to remove all the logic associated with a particular selection type (e.g. for a VE instance that didn't require TableSelections).

Event Timeline

Esanders raised the priority of this task from to Needs Triage.
Esanders updated the task description. (Show Details)
Esanders subscribed.

Change 248911 had a related patch set uploaded (by Esanders):
Introduce key down handlers to spearate logic from ce surface

https://gerrit.wikimedia.org/r/248911

Jdforrester-WMF triaged this task as Medium priority.
Jdforrester-WMF set Security to None.
Jdforrester-WMF edited a custom field.

Change 248911 merged by jenkins-bot:
Introduce key down handlers to separate logic from ce surface

https://gerrit.wikimedia.org/r/248911