提交 6e30b799 编写于 作者: S serge-rider

ER diagram create wizard redesign + menu element for entities

上级 83188be9
......@@ -2802,6 +2802,7 @@
<adapter type="org.jkiss.dbeaver.model.DBPNamedObject"/>
<adapter type="org.jkiss.dbeaver.model.DBPQualifiedObject"/>
<adapter type="org.jkiss.dbeaver.model.struct.DBSObject"/>
<adapter type="org.jkiss.dbeaver.model.struct.DBSEntity"/>
<adapter type="org.jkiss.dbeaver.model.struct.DBSDataContainer"/>
<adapter type="org.jkiss.dbeaver.model.struct.DBSDataManipulator"/>
<adapter type="org.jkiss.dbeaver.model.struct.rdb.DBSProcedure"/>
......
......@@ -22,6 +22,7 @@ package org.jkiss.dbeaver.core;
public interface CoreCommands
{
String GROUP_TOOLS = "tools";
String GROUP_TOOLS_END = "tools_end";
String GROUP_NAVIGATOR_ADDITIONS = "navigator_additions";
......
......@@ -32,10 +32,7 @@ import org.jkiss.dbeaver.model.navigator.DBNDataSource;
import org.jkiss.dbeaver.model.navigator.DBNNode;
import org.jkiss.dbeaver.model.navigator.DBNResource;
import org.jkiss.dbeaver.model.preferences.DBPPropertySource;
import org.jkiss.dbeaver.model.struct.DBSDataContainer;
import org.jkiss.dbeaver.model.struct.DBSDataManipulator;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.model.struct.DBSWrapper;
import org.jkiss.dbeaver.model.struct.*;
import org.jkiss.dbeaver.runtime.properties.PropertyCollector;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.dbeaver.ui.properties.PropertySourceDelegate;
......@@ -50,6 +47,7 @@ public class NavigatorAdapterFactory implements IAdapterFactory
DBPQualifiedObject.class,
DBPObject.class,
DBSObject.class,
DBSEntity.class,
DBSDataContainer.class,
DBSDataManipulator.class,
DBPDataSourceContainer.class,
......
......@@ -231,6 +231,7 @@ public class NavigatorUtils {
}
manager.add(new GroupMarker(CoreCommands.GROUP_TOOLS));
manager.add(new GroupMarker(CoreCommands.GROUP_TOOLS_END));
if (menuListener != null) {
menuListener.menuAboutToShow(manager);
......
......@@ -318,6 +318,19 @@
</command>
</menuContribution>
<menuContribution allPopups="false" locationURI="popup:org.eclipse.ui.popup.any?before=generate">
<command commandId="org.jkiss.dbeaver.erd.diagram.create" label="%menu.create.new.diagram">
<visibleWhen>
<with variable="selection">
<count value="(1-"/>
<iterate operator="and">
<adapt type="org.jkiss.dbeaver.model.struct.DBSEntity"/>
</iterate>
</with>
</visibleWhen>
</command>
</menuContribution>
<menuContribution allPopups="false" locationURI="popup:org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart.EditorContext?after=additions">
<command commandId="org.eclipse.ui.edit.undo"/>
<command commandId="org.eclipse.ui.edit.redo"/>
......
......@@ -52,6 +52,7 @@ public class DiagramCreateWizard extends Wizard implements INewWizard {
private EntityDiagram diagram = new EntityDiagram(null, "");
private DiagramCreateWizardPage pageContent;
private String errorMessage;
private IStructuredSelection entitySelection;
public DiagramCreateWizard() {
}
......@@ -78,6 +79,13 @@ public class DiagramCreateWizard extends Wizard implements INewWizard {
errorMessage = e.getMessage();
}
}
// Check for entity selection
if (selection != null && !selection.isEmpty()) {
if (Platform.getAdapterManager().getAdapter(selection.getFirstElement(), DBSEntity.class) != null) {
entitySelection = selection;
}
}
}
this.folder = diagramFolder;
}
......@@ -85,7 +93,7 @@ public class DiagramCreateWizard extends Wizard implements INewWizard {
@Override
public void addPages() {
super.addPages();
pageContent = new DiagramCreateWizardPage(diagram);
pageContent = new DiagramCreateWizardPage(diagram, entitySelection);
addPage(pageContent);
if (getContainer() != null) {
//WizardDialog call
......
......@@ -19,6 +19,7 @@ package org.jkiss.dbeaver.ext.erd.navigator;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.ICheckStateProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
......@@ -50,11 +51,13 @@ class DiagramCreateWizardPage extends WizardPage {
private EntityDiagram diagram;
private DatabaseNavigatorTree contentTree;
private IStructuredSelection entitySelection;
protected DiagramCreateWizardPage(EntityDiagram diagram)
protected DiagramCreateWizardPage(EntityDiagram diagram, IStructuredSelection entitySelection)
{
super(ERDMessages.wizard_page_diagram_create_name);
this.diagram = diagram;
this.entitySelection = entitySelection;
setTitle(ERDMessages.wizard_page_diagram_create_title);
setDescription(ERDMessages.wizard_page_diagram_create_description);
......@@ -63,10 +66,16 @@ class DiagramCreateWizardPage extends WizardPage {
@Override
public boolean isPageComplete()
{
boolean hasName = !CommonUtils.isEmpty(diagram.getName());
if (!hasName) {
setErrorMessage("Set diagram name");
} else {
setErrorMessage(null);
}
if (getErrorMessage() != null) {
return false;
}
return !CommonUtils.isEmpty(diagram.getName());
return hasName;
}
@Override
......@@ -122,6 +131,11 @@ class DiagramCreateWizardPage extends WizardPage {
}
});
if (entitySelection != null) {
viewer.setSelection(entitySelection, true);
viewer.setCheckedElements(entitySelection.toArray());
}
setControl(placeholder);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册