Initial version of E4 based SC Viewer application

This commit is contained in:
2015-10-22 00:05:29 +02:00
parent a0e29e8ae2
commit 032ffea7c8
67 changed files with 4019 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
/*******************************************************************************
* Copyright (c) 2010 - 2013 IBM Corporation 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:
* IBM Corporation - initial API and implementation
* Lars Vogel <lars.Vogel@gmail.com> - Bug 419770
*******************************************************************************/
package com.minres.scviewer.e4.application.handlers;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
public class AboutHandler {
@Execute
public void execute(Shell shell) {
MessageDialog.openInformation(shell, "About", "Eclipse 4 Application example.");
}
}

View File

@@ -0,0 +1,29 @@
package com.minres.scviewer.e4.application.handlers;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.e4.application.parts.WaveformViewerPart;
public class DeleteWaveformHandler {
@CanExecute
public Boolean canExecute(ESelectionService selectionService){
Object o = selectionService.getSelection();
return o instanceof IWaveform<?>;
}
@Execute
public void execute(ESelectionService selectionService, MPart activePart) {
Object o = activePart.getObject();
Object sel = selectionService.getSelection();
if(o instanceof WaveformViewerPart && sel instanceof IWaveform<?>){
((WaveformViewerPart)o).removeStreamFromList((IWaveform<?>) sel);
}
}
}

View File

@@ -0,0 +1,38 @@
package com.minres.scviewer.e4.application.handlers;
import javax.inject.Named;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.e4.application.parts.WaveformViewerPart;
public class MoveWaveformHandler {
static final String PARAMETER_ID="com.minres.scviewer.e4.application.command.movewaveformupCommand.parameter.dir";
@CanExecute
public Boolean canExecute(ESelectionService selectionService){
Object o = selectionService.getSelection();
return o instanceof IWaveform<?> || o instanceof ITx;
}
@Execute
public void execute(@Named(PARAMETER_ID) String param, EPartService partService) {
MPart part = partService.getActivePart();
Object obj = part.getObject();
if(obj instanceof WaveformViewerPart){
if("up".equalsIgnoreCase(param))
((WaveformViewerPart)obj).moveSelected(-1);
else if("down".equalsIgnoreCase(param))
((WaveformViewerPart)obj).moveSelected(1);
}
}
}

View File

@@ -0,0 +1,40 @@
package com.minres.scviewer.e4.application.handlers;
import javax.inject.Named;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.swt.GotoDirection;
import com.minres.scviewer.e4.application.parts.WaveformViewerPart;
public class NavigateEvent {
final static String PARAMTER_ID="com.minres.scviewer.e4.application.command.navigateEventCommand.parameter.dir";
@CanExecute
public Boolean canExecute(ESelectionService selectionService){
Object o = selectionService.getSelection();
return o instanceof IWaveform<?> || o instanceof ITx;
}
@Execute
public void execute(@Named(PARAMTER_ID) String param, EPartService partService) {
// public void execute(EPartService partService) {
// String param="next";
MPart part = partService.getActivePart();
Object obj = part.getObject();
if(obj instanceof WaveformViewerPart){
if("next".equalsIgnoreCase(param))
((WaveformViewerPart)obj).moveCursor(GotoDirection.NEXT);
else if("prev".equalsIgnoreCase(param))
((WaveformViewerPart)obj).moveCursor(GotoDirection.PREV);
}
}
}

View File

@@ -0,0 +1,37 @@
package com.minres.scviewer.e4.application.handlers;
import javax.inject.Named;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.swt.GotoDirection;
import com.minres.scviewer.e4.application.parts.WaveformViewerPart;
public class NavigateTrans {
final static String PARAMTER_ID="com.minres.scviewer.e4.application.command.navigateTransCommand.parameter.dir";
@CanExecute
public Boolean canExecute(ESelectionService selectionService){
Object o = selectionService.getSelection();
return o instanceof ITx;
}
@Execute
public void execute(@Named(PARAMTER_ID) String param, EPartService partService) {
MPart part = partService.getActivePart();
Object obj = part.getObject();
if(obj instanceof WaveformViewerPart){
if("next".equalsIgnoreCase(param))
((WaveformViewerPart)obj).moveSelection(GotoDirection.NEXT);
else if("prev".equalsIgnoreCase(param))
((WaveformViewerPart)obj).moveSelection(GotoDirection.PREV);
}
}
}

