Search in sources :

Example 1 with VirtualSupersetCreateCommand

use of org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetCreateCommand 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

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