From de692aaedd66e4b9e78984216df31529fd41cd81 Mon Sep 17 00:00:00 2001 From: Andrey Hitrin Date: Thu, 6 Apr 2017 11:00:07 +0300 Subject: [PATCH] * Lock viewer placed in separate plugin org.jkiss.dbeaver.ext.ui.locks in pursuance of Serge review : Could you extract org.jkiss.dbeaver.ui.views.lock* into separate plugin? Let's say org.jkiss.dbeaver.ext.ui.locks. This will make you a plugin owner, will simplify its support and will remove gef/draw2d dependency from core module. All reference to GEF removed from core. ----------- + Also some minor fix. --- .../META-INF/MANIFEST.MF | 6 +- .../ui/views/lock/AbstractLockEditor.java | 64 ----- .../dbeaver/ui/views/lock/LockGraph.java | 76 ------ .../views/lock/LockGraphConnectionAnchor.java | 40 --- .../lock/LockGraphConnectionEditPolicy.java | 30 --- .../dbeaver/ui/views/lock/LockGraphEdge.java | 52 ---- .../ui/views/lock/LockGraphEdgeEditPart.java | 54 ---- .../ui/views/lock/LockGraphEditPart.java | 58 ----- .../views/lock/LockGraphEditPartFactory.java | 50 ---- .../ui/views/lock/LockGraphManager.java | 182 ------------- .../dbeaver/ui/views/lock/LockGraphNode.java | 122 --------- .../ui/views/lock/LockGraphNodeEditPart.java | 130 ---------- .../ui/views/lock/LockGraphNodeFigure.java | 60 ----- .../lock/LockGraphXYLayoutEditPolicy.java | 40 --- .../ui/views/lock/LockGraphicalView.java | 106 -------- .../ui/views/lock/LockManagerViewer.java | 244 ------------------ .../dbeaver/ui/views/lock/LockTable.java | 160 ------------ .../ui/views/lock/LockTableDetail.java | 133 ---------- .../META-INF/MANIFEST.MF | 2 + .../ext/oracle/editors/OracleLockEditor.java | 4 +- .../oracle/model/lock/OracleLockManager.java | 4 +- .../META-INF/MANIFEST.MF | 2 + .../postgresql/edit/PostgreLockEditor.java | 4 +- .../model/lock/PostgreLockManager.java | 4 +- 24 files changed, 14 insertions(+), 1613 deletions(-) delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/AbstractLockEditor.java delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraph.java delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphConnectionAnchor.java delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphConnectionEditPolicy.java delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphEdge.java delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphEdgeEditPart.java delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphEditPart.java delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphEditPartFactory.java delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphManager.java delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphNode.java delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphNodeEditPart.java delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphNodeFigure.java delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphXYLayoutEditPolicy.java delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphicalView.java delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockManagerViewer.java delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockTable.java delete mode 100644 plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockTableDetail.java diff --git a/plugins/org.jkiss.dbeaver.core/META-INF/MANIFEST.MF b/plugins/org.jkiss.dbeaver.core/META-INF/MANIFEST.MF index 48ff5cae20..6c880b1881 100644 --- a/plugins/org.jkiss.dbeaver.core/META-INF/MANIFEST.MF +++ b/plugins/org.jkiss.dbeaver.core/META-INF/MANIFEST.MF @@ -105,8 +105,7 @@ Export-Package: org.jkiss.dbeaver, org.jkiss.dbeaver.ui.views.plan, org.jkiss.dbeaver.ui.views.process, org.jkiss.dbeaver.ui.views.qm, - org.jkiss.dbeaver.ui.views.session, - org.jkiss.dbeaver.ui.views.lock + org.jkiss.dbeaver.ui.views.session Bundle-ClassPath: . Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.filesystem, @@ -128,7 +127,6 @@ Require-Bundle: org.eclipse.core.runtime, com.jcraft.jsch, org.objectweb.asm, org.eclipse.e4.ui.css.core, - org.eclipse.e4.ui.css.swt, - org.eclipse.gef + org.eclipse.e4.ui.css.swt Bundle-Vendor: JKISS Bundle-Localization: plugin diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/AbstractLockEditor.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/AbstractLockEditor.java deleted file mode 100644 index 83f33ee016..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/AbstractLockEditor.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ui.views.lock; - -import org.eclipse.swt.widgets.Composite; -import org.jkiss.dbeaver.model.exec.DBCExecutionContext; -import org.jkiss.dbeaver.ui.editors.IDatabaseEditorInput; -import org.jkiss.dbeaver.ui.editors.SinglePageDatabaseEditor; - -/** - * AbstractLockEditor for Lock View - */ - -public abstract class AbstractLockEditor extends SinglePageDatabaseEditor - { - - private LockManagerViewer lockViewer; - - public LockManagerViewer getLockViewer() { - return lockViewer; - } - - @Override - public void dispose() - { - if (lockViewer != null) { - lockViewer.dispose(); - } - super.dispose(); - } - - @Override - public void createPartControl(Composite parent) { - final DBCExecutionContext executionContext = getExecutionContext(); - if (executionContext != null) { - setPartName("Lock - " + executionContext.getDataSource().getContainer().getName()); - lockViewer = createLockViewer(executionContext, parent); - lockViewer.refreshLocks(null); - } - } - - protected abstract LockManagerViewer createLockViewer(DBCExecutionContext executionContext, Composite parent); - - @Override - public void refreshPart(Object source, boolean force) - { - lockViewer.refreshLocks(null); - } - - } diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraph.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraph.java deleted file mode 100644 index 5dce85f6e3..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraph.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ui.views.lock; - -import java.util.ArrayList; -import java.util.List; -import org.jkiss.dbeaver.model.admin.locks.DBAServerLock; - - -public class LockGraph { - - private List nodes = new ArrayList(); - - private int maxWidth = 0; - - private LockGraphNode selection; - - private LockManagerViewer lockManagerViewer; - - private final DBAServerLock lockRoot; - - public DBAServerLock getLockRoot() { - return lockRoot; - } - - public LockManagerViewer getLockManagerViewer() { - return lockManagerViewer; - } - - public void setLockManagerViewer(LockManagerViewer lockManagerViewer) { - this.lockManagerViewer = lockManagerViewer; - } - - public LockGraph(DBAServerLock lockRoot) { - this.selection = null; - this.lockRoot = lockRoot; - } - - public LockGraphNode getSelection() { - return selection; - } - - - public void setSelection(LockGraphNode selection) { - this.selection = selection; - } - - - public List getNodes() { - return this.nodes; - } - - - public int getMaxWidth() { - return maxWidth; - } - - - public void setMaxWidth(int maxWidth) { - this.maxWidth = maxWidth; - } -} diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphConnectionAnchor.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphConnectionAnchor.java deleted file mode 100644 index 952dc2eb07..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphConnectionAnchor.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ui.views.lock; - -import org.eclipse.draw2d.AbstractConnectionAnchor; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Point; - -public class LockGraphConnectionAnchor extends AbstractConnectionAnchor { - - public LockGraphConnectionAnchor(IFigure owner) { - super(owner); - } - - public Point getLocation(Point reference) { - Point point = getOwner().getBounds().getCenter(); - getOwner().translateToAbsolute(point); - if (reference.x < point.x) - point = getOwner().getBounds().getTop(); - else - point = getOwner().getBounds().getBottom(); - getOwner().translateToAbsolute(point); - return point; - } - -} diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphConnectionEditPolicy.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphConnectionEditPolicy.java deleted file mode 100644 index 0b85e24092..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphConnectionEditPolicy.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ui.views.lock; - -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.ConnectionEditPolicy; -import org.eclipse.gef.requests.GroupRequest; - -public class LockGraphConnectionEditPolicy extends ConnectionEditPolicy { - - @Override - protected Command getDeleteCommand(GroupRequest request) { - return null; - } - -} diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphEdge.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphEdge.java deleted file mode 100644 index 287615f886..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphEdge.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ui.views.lock; - -public class LockGraphEdge { - - private LockGraphNode source; - - private LockGraphNode target; - - public LockGraphNode getSource() { - return this.source; - } - - public LockGraphNode getTarget() { - return this.target; - } - - public void setSource(LockGraphNode newSource) { - if (this.source != null) { - this.source.removeSourceEdge(this); - } - this.source = newSource; - if (this.source != null) { - this.source.addSourceEdge(this); - } - } - - public void setTarget(LockGraphNode newTarget) { - if (this.target != null) { - this.target.removeTargetEdge(this); - } - this.target = newTarget; - if (this.target != null) { - this.target.addTargetEdge(this); - } - } -} diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphEdgeEditPart.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphEdgeEditPart.java deleted file mode 100644 index 2dc315c96b..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphEdgeEditPart.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ui.views.lock; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.PolygonDecoration; -import org.eclipse.draw2d.PolylineConnection; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.editparts.AbstractConnectionEditPart; -import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy; - -public class LockGraphEdgeEditPart extends AbstractConnectionEditPart { - - @Override - protected void createEditPolicies() { - installEditPolicy(EditPolicy.CONNECTION_ROLE, - new LockGraphConnectionEditPolicy()); - installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, - new ConnectionEndpointEditPolicy()); - } - - @Override - protected IFigure createFigure() { - - PolylineConnection connection = (PolylineConnection) super.createFigure(); - - connection.setLineWidth(1); - - PolygonDecoration decoration = new PolygonDecoration(); - - decoration.setTemplate(PolygonDecoration.TRIANGLE_TIP); - connection.setSourceDecoration(decoration); - - - return connection; - - - } - -} diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphEditPart.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphEditPart.java deleted file mode 100644 index 6127a0577f..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphEditPart.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ui.views.lock; - -import java.util.List; - -import org.eclipse.draw2d.ConnectionLayer; -import org.eclipse.draw2d.FreeformLayer; -import org.eclipse.draw2d.GridLayout; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.ShortestPathConnectionRouter; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.LayerConstants; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; - -public class LockGraphEditPart extends AbstractGraphicalEditPart { - - @Override - protected void createEditPolicies() { - installEditPolicy(EditPolicy.LAYOUT_ROLE, - new LockGraphXYLayoutEditPolicy()); - } - - @Override - protected IFigure createFigure() { - FreeformLayer freeformLayer = new FreeformLayer(); - freeformLayer.setLayoutManager(new GridLayout(((LockGraph) getModel()).getMaxWidth(), true)); - return freeformLayer; - } - - @Override - protected List getModelChildren() { - List nodes = ((LockGraph) getModel()).getNodes(); - return nodes; - } - - @Override - protected void refreshVisuals() { - ConnectionLayer connectionLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER); - connectionLayer.setConnectionRouter(new ShortestPathConnectionRouter(getFigure())); - } - - -} diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphEditPartFactory.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphEditPartFactory.java deleted file mode 100644 index 8241ffe595..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphEditPartFactory.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ui.views.lock; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartFactory; - - -public class LockGraphEditPartFactory implements EditPartFactory { - - public EditPart createEditPart(EditPart context, Object model) { - - EditPart editPart = null; - - if (model instanceof LockGraph) { - - editPart = new LockGraphEditPart(); - - } else if (model instanceof LockGraphEdge) { - - editPart = new LockGraphEdgeEditPart(); - - } else if (model instanceof LockGraphNode) { - - editPart = new LockGraphNodeEditPart(); - - } - - if (editPart != null) { - - editPart.setModel(model); - } - - return editPart; - } -} diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphManager.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphManager.java deleted file mode 100644 index 510ea16a70..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphManager.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ui.views.lock; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.jkiss.dbeaver.model.admin.locks.DBAServerLock; - - - -public abstract class LockGraphManager, ID_TYPE> { - - private Map nodes = new HashMap(); - - private Map graphIndex = new HashMap(); - - - public LockGraph getGraph(DBAServerLock curLock) { - - LockGraphNode selection = nodes.get(curLock.getId()); - - LockGraph graph = graphIndex.get(curLock.getId()); - - if (graph != null && selection != null) { - graph.setSelection(selection); - } - - return graph; - - } - - @SuppressWarnings("unchecked") - private LockGraph createGraph(LOCK_TYPE root) { - - - LockGraph graph = new LockGraph(root); - - int maxWidth = 1; - - int level = 1; - - LockGraphNode nodeRoot = nodes.get(root.getId()); - - nodeRoot.setLevel(0); - - nodeRoot.setSpan(1); - - graph.getNodes().add(nodeRoot); - - graphIndex.put((ID_TYPE) root.getId(), graph); - - List current = new ArrayList(); - - Set> touched = new HashSet<>(); //Prevent Cycle - - current.add(root); - - touched.add((DBAServerLock) root); - - Map> childs = new HashMap>(); - - while(current.size() > 0) { - - if (maxWidth < current.size()) { - - maxWidth = current.size(); - - } - - for(int index = 0; index < current.size(); index++) { - - DBAServerLock l = (DBAServerLock) current.get(index); - - LockGraphNode node = nodes.get(l.getId()); - - if (index == 0) { - node.setLevelPosition(LockGraphNode.LevelPosition.LEFT); - } else if (index == current.size() - 1) { - node.setLevelPosition(LockGraphNode.LevelPosition.RIGHT); - } else { - node.setLevelPosition(LockGraphNode.LevelPosition.CENTER); - } - - node.setSpan(current.size()); - - - for(DBAServerLock c : l.waitThis()) { - - if (touched.contains(c)) continue; - - touched.add(c); - - childs.put(c.getId(), c); - - graphIndex.put(c.getId(), graph); - - LockGraphNode nodeChild = nodes.get(c.getId()); - - graph.getNodes().add(nodeChild); - - nodeChild.setLevel(level); - - LockGraphEdge edge = new LockGraphEdge(); - edge.setSource(node); - edge.setTarget(nodeChild); - - } - - - } - - level++; - - current = new ArrayList((Collection) childs.values()); - - childs.clear(); - - - } - - graph.setMaxWidth(maxWidth); - - return graph; - - } - - - - public void buildGraphs(Map locks) { - - Set roots = new HashSet(); - - this.nodes.clear(); - - this.graphIndex.clear(); - - for(LOCK_TYPE l: locks.values()) { - - if (locks.containsKey(l.getHoldID()) && (!l.getHoldID().equals(l.getId()))) { - - LOCK_TYPE holder = locks.get(l.getHoldID()); - l.setHoldBy(holder); - holder.waitThis().add((DBAServerLock) l); - - } else { - - roots.add(l); - - } - - nodes.put((ID_TYPE) l.getId(), new LockGraphNode(l)); - } - - for(LOCK_TYPE root : roots) { - - if (root.waitThis().size() >= 0) - createGraph(root); - } - - } - -} diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphNode.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphNode.java deleted file mode 100644 index 98fe8f2c8c..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphNode.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ui.views.lock; - -import java.util.ArrayList; -import java.util.List; - -import org.jkiss.dbeaver.model.admin.locks.DBAServerLock; - - -public class LockGraphNode { - - private int level; - - private int span; - - private String title; - - private DBAServerLock lock; - - public enum LevelPosition { LEFT, CENTER, RIGHT}; - - private LevelPosition levelPosition; - - public LevelPosition getLevelPosition() { - return levelPosition; - } - - public void setLevelPosition(LevelPosition levelPosition) { - this.levelPosition = levelPosition; - } - - public int getLevel() { - return this.level; - } - - private List sourceEdges; - - private List targetEdges; - - public LockGraphNode(DBAServerLock lock){ - - this.lock = lock; - this.level = 0; - this.span = 0; - this.title = lock.getTitle(); - this.sourceEdges = new ArrayList(); - this.targetEdges = new ArrayList(); - - this.levelPosition = LevelPosition.CENTER; - - } - - public LockGraphNode(String title,int level,int span) { - this.level = level; - this.span = span; - this.title = title; - this.sourceEdges = new ArrayList(); - this.targetEdges = new ArrayList(); - } - - public void addSourceEdge(LockGraphEdge sourceEdge) { - this.sourceEdges.add(sourceEdge); - } - - public void addTargetEdge(LockGraphEdge targetEdge) { - this.targetEdges.add(targetEdge); - } - - public List getSourceEdges() { - return this.sourceEdges; - } - - public List getTargetEdges() { - return this.targetEdges; - } - - public void removeSourceEdge(LockGraphEdge sourceEdge) { - this.sourceEdges.remove(sourceEdge); - } - - public void removeTargetEdge(LockGraphEdge targetEdge) { - this.targetEdges.remove(targetEdge); - } - - public int getSpan() { - return span; - } - - public String getTitle() { - return title; - } - - public void setLevel(int level) { - this.level = level; - } - - public void setSpan(int span) { - this.span = span; - } - - public DBAServerLock getLock() { - return lock; - } - - -} - diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphNodeEditPart.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphNodeEditPart.java deleted file mode 100644 index c7fec398af..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphNodeEditPart.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ui.views.lock; - -import java.util.List; - -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.GridData; -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.ConnectionEditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.gef.editpolicies.NonResizableEditPolicy; - -public class LockGraphNodeEditPart extends AbstractGraphicalEditPart { - - private LockGraphConnectionAnchor sourceAnchor; - - private LockGraphConnectionAnchor targetAnchor; - - @Override - public boolean isSelectable() { - return true; - } - - @Override - protected IFigure createFigure() { - LockGraphNode node = (LockGraphNode) getModel(); - LockGraph graph = (LockGraph)((LockGraphEditPart) getParent()).getModel(); - LockGraphNodeFigure nodeFigure = new LockGraphNodeFigure(node.getTitle(),(node == graph.getSelection())); - this.targetAnchor = new LockGraphConnectionAnchor(nodeFigure); - this.sourceAnchor = new LockGraphConnectionAnchor(nodeFigure); - return nodeFigure; - } - - @Override - protected List getModelSourceConnections() { - return ((LockGraphNode) getModel()).getSourceEdges(); - } - - @Override - protected List getModelTargetConnections() { - return ((LockGraphNode) getModel()).getTargetEdges(); - } - - public ConnectionAnchor getSourceConnectionAnchor( - ConnectionEditPart connection) { - return this.sourceAnchor; - } - - public ConnectionAnchor getSourceConnectionAnchor(Request request) { - return this.sourceAnchor; - } - - public ConnectionAnchor getTargetConnectionAnchor( - ConnectionEditPart connection) { - return this.targetAnchor; - } - - public ConnectionAnchor getTargetConnectionAnchor(Request request) { - return this.targetAnchor; - } - - @Override - protected void refreshVisuals() { - LockGraphNode node = (LockGraphNode) getModel(); - LockGraph lgraph = (LockGraph)((LockGraphEditPart) getParent()).getModel(); - LockGraphNodeFigure nodeFigure = (LockGraphNodeFigure) getFigure(); - LockGraphEditPart graph = (LockGraphEditPart) getParent(); - GridData gridData = new GridData(55,30); - gridData.horizontalAlignment = GridData.CENTER; - gridData.verticalAlignment = GridData.CENTER; - gridData.verticalSpan = 10; - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - int span = lgraph.getMaxWidth() / node.getSpan(); - int spanMod = lgraph.getMaxWidth() % node.getSpan(); - gridData.horizontalSpan = 0 ; - if (span > 1 && node.getLevelPosition() != LockGraphNode.LevelPosition.RIGHT) { - gridData.horizontalSpan = span; - } else if (spanMod > 0 && node.getLevelPosition() == LockGraphNode.LevelPosition.RIGHT) { - gridData.horizontalSpan = span + spanMod; - } - graph.setLayoutConstraint(this, nodeFigure,gridData); - } - - @Override - protected void createEditPolicies() { - SelectionPolicy selectionPolicy = new SelectionPolicy(); - selectionPolicy.setDragAllowed(false); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionPolicy); - } - - - -} - -class SelectionPolicy extends NonResizableEditPolicy { - - @Override - protected void hideSelection() { - } - - @Override - protected void showSelection() { - - LockManagerViewer viewer = ((LockGraph)getHost().getParent().getModel()).getLockManagerViewer(); - - if (viewer != null) { - viewer.setTableLockSelect(((LockGraphNode)getHost().getModel()).getLock()); - } - - } -} - diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphNodeFigure.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphNodeFigure.java deleted file mode 100644 index fadc820534..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphNodeFigure.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ui.views.lock; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.XYLayout; -import org.eclipse.draw2d.geometry.Rectangle; - - -public class LockGraphNodeFigure extends Figure { - - private Label label; - - private RectangleFigure rectangleFigure; - - public LockGraphNodeFigure(String title,boolean selected) { - setLayoutManager(new XYLayout()); - this.rectangleFigure = new RectangleFigure(); - this.rectangleFigure.setBackgroundColor(selected ? ColorConstants.orange : ColorConstants.lightGray); - add(this.rectangleFigure); - this.label = new Label(); - this.label.setText(title); //$NON-NLS-1$ - add(this.label); - } - - public Label getLabel() { - return this.label; - } - - public RectangleFigure getRectangleFigure() { - return this.rectangleFigure; - } - - @Override - public void paintFigure(Graphics g) { - Rectangle r = getBounds().getCopy(); - setConstraint(getRectangleFigure(), new Rectangle(0, 0, r.width,r.height)); - setConstraint(getLabel(), new Rectangle(0, 0, r.width, r.height)); - getRectangleFigure().invalidate(); - getLabel().invalidate(); - } -} \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphXYLayoutEditPolicy.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphXYLayoutEditPolicy.java deleted file mode 100644 index 645314b1a5..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphXYLayoutEditPolicy.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ui.views.lock; - - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.XYLayoutEditPolicy; -import org.eclipse.gef.requests.CreateRequest; - -public class LockGraphXYLayoutEditPolicy extends XYLayoutEditPolicy { - - @Override - protected Command createChangeConstraintCommand(EditPart child, - Object constraint) { - return null; - } - - @Override - protected Command getCreateCommand(CreateRequest request) { - return null; - } - - - -} diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphicalView.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphicalView.java deleted file mode 100644 index f84ac56eae..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockGraphicalView.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ui.views.lock; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.gef.ContextMenuProvider; -import org.eclipse.gef.DefaultEditDomain; -import org.eclipse.gef.GraphicalViewer; -import org.eclipse.gef.editparts.FreeformGraphicalRootEditPart; -import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.part.ViewPart; -import org.jkiss.dbeaver.model.admin.locks.DBAServerLock; - -public class LockGraphicalView extends ViewPart { - - private static final LockGraph EMPTY_GRAPH = new LockGraph(null); - - private DefaultEditDomain editDomain; - - private GraphicalViewer graphicalViewer; - - - private final LockGraphManager graphManager; - - private final LockManagerViewer viewer; - - public LockGraphicalView(LockManagerViewer viewer) { - super(); - this.viewer = viewer; - this.graphManager = viewer.getGraphManager(); - } - - @Override - public void createPartControl(Composite parent) { - setEditDomain(new DefaultEditDomain(null)); - setGraphicalViewer(new ScrollingGraphicalViewer()); - getGraphicalViewer().createControl(parent); - getGraphicalViewer().setRootEditPart(new FreeformGraphicalRootEditPart()); - getGraphicalViewer().setEditPartFactory(new LockGraphEditPartFactory()); - getGraphicalViewer().setContextMenu(new ContextMenuProvider(graphicalViewer){ - - @Override - public void buildContextMenu(IMenuManager menu) { - - menu.add(viewer.getKillAction()); - - } - - }); - } - - public void drawGraf(DBAServerLock selection) - { - if (selection == null) return; - - LockGraph g = selection == null ? EMPTY_GRAPH : graphManager.getGraph(selection); - - if (g == null) return; - - if (g != EMPTY_GRAPH) { - g.setLockManagerViewer(viewer); - } - - getGraphicalViewer().setContents(g); - getGraphicalViewer().getControl().setBackground(ColorConstants.listBackground); - } - - protected DefaultEditDomain getEditDomain() { - return this.editDomain; - } - - protected GraphicalViewer getGraphicalViewer() { - return this.graphicalViewer; - } - - protected void setEditDomain(DefaultEditDomain anEditDomain) { - this.editDomain = anEditDomain; - } - - @Override - public void setFocus() { - getGraphicalViewer().getControl().setFocus(); - } - - protected void setGraphicalViewer(GraphicalViewer viewer) { - getEditDomain().addViewer(viewer); - this.graphicalViewer = viewer; - } - -} diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockManagerViewer.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockManagerViewer.java deleted file mode 100644 index 34f06f1c10..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockManagerViewer.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ui.views.lock; - -import java.util.Map; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IContributionManager; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchSite; -import org.jkiss.dbeaver.model.admin.locks.DBAServerLock; -import org.jkiss.dbeaver.model.admin.locks.DBAServerLockItem; -import org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager; -import org.jkiss.dbeaver.ui.DBeaverIcons; -import org.jkiss.dbeaver.ui.UIIcon; -import org.jkiss.dbeaver.ui.UIUtils; - -/** - * LockManagerViewer - */ -public class LockManagerViewer -{ - - public static final String keyType = "type"; - public static final String typeWait = "wait"; - public static final String typeHold = "hold"; - - private Font boldFont; - private LockListControl lockTable; - private LockTableDetail blockedTable; - private LockTableDetail blockingTable; - private Label blockedLabel; - private Label blockingLabel; - private SashForm sashMain; - private DBAServerLock curLock; - private LockGraphManager graphManager; - private LockGraphicalView gv; - private final DBAServerLockManager,DBAServerLockItem> lockManager; - - private Action killAction = new Action("Kill waiting session", UIUtils.getShardImageDescriptor(ISharedImages.IMG_ELCL_STOP)) { - @Override - public void run() - { - DBAServerLock root = graphManager.getGraph((DBAServerLock)curLock).getLockRoot(); - alterSession(); - refreshLocks(root); - setTableLockSelect(root); - } - }; - - - - public LockGraphManager getGraphManager() { - return graphManager; - } - public void dispose() - { - lockTable.disposeControl(); - UIUtils.dispose(boldFont); - } - public LockManagerViewer(IWorkbenchPart part, Composite parent, final DBAServerLockManager,DBAServerLockItem> lockManager) { - - - this.graphManager = (LockGraphManager) lockManager; - - boldFont = UIUtils.makeBoldFont(parent.getFont()); - Composite composite = UIUtils.createPlaceholder(parent, 1); - - sashMain = UIUtils.createPartDivider(part, composite, SWT.HORIZONTAL | SWT.SMOOTH); - sashMain.setLayoutData(new GridData(GridData.FILL_BOTH)); - - SashForm sash = UIUtils.createPartDivider(part, sashMain, SWT.VERTICAL | SWT.SMOOTH); - sash.setLayoutData(new GridData(GridData.FILL_BOTH)); - - this.lockManager = lockManager; - lockTable = new LockListControl(sash, part.getSite(), lockManager); - lockTable.createProgressPanel(composite); - - lockTable.getItemsViewer().addSelectionChangedListener(new ISelectionChangedListener() { - @Override - public void selectionChanged(SelectionChangedEvent event) - { - onLockSelect(getSelectedLock()); - } - }); - - lockTable.loadData(); - - - SashForm infoSash = UIUtils.createPartDivider(part, sash, SWT.HORIZONTAL | SWT.SMOOTH); - infoSash.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite cBlocked = new Composite(infoSash,SWT.DOUBLE_BUFFERED); - cBlocked.setLayout(new GridLayout(1,true)); - - blockedLabel = new Label(cBlocked, SWT.NULL); - blockedLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - blockedLabel.setFont(boldFont); - - blockedTable = new LockTableDetail(cBlocked, SWT.SHEET, part.getSite(), lockManager); - blockedTable.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite cBlocking = new Composite(infoSash,SWT.DOUBLE_BUFFERED); - cBlocking.setLayout(new GridLayout(1,true)); - - blockingLabel = new Label(cBlocking, SWT.NULL); - blockingLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - blockingLabel.setFont(boldFont); - - blockingTable = new LockTableDetail(cBlocking, SWT.SHEET, part.getSite(), lockManager); - blockingTable.setLayoutData(new GridData(GridData.FILL_BOTH)); - - gv = new LockGraphicalView(this); - gv.createPartControl(sashMain); - - sashMain.setWeights(new int[] { 3, 1}); - sash.setWeights(new int[] { 4, 1}); - - } - - protected void onLockSelect(DBAServerLock lock) - { - curLock = lock; - refreshGraph(curLock); - } - - public void setTableLockSelect(DBAServerLock lock) { - lockTable.getItemsViewer().setSelection(new StructuredSelection(lock),true); - curLock = lock; - } - - protected void contributeToToolbar(DBAServerLockManager,DBAServerLockItem> sessionManager, IContributionManager contributionManager) - { - - } - - public Action getKillAction() { - return killAction; - } - public DBAServerLock getSelectedLock() - { - ISelection selection = lockTable.getSelectionProvider().getSelection(); - if (selection instanceof IStructuredSelection && !selection.isEmpty()) { - return (DBAServerLock)((IStructuredSelection) selection).getFirstElement(); - } else { - return null; - } - } - - - - private void refreshGraph(DBAServerLock selected){ - gv.drawGraf(selected); - } - - - public void refreshLocks(DBAServerLock selected) - { - lockTable.loadData(false); - gv.drawGraf(selected); - - } - - public void refreshDetail(Map options) - { - StringBuilder sb = new StringBuilder("Wait - "); - sb.append(curLock.getTitle()); - blockedLabel.setText(sb.toString()); - blockedTable.getOptions().putAll(options); - blockedTable.getOptions().put(keyType, typeWait); - blockedTable.loadData(false); - sb.setLength(0); - if (curLock.getHoldBy() != null) { - sb.append("Hold - "); - sb.append(curLock.getHoldBy().getTitle()); - blockingLabel.setText(sb.toString()); - } - blockingTable.getOptions().putAll(options); - blockingTable.getOptions().put(keyType, typeHold); - blockingTable.loadData(); - - } - - public void alterSession() { - if (UIUtils.confirmAction( - "Terminate", - NLS.bind("Teminate session?", "Terminate"))) { - - lockTable.createAlterService(curLock,null).schedule(); - } - } - - private class LockListControl extends LockTable { - - public LockListControl(SashForm sash, IWorkbenchSite site, DBAServerLockManager,DBAServerLockItem> lockManager) - { - super(sash, SWT.SHEET, site, lockManager); - } - - - @Override - protected void fillCustomActions(IContributionManager contributionManager) { - contributeToToolbar(getLockManager(), contributionManager); - contributionManager.add(new Action("Refresh locks", DBeaverIcons.getImageDescriptor(UIIcon.REFRESH)) { - @Override - public void run() - { - refreshLocks(curLock); - } - }); - contributionManager.add(killAction); - } - - } - -} \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockTable.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockTable.java deleted file mode 100644 index ba5ec9dee3..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockTable.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * Copyright (C) 2010-2016 Serge Rieder (serge@jkiss.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License (version 2) - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -package org.jkiss.dbeaver.ui.views.lock; - -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbenchSite; -import org.jkiss.code.NotNull; -import org.jkiss.dbeaver.model.admin.locks.DBAServerLock; -import org.jkiss.dbeaver.model.admin.locks.DBAServerLockItem; -import org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager; -import org.jkiss.dbeaver.model.exec.DBCExecutionContext; -import org.jkiss.dbeaver.model.exec.DBCExecutionPurpose; -import org.jkiss.dbeaver.model.exec.DBCSession; -import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; -import org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService; -import org.jkiss.dbeaver.ui.LoadingJob; -import org.jkiss.dbeaver.ui.controls.itemlist.DatabaseObjectListControl; - -import java.lang.reflect.InvocationTargetException; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * Session table - */ -public class LockTable extends DatabaseObjectListControl> { - - private DBAServerLockManager,DBAServerLockItem> lockManager; - - public LockTable(Composite parent, int style, IWorkbenchSite site, DBAServerLockManager,DBAServerLockItem> lockManager) - { - super(parent, style, site, CONTENT_PROVIDER); - this.lockManager = lockManager; - } - - public DBAServerLockManager,DBAServerLockItem> getLockManager() { - return lockManager; - } - - @NotNull - @Override - protected String getListConfigId(List> classList) { - return "Locks/" + lockManager.getDataSource().getContainer().getDriver().getId(); - } - - @Override - protected LoadingJob>> createLoadService() - { - return LoadingJob.createService( - new LoadLocksService(), - new ObjectsLoadVisualizer()); - } - - protected LoadingJob createAlterService(DBAServerLock lock, Map options) - { - return LoadingJob.createService( - new KillSessionByLockService(lock, options), - new ObjectActionVisualizer()); - } - - public void init(DBAServerLockManager,DBAServerLockItem> lockManager) - { - this.lockManager = lockManager; - } - - private static IStructuredContentProvider CONTENT_PROVIDER = new IStructuredContentProvider() { - @Override - public Object[] getElements(Object inputElement) - { - if (inputElement instanceof Collection) { - return ((Collection)inputElement).toArray(); - } - return null; - } - - @Override - public void dispose() - { - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - } - - }; - - private class LoadLocksService extends DatabaseLoadService>> { - - protected LoadLocksService() - { - super("Load locks", lockManager.getDataSource()); - } - - @Override - public Collection> evaluate(DBRProgressMonitor monitor) - throws InvocationTargetException, InterruptedException - { - try { - try (DBCExecutionContext isolatedContext = lockManager.getDataSource().openIsolatedContext(monitor, "View Locks")) { - try (DBCSession session = isolatedContext.openSession(monitor, DBCExecutionPurpose.UTIL, "Retrieve server locks")) { - return lockManager.getLocks(session, null).values(); - } - } - } catch (Throwable ex) { - throw new InvocationTargetException(ex); - } - } - } - - private class KillSessionByLockService extends DatabaseLoadService { - private final DBAServerLock lock; - private final Map options; - - - protected KillSessionByLockService(DBAServerLock lock, Map options) - { - super("Kill session by lock", lockManager.getDataSource()); - this.lock = lock; - this.options = options; - } - - @Override - public Void evaluate(DBRProgressMonitor monitor) - throws InvocationTargetException, InterruptedException - { - try { - try (DBCExecutionContext isolatedContext = lockManager.getDataSource().openIsolatedContext(monitor, "View locks")) { - try (DBCSession session = isolatedContext.openSession(monitor, DBCExecutionPurpose.UTIL, "Kill server session by lock")) { - lockManager.alterSession(session, this.lock, options); - return null; - } - } - } catch (Throwable ex) { - throw new InvocationTargetException(ex); - } - } - - } - -} diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockTableDetail.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockTableDetail.java deleted file mode 100644 index c912de10c9..0000000000 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/views/lock/LockTableDetail.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com) - * Copyright (C) 2010-2016 Serge Rieder (serge@jkiss.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License (version 2) - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -package org.jkiss.dbeaver.ui.views.lock; - -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbenchSite; -import org.jkiss.code.NotNull; -import org.jkiss.dbeaver.model.admin.locks.DBAServerLock; -import org.jkiss.dbeaver.model.admin.locks.DBAServerLockItem; -import org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager; -import org.jkiss.dbeaver.model.exec.DBCExecutionContext; -import org.jkiss.dbeaver.model.exec.DBCExecutionPurpose; -import org.jkiss.dbeaver.model.exec.DBCSession; -import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; -import org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService; -import org.jkiss.dbeaver.ui.LoadingJob; -import org.jkiss.dbeaver.ui.controls.itemlist.DatabaseObjectListControl; - -import java.lang.reflect.InvocationTargetException; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Lock detail table - */ -public class LockTableDetail extends DatabaseObjectListControl { - - private DBAServerLockManager,DBAServerLockItem> lockManager; - Map options = new HashMap(1); - - public Map getOptions() { - return options; - } - - public LockTableDetail(Composite parent, int style, IWorkbenchSite site, DBAServerLockManager,DBAServerLockItem> lockManager) - { - super(parent, style, site, CONTENT_PROVIDER); - this.lockManager = lockManager; - } - - public DBAServerLockManager,DBAServerLockItem> getLockManager() { - return lockManager; - } - - @NotNull - @Override - protected String getListConfigId(List> classList) { - return "LocksDetail/" + lockManager.getDataSource().getContainer().getDriver().getId(); - } - - @Override - protected LoadingJob> createLoadService() - { - return LoadingJob.createService( - new LoadLockDetailService(), - new ObjectsLoadVisualizer()); - } - - public void init(DBAServerLockManager,DBAServerLockItem> lockManager) - { - this.lockManager = lockManager; - } - - private static IStructuredContentProvider CONTENT_PROVIDER = new IStructuredContentProvider() { - @Override - public Object[] getElements(Object inputElement) - { - if (inputElement instanceof Collection) { - return ((Collection)inputElement).toArray(); - } - return null; - } - - @Override - public void dispose() - { - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - } - - }; - - - private class LoadLockDetailService extends DatabaseLoadService> { - - protected LoadLockDetailService() - { - super(String.format("Load lock details"), lockManager.getDataSource()); - } - - @Override - public Collection evaluate(DBRProgressMonitor monitor) - throws InvocationTargetException, InterruptedException - { - try { - try (DBCExecutionContext isolatedContext = lockManager.getDataSource().openIsolatedContext(monitor, "View Lock item")) { - try (DBCSession session = isolatedContext.openSession(monitor, DBCExecutionPurpose.UTIL, "Retrieve server lock detail")) { - return lockManager.getLockItems(session, options); - } - } - } catch (Throwable ex) { - throw new InvocationTargetException(ex); - } - } - } - - -} - - diff --git a/plugins/org.jkiss.dbeaver.ext.oracle/META-INF/MANIFEST.MF b/plugins/org.jkiss.dbeaver.ext.oracle/META-INF/MANIFEST.MF index 3d38ff3cee..bc301cf66e 100644 --- a/plugins/org.jkiss.dbeaver.ext.oracle/META-INF/MANIFEST.MF +++ b/plugins/org.jkiss.dbeaver.ext.oracle/META-INF/MANIFEST.MF @@ -21,3 +21,5 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-Vendor: JKISS Bundle-ClassPath: . Bundle-Localization: plugin +Import-Package: org.jkiss.dbeaver.ext.ui.locks.edit, + org.jkiss.dbeaver.ext.ui.locks.manage diff --git a/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/editors/OracleLockEditor.java b/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/editors/OracleLockEditor.java index ac67bad66e..971bd85651 100644 --- a/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/editors/OracleLockEditor.java +++ b/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/editors/OracleLockEditor.java @@ -24,12 +24,12 @@ import org.eclipse.swt.widgets.Composite; import org.jkiss.dbeaver.ext.oracle.model.OracleDataSource; import org.jkiss.dbeaver.ext.oracle.model.lock.OracleLock; import org.jkiss.dbeaver.ext.oracle.model.lock.OracleLockManager; +import org.jkiss.dbeaver.ext.ui.locks.edit.AbstractLockEditor; +import org.jkiss.dbeaver.ext.ui.locks.manage.LockManagerViewer; import org.jkiss.dbeaver.model.admin.locks.DBAServerLock; import org.jkiss.dbeaver.model.admin.locks.DBAServerLockItem; import org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager; import org.jkiss.dbeaver.model.exec.DBCExecutionContext; -import org.jkiss.dbeaver.ui.views.lock.AbstractLockEditor; -import org.jkiss.dbeaver.ui.views.lock.LockManagerViewer; public class OracleLockEditor extends AbstractLockEditor{ diff --git a/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/model/lock/OracleLockManager.java b/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/model/lock/OracleLockManager.java index 89292dd8e1..efe7db7955 100644 --- a/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/model/lock/OracleLockManager.java +++ b/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/model/lock/OracleLockManager.java @@ -26,14 +26,14 @@ import java.util.Map; import org.jkiss.dbeaver.DBException; import org.jkiss.dbeaver.ext.oracle.editors.OracleLockEditor; import org.jkiss.dbeaver.ext.oracle.model.OracleDataSource; +import org.jkiss.dbeaver.ext.ui.locks.manage.LockGraphManager; +import org.jkiss.dbeaver.ext.ui.locks.manage.LockManagerViewer; import org.jkiss.dbeaver.model.DBPDataSource; import org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager; import org.jkiss.dbeaver.model.exec.DBCSession; import org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement; import org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet; import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession; -import org.jkiss.dbeaver.ui.views.lock.LockGraphManager; -import org.jkiss.dbeaver.ui.views.lock.LockManagerViewer; public class OracleLockManager extends LockGraphManager implements DBAServerLockManager{ diff --git a/plugins/org.jkiss.dbeaver.ext.postgresql/META-INF/MANIFEST.MF b/plugins/org.jkiss.dbeaver.ext.postgresql/META-INF/MANIFEST.MF index 006b422837..1b42626631 100644 --- a/plugins/org.jkiss.dbeaver.ext.postgresql/META-INF/MANIFEST.MF +++ b/plugins/org.jkiss.dbeaver.ext.postgresql/META-INF/MANIFEST.MF @@ -21,3 +21,5 @@ Bundle-Vendor: JKISS Bundle-ClassPath: . Bundle-Localization: plugin Bundle-Activator: org.jkiss.dbeaver.ext.postgresql.PostgreActivator +Import-Package: org.jkiss.dbeaver.ext.ui.locks.edit, + org.jkiss.dbeaver.ext.ui.locks.manage diff --git a/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreLockEditor.java b/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreLockEditor.java index f0bb4708b4..2e11251810 100644 --- a/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreLockEditor.java +++ b/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreLockEditor.java @@ -25,12 +25,12 @@ import org.eclipse.swt.widgets.Composite; import org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource; import org.jkiss.dbeaver.ext.postgresql.model.lock.PostgreLock; import org.jkiss.dbeaver.ext.postgresql.model.lock.PostgreLockManager; +import org.jkiss.dbeaver.ext.ui.locks.edit.AbstractLockEditor; +import org.jkiss.dbeaver.ext.ui.locks.manage.LockManagerViewer; import org.jkiss.dbeaver.model.admin.locks.DBAServerLock; import org.jkiss.dbeaver.model.admin.locks.DBAServerLockItem; import org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager; import org.jkiss.dbeaver.model.exec.DBCExecutionContext; -import org.jkiss.dbeaver.ui.views.lock.AbstractLockEditor; -import org.jkiss.dbeaver.ui.views.lock.LockManagerViewer; public class PostgreLockEditor extends AbstractLockEditor{ diff --git a/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/lock/PostgreLockManager.java b/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/lock/PostgreLockManager.java index 5044f688cf..bddcf06595 100644 --- a/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/lock/PostgreLockManager.java +++ b/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/lock/PostgreLockManager.java @@ -19,14 +19,14 @@ package org.jkiss.dbeaver.ext.postgresql.model.lock; import org.jkiss.dbeaver.DBException; import org.jkiss.dbeaver.ext.postgresql.edit.PostgreLockEditor; import org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource; +import org.jkiss.dbeaver.ext.ui.locks.manage.LockGraphManager; +import org.jkiss.dbeaver.ext.ui.locks.manage.LockManagerViewer; import org.jkiss.dbeaver.model.DBPDataSource; import org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager; import org.jkiss.dbeaver.model.exec.DBCSession; import org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement; import org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet; import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession; -import org.jkiss.dbeaver.ui.views.lock.LockGraphManager; -import org.jkiss.dbeaver.ui.views.lock.LockManagerViewer; import java.sql.SQLException; import java.util.ArrayList; -- GitLab