Java Code Examples for org.eclipse.emf.common.util.EList#clear()

The following examples show how to use org.eclipse.emf.common.util.EList#clear() . 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: RerouteEdgeHandler.java    From graphical-lsp with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void execute(AbstractOperationAction operationAction, GraphicalModelState modelState) {
	if (!(operationAction instanceof RerouteConnectionOperationAction)) {
		throw new IllegalArgumentException("Unexpected action " + operationAction);
	}

	// check for null-values
	final RerouteConnectionOperationAction action = (RerouteConnectionOperationAction) operationAction;
	if (action.getConnectionElementId() == null || action.getRoutingPoints() == null) {
		throw new IllegalArgumentException("Incomplete reconnect connection action");
	}

	// check for existence of matching elements
	GModelIndex index = modelState.getIndex();
	Optional<GEdge> edge = index.findElementByClass(action.getConnectionElementId(), GEdge.class);
	if (!edge.isPresent()) {
		throw new IllegalArgumentException("Invalid edge: edge ID " + action.getConnectionElementId());
	}

	// reroute
	EList<GPoint> routingPoints = edge.get().getRoutingPoints();
	routingPoints.clear();
	routingPoints.addAll(action.getRoutingPoints());
}
 
Example 2
Source File: ElkLayoutEngine.java    From graphical-lsp with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Apply the computed ELK layout to the given sprotty edge.
 */
protected void transferEdgeLayout(GEdge gedge, ElkEdge elkEdge, LayoutContext context) {
	if (!elkEdge.getSections().isEmpty()) {
		GPoint offset = getOffset(gedge, elkEdge, context);
		ElkEdgeSection section = elkEdge.getSections().get(0);
		List<GPoint> newRoutingPoints = new ArrayList<>();
		GPoint p1 = point(section.getStartX() + offset.getX(), section.getStartY() + offset.getY());
		newRoutingPoints.add(p1);
		for (ElkBendPoint bendGPoint : section.getBendPoints()) {
			GPoint p2 = point(bendGPoint.getX() + offset.getX(), bendGPoint.getY() + offset.getY());
			newRoutingPoints.add(p2);
		}
		GPoint p3 = point(section.getEndX() + offset.getX(), section.getEndY() + offset.getY());
		newRoutingPoints.add(p3);
		EList<GPoint> routingPoints = gedge.getRoutingPoints();
		routingPoints.clear();
		routingPoints.addAll(newRoutingPoints);
	}
}
 
Example 3
Source File: CityUtils.java    From Getaviz with Apache License 2.0 5 votes vote down vote up
/**
 * Sorting the {@link BuildingSegment}s with help of
 * {@link BuildingSegmentComparator} based on sorting settings in
 * {@link CitySettings}.
 * 
 * @param bsList
 *            BuildingSegments which are to be sorted.
 *
 */
public static void sortBuildingSegments(final EList<BuildingSegment> bsList) {
	final List<BuildingSegmentComparator> sortedList = new ArrayList<BuildingSegmentComparator>(bsList.size());
	for (BuildingSegment bs : bsList)
		sortedList.add(new BuildingSegmentComparator(bs));
	Collections.sort(sortedList);
	bsList.clear();
	for (BuildingSegmentComparator bsc : sortedList)
		bsList.add(bsc.getBuildingSegment());
}
 
Example 4
Source File: JavaDerivedStateComputer.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public void discardDerivedState(Resource resource) {
	EList<EObject> resourcesContentsList = resource.getContents();
	for (EObject eObject : resourcesContentsList) {
		unloader.unloadRoot(eObject);
	}
	resourcesContentsList.clear();
	if (isInfoFile(resource)) {
		return;
	}
	if (getCompilationUnit(resource) != null) {
		ClassFileCache classFileCache = findOrCreateClassFileCache(resource.getResourceSet());
		classFileCache.addResourceToCompile(resource);
	}
}
 
Example 5
Source File: ScriptBuilderImpl.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Create the internal Sarl script.
 */
public void eInit(Resource resource, String packageName, IJvmTypeProvider context) {
	setTypeResolutionContext(context);
	if (this.script == null) {
		this.script = SarlFactory.eINSTANCE.createSarlScript();
		EList<EObject> content = resource.getContents();
		if (!content.isEmpty()) {
			content.clear();
		}
		content.add(this.script);
		if (!Strings.isEmpty(packageName)) {
			script.setPackage(packageName);
		}
	}
}
 
Example 6
Source File: PaletteImpl.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void shift( int step, int size )
{
	if ( size <= 0 || size > colorLib.size( ) )
	{
		size = colorLib.size( );
	}

	final EList<Fill> el = getEntries( );
	el.clear( );

	if ( step == 0 || Math.abs( step ) >= size )
	{
		// Do nothing
		step = 0;
	}
	else if ( step < 0 )
	{
		// Move to the left side
		step = -step;
	}
	else if ( step > 0 )
	{
		// Move to the right side
		step = size - step;
	}

	for ( int i = step; i < size; i++ )
	{
		el.add( ( (ColorDefinition) colorLib.get( i ) ).copyInstance( ) );
	}
	for ( int i = 0; i < step; i++ )
	{
		el.add( ( (ColorDefinition) colorLib.get( i ) ).copyInstance( ) );
	}
}
 
Example 7
Source File: RemoveBoundaryWithItsFlows.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void cleanExceptionFlow() {
    final EList<Connection> exceptionFlowsToDelete = boundaryToRemove.getOutgoing();
    for (final Connection exceptionFlowToDelete : exceptionFlowsToDelete) {
        EcoreUtil.remove(exceptionFlowToDelete);
        final TargetElement target = exceptionFlowToDelete.getTarget();
        if (target != null) {
            target.getIncoming().remove(exceptionFlowToDelete);
        }
    }
    exceptionFlowsToDelete.clear();
}
 
Example 8
Source File: PaletteImpl.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public final void update( int iIndex )
{
	final EList el = getEntries( );
	el.clear( );
	if ( iIndex < 0 )
	{
		// a rotation version of palette-0, rataion pos is the negatvie
		// index.
		ArrayList al = new ArrayList( );

		al.add( ColorDefinitionImpl.create( 80, 166, 218 ) );
		al.add( ColorDefinitionImpl.create( 242, 88, 106 ) );
		al.add( ColorDefinitionImpl.create( 232, 172, 57 ) );
		al.add( ColorDefinitionImpl.create( 128, 255, 128 ) );
		al.add( ColorDefinitionImpl.create( 64, 128, 128 ) );
		al.add( ColorDefinitionImpl.create( 128, 128, 192 ) );
		al.add( ColorDefinitionImpl.create( 170, 85, 85 ) );
		al.add( ColorDefinitionImpl.create( 128, 128, 0 ) );

		shiftList( al, -iIndex );

		el.addAll( al );
	}
	else if ( iIndex == 0 )
	{
		el.add( ColorDefinitionImpl.create( 80, 166, 218 ) );
		el.add( ColorDefinitionImpl.create( 242, 88, 106 ) );
		el.add( ColorDefinitionImpl.create( 232, 172, 57 ) );
		el.add( ColorDefinitionImpl.create( 128, 255, 128 ) );
		el.add( ColorDefinitionImpl.create( 64, 128, 128 ) );
		el.add( ColorDefinitionImpl.create( 128, 128, 192 ) );
		el.add( ColorDefinitionImpl.create( 170, 85, 85 ) );
		el.add( ColorDefinitionImpl.create( 128, 128, 0 ) );
	}
	else if ( iIndex == 1 )
	{
		el.add( ColorDefinitionImpl.create( 225, 225, 255 ) );
		el.add( ColorDefinitionImpl.create( 223, 197, 41 ) );
		el.add( ColorDefinitionImpl.create( 249, 225, 191 ) );
		el.add( ColorDefinitionImpl.create( 255, 205, 225 ) );
		el.add( ColorDefinitionImpl.create( 225, 255, 225 ) );
		el.add( ColorDefinitionImpl.create( 255, 191, 255 ) );
		el.add( ColorDefinitionImpl.create( 185, 185, 221 ) );
		el.add( ColorDefinitionImpl.create( 40, 255, 148 ) );
	}
	else
	{
		logger.log( ILogger.WARNING,
				Messages.getString( "error.unknown.palette", //$NON-NLS-1$ 
						new Object[]{
							Integer.valueOf( iIndex )
						},
						ULocale.getDefault( ) ) );
		update( 0 );
	}
}
 
Example 9
Source File: PaletteImpl.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public final void update( Fill f )
{
	final EList el = getEntries( );
	el.clear( );
	el.add( f );
}
 
Example 10
Source File: ResultSetCriteriaAdapter.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Updates oda sort key.
 * 
 */
private void updateODASortKey( ResultSetCriteria criteria )

{

	SortSpecification sortSpec = criteria.getRowOrdering( );

	// if an Oda data set has no BIRT sort hints, the Adapter should create
	// an empty SortSpecification.
	if ( sortSpec == null )
	{
		sortSpec = designFactory.createSortSpecification( );
		criteria.setRowOrdering( sortSpec );
	}

	EList<SortKey> list = sortSpec.getSortKeys( );

	// clear the original value.
	list.clear( );

	Iterator<SortHintHandle> iter = setHandle.sortHintsIterator( );

	while ( iter.hasNext( ) )
	{
		SortHintHandle handle = iter.next( );
		SortKey key = designFactory.createSortKey( );
		key.setColumnName( handle.getColumnName( ) );
		key.setColumnPosition( handle.getPosition( ) );

		String ordering = handle.getNullValueOrdering( );

		setODANullValueOrdering( key, ordering );

		key.setOptional( handle.isOptional( ) );

		// default value
		if ( DesignChoiceConstants.SORT_DIRECTION_ASC.equals( handle
				.getDirection( ) ) )
		{
			key.setSortDirection( SortDirectionType.ASCENDING );
		}
		else if ( DesignChoiceConstants.SORT_DIRECTION_DESC.equals( handle
				.getDirection( ) ) )
		{
			key.setSortDirection( SortDirectionType.DESCENDING );
		}

		list.add( key );
	}

}