diff --git a/plugins/com.minres.scviewer.e4.application/Application.e4xmi b/plugins/com.minres.scviewer.e4.application/Application.e4xmi index 81fadd5..0822bbe 100644 --- a/plugins/com.minres.scviewer.e4.application/Application.e4xmi +++ b/plugins/com.minres.scviewer.e4.application/Application.e4xmi @@ -11,7 +11,8 @@ - + + @@ -58,7 +59,8 @@ - + + @@ -133,6 +135,7 @@ + type:user @@ -264,6 +267,7 @@ + diff --git a/plugins/com.minres.scviewer.e4.application/icons/database_refresh.png b/plugins/com.minres.scviewer.e4.application/icons/database_refresh.png new file mode 100644 index 0000000..ff803be Binary files /dev/null and b/plugins/com.minres.scviewer.e4.application/icons/database_refresh.png differ diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/ReloadHandler.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/ReloadHandler.java new file mode 100644 index 0000000..6c53a63 --- /dev/null +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/ReloadHandler.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * 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.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.widgets.Shell; + +import com.minres.scviewer.e4.application.parts.WaveformViewer; +public class ReloadHandler { + + @CanExecute + public boolean canExecute(EPartService partService) { + MPart part = partService.getActivePart(); + if(part==null) return false; + return (part.getObject() instanceof WaveformViewer); + } + + @Execute + public void execute(Shell shell, MApplication app, EModelService modelService, + EPartService partService){ + + MPart part = partService.getActivePart(); + Object obj = part.getObject(); + if(part!=null && (obj instanceof WaveformViewer)) { + ((WaveformViewer)obj).reloadDatabase(); + } + + } +} \ No newline at end of file diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java index f11917f..0c42fb8 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java @@ -577,6 +577,10 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis * @param state the state */ protected void loadDatabase(final Map state) { + loadDatabase(state, 1000L); + } + + protected void loadDatabase(final Map state, long delay) { fileMonitor.removeFileChangeListener(this); Job job = new Job(Messages.WaveformViewer_15) { @Override @@ -619,8 +623,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis return result; } }; + job.setName("Load Database"); job.setSystem(true); - job.schedule(1000L); // let the UI initialize so that we have a progress monitor + job.schedule(delay); // let the UI initialize so that we have a progress monitor } /* (non-Javadoc) @@ -634,18 +639,23 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis public void run() { if (MessageDialog.openQuestion(display.getActiveShell(), Messages.WaveformViewer_17, Messages.WaveformViewer_18)) { - Map state = new HashMap<>(); - saveWaveformViewerState(state); - waveformPane.getStreamList().clear(); - database.clear(); - if (filesToLoad.size() > 0) - loadDatabase(state); + reloadDatabase(); } } + }); fileMonitor.removeFileChangeListener(this); } + public void reloadDatabase() { + Map state = new HashMap<>(); + saveWaveformViewerState(state); + waveformPane.getStreamList().clear(); + database.clear(); + if (filesToLoad.size() > 0) + loadDatabase(state, 0L); + } + /** * Sets the part input. *