//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// This file is a part of the 'gewt' project.
// Copyright 2018 Elmar Sonnenschein, esoco GmbH, Flensburg, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//	  http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
package de.esoco.ewt.app;

import de.esoco.ewt.EWT;
import de.esoco.ewt.UserInterfaceContext;
import de.esoco.ewt.component.View;

import java.util.HashMap;
import java.util.Map;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.i18n.client.ConstantsWithLookup;
import com.google.gwt.resources.client.ImageResource;


/********************************************************************
 * The base class for GEWT applications.
 *
 * @author eso
 */
public abstract class EWTEntryPoint implements EntryPoint
{
	//~ Methods ----------------------------------------------------------------

	/***************************************
	 * Creates a new user interface context for GWT and invokes the method
	 * {@link EWTModule#showModuleView(UserInterfaceContext, View)} with it.
	 */
	@Override
	public void onModuleLoad()
	{
		EWT.CSS.ensureInjected();

		EWTModule rModule = getApplicationModule();

		GwtResource aResource =
			new GwtResource(getApplicationStrings(), getApplicationImages());

		UserInterfaceContext rContext =
			EWT.createUserInterfaceContext(aResource);

		View rModuleView = rModule.createModuleView(rContext);

		rModule.showModuleView(rContext, rModuleView);
	}

	/***************************************
	 * Must be implemented by subclasses to return the application module that
	 * creates and manages the user interface of this GEWT entry point. This
	 * method will only be invoked once. Therefore the implementation may create
	 * the module instance on the fly if it doesn't need to keep a reference to
	 * it.
	 *
	 * @return The application module
	 */
	protected abstract EWTModule getApplicationModule();

	/***************************************
	 * Returns a mapping from resource identifiers to image resources. The
	 * default implementation returns an empty map.
	 *
	 * @return The image resources for this application or NULL for none
	 */
	protected Map<String, ImageResource> getApplicationImages()
	{
		return new HashMap<>();
	}

	/***************************************
	 * Returns an arrays of {@link ConstantsWithLookup} instances with the
	 * application's resource string. The default implementation returns an
	 * empty array.
	 *
	 * @return The resource strings for this application or NULL for none
	 */
	protected ConstantsWithLookup[] getApplicationStrings()
	{
		return new ConstantsWithLookup[0];
	}
}

@@ -970,23 +970,73 @@
 va.util.
-HashMap
+ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.List
 ;%0Aimport
@@ -2534,16 +2534,504 @@
 ule();%0A%0A
+%09/***************************************%0A%09 * Replaced with %7B@link #getImageResources()%7D.%0A%09 *%0A%09 * @return%0A%09 *%0A%09 * @deprecated%0A%09 */%0A%09@Deprecated%0A%09protected Map%3CString, ImageResource%3E getApplicationImages()%0A%09%7B%0A%09%09return getImageResources();%0A%09%7D%0A%0A%09/***************************************%0A%09 * Replaced with %7B@link #getStringResources()%7D.%0A%09 *%0A%09 * @return%0A%09 *%0A%09 * @deprecated%0A%09 */%0A%09@Deprecated%0A%09protected ConstantsWithLookup%5B%5D getApplicationStrings()%0A%09%7B%0A%09%09return new ConstantsWithLookup%5B0%5D;%0A%09%7D%0A%0A
 %09/******
@@ -3183,16 +3183,55 @@
 mpty map
+ that can be modified by%0A%09 * subclasses
 .%0A%09 *%0A%09 
@@ -3280,33 +3280,16 @@
 lication
- or NULL for none
 %0A%09 */%0A%09p
@@ -3331,53 +3331,57 @@
  get
-ApplicationImages()%0A%09%7B%0A%09%09return new HashMap%3C%3E
+ImageResources()%0A%09%7B%0A%09%09return getApplicationImages
 ();%0A
@@ -3443,16 +3443,13 @@
 ns a
-n arrays
+ list
  of 
@@ -3582,13 +3582,47 @@
 pty 
-array
+list that can be modified by subclasses
 .%0A%09 
@@ -3680,25 +3680,8 @@
 tion
- or NULL for none
 %0A%09 *
@@ -3685,32 +3685,37 @@
 %09 */%0A%09protected 
+List%3C
 ConstantsWithLoo
@@ -3717,39 +3717,35 @@
 thLookup
-%5B%5D
+%3E
  get
-ApplicationString
+StringResource
 s()%0A%09%7B%0A%09
@@ -3756,37 +3756,66 @@
 urn new 
-ConstantsWithLookup%5B0%5D
+ArrayList%3C%3E(Arrays.asList(getApplicationStrings()))
 ;%0A%09%7D%0A%7D%0A

Simplify application structure