View File

@@ -0,0 +1,61 @@
/*******************************************************************************
* Copyright (c) 2010 IBM Corporation 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:
* IBM Corporation - initial API and implementation
* Lars Vogel <lars.Vogel@gmail.com> - Bug 419770
*******************************************************************************/
package com.minres.scviewer.e4.application.handlers;
import java.io.File;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
public class OpenHandler {
@Execute
public void execute(Shell shell, MApplication app, EModelService modelService, EPartService partService){
FileDialog dialog = new FileDialog(shell, SWT.MULTI);
dialog.setFilterExtensions (new String []{"vcd", "txdb", "txlog"});
dialog.open();
String path = dialog.getFilterPath();
for(String fileName: dialog.getFileNames()){
File file = new File(path+File.separator+fileName);
if(file.exists()){
// MPart part = MBasicFactory.INSTANCE.createPart();
// part.setLabel(fileName);
// part.setContributionURI("bundleclass://com.minres.scviewer.e4.application/"+
// WaveformViewerPart.class.getName());
MPart part = partService .createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer");
part.setLabel(fileName);
MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app);
partStack.getChildren().add(part);
partService.showPart(part, PartState.ACTIVATE);
// Object o = part.getObject();
// if(o instanceof WaveformViewerPart)
// ((WaveformViewerPart)o).setPartInput(file);
IEclipseContext ctx=part.getContext();
ctx.modify("input", file);
ctx.declareModifiable("input");
}
}
}
}

View File

@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2010 - 2013 IBM Corporation 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:
* IBM Corporation - initial API and implementation
* Lars Vogel <lars.Vogel@gmail.com> - Bug 419770
*******************************************************************************/
package com.minres.scviewer.e4.application.handlers;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.workbench.IWorkbench;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
public class QuitHandler {
@Execute
public void execute(IWorkbench workbench, Shell shell){
if (MessageDialog.openConfirm(shell, "Confirmation",
"Do you want to exit?")) {
workbench.close();
}
}
}

View File

@@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2010 - 2013 IBM Corporation 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:
* IBM Corporation - initial API and implementation
* Lars Vogel <lars.Vogel@gmail.com> - Bug 419770
*******************************************************************************/
package com.minres.scviewer.e4.application.handlers;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
public class SaveHandler {
@CanExecute
public boolean canExecute(EPartService partService) {
if (partService != null) {
return !partService.getDirtyParts().isEmpty();
}
return false;
}
@Execute
public void execute(EPartService partService) {
partService.saveAll(false);
}
}

View File

@@ -0,0 +1,13 @@
package com.minres.scviewer.e4.application.handlers;
import org.eclipse.e4.core.di.annotations.Execute;
public class SelectAllHandler {
@Execute
public void execute() {
}
}

View File

@@ -0,0 +1,40 @@
package com.minres.scviewer.e4.application.handlers;
import javax.inject.Named;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import com.minres.scviewer.e4.application.parts.WaveformViewerPart;
public class ZoomHandler {
final static String PARAMTER_ID="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level";
@CanExecute
public boolean canExecute(EPartService partService) {
return true;
}
@Execute
public void execute(@Named(PARAMTER_ID) String level, EPartService partService) {
MPart part = partService.getActivePart();
Object obj = part.getObject();
if(obj instanceof WaveformViewerPart){
WaveformViewerPart waveformViewerPart = (WaveformViewerPart) obj;
int zoomLevel = waveformViewerPart.getZoomLevel();
if("in".equalsIgnoreCase(level))
waveformViewerPart.setZoomLevel(zoomLevel-1);
else if("out".equalsIgnoreCase(level))
waveformViewerPart.setZoomLevel(zoomLevel+1);
else if("fit".equalsIgnoreCase(level))
waveformViewerPart.setZoomFit();
}
}
}