Search in sources :

Example 11 with EntityPart

use of org.jkiss.dbeaver.erd.ui.part.EntityPart in project dbeaver by dbeaver.

the class ERDGraphicalViewer method setContents.

@Override
public void setContents(EditPart editpart) {
    loadContents = true;
    try {
        super.setContents(editpart);
        // Reset palette contents
        if (editpart instanceof DiagramPart) {
            List<DBSEntity> tables = new ArrayList<>();
            for (Object child : editpart.getChildren()) {
                if (child instanceof EntityPart) {
                    tables.add(((EntityPart) child).getEntity().getObject());
                }
            }
            tables.sort(DBUtils.nameComparator());
            Map<PaletteDrawer, List<ToolEntryTable>> toolMap = new LinkedHashMap<>();
            for (DBSEntity table : tables) {
                DBPDataSourceContainer container = table.getDataSource().getContainer();
                PaletteDrawer drawer = getContainerPaletteDrawer(container);
                if (drawer != null) {
                    List<ToolEntryTable> tools = toolMap.get(drawer);
                    if (tools == null) {
                        tools = new ArrayList<>(tables.size());
                        toolMap.put(drawer, tools);
                    }
                    tools.add(new ToolEntryTable(table));
                }
            }
            for (Map.Entry<PaletteDrawer, List<ToolEntryTable>> entry : toolMap.entrySet()) {
                entry.getKey().setChildren(entry.getValue());
            }
        // editor.getPaletteContents().setChildren(tools);
        }
    } finally {
        loadContents = false;
    }
}
Also used : PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) DBSEntity(org.jkiss.dbeaver.model.struct.DBSEntity) EntityPart(org.jkiss.dbeaver.erd.ui.part.EntityPart) DiagramPart(org.jkiss.dbeaver.erd.ui.part.DiagramPart)

Example 12 with EntityPart

use of org.jkiss.dbeaver.erd.ui.part.EntityPart in project dbeaver by dbeaver.

the class EntityDirectEditPolicy method revertOldEditValue.

@Override
protected void revertOldEditValue(DirectEditRequest request) {
    CellEditor cellEditor = request.getCellEditor();
    cellEditor.setValue(oldValue);
    EntityPart entityPart = (EntityPart) getHost();
    entityPart.revertNameChange();
}
Also used : CellEditor(org.eclipse.jface.viewers.CellEditor) EntityPart(org.jkiss.dbeaver.erd.ui.part.EntityPart)

Example 13 with EntityPart

use of org.jkiss.dbeaver.erd.ui.part.EntityPart in project dbeaver by dbeaver.

the class EntityDirectEditPolicy method showCurrentEditValue.

@Override
protected void showCurrentEditValue(DirectEditRequest request) {
    String value = (String) request.getCellEditor().getValue();
    EntityPart entityPart = (EntityPart) getHost();
    entityPart.handleNameChange(value);
}
Also used : EntityPart(org.jkiss.dbeaver.erd.ui.part.EntityPart)

Example 14 with EntityPart

use of org.jkiss.dbeaver.erd.ui.part.EntityPart in project dbeaver by serge-rider.

the class ERDEditorPart method fillAttributeVisibilityMenu.

