Search in sources :

Example 1 with VirtualSupersetEditCommand

use of org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetEditCommand in project tmdmaker by tmdmaker.

the class VirtualSupersetTypeEditPart method getCommand.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.gef.editparts.AbstractEditPart#getCommand(org.eclipse.gef.Request)
 */
@Override
public Command getCommand(Request request) {
    if (!REQ_OPEN.equals(request.getType()))
        return super.getCommand(request);
    VirtualSupersetType type = getModel();
    VirtualSuperset superset = type.getSuperset();
    Diagram diagram = superset.getDiagram();
    List<AbstractEntityModel> list = type.getSubsetList();
    VirtualSupersetCreateDialog dialog = new VirtualSupersetCreateDialog(getViewer().getControl().getShell(), diagram, superset, list);
    if (dialog.open() != Dialog.OK)
        return null;
    return new VirtualSupersetEditCommand(superset, dialog.getEditedValue(), dialog.getSelection(), dialog.getEditedAggregator().isApplyAttribute());
}
Also used : VirtualSupersetType(org.tmdmaker.core.model.VirtualSupersetType) VirtualSupersetCreateDialog(org.tmdmaker.ui.dialogs.VirtualSupersetCreateDialog) VirtualSuperset(org.tmdmaker.core.model.VirtualSuperset) VirtualSupersetEditCommand(org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetEditCommand) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) Diagram(org.tmdmaker.core.model.Diagram)

Example 2 with VirtualSupersetEditCommand

use of org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetEditCommand in project tmdmaker by tmdmaker.

the class VirtualSupersetCreateAction method run.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    // アクション呼び出し時のマウスカーソル位置を取得。位置の微調整必要かも
    Point pos = getControlCursorLocation();
    List<AbstractEntityModel> selectedModels = getSelectedModelList();
    Diagram diagram = getDiagram();
    VirtualSuperset original = null;
    VirtualSupersetType aggregator = null;
    if (!selectedModels.isEmpty()) {
        original = getVirtualSuperset();
        if (original != null) {
            selectedModels.remove(original);
        }
    }
    VirtualSupersetCreateDialog dialog = new VirtualSupersetCreateDialog(getControl().getShell(), diagram, original, selectedModels);
    if (dialog.open() == Dialog.OK) {
        CompoundCommand ccommand = null;
        VirtualSuperset edited = dialog.getEditedValue();
        aggregator = dialog.getEditedAggregator();
        List<AbstractEntityModel> selection = dialog.getSelection();
        // みなしスーパーセット作成
        if (original == null) {
            if (selection.isEmpty()) {
                return;
            }
            ccommand = new CompoundCommand();
            ccommand.add(new VirtualSupersetCreateCommand(edited, selection, pos.x, pos.y));
            ccommand.add(new VirtualSupersetTypeChangeCommand(edited, aggregator.isApplyAttribute()));
        } else {
            ccommand = new VirtualSupersetEditCommand(original, edited, selection, aggregator.isApplyAttribute());
        }
        execute(ccommand);
    }
}
Also used : VirtualSupersetCreateCommand(org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetCreateCommand) VirtualSupersetType(org.tmdmaker.core.model.VirtualSupersetType) VirtualSupersetCreateDialog(org.tmdmaker.ui.dialogs.VirtualSupersetCreateDialog) VirtualSuperset(org.tmdmaker.core.model.VirtualSuperset) VirtualSupersetTypeChangeCommand(org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetTypeChangeCommand) Point(org.eclipse.swt.graphics.Point) VirtualSupersetEditCommand(org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetEditCommand) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) Diagram(org.tmdmaker.core.model.Diagram) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Aggregations

AbstractEntityModel (org.tmdmaker.core.model.AbstractEntityModel)2 Diagram (org.tmdmaker.core.model.Diagram)2 VirtualSuperset (org.tmdmaker.core.model.VirtualSuperset)2 VirtualSupersetType (org.tmdmaker.core.model.VirtualSupersetType)2 VirtualSupersetCreateDialog (org.tmdmaker.ui.dialogs.VirtualSupersetCreateDialog)2 VirtualSupersetEditCommand (org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetEditCommand)2 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 Point (org.eclipse.swt.graphics.Point)1 VirtualSupersetCreateCommand (org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetCreateCommand)1 VirtualSupersetTypeChangeCommand (org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetTypeChangeCommand)1