Commit 34f859e8 authored by Romain Bioteau's avatar Romain Bioteau

honor run in background pref

parent 69996000
......@@ -37,6 +37,8 @@ import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.IPreferenceConstants;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.progress.ProgressMonitorFocusJobDialog;
......@@ -79,10 +81,16 @@ public abstract class AbstractOpenConsoleCommand extends AbstractHandler {
}
};
job.setUser(true);
job.schedule();
Shell activeShell = Display.getDefault().getActiveShell();
ProgressMonitorFocusJobDialog dialog = new ProgressMonitorFocusJobDialog(activeShell);
dialog.show(job, activeShell);
boolean runInBackground = WorkbenchPlugin.getDefault().getPreferenceStore()
.getBoolean(IPreferenceConstants.RUN_IN_BACKGROUND);
if (!runInBackground) {
Shell activeShell = Display.getDefault().getActiveShell();
ProgressMonitorFocusJobDialog dialog = new ProgressMonitorFocusJobDialog(activeShell);
dialog.show(job, activeShell);
job.schedule();
} else {
job.schedule();
}
}
}
......
......@@ -44,6 +44,8 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.IPreferenceConstants;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.progress.ProgressMonitorFocusJobDialog;
public class DeployDiagramHandler extends AbstractHandler {
......@@ -81,10 +83,16 @@ public class DeployDiagramHandler extends AbstractHandler {
}
});
deployJob.setUser(true);
deployJob.schedule();
Shell activeShell = Display.getDefault().getActiveShell();
ProgressMonitorFocusJobDialog dialog = new ProgressMonitorFocusJobDialog(activeShell);
dialog.show(deployJob, activeShell);
boolean runInBackground = WorkbenchPlugin.getDefault().getPreferenceStore()
.getBoolean(IPreferenceConstants.RUN_IN_BACKGROUND);
if (!runInBackground) {
Shell activeShell = Display.getDefault().getActiveShell();
ProgressMonitorFocusJobDialog dialog = new ProgressMonitorFocusJobDialog(activeShell);
dialog.show(deployJob, activeShell);
deployJob.schedule();
} else {
deployJob.schedule();
}
}
return null;
}
......
......@@ -53,6 +53,8 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.IPreferenceConstants;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.progress.ProgressMonitorFocusJobDialog;
import org.eclipse.ui.progress.IProgressService;
......@@ -133,10 +135,16 @@ public class RunProcessCommand extends AbstractHandler {
}
};
job.setUser(true);
job.schedule();
Shell activeShell = Display.getDefault().getActiveShell();
ProgressMonitorFocusJobDialog dialog = new ProgressMonitorFocusJobDialog(activeShell);
dialog.show(job, activeShell);
boolean runInBackground = WorkbenchPlugin.getDefault().getPreferenceStore()
.getBoolean(IPreferenceConstants.RUN_IN_BACKGROUND);
if (!runInBackground) {
Shell activeShell = Display.getDefault().getActiveShell();
ProgressMonitorFocusJobDialog dialog = new ProgressMonitorFocusJobDialog(activeShell);
dialog.show(job, activeShell);
job.schedule();
} else {
job.schedule();
}
}
} catch (final Exception e) {
BonitaStudioLog.error(e);
......
......@@ -32,7 +32,7 @@ import org.mockito.runners.MockitoJUnitRunner;
public class PreferenceInitializerTest {
@Mock
public IPreferenceStore apiPrefStore, webPrefStore, bonitaPrefStore, jdtPrefStore, dslPreferenceStore;
public IPreferenceStore apiPrefStore, webPrefStore, bonitaPrefStore, jdtPrefStore, dslPreferenceStore, workbenchStore;
@Test
public void testLegacyModeDeactivatedByDefault() throws Exception {
......@@ -60,6 +60,7 @@ public class PreferenceInitializerTest {
doReturn(webPrefStore).when(preferenceInitializer).getWebBrowserPreferenceStore();
doReturn(bonitaPrefStore).when(preferenceInitializer).getBonitaPreferenceStore();
doReturn(jdtPrefStore).when(preferenceInitializer).getJDTPreferenceStore();
doReturn(workbenchStore).when(preferenceInitializer).getWorbenchPreferences();
doReturn(new Locale[] {}).when(preferenceInitializer).getStudioLocales();
doNothing().when(preferenceInitializer).setUTF8DefaultEncoding();
doNothing().when(preferenceInitializer).initDefaultDebugPreferences();
......
......@@ -27,6 +27,8 @@ import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.IWorkbenchPreferenceConstants;
import org.eclipse.ui.internal.IPreferenceConstants;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.browser.WebBrowserUIPlugin;
import org.eclipse.ui.internal.util.PrefUtil;
......@@ -66,6 +68,13 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer impleme
final IPreferenceStore jdtUIStore = getJDTPreferenceStore();
jdtUIStore.setValue(PreferenceConstants.EDITOR_MARK_OCCURRENCES, Boolean.FALSE);
getWorbenchPreferences().setDefault(IPreferenceConstants.RUN_IN_BACKGROUND, false);
}
protected IPreferenceStore getWorbenchPreferences() {
return WorkbenchPlugin.getDefault().getPreferenceStore();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment