[WIP ]reorganized dir structure
This commit is contained in:
		@@ -0,0 +1,116 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * Copyright (c) 2015 MINRES Technologies GmbH and others.
 | 
			
		||||
 * 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:
 | 
			
		||||
 *     MINRES Technologies GmbH - initial API and implementation
 | 
			
		||||
 *******************************************************************************/
 | 
			
		||||
package com.minres.scviewer.e4.application.provider;
 | 
			
		||||
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.eclipse.jface.viewers.ITreeContentProvider;
 | 
			
		||||
import org.eclipse.jface.viewers.Viewer;
 | 
			
		||||
 | 
			
		||||
import com.google.common.base.Predicate;
 | 
			
		||||
import com.google.common.collect.Collections2;
 | 
			
		||||
import com.minres.scviewer.database.IHierNode;
 | 
			
		||||
import com.minres.scviewer.database.IWaveform;
 | 
			
		||||
import com.minres.scviewer.database.IWaveformDb;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The Class TxDbContentProvider providing the tree content of a database for the respective viewer.
 | 
			
		||||
 */
 | 
			
		||||
public class TxDbContentProvider implements ITreeContentProvider {
 | 
			
		||||
 | 
			
		||||
	/** The show nodes. */
 | 
			
		||||
	//	private List<HierNode> nodes;
 | 
			
		||||
	private boolean showNodes;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Instantiates a new tx db content provider.
 | 
			
		||||
	 */
 | 
			
		||||
	public TxDbContentProvider() {
 | 
			
		||||
		super();
 | 
			
		||||
		this.showNodes = false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Instantiates a new tx db content provider.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param showNodes the show nodes
 | 
			
		||||
	 */
 | 
			
		||||
	public TxDbContentProvider(boolean showNodes) {
 | 
			
		||||
		super();
 | 
			
		||||
		this.showNodes = showNodes;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public void dispose() {	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
 | 
			
		||||
//		showNodes=!(newInput instanceof IHierNode);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public Object[] getElements(Object inputElement) {
 | 
			
		||||
		if(inputElement instanceof IHierNode){
 | 
			
		||||
			Collection<IHierNode> res = Collections2.filter(((IHierNode)inputElement).getChildNodes(), new Predicate<IHierNode>(){
 | 
			
		||||
				@Override
 | 
			
		||||
				public boolean apply(IHierNode arg0) {
 | 
			
		||||
					if(showNodes){
 | 
			
		||||
						return arg0 instanceof IWaveform;
 | 
			
		||||
					} else{
 | 
			
		||||
						return arg0.getChildNodes().size()!=0;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			});
 | 
			
		||||
			return res.toArray();
 | 
			
		||||
		}else if(inputElement instanceof List<?>){
 | 
			
		||||
			return ((List<?>)inputElement).toArray();
 | 
			
		||||
		}else if(inputElement instanceof IWaveformDb){
 | 
			
		||||
			return new Object[]{};
 | 
			
		||||
		} else
 | 
			
		||||
			return null;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public Object[] getChildren(Object parentElement) {
 | 
			
		||||
		return getElements(parentElement);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public Object getParent(Object element) {
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean hasChildren(Object element) {
 | 
			
		||||
		Object[] obj = getElements(element);
 | 
			
		||||
		return obj == null ? false : obj.length > 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,124 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * Copyright (c) 2015 MINRES Technologies GmbH and others.
 | 
			
		||||
 * 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:
 | 
			
		||||
 *     MINRES Technologies GmbH - initial API and implementation
 | 
			
		||||
 *******************************************************************************/
 | 
			
		||||
package com.minres.scviewer.e4.application.provider;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.eclipse.jface.viewers.ILabelProvider;
 | 
			
		||||
import org.eclipse.jface.viewers.ILabelProviderListener;
 | 
			
		||||
import org.eclipse.swt.graphics.Image;
 | 
			
		||||
import org.eclipse.wb.swt.ResourceManager;
 | 
			
		||||
 | 
			
		||||
import com.minres.scviewer.database.BitVector;
 | 
			
		||||
import com.minres.scviewer.database.IHierNode;
 | 
			
		||||
import com.minres.scviewer.database.ISignal;
 | 
			
		||||
import com.minres.scviewer.database.ITxStream;
 | 
			
		||||
import com.minres.scviewer.database.IWaveformDb;
 | 
			
		||||
import com.minres.scviewer.e4.application.parts.LoadingWaveformDb;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The Class TxDbLabelProvider providing the labels for the respective viewers.
 | 
			
		||||
 */
 | 
			
		||||
public class TxDbLabelProvider implements ILabelProvider {
 | 
			
		||||
 | 
			
		||||
	/** The listeners. */
 | 
			
		||||
	private List<ILabelProviderListener> listeners = new ArrayList<ILabelProviderListener>();
 | 
			
		||||
 | 
			
		||||
	/** The wave. */
 | 
			
		||||
	private Image loadinDatabase, database, stream, signal, folder, wave;
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * Instantiates a new tx db label provider.
 | 
			
		||||
	 */
 | 
			
		||||
	public TxDbLabelProvider() {
 | 
			
		||||
		super();
 | 
			
		||||
		loadinDatabase=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/database_go.png"); //$NON-NLS-1$ //$NON-NLS-2$
 | 
			
		||||
		database=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/database.png"); //$NON-NLS-1$ //$NON-NLS-2$
 | 
			
		||||
		stream=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/stream.png"); //$NON-NLS-1$ //$NON-NLS-2$
 | 
			
		||||
		folder=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/folder.png"); //$NON-NLS-1$ //$NON-NLS-2$
 | 
			
		||||
		signal=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/signal.png"); //$NON-NLS-1$ //$NON-NLS-2$
 | 
			
		||||
		wave=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/wave.png"); //$NON-NLS-1$ //$NON-NLS-2$
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public void addListener(ILabelProviderListener listener) {
 | 
			
		||||
		  listeners.add(listener);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public void dispose() {
 | 
			
		||||
		if(loadinDatabase!=null) database.dispose();
 | 
			
		||||
		if(database!=null) database.dispose();
 | 
			
		||||
		if(stream!=null) stream.dispose();
 | 
			
		||||
		if(folder!=null) folder.dispose();
 | 
			
		||||
		if(signal!=null) signal.dispose();
 | 
			
		||||
		if(wave!=null) wave.dispose();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean isLabelProperty(Object element, String property) {
 | 
			
		||||
		  return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public void removeListener(ILabelProviderListener listener) {
 | 
			
		||||
		  listeners.remove(listener);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public Image getImage(Object element) {
 | 
			
		||||
		if(element instanceof IWaveformDb){
 | 
			
		||||
			if(element instanceof LoadingWaveformDb)
 | 
			
		||||
				return loadinDatabase;
 | 
			
		||||
			else
 | 
			
		||||
				return database;
 | 
			
		||||
		}else if(element instanceof ITxStream){
 | 
			
		||||
			return stream;
 | 
			
		||||
		}else if(element instanceof ISignal<?>){
 | 
			
		||||
			Object o = ((ISignal<?>)element).getEvents().firstEntry().getValue();
 | 
			
		||||
			if(o instanceof BitVector && ((BitVector)o).getWidth()==1)
 | 
			
		||||
				return signal;
 | 
			
		||||
			else 
 | 
			
		||||
				return wave;
 | 
			
		||||
		}else if(element instanceof IHierNode){
 | 
			
		||||
			return folder;
 | 
			
		||||
		} else
 | 
			
		||||
			return null;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getText(Object element) {
 | 
			
		||||
		return ((IHierNode)element).getName();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -0,0 +1,65 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * Copyright (c) 2015 MINRES Technologies GmbH and others.
 | 
			
		||||
 * 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:
 | 
			
		||||
 *     MINRES Technologies GmbH - initial API and implementation
 | 
			
		||||
 *******************************************************************************/
 | 
			
		||||
package com.minres.scviewer.e4.application.provider;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
 | 
			
		||||
import org.eclipse.jface.viewers.Viewer;
 | 
			
		||||
 | 
			
		||||
import com.google.common.base.Predicate;
 | 
			
		||||
import com.google.common.collect.Collections2;
 | 
			
		||||
import com.minres.scviewer.database.IHierNode;
 | 
			
		||||
import com.minres.scviewer.database.ITx;
 | 
			
		||||
import com.minres.scviewer.database.ITxAttribute;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The Class TxPropertiesContentProvider. Not used atm
 | 
			
		||||
 */
 | 
			
		||||
public class TxPropertiesContentProvider implements IStructuredContentProvider {
 | 
			
		||||
 | 
			
		||||
	/** The show nodes. */
 | 
			
		||||
	//	private List<HierNode> nodes;
 | 
			
		||||
	private boolean showNodes=false;
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public void dispose() {	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
 | 
			
		||||
		showNodes=!(newInput instanceof IHierNode);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public Object[] getElements(Object inputElement) {
 | 
			
		||||
		if(inputElement instanceof ITx){
 | 
			
		||||
			return Collections2.filter(((ITx)inputElement).getAttributes(), new Predicate<ITxAttribute>(){
 | 
			
		||||
				@Override
 | 
			
		||||
				public boolean apply(ITxAttribute arg0) {
 | 
			
		||||
					return (arg0 instanceof ITx)!=showNodes;
 | 
			
		||||
				}
 | 
			
		||||
			}).toArray();
 | 
			
		||||
		}else if(inputElement instanceof List<?>)
 | 
			
		||||
			return ((List<?>)inputElement).toArray();
 | 
			
		||||
		else
 | 
			
		||||
			return null;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,97 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * Copyright (c) 2015 MINRES Technologies GmbH and others.
 | 
			
		||||
 * 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:
 | 
			
		||||
 *     MINRES Technologies GmbH - initial API and implementation
 | 
			
		||||
 *******************************************************************************/
 | 
			
		||||
package com.minres.scviewer.e4.application.provider;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.eclipse.jface.viewers.ILabelProviderListener;
 | 
			
		||||
import org.eclipse.jface.viewers.ITableLabelProvider;
 | 
			
		||||
import org.eclipse.swt.graphics.Image;
 | 
			
		||||
 | 
			
		||||
import com.minres.scviewer.database.ITxAttribute;
 | 
			
		||||
import com.minres.scviewer.e4.application.parts.TransactionDetails;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The Class TxPropertiesLabelProvider providing the labels of a property to the respective viewer.
 | 
			
		||||
 */
 | 
			
		||||
public class TxPropertiesLabelProvider implements ITableLabelProvider {
 | 
			
		||||
 | 
			
		||||
	/** The listeners. */
 | 
			
		||||
	private List<ILabelProviderListener> listeners = new ArrayList<ILabelProviderListener>();
 | 
			
		||||
		
 | 
			
		||||
	/**
 | 
			
		||||
	 * Instantiates a new tx properties label provider.
 | 
			
		||||
	 */
 | 
			
		||||
	public TxPropertiesLabelProvider() {
 | 
			
		||||
		super();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public void dispose() {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public void addListener(ILabelProviderListener listener) {
 | 
			
		||||
		  listeners.add(listener);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public void removeListener(ILabelProviderListener listener) {
 | 
			
		||||
		  listeners.remove(listener);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean isLabelProperty(Object element, String property) {
 | 
			
		||||
		  return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public Image getColumnImage(Object element, int columnIndex) {
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getColumnText(Object element, int columnIndex) {
 | 
			
		||||
		ITxAttribute attribute = (ITxAttribute) element;
 | 
			
		||||
	    String text = ""; //$NON-NLS-1$
 | 
			
		||||
	    switch (columnIndex) {
 | 
			
		||||
	    case TransactionDetails.COLUMN_FIRST:
 | 
			
		||||
	      text = attribute.getName();
 | 
			
		||||
	      break;
 | 
			
		||||
	    case TransactionDetails.COLUMN_SECOND:
 | 
			
		||||
	      text = attribute.getValue().toString();
 | 
			
		||||
	      break;
 | 
			
		||||
	    }
 | 
			
		||||
	    return text;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user