public void fillAttributeVisibilityMenu(IMenuManager menu) {
    MenuManager asMenu = new MenuManager(ERDUIMessages.menu_view_style);
    asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.ICONS));
    asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.TYPES));
    asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.NULLABILITY));
    asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.COMMENTS));
    asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.ENTITY_FQN));
    menu.add(asMenu);
    if (getDiagram().getDecorator().supportsAttributeVisibility()) {
        MenuManager avMenu = new MenuManager(ERDUIMessages.menu_attribute_visibility);
        avMenu.add(new EmptyAction(ERDUIMessages.menu_attribute_visibility_default));
        avMenu.add(new ChangeAttributeVisibilityAction(true, ERDAttributeVisibility.ALL));
        avMenu.add(new ChangeAttributeVisibilityAction(true, ERDAttributeVisibility.KEYS));
        avMenu.add(new ChangeAttributeVisibilityAction(true, ERDAttributeVisibility.PRIMARY));
        avMenu.add(new ChangeAttributeVisibilityAction(true, ERDAttributeVisibility.NONE));
        ISelection selection = getGraphicalViewer().getSelection();
        if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
            int totalEntities = 0;
            for (Object item : ((IStructuredSelection) selection).toArray()) {
                if (item instanceof EntityPart) {
                    totalEntities++;
                }
            }
            if (totalEntities > 0) {
                avMenu.add(new Separator());
                String avaTitle = ERDUIMessages.menu_attribute_visibility_entity;
                if (((IStructuredSelection) selection).size() == 1) {
                    avaTitle += " (" + ((IStructuredSelection) selection).getFirstElement() + ")";
                } else {
                    avaTitle += " (" + totalEntities + ")";
                }
                avMenu.add(new EmptyAction(avaTitle));
                avMenu.add(new ChangeAttributeVisibilityAction(false, ERDAttributeVisibility.ALL));
                avMenu.add(new ChangeAttributeVisibilityAction(false, ERDAttributeVisibility.KEYS));
                avMenu.add(new ChangeAttributeVisibilityAction(false, ERDAttributeVisibility.PRIMARY));
                avMenu.add(new ChangeAttributeVisibilityAction(false, ERDAttributeVisibility.NONE));
            }
        }
        menu.add(avMenu);
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) EventObject(java.util.EventObject) DBPNamedObject(org.jkiss.dbeaver.model.DBPNamedObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) EntityPart(org.jkiss.dbeaver.erd.ui.part.EntityPart)

Example 15 with EntityPart

use of org.jkiss.dbeaver.erd.ui.part.EntityPart in project dbeaver by serge-rider.

the class ERDEditorPart method restoreVisualSettings.

private boolean restoreVisualSettings(DiagramPart oldDiagram, EntityDiagram newDiagram) {
    boolean hasChanges = false;
    // Collect visual settings from old diagram and apply them to the new one
    for (ERDEntity newEntity : newDiagram.getEntities()) {
        NodePart oldEntity = oldDiagram.getChildByObject(newEntity.getObject());
        if (oldEntity instanceof EntityPart) {
            EntityDiagram.NodeVisualInfo vi = new EntityDiagram.NodeVisualInfo(oldEntity);
            newDiagram.addVisualInfo(newEntity.getObject(), vi);
            hasChanges = true;
        }
    }
    for (ERDNote newNote : newDiagram.getNotes()) {
        NodePart oldNotePart = oldDiagram.getChildByObject(newNote.getObject());
        if (oldNotePart instanceof NotePart) {
            EntityDiagram.NodeVisualInfo vi = new EntityDiagram.NodeVisualInfo(oldNotePart);
            vi.initBounds = oldNotePart.getBounds();
            newDiagram.addVisualInfo(newNote, vi);
            hasChanges = true;
        }
    }
    return hasChanges;
}
Also used : EntityDiagram(org.jkiss.dbeaver.erd.ui.model.EntityDiagram) NotePart(org.jkiss.dbeaver.erd.ui.part.NotePart) NodePart(org.jkiss.dbeaver.erd.ui.part.NodePart) EntityPart(org.jkiss.dbeaver.erd.ui.part.EntityPart)

Aggregations

EntityPart (org.jkiss.dbeaver.erd.ui.part.EntityPart)20 Rectangle (org.eclipse.draw2d.geometry.Rectangle)6 NodePart (org.jkiss.dbeaver.erd.ui.part.NodePart)6 HashMap (java.util.HashMap)4 Dimension (org.eclipse.draw2d.geometry.Dimension)4 ERDEntity (org.jkiss.dbeaver.erd.model.ERDEntity)4 NotePart (org.jkiss.dbeaver.erd.ui.part.NotePart)4 DBSEntity (org.jkiss.dbeaver.model.struct.DBSEntity)4 FileOutputStream (java.io.FileOutputStream)2 EventObject (java.util.EventObject)2 Map (java.util.Map)2 Bendpoint (org.eclipse.draw2d.Bendpoint)2 Figure (org.eclipse.draw2d.Figure)2 IFigure (org.eclipse.draw2d.IFigure)2 Point (org.eclipse.draw2d.geometry.Point)2 Command (org.eclipse.gef.commands.Command)2 PaletteDrawer (org.eclipse.gef.palette.PaletteDrawer)2 CellEditor (org.eclipse.jface.viewers.CellEditor)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2