Search in sources :

Example 1 with ERDNote

use of org.jkiss.dbeaver.ext.erd.model.ERDNote in project dbeaver by serge-rider.

the class DiagramContainerEditPolicy method getCreateCommand.

/**
     * @see ContainerEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
     */
@Override
protected Command getCreateCommand(CreateRequest request) {
    DiagramPart diagramPart = (DiagramPart) getHost();
    Point location = request.getLocation();
    diagramPart.getFigure().translateToRelative(location);
    Object newObject = request.getNewObject();
    if (newObject instanceof ERDNote) {
        return new NoteCreateCommand(diagramPart, (ERDNote) newObject, location);
    }
    Collection<ERDEntity> entities = null;
    if (newObject instanceof ERDEntity) {
        entities = Collections.singletonList((ERDEntity) newObject);
    } else if (newObject instanceof Collection) {
        entities = (Collection<ERDEntity>) newObject;
    }
    if (CommonUtils.isEmpty(entities)) {
        return null;
    }
    return new EntityAddCommand(diagramPart, entities, location);
}
Also used : NoteCreateCommand(org.jkiss.dbeaver.ext.erd.command.NoteCreateCommand) ERDEntity(org.jkiss.dbeaver.ext.erd.model.ERDEntity) ERDNote(org.jkiss.dbeaver.ext.erd.model.ERDNote) Collection(java.util.Collection) Point(org.eclipse.draw2d.geometry.Point) EntityAddCommand(org.jkiss.dbeaver.ext.erd.command.EntityAddCommand) DiagramPart(org.jkiss.dbeaver.ext.erd.part.DiagramPart)

Example 2 with ERDNote

use of org.jkiss.dbeaver.ext.erd.model.ERDNote in project dbeaver by serge-rider.

the class ERDEditorPart method createPaletteRoot.

public PaletteRoot createPaletteRoot() {
    // create root
    PaletteRoot paletteRoot = new PaletteRoot();
    paletteRoot.setLabel("Entity Diagram");
    {
        // a group of default control tools
        PaletteDrawer controls = new PaletteDrawer("Tools", DBeaverIcons.getImageDescriptor(UIIcon.CONFIGURATION));
        paletteRoot.add(controls);
        // the selection tool
        ToolEntry selectionTool = new SelectionToolEntry();
        controls.add(selectionTool);
        // use selection tool as default entry
        paletteRoot.setDefaultEntry(selectionTool);
        // the marquee selection tool
        controls.add(new MarqueeToolEntry());
        if (!isReadOnly()) {
            // separator
            PaletteSeparator separator = new PaletteSeparator("tools");
            separator.setUserModificationPermission(PaletteEntry.PERMISSION_NO_MODIFICATION);
            controls.add(separator);
            final ImageDescriptor connectImage = ERDActivator.getImageDescriptor("icons/connect.png");
            controls.add(new ConnectionCreationToolEntry("Connection", "Create Connection", null, connectImage, connectImage));
            final ImageDescriptor noteImage = ERDActivator.getImageDescriptor("icons/note.png");
            controls.add(new CreationToolEntry("Note", "Create Note", new CreationFactory() {

                @Override
                public Object getNewObject() {
                    return new ERDNote("Note");
                }

                @Override
                public Object getObjectType() {
                    return RequestConstants.REQ_CREATE;
                }
            }, noteImage, noteImage));
        }
    }
    return paletteRoot;
}
Also used : CreationFactory(org.eclipse.gef.requests.CreationFactory) ERDNote(org.jkiss.dbeaver.ext.erd.model.ERDNote) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) DBPNamedObject(org.jkiss.dbeaver.model.DBPNamedObject)

Aggregations

ERDNote (org.jkiss.dbeaver.ext.erd.model.ERDNote)2 Collection (java.util.Collection)1 Point (org.eclipse.draw2d.geometry.Point)1 CreationFactory (org.eclipse.gef.requests.CreationFactory)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 EntityAddCommand (org.jkiss.dbeaver.ext.erd.command.EntityAddCommand)1 NoteCreateCommand (org.jkiss.dbeaver.ext.erd.command.NoteCreateCommand)1 ERDEntity (org.jkiss.dbeaver.ext.erd.model.ERDEntity)1 DiagramPart (org.jkiss.dbeaver.ext.erd.part.DiagramPart)1 DBPNamedObject (org.jkiss.dbeaver.model.DBPNamedObject)1