org.tizen.web.advanceddeclarationview_1.0.0.201310101533

16:50:30.869 INFO  jd.cli.Main - Decompiling org.tizen.web.advanceddeclarationview_1.0.0.201310101533.jar
package org.tizen.web.advanceddeclarationview;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public class Activator
  extends AbstractUIPlugin
{
  public static final String PLUGIN_ID = "org.tizen.web.advanceddeclarationview";
  private static Activator plugin;
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    plugin = this;
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    plugin = null;
    super.stop(context);
  }
  
  public static Activator getDefault()
  {
    return plugin;
  }
  
  public static ImageDescriptor getImageDescriptor(String path)
  {
    return imageDescriptorFromPlugin("org.tizen.web.advanceddeclarationview", path);
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.advanceddeclarationview.Activator
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.advanceddeclarationview.ui;

import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.IWorkbenchPartSite;

class AdvancedDeclarationView$1
  implements IPartListener2
{
  AdvancedDeclarationView$1(AdvancedDeclarationView paramAdvancedDeclarationView) {}
  
  public void partVisible(IWorkbenchPartReference ref)
  {
    if (ref.getId().equals(this$0.getSite().getId()))
    {
      IWorkbenchPart activePart = ref.getPage().getActivePart();
      if (activePart != null) {
        this$0.selectionChanged(activePart, ref.getPage().getSelection());
      }
      this$0.startListeningForSelectionChanges();
    }
  }
  
  public void partHidden(IWorkbenchPartReference ref)
  {
    if (ref.getId().equals(this$0.getSite().getId())) {
      this$0.stopListeningForSelectionChanges();
    }
  }
  
  public void partInputChanged(IWorkbenchPartReference ref)
  {
    if ((!ref.getId().equals(this$0.getSite().getId())) && 
      ((this$0.getCurrentPage() instanceof DeclarationPage))) {
      ((DeclarationPage)this$0.getCurrentPage()).computeAndSetInput(ref.getPart(false));
    }
  }
  
  public void partActivated(IWorkbenchPartReference ref) {}
  
  public void partBroughtToTop(IWorkbenchPartReference ref) {}
  
  public void partClosed(IWorkbenchPartReference ref) {}
  
  public void partDeactivated(IWorkbenchPartReference ref) {}
  
  public void partOpened(IWorkbenchPartReference ref) {}
}

/* Location:
 * Qualified Name:     org.tizen.web.advanceddeclarationview.ui.AdvancedDeclarationView.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.advanceddeclarationview.ui;

import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jst.pagedesigner.editors.HTMLEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.IPartService;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.part.IPage;
import org.eclipse.ui.part.MessagePage;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.PageBookView;
import org.eclipse.ui.part.PageBookView.PageRec;
import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.tizen.webuibuilder.ui.editor.PageDesigner;

public class AdvancedDeclarationView
  extends PageBookView
  implements ISelectionListener
{
  public static final String ID = "org.tizen.web.advanceddeclarationview.ui.AdvancedDeclarationView";
  private IPartListener2 fPartListener = new IPartListener2()
  {
    public void partVisible(IWorkbenchPartReference ref)
    {
      if (ref.getId().equals(getSite().getId()))
      {
        IWorkbenchPart activePart = ref.getPage().getActivePart();
        if (activePart != null) {
          selectionChanged(activePart, ref.getPage().getSelection());
        }
        startListeningForSelectionChanges();
      }
    }
    
    public void partHidden(IWorkbenchPartReference ref)
    {
      if (ref.getId().equals(getSite().getId())) {
        stopListeningForSelectionChanges();
      }
    }
    
    public void partInputChanged(IWorkbenchPartReference ref)
    {
      if ((!ref.getId().equals(getSite().getId())) && 
        ((getCurrentPage() instanceof DeclarationPage))) {
        ((DeclarationPage)getCurrentPage()).computeAndSetInput(ref.getPart(false));
      }
    }
    
    public void partActivated(IWorkbenchPartReference ref) {}
    
    public void partBroughtToTop(IWorkbenchPartReference ref) {}
    
    public void partClosed(IWorkbenchPartReference ref) {}
    
    public void partDeactivated(IWorkbenchPartReference ref) {}
    
    public void partOpened(IWorkbenchPartReference ref) {}
  };
  private ToggleLockAction fToggleLockAction;
  private ToggleLineNumberAction fToggleLineNumberAction;
  
  void startListeningForSelectionChanges()
  {
    getSite().getPage().addPostSelectionListener(this);
  }
  
  void stopListeningForSelectionChanges()
  {
    getSite().getPage().removePostSelectionListener(this);
  }
  
  private IWorkbenchPart currentPart = null;
  
  public ToggleLockAction getToggleLockAction()
  {
    return fToggleLockAction;
  }
  
  public boolean isLocked()
  {
    if ((getToggleLockAction() != null) && (getToggleLockAction().isChecked())) {
      return true;
    }
    return false;
  }
  
  public ToggleLineNumberAction getToggleLineNumberAction()
  {
    return fToggleLineNumberAction;
  }
  
  protected void createActions()
  {
    fToggleLockAction = new ToggleLockAction(this);
    fToggleLineNumberAction = new ToggleLineNumberAction(this);
  }
  
  public void setActionBars(IActionBars actionBars)
  {
    IToolBarManager toolBarManager = actionBars.getToolBarManager();
    toolBarManager.add(getToggleLockAction());
  }
  
  public void createPartControl(Composite parent)
  {
    super.createPartControl(parent);
    getSite().getWorkbenchWindow().getPartService().addPartListener(fPartListener);
    createActions();
    setActionBars(getViewSite().getActionBars());
  }
  
  protected IPage createDefaultPage(PageBook book)
  {
    MessagePage messagePage = new MessagePage();
    initPage(messagePage);
    messagePage.setMessage("Declaration View is not available");
    messagePage.createControl(book);
    return messagePage;
  }
  
  protected PageBookView.PageRec doCreatePage(IWorkbenchPart part)
  {
    if ((part instanceof JavaEditor))
    {
      JSDeclarationPage jsDeclarationPage = new JSDeclarationPage(getViewSite());
      initPage(jsDeclarationPage);
      jsDeclarationPage.createControl(getPageBook());
      return new PageBookView.PageRec(part, jsDeclarationPage);
    }
    if ((part instanceof PageDesigner))
    {
      GUIBuilderDeclarationPage guiBuilderDeclarationPage = new GUIBuilderDeclarationPage(getViewSite());
      initPage(guiBuilderDeclarationPage);
      guiBuilderDeclarationPage.createControl(getPageBook());
      return new PageBookView.PageRec(part, guiBuilderDeclarationPage);
    }
    if (((part instanceof StructuredTextEditor)) || 
      ((part instanceof HTMLEditor)))
    {
      HTMLDeclarationPage htmlDeclarationPage = new HTMLDeclarationPage(getViewSite());
      initPage(htmlDeclarationPage);
      htmlDeclarationPage.createControl(getPageBook());
      return new PageBookView.PageRec(part, htmlDeclarationPage);
    }
    MessagePage messagePage = new MessagePage();
    initPage(messagePage);
    String msg = "Page for " + part.getSite().getPluginId();
    if ((part instanceof PageDesigner)) {
      msg = msg + " : Pagedesigner";
    } else if ((part instanceof JavaEditor)) {
      msg = msg + " : JavaScriptEditor";
    } else {
      msg = msg + " : Not interested";
    }
    messagePage.setMessage(msg);
    messagePage.createControl(getPageBook());
    return new PageBookView.PageRec(part, messagePage);
  }
  
  protected void doDestroyPage(IWorkbenchPart part, PageBookView.PageRec pageRecord)
  {
    page.dispose();
  }
  
  protected IWorkbenchPart getBootstrapPart()
  {
    return null;
  }
  
  protected boolean isImportant(IWorkbenchPart part)
  {
    if (isLocked()) {
      return false;
    }
    if ((part instanceof JavaEditor)) {
      return true;
    }
    if ((part instanceof PageDesigner)) {
      return true;
    }
    if ((part instanceof StructuredTextEditor)) {
      return true;
    }
    if ((part instanceof HTMLEditor)) {
      return true;
    }
    return false;
  }
  
  protected void showPageRec(PageBookView.PageRec pageRec)
  {
    super.showPageRec(pageRec);
    if ((page instanceof DeclarationPage)) {
      ((DeclarationPage)page).updateLineNumberRuler(getToggleLineNumberAction().isChecked());
    }
  }
  
  public void selectionChanged(IWorkbenchPart part, ISelection selection)
  {
    if (part.equals(this)) {
      return;
    }
    if ((getCurrentPage() instanceof DeclarationPage)) {
      ((DeclarationPage)getCurrentPage()).computeAndSetInput(part);
    }
  }
  
  protected void partHidden(IWorkbenchPart part)
  {
    if (!isLocked()) {
      super.partHidden(part);
    }
  }
  
  public void partActivated(IWorkbenchPart part)
  {
    super.partActivated(part);
    if (isImportant(part)) {
      currentPart = part;
    }
  }
  
  public void partClosed(IWorkbenchPart part)
  {
    if ((isLocked()) && (part.equals(currentPart))) {
      getToggleLockAction().setChecked(false);
    }
    super.partClosed(part);
  }
  
  public final void dispose()
  {
    currentPart = null;
    getSite().getWorkbenchWindow().getPartService().removePartListener(fPartListener);
    super.dispose();
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.advanceddeclarationview.ui.AdvancedDeclarationView
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.advanceddeclarationview.ui;

public class CSSRuleInfo
{
  private String cssRule = "";
  private String cssRuleInfo = "";
  private String cssFilePath = "";
  private int offset;
  private int length;
  
  public String getCssRule()
  {
    return cssRule;
  }
  
  public void setCssRule(String cssRule)
  {
    this.cssRule = cssRule;
  }
  
  public String getCssRuleInfo()
  {
    return cssRuleInfo;
  }
  
  public void setCssRuleInfo(String cssRuleInfo)
  {
    this.cssRuleInfo = cssRuleInfo;
  }
  
  public String getCssFilePath()
  {
    return cssFilePath;
  }
  
  public void setCSSFilePath(String cssFilePath)
  {
    this.cssFilePath = cssFilePath;
  }
  
  public void setOffset(int offset)
  {
    this.offset = offset;
  }
  
  public void setLength(int length)
  {
    this.length = length;
  }
  
  public int getOffset()
  {
    return offset;
  }
  
  public int getLength()
  {
    return length;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.advanceddeclarationview.ui.CSSRuleInfo
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.advanceddeclarationview.ui;

import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.Page;

public abstract class DeclarationPage
  extends Page
{
  public abstract void updateLineNumberRuler(boolean paramBoolean);
  
  public abstract void computeAndSetInput(IWorkbenchPart paramIWorkbenchPart);
  
  public abstract void lock();
  
  public abstract void unLock();
}

/* Location:
 * Qualified Name:     org.tizen.web.advanceddeclarationview.ui.DeclarationPage
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.advanceddeclarationview.ui;

import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;

class GUIBuilderDeclarationPage$1
  implements MouseListener
{
  GUIBuilderDeclarationPage$1(GUIBuilderDeclarationPage paramGUIBuilderDeclarationPage) {}
  
  public void mouseUp(MouseEvent e) {}
  
  public void mouseDown(MouseEvent e)
  {
    for (int i = 0; i < 3; i++) {
      if (widget == GUIBuilderDeclarationPage.access$7(this$0)[i])
      {
        this$0.setMode(i);
        GUIBuilderDeclarationPage.access$4(this$0);
      }
    }
  }
  
  public void mouseDoubleClick(MouseEvent e) {}
}

/* Location:
 * Qualified Name:     org.tizen.web.advanceddeclarationview.ui.GUIBuilderDeclarationPage.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.advanceddeclarationview.ui;

import org.eclipse.jface.viewers.LabelProvider;
import org.tizen.webuibuilder.extintrf.JsInfo;

class GUIBuilderDeclarationPage$2
  extends LabelProvider
{
  GUIBuilderDeclarationPage$2(GUIBuilderDeclarationPage paramGUIBuilderDeclarationPage) {}
  
  public String getText(Object element)
  {
    if ((element instanceof JsInfo))
    {
      JsInfo jsInfo = (JsInfo)element;
      return jsInfo.getFunctionName();
    }
    return super.getText(element);
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.advanceddeclarationview.ui.GUIBuilderDeclarationPage.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.advanceddeclarationview.ui;

import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.tizen.webuibuilder.extintrf.JsInfo;

class GUIBuilderDeclarationPage$3
  implements ISelectionChangedListener
{
  GUIBuilderDeclarationPage$3(GUIBuilderDeclarationPage paramGUIBuilderDeclarationPage) {}
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    ISelection selection = event.getSelection();
    if (!(selection instanceof StructuredSelection)) {
      return;
    }
    Object selectedObject = ((StructuredSelection)selection).getFirstElement();
    if (!(selectedObject instanceof JsInfo)) {
      return;
    }
    this$0.fSelectedJsInfo = ((JsInfo)selectedObject);
    GUIBuilderDeclarationPage.access$0(this$0).setRangeIndication((int)this$0.fSelectedJsInfo.getOffset(), 
      (int)this$0.fSelectedJsInfo.getLength(), true);
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.advanceddeclarationview.ui.GUIBuilderDeclarationPage.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.advanceddeclarationview.ui;

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

class GUIBuilderDeclarationPage$4
  implements Listener
{
  GUIBuilderDeclarationPage$4(GUIBuilderDeclarationPage paramGUIBuilderDeclarationPage) {}
  
  public void handleEvent(Event event)
  {
    GUIBuilderDeclarationPage.access$8(this$0);
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.advanceddeclarationview.ui.GUIBuilderDeclarationPage.4
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.advanceddeclarationview.ui;

import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML;
import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration;
import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;

class GUIBuilderDeclarationPage$5
  extends StructuredTextViewerConfiguration
{
  StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationHTML();
  
  GUIBuilderDeclarationPage$5(GUIBuilderDeclarationPage paramGUIBuilderDeclarationPage) {}
  
  public String[] getConfiguredContentTypes(ISourceViewer sourceViewer)
  {
    return baseConfiguration.getConfiguredContentTypes(sourceViewer);
  }
  
  public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType)
  {
    return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType);
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.advanceddeclarationview.ui.GUIBuilderDeclarationPage.5
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.advanceddeclarationview.ui;

import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.wst.css.ui.StructuredTextViewerConfigurationCSS;
import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration;
import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;

class GUIBuilderDeclarationPage$6
  extends StructuredTextViewerConfiguration
{
  StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationCSS();
  
  GUIBuilderDeclarationPage$6(GUIBuilderDeclarationPage paramGUIBuilderDeclarationPage) {}
  
  public String[] getConfiguredContentTypes(ISourceViewer sourceViewer)
  {
    return baseConfiguration.getConfiguredContentTypes(sourceViewer);
  }
  
  public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType)
  {
    return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType);
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.advanceddeclarationview.ui.GUIBuilderDeclarationPage.6
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.advanceddeclarationview.ui;

import org.tizen.webuibuilder.extintrf.DeclarationViewInfoProvider;
import org.tizen.webuibuilder.extintrf.IContentChangeListener;

class GUIBuilderDeclarationPage$ContentChangeListener
  implements IContentChangeListener
{
  GUIBuilderDeclarationPage$ContentChangeListener(GUIBuilderDeclarationPage paramGUIBuilderDeclarationPage) {}
  
  public void selectionChanged()
  {
    if (GUIBuilderDeclarationPage.access$3(this$0)) {
      return;
    }
    GUIBuilderDeclarationPage.access$4(this$0);
  }
  
  public void contentChanged()
  {
    GUIBuilderDeclarationPage.access$4(this$0);
  }
  
  public void lockStatusChanged()
  {
    GUIBuilderDeclarationPage.access$5(this$0).setChecked(GUIBuilderDeclarationPage.access$6(this$0).getLockStatus());
    GUIBuilderDeclarationPage.access$4(this$0);
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.advanceddeclarationview.ui.GUIBuilderDeclarationPage.ContentChangeListener
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.advanceddeclarationview.ui;

import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;

class GUIBuilderDeclarationPage$FontPropertyChangeListener
  implements IPropertyChangeListener
{
  GUIBuilderDeclarationPage$FontPropertyChangeListener(GUIBuilderDeclarationPage paramGUIBuilderDeclarationPage) {}
  
  public void propertyChange(PropertyChangeEvent event)
  {
    if (GUIBuilderDeclarationPage.access$0(this$0) == null) {
      return;
    }
    String property = event.getProperty();
    if ("org.eclipse.wst.sse.ui.textfont".equals(property)) {
      GUIBuilderDeclarationPage.access$2(this$0);
    }
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.advanceddeclarationview.ui.GUIBuilderDeclarationPage.FontPropertyChangeListener
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.advanceddeclarationview.ui;

import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;

class GUIBuilderDeclarationPage$PropertyChangeListener
  implements IPropertyChangeListener
{
  GUIBuilderDeclarationPage$PropertyChangeListener(GUIBuilderDeclarationPage paramGUIBuilderDeclarationPage) {}
  
  public void propertyChange(PropertyChangeEvent event)
  {
    if (GUIBuilderDeclarationPage.access$0(this$0) == null) {
      return;
    }
    GUIBuilderDeclarationPage.access$0(this$0).invalidateTextPresentation();
    if (event.getProperty().equals("lineNumberColor")) {
      GUIBuilderDeclarationPage.access$1(this$0, true);
    }
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.advanceddeclarationview.ui.GUIBuilderDeclarationPage.PropertyChangeListener
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.advanceddeclarationview.ui;

import java.io.File;
import java.util.List;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.filesystem.IFileSystem;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.source.CompositeRuler;
import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.LineNumberRulerColumn;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.wst.css.core.internal.provisional.contenttype.ContentTypeIdForCSS;
import org.eclipse.wst.css.ui.StructuredTextViewerConfigurationCSS;
import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeIdForHTML;
import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML;
import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaSourceViewer;
import org.eclipse.wst.jsdt.internal.ui.text.SimpleJavaSourceViewerConfiguration;
import org.eclipse.wst.jsdt.ui.text.JavaScriptTextTools;
import org.eclipse.wst.jsdt.web.ui.internal.Logger;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration;
import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
import org.tizen.webuibuilder.extintrf.DeclarationViewInfoProvider;
import org.tizen.webuibuilder.extintrf.IContentChangeListener;
import org.tizen.webuibuilder.extintrf.JsInfo;
import org.tizen.webuibuilder.extintrf.WidgetInfo;

public class GUIBuilderDeclarationPage
  extends DeclarationPage
  implements ISelectionListener, IMenuListener, IPropertyChangeListener
{
  private static final String SYMBOLIC_FONT_NAME = "org.eclipse.wst.sse.ui.textfont";
  private static final int MODE_HTML = 0;
  private static final int MODE_CSS = 1;
  private static final int MODE_JS = 2;
  private static final int NUMBER_OF_MODES = 3;
  private int mode = 0;
  private IViewSite parentSite;
  private Composite mainComposite;
  private Composite[] tabItemComposites;
  private Composite tabComposite;
  private Label[] tabLabels;
  private MouseListener fTabSelectionListener;
  private SourceViewer fSrcViewer;
  private SourceViewer[] fSrcViewers;
  private ComboViewer fComboViewer;
  private Label[] fNoContentsLabels;
  private TextSourceViewerConfiguration[] fViewerConfigurations;
  private Link fElementInfoLabel;
  private CompositeRuler[] fVerticalRulers;
  private LineNumberRulerColumn fJSLineNumberColumn;
  private boolean lineNumberColumnOn = false;
  private IPropertyChangeListener fFontPropertyChangeListener = new FontPropertyChangeListener();
  private IPropertyChangeListener fPropertyChangeListener = new PropertyChangeListener();
  private Color fBackgroundColor;
  private RGB fBackgroundColorRGB;
  private DeclarationViewInfoProvider fDeclaratonViewInfoProvider;
  private IContentChangeListener fContentChangeListener = new ContentChangeListener();
  JsInfo fSelectedJsInfo;
  
  class PropertyChangeListener
    implements IPropertyChangeListener
  {
    PropertyChangeListener() {}
    
    public void propertyChange(PropertyChangeEvent event)
    {
      if (fSrcViewer == null) {
        return;
      }
      fSrcViewer.invalidateTextPresentation();
      if (event.getProperty().equals("lineNumberColor")) {
        GUIBuilderDeclarationPage.this.updateLineNumberColumnPresentation(true);
      }
    }
  }
  
  class FontPropertyChangeListener
    implements IPropertyChangeListener
  {
    FontPropertyChangeListener() {}
    
    public void propertyChange(PropertyChangeEvent event)
    {
      if (fSrcViewer == null) {
        return;
      }
      String property = event.getProperty();
      if ("org.eclipse.wst.sse.ui.textfont".equals(property)) {
        GUIBuilderDeclarationPage.this.setViewerFont();
      }
    }
  }
  
  class ContentChangeListener
    implements IContentChangeListener
  {
    ContentChangeListener() {}
    
    public void selectionChanged()
    {
      if (GUIBuilderDeclarationPage.this.isLocked()) {
        return;
      }
      GUIBuilderDeclarationPage.this.processViewing();
    }
    
    public void contentChanged()
    {
      GUIBuilderDeclarationPage.this.processViewing();
    }
    
    public void lockStatusChanged()
    {
      GUIBuilderDeclarationPage.this.getToggleLockAction().setChecked(fDeclaratonViewInfoProvider.getLockStatus());
      GUIBuilderDeclarationPage.this.processViewing();
    }
  }
  
  private ToggleLockAction getToggleLockAction()
  {
    return ((AdvancedDeclarationView)parentSite.getPart()).getToggleLockAction();
  }
  
  private boolean isLocked()
  {
    return ((AdvancedDeclarationView)parentSite.getPart()).isLocked();
  }
  
  private ToggleLineNumberAction getToggleLineNumberAction()
  {
    return ((AdvancedDeclarationView)parentSite.getPart()).getToggleLineNumberAction();
  }
  
  private void processViewing()
  {
    String srcString = getSourceString();
    setInput(srcString);
    setEventHandlerList();
    updateLayout((srcString == null) || ("".equals(srcString)));
  }
  
  protected void setInput(String input)
  {
    if (input == null)
    {
      switch (mode)
      {
      case 0: 
      case 1: 
        fSrcViewer.getDocument().set("");
        break;
      case 2: 
        fSrcViewer.setInput(new Document(""));
        break;
      }
    }
    else
    {
      switch (mode)
      {
      case 0: 
      case 1: 
        fSrcViewer.getDocument().set(input);
        break;
      case 2: 
        IDocument document = new Document(input.toString());
        JavaScriptPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document, "___java_partitioning");
        fSrcViewer.setInput(document);
        break;
      }
      fSrcViewer.invalidateTextPresentation();
    }
    String elementInfoString = getElementInfoString();
    switch (mode)
    {
    case 0: 
    case 1: 
      break;
    case 2: 
      elementInfoString = "<a>" + elementInfoString + "</a>";
      break;
    }
    fElementInfoLabel.setText(elementInfoString);
  }
  
  protected void setForeground(Color color)
  {
    for (int i = 0; i < 3; i++) {
      fSrcViewers[i].getTextWidget().setForeground(color);
    }
  }
  
  protected void setBackground(Color color)
  {
    for (int i = 0; i < 3; i++) {
      fSrcViewers[i].getTextWidget().setBackground(color);
    }
  }
  
  protected void internalCreatePartControl(Composite parent)
  {
    mainComposite = new Composite(parent, 0);
    mainComposite.setLayout(new FormLayout());
    
    tabComposite = new Composite(mainComposite, 0);
    tabComposite.setLayout(new FormLayout());
    
    tabItemComposites = new Composite[3];
    
    fTabSelectionListener = new MouseListener()
    {
      public void mouseUp(MouseEvent e) {}
      
      public void mouseDown(MouseEvent e)
      {
        for (int i = 0; i < 3; i++) {
          if (widget == tabLabels[i])
          {
            setMode(i);
            GUIBuilderDeclarationPage.this.processViewing();
          }
        }
      }
      
      public void mouseDoubleClick(MouseEvent e) {}
    };
    tabLabels = new Label[3];
    for (int i = 0; i < 3; i++)
    {
      tabItemComposites[i] = new Composite(mainComposite, 0);
      tabItemComposites[i].setLayout(new FormLayout());
      tabLabels[i] = new Label(tabComposite, 18432);
      switch (i)
      {
      case 0: 
        tabLabels[i].setText(" HTML   ");
        break;
      case 1: 
        tabLabels[i].setText(" CSS");
        break;
      case 2: 
        tabLabels[i].setText(" JS");
        break;
      }
      tabLabels[i].addMouseListener(fTabSelectionListener);
    }
    fComboViewer = new ComboViewer(mainComposite, 8);
    fComboViewer.setLabelProvider(new LabelProvider()
    {
      public String getText(Object element)
      {
        if ((element instanceof JsInfo))
        {
          JsInfo jsInfo = (JsInfo)element;
          return jsInfo.getFunctionName();
        }
        return super.getText(element);
      }
    });
    fComboViewer.setContentProvider(new ArrayContentProvider());
    fComboViewer.addSelectionChangedListener(new ISelectionChangedListener()
    {
      public void selectionChanged(SelectionChangedEvent event)
      {
        ISelection selection = event.getSelection();
        if (!(selection instanceof StructuredSelection)) {
          return;
        }
        Object selectedObject = ((StructuredSelection)selection).getFirstElement();
        if (!(selectedObject instanceof JsInfo)) {
          return;
        }
        fSelectedJsInfo = ((JsInfo)selectedObject);
        fSrcViewer.setRangeIndication((int)fSelectedJsInfo.getOffset(), 
          (int)fSelectedJsInfo.getLength(), true);
      }
    });
    fElementInfoLabel = new Link(mainComposite, 16384);
    fElementInfoLabel.setText("");
    
    fElementInfoLabel.addListener(13, new Listener()
    {
      public void handleEvent(Event event)
      {
        GUIBuilderDeclarationPage.this.processElementInfoClick();
      }
    });
    fSrcViewers = new SourceViewer[3];
    fViewerConfigurations = new TextSourceViewerConfiguration[3];
    fVerticalRulers = new CompositeRuler[3];
    fNoContentsLabels = new Label[3];
    
    lineNumberColumnOn = false;
    for (int i = 0; i < 3; i++)
    {
      fVerticalRulers[i] = new CompositeRuler();
      fViewerConfigurations[i] = createTextViewerConfiguration(i);
      fSrcViewers[i] = createViewer(i, tabItemComposites[i], fVerticalRulers[i], fViewerConfigurations[i]);
      fNoContentsLabels[i] = new Label(tabItemComposites[i], 16384);
      fNoContentsLabels[i].setVisible(false);
      fSrcViewers[i].setEditable(false);
    }
    fNoContentsLabels[0].setText("No HTML contents");
    fNoContentsLabels[1].setText("No CSS contents");
    fNoContentsLabels[2].setText("No JavaScript contents");
    
    setMode(mode);
    
    JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener);
    EditorsUI.getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
    
    updateLayout(true);
  }
  
  private void processElementInfoClick()
  {
    switch (mode)
    {
    case 0: 
      break;
    case 1: 
      break;
    case 2: 
      try
      {
        File file = new File(fDeclaratonViewInfoProvider.getJsPath());
        if ((file.exists()) && (file.isFile()))
        {
          IFileStore fileStore = EFS.getLocalFileSystem().getStore(file.toURI());
          IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
          
          IEditorPart editor = IDE.openEditorOnFileStore(page, fileStore);
          if ((fSelectedJsInfo != null) && ((editor instanceof ITextEditor))) {
            ((ITextEditor)editor).selectAndReveal((int)fSelectedJsInfo.getOffset(), (int)fSelectedJsInfo.getLength());
          }
        }
      }
      catch (PartInitException pie)
      {
        Logger.log(202, pie.getMessage(), pie);
      }
    }
  }
  
  private TextSourceViewerConfiguration createTextViewerConfiguration(int mode)
  {
    TextSourceViewerConfiguration viewerConfiguration = null;
    switch (mode)
    {
    case 0: 
      viewerConfiguration = new StructuredTextViewerConfiguration()
      {
        StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationHTML();
        
        public String[] getConfiguredContentTypes(ISourceViewer sourceViewer)
        {
          return baseConfiguration.getConfiguredContentTypes(sourceViewer);
        }
        
        public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType)
        {
          return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType);
        }
      };
      break;
    case 1: 
      viewerConfiguration = new StructuredTextViewerConfiguration()
      {
        StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationCSS();
        
        public String[] getConfiguredContentTypes(ISourceViewer sourceViewer)
        {
          return baseConfiguration.getConfiguredContentTypes(sourceViewer);
        }
        
        public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType)
        {
          return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType);
        }
      };
      break;
    case 2: 
      IPreferenceStore store = JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
      viewerConfiguration = new SimpleJavaSourceViewerConfiguration(JavaScriptPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, "___java_partitioning", false);
      break;
    }
    return viewerConfiguration;
  }
  
  private SourceViewer createViewer(int mode, Composite parent, IVerticalRuler verticalRuler, SourceViewerConfiguration viewerConfiguration)
  {
    SourceViewer viewer = null;
    switch (mode)
    {
    case 0: 
      viewer = createHTMLViewer(parent, verticalRuler, viewerConfiguration);
      break;
    case 1: 
      viewer = createCSSViewer(parent, verticalRuler, viewerConfiguration);
      break;
    case 2: 
      viewer = createJSViewer(parent, verticalRuler, viewerConfiguration);
      break;
    }
    return viewer;
  }
  
  SourceViewer createHTMLViewer(Composite parent, IVerticalRuler verticalRuler, SourceViewerConfiguration viewerConfiguration)
  {
    SourceViewer viewer = null;
    String contentTypeID = ContentTypeIdForHTML.ContentTypeID_HTML;
    viewer = new StructuredTextViewer(parent, verticalRuler, null, false, 2816);
    viewer.getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"));
    IStructuredModel scratchModel = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(contentTypeID);
    IDocument document = scratchModel.getStructuredDocument();
    viewer.configure(viewerConfiguration);
    viewer.setDocument(document);
    return viewer;
  }
  
  SourceViewer createCSSViewer(Composite parent, IVerticalRuler verticalRuler, SourceViewerConfiguration viewerConfiguration)
  {
    SourceViewer viewer = null;
    String contentTypeID = ContentTypeIdForCSS.ContentTypeID_CSS;
    viewer = new StructuredTextViewer(parent, verticalRuler, null, false, 2816);
    viewer.getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"));
    IStructuredModel scratchModel = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(contentTypeID);
    IDocument document = scratchModel.getStructuredDocument();
    viewer.configure(viewerConfiguration);
    viewer.setDocument(document);
    return viewer;
  }
  
  SourceViewer createJSViewer(Composite parent, IVerticalRuler verticalRuler, SourceViewerConfiguration viewerConfiguration)
  {
    IPreferenceStore store = JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
    SourceViewer viewer = new JavaSourceViewer(parent, verticalRuler, null, false, 768, store);
    viewer.configure(viewerConfiguration);
    return viewer;
  }
  
  void setMode(int mode)
  {
    this.mode = mode;
    
    fSrcViewer = fSrcViewers[mode];
    
    setTabLabels();
    setViewerFont();
    getSite().setSelectionProvider(fSrcViewer);
    updateLineNumberRuler(getToggleLineNumberAction().isChecked());
  }
  
  void setTabLabels()
  {
    Display display = getSite().getShell().getDisplay();
    for (int i = 0; i < 3; i++) {
      if (mode == i)
      {
        Color color = display.getSystemColor(1);
        tabLabels[i].setBackground(color);
      }
      else
      {
        Color color = display.getSystemColor(15);
        tabLabels[i].setBackground(color);
      }
    }
  }
  
  private void inititalizeColors()
  {
    if (getSite().getShell().isDisposed()) {
      return;
    }
    Display display = getSite().getShell().getDisplay();
    if ((display == null) || (display.isDisposed())) {
      return;
    }
    ColorRegistry registry = JFaceResources.getColorRegistry();
    registry.addListener(this);
    
    RGB foregroundRGB = registry.getRGB(getForegroundColorKey());
    Color fgColor;
    Color fgColor;
    if (foregroundRGB == null) {
      fgColor = display.getSystemColor(2);
    } else {
      fgColor = new Color(display, foregroundRGB);
    }
    setForeground(fgColor);
    
    fBackgroundColorRGB = registry.getRGB(getBackgroundColorKey());
    Color bgColor;
    if (fBackgroundColorRGB == null)
    {
      Color bgColor = display.getSystemColor(1);
      fBackgroundColorRGB = bgColor.getRGB();
    }
    else
    {
      bgColor = new Color(display, fBackgroundColorRGB);
      fBackgroundColor = bgColor;
    }
    setBackground(bgColor);
  }
  
  protected void createContextMenu()
  {
    for (int i = 0; i < 3; i++)
    {
      MenuManager menuManager = new 
1 2 3 4 5

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