import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.swt.widgets.Display;
import org.simantics.DatabaseJob;
}
private void delete(IProgressMonitor monitor) throws DatabaseException {
+ SubMonitor subMonitor = SubMonitor.convert(monitor, 4);
Simantics.getSession().syncRequest(new WriteRequest() {
Set<Resource> connectionsToRemove = new HashSet<Resource>();
Set<Resource> touchedConnections = new HashSet<Resource>();
graph.markUndoPoint();
ConnectionUtil cu = new ConnectionUtil(graph);
-
+ SubMonitor edgeElementMonitor = subMonitor.split(2); // Consume 50 % of the monitor
+ edgeElementMonitor.setWorkRemaining(edges.size() + elements.size()); // set work remaining to size of edges and elements
+ edgeElementMonitor.setTaskName("Removing edges");
// Remove edges
for (IElement edge : edges) {
ConnectionEntity ce = edge.getHint(ElementHints.KEY_CONNECTION_ENTITY);
if (obj instanceof EdgeResource) {
cu.remove((EdgeResource) obj);
}
+ edgeElementMonitor.worked(1);
}
-
+ edgeElementMonitor.setTaskName("Removing elements");
// Remove elements
for (IElement element : elements) {
ConnectionHandler ch = element.getElementClass().getAtMostOneItemOfClass(ConnectionHandler.class);
}
}
}
+ edgeElementMonitor.worked(1);
}
-
+ SubMonitor connectionsMonitor = subMonitor.split(1); // Consume 50 % of the monitor
+ connectionsMonitor.setWorkRemaining(touchedConnections.size()); // set work remaining to size of edges and elements
+ connectionsMonitor.setTaskName("Pruning connectors");
// Check all touched connections to see if they are empty.
for (Resource connection : touchedConnections) {
int removedConnectors = cu.removeUnusedConnectors(connection);
if (connectors < 2) {
connectionsToRemove.add(connection);
}
+ connectionsMonitor.worked(1);
}
-
+ SubMonitor connectionsMonitor2 = subMonitor.split(1); // Consume 50 % of the monitor
+ connectionsMonitor2.setWorkRemaining(connectionsToRemove.size()); // set work remaini
+ connectionsMonitor2.setTaskName("Removing leftover connections");
// Remove selected/left-over empty connections
for (Resource connection : connectionsToRemove) {
if (DEBUG_DELETE)
System.out.println("REMOVING CONNECTION: " + connection);
RemoveElement.removeElement(graph, (Resource)d.getHint(DiagramModelHints.KEY_DIAGRAM_RESOURCE), connection);
+ connectionsMonitor2.worked(1);
}
}