All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.techad.edc.popover.swing.EdcSwingHelpSingleton Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package fr.techad.edc.popover.swing;

import com.google.inject.Guice;
import com.google.inject.Injector;
import fr.techad.edc.client.EdcClient;
import fr.techad.edc.client.injector.EdcClientModule;
import fr.techad.edc.popover.injector.EdcPopoverModule;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseListener;

/**
 * This classe declare a singleton to configure and create a Swing component.
 * 

* DO NOT USE IT if to use injection. */ public class EdcSwingHelpSingleton implements EdcSwingHelp { private static EdcSwingHelpSingleton instance = null; private EdcSwingHelp edcSwingHelp; private EdcClient edcClient; /** * A private constructor to avoid to instantiate it. * Use the method {@link EdcSwingHelpSingleton#getInstance()} */ private EdcSwingHelpSingleton() { super(); } /** * Return the unique instance of this utility class * * @return the instance */ public static EdcSwingHelpSingleton getInstance() { if (instance == null) { instance = new EdcSwingHelpSingleton(); instance.init(); } return instance; } /** * Initialize the instance. */ private void init() { // Init the injector with Client and Popover Module. Injector injector = Guice.createInjector(new EdcClientModule(), new EdcPopoverModule()); // Get the instance edcSwingHelp = injector.getInstance(EdcSwingHelp.class); edcClient = injector.getInstance(EdcClient.class); } /** * Return the EdcClient instance. *

* Warning, if you don't use the injection, do not use the {@link fr.techad.edc.client.EdcClientSingleton} because * the injection scope is different and the instance will be different. * * @return the edc client instance. */ public EdcClient getEdcClient() { return this.edcClient; } @Override public JComponent createComponent(String mainKey, String subKey) { return edcSwingHelp.createComponent(mainKey, subKey); } @Override public MouseListener getMouseListener(String mainKey, String subKey) { return edcSwingHelp.getMouseListener(mainKey, subKey); } @Override public void setIconPath(String iconPath) { edcSwingHelp.setIconPath(iconPath); } @Override public void setCloseIconPath(String iconPath) { edcSwingHelp.setCloseIconPath(iconPath); } @Override public void setLanguageCode(String languageCode) { edcSwingHelp.setLanguageCode(languageCode); } @Override public void setTooltipLabel(String label) { edcSwingHelp.setTooltipLabel(label); } @Override public void setSummaryDisplay(boolean enable) { edcSwingHelp.setSummaryDisplay(enable); } @Override public void setBackgroundColor(Color backgroundColor) { edcSwingHelp.setBackgroundColor(backgroundColor); } @Override public void setInternalBrowser(boolean state) { edcSwingHelp.setInternalBrowser(state); } @Override public void setAutoDisabledMode(boolean state) { edcSwingHelp.setAutoDisabledMode(state); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy