add multi file feature
This commit is contained in:
parent
e8682e446b
commit
ec8d54dca3
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %Bundle-Name
|
Bundle-Name: %Bundle-Name
|
||||||
Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true
|
Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true
|
||||||
Bundle-Version: 2.2.0.qualifier
|
Bundle-Version: 2.3.0.qualifier
|
||||||
Bundle-Vendor: %Bundle-Vendor
|
Bundle-Vendor: %Bundle-Vendor
|
||||||
Require-Bundle: javax.inject;bundle-version="1.0.0",
|
Require-Bundle: javax.inject;bundle-version="1.0.0",
|
||||||
org.eclipse.core.runtime;bundle-version="3.11.1",
|
org.eclipse.core.runtime;bundle-version="3.11.1",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>com.minres.scviewer.e4.application</artifactId>
|
<artifactId>com.minres.scviewer.e4.application</artifactId>
|
||||||
<version>2.2.0-SNAPSHOT</version>
|
<version>2.3.0-SNAPSHOT</version>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.minres.scviewer</groupId>
|
<groupId>com.minres.scviewer</groupId>
|
||||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||||
|
|
|
@ -158,19 +158,27 @@ public class E4LifeCycle {
|
||||||
* @param name the name
|
* @param name the name
|
||||||
*/
|
*/
|
||||||
public void openViewForFile(String name){
|
public void openViewForFile(String name){
|
||||||
File file = new File(name);
|
File file = new File(getFirstFileName(name));
|
||||||
MPart part = partService.createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); //$NON-NLS-1$
|
MPart part = partService.createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); //$NON-NLS-1$
|
||||||
part.setLabel(file.getName());
|
part.setLabel(file.getName());
|
||||||
MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$
|
MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$
|
||||||
partStack.getChildren().add(part);
|
partStack.getChildren().add(part);
|
||||||
partService.showPart(part, PartState.ACTIVATE);
|
partService.showPart(part, PartState.ACTIVATE);
|
||||||
IEclipseContext ctx=part.getContext();
|
IEclipseContext ctx=part.getContext();
|
||||||
ctx.modify("input", file); //$NON-NLS-1$
|
ctx.modify("input", name); //$NON-NLS-1$
|
||||||
//ctx.declareModifiable("input"); //$NON-NLS-1$
|
//ctx.declareModifiable("input"); //$NON-NLS-1$
|
||||||
ctx.modify("config", confFile); //$NON-NLS-1$
|
ctx.modify("config", confFile); //$NON-NLS-1$
|
||||||
//ctx.declareModifiable("config"); //$NON-NLS-1$
|
//ctx.declareModifiable("config"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getFirstFileName(String name) {
|
||||||
|
if(name.contains(":")) {
|
||||||
|
String[] tokens = name.split(",");
|
||||||
|
return tokens[0];
|
||||||
|
} else
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
public void setConfigFile(String confFile) {
|
public void setConfigFile(String confFile) {
|
||||||
this.confFile=confFile;
|
this.confFile=confFile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package com.minres.scviewer.e4.application.handlers;
|
package com.minres.scviewer.e4.application.handlers;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||||
import org.eclipse.e4.core.di.annotations.Execute;
|
import org.eclipse.e4.core.di.annotations.Execute;
|
||||||
|
@ -33,19 +34,23 @@ public class OpenHandler {
|
||||||
dialog.setFilterExtensions (new String []{Messages.OpenHandler_0});
|
dialog.setFilterExtensions (new String []{Messages.OpenHandler_0});
|
||||||
dialog.open();
|
dialog.open();
|
||||||
String path = dialog.getFilterPath();
|
String path = dialog.getFilterPath();
|
||||||
|
ArrayList<File> files = new ArrayList<File>();
|
||||||
for(String fileName: dialog.getFileNames()){
|
for(String fileName: dialog.getFileNames()){
|
||||||
File file = new File(path+File.separator+fileName);
|
File file = new File(path+File.separator+fileName);
|
||||||
if(file.exists()){
|
if(file.exists())
|
||||||
|
files.add(file);
|
||||||
|
}
|
||||||
MPart part = partService .createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); //$NON-NLS-1$
|
MPart part = partService .createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); //$NON-NLS-1$
|
||||||
part.setLabel(file.getName());
|
part.setLabel(files.get(0).getName());
|
||||||
MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$
|
MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$
|
||||||
partStack.getChildren().add(part);
|
partStack.getChildren().add(part);
|
||||||
partService.showPart(part, PartState.ACTIVATE);
|
partService.showPart(part, PartState.ACTIVATE);
|
||||||
IEclipseContext ctx=part.getContext();
|
final IEclipseContext ctx=part.getContext();
|
||||||
ctx.modify("input", file); //$NON-NLS-1$
|
files.stream()
|
||||||
|
.map(x -> x.getAbsolutePath())
|
||||||
|
.reduce((s1, s2) -> s1 + "," + s2)
|
||||||
|
.ifPresent(s -> ctx.modify("input", s)); //$NON-NLS-1$
|
||||||
ctx.modify("config", ""); //$NON-NLS-1$
|
ctx.modify("config", ""); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -507,14 +507,19 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
@Inject
|
@Inject
|
||||||
@Optional
|
@Optional
|
||||||
public void setPartInput(@Named("input") Object partInput, @Named("config") Object partConfig) {
|
public void setPartInput(@Named("input") Object partInput, @Named("config") Object partConfig) {
|
||||||
if (partInput instanceof File) {
|
if (partInput instanceof String) {
|
||||||
|
String name = (String)partInput;
|
||||||
filesToLoad = new ArrayList<File>();
|
filesToLoad = new ArrayList<File>();
|
||||||
File file = (File) partInput;
|
boolean explicit = name.contains(",");
|
||||||
|
for(String tok: name.split(",")) {
|
||||||
|
File file = new File(tok);
|
||||||
if(file.isFile() && "CURRENT".equals(file.getName())){
|
if(file.isFile() && "CURRENT".equals(file.getName())){
|
||||||
file=file.getParentFile();
|
file=file.getParentFile();
|
||||||
}
|
}
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
filesToLoad.add(file);
|
filesToLoad.add(file);
|
||||||
|
}
|
||||||
|
if(!explicit)
|
||||||
try {
|
try {
|
||||||
String ext = getFileExtension(file.getName());
|
String ext = getFileExtension(file.getName());
|
||||||
if (Messages.WaveformViewer_19.equals(ext.toLowerCase())) {
|
if (Messages.WaveformViewer_19.equals(ext.toLowerCase())) {
|
||||||
|
@ -535,6 +540,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
}
|
}
|
||||||
} catch (IOException e) { // silently ignore any error
|
} catch (IOException e) { // silently ignore any error
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (filesToLoad.size() > 0)
|
if (filesToLoad.size() > 0)
|
||||||
loadDatabase(persistedState);
|
loadDatabase(persistedState);
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<relativePath>../com.minres.scviewer.parent</relativePath>
|
<relativePath>../com.minres.scviewer.parent</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>com.minres.scviewer.e4.product</artifactId>
|
<artifactId>com.minres.scviewer.e4.product</artifactId>
|
||||||
<version>2.2.0-SNAPSHOT</version>
|
<version>2.3.0-SNAPSHOT</version>
|
||||||
<packaging>eclipse-repository</packaging>
|
<packaging>eclipse-repository</packaging>
|
||||||
<groupId>com.minres.scviewer</groupId>
|
<groupId>com.minres.scviewer</groupId>
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<?pde version="3.5"?>
|
<?pde version="3.5"?>
|
||||||
|
|
||||||
<product name="SCViewer" uid="scviewer" id="com.minres.scviewer.e4.application.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="2.2.0.qualifier" useFeatures="false" includeLaunchers="true">
|
<product name="SCViewer" uid="scviewer" id="com.minres.scviewer.e4.application.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="2.3.0.qualifier" useFeatures="false" includeLaunchers="true">
|
||||||
|
|
||||||
<configIni use="default">
|
<configIni use="default">
|
||||||
</configIni>
|
</configIni>
|
||||||
|
|
Loading…
Reference in New Issue