From f591ddea5bccb23309efc6e2691b133531879966 Mon Sep 17 00:00:00 2001 From: Samuel Cardoso Date: Wed, 16 Dec 2015 17:50:36 -0200 Subject: [PATCH] Issue #2 - Make Showcase project compatible with Crux 5.4 --- showcase-core/pom.xml | 6 +-- .../controller/showcase/LanguageManager.java | 30 +++++++----- .../controller/showcase/MainController.java | 49 +++++++++---------- .../client/resource/ShowcaseCoreMessages.java | 14 ++++-- .../resource/large/cssShowcaseLarge.css | 16 ++++-- 5 files changed, 67 insertions(+), 48 deletions(-) diff --git a/showcase-core/pom.xml b/showcase-core/pom.xml index a895e59..4f59311 100644 --- a/showcase-core/pom.xml +++ b/showcase-core/pom.xml @@ -7,9 +7,9 @@ UTF-8 - 5.4-SNAPSHOT - 1.3-SNAPSHOT - 5.4-SNAPSHOT + 5.4.0 + 1.3.0 + 5.4.0 1.7 1.7 diff --git a/showcase-core/src/main/java/org/cruxframework/showcasecore/client/controller/showcase/LanguageManager.java b/showcase-core/src/main/java/org/cruxframework/showcasecore/client/controller/showcase/LanguageManager.java index a71bbc5..d48e41a 100644 --- a/showcase-core/src/main/java/org/cruxframework/showcasecore/client/controller/showcase/LanguageManager.java +++ b/showcase-core/src/main/java/org/cruxframework/showcasecore/client/controller/showcase/LanguageManager.java @@ -1,12 +1,21 @@ package org.cruxframework.showcasecore.client.controller.showcase; -import org.cruxframework.crux.core.client.screen.views.View; - import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Widget; public class LanguageManager { + private Widget langToggler; + private Widget langEn; + private Widget langPt; + + public LanguageManager(Widget langToggler, Widget langEn, Widget langPt) + { + this.langEn = langEn; + this.langPt = langPt; + this.langToggler = langToggler; + } + public void verifyAndToggleLanguage() { String uriLocale = Window.Location.getParameter("locale"); @@ -17,14 +26,9 @@ public void switchLocaleToggle(String locale) { if(locale == null) { - return; + locale = getBrowserLocale(); } - Widget langToggler = View.of(this).getWidget("langToggler"); - - Widget langEn = View.of(this).getWidget("langEn"); - Widget langPt = View.of(this).getWidget("langPt"); - if(locale.contains("pt_BR")) { langEn.removeStyleName("active"); @@ -37,11 +41,15 @@ public void switchLocaleToggle(String locale) langEn.addStyleName("active"); } } - + private native String getBrowserLocale()/*-{ - if($wnd.navigator.language == "pt-br") + + if($wnd.navigator !== undefined && $wnd.navigator.language !== undefined) { - return "pt_BR"; + if($wnd.navigator.language == "pt" || ($wnd.navigator.language.indexOf("pt-") > -1) || ($wnd.navigator.language.indexOf("pt_") > -1)) + { + return "pt_BR"; + } } return "en_US"; }-*/; diff --git a/showcase-core/src/main/java/org/cruxframework/showcasecore/client/controller/showcase/MainController.java b/showcase-core/src/main/java/org/cruxframework/showcasecore/client/controller/showcase/MainController.java index b476d74..84427bd 100644 --- a/showcase-core/src/main/java/org/cruxframework/showcasecore/client/controller/showcase/MainController.java +++ b/showcase-core/src/main/java/org/cruxframework/showcasecore/client/controller/showcase/MainController.java @@ -25,7 +25,6 @@ import org.cruxframework.showcasecore.client.resource.ShowcaseCoreMessages; import org.cruxframework.showcasecore.client.resource.common.ShowcaseResourcesCommon; import org.cruxframework.showcasecore.client.util.LoadingCallback; -import org.cruxframework.showcasecore.client.util.VisualBoxLogHandler; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; @@ -51,9 +50,8 @@ public class MainController private Logger logger = Logger.getLogger(""); - @Inject private LanguageManager languageManager; - + @Expose public void replaceText(AttachEvent event) { @@ -74,9 +72,12 @@ public void setWidgets(MyWidgetAccessor widgets) public static interface MyWidgetAccessor extends WidgetAccessor { MenuTabsDisposal menuDisposal(); + Filter filter(); + Widget langToggler(); + Widget langEn(); + Widget langPt(); } - @Expose public void switchLocaleUrl() { @@ -98,16 +99,17 @@ public void loadShowcaseUrl() } @Expose - public void wellcome() + public void onLoad() { + languageManager = new LanguageManager(widgets.langToggler(), widgets.langEn(), widgets.langPt()); + //add the event log window - if(Screen.getCurrentDevice().getSize().equals(Size.large)) - { - logger.addHandler(new VisualBoxLogHandler(messages.enableLog(), messages.disableLog())); - } + //if(Screen.getCurrentDevice().getSize().equals(Size.large)) + //{ + // logger.addHandler(new VisualBoxLogHandler(messages.enableLog(), messages.disableLog())); + //} String hash = Window.Location.getHash(); - MenuTabsDisposal menuDisposal = (MenuTabsDisposal) Screen.get("menuDisposal"); if(!StringUtils.isEmpty(hash)) { @@ -115,16 +117,16 @@ public void wellcome() if(!"wellcome".equals(viewName)) { - menuDisposal.showView(viewName, Direction.FORWARD); + widgets.menuDisposal().showView(viewName, Direction.FORWARD); } else { - menuDisposal.showView("wellcome", Direction.FORWARD); + widgets.menuDisposal().showView("wellcome", Direction.FORWARD); } } else { - menuDisposal.showView("wellcome", Direction.FORWARD); + widgets.menuDisposal().showView("wellcome", Direction.FORWARD); } //Call method to verify browser language @@ -133,14 +135,14 @@ public void wellcome() if(Screen.getCurrentDevice().getSize().equals(Size.large)) { //Setup the top filters - setupFilters(menuDisposal); + setupFilters(); } } - private void setupFilters(final MenuTabsDisposal menuDisposal) + private void setupFilters() { - final Filter filter = (Filter) Screen.get("filter"); - + final Filter filter = widgets.filter(); + filter.setFilterable(new Filterable() { @Override @@ -212,7 +214,7 @@ public List> filter(String query) @Override public void onSelectItem(String selectedItem) { - menuDisposal.showView(selectedItem, null); + widgets.menuDisposal().showView(selectedItem, null); filter.setText(""); } @@ -222,8 +224,7 @@ public void onSelectItem(String selectedItem) @Expose public void showMenu() { - MenuTabsDisposal menuDisposal = (MenuTabsDisposal) Screen.get("menuDisposal"); - menuDisposal.showMenu(); + widgets.menuDisposal().showMenu(); } @Expose @@ -241,8 +242,7 @@ public void navigateToProject() @Expose public void viewSourceCode() { - MenuTabsDisposal menuDisposal = (MenuTabsDisposal) Screen.get("menuDisposal"); - String viewId = menuDisposal.getCurrentView(); + String viewId = widgets.menuDisposal().getCurrentView(); service.listSourceFilesForView(viewId, new LoadingCallback>() { @@ -349,9 +349,4 @@ public void setMessages(ShowcaseCoreMessages messages) { this.messages = messages; } - - public void setLanguageManager(LanguageManager languageManager) - { - this.languageManager = languageManager; - } } diff --git a/showcase-core/src/main/java/org/cruxframework/showcasecore/client/resource/ShowcaseCoreMessages.java b/showcase-core/src/main/java/org/cruxframework/showcasecore/client/resource/ShowcaseCoreMessages.java index 6fa5003..fd28f92 100644 --- a/showcase-core/src/main/java/org/cruxframework/showcasecore/client/resource/ShowcaseCoreMessages.java +++ b/showcase-core/src/main/java/org/cruxframework/showcasecore/client/resource/ShowcaseCoreMessages.java @@ -14,18 +14,24 @@ @MessageName("messages_core") public interface ShowcaseCoreMessages extends Messages { - @DefaultMessage("O seu navegador não suporta a criação de bancos de dados locais.") + //TODO fix this: https://github.com/CruxFramework/crux/issues/913 +// @DefaultMessage("O seu navegador não suporta a criação de bancos de dados locais.") + @DefaultMessage("Database not supported by your browser") String databaseNotSupportedError(); - @DefaultMessage("Ver Código Fonte") +// @DefaultMessage("Código Fonte") + @DefaultMessage("Source") String viewSourceCode(); - @DefaultMessage("Carregando") +// @DefaultMessage("Carregando") + @DefaultMessage("Loading") String loading(); +// @DefaultMessage("Enable Log") @DefaultMessage("Enable Log") String enableLog(); +// @DefaultMessage("X") @DefaultMessage("X") String disableLog(); -} +} \ No newline at end of file diff --git a/showcase-core/src/main/resources/org/cruxframework/showcasecore/client/resource/large/cssShowcaseLarge.css b/showcase-core/src/main/resources/org/cruxframework/showcasecore/client/resource/large/cssShowcaseLarge.css index 5afa682..608cd53 100644 --- a/showcase-core/src/main/resources/org/cruxframework/showcasecore/client/resource/large/cssShowcaseLarge.css +++ b/showcase-core/src/main/resources/org/cruxframework/showcasecore/client/resource/large/cssShowcaseLarge.css @@ -103,9 +103,19 @@ body { background-repeat: no-repeat; background-position: top; - padding-top: 80px; - background-image: logoLargeUrl; - background-position: center 25px; + padding-top: 120px; + background: logoLargeUrl no-repeat 0 10px #ececec; + background-position: center 18px; +} + +.viewFilter +{ + position: absolute; + z-index: 1; + width: 266px; + margin-left: 16px; + margin-top: 86px; + height: 29px; } .layoutSectionIcon