org.tizen.uicustomizer.ui.editor_1.0.0.201311010051

16:50:29.312 INFO  jd.cli.Main - Decompiling org.tizen.uicustomizer.ui.editor_1.0.0.201311010051.jar
package org.tizen.uicustomizer.ui.editor;

import org.eclipse.gef.GraphicalViewer;
import org.tizen.uicustomizer.events.EventData;
import org.tizen.uicustomizer.events.EventType;
import org.tizen.uicustomizer.events.IUIControlEventHandler;
import org.tizen.uicustomizer.events.UIControlEventManager;
import org.tizen.uicustomizer.events.UIControlEventManager.EventPriority;
import org.tizen.uicustomizer.model.Animation;
import org.tizen.uicustomizer.model.WinsetItem;
import org.tizen.uicustomizer.model.WinsetItemAnimationPropertySource;
import org.tizen.uicustomizer.model.WinsetItemControls;
import org.tizen.uicustomizer.model.input.WinsetItemInput;
import org.tizen.uicustomizer.ui.animation.AnimationManager;

public class AnimationEditor
  extends WinsetItemEditor
  implements IUIControlEventHandler
{
  private Animation animation;
  private WinsetItem item;
  private EventType[] types = { EventType.ANIMATION_PROPERTY_CHANGED };
  
  public AnimationEditor()
  {
    UIControlEventManager.getInstance().registerEvents(types, this);
  }
  
  public AnimationEditor(WinsetItem item)
  {
    this.item = item;
    UIControlEventManager.getInstance().registerEvents(types, this);
  }
  
  protected void initializeGraphicalViewer()
  {
    animation = new Animation(item);
    viewer.setContents(animation);
    setPartName(((WinsetItemInput)getEditorInput()).getItem().getType().name());
    hasFocus = true;
  }
  
  public void setFocus()
  {
    super.setFocus();
    UIControlEventManager.getInstance().notifyEvents(EventType.ANIMATION_FOCUS, new EventData(EventType.ANIMATION_FOCUS, animation, null, this));
  }
  
  public void handleEvent(EventData data)
  {
    if (!(source instanceof WinsetItemAnimationPropertySource)) {
      switch (type)
      {
      case XML_EDITOR_FOCUS: 
        getGraphicalViewer().setContents(animation);
        setFocus();
        break;
      }
    }
  }
  
  public Object getContext()
  {
    return null;
  }
  
  public UIControlEventManager.EventPriority getPriority()
  {
    return UIControlEventManager.EventPriority.GRAPHICAL_EDITOR;
  }
  
  public void dispose()
  {
    AnimationManager.killActiveAnimation();
    super.dispose();
  }
}

