Java Code Examples for org.eclipse.gef.GraphicalViewer#getSelectedEditParts()

The following examples show how to use org.eclipse.gef.GraphicalViewer#getSelectedEditParts() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultLineAction.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean calculateEnabled() {
    final GraphicalViewer viewer = getGraphicalViewer();

    for (final Object object : viewer.getSelectedEditParts()) {
        if (object instanceof ConnectionEditPart) {
            return true;

        } else if (object instanceof NodeElementEditPart) {
            final NodeElementEditPart nodeElementEditPart = (NodeElementEditPart) object;

            if (!nodeElementEditPart.getSourceConnections().isEmpty()) {
                return true;
            }
        }
    }

    return false;
}
 
Example 2
Source File: RightAngleLineAction.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected boolean calculateEnabled() {
    final GraphicalViewer viewer = getGraphicalViewer();

    for (final Object object : viewer.getSelectedEditParts()) {
        if (object instanceof ConnectionEditPart) {
            return true;

        } else if (object instanceof NodeElementEditPart) {
            final NodeElementEditPart nodeElementEditPart = (NodeElementEditPart) object;

            if (!nodeElementEditPart.getSourceConnections().isEmpty()) {
                return true;
            }
        }
    }

    return false;
}
 
Example 3
Source File: ResizeModelAction.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected boolean calculateEnabled() {
    final GraphicalViewer viewer = getGraphicalViewer();

    for (final Object object : viewer.getSelectedEditParts()) {
        if (object instanceof NodeElementEditPart) {
            final NodeElementEditPart nodeElementEditPart = (NodeElementEditPart) object;

            if (nodeElementEditPart instanceof ERTableEditPart || nodeElementEditPart instanceof NoteEditPart) {
                return true;
            }
        }
    }

    return false;
}
 
Example 4
Source File: AutoResizeModelAction.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected boolean calculateEnabled() {
    final GraphicalViewer viewer = getGraphicalViewer();

    for (final Object object : viewer.getSelectedEditParts()) {
        if (object instanceof NodeElementEditPart) {
            final NodeElementEditPart nodeElementEditPart = (NodeElementEditPart) object;

            if (nodeElementEditPart instanceof ERTableEditPart || nodeElementEditPart instanceof NoteEditPart) {
                return true;
            }
        }
    }

    return false;
}
 
Example 5
Source File: AbstractBaseSelectionAction.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
protected void execute(final Event event) {
    final GraphicalViewer viewer = getGraphicalViewer();

    final List<Command> commandList = new ArrayList<Command>();

    for (final Object object : viewer.getSelectedEditParts()) {
        final List<Command> subCommandList = getCommand((EditPart) object, event);
        commandList.addAll(subCommandList);
    }

    if (!commandList.isEmpty()) {
        final CompoundCommand compoundCommand = new CompoundCommand();
        for (final Command command : commandList) {
            compoundCommand.add(command);
        }

        this.execute(compoundCommand);
    }
}
 
Example 6
Source File: DefaultLineAction.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean calculateEnabled() {
    final GraphicalViewer viewer = getGraphicalViewer();

    for (final Object object : viewer.getSelectedEditParts()) {
        if (object instanceof ConnectionEditPart) {
            return true;

        } else if (object instanceof DiagramWalkerEditPart) {
            final DiagramWalkerEditPart nodeElementEditPart = (DiagramWalkerEditPart) object;

            if (!nodeElementEditPart.getSourceConnections().isEmpty()) {
                return true;
            }
        }
    }

    return false;
}
 
Example 7
Source File: ResizeModelAction.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean calculateEnabled() {
    final GraphicalViewer viewer = getGraphicalViewer();

    for (final Object object : viewer.getSelectedEditParts()) {
        if (object instanceof DiagramWalkerEditPart) {
            final DiagramWalkerEditPart nodeElementEditPart = (DiagramWalkerEditPart) object;

            if (nodeElementEditPart instanceof ERTableEditPart || nodeElementEditPart instanceof WalkerNoteEditPart) {
                return true;
            }
        }
    }

    return false;
}
 
Example 8
Source File: AbstractBaseSelectionAction.java    From erflute with Apache License 2.0 6 votes vote down vote up
protected void execute(Event event) {
    final GraphicalViewer viewer = getGraphicalViewer();

    final List<Command> commandList = new ArrayList<>();

    for (final Object object : viewer.getSelectedEditParts()) {
        final List<Command> subCommandList = getCommand((EditPart) object, event);
        commandList.addAll(subCommandList);
    }

    if (!commandList.isEmpty()) {
        final CompoundCommand compoundCommand = new CompoundCommand();
        for (final Command command : commandList) {
            compoundCommand.add(command);
        }

        execute(compoundCommand);
    }
}
 
Example 9
Source File: DefaultLineAction.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean calculateEnabled() {
	GraphicalViewer viewer = this.getGraphicalViewer();

	for (Object object : viewer.getSelectedEditParts()) {
		if (object instanceof ConnectionEditPart) {
			return true;

		} else if (object instanceof NodeElementEditPart) {
			NodeElementEditPart nodeElementEditPart = (NodeElementEditPart) object;

			if (!nodeElementEditPart.getSourceConnections().isEmpty()) {
				return true;
			}
		}
	}

	return false;
}
 
Example 10
Source File: RightAngleLineAction.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected boolean calculateEnabled() {
	GraphicalViewer viewer = this.getGraphicalViewer();

	for (Object object : viewer.getSelectedEditParts()) {
		if (object instanceof ConnectionEditPart) {
			return true;

		} else if (object instanceof NodeElementEditPart) {
			NodeElementEditPart nodeElementEditPart = (NodeElementEditPart) object;

			if (!nodeElementEditPart.getSourceConnections().isEmpty()) {
				return true;
			}
		}
	}

	return false;
}
 
Example 11
Source File: ResizeModelAction.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected boolean calculateEnabled() {
	GraphicalViewer viewer = this.getGraphicalViewer();

	for (Object object : viewer.getSelectedEditParts()) {
		if (object instanceof NodeElementEditPart) {
			NodeElementEditPart nodeElementEditPart = (NodeElementEditPart) object;

			if (nodeElementEditPart instanceof ERTableEditPart
					|| nodeElementEditPart instanceof NoteEditPart) {
				return true;
			}
		}
	}

	return false;
}
 
Example 12
Source File: AbstractBaseSelectionAction.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
protected void execute(Event event) {
	GraphicalViewer viewer = this.getGraphicalViewer();

	List<Command> commandList = new ArrayList<Command>();

	for (Object object : viewer.getSelectedEditParts()) {
		List<Command> subCommandList = this.getCommand((EditPart) object,
				event);
		commandList.addAll(subCommandList);
	}

	if (!commandList.isEmpty()) {
		CompoundCommand compoundCommand = new CompoundCommand();
		for (Command command : commandList) {
			compoundCommand.add(command);
		}

		this.execute(compoundCommand);
	}
}
 
Example 13
Source File: RightAngleLineAction.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean calculateEnabled() {
    final GraphicalViewer viewer = getGraphicalViewer();
    for (final Object object : viewer.getSelectedEditParts()) {
        if (object instanceof ConnectionEditPart) {
            return true;
        } else if (object instanceof DiagramWalkerEditPart) {
            final DiagramWalkerEditPart nodeElementEditPart = (DiagramWalkerEditPart) object;
            if (!nodeElementEditPart.getSourceConnections().isEmpty()) {
                return true;
            }
        }
    }
    return false;
}