add reload menu and toolbar item
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -577,6 +577,10 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
* @param state the state
|
||||
*/
|
||||
protected void loadDatabase(final Map<String, String> state) {
|
||||
loadDatabase(state, 1000L);
|
||||
}
|
||||
|
||||
protected void loadDatabase(final Map<String, String> 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<String, String> state = new HashMap<>();
|
||||
saveWaveformViewerState(state);
|
||||
waveformPane.getStreamList().clear();
|
||||
database.clear();
|
||||
if (filesToLoad.size() > 0)
|
||||
loadDatabase(state);
|
||||
reloadDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
fileMonitor.removeFileChangeListener(this);
|
||||
}
|
||||
|
||||
public void reloadDatabase() {
|
||||
Map<String, String> state = new HashMap<>();
|
||||
saveWaveformViewerState(state);
|
||||
waveformPane.getStreamList().clear();
|
||||
database.clear();
|
||||
if (filesToLoad.size() > 0)
|
||||
loadDatabase(state, 0L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the part input.
|
||||
*
|
||||
|
Reference in New Issue
Block a user