Skip to content
Snippets Groups Projects
Commit 8db52c85 authored by Johannes Eder's avatar Johannes Eder
Browse files

Tutorial Mode auto start impl via thread

refs 2869
parent 95d80fd3
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,8 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.internal;
import static org.eclipse.core.runtime.Status.CANCEL_STATUS;
import static org.eclipse.core.runtime.Status.OK_STATUS;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import java.io.File;
......@@ -24,17 +26,25 @@ import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.UIJob;
import org.fortiss.tooling.kernel.extension.ITutorialProvider;
import org.fortiss.tooling.kernel.extension.data.TutorialStepBase;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
......@@ -59,7 +69,7 @@ import org.osgi.framework.BundleException;
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: 3D55FF9743BBA332783A37E078A1465E
* @ConQAT.Rating RED Hash: 86CD841209EB95BE385D3201B5137A06
*/
public final class TutorialUIService implements ITutorialUIService, ITutorialUIWhitelistProvider,
IIntrospectiveKernelService {
......@@ -134,6 +144,45 @@ public final class TutorialUIService implements ITutorialUIService, ITutorialUIW
} catch(MalformedURLException urlEx) {
System.err.println("[TUIS] " + urlEx.getMessage());
}
// start tutorial immediately if command line arguments have been given
UIJob uiJob = new UIJob(Display.getCurrent(), "TutorialJob") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
final String getenv = System.getProperty("sun.java.command");
List<String> split = Arrays.asList(getenv.split(" "));
// search for Tutorial
Optional<String> cmdLineArgument =
split.stream().filter(s -> s.contains("tutorial")).findFirst();
if(!cmdLineArgument.isPresent()) {
return CANCEL_STATUS;
}
// 'tutorial = <Class name of tutorial root provider>'
String cmdLineString = cmdLineArgument.get();
String[] split2 = cmdLineString.split("=");
String className = split2[split2.length - 1];
Optional<Entry<Class<? extends ITutorialProvider>, Class<? extends ITutorialUIProvider>>> tutorialProvider =
providerMap.entrySet().stream()
.filter(c -> c.getKey().toString().contains(className)).findFirst();
if(!tutorialProvider.isPresent()) {
return null;
}
Class<? extends ITutorialProvider> clazz = tutorialProvider.get().getKey();
Display.getCurrent().asyncExec(
() -> ITutorialService.getInstance().startTutorial(clazz));
return OK_STATUS;
}
};
uiJob.schedule();
}
/** Tests for existence of META-INF sub-directory. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment