[WIP ]reorganized dir structure
This commit is contained in:
		@@ -0,0 +1,31 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * 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.handlers;
 | 
			
		||||
 | 
			
		||||
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.MWindow;
 | 
			
		||||
import org.eclipse.e4.ui.workbench.modeling.EModelService;
 | 
			
		||||
import org.eclipse.swt.widgets.Shell;
 | 
			
		||||
 | 
			
		||||
public class AboutHandler {
 | 
			
		||||
 | 
			
		||||
	static final String DIALOG_ID="com.minres.scviewer.e4.application.dialog.aboutscviewer";
 | 
			
		||||
	
 | 
			
		||||
	@Execute
 | 
			
		||||
	public void execute(Shell shell, MApplication app, MWindow window, EModelService ms /*@Named("mdialog01.dialog.0") MDialog dialog*/) {
 | 
			
		||||
		MPart mel = (MPart) ms.find(DIALOG_ID, app); //$NON-NLS-1$
 | 
			
		||||
		mel.setToBeRendered(true);
 | 
			
		||||
		mel.setToBeRendered(false);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,74 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * 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.handlers;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import javax.inject.Inject;
 | 
			
		||||
import javax.inject.Named;
 | 
			
		||||
 | 
			
		||||
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.ui.model.application.ui.basic.MPart;
 | 
			
		||||
import org.eclipse.e4.ui.services.IServiceConstants;
 | 
			
		||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
 | 
			
		||||
import org.eclipse.jface.viewers.IStructuredSelection;
 | 
			
		||||
 | 
			
		||||
import com.minres.scviewer.database.IWaveform;
 | 
			
		||||
import com.minres.scviewer.e4.application.parts.DesignBrowser;
 | 
			
		||||
 | 
			
		||||
public class AddWaveformHandler {
 | 
			
		||||
 | 
			
		||||
	public final static String PARAM_WHERE_ID="com.minres.scviewer.e4.application.command.addwaveform.where"; //$NON-NLS-1$
 | 
			
		||||
	public final static String PARAM_ALL_ID="com.minres.scviewer.e4.application.command.addwaveform.all"; //$NON-NLS-1$
 | 
			
		||||
	
 | 
			
		||||
	@Inject @Optional DesignBrowser designBrowser;
 | 
			
		||||
	
 | 
			
		||||
	@CanExecute
 | 
			
		||||
	public boolean canExecute(@Named(PARAM_WHERE_ID) String where, @Named(PARAM_ALL_ID) String all,
 | 
			
		||||
			EPartService partService,
 | 
			
		||||
			@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection) {
 | 
			
		||||
		if(designBrowser==null) designBrowser = getListPart( partService);
 | 
			
		||||
		if(designBrowser==null || designBrowser.getActiveWaveformViewerPart()==null) return false;
 | 
			
		||||
		boolean before = "before".equalsIgnoreCase(where); //$NON-NLS-1$
 | 
			
		||||
		IStructuredSelection waveformSelection = null;
 | 
			
		||||
		if(designBrowser.getActiveWaveformViewerPart()!=null)
 | 
			
		||||
			waveformSelection = (IStructuredSelection)designBrowser.getActiveWaveformViewerPart().getSelection();
 | 
			
		||||
		if("true".equalsIgnoreCase(all))  //$NON-NLS-1$
 | 
			
		||||
			return designBrowser.getFilteredChildren().length>0 && 
 | 
			
		||||
					(!before || (waveformSelection!=null && waveformSelection.size()>0));
 | 
			
		||||
		else
 | 
			
		||||
			return selection!=null && selection.size()>0 && 
 | 
			
		||||
					(!before || (waveformSelection!=null && waveformSelection.size()>0));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Execute
 | 
			
		||||
	public void execute(@Named(PARAM_WHERE_ID) String where, @Named(PARAM_ALL_ID) String all, 
 | 
			
		||||
			EPartService partService,
 | 
			
		||||
			@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection) {
 | 
			
		||||
		if(designBrowser==null) designBrowser = getListPart( partService);
 | 
			
		||||
		if(designBrowser!=null && selection.size()>0){
 | 
			
		||||
			List<?> sel=selection.toList();
 | 
			
		||||
			designBrowser.getActiveWaveformViewerPart().addStreamsToList(sel.toArray(new IWaveform[]{}),
 | 
			
		||||
					"before".equalsIgnoreCase(where)); //$NON-NLS-1$
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	protected DesignBrowser getListPart(EPartService partService){
 | 
			
		||||
		MPart part = partService.getActivePart();
 | 
			
		||||
		if(part.getObject() instanceof DesignBrowser)
 | 
			
		||||
			return (DesignBrowser) part.getObject();
 | 
			
		||||
		else
 | 
			
		||||
			return null;
 | 
			
		||||
	}	
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,51 @@
 | 
			
		||||
 
 | 
			
		||||
package com.minres.scviewer.e4.application.handlers;
 | 
			
		||||
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
 | 
			
		||||
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.jface.viewers.ISelection;
 | 
			
		||||
import org.eclipse.jface.viewers.IStructuredSelection;
 | 
			
		||||
 | 
			
		||||
import com.minres.scviewer.database.ui.TrackEntry;
 | 
			
		||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
 | 
			
		||||
 | 
			
		||||
public class ChangeValueDisplay {
 | 
			
		||||
	
 | 
			
		||||
	static final String PARAMETER_ID="com.minres.scviewer.e4.application.commandparameter.changevaluedisplay"; //$NON-NLS-1$
 | 
			
		||||
 | 
			
		||||
	@CanExecute
 | 
			
		||||
	public boolean canExecute(EPartService partService) {
 | 
			
		||||
		MPart part = partService.getActivePart();
 | 
			
		||||
		if(part==null) return false;
 | 
			
		||||
		return (part.getObject() instanceof WaveformViewer);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Execute
 | 
			
		||||
	public void execute(@Named(PARAMETER_ID) String param, EPartService partService) {
 | 
			
		||||
		MPart part = partService.getActivePart();
 | 
			
		||||
		Object obj = part.getObject();
 | 
			
		||||
		if(obj instanceof WaveformViewer){
 | 
			
		||||
			WaveformViewer wfv = (WaveformViewer)obj;
 | 
			
		||||
			ISelection sel = wfv.getSelection();
 | 
			
		||||
			if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
 | 
			
		||||
				Iterator<?> it = ((IStructuredSelection)sel).iterator();
 | 
			
		||||
				it.next();
 | 
			
		||||
				if(it.hasNext()) {
 | 
			
		||||
						Object second = it.next();
 | 
			
		||||
						if(second instanceof TrackEntry) {
 | 
			
		||||
							TrackEntry.ValueDisplay val = TrackEntry.ValueDisplay.valueOf(param);
 | 
			
		||||
							((TrackEntry)second).valueDisplay=val;
 | 
			
		||||
							wfv.update();
 | 
			
		||||
						}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
		
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,51 @@
 | 
			
		||||
 
 | 
			
		||||
package com.minres.scviewer.e4.application.handlers;
 | 
			
		||||
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
 | 
			
		||||
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.jface.viewers.ISelection;
 | 
			
		||||
import org.eclipse.jface.viewers.IStructuredSelection;
 | 
			
		||||
 | 
			
		||||
import com.minres.scviewer.database.ui.TrackEntry;
 | 
			
		||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
 | 
			
		||||
 | 
			
		||||
public class ChangeWaveformDisplay {
 | 
			
		||||
	
 | 
			
		||||
	static final String PARAMETER_ID="com.minres.scviewer.e4.application.commandparameter.changewavedisplay"; //$NON-NLS-1$
 | 
			
		||||
 | 
			
		||||
	@CanExecute
 | 
			
		||||
	public boolean canExecute(EPartService partService) {
 | 
			
		||||
		MPart part = partService.getActivePart();
 | 
			
		||||
		if(part==null) return false;
 | 
			
		||||
		return (part.getObject() instanceof WaveformViewer);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Execute
 | 
			
		||||
	public void execute(@Named(PARAMETER_ID) String param, EPartService partService) {
 | 
			
		||||
		MPart part = partService.getActivePart();
 | 
			
		||||
		Object obj = part.getObject();
 | 
			
		||||
		if(obj instanceof WaveformViewer){
 | 
			
		||||
			WaveformViewer wfv = (WaveformViewer)obj;
 | 
			
		||||
			ISelection sel = wfv.getSelection();
 | 
			
		||||
			if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
 | 
			
		||||
				Iterator<?> it = ((IStructuredSelection)sel).iterator();
 | 
			
		||||
				it.next();
 | 
			
		||||
				if(it.hasNext()) {
 | 
			
		||||
						Object second = it.next();
 | 
			
		||||
						if(second instanceof TrackEntry) {
 | 
			
		||||
							TrackEntry.WaveDisplay val= TrackEntry.WaveDisplay.valueOf(param);
 | 
			
		||||
							((TrackEntry)second).waveDisplay=val;
 | 
			
		||||
							wfv.update();
 | 
			
		||||
						}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
		
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,39 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * 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.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 org.eclipse.jface.viewers.IStructuredSelection;
 | 
			
		||||
 | 
			
		||||
import com.minres.scviewer.database.IWaveform;
 | 
			
		||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
 | 
			
		||||
 | 
			
		||||
public class DeleteWaveformHandler {
 | 
			
		||||
	
 | 
			
		||||
	@CanExecute
 | 
			
		||||
	public Boolean canExecute(ESelectionService selectionService){
 | 
			
		||||
		Object o = selectionService.getSelection();
 | 
			
		||||
		return o instanceof IStructuredSelection && ((IStructuredSelection)o).getFirstElement() instanceof IWaveform;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Execute
 | 
			
		||||
	public void execute(ESelectionService selectionService, MPart activePart) {
 | 
			
		||||
		Object o = activePart.getObject();
 | 
			
		||||
		Object sel = selectionService.getSelection();
 | 
			
		||||
		if(o instanceof WaveformViewer && ((IStructuredSelection)sel).getFirstElement() instanceof IWaveform){
 | 
			
		||||
			((WaveformViewer)o).removeStreamFromList((IWaveform) ((IStructuredSelection)sel).getFirstElement());
 | 
			
		||||
		}	
 | 
			
		||||
	}	
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,48 @@
 | 
			
		||||
 
 | 
			
		||||
package com.minres.scviewer.e4.application.handlers;
 | 
			
		||||
 | 
			
		||||
import java.util.LinkedList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.PostConstruct;
 | 
			
		||||
import javax.inject.Inject;
 | 
			
		||||
 | 
			
		||||
import org.eclipse.core.runtime.preferences.ConfigurationScope;
 | 
			
		||||
import org.eclipse.e4.core.contexts.Active;
 | 
			
		||||
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.MWindow;
 | 
			
		||||
import org.eclipse.e4.ui.model.application.ui.menu.MHandledItem;
 | 
			
		||||
import org.eclipse.e4.ui.workbench.modeling.EModelService;
 | 
			
		||||
import org.eclipse.jface.preference.IPreferenceStore;
 | 
			
		||||
 | 
			
		||||
import com.minres.scviewer.e4.application.preferences.PreferenceConstants;
 | 
			
		||||
import com.opcoach.e4.preferences.ScopedPreferenceStore;
 | 
			
		||||
 | 
			
		||||
public class EnableHover {
 | 
			
		||||
	static final String TAG_NAME = "EnableHover"; //$NON-NLS-1$
 | 
			
		||||
 | 
			
		||||
	@Inject
 | 
			
		||||
	MApplication application;
 | 
			
		||||
		
 | 
			
		||||
	@PostConstruct
 | 
			
		||||
	public void initialize(EModelService modelService) {
 | 
			
		||||
		List<String> tags = new LinkedList<>();
 | 
			
		||||
		tags.add(TAG_NAME);
 | 
			
		||||
		List<MHandledItem> elements = modelService.findElements(application, null, MHandledItem.class, tags );
 | 
			
		||||
	   // cover initialization stuff, sync it with code
 | 
			
		||||
		IPreferenceStore store = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE);
 | 
			
		||||
		boolean state = store.getBoolean(PreferenceConstants.SHOW_HOVER);
 | 
			
		||||
		for( MHandledItem hi : elements ){
 | 
			
		||||
			hi.setSelected(state);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Execute
 | 
			
		||||
	public void execute(@Active MPart part, @Active MWindow window, MHandledItem handledItem, EModelService modelService ) {
 | 
			
		||||
		IPreferenceStore store = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE);
 | 
			
		||||
		store.setValue(PreferenceConstants.SHOW_HOVER, handledItem.isSelected());
 | 
			
		||||
	}
 | 
			
		||||
		
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,100 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * 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.handlers;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
 | 
			
		||||
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.MApplication;
 | 
			
		||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 | 
			
		||||
import org.eclipse.e4.ui.workbench.modeling.EModelService;
 | 
			
		||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
 | 
			
		||||
import org.eclipse.swt.SWT;
 | 
			
		||||
import org.eclipse.swt.widgets.FileDialog;
 | 
			
		||||
import org.eclipse.swt.widgets.MessageBox;
 | 
			
		||||
import org.eclipse.swt.widgets.Shell;
 | 
			
		||||
 | 
			
		||||
import com.minres.scviewer.e4.application.Messages;
 | 
			
		||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
 | 
			
		||||
public class LoadStoreSettingsHandler {
 | 
			
		||||
 | 
			
		||||
	static final String PARAMETER_ID="com.minres.scviewer.e4.application.commandparameter.loadStore"; //$NON-NLS-1$
 | 
			
		||||
 | 
			
		||||
	@CanExecute
 | 
			
		||||
	public boolean canExecute(EPartService partService) {
 | 
			
		||||
		MPart part = partService.getActivePart();
 | 
			
		||||
		if(part==null) return false;
 | 
			
		||||
		return (part.getObject() instanceof WaveformViewer);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Execute
 | 
			
		||||
	public void execute(@Named(PARAMETER_ID) String param, Shell shell, MApplication app, EModelService modelService, 
 | 
			
		||||
			EPartService partService){
 | 
			
		||||
		
 | 
			
		||||
		boolean load = "load".equals(param); //$NON-NLS-1$
 | 
			
		||||
		FileDialog dialog = new FileDialog(shell, load?SWT.OPEN:SWT.SAVE);
 | 
			
		||||
		dialog.setFilterExtensions (new String []{Messages.LoadStoreSettingsHandler_2});
 | 
			
		||||
		if(!load) dialog.setFileName(Messages.LoadStoreSettingsHandler_3);
 | 
			
		||||
		
 | 
			
		||||
		String fileName = null;
 | 
			
		||||
		MPart part = partService.getActivePart();
 | 
			
		||||
		Object obj = part.getObject();
 | 
			
		||||
		
 | 
			
		||||
		// Save active tab settings
 | 
			
		||||
		if(!load) {
 | 
			
		||||
			// 3 possible cases when when saving active tab settings:
 | 
			
		||||
			// - user dismisses the dialog by pressing Cancel
 | 
			
		||||
			// - selected file name does not exist
 | 
			
		||||
			// - user agrees to overwrite existing file
 | 
			
		||||
			boolean done = false;
 | 
			
		||||
			while (!done) {
 | 
			
		||||
				// open the File Dialog
 | 
			
		||||
				fileName = dialog.open();
 | 
			
		||||
				if (fileName == null) {
 | 
			
		||||
					// user has cancelled -> quit and return
 | 
			
		||||
					done = true;
 | 
			
		||||
				} else {
 | 
			
		||||
					// user has selected a file -> see if it already exists
 | 
			
		||||
					File file = new File(fileName);
 | 
			
		||||
					if (file.exists()) {
 | 
			
		||||
						// file already exists -> asks for confirmation
 | 
			
		||||
						MessageBox mb = new MessageBox(dialog.getParent(), SWT.ICON_WARNING
 | 
			
		||||
								| SWT.YES | SWT.NO);
 | 
			
		||||
						mb.setText("Confirm overwrite");
 | 
			
		||||
						mb.setMessage(fileName + " already exists. Do you want to overwrite it?");
 | 
			
		||||
						// user clicks Yes -> all done, drop out 
 | 
			
		||||
						if(mb.open() == SWT.YES) {
 | 
			
		||||
							((WaveformViewer)obj).saveState(fileName);
 | 
			
		||||
							done = true;
 | 
			
		||||
						} else { // user clicks No -> redisplay the File Dialog
 | 
			
		||||
							done = false;
 | 
			
		||||
						}
 | 
			
		||||
					} else {
 | 
			
		||||
						// file does not exist -> save and drop out
 | 
			
		||||
						((WaveformViewer)obj).saveState(fileName);
 | 
			
		||||
						done = true;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			return;
 | 
			
		||||
		} // end if(!load)
 | 
			
		||||
		
 | 
			
		||||
	    else { // load active tab settings
 | 
			
		||||
	    	String res = dialog.open();
 | 
			
		||||
	    	if(res != null && part!=null && (obj instanceof WaveformViewer)) { 
 | 
			
		||||
	        	((WaveformViewer)obj).loadState(res);
 | 
			
		||||
	    	}
 | 
			
		||||
	    }
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,53 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * 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.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 org.eclipse.jface.viewers.IStructuredSelection;
 | 
			
		||||
 | 
			
		||||
import com.minres.scviewer.database.ITx;
 | 
			
		||||
import com.minres.scviewer.database.IWaveform;
 | 
			
		||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
 | 
			
		||||
 | 
			
		||||
public class MoveWaveformHandler {
 | 
			
		||||
 | 
			
		||||
	static final String PARAMETER_ID="com.minres.scviewer.e4.application.command.movewaveformupCommand.parameter.dir"; //$NON-NLS-1$
 | 
			
		||||
 | 
			
		||||
	@CanExecute
 | 
			
		||||
	public Boolean canExecute(ESelectionService selectionService){
 | 
			
		||||
		Object sel = selectionService.getSelection();
 | 
			
		||||
		if( sel instanceof IStructuredSelection) {
 | 
			
		||||
			Object o= ((IStructuredSelection)sel).getFirstElement();
 | 
			
		||||
			return o instanceof IWaveform || o instanceof ITx;
 | 
			
		||||
		}
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Execute
 | 
			
		||||
	public void execute(@Named(PARAMETER_ID) String param, EPartService partService) {
 | 
			
		||||
		MPart part = partService.getActivePart();
 | 
			
		||||
		Object obj = part.getObject();
 | 
			
		||||
		if(obj instanceof WaveformViewer){
 | 
			
		||||
			if("up".equalsIgnoreCase(param)) //$NON-NLS-1$
 | 
			
		||||
				((WaveformViewer)obj).moveSelected(-1);
 | 
			
		||||
			else if("down".equalsIgnoreCase(param)) //$NON-NLS-1$
 | 
			
		||||
				((WaveformViewer)obj).moveSelected(1);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
		
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,55 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * 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.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 org.eclipse.jface.viewers.IStructuredSelection;
 | 
			
		||||
 | 
			
		||||
import com.minres.scviewer.database.ITx;
 | 
			
		||||
import com.minres.scviewer.database.IWaveform;
 | 
			
		||||
import com.minres.scviewer.database.ui.GotoDirection;
 | 
			
		||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
 | 
			
		||||
 | 
			
		||||
public class NavigateEvent {
 | 
			
		||||
 | 
			
		||||
	final static String PARAMTER_ID="com.minres.scviewer.e4.application.command.navigateEventCommand.parameter.dir"; //$NON-NLS-1$
 | 
			
		||||
	
 | 
			
		||||
	@CanExecute
 | 
			
		||||
	public Boolean canExecute(ESelectionService selectionService){
 | 
			
		||||
		Object sel = selectionService.getSelection();
 | 
			
		||||
		if( sel instanceof IStructuredSelection) {
 | 
			
		||||
			Object o= ((IStructuredSelection)sel).getFirstElement();
 | 
			
		||||
			return o instanceof IWaveform || o instanceof ITx;
 | 
			
		||||
		}
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@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 WaveformViewer){
 | 
			
		||||
			if("next".equalsIgnoreCase(param)) //$NON-NLS-1$
 | 
			
		||||
				((WaveformViewer)obj).moveCursor(GotoDirection.NEXT);
 | 
			
		||||
			else if("prev".equalsIgnoreCase(param)) //$NON-NLS-1$
 | 
			
		||||
				((WaveformViewer)obj).moveCursor(GotoDirection.PREV);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,52 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * 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.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 org.eclipse.jface.viewers.IStructuredSelection;
 | 
			
		||||
 | 
			
		||||
import com.minres.scviewer.database.ITx;
 | 
			
		||||
import com.minres.scviewer.database.ui.GotoDirection;
 | 
			
		||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
 | 
			
		||||
 | 
			
		||||
public class NavigateTrans {
 | 
			
		||||
 | 
			
		||||
	final static String PARAMTER_ID="com.minres.scviewer.e4.application.command.navigateTransCommand.parameter.dir"; //$NON-NLS-1$
 | 
			
		||||
	
 | 
			
		||||
	@CanExecute
 | 
			
		||||
	public Boolean canExecute(ESelectionService selectionService){
 | 
			
		||||
		Object sel = selectionService.getSelection();
 | 
			
		||||
		if( sel instanceof IStructuredSelection) {
 | 
			
		||||
			Object o= ((IStructuredSelection)sel).getFirstElement();
 | 
			
		||||
			return o instanceof ITx;
 | 
			
		||||
		}
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Execute
 | 
			
		||||
	public void execute(@Named(PARAMTER_ID) String param, EPartService partService) {
 | 
			
		||||
		MPart part = partService.getActivePart();
 | 
			
		||||
		Object obj = part.getObject();
 | 
			
		||||
		if(obj instanceof WaveformViewer){
 | 
			
		||||
			if("next".equalsIgnoreCase(param)) //$NON-NLS-1$
 | 
			
		||||
				((WaveformViewer)obj).moveSelection(GotoDirection.NEXT);
 | 
			
		||||
			else if("prev".equalsIgnoreCase(param)) //$NON-NLS-1$
 | 
			
		||||
				((WaveformViewer)obj).moveSelection(GotoDirection.PREV);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,51 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * 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.handlers;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
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.jface.window.Window;
 | 
			
		||||
import org.eclipse.swt.widgets.Shell;
 | 
			
		||||
 | 
			
		||||
import com.minres.scviewer.e4.application.Messages;
 | 
			
		||||
import com.minres.scviewer.e4.application.parts.FileBrowserDialog;
 | 
			
		||||
public class OpenHandler {
 | 
			
		||||
 | 
			
		||||
	@Execute
 | 
			
		||||
	public void execute(Shell shell, MApplication app, EModelService modelService, EPartService partService){
 | 
			
		||||
		FileBrowserDialog dlg = new FileBrowserDialog(shell);
 | 
			
		||||
		//dlg.create();
 | 
			
		||||
		dlg.setFilterExtensions (new String []{Messages.OpenHandler_0, "*"});
 | 
			
		||||
		if (dlg.open() != Window.OK) return;
 | 
			
		||||
		List<File> files = dlg.getSelectedFiles();
 | 
			
		||||
		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$				
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,29 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * 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.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;
 | 
			
		||||
 | 
			
		||||
import com.minres.scviewer.e4.application.Messages;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class QuitHandler {
 | 
			
		||||
	@Execute
 | 
			
		||||
	public void execute(IWorkbench workbench, Shell shell){
 | 
			
		||||
		if (MessageDialog.openConfirm(shell, Messages.QuitHandler_0,
 | 
			
		||||
				Messages.QuitHandler_1)) {
 | 
			
		||||
			workbench.close();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,31 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * 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.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);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,43 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * 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.handlers;
 | 
			
		||||
 | 
			
		||||
import javax.inject.Inject;
 | 
			
		||||
 | 
			
		||||
import org.eclipse.e4.core.di.annotations.Execute;
 | 
			
		||||
import org.eclipse.e4.core.di.annotations.Optional;
 | 
			
		||||
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.DesignBrowser;
 | 
			
		||||
 | 
			
		||||
public class SelectAllHandler {
 | 
			
		||||
 | 
			
		||||
	@Inject @Optional DesignBrowser designBrowser;
 | 
			
		||||
 | 
			
		||||
	@Execute
 | 
			
		||||
	public void execute(EPartService partService) {
 | 
			
		||||
		if(designBrowser==null) designBrowser = getListPart(partService);
 | 
			
		||||
		if(designBrowser!=null){
 | 
			
		||||
			designBrowser.selectAllWaveforms();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	protected DesignBrowser getListPart(EPartService partService){
 | 
			
		||||
		MPart part = partService.getActivePart();
 | 
			
		||||
		if(part.getObject() instanceof DesignBrowser)
 | 
			
		||||
			return (DesignBrowser) part.getObject();
 | 
			
		||||
		else
 | 
			
		||||
			return null;
 | 
			
		||||
	}	
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,35 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * 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.handlers;
 | 
			
		||||
 | 
			
		||||
import javax.inject.Named;
 | 
			
		||||
 | 
			
		||||
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.WaveformViewer;
 | 
			
		||||
 | 
			
		||||
public class SetRelationTypeHandler {
 | 
			
		||||
	final static String PARAMTER_ID="com.minres.scviewer.e4.application.commandparameter.relationName"; //$NON-NLS-1$
 | 
			
		||||
 | 
			
		||||
	@Execute
 | 
			
		||||
	public void execute(@Named(PARAMTER_ID) String relationName, EPartService partService) {
 | 
			
		||||
		MPart part = partService.getActivePart();
 | 
			
		||||
		Object obj = part.getObject();
 | 
			
		||||
		if(obj instanceof WaveformViewer){
 | 
			
		||||
			WaveformViewer waveformViewerPart = (WaveformViewer) obj;
 | 
			
		||||
			waveformViewerPart.setNavigationRelationType(relationName);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
		
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,40 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * 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.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.css.swt.theme.IThemeEngine;
 | 
			
		||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * see http://www.vogella.com/tutorials/Eclipse4CSS/article.html#tutorial_cssstyling
 | 
			
		||||
 */
 | 
			
		||||
@SuppressWarnings("restriction")
 | 
			
		||||
public class ThemeSetHandler {
 | 
			
		||||
	final static String PARAMTER_ID = "com.minres.scviewer.e4.application.command.theme.parameter.id"; //$NON-NLS-1$
 | 
			
		||||
 | 
			
		||||
	@CanExecute
 | 
			
		||||
	public boolean canExecute(EPartService partService) {
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Execute
 | 
			
		||||
	public void setTheme(@Named(PARAMTER_ID) String param, IThemeEngine engine) {
 | 
			
		||||
		if (!engine.getActiveTheme().getId().equals(param)) {
 | 
			
		||||
			// second argument defines that change is
 | 
			
		||||
			// persisted and restored on restart
 | 
			
		||||
			engine.setTheme(param, true);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,50 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
 * 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.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.WaveformViewer;
 | 
			
		||||
 | 
			
		||||
public class ZoomHandler {
 | 
			
		||||
 | 
			
		||||
	final static String PARAMTER_ID="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level"; //$NON-NLS-1$
 | 
			
		||||
 | 
			
		||||
	@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 WaveformViewer){
 | 
			
		||||
			WaveformViewer waveformViewerPart = (WaveformViewer) obj;
 | 
			
		||||
			int zoomLevel = waveformViewerPart.getZoomLevel();
 | 
			
		||||
			if("in".equalsIgnoreCase(level)) //$NON-NLS-1$
 | 
			
		||||
				waveformViewerPart.setZoomLevel(zoomLevel-1);
 | 
			
		||||
			else if("out".equalsIgnoreCase(level)) //$NON-NLS-1$
 | 
			
		||||
				waveformViewerPart.setZoomLevel(zoomLevel+1);
 | 
			
		||||
			else if("fit".equalsIgnoreCase(level)) //$NON-NLS-1$
 | 
			
		||||
				waveformViewerPart.setZoomFit();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user