/* Location:
 * Qualified Name:     org.tizen.uicustomizer.ui.editor.AnimationEditor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.uicustomizer.ui.editor;

import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public class EditorActivator
  extends AbstractUIPlugin
{
  public static final String PLUGIN_ID = "org.tizen.uicustomizer.ui.editor";
  public static final String BUNDLE_ID = "org.tizen.uicustomizer.ui.editor.XMLEditorPluginResources";
  private static EditorActivator plugin;
  private ResourceBundle resourceBundle;
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    plugin = this;
    try
    {
      resourceBundle = ResourceBundle.getBundle("org.tizen.uicustomizer.ui.editor.XMLEditorPluginResources");
    }
    catch (MissingResourceException localMissingResourceException)
    {
      resourceBundle = null;
    }
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    plugin = null;
    resourceBundle = null;
    super.stop(context);
  }
  
  public static EditorActivator getDefault()
  {
    return plugin;
  }
  
  public static ImageDescriptor getImageDescriptor(String path)
  {
    return imageDescriptorFromPlugin("org.tizen.uicustomizer.ui.editor", path);
  }
  
  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 getResourceBundle()
  {
    return resourceBundle;
  }
  
  public static void logException(Exception e)
  {
    getDefault().getLog().log(new Status(4, "org.tizen.uicustomizer.ui.editor", e.getMessage(), e));
  }
}

/* Location:
 * Qualified Name:     org.tizen.uicustomizer.ui.editor.EditorActivator
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.uicustomizer.ui.editor;

import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.GridData;
import org.eclipse.draw2d.GridLayout;
import org.eclipse.gef.editparts.GridLayer;
import org.tizen.uicustomizer.model.IColorConstant;

public class EditorBackGround
  extends GridLayer
{
  public EditorBackGround()
  {
    setForegroundColor(IColorConstant.colorEditorBackground);
    Figure backgroundFigure = new Figure();
    backgroundFigure.setOpaque(true);
    backgroundFigure.setBackgroundColor(IColorConstant.colorMainEditorBackground);
    backgroundFigure.setForegroundColor(IColorConstant.colorMainEditorBackground);
    backgroundFigure.setOpaque(true);
    GridLayout layoutManager = new GridLayout(1, false);
    horizontalSpacing = 0;
    marginHeight = 0;
    marginWidth = 0;
    verticalSpacing = 0;
    setLayoutManager(layoutManager);
    add(backgroundFigure, new GridData(4, 4, true, true));
  }
}

/* Location:
 * Qualified Name:     org.tizen.uicustomizer.ui.editor.EditorBackGround
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.uicustomizer.ui.editor;

import org.eclipse.gef.editparts.ZoomManager;
import org.eclipse.gef.ui.actions.ZoomInRetargetAction;
import org.eclipse.gef.ui.actions.ZoomOutRetargetAction;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.widgets.Event;

class GraphicalEditorActionBarContributor$1
  extends ZoomInRetargetAction
{
  GraphicalEditorActionBarContributor$1(GraphicalEditorActionBarContributor paramGraphicalEditorActionBarContributor) {}
  
  public void run()
  {
    GraphicalEditorActionBarContributor.access$0(this$0).zoomIn();
    if (GraphicalEditorActionBarContributor.access$0(this$0).getZoom() == GraphicalEditorActionBarContributor.access$0(this$0).getMaxZoom()) {
      GraphicalEditorActionBarContributor.access$1(this$0).setEnabled(false);
    }
    GraphicalEditorActionBarContributor.access$2(this$0).setEnabled(true);
    if (GraphicalEditorActionBarContributor.access$3(this$0) != null) {
      GraphicalEditorActionBarContributor.access$3(this$0).update(true);
    }
  }
  
  public void runWithEvent(Event event)
  {
    run();
  }
  
  public boolean isEnabled()
  {
    return GraphicalEditorActionBarContributor.access$0(this$0).getZoom() < GraphicalEditorActionBarContributor.access$0(this$0).getMaxZoom();
  }
}

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

import org.eclipse.gef.editparts.ZoomManager;
import org.eclipse.gef.ui.actions.ZoomInRetargetAction;
import org.eclipse.gef.ui.actions.ZoomOutRetargetAction;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.widgets.Event;

class GraphicalEditorActionBarContributor$2
  extends ZoomOutRetargetAction
{
  GraphicalEditorActionBarContributor$2(GraphicalEditorActionBarContributor paramGraphicalEditorActionBarContributor) {}
  
  public void run()
  {
    GraphicalEditorActionBarContributor.access$0(this$0).zoomOut();
    if (GraphicalEditorActionBarContributor.access$0(this$0).getZoom() == GraphicalEditorActionBarContributor.access$0(this$0).getMinZoom()) {
      GraphicalEditorActionBarContributor.access$2(this$0).setEnabled(false);
    }
    GraphicalEditorActionBarContributor.access$1(this$0).setEnabled(true);
    if (GraphicalEditorActionBarContributor.access$3(this$0) != null) {
      GraphicalEditorActionBarContributor.access$3(this$0).update(true);
    }
  }
  
  public boolean isEnabled()
  {
    return GraphicalEditorActionBarContributor.access$0(this$0).getZoom() > GraphicalEditorActionBarContributor.access$0(this$0).getMinZoom();
  }
  
  public void runWithEvent(Event event)
  {
    run();
  }
}

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

import org.eclipse.gef.editparts.ZoomListener;
import org.eclipse.gef.editparts.ZoomManager;
import org.eclipse.gef.ui.actions.ZoomInRetargetAction;
import org.eclipse.gef.ui.actions.ZoomOutRetargetAction;

class GraphicalEditorActionBarContributor$3
  implements ZoomListener
{
  GraphicalEditorActionBarContributor$3(GraphicalEditorActionBarContributor paramGraphicalEditorActionBarContributor) {}
  
  public void zoomChanged(double arg0)
  {
    if ((arg0 < GraphicalEditorActionBarContributor.access$0(this$0).getMaxZoom()) && (arg0 > GraphicalEditorActionBarContributor.access$0(this$0).getMinZoom()))
    {
      GraphicalEditorActionBarContributor.access$1(this$0).setEnabled(true);
      GraphicalEditorActionBarContributor.access$2(this$0).setEnabled(true);
    }
    if (arg0 >= GraphicalEditorActionBarContributor.access$0(this$0).getMaxZoom())
    {
      GraphicalEditorActionBarContributor.access$1(this$0).setEnabled(false);
      GraphicalEditorActionBarContributor.access$2(this$0).setEnabled(true);
    }
    if (arg0 <= GraphicalEditorActionBarContributor.access$0(this$0).getMinZoom())
    {
      GraphicalEditorActionBarContributor.access$2(this$0).setEnabled(false);
      GraphicalEditorActionBarContributor.access$1(this$0).setEnabled(true);
    }
  }
}

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

import org.eclipse.gef.editparts.ZoomListener;
import org.eclipse.gef.editparts.ZoomManager;
import org.eclipse.gef.ui.actions.ZoomComboContributionItem;
import org.eclipse.gef.ui.actions.ZoomInRetargetAction;
import org.eclipse.gef.ui.actions.ZoomOutRetargetAction;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
import org.tizen.uicustomizer.events.EventData;
import org.tizen.uicustomizer.events.EventType;
import org.tizen.uicustomizer.events.IUIControlEventHandler;
import org.tizen.uicustomizer.events.UIControlEventManager;
import org.tizen.uicustomizer.events.UIControlEventManager.EventPriority;

public class GraphicalEditorActionBarContributor
  extends MultiPageEditorActionBarContributor
  implements IUIControlEventHandler
{
  private ZoomComboContributionItem zoomToolbarItem;
  private ZoomManager zoomManager;
  private static final EventType[] types = { EventType.WINSET_ITEM_FOCUS };
  private IToolBarManager toolBarManager;
  
  public GraphicalEditorActionBarContributor()
  {
    UIControlEventManager.getInstance().registerEvents(types, this);
  }
  
  private ZoomInRetargetAction zoomIn = new ZoomInRetargetAction()
  {
    public void run()
    {
      zoomManager.zoomIn();
      if (zoomManager.getZoom() == zoomManager.getMaxZoom()) {
        zoomIn.setEnabled(false);
      }
      zoomOut.setEnabled(true);
      if (toolBarManager != null) {
        toolBarManager.update(true);
      }
    }
    
    public void runWithEvent(Event event)
    {
      run();
    }
    
    public boolean isEnabled()
    {
      return zoomManager.getZoom() < zoomManager.getMaxZoom();
    }
  };
  private ZoomOutRetargetAction zoomOut = new ZoomOutRetargetAction()
  {
    public void run()
    {
      zoomManager.zoomOut();
      if (zoomManager.getZoom() == zoomManager.getMinZoom()) {
        zoomOut.setEnabled(false);
      }
      zoomIn.setEnabled(true);
      if (toolBarManager != null) {
        toolBarManager.update(true);
      }
    }
    
    public boolean isEnabled()
    {
      return zoomManager.getZoom() > zoomManager.getMinZoom();
    }
    
    public void runWithEvent(Event event)
    {
      run();
    }
  };
  
  public void contributeToToolBar(IToolBarManager toolBarManager)
  {
    super.contributeToToolBar(toolBarManager);
    zoomToolbarItem = new ZoomComboContributionItem(getPage());
    this.toolBarManager = toolBarManager;
    toolBarManager.add(zoomToolbarItem);
    toolBarManager.add(zoomIn);
    toolBarManager.add(zoomOut);
  }
  
  public void setActivePage(IEditorPart activeEditor)
  {
    zoomManager = ((ZoomManager)activeEditor.getAdapter(ZoomManager.class));
    zoomToolbarItem.setZoomManager(zoomManager);
    zoomManager.addZoomListener(new ZoomListener()
    {
      public void zoomChanged(double arg0)
      {
        if ((arg0 < zoomManager.getMaxZoom()) && (arg0 > zoomManager.getMinZoom()))
        {
          zoomIn.setEnabled(true);
          zoomOut.setEnabled(true);
        }
        if (arg0 >= zoomManager.getMaxZoom())
        {
          zoomIn.setEnabled(false);
          zoomOut.setEnabled(true);
        }
        if (arg0 <= zoomManager.getMinZoom())
        {
          zoomOut.setEnabled(false);
          zoomIn.setEnabled(true);
        }
      }
    });
  }
  
  public void handleEvent(EventData data)
  {
    if ((data != null) && (!equals(source))) {
      switch (type)
      {
      case PALETTE_CHANGED: 
        if (zoomManager != null)
        {
          zoomManager.setZoom(zoomManager.getZoom());
          getPage().bringToTop(getPage().getActivePart());
          if (zoomManager.getZoom() < zoomManager.getMaxZoom()) {
            zoomIn.setEnabled(true);
          } else {
            zoomIn.setEnabled(false);
          }
          if (zoomManager.getZoom() > zoomManager.getMinZoom()) {
            zoomOut.setEnabled(true);
          } else {
            zoomOut.setEnabled(false);
          }
        }
        break;
      }
    }
  }
  
  public Object getContext()
  {
    return Boolean.valueOf(true);
  }
  
  public UIControlEventManager.EventPriority getPriority()
  {
    return UIControlEventManager.EventPriority.GRAPHICAL_EDITOR;
  }
}

/* Location:
 * Qualified Name:     org.tizen.uicustomizer.ui.editor.GraphicalEditorActionBarContributor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.uicustomizer.ui.editor;

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.tizen.uicustomizer.ui.editor.messages";
  public static String GraphicalControlsEditor_0;
  public static String GraphicalControlsEditor_1;
  public static String GraphicalEditorActionBarContributor_0;
  public static String GraphicalEditorActionBarContributor_1;
  public static String UICustomizerEditor_0;
  public static String XMLEditor_ReadOnly;
  
  static
  {
    NLS.initializeMessages("org.tizen.uicustomizer.ui.editor.messages", Messages.class);
  }
}

/* Location:
 * Qualified Name:     org.tizen.uicustomizer.ui.editor.Messages
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.uicustomizer.ui.editor;

import java.util.LinkedList;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.MultiPageEditorPart;
import org.tizen.uicustomizer.events.EventData;
import org.tizen.uicustomizer.events.EventType;
import org.tizen.uicustomizer.events.IUIControlEventHandler;
import org.tizen.uicustomizer.events.UIControlEventManager;
import org.tizen.uicustomizer.events.UIControlEventManager.EventPriority;
import org.tizen.uicustomizer.model.WinsetItem;
import org.tizen.uicustomizer.model.input.WinsetItemInput;
import org.tizen.uicustomizer.model.templates.CustomUITemplate;
import org.tizen.uicustomizer.ui.animation.AnimationManager;
import org.tizen.uicustomizer.ui.views.Navigator;
import org.tizen.uicustomizer.ui.views.Properties;
import org.tizen.uicustomizer.utils.ModelSynchronizer;

public class UICustomizerEditor
  extends MultiPageEditorPart
  implements IUIControlEventHandler
{
  private static final EventType[] types = { EventType.DIRTY_PROP_CHANGED, EventType.PROJECT_SAVE, EventType.XML_EDITOR_FOCUS, EventType.REMOVE_CONTROL };
  private WinsetItemInput input;
  private LinkedList<WinsetItemEditor> editors;
  
  public UICustomizerEditor()
  {
    editors = new LinkedList();
    UIControlEventManager.getInstance().registerEvents(types, this);
  }
  
  public boolean isDirty()
  {
    return input.getItem().isDirty();
  }
  
  public boolean isSaveOnCloseNeeded()
  {
    String title = getEditorSite().getPart().getTitle();
    if (!Navigator.openCalled) {
      ModelSynchronizer.getInstance().editorCloseConfirmationDialog(title, input.getItem());
    }
    return false;
  }
  
  public Object getAdapter(Class adapter)
  {
    if (adapter == Properties.class)
    {
      if ((getActiveEditor() instanceof AnimationEditor)) {
        return Boolean.valueOf(true);
      }
      return Boolean.valueOf(false);
    }
    return super.getAdapter(adapter);
  }
  
  protected void createPages()
  {
    if ((getEditorInput() instanceof WinsetItemInput)) {
      input = ((WinsetItemInput)getEditorInput());
    }
    addWinsetItemEditor();
    if (input.getItem().hasAnimation()) {
      addAnimationEditor();
    }
    setPartName();
  }
  
  private void addAnimationEditor()
  {
    try
    {
      AnimationEditor animationEditor = new AnimationEditor(input.getItem());
      editors.add(animationEditor);
      int index = addPage(animationEditor, input);
      setPageText(index, input.getItem().toString() + Messages.UICustomizerEditor_0);
    }
    catch (PartInitException e)
    {
      EditorActivator.logException(e);
    }
  }
  
  private void addWinsetItemEditor()
  {
    try
    {
      WinsetItemEditor itemEditor = new WinsetItemEditor();
      editors.add(itemEditor);
      int index = addPage(itemEditor, input);
      setPageText(index, input.getItem().toString());
    }
    catch (PartInitException e)
    {
      EditorActivator.logException(e);
    }
  }
  
  private void setPartName()
  {
    String name = input.getItem().toString();
    setPartName(name);
  }
  
  public void doSave(IProgressMonitor monitor)
  {
    for (WinsetItemEditor editor : editors) {
      editor.doSave(new NullProgressMonitor());
    }
    for (WinsetItem control : ModelSynchronizer.getInstance().getCurrentWinset().getControlslist()) {
      if (control.equals(input.getItem()))
      {
        control.setDirty(false);
        ModelSynchronizer.getInstance().setDirty(false);
      }
    }
  }
  
  public void doSaveAs() {}
  
  public boolean isSaveAsAllowed()
  {
    return false;
  }
  
  public void handleEvent(EventData data)
  {
    if (data != null) {
      switch (type)
      {
      case WINSET_ITEM_CLOSE: 
        firePropertyChange(257);
        break;
      case PROJECT_CLOSE: 
      case PROJECT_SAVE: 
        break;
      case UI_CONTROL_COLOR_ALPHA_PROPERTY_CHANGE: 
        markSave();
        break;
      case UI_CONTROL_IMAGE_PROPERTY_CHANGE: 
        if ((property != null) && (property.equals(((WinsetItemInput)getEditorInput()).getItem()))) {
          PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(this, false);
        }
        break;
      }
    }
  }
  
  private void markSave()
  {
    firePropertyChange(257);
  }
  
  public Object getContext()
  {
    return null;
  }
  
  public UIControlEventManager.EventPriority getPriority()
  {
    return UIControlEventManager.EventPriority.MULTIPAGE_EDITOR;
  }
  
  public void dispose()
  {
    AnimationManager.killActiveAnimation();
    super.dispose();
  }
}

/* Location:
 * Qualified Name:     org.tizen.uicustomizer.ui.editor.UICustomizerEditor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.uicustomizer.ui.editor;

class WinsetItemEditor$1$1
  extends EditorBackGround
{
  WinsetItemEditor$1$1(WinsetItemEditor.1 param1) {}
}

/* Location:
 * Qualified Name:     org.tizen.uicustomizer.ui.editor.WinsetItemEditor.1.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.uicustomizer.ui.editor;

import org.eclipse.gef.editparts.GridLayer;
import org.eclipse.gef.editparts.ScalableRootEditPart;

class WinsetItemEditor$1
  extends ScalableRootEditPart
{
  WinsetItemEditor$1(WinsetItemEditor paramWinsetItemEditor) {}
  
  protected GridLayer createGridLayer()
  {
    new EditorBackGround() {};
  }
}

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

import java.util.EventObject;
import org.eclipse.gef.commands.CommandStackListener;

class WinsetItemEditor$2
  implements CommandStackListener
{
  WinsetItemEditor$2(WinsetItemEditor paramWinsetItemEditor) {}
  
  public void commandStackChanged(EventObject event)
  {
    WinsetItemEditor.access$0(this$0, 257);
  }
}

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

import java.util.Arrays;
import java.util.EventObject;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.gef.DefaultEditDomain;
import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.RootEditPart;
import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.commands.CommandStackListener;
import org.eclipse.gef.editparts.GridLayer;
import org.eclipse.gef.editparts.ScalableRootEditPart;
import org.eclipse.gef.editparts.ZoomManager;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.gef.ui.actions.RedoAction;
import org.eclipse.gef.ui.actions.UndoAction;
import org.eclipse.gef.ui.actions.ZoomInAction;
import org.eclipse.gef.ui.actions.ZoomOutAction;
import org.eclipse.gef.ui.parts.GraphicalEditor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IKeyBindingService;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.tizen.uicustomizer.events.EventData;
import org.tizen.uicustomizer.events.EventType;
import org.tizen.uicustomizer.events.UIControlEventManager;
import org.tizen.uicustomizer.model.Frame;
import org.tizen.uicustomizer.model.WinsetItem;
import org.tizen.uicustomizer.model.WinsetItemControls;
import org.tizen.uicustomizer.model.input.WinsetItemInput;
import org.tizen.uicustomizer.ui.editor.parts.FramePart;
import org.tizen.uicustomizer.ui.editor.parts.WinsetDetailPart;
import org.tizen.uicustomizer.ui.editor.parts.WinsetItemEditPartFactory;
import org.tizen.uicustomizer.utils.ImageSaveUtil;
import org.tizen.uicustomizer.utils.ModelSynchronizer;

public class WinsetItemEditor
  extends GraphicalEditor
{
  private static final String REDO_KEY = "org.eclipse.ui.edit.redo";
  private static final String UNDO_KEY = "org.eclipse.ui.edit.undo";
  protected GraphicalViewer viewer;
  protected boolean hasFocus;
  private Frame frame;
  
  public WinsetItemEditor()
  {
    setEditDomain(new DefaultEditDomain(this));
  }
  
  public boolean isDirty()
  {
    return ModelSynchronizer.getInstance().isDirty();
  }
  
  public void init(IEditorSite site, IEditorInput input)
    throws PartInitException
  {
    super.init(site, input);
    Assert.isTrue(input instanceof WinsetItemInput, "Invalid input passed");
    UIControlEventManager.getInstance().notifyEvents(EventType.WINSET_ITEM_OPEN, 
      new EventData(EventType.WINSET_ITEM_OPEN, ((WinsetItemInput)getEditorInput()).getItem(), ((WinsetItemInput)getEditorInput()).getTemplate(), this));
  }
  
  public boolean isSaveOnCloseNeeded()
  {
    return false;
  }
  
  protected void configureGraphicalViewer()
  {
    super.configureGraphicalViewer();
    viewer = getGraphicalViewer();
    ScalableRootEditPart rootEditPart = new ScalableRootEditPart()
    {
      protected GridLayer createGridLayer()
      {
        new EditorBackGround() {};
      }
    };
    viewer.setRootEditPart(rootEditPart);
    viewer.setProperty("SnapToGrid.isEnabled", Boolean.valueOf(true));
    viewer.setProperty("SnapToGrid.isVisible", Boolean.valueOf(true));
    CommandStack commandStack = getCommandStack();
    commandStack.addCommandStackListener(new CommandStackListener()
    {
      public void commandStackChanged(EventObject event)
      {
        firePropertyChange(257);
      }
    });
    viewer.setEditPartFactory(new WinsetItemEditPartFactory(commandStack));
    List<?> zoomContributions = Arrays.asList(new String[] {
    
      ZoomManager.FIT_ALL, 
      
      ZoomManager.FIT_HEIGHT, 
      
      ZoomManager.FIT_WIDTH });
    
    rootEditPart = (ScalableRootEditPart)viewer.getRootEditPart();
    rootEditPart.getZoomManager().setZoomLevelContributions(zoomContributions);
    
    rootEditPart.getZoomManager().setZoomLevels(new double[] { 0.25D, 0.5D, 0.75D, 1.0D, 1.25D, 1.5D, 1.75D, 2.0D });
    
    IAction zoomIn = new ZoomInAction(rootEditPart.getZoomManager());
    
    IAction zoomOut = new ZoomOutAction(rootEditPart.getZoomManager());
    
    getActionRegistry().registerAction(zoomIn);
    
    getActionRegistry().registerAction(zoomOut);
    
    IAction undoAction = new UndoAction(this);
    
    IAction redoAction = new RedoAction(this);
    
    undoAction.setActionDefinitionId("org.eclipse.ui.edit.undo");
    getActionRegistry().registerAction(undoAction);
    
    redoAction.setActionDefinitionId("org.eclipse.ui.edit.redo");
    getActionRegistry().registerAction(redoAction);
    
    getSite().getKeyBindingService().registerAction(zoomIn);
    getSite().getKeyBindingService().registerAction(zoomOut);
  }
  
  public Object getAdapter(Class type)
  {
    if (type == ZoomManager.class) {
      return getGraphicalViewer().getProperty(ZoomManager.class.toString());
    }
    return super.getAdapter(type);
  }
  
  protected void initializeGraphicalViewer()
  {
    frame = new Frame(((WinsetItemInput)getEditorInput()).getItem(), ((WinsetItemInput)getEditorInput()).getTemplate());
    viewer.setContents(frame);
    setPartName(((WinsetItemInput)getEditorInput()).getItem().getType().name());
    hasFocus = true;
  }
  
  public void doSave(IProgressMonitor monitor)
  {
    ModelSynchronizer.getInstance().doSave();
    markSave();
    List<?> framepartList = viewer.getRootEditPart().getChildren();
    for (Object framePart : framepartList) {
      if ((framePart instanceof FramePart)) {
        for (Object part : ((FramePart)framePart).getChildren()) {
          if ((part instanceof WinsetDetailPart)) {
            ImageSaveUtil.saveEditPartAsImage(this, viewer, (WinsetDetailPart)part);
          }
        }
      }
    }
  }
  
  private void markSave()
  {
    if (!hasFocus) {
      viewer.setContents(frame);
    }
    getCommandStack().markSaveLocation();
    firePropertyChange(257);
  }
  
  public void setFocus()
  {
    if (!hasFocus)
    {
      IEditorReference[] arrayOfIEditorReference;
      int j = (arrayOfIEditorReference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences()).length;
      for (int i = 0; i < j; i++)
      {
        IEditorReference ref = arrayOfIEditorReference[i];
        if ((ref.getEditor(true) instanceof XMLEditor))
        {
          viewer.setContents(frame);
          break;
        }
      }
    }
    if (getGraphicalViewer().getControl() != null) {
      getGraphicalViewer().getControl().setFocus();
    }
    hasFocus = true;
    UIControlEventManager.getInstance().notifyEvents(EventType.WINSET_ITEM_FOCUS, 
      new EventData(EventType.WINSET_ITEM_FOCUS, ((WinsetItemInput)getEditorInput()).getItem(), ((WinsetItemInput)getEditorInput()).getTemplate(), this));
    for (Object o : getGraphicalViewer().getEditPartRegistry().values()) {
      if ((o instanceof WinsetDetailPart)) {
        getGraphicalViewer().select((WinsetDetailPart)o);
      }
    }
  }
  
  public void dispose()
  {
    super.dispose();
    UIControlEventManager.getInstance().notifyEvents(EventType.WINSET_ITEM_CLOSE, 
      new EventData(EventType.WINSET_ITEM_CLOSE, ((WinsetItemInput)getEditorInput()).getItem(), ((WinsetItemInput)getEditorInput()).getTemplate(), this));
  }
  
  public void setStatusMessage(Image image, String message)
  {
    getEditorSite().getActionBars().getStatusLineManager().setMessage(image, message);
  }
}

/* Location:
 * Qualified Name:     org.tizen.uicustomizer.ui.editor.WinsetItemEditor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.uicustomizer.ui.editor;

import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocumentListener;
import org.tizen.uicustomizer.events.EventData;
import org.tizen.uicustomizer.events.EventType;
import org.tizen.uicustomizer.events.UIControlEventManager;

class XMLEditor$1
  implements IDocumentListener
{
  XMLEditor$1(XMLEditor paramXMLEditor) {}
  
  public void documentChanged(DocumentEvent event)
  {
    if (!XMLEditor.access$0(this$0)) {
      UIControlEventManager.getInstance().notifyEvents(EventType.XML_DOCUMENT_CHANGED, new EventData(EventType.XML_DOCUMENT_CHANGED, event, event, this));
    }
  }
  
  public void documentAboutToBeChanged(DocumentEvent event) {}
}

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

import java.util.ArrayList;
import java.util.HashMap;
import java.util.ResourceBundle;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.text.source.projection.ProjectionAnnotation;
import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel;
import org.eclipse.jface.text.source.projection.ProjectionSupport;
import org.eclipse.jface.text.source.projection.ProjectionViewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.TextOperationAction;
import org.tizen.uicustomizer.events.EventData;
import org.tizen.uicustomizer.events.EventType;
import org.tizen.uicustomizer.events.IUIControlEventHandler;
import org.tizen.uicustomizer.events.UIControlEventManager;
import org.tizen.uicustomizer.events.UIControlEventManager.EventPriority;
import org.tizen.uicustomizer.ui.StringStorage;
import org.tizen.uicustomizer.ui.XMLEditorInput;
import org.tizen.uicustomizer.ui.editor.xmlEditor.editor.ColorManager;
import org.tizen.uicustomizer.ui.editor.xmlEditor.editor.XMLConfiguration;
import org.tizen.uicustomizer.ui.editor.xmlEditor.editor.XMLDocumentProvider;
import org.tizen.uicustomizer.utils.ModelSynchronizer;
import org.w3c.dom.ls.LSException;

public class XMLEditor
  extends TextEditor
  implements IUIControlEventHandler
{
  private ColorManager colorManager;
  public XMLEditorInput editorInput;
  private ProjectionSupport projectionSupport;
  private boolean hasFocus;
  private Annotation[] oldAnnotations;
  private ProjectionAnnotationModel annotationModel;
  public static final String CONTENT_FORMAT_PROPOSAL = "ContentFormatProposal";
  public static final String CONTENT_FORMAT_PROPOSAL_PREFIX = "ContentFormatProposal.";
  public static final String CONTENT_FORMAT_ACTION_ID = "org.tizen.uicustomizer.formatCommand";
  private boolean internalFocusOp = false;
  private Composite parent;
  private static HashMap<ProjectionAnnotation, Position> newAnnotations = new HashMap();
  private static final EventType[] types = { EventType.DIRTY_PROP_CHANGED, EventType.PROJECT_SAVE, EventType.WINSET_ITEM_FOCUS, EventType.MODEL_UPDATED, 
    EventType.PROJECT_SAVE };
  
  public XMLEditor()
  {
    colorManager = new ColorManager();
    setSourceViewerConfiguration(new XMLConfiguration(colorManager, this));
    setDocumentProvider(new XMLDocumentProvider(getEditorInput()));
    UIControlEventManager.getInstance().registerEvents(types, this);
    UIControlEventManager.getInstance().notifyEvents(EventType.XML_EDITOR_OPEN, new EventData(EventType.XML_EDITOR_OPEN, getEditorInput(), getEditorInput(), this));
    hasFocus = false;
  }
  
  public void dispose()
  {
    colorManager.dispose();
    super.dispose();
    UIControlEventManager.getInstance().deRegisterEventListener(this);
    UIControlEventManager.getInstance().notifyEvents(EventType.XML_EDITOR_CLOSE, new EventData(EventType.XML_EDITOR_CLOSE, getEditorInput(), getEditorInput(), this));
  }
  
  public boolean isSaveOnCloseNeeded()
  {
    return false;
  }
  
  public void createPartControl(Composite parent)
  {
    super.createPartControl(parent);
    this.parent = parent;
    ProjectionViewer viewer = (ProjectionViewer)getSourceViewer();
    projectionSupport = new ProjectionSupport(viewer, getAnnotationAccess(), getSharedColors());
    projectionSupport.install();
    
    viewer.doOperation(19);
    annotationModel = viewer.getProjectionAnnotationModel();
    
    getDocumentProvider().getDocument(editorInput).addDocumentListener(new IDocumentListener()
    {
      public void documentChanged(DocumentEvent event)
      {
        if (!internalFocusOp) {
          UIControlEventManager.getInstance().notifyEvents(EventType.XML_DOCUMENT_CHANGED, new EventData(EventType.XML_DOCUMENT_CHANGED, event, event, this));
        }
      }
      
      public void documentAboutToBeChanged(DocumentEvent event) {}
    });
  }
  
  protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles)
  {
    ISourceViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles);
    
    getSourceViewerDecorationSupport(viewer);
    return viewer;
  }
  
  public void updateFoldingStructure(ArrayList<Position> positions)
  {
    Annotation[] annotations = new Annotation[positions.size()];
    
    newAnnotations.clear();
    for (int i = 0; i < positions.size(); i++)
    {
      ProjectionAnnotation annotation = new ProjectionAnnotation();
      newAnnotations.put(annotation, (Position)positions.get(i));
      annotations[i] = annotation;
    }
    annotationModel.modifyAnnotations(oldAnnotations, newAnnotations, null);
    oldAnnotations = annotations;
  }
  
  protected void doSetInput(IEditorInput newInput)
    throws CoreException
  {
    super.doSetInput(newInput);
    editorInput = ((XMLEditorInput)newInput);
  }
  
  public void doSave(IProgressMonitor progressMonitor)
  {
    try
    {
      ModelSynchronizer.getInstance().doSave();
      markSave();
    }
    catch (ClassCastException e)
    {
      EditorActivator.getDefault().getLog().log(new Status(4, "org.tizen.uicustomizer.ui.editor", e.getMessage(), e));
    }
    catch (CoreException e)
    {
      EditorActivator.getDefault().getLog().log(new Status(4, "org.tizen.uicustomizer.ui.editor", e.getMessage(), e));
    }
    catch (LSException e)
    {
      EditorActivator.getDefault().getLog().log(new Status(4, "org.tizen.uicustomizer.ui.editor", e.getMessage(), e));
    }
  }
  
  public void updateModelFromXML() {}
  
  public void setFocus()
  {
    super.setFocus();
    if (!hasFocus) {
      updateXMLContents();
    }
    hasFocus = true;
    UIControlEventManager.getInstance().notifyEvents(EventType.XML_EDITOR_FOCUS, new EventData(EventType.XML_EDITOR_FOCUS, getEditorInput(), getEditorInput(), this));
    parent.setFocus();
  }
  
  public void updateXMLContents()
  {
    internalFocusOp = true;
    try
    {
      ((XMLEditorInput)getEditorInput()).reLoadInput();
      IDocumentProvider documentProvider = getDocumentProvider();
      if (documentProvider != null)
      {
        documentProvider.getDocument(getEditorInput()).set(((StringStorage)((XMLEditorInput)getEditorInput()).getStorage()).getData());
        ((SourceViewer)getSourceViewer()).doOperation(15);
      }
    }
    catch (ClassCastException e)
    {
      EditorActivator.getDefault().getLog().log(new Status(4, "org.tizen.uicustomizer.ui.editor", e.getMessage(), e));
    }
    internalFocusOp = false;
  }
  
  private void markSave()
    throws CoreException
  {
    if (!hasFocus)
    {
      internalFocusOp = true;
      ((XMLEditorInput)getEditorInput()).reLoadInput();
      SourceViewer sourceViewer = (SourceViewer)getSourceViewer();
      if (sourceViewer != null)
      {
        sourceViewer.doOperation(15);
        getDocumentProvider().getDocument(getEditorInput()).set(((StringStorage)((XMLEditorInput)getEditorInput()).getStorage()).getData());
      }
      internalFocusOp = false;
    }
  }
  
  public boolean isDirty()
  {
    return false;
  }
  
  protected void createActions()
  {
    super.createActions();
    ResourceBundle bundle = EditorActivator.getDefault().getResourceBundle();
    TextOperationAction action = new TextOperationAction(bundle, "ContentFormatProposal.", this, 15);
    action.setActionDefinitionId("org.tizen.uicustomizer.formatCommand");
    setAction("ContentFormatProposal", action);
  }
  
  public void init(IEditorSite site, IEditorInput input)
    throws PartInitException
  {
    editorInput = ((XMLEditorInput)input);
    super.init(site, input);
  }
  
  public void handleEvent(EventData data)
  {
    if (data != null) {
      switch (type)
      {
      case WINSET_ITEM_CLOSE: 
        firePropertyChange(257);
        break;
      case MODEL_UPDATED: 
      case PALETTE_CHANGED: 
        hasFocus = false;
        break;
      case UI_CONTROL_COLOR_ALPHA_PROPERTY_CHANGE: 
        try
        {
          updateXMLContents();
        }
        catch (ClassCastException e)
        {
          EditorActivator.getDefault().getLog().log(new Status(4, "org.tizen.uicustomizer.ui.editor", e.getMessage(), e));
        }
      case XML_EDITOR_CLOSE: 
        updateXMLContents();
      }
    }
  }
  
  public Object getContext()
  {
    return null;
  }
  
  public UIControlEventManager.EventPriority getPriority()
  {
    return UIControlEventManager.EventPriority.XML_EDITOR;
  }
}

/* Location:
 * Qualified Name:     org.tizen.uicustomizer.ui.editor.XMLEditor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.uicustomizer.ui.editor;

import java.util.ResourceBundle;
i
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

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