2015-10-22 00:05:29 +02:00
|
|
|
/*******************************************************************************
|
2015-10-22 00:25:12 +02:00
|
|
|
* Copyright (c) 2015 MINRES Technologies GmbH and others.
|
2015-10-22 00:05:29 +02:00
|
|
|
* 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:
|
2015-10-22 00:25:12 +02:00
|
|
|
* MINRES Technologies GmbH - initial API and implementation
|
2015-10-22 00:05:29 +02:00
|
|
|
*******************************************************************************/
|
|
|
|
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){
|
2015-11-30 22:16:29 +01:00
|
|
|
FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
|
|
|
|
// dialog.setFilterExtensions (new String []{"vcd", "txdb", "txlog"});
|
|
|
|
dialog.setFilterExtensions (new String []{"*.vcd;*.txdb;*.txlog"});
|
2015-10-22 00:05:29 +02:00
|
|
|
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);
|
2015-11-30 22:16:29 +01:00
|
|
|
// part.setContributionURI("bundleclass://com.minres.scviewer.e4.application/"+ WaveformViewerPart.class.getName());
|
2015-10-22 00:05:29 +02:00
|
|
|
MPart part = partService .createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer");
|
2015-11-03 22:29:42 +01:00
|
|
|
part.setLabel(file.getName());
|
2015-10-22 00:05:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|