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-Name: %Bundle-Name
|
||||
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
|
||||
Require-Bundle: javax.inject;bundle-version="1.0.0",
|
||||
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>com.minres.scviewer.e4.application</artifactId>
|
||||
<version>2.2.0-SNAPSHOT</version>
|
||||
<version>2.3.0-SNAPSHOT</version>
|
||||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
|
@ -158,19 +158,27 @@ public class E4LifeCycle {
|
||||
* @param name the 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$
|
||||
part.setLabel(file.getName());
|
||||
MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$
|
||||
partStack.getChildren().add(part);
|
||||
partService.showPart(part, PartState.ACTIVATE);
|
||||
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.modify("config", confFile); //$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) {
|
||||
this.confFile=confFile;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
package com.minres.scviewer.e4.application.handlers;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.e4.core.di.annotations.Execute;
|
||||
@ -33,19 +34,23 @@ public class OpenHandler {
|
||||
dialog.setFilterExtensions (new String []{Messages.OpenHandler_0});
|
||||
dialog.open();
|
||||
String path = dialog.getFilterPath();
|
||||
ArrayList<File> files = new ArrayList<File>();
|
||||
for(String fileName: dialog.getFileNames()){
|
||||
File file = new File(path+File.separator+fileName);
|
||||
if(file.exists()){
|
||||
MPart part = partService .createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); //$NON-NLS-1$
|
||||
part.setLabel(file.getName());
|
||||
MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$
|
||||
partStack.getChildren().add(part);
|
||||
partService.showPart(part, PartState.ACTIVATE);
|
||||
IEclipseContext ctx=part.getContext();
|
||||
ctx.modify("input", file); //$NON-NLS-1$
|
||||
ctx.modify("config", ""); //$NON-NLS-1$
|
||||
}
|
||||
if(file.exists())
|
||||
files.add(file);
|
||||
}
|
||||
MPart part = partService .createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); //$NON-NLS-1$
|
||||
part.setLabel(files.get(0).getName());
|
||||
MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$
|
||||
partStack.getChildren().add(part);
|
||||
partService.showPart(part, PartState.ACTIVATE);
|
||||
final IEclipseContext ctx=part.getContext();
|
||||
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$
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -507,34 +507,40 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
@Inject
|
||||
@Optional
|
||||
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>();
|
||||
File file = (File) partInput;
|
||||
if(file.isFile() && "CURRENT".equals(file.getName())){
|
||||
file=file.getParentFile();
|
||||
}
|
||||
if (file.exists()) {
|
||||
filesToLoad.add(file);
|
||||
try {
|
||||
String ext = getFileExtension(file.getName());
|
||||
if (Messages.WaveformViewer_19.equals(ext.toLowerCase())) {
|
||||
if (askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), Messages.WaveformViewer_20)))) {
|
||||
filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), Messages.WaveformViewer_20)));
|
||||
} else if (askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), Messages.WaveformViewer_21)))) {
|
||||
filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), Messages.WaveformViewer_21)));
|
||||
} else if (askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), Messages.WaveformViewer_22)))) {
|
||||
filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), Messages.WaveformViewer_22)));
|
||||
}
|
||||
} else if (Messages.WaveformViewer_20.equals(ext.toLowerCase()) ||
|
||||
Messages.WaveformViewer_21.equals(ext.toLowerCase()) ||
|
||||
Messages.WaveformViewer_22.equals(ext.toLowerCase())
|
||||
) {
|
||||
if (askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), Messages.WaveformViewer_19)))) {
|
||||
filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), Messages.WaveformViewer_19)));
|
||||
}
|
||||
}
|
||||
} catch (IOException e) { // silently ignore any error
|
||||
boolean explicit = name.contains(",");
|
||||
for(String tok: name.split(",")) {
|
||||
File file = new File(tok);
|
||||
if(file.isFile() && "CURRENT".equals(file.getName())){
|
||||
file=file.getParentFile();
|
||||
}
|
||||
if (file.exists()) {
|
||||
filesToLoad.add(file);
|
||||
}
|
||||
if(!explicit)
|
||||
try {
|
||||
String ext = getFileExtension(file.getName());
|
||||
if (Messages.WaveformViewer_19.equals(ext.toLowerCase())) {
|
||||
if (askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), Messages.WaveformViewer_20)))) {
|
||||
filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), Messages.WaveformViewer_20)));
|
||||
} else if (askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), Messages.WaveformViewer_21)))) {
|
||||
filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), Messages.WaveformViewer_21)));
|
||||
} else if (askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), Messages.WaveformViewer_22)))) {
|
||||
filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), Messages.WaveformViewer_22)));
|
||||
}
|
||||
} else if (Messages.WaveformViewer_20.equals(ext.toLowerCase()) ||
|
||||
Messages.WaveformViewer_21.equals(ext.toLowerCase()) ||
|
||||
Messages.WaveformViewer_22.equals(ext.toLowerCase())
|
||||
) {
|
||||
if (askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), Messages.WaveformViewer_19)))) {
|
||||
filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), Messages.WaveformViewer_19)));
|
||||
}
|
||||
}
|
||||
} catch (IOException e) { // silently ignore any error
|
||||
}
|
||||
|
||||
}
|
||||
if (filesToLoad.size() > 0)
|
||||
loadDatabase(persistedState);
|
||||
|
@ -10,7 +10,7 @@
|
||||
<relativePath>../com.minres.scviewer.parent</relativePath>
|
||||
</parent>
|
||||
<artifactId>com.minres.scviewer.e4.product</artifactId>
|
||||
<version>2.2.0-SNAPSHOT</version>
|
||||
<version>2.3.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-repository</packaging>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<build>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?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>
|
||||
|
Loading…
Reference in New Issue
Block a user