예제 #1
0
        public void TestMethod1()
        {
            var page = new LauncherPage(session);
            var text = page.getSelectedProjectName();

            Console.Out.WriteLine("---------------------------------------------");
            Console.Out.WriteLine(text);
        }
예제 #2
0
        /// <summary>
        /// Set the current profile to the provided profile.
        /// </summary>
        /// <param name="profile">The profile to activate</param>
        /// <param name="skipSavePrompt">Skip saving the current profile?</param>
        /// <returns><see langword="true"/> if successful, otherwise <see langword="false"/></returns>
        public static bool SetActiveProfile(MefinoProfile profile, bool skipSavePrompt)
        {
            if (!skipSavePrompt && !string.IsNullOrEmpty(s_activeProfile))
            {
                SavePrompt();
            }

            try
            {
                s_activeProfile = profile.name;
                profile.EnableProfile();

                AppDataManager.SaveConfig();

                LauncherPage.SendRebuildPackageList();

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(false);
            }
        }
예제 #3
0
        /// <summary>
        /// Set the <see cref="s_changesSinceLastSave"/> value, and update the LauncherPage for this.
        /// </summary>
        /// <param name="changes"></param>
        internal static void SetChangesSinceSave(bool changes)
        {
            s_changesSinceLastSave = changes;

            LauncherPage.OnChangesSinceLastSaveChanged(changes);
        }
예제 #4
0
        /// <summary>
        /// Every application in Starcounter works like a console application. They have an .EXE ending. They have a Main() function and
        /// they can do console output. However, they are run inside the scope of a database rather than connecting to it.
        /// </summary>
        public static void Init()
        {
            Application application = Application.Current;

            Layout.Register();

            JsonResponseMerger.RegisterMergeCallback(OnJsonMerge);

            application.Use((Request req) => {
                string uri = req.Uri;

                // Checking if we should process this request.
                if (("/" == uri) || (uri.StartsWith("/launcher/", StringComparison.InvariantCultureIgnoreCase)) || (uri.Equals("/launcher", StringComparison.InvariantCultureIgnoreCase))) {
                    return null;
                }
                return WrapInLauncher(req);
            });

            Handle.GET("/launcher", (Request req) => {
                var session = Session.Current;
                LauncherPage launcher;

                if (session != null && session.Data != null) {
                    launcher = (LauncherPage)Session.Current.Data;
                    launcher.uri = req.Uri;
                    MarkWorkspacesInactive(launcher.workspaces);
                    return launcher;
                }

                if (session == null) {
                    session = new Session(SessionOptions.PatchVersioning);
                }

                launcher = new LauncherPage() {
                    Html = "/Launcher/viewmodels/LauncherTemplate.html"
                };

                launcher.Session = session;

                launcher.launchpad.names = Self.GET<Json>(UriMapping.MappingUriPrefix + "/app-name", () => {
                    var p = new Page();
                    return p;
                });
                var setup = Layout.GetSetup("/launcher/launchpad");

                if (setup == null) {
                    // launcher.launchpad.layout = null
                    // workaround for https://github.com/Starcounter/Starcounter/issues/3072
                    // set default value
                    // consider moving to HTML, or pre-populatind default layouts
                    //launcher.launchpad.layout = new Json("{\"width\": \"1000\", \"items\":[]}");
                    launcher.launchpad.layout = "{\"width\": \"1000\", \"items\":[]}";
                } else {
            //                    dynamic setupJson = new Json(setup.Value);
                    launcher.launchpad.layout = setup.Value; //setupJson;
                }

                launcher.user = Self.GET(UriMapping.MappingUriPrefix + "/user", () => {
                    var p = new Page();
                    return p;
                });

                launcher.menu = Self.GET<Json>(UriMapping.MappingUriPrefix + "/menu", () => {
                    var p = new Page() {
                        Html = "/Launcher/viewmodels/LauncherMenu.html"
                    };
                    return p;
                });

                launcher.uri = req.Uri;
                MarkWorkspacesInactive(launcher.workspaces);
                return launcher;
            });

            Handle.GET("/launcher/dashboard", (Request req) => {

                LauncherPage launcher = Self.GET<LauncherPage>("/launcher");

                launcher.currentPage = Self.GET(UriMapping.MappingUriPrefix + "/dashboard", () => {
                    var p = new Page();

                    return p;
                });

                launcher.uri = req.Uri;
                return launcher;
            });

            Handle.GET("/launcher/settings", (Request req) => {

                LauncherPage launcher = Self.GET<LauncherPage>("/launcher");

                launcher.currentPage = Self.GET<SettingsPage>(UriMapping.MappingUriPrefix + "/settings", () => {
                    var p = new SettingsPage() {
                        Html = "/Launcher/viewmodels/SettingsPage.html"

                    };
                    return p;
                });

                launcher.uri = req.Uri;
                return launcher;
            });

            Handle.GET("/launcher/search?query={?}", (Request req, string query) => {
             //   LauncherPage launcher = Self.GET<LauncherPage>("/launcher");

               // string uri = UriMapping.MappingUriPrefix + "/search?query=" + HttpUtility.UrlEncode(query);
                /*
                launcher.currentPage = Self.GET<ResultPage>(uri, () => {
                    var p = new ResultPage() {
                        Html = "/Launcher/viewmodels/ResultPage.html"
                    };
                    return p;
                });

                launcher.uri = req.Uri;
                launcher.searchBar.query = query;*/

                return null;
            });

            // + dummy responses from launcher itself
            // Merges HTML partials according to provided URLs.
            Handle.GET(StarcounterConstants.HtmlMergerPrefix + "{?}", (String s) => {

                StringBuilder sb = new StringBuilder();

                String[] allPartialInfos = s.Split(new char[] { '&' });

                foreach (String appNamePlusPartialUrl in allPartialInfos) {

                    String[] a = appNamePlusPartialUrl.Split(new char[] { '=' });
                    if (String.IsNullOrEmpty(a[1]))
                        continue;

                    Response resp = Self.GET(a[1]);
                    sb.Append("<imported-template-scope scope=\"" + a[0] + "\">");
                    sb.Append("<template><juicy-tile-group name=\"" + a[0] + "\"></juicy-tile-group></template>");
                    if (resp != null)
                        sb.Append(resp.Body);
                    sb.Append("</imported-template-scope>");
                }

                return sb.ToString();
            }, new HandlerOptions() {
                SkipHandlersPolicy = true,
                ReplaceExistingHandler = true
            });
        }