/******************************************************************************* * Copyright (c) 2012 IT Just working. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IT Just working - initial API and implementation *******************************************************************************/ package com.itjw.txviewer.graph; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.eclipse.jface.viewers.IStructuredSelection; import com.itjw.txviewer.graph.data.ITrStreamFacade; import com.itjw.txviewer.graph.data.ITransactionFacade; public class TransactionSelection implements IStructuredSelection { List selection = new ArrayList(); public TransactionSelection(ITransactionFacade node){ selection.add(node); } public TransactionSelection(List nodes){ selection.addAll(nodes); } public TransactionSelection(ITransactionFacade currentSelection, ITrStreamFacade currentStreamSelection) { selection.add(currentSelection); if(currentStreamSelection!=null) selection.add(currentStreamSelection); } public void add(ITransactionFacade node){ selection.add(node); } public void addAll(List nodes){ selection.addAll(nodes); } @Override public boolean isEmpty() { return selection.size()==0; } @Override public ITransactionFacade getFirstElement() { return (ITransactionFacade)selection.get(0); } @Override public Iterator iterator() { return selection.iterator(); } @Override public int size() { return selection.size(); } @Override public Object[] toArray() { return selection.toArray(); } @Override public List toList() { return selection; } }