[WIP ]reorganized dir structure
This commit is contained in:
@ -0,0 +1,172 @@
|
||||
/*******************************************************************************
|
||||
* 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.parts;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.StyleRange;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.events.PaintEvent;
|
||||
import org.eclipse.swt.events.PaintListener;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Canvas;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.wb.swt.ResourceManager;
|
||||
import org.eclipse.wb.swt.SWTResourceManager;
|
||||
import org.osgi.framework.Version;
|
||||
|
||||
import com.minres.scviewer.e4.application.Messages;
|
||||
|
||||
/**
|
||||
* The Class AboutDialog.
|
||||
*/
|
||||
public class AboutDialog extends Dialog {
|
||||
|
||||
/** The copyright text. */
|
||||
private String copyrightText=Messages.AboutDialog_1;
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
*
|
||||
* @param parentShell the parent shell
|
||||
*/
|
||||
@Inject
|
||||
public AboutDialog(Shell parentShell) {
|
||||
super(parentShell);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create contents of the dialog.
|
||||
*
|
||||
* @param parent the parent
|
||||
* @return the control
|
||||
*/
|
||||
@Override
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
GridData gd_composite = new GridData(SWT.LEFT, SWT.FILL, true, true);
|
||||
gd_composite.widthHint = 600;
|
||||
gd_composite.heightHint =300;
|
||||
composite.setLayoutData(gd_composite);
|
||||
composite.setLayout(new GridLayout(2, false));
|
||||
|
||||
final Color white=SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
final Image scviewerLogo=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/SCViewer_logo.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
final Image minresLogo=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/Minres_logo.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
Canvas canvas = new Canvas(composite,SWT.NO_REDRAW_RESIZE);
|
||||
GridData gd_canvas = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
|
||||
gd_canvas.widthHint = 200;
|
||||
gd_canvas.heightHint =300;
|
||||
canvas.setLayoutData(gd_canvas);
|
||||
canvas.addPaintListener(new PaintListener() {
|
||||
public void paintControl(PaintEvent e) {
|
||||
e.gc.setBackground(white);
|
||||
e.gc.fillRectangle(e.x, e.y, e.width, e.height);
|
||||
e.gc.drawImage(scviewerLogo,4,0);
|
||||
e.gc.drawImage(minresLogo,0,200);
|
||||
}
|
||||
});
|
||||
|
||||
StyledText styledText = new StyledText(composite, SWT.V_SCROLL | SWT.BORDER);
|
||||
styledText.setEditable(false);
|
||||
GridData gd_styledText = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
|
||||
styledText.setLayoutData(gd_styledText);
|
||||
Version version = Platform.getProduct().getDefiningBundle().getVersion();
|
||||
String versionString = String.format("%d.%d.%d", version.getMajor(), version.getMinor(), version.getMicro());
|
||||
String productTitle = NLS.bind(Messages.AboutDialog_0, versionString);
|
||||
styledText.setText(productTitle+copyrightText);
|
||||
styledText.setBackground(white);
|
||||
styledText.setWordWrap(true);
|
||||
styledText.setLeftMargin(5);
|
||||
StyleRange styleRange = new StyleRange();
|
||||
styleRange.start = 0;
|
||||
styleRange.length = productTitle.length();
|
||||
styleRange.fontStyle = SWT.BOLD;
|
||||
styledText.setStyleRange(styleRange);
|
||||
///^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/
|
||||
Pattern pattern = Pattern.compile("https?:\\/\\/([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w\\.-]*)*\\/?"); //$NON-NLS-1$
|
||||
// in case you would like to ignore case sensitivity,
|
||||
// you could use this statement:
|
||||
// Pattern pattern = Pattern.compile("\\s+", Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(productTitle+copyrightText);
|
||||
// check all occurance
|
||||
while (matcher.find()) {
|
||||
styleRange = new StyleRange();
|
||||
styleRange.underline=true;
|
||||
styleRange.underlineStyle = SWT.UNDERLINE_LINK;
|
||||
styleRange.data = matcher.group();
|
||||
styleRange.start = matcher.start();
|
||||
styleRange.length = matcher.end()-matcher.start();
|
||||
styledText.setStyleRange(styleRange);
|
||||
}
|
||||
styledText.addListener(SWT.MouseDown, new Listener() {
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
// It is up to the application to determine when and how a link should be activated.
|
||||
// links are activated on mouse down when the control key is held down
|
||||
// if ((event.stateMask & SWT.MOD1) != 0) {
|
||||
try {
|
||||
@SuppressWarnings("deprecation")
|
||||
int offset = ((StyledText)event.widget).getOffsetAtLocation(new Point (event.x, event.y));
|
||||
StyleRange style = ((StyledText)event.widget).getStyleRangeAtOffset(offset);
|
||||
if (style != null && style.underline && style.underlineStyle == SWT.UNDERLINE_LINK) {
|
||||
Desktop.getDesktop().browse(new java.net.URI(style.data.toString()));
|
||||
}
|
||||
} catch (IOException | URISyntaxException | IllegalArgumentException e) {}
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
styleRange.start = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the dialog.
|
||||
* @return the result
|
||||
*/
|
||||
@PostConstruct
|
||||
@Override
|
||||
public int open() {
|
||||
return super.open();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,665 @@
|
||||
/*******************************************************************************
|
||||
* 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.parts;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.e4.core.di.annotations.CanExecute;
|
||||
import org.eclipse.e4.core.di.annotations.Execute;
|
||||
import org.eclipse.e4.core.di.annotations.Optional;
|
||||
import org.eclipse.e4.core.services.events.IEventBroker;
|
||||
import org.eclipse.e4.ui.di.Focus;
|
||||
import org.eclipse.e4.ui.di.UIEventTopic;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||
import org.eclipse.e4.ui.services.EMenuService;
|
||||
import org.eclipse.e4.ui.services.IServiceConstants;
|
||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
|
||||
import org.eclipse.jface.viewers.DoubleClickEvent;
|
||||
import org.eclipse.jface.viewers.IContentProvider;
|
||||
import org.eclipse.jface.viewers.IDoubleClickListener;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.ITreePathContentProvider;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.TableViewer;
|
||||
import org.eclipse.jface.viewers.TreePath;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.SashForm;
|
||||
import org.eclipse.swt.events.ControlAdapter;
|
||||
import org.eclipse.swt.events.ControlEvent;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.PaintEvent;
|
||||
import org.eclipse.swt.events.PaintListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.swt.widgets.ToolBar;
|
||||
import org.eclipse.swt.widgets.ToolItem;
|
||||
import org.eclipse.wb.swt.ResourceManager;
|
||||
import org.eclipse.wb.swt.SWTResourceManager;
|
||||
|
||||
import com.minres.scviewer.database.HierNode;
|
||||
import com.minres.scviewer.database.IHierNode;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.e4.application.Messages;
|
||||
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"; //$NON-NLS-1$
|
||||
|
||||
/** 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 of the design browser tree. */
|
||||
private Text treeNameFilter;
|
||||
|
||||
/** The attribute filter. */
|
||||
StreamTTreeFilter treeAttributeFilter;
|
||||
|
||||
/** The name filter. */
|
||||
private Text tableNameFilter;
|
||||
|
||||
/** The attribute filter. */
|
||||
StreamTableFilter tableAttributeFilter;
|
||||
|
||||
/** The tx table viewer. */
|
||||
private TableViewer txTableViewer;
|
||||
|
||||
/** The append all item. */
|
||||
ToolItem appendItem, insertItem;
|
||||
|
||||
/** The other selection count. */
|
||||
int thisSelectionCount=0, otherSelectionCount=0;
|
||||
|
||||
/** The tree viewer pcl. */
|
||||
private PropertyChangeListener treeViewerPCL = new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
if("CHILDS".equals(evt.getPropertyName())){ //$NON-NLS-1$
|
||||
treeViewer.getTree().getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
treeViewer.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** The waveform viewer part. */
|
||||
private WaveformViewer waveformViewerPart;
|
||||
|
||||
/** The sash paint listener. */
|
||||
protected PaintListener sashPaintListener=new PaintListener() {
|
||||
@Override
|
||||
public void paintControl(PaintEvent e) {
|
||||
int size=Math.min(e.width, e.height)-1;
|
||||
e.gc.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY));
|
||||
e.gc.setFillRule(SWT.FILL_EVEN_ODD);
|
||||
if(e.width>e.height)
|
||||
e.gc.drawArc(e.x+(e.width-size)/2, e.y, size, size, 0, 360);
|
||||
else
|
||||
e.gc.drawArc(e.x, e.y+(e.height-size)/2, size, size, 0, 360);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Creates the composite.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
@PostConstruct
|
||||
public void createComposite(Composite parent) {
|
||||
sashForm = new SashForm(parent, SWT.BORDER | SWT.SMOOTH | SWT.VERTICAL);
|
||||
|
||||
top = new Composite(sashForm, SWT.NONE);
|
||||
createTreeViewerComposite(top);
|
||||
bottom = new Composite(sashForm, SWT.NONE);
|
||||
createTableComposite(bottom);
|
||||
|
||||
sashForm.setWeights(new int[] {100, 100});
|
||||
sashForm.SASH_WIDTH=5;
|
||||
top.addControlListener(new ControlAdapter() {
|
||||
public void controlResized(ControlEvent e) {
|
||||
sashForm.getChildren()[2].addPaintListener(sashPaintListener);
|
||||
top.removeControlListener(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tree viewer composite.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
public void createTreeViewerComposite(Composite parent) {
|
||||
parent.setLayout(new GridLayout(1, false));
|
||||
|
||||
treeNameFilter = new Text(parent, SWT.BORDER);
|
||||
treeNameFilter.setMessage(Messages.DesignBrowser_3);
|
||||
treeNameFilter.addModifyListener(new ModifyListener() {
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e) {
|
||||
treeAttributeFilter.setSearchText(((Text) e.widget).getText());
|
||||
treeViewer.refresh();
|
||||
}
|
||||
});
|
||||
treeNameFilter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
treeAttributeFilter = new StreamTTreeFilter();
|
||||
|
||||
treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
treeViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
treeViewer.setContentProvider(new TxDbContentProvider());
|
||||
treeViewer.setLabelProvider(new TxDbLabelProvider());
|
||||
treeViewer.addFilter(treeAttributeFilter);
|
||||
treeViewer.setUseHashlookup(true);
|
||||
treeViewer.setAutoExpandLevel(2);
|
||||
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
|
||||
@Override
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
ISelection selection=event.getSelection();
|
||||
if( selection instanceof IStructuredSelection) {
|
||||
Object object= ((IStructuredSelection)selection).getFirstElement();
|
||||
if(object instanceof IHierNode && ((IHierNode)object).getChildNodes().size()!=0){
|
||||
txTableViewer.setInput(object);
|
||||
updateButtons();
|
||||
}
|
||||
else { //if selection is changed but empty
|
||||
txTableViewer.setInput(null);
|
||||
updateButtons();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the table composite.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
public void createTableComposite(Composite parent) {
|
||||
parent.setLayout(new GridLayout(1, false));
|
||||
|
||||
tableNameFilter = new Text(parent, SWT.BORDER);
|
||||
tableNameFilter.setMessage(Messages.DesignBrowser_2);
|
||||
tableNameFilter.addModifyListener(new ModifyListener() {
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e) {
|
||||
tableAttributeFilter.setSearchText(((Text) e.widget).getText());
|
||||
updateButtons();
|
||||
txTableViewer.refresh();
|
||||
}
|
||||
});
|
||||
tableNameFilter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
tableAttributeFilter = new StreamTableFilter();
|
||||
|
||||
txTableViewer = new TableViewer(parent);
|
||||
txTableViewer.setContentProvider(new TxDbContentProvider(true));
|
||||
txTableViewer.setLabelProvider(new TxDbLabelProvider());
|
||||
txTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
txTableViewer.addFilter(tableAttributeFilter);
|
||||
txTableViewer.addDoubleClickListener(new IDoubleClickListener() {
|
||||
@Override
|
||||
public void doubleClick(DoubleClickEvent event) {
|
||||
AddWaveformHandler myHandler = new AddWaveformHandler();
|
||||
Object result = runCommand(myHandler, CanExecute.class, "after", false); //$NON-NLS-1$
|
||||
if(result!=null && (Boolean)result)
|
||||
ContextInjectionFactory.invoke(myHandler, Execute.class, eclipseCtx);
|
||||
}
|
||||
});
|
||||
txTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
|
||||
@Override
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
selectionService.setSelection(event.getSelection());
|
||||
updateButtons();
|
||||
}
|
||||
});
|
||||
menuService.registerContextMenu(txTableViewer.getControl(), POPUP_ID);
|
||||
|
||||
ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.RIGHT);
|
||||
toolBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
|
||||
toolBar.setBounds(0, 0, 87, 20);
|
||||
|
||||
appendItem = new ToolItem(toolBar, SWT.NONE);
|
||||
appendItem.setToolTipText(Messages.DesignBrowser_4);
|
||||
appendItem.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/append_wave.png")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
appendItem.setEnabled(false);
|
||||
appendItem.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
AddWaveformHandler myHandler = new AddWaveformHandler();
|
||||
Object result = runCommand(myHandler, CanExecute.class, "after", false); //$NON-NLS-1$
|
||||
if(result!=null && (Boolean)result)
|
||||
ContextInjectionFactory.invoke(myHandler, Execute.class, eclipseCtx);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
insertItem = new ToolItem(toolBar, SWT.NONE);
|
||||
insertItem.setToolTipText(Messages.DesignBrowser_8);
|
||||
insertItem.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/insert_wave.png")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
insertItem.setEnabled(false);
|
||||
insertItem.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
AddWaveformHandler myHandler = new AddWaveformHandler();
|
||||
Object result = runCommand(myHandler, CanExecute.class, "before", false); //$NON-NLS-1$
|
||||
if(result!=null && (Boolean)result)
|
||||
ContextInjectionFactory.invoke(myHandler, Execute.class, eclipseCtx);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the focus.
|
||||
*/
|
||||
@Focus
|
||||
public void setFocus() {
|
||||
if(txTableViewer!=null) {
|
||||
txTableViewer.getTable().setFocus();
|
||||
IStructuredSelection selection = (IStructuredSelection)txTableViewer.getSelection();
|
||||
if(selection.size()==0){
|
||||
appendItem.setEnabled(false);
|
||||
}
|
||||
selectionService.setSelection(selection);
|
||||
thisSelectionCount=selection.toList().size();
|
||||
}
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
* reset tree viewer and tableviewer after every closed tab
|
||||
*/
|
||||
protected void resetTreeViewer() {
|
||||
//reset tree- and tableviewer
|
||||
treeViewer.setInput(null);
|
||||
txTableViewer.setInput(null);
|
||||
txTableViewer.setSelection(null);
|
||||
}
|
||||
|
||||
public void selectAllWaveforms() {
|
||||
int itemCount = txTableViewer.getTable().getItemCount();
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
for(int i=0; i<itemCount; i++) {
|
||||
list.add(txTableViewer.getElementAt(i));
|
||||
}
|
||||
StructuredSelection sel = new StructuredSelection(list);
|
||||
txTableViewer.setSelection(sel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status event.
|
||||
*
|
||||
* @param waveformViewerPart the waveform viewer part
|
||||
* @return the status event
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Inject @Optional
|
||||
public void getActiveWaveformViewerEvent(@UIEventTopic(WaveformViewer.ACTIVE_WAVEFORMVIEW) WaveformViewer waveformViewerPart) {
|
||||
if(this.waveformViewerPart!=null) {
|
||||
this.waveformViewerPart.storeDesignBrowerState(new DBState());
|
||||
}
|
||||
if( this.waveformViewerPart == null || this.waveformViewerPart != waveformViewerPart ) {
|
||||
waveformViewerPart.addDisposeListener( new DisposeListener() {
|
||||
@Override
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
Control control = treeViewer.getControl();
|
||||
// check if widget is already disposed (f.ex. because of workbench closing)
|
||||
if (control == null || control.isDisposed()) { //if so: do nothing
|
||||
}else { //reset tree- and tableviewer
|
||||
resetTreeViewer();
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
this.waveformViewerPart=waveformViewerPart;
|
||||
IWaveformDb database = waveformViewerPart.getDatabase();
|
||||
Object input = treeViewer.getInput();
|
||||
if(input!=null && input instanceof List<?>){
|
||||
IWaveformDb db = ((List<IWaveformDb>)input).get(0);
|
||||
if(db==database) return; // do nothing if old and new database is the same
|
||||
((List<IWaveformDb>)input).get(0).removePropertyChangeListener(treeViewerPCL);
|
||||
}
|
||||
treeViewer.setInput(Arrays.asList(database.isLoaded()?new IWaveformDb[]{database}:new IWaveformDb[]{new LoadingWaveformDb()}));
|
||||
Object state=this.waveformViewerPart.retrieveDesignBrowerState();
|
||||
if(state!=null && state instanceof DBState)
|
||||
((DBState)state).apply();
|
||||
else
|
||||
txTableViewer.setInput(null);
|
||||
// Set up the tree viewer
|
||||
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();
|
||||
if(part!=null && part.getObject() != this && selection!=null){
|
||||
if( selection instanceof IStructuredSelection) {
|
||||
Object object= ((IStructuredSelection)selection).getFirstElement();
|
||||
if(object instanceof IHierNode&& ((IHierNode)object).getChildNodes().size()!=0)
|
||||
txTableViewer.setInput(object);
|
||||
otherSelectionCount = (object instanceof IWaveform || object instanceof ITx)?1:0;
|
||||
}
|
||||
}
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update buttons.
|
||||
*/
|
||||
private void updateButtons() {
|
||||
if(txTableViewer!=null && !insertItem.isDisposed() && !appendItem.isDisposed()){
|
||||
AddWaveformHandler myHandler = new AddWaveformHandler();
|
||||
Object result = runCommand(myHandler, CanExecute.class, "after", false); //$NON-NLS-1$
|
||||
appendItem.setEnabled(result instanceof Boolean && (Boolean)result);
|
||||
result = runCommand(myHandler, CanExecute.class, "before", false); //$NON-NLS-1$
|
||||
insertItem.setEnabled(result instanceof Boolean && (Boolean)result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class StreamTableFilter.
|
||||
*/
|
||||
public class StreamTableFilter extends ViewerFilter {
|
||||
|
||||
/** The search string. */
|
||||
private String searchString;
|
||||
private Pattern pattern;
|
||||
|
||||
/**
|
||||
* Sets the search text.
|
||||
*
|
||||
* @param s the new search text
|
||||
*/
|
||||
public void setSearchText(String s) {
|
||||
try {
|
||||
pattern = Pattern.compile(".*" + s + ".*"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
this.searchString = ".*" + s + ".*"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} catch (PatternSyntaxException e) {}
|
||||
}
|
||||
|
||||
/* (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) {
|
||||
return true;
|
||||
}
|
||||
if(element instanceof IWaveform) {
|
||||
if (pattern.matcher(((IWaveform) element).getName()).matches())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class StreamTTreeFilter extends ViewerFilter {
|
||||
|
||||
/** The search string. */
|
||||
private String searchString;
|
||||
private Pattern pattern;
|
||||
|
||||
/**
|
||||
* Sets the search text.
|
||||
*
|
||||
* @param s the new search text
|
||||
*/
|
||||
public void setSearchText(String s) {
|
||||
try {
|
||||
pattern = Pattern.compile(".*" + s + ".*");
|
||||
this.searchString = ".*" + s + ".*"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} catch (PatternSyntaxException e) {}
|
||||
|
||||
}
|
||||
|
||||
/* (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) {
|
||||
return selectTreePath(viewer, new TreePath(new Object[] { parentElement }), element);
|
||||
}
|
||||
|
||||
private boolean selectTreePath(Viewer viewer, TreePath parentPath, Object element) {
|
||||
// Cut off children of elements that are shown repeatedly.
|
||||
for (int i = 0; i < parentPath.getSegmentCount() - 1; i++) {
|
||||
if (element.equals(parentPath.getSegment(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(viewer instanceof TreeViewer)) {
|
||||
return true;
|
||||
}
|
||||
if (searchString == null || searchString.length() == 0) {
|
||||
return true;
|
||||
}
|
||||
TreeViewer treeViewer = (TreeViewer) viewer;
|
||||
Boolean matchingResult = isMatchingOrNull(element);
|
||||
if (matchingResult != null) {
|
||||
return matchingResult;
|
||||
}
|
||||
return hasUnfilteredChild(treeViewer, parentPath, element);
|
||||
}
|
||||
|
||||
Boolean isMatchingOrNull(Object element) {
|
||||
if(element instanceof IWaveform) {
|
||||
if (pattern.matcher(((IWaveform) element).getName()).matches())
|
||||
return Boolean.TRUE;
|
||||
} else if(element instanceof IWaveformDb) {
|
||||
return Boolean.TRUE;
|
||||
} else if(element instanceof HierNode) {
|
||||
HierNode n = (HierNode) element;
|
||||
try {
|
||||
if (pattern.matcher(n.getFullName()).matches())
|
||||
return Boolean.TRUE;
|
||||
} catch (PatternSyntaxException e) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
} else {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
/* maybe children are matching */
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean hasUnfilteredChild(TreeViewer viewer, TreePath parentPath, Object element) {
|
||||
TreePath elementPath = parentPath.createChildPath(element);
|
||||
IContentProvider contentProvider = viewer.getContentProvider();
|
||||
Object[] children = contentProvider instanceof ITreePathContentProvider
|
||||
? ((ITreePathContentProvider) contentProvider).getChildren(elementPath)
|
||||
: ((ITreeContentProvider) contentProvider).getChildren(element);
|
||||
|
||||
/* avoid NPE + guard close */
|
||||
if (children == null || children.length == 0) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
if (selectTreePath(viewer, elementPath, children[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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];
|
||||
Object[] result = null;
|
||||
if (parent != null) {
|
||||
IStructuredContentProvider cp = (IStructuredContentProvider) viewer.getContentProvider();
|
||||
if (cp != null) {
|
||||
result = cp.getElements(parent);
|
||||
if(result==null) return new Object[0];
|
||||
for (int i = 0, n = result.length; i < n; ++i) {
|
||||
if(result[i]==null) return new Object[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
ViewerFilter[] filters = viewer.getFilters();
|
||||
if (filters != null) {
|
||||
for (ViewerFilter f:filters) {
|
||||
Object[] filteredResult = f.filter(viewer, parent, result);
|
||||
result = filteredResult;
|
||||
}
|
||||
}
|
||||
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(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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
txTableViewer.setSelection(tableSelection, true);
|
||||
|
||||
}
|
||||
|
||||
/** The expanded elements. */
|
||||
private Object[] expandedElements;
|
||||
|
||||
/** The tree selection. */
|
||||
private ISelection treeSelection;
|
||||
|
||||
/** The table selection. */
|
||||
private ISelection tableSelection;
|
||||
}
|
||||
};
|
@ -0,0 +1,482 @@
|
||||
package com.minres.scviewer.e4.application.parts;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.PathMatcher;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.dialogs.TrayDialog;
|
||||
import org.eclipse.jface.viewers.ArrayContentProvider;
|
||||
import org.eclipse.jface.viewers.ColumnLabelProvider;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.ILabelProviderListener;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.TableViewer;
|
||||
import org.eclipse.jface.viewers.TableViewerColumn;
|
||||
import org.eclipse.jface.viewers.TreePath;
|
||||
import org.eclipse.jface.viewers.TreeSelection;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.jface.viewers.ViewerComparator;
|
||||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.SashForm;
|
||||
import org.eclipse.swt.events.MouseAdapter;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Table;
|
||||
import org.eclipse.swt.widgets.TableColumn;
|
||||
import org.eclipse.swt.widgets.TableItem;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.swt.widgets.ToolBar;
|
||||
import org.eclipse.swt.widgets.ToolItem;
|
||||
import org.eclipse.wb.swt.ResourceManager;
|
||||
|
||||
public class FileBrowserDialog extends TrayDialog {
|
||||
|
||||
private Image folderImage;
|
||||
|
||||
private Image fileImage;
|
||||
|
||||
private Image dbImage;
|
||||
|
||||
File currentDirFile;
|
||||
|
||||
TreeViewer dirTreeViewer;
|
||||
|
||||
TableViewer tableViewer;
|
||||
|
||||
Text fileNameEntry;
|
||||
|
||||
Combo filterCombo;
|
||||
|
||||
FileTableComparator fileTableComparator;
|
||||
|
||||
private FileGlobber globber = new FileGlobber();
|
||||
|
||||
private FileGlobber imageGlobber = new FileGlobber();
|
||||
|
||||
private File selectedDir;
|
||||
|
||||
private List<File> selectedFiles;
|
||||
|
||||
String[] filterStrings = new String[] {"*"};
|
||||
|
||||
public FileBrowserDialog(Shell parentShell) {
|
||||
super(parentShell);
|
||||
folderImage=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/folder.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
dbImage=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/database.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
fileImage=ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/page_white.png"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
currentDirFile = new File(".");
|
||||
}
|
||||
|
||||
public void setFilterExtensions(String[] filterStrings) {
|
||||
if(filterStrings.length==0){
|
||||
globber = new FileGlobber();
|
||||
} else {
|
||||
globber= new FileGlobber(filterStrings[0]);
|
||||
imageGlobber = new FileGlobber(filterStrings[0]);
|
||||
if(filterCombo!=null) {
|
||||
filterCombo.setItems(filterStrings);
|
||||
filterCombo.select(0);
|
||||
filterCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT);
|
||||
}
|
||||
}
|
||||
this.filterStrings=filterStrings;
|
||||
}
|
||||
|
||||
public List<File> getSelectedFiles(){
|
||||
return selectedFiles;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createContents(Composite parent) {
|
||||
Control ret = super.createContents(parent);
|
||||
setDirSelection(currentDirFile.getAbsoluteFile().getParentFile());
|
||||
getButton(IDialogConstants.OK_ID).setEnabled(!tableViewer.getSelection().isEmpty());
|
||||
if(parent instanceof Shell) {
|
||||
Point size = ((Shell)parent).computeSize(SWT.DEFAULT, SWT.DEFAULT);
|
||||
((Shell)parent).setSize(size.x, 400);
|
||||
((Shell)parent).setText("Select database");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
Composite area = (Composite) super.createDialogArea(parent);
|
||||
final SashForm sashForm = new SashForm(area, SWT.HORIZONTAL);
|
||||
sashForm.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
|
||||
|
||||
dirTreeViewer = new TreeViewer(sashForm);
|
||||
dirTreeViewer.setContentProvider(new FileTreeContentProvider());
|
||||
dirTreeViewer.setLabelProvider(new FileTreeLabelProvider());
|
||||
dirTreeViewer.addSelectionChangedListener(event -> {
|
||||
IStructuredSelection sel = event.getStructuredSelection();
|
||||
File entry = (File) sel.getFirstElement();
|
||||
if(entry!=null && entry.isDirectory()) {
|
||||
selectedDir = entry;
|
||||
tableViewer.setInput(selectedDir.listFiles());
|
||||
}
|
||||
});
|
||||
dirTreeViewer.setInput("root");
|
||||
|
||||
final Composite tableViewerParent = new Composite(sashForm, SWT.NONE);
|
||||
GridLayout gridLayout = new GridLayout(1, true);
|
||||
gridLayout.horizontalSpacing=0;
|
||||
gridLayout.verticalSpacing=5;
|
||||
gridLayout.marginHeight=0;
|
||||
gridLayout.marginHeight=0;
|
||||
tableViewerParent.setLayout(gridLayout);
|
||||
final ToolBar toolBar = new ToolBar(tableViewerParent, SWT.HORIZONTAL |SWT.SHADOW_OUT);
|
||||
toolBar.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
|
||||
final ToolItem toolbarItemUp = new ToolItem(toolBar, SWT.PUSH);
|
||||
toolbarItemUp.setToolTipText("up one level");
|
||||
toolbarItemUp.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/arrow_up.png")); //$NON-NLS-1$ //$NON-NLS-2$);
|
||||
toolbarItemUp.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if(selectedDir.getParentFile()!=null) {
|
||||
selectedDir=selectedDir.getParentFile();
|
||||
tableViewer.setInput(selectedDir.listFiles());
|
||||
}
|
||||
}
|
||||
});
|
||||
tableViewer = new TableViewer(tableViewerParent, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
|
||||
tableViewer.getTable().setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
|
||||
tableViewer.addSelectionChangedListener(event -> {
|
||||
IStructuredSelection sel = event.getStructuredSelection();
|
||||
getButton(IDialogConstants.OK_ID).setEnabled(!sel.isEmpty());
|
||||
@SuppressWarnings("unchecked")
|
||||
Object text = sel.toList().stream().map(e -> ((File)e).getName()).collect(Collectors.joining(";"));
|
||||
fileNameEntry.setText(text.toString());
|
||||
});
|
||||
tableViewer.addDoubleClickListener(event -> {
|
||||
IStructuredSelection sel = tableViewer.getStructuredSelection();
|
||||
if(sel.isEmpty()) return;
|
||||
if(sel.size()==1) {
|
||||
File elem = (File) sel.getFirstElement();
|
||||
if(globber.matches(elem))
|
||||
buttonPressed(IDialogConstants.OK_ID);
|
||||
else if(elem.isDirectory())
|
||||
setDirSelection(elem);
|
||||
} else
|
||||
buttonPressed(IDialogConstants.OK_ID);
|
||||
});
|
||||
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
|
||||
tableViewer.getTable().setHeaderVisible(true);
|
||||
tableViewer.getTable().setLinesVisible(true);
|
||||
tableViewer.getTable().addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseDown(MouseEvent e) { mouseUp(e); }
|
||||
@Override
|
||||
public void mouseUp(MouseEvent e) {
|
||||
TableItem element = (TableItem)tableViewer.getTable().getItem(new Point(e.x, e.y));
|
||||
final Table table = tableViewer.getTable();
|
||||
if (element == null )//&& (e.stateMask&SWT.MODIFIER_MASK)!=0)
|
||||
table.deselectAll();
|
||||
else {
|
||||
int[] indices = table.getSelectionIndices();
|
||||
if(indices.length==1) {
|
||||
TableItem ti = table.getItem(indices[0]);
|
||||
if(!globber.matches(ti.getData()) && !((File)ti.getData()).isDirectory())
|
||||
table.deselect(indices[0]);
|
||||
} else {
|
||||
for (int idx : indices) {
|
||||
TableItem ti = table.getItem(idx);
|
||||
if(!globber.matches(ti.getData()))
|
||||
table.deselect(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
TableViewerColumn colName = new TableViewerColumn(tableViewer, SWT.NONE);
|
||||
colName.setLabelProvider(new FileTableLabelProvider() {
|
||||
@Override public String getText(Object element) { return ((File) element).getName(); }
|
||||
@Override public Image getImage(Object element){
|
||||
if(imageGlobber.matches(element)) return dbImage;
|
||||
return ((File) element).isDirectory()?folderImage:fileImage;
|
||||
}
|
||||
});
|
||||
colName.getColumn().setWidth(300);
|
||||
colName.getColumn().setText("Name");
|
||||
colName.getColumn().addSelectionListener(getSelectionAdapter(colName.getColumn(), 0));
|
||||
|
||||
TableViewerColumn colSize = new TableViewerColumn(tableViewer, SWT.RIGHT);
|
||||
colSize.setLabelProvider(new FileTableLabelProvider() {
|
||||
@Override public String getText(Object element) { return String.format("%d", ((File) element).length()); }
|
||||
});
|
||||
colSize.getColumn().setWidth(100);
|
||||
colSize.getColumn().setText("Size");
|
||||
colSize.getColumn().addSelectionListener(getSelectionAdapter(colSize.getColumn(), 1));
|
||||
|
||||
TableViewerColumn colEmpty = new TableViewerColumn(tableViewer, SWT.CENTER);
|
||||
colEmpty.setLabelProvider(new FileTableLabelProvider() {
|
||||
@Override public String getText(Object element) { return ""; }
|
||||
});
|
||||
//colEmpty.getColumn().setWidth(200);
|
||||
colEmpty.getColumn().setText("");
|
||||
|
||||
fileTableComparator = new FileTableComparator();
|
||||
tableViewer.setComparator(fileTableComparator);
|
||||
tableViewer.addFilter(new FileTableFilter());
|
||||
|
||||
Composite bottomBar = new Composite(tableViewerParent, SWT.NONE);
|
||||
bottomBar.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
|
||||
GridLayout gridLayoutBottom = new GridLayout(2, false);
|
||||
gridLayoutBottom.horizontalSpacing=0;
|
||||
gridLayoutBottom.verticalSpacing=0;
|
||||
gridLayoutBottom.marginHeight=0;
|
||||
gridLayoutBottom.marginWidth=0;
|
||||
bottomBar.setLayout(gridLayoutBottom);
|
||||
|
||||
fileNameEntry = new Text(bottomBar, SWT.BORDER);
|
||||
fileNameEntry.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
|
||||
fileNameEntry.setEditable(false); //TODO: temporary disabled
|
||||
fileNameEntry.setEnabled(false);
|
||||
|
||||
filterCombo = new Combo(bottomBar, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
|
||||
filterCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
|
||||
filterCombo.setItems(filterStrings);
|
||||
filterCombo.select(0);
|
||||
filterCombo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
globber= new FileGlobber(filterCombo.getText());
|
||||
tableViewer.setInput(selectedDir.listFiles());
|
||||
}
|
||||
});
|
||||
sashForm.setWeights(new int[]{3, 3});
|
||||
return area;
|
||||
}
|
||||
|
||||
private SelectionAdapter getSelectionAdapter(final TableColumn column, final int index) {
|
||||
SelectionAdapter selectionAdapter = new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
fileTableComparator.setColumn(index);
|
||||
int dir = fileTableComparator.getDirection();
|
||||
tableViewer.getTable().setSortDirection(dir);
|
||||
tableViewer.getTable().setSortColumn(column);
|
||||
tableViewer.refresh();
|
||||
}
|
||||
};
|
||||
return selectionAdapter;
|
||||
}
|
||||
|
||||
private void setDirSelection(File f) {
|
||||
ArrayList<File> fileTree = getParentDirList(f);
|
||||
TreeSelection selection = new TreeSelection(new TreePath(fileTree.toArray()));
|
||||
dirTreeViewer.setSelection(selection, true);
|
||||
}
|
||||
|
||||
private ArrayList<File> getParentDirList(File actual){
|
||||
if(actual==null)
|
||||
return new ArrayList<>();
|
||||
else {
|
||||
ArrayList<File> l = getParentDirList(actual.getParentFile());
|
||||
l.add(actual);
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isResizable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// save content of the Text fields because they get disposed
|
||||
// as soon as the Dialog closes
|
||||
@SuppressWarnings("unchecked")
|
||||
private void saveInput() {
|
||||
selectedFiles= tableViewer.getStructuredSelection().toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void okPressed() {
|
||||
saveInput();
|
||||
super.okPressed();
|
||||
}
|
||||
|
||||
class FileGlobber {
|
||||
|
||||
List<PathMatcher> matchers;
|
||||
|
||||
public FileGlobber() {
|
||||
matchers = new ArrayList<>(); }
|
||||
|
||||
public FileGlobber(String expr) {
|
||||
ArrayList<PathMatcher> m = new ArrayList<>();
|
||||
if(expr.length()>0) {
|
||||
String[] tok = expr.split(";");
|
||||
for (String string : tok) {
|
||||
m.add(FileSystems.getDefault().getPathMatcher("glob:**/"+string));
|
||||
}
|
||||
}
|
||||
matchers = m;
|
||||
}
|
||||
|
||||
public boolean matches(Object f) {
|
||||
assert(f instanceof File);
|
||||
if(matchers.size()==0) return true;
|
||||
for (PathMatcher m : matchers) {
|
||||
if(m.matches(((File)f).toPath())) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class FileTreeContentProvider implements ITreeContentProvider {
|
||||
public Object[] getChildren(Object arg0) {
|
||||
File[] entries = ((File) arg0).listFiles();
|
||||
if(entries != null) {
|
||||
List<File> res = Arrays.stream(entries)
|
||||
.filter(file -> !(file.isFile()||file.getName().startsWith(".") ||globber.matches(file)))
|
||||
.sorted(new Comparator<File>(){
|
||||
public int compare(File f1, File f2){return f1.getName().compareTo(f2.getName());}
|
||||
})
|
||||
.collect(Collectors.toList()); ;
|
||||
return res.toArray();
|
||||
} else
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
public Object getParent(Object arg0) {
|
||||
return ((File) arg0).getParentFile();
|
||||
}
|
||||
|
||||
public boolean hasChildren(Object arg0) {
|
||||
Object[] obj = getChildren(arg0);
|
||||
return obj == null ? false : obj.length > 0;
|
||||
}
|
||||
|
||||
public Object[] getElements(Object arg0) {
|
||||
return File.listRoots();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
|
||||
}
|
||||
}
|
||||
|
||||
class FileTreeLabelProvider implements ILabelProvider {
|
||||
private List<ILabelProviderListener> listeners;
|
||||
|
||||
private Image file;
|
||||
|
||||
private Image dir;
|
||||
|
||||
public FileTreeLabelProvider() {
|
||||
listeners = new ArrayList<ILabelProviderListener>();
|
||||
}
|
||||
|
||||
public Image getImage(Object arg0) {
|
||||
return ((File) arg0).isDirectory() ? folderImage : file;
|
||||
}
|
||||
|
||||
public String getText(Object arg0) {
|
||||
File f = (File)arg0;
|
||||
return f.getName().length() == 0? f.getPath() : f.getName();
|
||||
}
|
||||
|
||||
public void addListener(ILabelProviderListener arg0) {
|
||||
listeners.add(arg0);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
// Dispose the images
|
||||
if (dir != null)
|
||||
dir.dispose();
|
||||
if (file != null)
|
||||
file.dispose();
|
||||
}
|
||||
|
||||
public boolean isLabelProperty(Object arg0, String arg1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removeListener(ILabelProviderListener arg0) {
|
||||
listeners.remove(arg0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class FileTableFilter extends ViewerFilter {
|
||||
|
||||
@Override
|
||||
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||
File p = (File) element;
|
||||
return !p.getName().startsWith(".");
|
||||
}
|
||||
}
|
||||
|
||||
public class FileTableComparator extends ViewerComparator {
|
||||
private int propertyIndex = 0;
|
||||
private boolean descending = false;
|
||||
|
||||
public FileTableComparator() {
|
||||
}
|
||||
|
||||
public int getDirection() {
|
||||
return descending ? SWT.DOWN : SWT.UP;
|
||||
}
|
||||
|
||||
public void setColumn(int column) {
|
||||
descending = column == this.propertyIndex?!descending : false;
|
||||
this.propertyIndex = column;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(Viewer viewer, Object e1, Object e2) {
|
||||
File p1 = (File) e1;
|
||||
File p2 = (File) e2;
|
||||
int rc = 0;
|
||||
switch (propertyIndex) {
|
||||
case 0:
|
||||
rc = p1.getName().compareTo(p2.getName());
|
||||
break;
|
||||
case 1:
|
||||
rc = Long.valueOf(p1.length()).compareTo(p2.length());
|
||||
break;
|
||||
default:
|
||||
rc = 0;
|
||||
}
|
||||
// If descending order, flip the direction
|
||||
return descending? -rc : rc;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class FileTableLabelProvider extends ColumnLabelProvider {
|
||||
@Override
|
||||
public Color getBackground(Object element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getForeground(Object element) {
|
||||
return globber.matches(element) || ((File)element).isDirectory()? null: ResourceManager.getColor(SWT.COLOR_GRAY);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,88 @@
|
||||
package com.minres.scviewer.e4.application.parts;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.minres.scviewer.database.IHierNode;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
import com.minres.scviewer.e4.application.Messages;
|
||||
|
||||
public class LoadingWaveformDb implements IWaveformDb {
|
||||
|
||||
private final String label = Messages.LoadingWaveformDb_0;
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFullName() {
|
||||
return label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentName(String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IHierNode> getChildNodes() {
|
||||
return new ArrayList<IHierNode>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(IHierNode o) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getMaxTime() {
|
||||
return new Long(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWaveform getStreamByName(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IWaveform> getAllWaves() {
|
||||
return new ArrayList<IWaveform>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationType> getAllRelationTypes() {
|
||||
return new ArrayList<RelationType>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean load(File inp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*******************************************************************************
|
||||
* 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.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) {}
|
||||
}
|
@ -0,0 +1,748 @@
|
||||
/*******************************************************************************
|
||||
* 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.parts;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Vector;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.eclipse.e4.core.di.annotations.Optional;
|
||||
import org.eclipse.e4.core.services.events.IEventBroker;
|
||||
import org.eclipse.e4.ui.di.Focus;
|
||||
import org.eclipse.e4.ui.di.UIEventTopic;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||
import org.eclipse.e4.ui.services.IServiceConstants;
|
||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
|
||||
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
|
||||
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
|
||||
import org.eclipse.jface.viewers.DoubleClickEvent;
|
||||
import org.eclipse.jface.viewers.IDoubleClickListener;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.ITreeViewerListener;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.StyledString;
|
||||
import org.eclipse.jface.viewers.TreeExpansionEvent;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.jface.viewers.TreeViewerColumn;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.jface.viewers.ViewerComparator;
|
||||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ControlAdapter;
|
||||
import org.eclipse.swt.events.ControlEvent;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
|
||||
import com.minres.scviewer.database.DataType;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxAttribute;
|
||||
import com.minres.scviewer.database.ITxRelation;
|
||||
import com.minres.scviewer.e4.application.Messages;
|
||||
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;
|
||||
|
||||
/** 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));
|
||||
|
||||
nameFilter = new Text(parent, SWT.BORDER);
|
||||
nameFilter.setMessage(Messages.TransactionDetails_0);
|
||||
nameFilter.addModifyListener(new ModifyListener() {
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e) {
|
||||
attributeFilter.setSearchText(((Text) e.widget).getText());
|
||||
treeViewer.refresh();
|
||||
treeViewer.expandAll(true);
|
||||
}
|
||||
});
|
||||
|
||||
nameFilter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
attributeFilter = new TxAttributeFilter();
|
||||
viewSorter = new TxAttributeViewerSorter();
|
||||
|
||||
treeViewer = new TreeViewer(parent);
|
||||
treeViewer.setContentProvider(new TransactionTreeContentProvider());
|
||||
treeViewer.setLabelProvider(new TxPropertiesLabelProvider());
|
||||
treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
treeViewer.addFilter(attributeFilter);
|
||||
treeViewer.setComparator(viewSorter);
|
||||
treeViewer.setAutoExpandLevel(2);
|
||||
treeViewer.addTreeListener(new ITreeViewerListener() {
|
||||
|
||||
@Override
|
||||
public void treeCollapsed(TreeExpansionEvent event) {
|
||||
treeViewer.getSelection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void treeExpanded(TreeExpansionEvent event) {
|
||||
treeViewer.getSelection();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Set up the table
|
||||
Tree tree = treeViewer.getTree();
|
||||
tree.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
// Add the name column
|
||||
col1 = new TreeViewerColumn(treeViewer, SWT.NONE);
|
||||
col1.getColumn().setText(Messages.TransactionDetails_1);
|
||||
col1.getColumn().setResizable(true);
|
||||
col1.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(AttributeLabelProvider.NAME)));
|
||||
col1.getColumn().addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
((TxAttributeViewerSorter) treeViewer.getComparator()).doSort(COLUMN_FIRST);
|
||||
treeViewer.refresh();
|
||||
}
|
||||
});
|
||||
// Add the type column
|
||||
col2 = new TreeViewerColumn(treeViewer, SWT.NONE);
|
||||
col2.getColumn().setText(Messages.TransactionDetails_2);
|
||||
col2.getColumn().setResizable(true);
|
||||
col2.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(AttributeLabelProvider.TYPE)));
|
||||
col2.getColumn().addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
((TxAttributeViewerSorter) treeViewer.getComparator()).doSort(COLUMN_SECOND);
|
||||
treeViewer.refresh();
|
||||
}
|
||||
});
|
||||
// Add the value column
|
||||
col3 = new TreeViewerColumn(treeViewer, SWT.NONE);
|
||||
col3.getColumn().setText(Messages.TransactionDetails_3);
|
||||
col3.getColumn().setResizable(true);
|
||||
col3.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(AttributeLabelProvider.VALUE)));
|
||||
col3.getColumn().addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
((TxAttributeViewerSorter) treeViewer.getComparator()).doSort(COLUMN_SECOND);
|
||||
treeViewer.refresh();
|
||||
}
|
||||
});
|
||||
// Pack the columns
|
||||
// for (int i = 0, n = table.getColumnCount(); i < n; i++) {
|
||||
// table.getColumn(i).pack();
|
||||
// }
|
||||
|
||||
// Turn on the header and the lines
|
||||
tree.setHeaderVisible(true);
|
||||
tree.setLinesVisible(true);
|
||||
|
||||
treeViewer.addDoubleClickListener(new IDoubleClickListener(){
|
||||
|
||||
@Override
|
||||
public void doubleClick(DoubleClickEvent event) {
|
||||
ISelection selection = treeViewer.getSelection();
|
||||
if(selection instanceof IStructuredSelection){
|
||||
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
|
||||
Object selected = structuredSelection.getFirstElement();
|
||||
if(selected instanceof Object[]){
|
||||
Object[] selectedArray = (Object[]) selected;
|
||||
if(selectedArray.length==3 && selectedArray[2] instanceof ITx){
|
||||
waveformViewerPart.setSelection(new StructuredSelection(selectedArray[2]));
|
||||
setInput(selectedArray[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
parent.addControlListener(new ControlAdapter() {
|
||||
public void controlResized(ControlEvent e) {
|
||||
Tree table = treeViewer.getTree();
|
||||
Rectangle area = parent.getClientArea();
|
||||
Point preferredSize = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
|
||||
int width = area.width - 2*table.getBorderWidth();
|
||||
if (preferredSize.y > area.height + table.getHeaderHeight()) {
|
||||
// Subtract the scrollbar width from the total column width
|
||||
// if a vertical scrollbar will be required
|
||||
Point vBarSize = table.getVerticalBar().getSize();
|
||||
width -= vBarSize.x;
|
||||
}
|
||||
Point oldSize = table.getSize();
|
||||
if (oldSize.x > area.width) {
|
||||
// table is getting smaller so make the columns
|
||||
// smaller first and then resize the table to
|
||||
// match the client area width
|
||||
col1.getColumn().setWidth(width/3);
|
||||
col2.getColumn().setWidth(width/4);
|
||||
col3.getColumn().setWidth(width - col1.getColumn().getWidth());
|
||||
table.setSize(area.width, area.height);
|
||||
} else {
|
||||
// table is getting bigger so make the table
|
||||
// bigger first and then make the columns wider
|
||||
// to match the client area width
|
||||
table.setSize(area.width, area.height);
|
||||
col1.getColumn().setWidth(width/3);
|
||||
col2.getColumn().setWidth(width/4);
|
||||
col3.getColumn().setWidth(width - col1.getColumn().getWidth()- col2.getColumn().getWidth());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(WaveformViewer.ACTIVE_WAVEFORMVIEW) WaveformViewer part) {
|
||||
this.waveformViewerPart=part;
|
||||
}
|
||||
|
||||
public void setInput(Object object) {
|
||||
if(object instanceof ITx){
|
||||
ArrayList<String> names = new ArrayList<>();
|
||||
int indexInParent=getTopItemHier(names);
|
||||
ArrayList<Boolean> states = getExpandedState(treeViewer.getTree().getItems());
|
||||
treeViewer.setInput(object);
|
||||
setExpandedState(treeViewer.getTree().getItems(), states);
|
||||
setTopItemFromHier(names, indexInParent);
|
||||
} else {
|
||||
treeViewer.setInput(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setExpandedState(TreeItem[] treeItems, ArrayList<Boolean> states) {
|
||||
for (int i = 0; i < treeItems.length; i++) {
|
||||
treeItems[i].setExpanded(states.size()>i?states.get(i):true);
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<Boolean> getExpandedState(TreeItem[] items){
|
||||
ArrayList<Boolean> ret = new ArrayList<>();
|
||||
for (TreeItem treeItem : items)
|
||||
ret.add(treeItem.getItemCount()>0?treeItem.getExpanded():true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private int getTopItemHier(ArrayList<String> names){
|
||||
int indexInParent=-1;
|
||||
TreeItem obj = treeViewer.getTree().getTopItem();
|
||||
if(obj!=null) {
|
||||
names.add(0, obj.getText(0));
|
||||
if(obj.getParentItem()!=null) {
|
||||
TreeItem pobj=obj.getParentItem();
|
||||
names.add(0, pobj.getText(0));
|
||||
TreeItem[] items = pobj.getItems();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if(items[i]==obj) {
|
||||
indexInParent=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return indexInParent;
|
||||
}
|
||||
|
||||
private void setTopItemFromHier(ArrayList<String> names, int indexInParent) {
|
||||
if(indexInParent<0 || names.size()==0 ) return;
|
||||
TreeItem selItem=null;
|
||||
for (TreeItem item : treeViewer.getTree().getItems()) { // find item from category
|
||||
if(item.getText(0).equals(names.get(0))) {
|
||||
if(names.size()>1) { // if we had an attribute as top item
|
||||
TreeItem[] subItems=item.getItems();
|
||||
for(TreeItem it : subItems) { // try to align by name
|
||||
if(it.getText(0).equals(names.get(1))) {
|
||||
selItem=it;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(selItem==null && indexInParent>=0 && subItems.length>0) // name based match failed so try to use position
|
||||
selItem=subItems[subItems.length>indexInParent?indexInParent:subItems.length-1];
|
||||
}
|
||||
if(selItem==null) // no match in attributes so set the category as top item
|
||||
selItem=item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(selItem!=null)
|
||||
treeViewer.getTree().setTopItem(selItem);
|
||||
}
|
||||
/**
|
||||
* Sets the selection.
|
||||
*
|
||||
* @param selection the new selection
|
||||
*/
|
||||
@Inject
|
||||
public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection, EPartService partService){
|
||||
// only react if selection is actually from the WaveformViewer and nothing else
|
||||
MPart part = partService.getActivePart();
|
||||
if( part == null || ! (part.getObject() instanceof WaveformViewer ) )
|
||||
return;
|
||||
if(treeViewer!=null && selection!=null && !treeViewer.getTree().isDisposed()){
|
||||
if( selection instanceof IStructuredSelection) {
|
||||
setInput(((IStructuredSelection)selection).getFirstElement());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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())); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
sb.append(" - ").append(timeToString(tx.getEndTime())).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class TxAttributeViewerSorter.
|
||||
*/
|
||||
class TxAttributeViewerSorter extends ViewerComparator {
|
||||
|
||||
/** 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 the column
|
||||
*/
|
||||
public void doSort(int column) {
|
||||
if (column == this.column) {
|
||||
// Same column as last sort; toggle the direction
|
||||
direction = 1 - direction;
|
||||
} else {
|
||||
// New column; do an ascending sort
|
||||
this.column = column;
|
||||
direction = ASCENDING;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the object for sorting.
|
||||
*
|
||||
* @param viewer the viewer
|
||||
* @param e1 the e1
|
||||
* @param e2 the e2
|
||||
* @return the int
|
||||
*/
|
||||
public int compare(Viewer viewer, Object e1, Object e2) {
|
||||
int rc = 0;
|
||||
if(e1 instanceof ITxAttribute && e2 instanceof ITxAttribute){
|
||||
ITxAttribute p1 = (ITxAttribute) e1;
|
||||
ITxAttribute p2 = (ITxAttribute) e2;
|
||||
// Determine which column and do the appropriate sort
|
||||
switch (column) {
|
||||
case COLUMN_FIRST:
|
||||
rc = getComparator().compare(p1.getName(), p2.getName());
|
||||
break;
|
||||
case COLUMN_SECOND:
|
||||
rc = getComparator().compare(p1.getDataType().name(), p2.getDataType().name());
|
||||
break;
|
||||
case COLUMN_THIRD:
|
||||
rc = getComparator().compare(p1.getValue().toString(), p2.getValue().toString());
|
||||
break;
|
||||
}
|
||||
// If descending order, flip the direction
|
||||
if (direction == DESCENDING) rc = -rc;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
/* (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) {
|
||||
return true;
|
||||
}
|
||||
if(element instanceof TreeNode) {
|
||||
return true;
|
||||
}
|
||||
if(element instanceof ITxAttribute){
|
||||
try {
|
||||
return (((ITxAttribute) element).getName().toLowerCase().matches(searchString.toLowerCase()));
|
||||
} catch (PatternSyntaxException e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(element instanceof Object[]) {
|
||||
try {
|
||||
return (((Object[])element)[0]).toString().toLowerCase().matches(searchString.toLowerCase());
|
||||
} catch (PatternSyntaxException e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Enum Type.
|
||||
*/
|
||||
enum Type {
|
||||
PROPS, /** The props. */
|
||||
ATTRS, /** The attrs. */
|
||||
IN_REL, /** The in rel. */
|
||||
OUT_REL,/** The out rel. */
|
||||
HIER
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class TreeNode.
|
||||
*/
|
||||
class TreeNode{
|
||||
|
||||
/** The type. */
|
||||
public Type type;
|
||||
|
||||
/** The element. */
|
||||
public ITx element;
|
||||
|
||||
private String hier_path;
|
||||
/**
|
||||
* 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;
|
||||
this.hier_path="";
|
||||
}
|
||||
|
||||
public TreeNode(ITx element, String path){
|
||||
this.element=element;
|
||||
this.type=Type.HIER;
|
||||
this.hier_path=path;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString(){
|
||||
switch(type){
|
||||
case PROPS: return Messages.TransactionDetails_10;
|
||||
case ATTRS: return Messages.TransactionDetails_11;
|
||||
case IN_REL: return Messages.TransactionDetails_12;
|
||||
case OUT_REL: return Messages.TransactionDetails_13;
|
||||
case HIER:{
|
||||
String[] tokens = hier_path.split("\\.");
|
||||
return tokens[tokens.length-1];
|
||||
}
|
||||
}
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public Object[] getAttributeListForHier() {
|
||||
if(childs==null) {
|
||||
Map<String, Object> res = element.getAttributes().stream()
|
||||
.filter(txAttr -> txAttr.getName().startsWith(hier_path))
|
||||
.map(txAttr -> {
|
||||
String target = hier_path.length()==0?txAttr.getName():txAttr.getName().replace(hier_path+'.', "");
|
||||
String[] tokens = target.split("\\.");
|
||||
if(tokens.length==1)
|
||||
return new AbstractMap.SimpleEntry<>(tokens[0], txAttr);
|
||||
else
|
||||
return new AbstractMap.SimpleEntry<>(tokens[0], new TreeNode(element, hier_path.length()>0?hier_path+"."+tokens[0]:tokens[0]));
|
||||
})
|
||||
.collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue(), (first, second) -> first));
|
||||
childs = new TreeMap<String, Object>(res).values().toArray();
|
||||
}
|
||||
return childs;
|
||||
}
|
||||
|
||||
private Object[] childs=null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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[]{
|
||||
new TreeNode((ITx)element, Type.PROPS),
|
||||
new TreeNode((ITx)element, Type.ATTRS),
|
||||
new TreeNode((ITx)element, Type.IN_REL),
|
||||
new TreeNode((ITx)element, Type.OUT_REL)
|
||||
};
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Object[] getChildren(Object element) {
|
||||
if(element instanceof TreeNode){
|
||||
TreeNode propertyHolder=(TreeNode) element;
|
||||
if(propertyHolder.type == Type.PROPS){
|
||||
return new Object[][]{
|
||||
{Messages.TransactionDetails_1, Messages.TransactionDetails_16, propertyHolder.element.getStream().getFullName()},
|
||||
{Messages.TransactionDetails_2, Messages.TransactionDetails_16, propertyHolder.element.getGenerator().getName()},
|
||||
{Messages.TransactionDetails_19, Messages.TransactionDetails_20, timeToString(propertyHolder.element.getBeginTime())},
|
||||
{Messages.TransactionDetails_21, Messages.TransactionDetails_20, timeToString(propertyHolder.element.getEndTime())}
|
||||
};
|
||||
}else if(propertyHolder.type == Type.ATTRS || propertyHolder.type == Type.HIER)
|
||||
return propertyHolder.getAttributeListForHier();
|
||||
else if(propertyHolder.type == Type.IN_REL){
|
||||
Vector<Object[] > res = new Vector<>();
|
||||
for(ITxRelation rel:propertyHolder.element.getIncomingRelations()){
|
||||
res.add(new Object[]{
|
||||
rel.getRelationType(),
|
||||
rel.getSource().getGenerator().getName(),
|
||||
rel.getSource()});
|
||||
}
|
||||
return res.toArray();
|
||||
} else if(propertyHolder.type == Type.OUT_REL){
|
||||
Vector<Object[] > res = new Vector<>();
|
||||
for(ITxRelation rel:propertyHolder.element.getOutgoingRelations()){
|
||||
res.add(new Object[]{
|
||||
rel.getRelationType(),
|
||||
rel.getTarget().getGenerator().getName(),
|
||||
rel.getTarget()});
|
||||
}
|
||||
return res.toArray();
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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){
|
||||
case NAME:
|
||||
if (element instanceof ITxAttribute) {
|
||||
ITxAttribute attribute = (ITxAttribute) element;
|
||||
String[] tokens = attribute.getName().split("\\.");
|
||||
return new StyledString(tokens[tokens.length-1]);
|
||||
}else if (element instanceof ITxRelation) {
|
||||
return new StyledString(Messages.TransactionDetails_4);
|
||||
}else if(element instanceof Object[]){
|
||||
Object[] elements = (Object[]) element;
|
||||
return new StyledString(elements[field].toString());
|
||||
} else
|
||||
return new StyledString(element.toString());
|
||||
case TYPE:
|
||||
if (element instanceof ITxAttribute) {
|
||||
ITxAttribute attribute = (ITxAttribute) element;
|
||||
return new StyledString(attribute.getDataType().toString());
|
||||
}else if(element instanceof Object[]){
|
||||
Object[] elements = (Object[]) element;
|
||||
return new StyledString(elements[field].toString());
|
||||
}else
|
||||
return new StyledString(""); //$NON-NLS-1$
|
||||
default:
|
||||
if (element instanceof ITxAttribute) {
|
||||
ITxAttribute attribute = (ITxAttribute) element;
|
||||
String value = attribute.getValue().toString();
|
||||
if((DataType.UNSIGNED == attribute.getDataType() || DataType.INTEGER==attribute.getDataType()) && !"0".equals(value)) {
|
||||
try {
|
||||
value += " [0x"+Long.toHexString(Long.parseLong(attribute.getValue().toString()))+"]";
|
||||
} catch(NumberFormatException e) { }
|
||||
}
|
||||
return new StyledString(value);
|
||||
}else if(element instanceof Object[]){
|
||||
Object[] elements = (Object[]) element;
|
||||
Object o = elements[field];
|
||||
if(o instanceof ITx) {
|
||||
ITx tx = (ITx)o;
|
||||
return new StyledString(txToString(tx)+" ("+tx.getStream().getFullName()+")");
|
||||
} else
|
||||
return new StyledString(o.toString());
|
||||
} else if(element instanceof ITx){
|
||||
return new StyledString(txToString((ITx) element));
|
||||
}else
|
||||
return new StyledString(""); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user