Skip to content

Commit

Permalink
don't toggle mapping relevant state for types individually
Browse files Browse the repository at this point in the history
...because it results in bad performance when many types are removed,
as events were fired for each type.

Change-Id: Icf9a0ac98440f3b6a37542957ee0c1ea89d436aa
  • Loading branch information
stempler committed Oct 4, 2015
1 parent c7d0918 commit f2c9b8d
Showing 1 changed file with 18 additions and 10 deletions.
Expand Up @@ -15,8 +15,9 @@
*/
package eu.esdihumboldt.hale.ui.service.schema.handler;

import java.util.Collections;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
Expand All @@ -38,16 +39,15 @@
*/
public class MarkTypeUnmappableHandler extends AbstractHandler {

/**
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
SchemaService schemaService = (SchemaService) PlatformUI.getWorkbench().getService(
SchemaService.class);
Iterator<?> it = ((IStructuredSelection) selection).iterator();
List<TypeDefinition> sourceTypes = new ArrayList<>();
List<TypeDefinition> targetTypes = new ArrayList<>();
while (it.hasNext()) {
Object selected = it.next();
TypeDefinition type = null;
Expand All @@ -59,14 +59,22 @@ else if (selected instanceof TypeDefinition) {
}
if (type != null) {
if (schemaService.getSchemas(SchemaSpaceID.SOURCE).getMappingRelevantTypes()
.contains(type))
schemaService.toggleMappable(SchemaSpaceID.SOURCE,
Collections.singleton(type));
else
schemaService.toggleMappable(SchemaSpaceID.TARGET,
Collections.singleton(type));
.contains(type)) {
sourceTypes.add(type);
}
else {
targetTypes.add(type);
}
}
}

if (!sourceTypes.isEmpty()) {
schemaService.toggleMappable(SchemaSpaceID.SOURCE, sourceTypes);
}

if (!targetTypes.isEmpty()) {
schemaService.toggleMappable(SchemaSpaceID.TARGET, targetTypes);
}
}

return null;
Expand Down

0 comments on commit f2c9b8d

Please sign in to comment.