Java Code Examples for org.eclipse.gef.EditPart#setSelected()

The following examples show how to use org.eclipse.gef.EditPart#setSelected() . 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: ERDiagramMatchHeightAction.java    From erflute with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected List getSelectedObjects() {
    final List<?> objects = new ArrayList<Object>(super.getSelectedObjects());
    boolean first = true;
    for (final Iterator<?> iter = objects.iterator(); iter.hasNext();) {
        final Object object = iter.next();

        if (!(object instanceof EditPart)) {
            iter.remove();
        } else {
            final EditPart editPart = (EditPart) object;
            if (editPart instanceof NormalColumnEditPart) {
                iter.remove();
            } else {
                if (first) {
                    editPart.setSelected(2);
                    first = false;
                }
            }
        }
    }
    return objects;
}
 
Example 2
Source File: ERDiagramMatchWidthAction.java    From erflute with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected List getSelectedObjects() {
    final List<?> objects = new ArrayList<Object>(super.getSelectedObjects());
    boolean first = true;
    for (final Iterator<?> iter = objects.iterator(); iter.hasNext();) {
        final Object object = iter.next();
        if (!(object instanceof EditPart)) {
            iter.remove();
        } else {
            final EditPart editPart = (EditPart) object;
            if (editPart instanceof NormalColumnEditPart) {
                iter.remove();
            } else {
                if (first) {
                    editPart.setSelected(2);
                    first = false;
                }
            }
        }
    }
    return objects;
}
 
Example 3
Source File: BonitaDiagramSelectionManager.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void appendSelection(EditPart editpart) {
	if(editpart instanceof LabelEditPart){
		super.appendSelection(editpart) ;
		return ;
	}
	
	//--> disable multiple selection
	deselectAll();
	if (editpart != getFocus())
		getViewer().setFocus(null);
	if (!getSelection().isEmpty()) {
		EditPart primary = (EditPart) ((StructuredSelection) getSelection()).toList().get((((StructuredSelection) getSelection()).size()) - 1);
		primary.setSelected(EditPart.SELECTED);
	}
	// if the editpart is already in the list, re-order it to be the last one
	try{
		((StructuredSelection) getSelection()).toList().remove(editpart);
	}catch (UnsupportedOperationException e) {
		
	}
	setSelection(new StructuredSelection(editpart));
	editpart.setSelected(EditPart.SELECTED_PRIMARY);
	fireSelectionChanged();
}
 
Example 4
Source File: ERDiagramMatchHeightAction.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected List getSelectedObjects() {
    final List objects = new ArrayList(super.getSelectedObjects());
    boolean first = true;

    for (final Iterator iter = objects.iterator(); iter.hasNext();) {
        final Object object = iter.next();

        if (!(object instanceof EditPart)) {
            iter.remove();

        } else {
            final EditPart editPart = (EditPart) object;
            if (editPart instanceof NormalColumnEditPart) {
                iter.remove();

            } else {
                if (first) {
                    editPart.setSelected(2);
                    first = false;
                }
            }
        }
    }

    return objects;
}
 
Example 5
Source File: ERDiagramMatchWidthAction.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected List getSelectedObjects() {
    final List objects = new ArrayList(super.getSelectedObjects());
    boolean first = true;

    for (final Iterator iter = objects.iterator(); iter.hasNext();) {
        final Object object = iter.next();
        if (!(object instanceof EditPart)) {
            iter.remove();

        } else {
            final EditPart editPart = (EditPart) object;

            if (editPart instanceof NormalColumnEditPart) {
                iter.remove();

            } else {
                if (first) {
                    editPart.setSelected(2);
                    first = false;
                }
            }
        }
    }
    return objects;
}
 
Example 6
Source File: DeferredGraphicalViewer.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets the selection to the given selection and fires selection changed.
 * The ISelection should be an {@link IStructuredSelection}or it will be
 * ignored.
 * 
 * @see ISelectionProvider#setSelection(ISelection)
 */
public void setSelection( ISelection newSelection, boolean dispatch )
{
	if ( !( newSelection instanceof IStructuredSelection ) )
		return;

	List editparts = ( (IStructuredSelection) newSelection ).toList( );
	List selection = primGetSelectedEditParts( );

	setFocus( null );
	for ( int i = 0; i < selection.size( ); i++ )
		( (EditPart) selection.get( i ) ).setSelected( EditPart.SELECTED_NONE );
	selection.clear( );

	editparts = flitterEditpart( editparts );
	// for create handle
	selection.addAll( editparts );

	for ( int i = 0; i < editparts.size( ); i++ )
	{
		EditPart part = (EditPart) editparts.get( i );
		if ( i == editparts.size( ) - 1 )
			part.setSelected( EditPart.SELECTED_PRIMARY );
		else
			part.setSelected( EditPart.SELECTED );

	}

	if ( dispatch )
	{
		fireSelectionChanged( );
	}
}
 
Example 7
Source File: ERDiagramMatchHeightAction.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected List getSelectedObjects() {
	List objects = new ArrayList(super.getSelectedObjects());
	boolean first = true;

	for (Iterator iter = objects.iterator(); iter.hasNext();) {
		Object object = iter.next();

		if (!(object instanceof EditPart)) {
			iter.remove();
			
		} else {
			EditPart editPart = (EditPart) object;
			if (editPart instanceof NormalColumnEditPart) {
				iter.remove();

			} else {
				if (first) {
					editPart.setSelected(2);
					first = false;
				}
			}
		}
	}

	return objects;
}
 
Example 8
Source File: ERDiagramMatchWidthAction.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected List getSelectedObjects() {
	List objects = new ArrayList(super.getSelectedObjects());
	boolean first = true;

	for (Iterator iter = objects.iterator(); iter.hasNext();) {
		Object object = iter.next();
		if (!(object instanceof EditPart)) {
			iter.remove();
			
		} else {
			EditPart editPart = (EditPart) object;

			if (editPart instanceof NormalColumnEditPart) {
				iter.remove();

			} else {
				if (first) {
					editPart.setSelected(2);
					first = false;
				}
			}
		}
	}
	return objects;
}