org.eclipse.jst.jsf.common.ui_1.2.100.v201104061711

16:45:49.388 INFO  jd.cli.Main - Decompiling org.eclipse.jst.jsf.common.ui_1.2.100.v201104061711.jar
package org.eclipse.jst.jsf.common.ui;

public abstract interface IFileFolderConstants
{
  public static final String DOT = ".";
  public static final String PATH_SEPARATOR = "/";
  public static final String EXT_CLASS = "class";
  public static final String EXT_JAR = "jar";
  public static final String EXT_JAVA = "java";
  public static final String EXT_JSP = "jsp";
  public static final String EXT_PROPERTIES = "properties";
  public static final String EXT_TAGLIB = "tld";
  public static final String FILE_WEB_XML = "web.xml";
  public static final String FOLDER_CLASS = "classes";
  public static final String FOLDER_ICONS = "icons";
  public static final String FOLDER_METAINF = "META-INF";
  public static final String FOLDER_SOURCE = "src";
  public static final String FOLDER_WEBINF = "WEB-INF";
  public static final int WEBROOT_FOLDER_DEPTH = 2;
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.IFileFolderConstants
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Dictionary;
import java.util.MissingResourceException;
import java.util.Properties;
import java.util.ResourceBundle;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jst.jsf.common.ui.internal.guiutils.Alerts;
import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;

public class JSFUICommonPlugin
  extends AbstractUIPlugin
{
  private static final String PROPERTIES = "default.properties";
  private static final String P_CONSOLE_LOGGING = "console.logging.on";
  private static final String P_CONSOLE_LOG_LEVEL = "console.logging.max.level";
  private static final String P_ECLIPSE_LOGGING = "eclipse.logging.on";
  private static final String P_ECLIPSE_LOG_LEVEL = "eclipse.logging.max.level";
  private static final String P_FILE_LOGGING = "file.logging.on";
  private static final String P_FILE_LOG_LEVEL = "file.logging.max.level";
  private static final String P_FILE_PATH = "file.logging.path";
  private static final String P_FILE_CLEAR = "file.logging.startup.clear";
  private static final String P_FILE_ROLLOVER_FREQUENCY = "file.logging.rollover.frequency";
  private static final int DEBUG_LEVEL = 0;
  private static final int INFO_LEVEL = 1;
  private static final int WARN_LEVEL = 2;
  private static final int ERROR_LEVEL = 3;
  private static final int FATAL_LEVEL = 4;
  private static boolean TWO_DOT_ONE;
  private static boolean THREE_DOT;
  private static String _version;
  private static JSFUICommonPlugin _plugin;
  private Logger _log;
  private ResourceBundle _resourceBundle;
  private Properties _properties;
  private URL _pluginBase;
  private static Alerts _alerts;
  
  public JSFUICommonPlugin()
  {
    _plugin = this;
    versionCheck();
  }
  
  private void versionCheck()
  {
    String version = 
      (String)ResourcesPlugin.getPlugin().getBundle().getHeaders().get("Bundle-Version");
    Version identifier = new Version(version);
    
    TWO_DOT_ONE = (identifier.getMajor() == 2) && 
      (identifier.getMinor() == 1);
    THREE_DOT = identifier.getMajor() == 3;
    _version = identifier.toString();
  }
  
  /* Error */
  public void start(org.osgi.framework.BundleContext context)
    throws java.lang.Exception
  {
    // Byte code:
    //   0: aload_0
    //   1: aload_1
    //   2: invokespecial 350	org/eclipse/ui/plugin/AbstractUIPlugin:start	(Lorg/osgi/framework/BundleContext;)V
    //   5: invokestatic 338	org/eclipse/jst/jsf/common/ui/JSFUICommonPlugin:isThreeDot	()Z
    //   8: ifne +32 -> 40
    //   11: new 183	org/eclipse/core/runtime/CoreException
    //   14: dup
    //   15: new 185	org/eclipse/core/runtime/Status
    //   18: dup
    //   19: iconst_4
    //   20: aload_0
    //   21: invokevirtual 344	org/eclipse/jst/jsf/common/ui/JSFUICommonPlugin:getBundle	()Lorg/osgi/framework/Bundle;
    //   24: invokeinterface 357 1 0
    //   29: iconst_0
    //   30: ldc 5
    //   32: aconst_null
    //   33: invokespecial 332	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
    //   36: invokespecial 330	org/eclipse/core/runtime/CoreException:<init>	(Lorg/eclipse/core/runtime/IStatus;)V
    //   39: athrow
    //   40: aload_0
    //   41: ldc 17
    //   43: invokestatic 327	java/util/ResourceBundle:getBundle	(Ljava/lang/String;)Ljava/util/ResourceBundle;
    //   46: putfield 310	org/eclipse/jst/jsf/common/ui/JSFUICommonPlugin:_resourceBundle	Ljava/util/ResourceBundle;
    //   49: new 190	org/eclipse/jst/jsf/common/ui/internal/guiutils/Alerts
    //   52: dup
    //   53: aload_0
    //   54: aload_0
    //   55: getfield 310	org/eclipse/jst/jsf/common/ui/JSFUICommonPlugin:_resourceBundle	Ljava/util/ResourceBundle;
    //   58: invokespecial 345	org/eclipse/jst/jsf/common/ui/internal/guiutils/Alerts:<init>	(Lorg/eclipse/ui/plugin/AbstractUIPlugin;Ljava/util/ResourceBundle;)V
    //   61: putstatic 312	org/eclipse/jst/jsf/common/ui/JSFUICommonPlugin:_alerts	Lorg/eclipse/jst/jsf/common/ui/internal/guiutils/Alerts;
    //   64: aload_0
    //   65: new 180	java/util/Properties
    //   68: dup
    //   69: invokespecial 323	java/util/Properties:<init>	()V
    //   72: putfield 309	org/eclipse/jst/jsf/common/ui/JSFUICommonPlugin:_properties	Ljava/util/Properties;
    //   75: aconst_null
    //   76: astore_2
    //   77: aload_0
    //   78: aload_0
    //   79: invokevirtual 344	org/eclipse/jst/jsf/common/ui/JSFUICommonPlugin:getBundle	()Lorg/osgi/framework/Bundle;
    //   82: ldc 1
    //   84: invokeinterface 359 2 0
    //   89: putfield 308	org/eclipse/jst/jsf/common/ui/JSFUICommonPlugin:_pluginBase	Ljava/net/URL;
    //   92: new 177	java/net/URL
    //   95: dup
    //   96: aload_0
    //   97: getfield 308	org/eclipse/jst/jsf/common/ui/JSFUICommonPlugin:_pluginBase	Ljava/net/URL;
    //   100: ldc 8
    //   102: invokespecial 321	java/net/URL:<init>	(Ljava/net/URL;Ljava/lang/String;)V
    //   105: invokevirtual 320	java/net/URL:openStream	()Ljava/io/InputStream;
    //   108: astore_2
    //   109: aload_0
    //   110: getfield 309	org/eclipse/jst/jsf/common/ui/JSFUICommonPlugin:_properties	Ljava/util/Properties;
    //   113: aload_2
    //   114: invokevirtual 324	java/util/Properties:load	(Ljava/io/InputStream;)V
    //   117: goto +14 -> 131
    //   120: astore_3
    //   121: aload_2
    //   122: invokevirtual 314	java/io/InputStream:close	()V
    //   125: goto +4 -> 129
    //   128: pop
    //   129: aload_3
    //   130: athrow
    //   131: aload_2
    //   132: invokevirtual 314	java/io/InputStream:close	()V
    //   135: goto +4 -> 139
    //   138: pop
    //   139: aload_0
    //   140: new 191	org/eclipse/jst/jsf/common/ui/internal/logging/Logger
    //   143: dup
    //   144: aload_0
    //   145: invokevirtual 344	org/eclipse/jst/jsf/common/ui/JSFUICommonPlugin:getBundle	()Lorg/osgi/framework/Bundle;
    //   148: aload_0
    //   149: getfield 310	org/eclipse/jst/jsf/common/ui/JSFUICommonPlugin:_resourceBundle	Ljava/util/ResourceBundle;
    //   152: invokespecial 346	org/eclipse/jst/jsf/common/ui/internal/logging/Logger:<init>	(Lorg/osgi/framework/Bundle;Ljava/util/ResourceBundle;)V
    //   155: putfield 313	org/eclipse/jst/jsf/common/ui/JSFUICommonPlugin:_log	Lorg/eclipse/jst/jsf/common/ui/internal/logging/Logger;
    //   158: goto +52 -> 210
    //   161: astore_2
    //   162: aload_0
    //   163: getfield 313	org/eclipse/jst/jsf/common/ui/JSFUICommonPlugin:_log	Lorg/eclipse/jst/jsf/common/ui/internal/logging/Logger;
    //   166: ifnull +15 -> 181
    //   169: aload_0
    //   170: getfield 313	org/eclipse/jst/jsf/common/ui/JSFUICommonPlugin:_log	Lorg/eclipse/jst/jsf/common/ui/internal/logging/Logger;
    //   173: ldc 16
    //   175: ldc 4
    //   177: aload_2
    //   178: invokevirtual 347	org/eclipse/jst/jsf/common/ui/internal/logging/Logger:error	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   181: new 183	org/eclipse/core/runtime/CoreException
    //   184: dup
    //   185: new 185	org/eclipse/core/runtime/Status
    //   188: dup
    //   189: iconst_4
    //   190: aload_0
    //   191: invokevirtual 344	org/eclipse/jst/jsf/common/ui/JSFUICommonPlugin:getBundle	()Lorg/osgi/framework/Bundle;
    //   194: invokeinterface 357 1 0
    //   199: iconst_0
    //   200: ldc 3
    //   202: aload_2
    //   203: invokespecial 332	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
    //   206: invokespecial 330	org/eclipse/core/runtime/CoreException:<init>	(Lorg/eclipse/core/runtime/IStatus;)V
    //   209: athrow
    //   210: return
    // Line number table:
    //   Java source line #119	-> byte code offset #0
    //   Java source line #122	-> byte code offset #5
    //   Java source line #123	-> byte code offset #11
    //   Java source line #124	-> byte code offset #24
    //   Java source line #125	-> byte code offset #30
    //   Java source line #123	-> byte code offset #36
    //   Java source line #130	-> byte code offset #40
    //   Java source line #131	-> byte code offset #41
    //   Java source line #130	-> byte code offset #46
    //   Java source line #132	-> byte code offset #49
    //   Java source line #135	-> byte code offset #64
    //   Java source line #136	-> byte code offset #75
    //   Java source line #137	-> byte code offset #77
    //   Java source line #139	-> byte code offset #92
    //   Java source line #140	-> byte code offset #109
    //   Java source line #141	-> byte code offset #120
    //   Java source line #143	-> byte code offset #121
    //   Java source line #144	-> byte code offset #128
    //   Java source line #148	-> byte code offset #129
    //   Java source line #143	-> byte code offset #131
    //   Java source line #144	-> byte code offset #138
    //   Java source line #151	-> byte code offset #139
    //   Java source line #160	-> byte code offset #161
    //   Java source line #162	-> byte code offset #162
    //   Java source line #163	-> byte code offset #169
    //   Java source line #165	-> byte code offset #173
    //   Java source line #166	-> byte code offset #175
    //   Java source line #167	-> byte code offset #177
    //   Java source line #164	-> byte code offset #178
    //   Java source line #170	-> byte code offset #181
    //   Java source line #171	-> byte code offset #185
    //   Java source line #172	-> byte code offset #189
    //   Java source line #173	-> byte code offset #190
    //   Java source line #174	-> byte code offset #199
    //   Java source line #175	-> byte code offset #200
    //   Java source line #176	-> byte code offset #202
    //   Java source line #171	-> byte code offset #203
    //   Java source line #170	-> byte code offset #206
    //   Java source line #178	-> byte code offset #210
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	211	0	this	JSFUICommonPlugin
    //   0	211	1	context	org.osgi.framework.BundleContext
    //   76	56	2	input	java.io.InputStream
    //   161	42	2	ee	Exception
    //   120	10	3	localObject	Object
    //   128	1	5	localIOException1	java.io.IOException
    //   138	1	6	localIOException2	java.io.IOException
    // Exception table:
    //   from	to	target	type
    //   92	120	120	finally
    //   121	125	128	java/io/IOException
    //   131	135	138	java/io/IOException
    //   40	158	161	java/lang/Exception
  }
  
  public static JSFUICommonPlugin getDefault()
  {
    return _plugin;
  }
  
  public static Alerts getAlerts()
  {
    return _alerts;
  }
  
  public static Logger getLogger(Class theClass)
  {
    return getDefault().getRootLogger();
  }
  
  public Logger getRootLogger()
  {
    return _log;
  }
  
  public static String getPluginId()
  {
    return getDefault().getBundle().getSymbolicName();
  }
  
  public ResourceBundle getResourceBundle()
  {
    return _resourceBundle;
  }
  
  public static String getResourceString(String key)
  {
    ResourceBundle bundle = getDefault().getResourceBundle();
    try
    {
      return bundle != null ? bundle.getString(key) : key;
    }
    catch (MissingResourceException localMissingResourceException) {}
    return key;
  }
  
  public ResourceBundle getPluginDecriptorBundle()
  {
    return Platform.getResourceBundle(getDefault().getBundle());
  }
  
  public Properties getProperties()
  {
    return _properties;
  }
  
  public Image getImage(String name)
  {
    if (name == null) {
      return null;
    }
    ImageRegistry images = getImageRegistry();
    Image image = images.get(name);
    if (image == null) {
      try
      {
        ImageDescriptor id = ImageDescriptor.createFromURL(new URL(
          _pluginBase, "icons/" + name));
        images.put(name, id);
        
        image = images.get(name);
      }
      catch (MalformedURLException ee)
      {
        _log.error("log.msg", "log.CommonPlugin.image.error", name, ee);
      }
    }
    return image;
  }
  
  public ImageDescriptor getImageDescriptor(String name)
  {
    if (name == null) {
      return null;
    }
    ImageRegistry images = getImageRegistry();
    ImageDescriptor id = images.getDescriptor(name);
    if (id == null) {
      try
      {
        id = ImageDescriptor.createFromURL(new URL(_pluginBase, 
          "icons/" + name));
        images.put(name, id);
      }
      catch (MalformedURLException ee)
      {
        _log.error("log.msg", "log.CommonPlugin.image.error", name, ee);
      }
    }
    return id;
  }
  
  public static boolean isTwoDotOne()
  {
    return TWO_DOT_ONE;
  }
  
  public static boolean isThreeDot()
  {
    return THREE_DOT;
  }
  
  public static String getVersion()
  {
    return _version;
  }
  
  protected void initializeDefaultPreferences(IPreferenceStore store)
  {
    store.setDefault("console.logging.on", _properties.getProperty(
      "console.logging.on", Boolean.TRUE.toString()));
    store.setDefault("console.logging.max.level", strToIntLogLevel(_properties
      .getProperty("console.logging.max.level", "ERROR")));
    
    store.setDefault("eclipse.logging.on", _properties.getProperty(
      "eclipse.logging.on", Boolean.TRUE.toString()));
    store.setDefault("eclipse.logging.max.level", strToIntLogLevel(_properties
      .getProperty("eclipse.logging.max.level", "ERROR")));
    
    store.setDefault("file.logging.on", _properties.getProperty(
      "file.logging.on", Boolean.FALSE.toString()));
    store.setDefault("file.logging.max.level", strToIntLogLevel(_properties
      .getProperty("file.logging.max.level", "ERROR")));
    store.setDefault("file.logging.path", _properties.getProperty("file.logging.path", ""));
    store.setDefault("file.logging.startup.clear", _properties.getProperty("file.logging.startup.clear", 
      Boolean.TRUE.toString()));
    store.setDefault("file.logging.rollover.frequency", _properties.getProperty(
      "file.logging.rollover.frequency", "DAILY"));
  }
  
  private int strToIntLogLevel(String str)
  {
    if (str == null) {
      return 3;
    }
    if (str.equalsIgnoreCase("DEBUG")) {
      return 0;
    }
    if (str.equalsIgnoreCase("INFO")) {
      return 1;
    }
    if (str.equalsIgnoreCase("WARN")) {
      return 2;
    }
    if (str.equalsIgnoreCase("FATAL")) {
      return 4;
    }
    return 3;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.JSFUICommonPlugin
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.actions;

public abstract interface IOpenPage
{
  public abstract void setActiveEditorPage(String paramString);
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.actions.IOpenPage
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.actions;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.cheatsheets.OpenCheatSheetAction;

public class LoadCheatSheetAction
  extends Action
  implements IExecutableExtension
{
  private String _cheatSheetName = null;
  
  public void run()
  {
    if (_cheatSheetName != null)
    {
      OpenCheatSheetAction action = new OpenCheatSheetAction(
        _cheatSheetName);
      action.run();
    }
  }
  
  public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
    throws CoreException
  {
    _cheatSheetName = config.getAttribute("actionparameters");
  }
  
  public void setCheatSheetName(String cheatSheetName)
  {
    _cheatSheetName = cheatSheetName;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.actions.LoadCheatSheetAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.actions;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.help.HelpSystem;
import org.eclipse.help.IContext;
import org.eclipse.help.IHelpResource;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.help.IWorkbenchHelpSystem;

public class LoadHelpAction
  extends Action
  implements IExecutableExtension
{
  private String _helpContextId = null;
  
  public void run()
  {
    IContext context = HelpSystem.getContext(_helpContextId);
    if (context != null)
    {
      IHelpResource[] topics = context.getRelatedTopics();
      if ((topics != null) && (topics.length == 1)) {
        PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(
          topics[0].getHref());
      } else {
        PlatformUI.getWorkbench().getHelpSystem().displayHelp(
          _helpContextId);
      }
    }
  }
  
  public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
    throws CoreException
  {
    _helpContextId = config.getAttribute("actionparameters");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.actions.LoadHelpAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.actions;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.editor.FormEditor;

public class OpenPageAction
  extends Action
  implements IExecutableExtension
{
  private String pageID = null;
  private ISelection selection;
  
  public void run()
  {
    if (pageID != null)
    {
      IEditorPart editor = getActiveEditor();
      IOpenPage openPage = (IOpenPage)editor.getAdapter(IOpenPage.class);
      if (openPage != null)
      {
        openPage.setActiveEditorPage(pageID);
        if ((selection != null) && ((editor instanceof FormEditor)))
        {
          IEditorPart activePage = ((FormEditor)editor)
            .getActiveEditor();
          if ((activePage instanceof ISelectionProvider)) {
            ((ISelectionProvider)activePage).setSelection(selection);
          }
        }
      }
    }
  }
  
  public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
    throws CoreException
  {
    pageID = config.getAttribute("actionparameters");
  }
  
  public void setPageName(String className)
  {
    pageID = className;
  }
  
  public static IEditorPart getActiveEditor()
  {
    IEditorPart editor = null;
    IWorkbenchWindow win = PlatformUI.getWorkbench()
      .getActiveWorkbenchWindow();
    if (win != null)
    {
      IWorkbenchPage page = win.getActivePage();
      if (page != null) {
        editor = page.getActiveEditor();
      }
    }
    return editor;
  }
  
  public ISelection getSelection()
  {
    return selection;
  }
  
  public void setSelection(ISelection selection)
  {
    this.selection = selection;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.actions.OpenPageAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;

class AbstractClassButtonDialogField$1
  extends HyperlinkAdapter
{
  AbstractClassButtonDialogField$1(AbstractClassButtonDialogField paramAbstractClassButtonDialogField) {}
  
  public void linkActivated(HyperlinkEvent e)
  {
    AbstractClassButtonDialogField.access$0(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.AbstractClassButtonDialogField.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

class AbstractClassButtonDialogField$2
  implements IStringButtonAdapter
{
  AbstractClassButtonDialogField$2(AbstractClassButtonDialogField paramAbstractClassButtonDialogField) {}
  
  public void changeControlPressed(DialogField field)
  {
    AbstractClassButtonDialogField.access$1(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.AbstractClassButtonDialogField.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jst.jsf.common.ui.JSFUICommonPlugin;
import org.eclipse.jst.jsf.common.ui.internal.guiutils.Alerts;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.SelectionDialog;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;

abstract class AbstractClassButtonDialogField
  extends StringButtonDialogField
{
  private IProject _project;
  private String _superClass;
  private List _interfacesList;
  private IType _type;
  private int _typeFlag = 256;
  private boolean _autoOpenResource = true;
  
  public void setAutoOpenResource(boolean autoOpenResource)
  {
    _autoOpenResource = autoOpenResource;
  }
  
  public AbstractClassButtonDialogField(IProject project)
  {
    super(null);
    _project = project;
    
    setHyperLink(new HyperlinkAdapter()
    {
      public void linkActivated(HyperlinkEvent e)
      {
        AbstractClassButtonDialogField.this.activeLink();
      }
    });
    setStringButtonAdapter(new IStringButtonAdapter()
    {
      public void changeControlPressed(DialogField field)
      {
        AbstractClassButtonDialogField.this.browseButtonPressed();
      }
    });
  }
  
  private void activeLink()
  {
    String className = getText();
    className = trimNonAlphaChars(className);
    if ((className.length() > 0) && 
      (JavaUIHelper.doesClassExist(_project, className)))
    {
      JavaUIHelper.doOpenClass(_project, className);
    }
    else
    {
      try
      {
        if ((_project == null) || (!_project.hasNature("org.eclipse.jdt.core.javanature")))
        {
          ResourceBundle rb = 
            ResourceBundle.getBundle("org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogFieldResources");
          Alerts alerts = new Alerts(JSFUICommonPlugin.getDefault(), rb);
          alerts.error("ClassButtonDialogField.Alert.Title", 
            "ClassButtonDialogField.Alert.Msg");
          return;
        }
      }
      catch (CoreException e)
      {
        e.printStackTrace();
        return;
      }
      JavaClassWizard wizard = new JavaClassWizard(_project, className, 
        _superClass, getImplementInterfaces());
      wizard.setAutoOpenResource(_autoOpenResource);
      WizardDialog dialog = new WizardDialog(getShell(), wizard);
      dialog.create();
      
      setDialogSize(dialog, 400, 500);
      if (dialog.open() == 0)
      {
        String newValue = wizard.getClassNameWithArgs();
        if (!newValue.equals(className)) {
          setText(newValue);
        }
      }
    }
  }
  
  protected abstract List getImplementInterfaces();
  
  protected abstract IJavaSearchScope getJavaSearchScope();
  
  private void browseButtonPressed()
  {
    Shell shell = getShell();
    SelectionDialog dialog = JavaUIHelper.openSelectionDialog(shell, 
      getJavaSearchScope(), _typeFlag);
    dialog.setTitle(
      JSFUICommonPlugin.getResourceString("DialogField.ClassButton.SelectType"));
    if (dialog.open() == 0)
    {
      String oldClassName = getText();
      if (dialog.getResult() != null)
      {
        _type = ((IType)dialog.getResult()[0]);
        String newClassName = _type.getFullyQualifiedName();
        if (!oldClassName.equals(newClassName)) {
          setText(newClassName);
        }
      }
    }
  }
  
  private void setDialogSize(Dialog dialog, int width, int height)
  {
    Point computedSize = dialog.getShell().computeSize(-1, 
      -1);
    width = Math.max(x, width);
    height = Math.max(y, height);
    dialog.getShell().setSize(width, height);
  }
  
  private String trimNonAlphaChars(String className)
  {
    className = className.trim();
    while ((className.length() > 0) && (!
      Character.isLetter(className.charAt(0)))) {
      className = className.substring(1, className.length());
    }
    int loc = className.indexOf(":");
    if ((loc != -1) && (loc > 0)) {
      className = className.substring(0, loc);
    } else if (loc == 0) {
      className = "";
    }
    return className;
  }
  
  public IProject getProject()
  {
    return _project;
  }
  
  public void setProject(IProject project)
  {
    _project = project;
  }
  
  public String getSuperClassName()
  {
    return _superClass;
  }
  
  public void setSuperClassName(String superClassName)
  {
    _superClass = superClassName;
  }
  
  protected List getInterfacesList()
  {
    return _interfacesList;
  }
  
  public void setInterface(String interfaceName)
  {
    _interfacesList = new ArrayList();
    _interfacesList.add(interfaceName);
  }
  
  public IType getType()
  {
    return _type;
  }
  
  public int getTypeFlag()
  {
    return _typeFlag;
  }
  
  public void setTypeFlag(int typeFalg)
  {
    _typeFlag = typeFalg;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.AbstractClassButtonDialogField
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;

public class ClassButtonDialogField
  extends AbstractClassButtonDialogField
{
  public ClassButtonDialogField(IProject project)
  {
    super(project);
  }
  
  protected List getImplementInterfaces()
  {
    return getInterfacesList();
  }
  
  protected IJavaSearchScope getJavaSearchScope()
  {
    String superType = getSuperClassName();
    List interfaceList = getInterfacesList();
    if ((superType == null) && (interfaceList != null) && 
      (interfaceList.size() > 0)) {
      superType = interfaceList.get(0).toString();
    }
    if ((getSuperClassName() != null) && (interfaceList != null) && 
      (interfaceList.size() > 0)) {
      superType = null;
    }
    IJavaSearchScope scope;
    IJavaSearchScope scope;
    if (superType == null) {
      scope = 
        SearchEngine.createJavaSearchScope(new IJavaProject[] {
        JavaCore.create(getProject()) });
    } else {
      scope = JavaUIHelper.findSearchScope(getProject(), superType);
    }
    return scope;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;

class ColorButtonDialogField$1
  implements SelectionListener
{
  ColorButtonDialogField$1(ColorButtonDialogField paramColorButtonDialogField) {}
  
  public void widgetDefaultSelected(SelectionEvent e)
  {
    ColorButtonDialogField.access$0(this$0);
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    ColorButtonDialogField.access$0(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.ColorButtonDialogField.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;

class ColorButtonDialogField$2
  implements DisposeListener
{
  ColorButtonDialogField$2(ColorButtonDialogField paramColorButtonDialogField) {}
  
  public void widgetDisposed(DisposeEvent event)
  {
    ColorButtonDialogField.access$1(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.ColorButtonDialogField.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;

class ColorButtonDialogField$3
  implements SelectionListener
{
  ColorButtonDialogField$3(ColorButtonDialogField paramColorButtonDialogField) {}
  
  public void widgetDefaultSelected(SelectionEvent e)
  {
    ColorButtonDialogField.access$2(this$0);
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    ColorButtonDialogField.access$2(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.ColorButtonDialogField.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;

class ColorButtonDialogField$4
  extends FocusAdapter
{
  ColorButtonDialogField$4(ColorButtonDialogField paramColorButtonDialogField) {}
  
  public void focusLost(FocusEvent e)
  {
    ColorButtonDialogField.access$2(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.ColorButtonDialogField.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.eclipse.jst.jsf.common.ui.internal.utils.StyleCombo;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.ColorDialog;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.forms.widgets.FormToolkit;

public class ColorButtonDialogField
  extends StyleComboDialogField
{
  private Button _button;
  private boolean _buttonEnabled;
  private Color _color;
  private RGB _colorValue;
  private StyleCombo _combo;
  private Image _emptyImage;
  private Point _extent;
  private Image _image;
  private ColorPalette _colorPalette;
  
  public ColorButtonDialogField(int flags, ColorPalette colorPalette)
  {
    super(flags);
    _buttonEnabled = true;
    _colorPalette = colorPalette;
  }
  
  private void buttonPressed()
  {
    ColorDialog colorDialog = new ColorDialog(_button.getShell());
    colorDialog.setRGB(_colorValue);
    RGB newColor = colorDialog.open();
    if ((newColor != null) && (!newColor.equals(_colorValue)))
    {
      _colorValue = newColor;
      setText(ColorPalette.getStringColor(newColor));
      updateColorImage();
    }
  }
  
  private Point computeImageSize(Control window)
  {
    GC gc = new GC(window);
    Font f = _button.getFont();
    gc.setFont(f);
    int height = gc.getFontMetrics().getHeight();
    
    Point p = new Point(height * 3 - 6, height - 2);
    gc.dispose();
    return p;
  }
  
  private void disposeResources()
  {
    if (_image != null)
    {
      _image.dispose();
      _image = null;
    }
    if (_emptyImage != null)
    {
      _emptyImage.dispose();
      _emptyImage = null;
    }
    if (_color != null)
    {
      _color.dispose();
      _color = null;
    }
  }
  
  public Control[] doFillIntoGrid(FormToolkit toolkit, Composite parent, int nColumns)
  {
    assertEnoughColumns(nColumns);
    
    Control requiredLabel = getRequiredLabelControl(toolkit, parent);
    requiredLabel.setLayoutData(gridDataForLabel(1));
    
    Control label = getLabelControl(toolkit, parent);
    label.setLayoutData(gridDataForLabel(1));
    
    StyleCombo combo = getComboControl(toolkit, parent);
    combo.setLayoutData(gridDataForCombo(nColumns - 3));
    
    _button = getChangeControl(toolkit, parent);
    _button.setLayoutData(gridDataForButton(1));
    
    return new Control[] { requiredLabel, label, combo, _button };
  }
  
  public void enableButton(boolean enable)
  {
    if (isOkToUse(_button)) {
      _button.setEnabled((isEnabled()) && (enable));
    }
    _buttonEnabled = enable;
  }
  
  public Button getChangeControl(FormToolkit toolkit, Composite parent)
  {
    if (_button == null)
    {
      assertCompositeNotNull(parent);
      if (toolkit != null) {
        _button = toolkit.createButton(parent, "", 8);
      } else {
        _button = new Button(parent, 8);
      }
      _button.setEnabled((isEnabled()) && (_buttonEnabled));
      
      _button.addSelectionListener(new SelectionListener()
      {
        public void widgetDefaultSelected(SelectionEvent e)
        {
          ColorButtonDialogField.this.buttonPressed();
        }
        
        public void widgetSelected(SelectionEvent e)
        {
          ColorButtonDialogField.this.buttonPressed();
        }
      });
      _button.addDisposeListener(new DisposeListener()
      {
        public void widgetDisposed(DisposeEvent event)
        {
          ColorButtonDialogField.this.disposeResources();
        }
      });
      _extent = computeImageSize(parent);
      _image = new Image(parent.getDisplay(), _extent.x, _extent.y);
      _emptyImage = new Image(parent.getDisplay(), _extent.x, _extent.y);
      initEmptyImage(_button);
      updateColorImage();
    }
    return _button;
  }
  
  private String[] getColorList()
  {
    Map map = _colorPalette.getExtendedColorMap();
    List list = new ArrayList(map.keySet());
    Collections.sort(list);
    return (String[])list.toArray(new String[list.size()]);
  }
  
  public StyleCombo getComboControl(FormToolkit toolkit, Composite parent)
  {
    if (_combo == null)
    {
      _combo = super.getComboControl(toolkit, parent);
      
      _combo.addSelectionListener(new SelectionListener()
      {
        public void widgetDefaultSelected(SelectionEvent e)
        {
          ColorButtonDialogField.this.updateImageAfterChanged();
        }
        
        public void widgetSelected(SelectionEvent e)
        {
          ColorButtonDialogField.this.updateImageAfterChanged();
        }
      });
      _combo.addFocusListener(new FocusAdapter()
      {
        public void focusLost(FocusEvent e)
        {
          ColorButtonDialogField.this.updateImageAfterChanged();
        }
      });
      _combo.setItems(getColorList());
    }
    return _combo;
  }
  
  public int getNumberOfControls()
  {
    return 4;
  }
  
  private GridData gridDataForButton(int span)
  {
    GridData gd = new GridData();
    horizontalAlignment = 4;
    grabExcessHorizontalSpace = false;
    horizontalSpan = span;
    widthHint = LayoutUtil.getButtonWidthHint(_button);
    heightHint = _combo.computeSize(-1, -1).y;
    return gd;
  }
  
  private void initEmptyImage(Control parent)
  {
    Color transparentColor = parent.getForeground();
    ImageData imageData = _emptyImage.getImageData();
    transparentPixel = 0;
    GC gc = new GC(_emptyImage);
    gc.setBackground(transparentColor);
    gc.fillRectangle(0, 0, _emptyImage.getBounds().width, 
      _emptyImage.getBounds().height);
  }
  
  public void setColorValue(RGB rgb)
  {
    _colorValue = rgb;
  }
  
  public void setTextWithoutUpdate(String text)
  {
    super.setTextWithoutUpdate(text);
    updateImageAfterChanged();
  }
  
  protected void updateColorImage()
  {
    if (_button.isDisposed()) {
      return;
    }
    if (_colorValue == null)
    {
      _button.setImage(_emptyImage);
      return;
    }
    Display display = _button.getDisplay();
    GC gc = new GC(_image);
    gc.setForeground(display.getSystemColor(2));
    gc.drawRectangle(0, 0, _extent.x - 1, _extent.y - 1);
    if (_color != null) {
      _color.dispose();
    }
    _color = new Color(display, _colorValue);
    gc.setBackground(_color);
    gc.fillRectangle(1, 1, _extent.x - 2, _extent.y - 2);
    gc.dispose();
    _button.setImage(_image);
  }
  
  protected void updateEnableState()
  {
    super.updateEnableState();
    if (isOkToUse(_button)) {
      _button.setEnabled((isEnabled()) && (_buttonEnabled));
    }
  }
  
  private void updateImageAfterChanged()
  {
    String newColor = getText().trim();
    setColorValue(_colorPalette.getExtendedColorRGB(newColor));
    updateColorImage();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.ColorButtonDialogField
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;

public abstract class ColorPalette
{
  public final Color getBasicColor(String cssText)
  {
    return (Color)getBasicColorMap().get(cssText.toLowerCase());
  }
  
  public final Color getExtendedColor(String cssText)
  {
    Set keys = getExtendedColorMap().keySet();
    for (Iterator iterator = keys.iterator(); iterator.hasNext();)
    {
      Stri
1 2 3 4 5 6 7 8 9 10 11

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd