- small refactoring of part class names

- tried to improve Javadoc
This commit is contained in:
2015-11-22 12:47:07 +01:00
parent af1b3d00dc
commit f723a770c7
34 changed files with 926 additions and 122 deletions

View File

@ -40,15 +40,11 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.wb.swt.ResourceManager;
import org.eclipse.wb.swt.SWTResourceManager;
// TODO: Auto-generated Javadoc
/**
* The Class AboutDialog.
*/
public class AboutDialog extends Dialog {
/** The styled text. */
// protected StyledText styledText;
/** The product title. */
private String productTitle=
"\nSCViewer - a SystemC waveform viewer\n\nVersion: 1.0\n";
@ -64,8 +60,7 @@ public class AboutDialog extends Dialog {
/**
* Create the dialog.
*
* @param parent the parent
* @param style the style
* @param parentShell the parent shell
*/
@Inject
public AboutDialog(Shell parentShell) {
@ -75,6 +70,9 @@ public class AboutDialog extends Dialog {
/**
* Create contents of the dialog.
*
* @param parent the parent
* @return the control
*/
@Override
protected Control createDialogArea(Composite parent) {
@ -153,6 +151,9 @@ public class AboutDialog extends Dialog {
return composite;
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
*/
protected void createButtonsForButtonBar(Composite parent) {
// create OK button
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true);

View File

@ -72,36 +72,55 @@ import com.minres.scviewer.e4.application.handlers.AddWaveformHandler;
import com.minres.scviewer.e4.application.provider.TxDbContentProvider;
import com.minres.scviewer.e4.application.provider.TxDbLabelProvider;
/**
* The Class DesignBrowser. It contains the design tree, a list of Streams & signals and a few buttons to
* add them them to the waveform view
*/
public class DesignBrowser {
/** The Constant POPUP_ID. */
private static final String POPUP_ID="com.minres.scviewer.e4.application.parts.DesignBrowser.popupmenu";
/** The event broker. */
@Inject IEventBroker eventBroker;
/** The selection service. */
@Inject ESelectionService selectionService;
/** The menu service. */
@Inject EMenuService menuService;
/** The eclipse ctx. */
@Inject IEclipseContext eclipseCtx;
/** The sash form. */
private SashForm sashForm;
/** The top. */
Composite top;
/** The bottom. */
private Composite bottom;
/** The tree viewer. */
private TreeViewer treeViewer;
/** The name filter. */
private Text nameFilter;
/** The tx table viewer. */
private TableViewer txTableViewer;
/** The append all item. */
ToolItem appendItem, insertItem, insertAllItem, appendAllItem;
/** The attribute filter. */
WaveformAttributeFilter attributeFilter;
/** The other selection count. */
int thisSelectionCount=0, otherSelectionCount=0;
/** The tree viewer pcl. */
private PropertyChangeListener treeViewerPCL = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
@ -116,8 +135,10 @@ public class DesignBrowser {
}
};
private WaveformViewerPart waveformViewerPart;
/** The waveform viewer part. */
private WaveformViewer waveformViewerPart;
/** The sash paint listener. */
protected PaintListener sashPaintListener=new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
@ -132,6 +153,11 @@ public class DesignBrowser {
};
/**
* Creates the composite.
*
* @param parent the parent
*/
@PostConstruct
public void createComposite(Composite parent) {
sashForm = new SashForm(parent, SWT.BORDER | SWT.SMOOTH | SWT.VERTICAL);
@ -151,6 +177,11 @@ public class DesignBrowser {
});
}
/**
* Creates the tree viewer composite.
*
* @param parent the parent
*/
public void createTreeViewerComposite(Composite parent) {
parent.setLayout(new GridLayout(1, false));
treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
@ -175,6 +206,11 @@ public class DesignBrowser {
});
}
/**
* Creates the table composite.
*
* @param parent the parent
*/
public void createTableComposite(Composite parent) {
parent.setLayout(new GridLayout(1, false));
@ -293,6 +329,9 @@ public class DesignBrowser {
});
}
/**
* Sets the focus.
*/
@Focus
public void setFocus() {
txTableViewer.getTable().setFocus();
@ -305,9 +344,15 @@ public class DesignBrowser {
updateButtons();
}
/**
* Gets the status event.
*
* @param waveformViewerPart the waveform viewer part
* @return the status event
*/
@SuppressWarnings("unchecked")
@Inject @Optional
public void getStatusEvent(@UIEventTopic(WaveformViewerPart.ACTIVE_WAVEFORMVIEW) WaveformViewerPart waveformViewerPart) {
public void getActiveWaveformViewerEvent(@UIEventTopic(WaveformViewer.ACTIVE_WAVEFORMVIEW) WaveformViewer waveformViewerPart) {
if(this.waveformViewerPart!=null)
this.waveformViewerPart.storeDesignBrowerState(new DBState());
this.waveformViewerPart=waveformViewerPart;
@ -328,6 +373,12 @@ public class DesignBrowser {
database.addPropertyChangeListener(treeViewerPCL);
}
/**
* Sets the selection.
*
* @param selection the selection
* @param partService the part service
*/
@Inject
public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection, EPartService partService){
MPart part = partService.getActivePart();
@ -342,6 +393,9 @@ public class DesignBrowser {
updateButtons();
}
/**
* Update buttons.
*/
private void updateButtons() {
if(txTableViewer!=null && !insertItem.isDisposed() && !appendItem.isDisposed() &&
!appendAllItem.isDisposed() && !insertAllItem.isDisposed()){
@ -357,14 +411,26 @@ public class DesignBrowser {
}
}
/**
* The Class WaveformAttributeFilter.
*/
public class WaveformAttributeFilter extends ViewerFilter {
/** The search string. */
private String searchString;
/**
* Sets the search text.
*
* @param s the new search text
*/
public void setSearchText(String s) {
this.searchString = ".*" + s + ".*";
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (searchString == null || searchString.length() == 0) {
@ -378,6 +444,12 @@ public class DesignBrowser {
}
}
/**
* Gets the filtered children.
*
* @param viewer the viewer
* @return the filtered children
*/
protected Object[] getFilteredChildren(TableViewer viewer){
Object parent = viewer.getInput();
if(parent==null) return new Object[0];
@ -402,32 +474,60 @@ public class DesignBrowser {
return result;
}
/**
* Run command.
*
* @param handler the handler
* @param annotation the annotation
* @param where the where
* @param all the all
* @return the object
*/
protected Object runCommand(AddWaveformHandler handler, Class<? extends Annotation> annotation, String where, Boolean all) {
ContextInjectionFactory.inject(handler, eclipseCtx);
eclipseCtx.set(AddWaveformHandler.PARAM_WHERE_ID, where);
eclipseCtx.set(AddWaveformHandler.PARAM_ALL_ID, all.toString());
eclipseCtx.set(DesignBrowser.class, this);
eclipseCtx.set(WaveformViewerPart.class, waveformViewerPart);
eclipseCtx.set(WaveformViewer.class, waveformViewerPart);
Object result = ContextInjectionFactory.invoke(handler, annotation, eclipseCtx);
return result;
}
/**
* Gets the filtered children.
*
* @return the filtered children
*/
public Object[] getFilteredChildren() {
return getFilteredChildren(txTableViewer);
}
public WaveformViewerPart getActiveWaveformViewerPart() {
/**
* Gets the active waveform viewer part.
*
* @return the active waveform viewer part
*/
public WaveformViewer getActiveWaveformViewerPart() {
return waveformViewerPart;
}
/**
* The Class DBState.
*/
class DBState {
/**
* Instantiates a new DB state.
*/
public DBState() {
this.expandedElements=treeViewer.getExpandedElements();
this.treeSelection=treeViewer.getSelection();
this.tableSelection=txTableViewer.getSelection();
}
/**
* Apply.
*/
public void apply() {
treeViewer.setExpandedElements(expandedElements);
treeViewer.setSelection(treeSelection, true);
@ -435,8 +535,13 @@ public class DesignBrowser {
}
/** The expanded elements. */
private Object[] expandedElements;
/** The tree selection. */
private ISelection treeSelection;
/** The table selection. */
private ISelection tableSelection;
}
};

View File

@ -13,19 +13,46 @@ package com.minres.scviewer.e4.application.parts;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.IPartListener;
/**
* The default implementation of a {@link IPartListener}.
* The class that is interested in processing a part
* event extends this class overriding the respective method, and the object created
* with that class is registered with a component using the
* component's <code>addPartListener<code> method. When
* the part event occurs, that object's appropriate
* method is invoked.
*
* @see PartEvent
*/
public class PartListener implements IPartListener {
/* (non-Javadoc)
* @see org.eclipse.e4.ui.workbench.modeling.IPartListener#partBroughtToTop(org.eclipse.e4.ui.model.application.ui.basic.MPart)
*/
@Override
public void partBroughtToTop(MPart part) {}
/* (non-Javadoc)
* @see org.eclipse.e4.ui.workbench.modeling.IPartListener#partActivated(org.eclipse.e4.ui.model.application.ui.basic.MPart)
*/
@Override
public void partActivated(MPart part) {}
/* (non-Javadoc)
* @see org.eclipse.e4.ui.workbench.modeling.IPartListener#partDeactivated(org.eclipse.e4.ui.model.application.ui.basic.MPart)
*/
@Override
public void partDeactivated(MPart part) {}
/* (non-Javadoc)
* @see org.eclipse.e4.ui.workbench.modeling.IPartListener#partHidden(org.eclipse.e4.ui.model.application.ui.basic.MPart)
*/
@Override
public void partHidden(MPart part) {}
/* (non-Javadoc)
* @see org.eclipse.e4.ui.workbench.modeling.IPartListener#partVisible(org.eclipse.e4.ui.model.application.ui.basic.MPart)
*/
@Override
public void partVisible(MPart part) {}
}

View File

@ -57,32 +57,51 @@ import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.e4.application.provider.TxPropertiesLabelProvider;
/**
* The Class TransactionDetails shows the details of a selected transaction.
*/
public class TransactionDetails {
/** The Constant COLUMN_FIRST. */
// Column constants
public static final int COLUMN_FIRST = 0;
/** The Constant COLUMN_SECOND. */
public static final int COLUMN_SECOND = 1;
/** The Constant COLUMN_THIRD. */
public static final int COLUMN_THIRD = 2;
/** The event broker. */
@Inject IEventBroker eventBroker;
/** The selection service. */
@Inject ESelectionService selectionService;
/** The name filter. */
private Text nameFilter;
/** The tree viewer. */
private TreeViewer treeViewer;
/** The col3. */
private TreeViewerColumn col1, col2, col3;
/** The attribute filter. */
TxAttributeFilter attributeFilter;
/** The view sorter. */
TxAttributeViewerSorter viewSorter;
private WaveformViewerPart waveformViewerPart;
/** The waveform viewer part. */
private WaveformViewer waveformViewerPart;
/**
* Creates the composite.
*
* @param parent the parent
*/
@PostConstruct
public void createComposite(final Composite parent) {
parent.setLayout(new GridLayout(1, false));
@ -207,16 +226,30 @@ public class TransactionDetails {
});
}
/**
* Sets the focus.
*/
@Focus
public void setFocus() {
treeViewer.getTree().setFocus();
}
/**
* Gets the status event.
*
* @param part the part
* @return the status event
*/
@Inject @Optional
public void getStatusEvent(@UIEventTopic(WaveformViewerPart.ACTIVE_WAVEFORMVIEW) WaveformViewerPart part) {
public void getStatusEvent(@UIEventTopic(WaveformViewer.ACTIVE_WAVEFORMVIEW) WaveformViewer part) {
this.waveformViewerPart=part;
}
/**
* Sets the selection.
*
* @param selection the new selection
*/
@Inject
public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection){
if(treeViewer!=null && selection!=null && !treeViewer.getTree().isDisposed()){
@ -231,10 +264,22 @@ public class TransactionDetails {
}
}
/**
* Time to string.
*
* @param time the time
* @return the string
*/
String timeToString(Long time){
return waveformViewerPart.getScaledTime(time);
}
/**
* Tx to string.
*
* @param tx the tx
* @return the string
*/
String txToString(ITx tx){
StringBuilder sb = new StringBuilder();
sb.append("tx#").append(tx.getId()).append("[").append(timeToString(tx.getBeginTime())).
@ -242,21 +287,29 @@ public class TransactionDetails {
return sb.toString();
}
/**
* The Class TxAttributeViewerSorter.
*/
class TxAttributeViewerSorter extends ViewerSorter {
/** The Constant ASCENDING. */
private static final int ASCENDING = 0;
/** The Constant DESCENDING. */
private static final int DESCENDING = 1;
/** The column. */
private int column;
/** The direction. */
private int direction;
/**
* Does the sort. If it's a different column from the previous sort, do an
* ascending sort. If it's the same column as the last sort, toggle the sort
* direction.
*
* @param column
*
* @param column the column
*/
public void doSort(int column) {
if (column == this.column) {
@ -270,7 +323,12 @@ public class TransactionDetails {
}
/**
* Compares the object for sorting
* Compares the object for sorting.
*
* @param viewer the viewer
* @param e1 the e1
* @param e2 the e2
* @return the int
*/
@SuppressWarnings("unchecked")
public int compare(Viewer viewer, Object e1, Object e2) {
@ -297,14 +355,26 @@ public class TransactionDetails {
}
}
/**
* The Class TxAttributeFilter.
*/
class TxAttributeFilter extends ViewerFilter {
/** The search string. */
private String searchString;
/**
* Sets the search text.
*
* @param s the new search text
*/
public void setSearchText(String s) {
this.searchString = ".*" + s + ".*";
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (searchString == null || searchString.length() == 0) {
@ -321,17 +391,40 @@ public class TransactionDetails {
}
}
enum Type {PROPS, ATTRS, IN_REL, OUT_REL}
/**
* The Enum Type.
*/
enum Type {/** The props. */
PROPS, /** The attrs. */
ATTRS, /** The in rel. */
IN_REL, /** The out rel. */
OUT_REL}
/**
* The Class TreeNode.
*/
class TreeNode{
/** The type. */
public Type type;
/** The element. */
public ITx element;
/**
* Instantiates a new tree node.
*
* @param element the element
* @param type the type
*/
public TreeNode(ITx element, Type type){
this.element=element;
this.type=type;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString(){
switch(type){
case PROPS: return "Properties";
@ -343,15 +436,27 @@ public class TransactionDetails {
}
}
/**
* The Class TransactionTreeContentProvider.
*/
class TransactionTreeContentProvider implements ITreeContentProvider {
/* (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) {
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
*/
@Override
public Object[] getElements(Object element) {
return new Object[]{
@ -362,6 +467,9 @@ public class TransactionDetails {
};
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
*/
@Override
public Object[] getChildren(Object element) {
if(element instanceof TreeNode){
@ -398,11 +506,17 @@ public class TransactionDetails {
return null;
}
/* (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) {
return getChildren(element)!=null;
@ -410,16 +524,35 @@ public class TransactionDetails {
}
/**
* The Class AttributeLabelProvider.
*/
class AttributeLabelProvider extends LabelProvider implements IStyledLabelProvider {
/** The field. */
final int field;
/** The Constant NAME. */
public static final int NAME=0;
/** The Constant TYPE. */
public static final int TYPE=1;
/** The Constant VALUE. */
public static final int VALUE=2;
/**
* Instantiates a new attribute label provider.
*
* @param field the field
*/
public AttributeLabelProvider(int field) {
this.field=field;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
*/
@Override
public StyledString getStyledText(Object element) {
switch(field){

View File

@ -76,7 +76,6 @@ import com.minres.scviewer.e4.application.internal.util.IModificationChecker;
import com.minres.scviewer.e4.application.preferences.DefaultValuesInitializer;
import com.minres.scviewer.e4.application.preferences.PreferenceConstants;
// TODO: Auto-generated Javadoc
/**
* The Class WaveformViewerPart.
*/