org.eclipse.jst.jsf.facesconfig.ui_1.2.2.v201103292152

{
  WindowFreeformHelper$ChildTracker(WindowFreeformHelper paramWindowFreeformHelper) {}
  
  public void figureMoved(IFigure source)
  {
    this$0.invalidate();
  }
}

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

import java.util.List;
import org.eclipse.draw2d.FigureListener;
import org.eclipse.draw2d.FreeformFigure;
import org.eclipse.draw2d.FreeformLayeredPane;
import org.eclipse.draw2d.FreeformListener;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.LayoutManager;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.draw2d.geometry.Rectangle;

class WindowFreeformHelper
  implements FreeformListener
{
  FreeformLayeredPane x;
  private FreeformFigure host;
  private Rectangle freeformExtent;
  
  class ChildTracker
    implements FigureListener
  {
    ChildTracker() {}
    
    public void figureMoved(IFigure source)
    {
      invalidate();
    }
  }
  
  private FigureListener figureListener = new ChildTracker();
  
  public WindowFreeformHelper(FreeformFigure host)
  {
    this.host = host;
  }
  
  public Rectangle getFreeformExtent()
  {
    if (freeformExtent != null) {
      return freeformExtent;
    }
    List children = host.getChildren();
    for (int i = 0; i < children.size(); i++)
    {
      IFigure child = (IFigure)children.get(i);
      Rectangle r;
      Rectangle r;
      if ((child instanceof FreeformFigure)) {
        r = ((FreeformFigure)child).getFreeformExtent();
      } else {
        r = child.getBounds();
      }
      if (freeformExtent == null) {
        freeformExtent = r.getCopy();
      } else {
        freeformExtent.union(r);
      }
    }
    Insets insets = host.getInsets();
    if (freeformExtent == null)
    {
      freeformExtent = new Rectangle(0, 0, insets.getWidth(), insets
        .getHeight());
    }
    else
    {
      host.translateToParent(freeformExtent);
      freeformExtent.expand(insets);
    }
    return freeformExtent;
  }
  
  public void hookChild(IFigure child)
  {
    invalidate();
    if ((child instanceof FreeformFigure)) {
      ((FreeformFigure)child).addFreeformListener(this);
    } else {
      child.addFigureListener(figureListener);
    }
  }
  
  void invalidate()
  {
    freeformExtent = null;
    host.fireExtentChanged();
    if (host.getParent() != null) {
      host.getParent().revalidate();
    } else {
      host.revalidate();
    }
  }
  
  public void notifyFreeformExtentChanged()
  {
    invalidate();
  }
  
  public void setFreeformBounds(Rectangle bounds)
  {
    host.setBounds(bounds);
    bounds = bounds.getCopy();
    host.translateFromParent(bounds);
    List children = host.getChildren();
    for (int i = 0; i < children.size(); i++)
    {
      IFigure child = (IFigure)children.get(i);
      if ((child instanceof FreeformFigure)) {
        ((FreeformFigure)child).setFreeformBounds(bounds);
      }
    }
    host.getLayoutManager().layout(host);
  }
  
  public void unhookChild(IFigure child)
  {
    invalidate();
    if ((child instanceof FreeformFigure)) {
      ((FreeformFigure)child).removeFreeformListener(this);
    } else {
      child.removeFigureListener(figureListener);
    }
  }
}

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

import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanScopeType;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType;
import org.eclipse.jst.jsf.facesconfig.ui.section.ManagedBeanScopeTreeItem;

public class ManagedBeanContentProvider
  implements ITreeContentProvider
{
  private List scopeItemList = null;
  
  public Object[] getChildren(Object parent)
  {
    if ((parent instanceof FacesConfigType))
    {
      if (scopeItemList == null)
      {
        scopeItemList = new ArrayList();
        for (int i = 0; i < ManagedBeanScopeTreeItem.scopeItems.length; i++)
        {
          ManagedBeanScopeTreeItem scopeTreeItem = new ManagedBeanScopeTreeItem(
            ManagedBeanScopeTreeItem.scopeItems[i], 
            (FacesConfigType)parent);
          scopeItemList.add(scopeTreeItem);
        }
      }
      return scopeItemList.toArray();
    }
    if ((parent instanceof ManagedBeanScopeTreeItem)) {
      return ((ManagedBeanScopeTreeItem)parent).getChildren().toArray();
    }
    return new Object[0];
  }
  
  public Object[] getElements(Object inputElement)
  {
    return getChildren(inputElement);
  }
  
  public Object getParent(Object element)
  {
    if ((element instanceof ManagedBeanScopeTreeItem)) {
      return ((ManagedBeanScopeTreeItem)element).getParent();
    }
    if ((element instanceof ManagedBeanType))
    {
      String scope = null;
      if (((ManagedBeanType)element).getManagedBeanScope() != null) {
        scope = 
          ((ManagedBeanType)element).getManagedBeanScope().getTextContent();
      }
      if (scope != null) {
        for (int i = 0; i < scopeItemList.size(); i++) {
          if (((ManagedBeanScopeTreeItem)scopeItemList.get(i)).getScope().equals(scope)) {
            return scopeItemList.get(i);
          }
        }
      }
    }
    return null;
  }
  
  public boolean hasChildren(Object element)
  {
    if ((element instanceof FacesConfigType)) {
      return true;
    }
    if ((element instanceof ManagedBeanScopeTreeItem)) {
      return ((ManagedBeanScopeTreeItem)element).hasChildren();
    }
    return false;
  }
  
  public void dispose() {}
  
  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
}

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

import java.util.Hashtable;
import java.util.Map;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanClassType;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanNameType;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.jst.jsf.facesconfig.ui.section.ManagedBeanScopeTreeItem;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

public class ManagedBeanLabelProvider
  extends LabelProvider
{
  private static final String SCOPE_IMAGE_FILE = "Scope.gif";
  private static final String SCOPE_NONE_IMAGE_FILE = "Scope_None.gif";
  private static final String SCOPE_APPLICATION_IMAGE_FILE = "Scope_Application.gif";
  private static final String SCOPE_REQUEST_IMAGE_FILE = "Scope_Request.gif";
  private static final String SCOPE_SESSION_IMAGE_FILE = "Scope_Session.gif";
  private static final String MANAGED_BEAN_IMAGE_FILE = "facesconfig/FacesConfig_ManagedBean.gif";
  private Map imageTable;
  
  public String getText(Object obj)
  {
    String text = "";
    if ((obj instanceof ManagedBeanType))
    {
      ManagedBeanType bean = (ManagedBeanType)obj;
      if (bean.getManagedBeanName() != null) {
        text = bean.getManagedBeanName().getTextContent();
      }
      if (((text == null) || (text.length() < 1)) && 
        (bean.getManagedBeanClass() != null)) {
        text = bean.getManagedBeanClass().getTextContent();
      }
    }
    else if ((obj instanceof ManagedBeanScopeTreeItem))
    {
      text = ((ManagedBeanScopeTreeItem)obj).getScope();
    }
    return text;
  }
  
  public Image getImage(Object obj)
  {
    ImageDescriptor imageDesc = null;
    if ((obj instanceof ManagedBeanType))
    {
      imageDesc = EditorPlugin.getDefault().getImageDescriptor(
        "facesconfig/FacesConfig_ManagedBean.gif");
    }
    else if ((obj instanceof ManagedBeanScopeTreeItem))
    {
      ManagedBeanScopeTreeItem scopeTreeItem = (ManagedBeanScopeTreeItem)obj;
      if ("session".equals(scopeTreeItem.getScope())) {
        imageDesc = EditorPlugin.getDefault().getImageDescriptor(
          "Scope_Session.gif");
      } else if ("request".equals(scopeTreeItem.getScope())) {
        imageDesc = EditorPlugin.getDefault().getImageDescriptor(
          "Scope_Request.gif");
      } else if ("application".equals(scopeTreeItem.getScope())) {
        imageDesc = EditorPlugin.getDefault().getImageDescriptor(
          "Scope_Application.gif");
      } else if ("none".equals(scopeTreeItem.getScope())) {
        imageDesc = EditorPlugin.getDefault().getImageDescriptor(
          "Scope_None.gif");
      } else {
        imageDesc = EditorPlugin.getDefault().getImageDescriptor(
          "Scope.gif");
      }
    }
    if (imageDesc != null)
    {
      if (imageTable == null) {
        imageTable = new Hashtable(40);
      }
      Image image = (Image)imageTable.get(imageDesc);
      if (image == null)
      {
        image = imageDesc.createImage();
        imageTable.put(imageDesc, image);
      }
      return image;
    }
    return PlatformUI.getWorkbench().getSharedImages().getImage(
      "IMG_OBJ_ELEMENTS");
  }
}

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

import org.eclipse.help.HelpSystem;
import org.eclipse.help.IContext;
import org.eclipse.help.IHelpResource;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.help.IWorkbenchHelpSystem;

class AbstractFacesConfigSection$1
  extends HyperlinkAdapter
{
  AbstractFacesConfigSection$1(AbstractFacesConfigSection paramAbstractFacesConfigSection) {}
  
  public void linkActivated(HyperlinkEvent e)
  {
    IContext context = HelpSystem.getContext(AbstractFacesConfigSection.access$0(this$0));
    if (context != null)
    {
      IHelpResource[] topics = context.getRelatedTopics();
      if ((topics != null) && (topics.length == 1)) {
        EditorPlugin.getDefault().getWorkbench().getHelpSystem().displayHelpResource(
          topics[0].getHref());
      } else {
        EditorPlugin.getDefault().getWorkbench().getHelpSystem().displayHelp(AbstractFacesConfigSection.access$0(this$0));
      }
    }
  }
}

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

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.help.HelpSystem;
import org.eclipse.help.IContext;
import org.eclipse.help.IHelpResource;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.SectionPart;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ImageHyperlink;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.help.IWorkbenchHelpSystem;

public abstract class AbstractFacesConfigSection
  extends SectionPart
  implements IFacesConfigSection, ISelectionProvider, ISelectionChangedListener
{
  private FormToolkit toolkit;
  private String helpContextId = null;
  private String helpTooltip = null;
  private Object input = null;
  private IFacesConfigPage page;
  private List selectionChangedListeners = new ArrayList();
  private static final Image HELP_IMAGE = EditorPlugin.getDefault().getImage(
    "help.gif");
  
  public AbstractFacesConfigSection(Composite parent, IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit, String helpContextId, String helpTooltip)
  {
    super(parent, toolkit, 450);
    
    super.initialize(managedForm);
    this.page = page;
    this.toolkit = toolkit;
    this.helpContextId = helpContextId;
    this.helpTooltip = helpTooltip;
  }
  
  public void dispose()
  {
    selectionChangedListeners.clear();
    if (input != null) {
      removeAdaptersFromInput(input);
    }
    super.dispose();
  }
  
  public void initialize()
  {
    if (helpContextId != null) {
      createTextClientWithHelp();
    }
    getSection().setLayout(new GridLayout());
    
    Composite clientContainer = toolkit.createComposite(getSection());
    GridData gd = new GridData(1808);
    clientContainer.setLayoutData(gd);
    
    createContents(clientContainer, toolkit);
    getSection().setClient(clientContainer);
  }
  
  private void createTextClientWithHelp()
  {
    ImageHyperlink helpImage = new ImageHyperlink(getSection(), 0);
    
    toolkit.adapt(helpImage, true, true);
    
    helpImage.setImage(HELP_IMAGE);
    
    helpImage.setBackground(getSection().getTitleBarGradientBackground());
    if (helpTooltip != null) {
      helpImage.setToolTipText(helpTooltip);
    }
    helpImage.addHyperlinkListener(new HyperlinkAdapter()
    {
      public void linkActivated(HyperlinkEvent e)
      {
        IContext context = HelpSystem.getContext(helpContextId);
        if (context != null)
        {
          IHelpResource[] topics = context.getRelatedTopics();
          if ((topics != null) && (topics.length == 1)) {
            EditorPlugin.getDefault().getWorkbench().getHelpSystem().displayHelpResource(
              topics[0].getHref());
          } else {
            EditorPlugin.getDefault().getWorkbench().getHelpSystem().displayHelp(helpContextId);
          }
        }
      }
    });
    getSection().setTextClient(helpImage);
  }
  
  protected abstract void createContents(Composite paramComposite, FormToolkit paramFormToolkit);
  
  public Object getInput()
  {
    return input;
  }
  
  public void setInput(Object newInput)
  {
    if (input != null) {
      removeAdaptersFromInput(input);
    }
    input = newInput;
    if (newInput != null) {
      addAdaptersOntoInput(newInput);
    }
    refreshAll();
  }
  
  protected void removeAdaptersFromInput(Object oldInput) {}
  
  protected void addAdaptersOntoInput(Object newInput) {}
  
  public IFacesConfigPage getPage()
  {
    return page;
  }
  
  public ISelection getSelection()
  {
    return StructuredSelection.EMPTY;
  }
  
  public void setSelection(ISelection selection) {}
  
  public void addSelectionChangedListener(ISelectionChangedListener listener)
  {
    selectionChangedListeners.add(listener);
  }
  
  public void removeSelectionChangedListener(ISelectionChangedListener listener)
  {
    selectionChangedListeners.remove(listener);
  }
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    for (Iterator listeners = selectionChangedListeners.iterator(); listeners
          .hasNext();)
    {
      ISelectionChangedListener listener = 
        (ISelectionChangedListener)listeners.next();
      listener.selectionChanged(new SelectionChangedEvent(this, 
        event != null ? event.getSelection() : 
        StructuredSelection.EMPTY));
    }
  }
  
  public AdapterFactory getAdapterFactory()
  {
    return (AdapterFactory)getPage().getEditor().getAdapter(
      AdapterFactory.class);
  }
  
  public EditingDomain getEditingDomain()
  {
    return (EditingDomain)getPage().getEditor().getAdapter(
      EditingDomain.class);
  }
  
  public void clearAll() {}
}

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

import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jst.jsf.common.ui.internal.actions.OpenPageAction;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;

class AbstractOverviewSection$1
  extends MouseAdapter
{
  AbstractOverviewSection$1(AbstractOverviewSection paramAbstractOverviewSection) {}
  
  public void mouseDoubleClick(MouseEvent e)
  {
    if (((IStructuredSelection)this$0.tableViewer.getSelection())
      .size() == 1)
    {
      OpenPageAction action = new OpenPageAction();
      action.setPageName(AbstractOverviewSection.access$0(this$0));
      action.setSelection(this$0.tableViewer.getSelection());
      action.run();
    }
  }
}

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

import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jst.jsf.common.ui.internal.actions.OpenPageAction;
import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;

public abstract class AbstractOverviewSection
  extends AbstractFacesConfigSection
{
  protected TableViewer tableViewer;
  private String targetPageID;
  
  public AbstractOverviewSection(Composite parent, IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit, String targetPageID, String title, String description, String helpContextId, String helpTooltip)
  {
    super(parent, managedForm, page, toolkit, helpContextId, helpTooltip);
    this.targetPageID = targetPageID;
    getSection().setText(title);
    getSection().setDescription(description);
  }
  
  protected void createContents(Composite container, FormToolkit toolkit)
  {
    GridLayout layout = new GridLayout();
    numColumns = 1;
    marginHeight = 2;
    marginWidth = 2;
    verticalSpacing = 5;
    horizontalSpacing = 6;
    container.setLayout(layout);
    toolkit.paintBordersFor(container);
    Table table = createTable(container);
    if (targetPageID != null) {
      table.addMouseListener(new MouseAdapter()
      {
        public void mouseDoubleClick(MouseEvent e)
        {
          if (((IStructuredSelection)tableViewer.getSelection())
            .size() == 1)
          {
            OpenPageAction action = new OpenPageAction();
            action.setPageName(targetPageID);
            action.setSelection(tableViewer.getSelection());
            action.run();
          }
        }
      });
    }
    tableViewer = new TableViewer(table);
    tableViewer.setContentProvider(new AdapterFactoryContentProvider(
      getAdapterFactory()));
    ComposedAdapterFactory factory = (ComposedAdapterFactory)getAdapterFactory();
    tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(factory));
    configTableViewer(tableViewer);
  }
  
  protected abstract Table createTable(Composite paramComposite);
  
  protected abstract void configTableViewer(TableViewer paramTableViewer);
  
  public void clearAll()
  {
    tableViewer.setInput(null);
  }
  
  public void refreshAll()
  {
    tableViewer.setInput(getInput());
  }
}

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

import org.eclipse.emf.ecore.EClass;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;

class ApplicationSection$1
  extends ViewerFilter
{
  ApplicationSection$1(ApplicationSection paramApplicationSection) {}
  
  public boolean select(Viewer viewer, Object parentElement, Object element)
  {
    return ApplicationSection.access$0(this$0).isInstance(element);
  }
}

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

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandStack;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jst.jsf.facesconfig.emf.ApplicationType;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType;
import org.eclipse.jst.jsf.facesconfig.ui.dialog.DialogUtil;
import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage;
import org.eclipse.jst.jsf.facesconfig.ui.page.OthersPage;
import org.eclipse.jst.jsf.facesconfig.ui.util.ModelUtil;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;

public class ApplicationSection
  extends OthersPageBaseSection
{
  private EClass applicationChildClass;
  
  public ApplicationSection(EClass applicationChildClass, Composite parent, IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit, String helpContextId, String helpTooltip)
  {
    super(parent, managedForm, page, toolkit, helpContextId, helpTooltip);
    this.applicationChildClass = applicationChildClass;
  }
  
  public ApplicationSection(EClass componentClass, Composite parent, IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit)
  {
    this(componentClass, parent, managedForm, page, toolkit, null, null);
  }
  
  public EObject createApplicationChildObject()
  {
    String textValue = null;
    IProject project = (IProject)getPage().getEditor().getAdapter(
      IProject.class);
    FacesConfigType facesConfig = (FacesConfigType)getPage()
      .getInput();
    if (applicationChildClass == FacesConfigPackage.eINSTANCE
      .getDefaultRenderKitIdType())
    {
      textValue = DialogUtil.openRenderKitDialog(getSection().getShell(), 
        facesConfig);
    }
    else if (applicationChildClass == FacesConfigPackage.eINSTANCE
      .getMessageBundleType())
    {
      List bundles = new ArrayList();
      if (facesConfig.getApplication().size() > 0)
      {
        ApplicationType applicationType = 
          (ApplicationType)facesConfig.getApplication().get(0);
        bundles = applicationType.getMessageBundle();
      }
      textValue = DialogUtil.openMessageBundleDialog(getSection()
        .getShell(), project, bundles);
    }
    else
    {
      String superType = ModelUtil.getSuperType(applicationChildClass);
      textValue = DialogUtil.openClassDialog(getSection().getShell(), 
        project, superType, 
        256);
    }
    if ((textValue != null) && (textValue.length() > 0))
    {
      EObject component = FacesConfigFactory.eINSTANCE
        .create(applicationChildClass);
      
      EStructuralFeature feature = 
        (EStructuralFeature)applicationChildClass.getEStructuralFeatures().get(0);
      component.eSet(feature, textValue);
      return component;
    }
    return null;
  }
  
  protected void setViewerInput(Object input)
  {
    if ((input instanceof ApplicationType)) {
      tableViewer.setInput(input);
    } else {
      tableViewer.setInput(null);
    }
  }
  
  protected void configTableViewer(TableViewer tableViewer1)
  {
    tableViewer1.addFilter(new ViewerFilter()
    {
      public boolean select(Viewer viewer, Object parentElement, Object element)
      {
        return applicationChildClass.isInstance(element);
      }
    });
  }
  
  void addButtonSelected(SelectionEvent e)
  {
    EObject obj = createApplicationChildObject();
    if (obj != null)
    {
      boolean needRefreshAll = false;
      Command command = null;
      if ((getInput() instanceof ApplicationType))
      {
        ApplicationType application = (ApplicationType)getInput();
        command = AddCommand.create(getEditingDomain(), application, 
          null, obj);
      }
      else
      {
        needRefreshAll = true;
        
        List list = new ArrayList(2);
        ApplicationType application = FacesConfigFactory.eINSTANCE
          .createApplicationType();
        Command cmd1 = AddCommand.create(getEditingDomain(), 
          application, null, obj);
        list.add(cmd1);
        Command cmd2 = AddCommand.create(getEditingDomain(), 
          getPage().getInput(), null, application);
        list.add(cmd2);
        command = new CompoundCommand(list);
      }
      if (command.canExecute())
      {
        getEditingDomain().getCommandStack().execute(command);
        if (needRefreshAll) {
          ((OthersPage)getPage()).resetApplicationInput();
        }
      }
    }
  }
}

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

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

class AttributeSection$1
  extends SelectionAdapter
{
  AttributeSection$1(AttributeSection paramAttributeSection) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    AttributeSection.access$0(this$0);
  }
}

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

import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;

class AttributeSection$2
  extends MouseAdapter
{
  AttributeSection$2(AttributeSection paramAttributeSection) {}
  
  public void mouseDoubleClick(MouseEvent e)
  {
    if (((IStructuredSelection)AttributeSection.access$1(this$0).getSelection()).size() > 0) {
      AttributeSection.access$2(this$0);
    }
  }
}

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

import org.eclipse.emf.ecore.EClass;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;

class AttributeSection$3
  extends ViewerFilter
{
  AttributeSection$3(AttributeSection paramAttributeSection) {}
  
  public boolean select(Viewer viewer, Object parentElement, Object element)
  {
    return 
      FacesConfigPackage.eINSTANCE.getAttributeType().isInstance(element);
  }
}

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

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

class AttributeSection$4
  extends SelectionAdapter
{
  AttributeSection$4(AttributeSection paramAttributeSection) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    AttributeSection.access$3(this$0);
  }
}

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

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

class AttributeSection$5
  extends SelectionAdapter
{
  AttributeSection$5(AttributeSection paramAttributeSection) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    AttributeSection.access$2(this$0);
  }
}

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

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

class AttributeSection$6
  extends SelectionAdapter
{
  AttributeSection$6(AttributeSection paramAttributeSection) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    AttributeSection.access$4(this$0);
  }
}

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

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Assert;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandStack;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jst.jsf.facesconfig.emf.AttributeClassType;
import org.eclipse.jst.jsf.facesconfig.emf.AttributeNameType;
import org.eclipse.jst.jsf.facesconfig.emf.AttributeType;
import org.eclipse.jst.jsf.facesconfig.emf.DefaultValueType;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
import org.eclipse.jst.jsf.facesconfig.emf.SuggestedValueType;
import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.jst.jsf.facesconfig.ui.dialog.AddEditAttributeDialog;
import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;

public class AttributeSection
  extends AbstractFacesConfigSection
{
  private static final int TABLE_DEFAULT_HEIGHT = 160;
  private TableViewer tableViewer;
  private Button removeButton;
  private Button editButton;
  
  public AttributeSection(Composite parent, IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit)
  {
    super(parent, managedForm, page, toolkit, null, null);
    getSection().setText(EditorMessages.AttributeSection_Name);
    getSection().setDescription(
      EditorMessages.AttributeSection_Description);
  }
  
  protected void createContents(Composite container, FormToolkit toolkit)
  {
    GridLayout gl = new GridLayout();
    horizontalSpacing = 0;
    marginWidth = 0;
    numColumns = 2;
    container.setLayout(gl);
    GridData td = new GridData(1808);
    container.setLayoutData(td);
    
    toolkit.paintBordersFor(container);
    
    Composite attributeSection = toolkit.createComposite(container);
    GridLayout gl2 = new GridLayout();
    horizontalSpacing = 0;
    verticalSpacing = 0;
    marginWidth = 0;
    marginHeight = 0;
    numColumns = 2;
    attributeSection.setLayout(gl2);
    GridData gd = new GridData(1810);
    
    attributeSection.setLayoutData(gd);
    
    createTableSection(attributeSection, toolkit);
    createButtonsSection(attributeSection, toolkit);
  }
  
  private void createTableSection(Composite container, FormToolkit toolkit)
  {
    Composite tableContainer = toolkit.createComposite(container);
    GridData gd = new GridData(1808);
    
    tableContainer.setLayoutData(gd);
    toolkit.paintBordersFor(tableContainer);
    
    GridLayout gl = new GridLayout();
    tableContainer.setLayout(gl);
    
    Table table = new Table(tableContainer, 68352);
    
    gd = new GridData(1808);
    horizontalSpan = 1;
    heightHint = 160;
    table.setLayoutData(gd);
    
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableLayout layout = new TableLayout();
    table.setLayout(layout);
    
    TableColumn nameCol = new TableColumn(table, 0);
    layout.addColumnData(new ColumnWeightData(1, true));
    nameCol
      .setText(EditorMessages.AttributeSection_Table_NameColumn);
    
    TableColumn classCol = new TableColumn(table, 0);
    layout.addColumnData(new ColumnWeightData(1, true));
    classCol
      .setText(EditorMessages.AttributeSection_Table_ClassColumn);
    
    TableColumn valueCol = new TableColumn(table, 0);
    layout.addColumnData(new ColumnWeightData(1, true));
    valueCol
      .setText(EditorMessages.AttributeSection_Table_DefaultValueColumn);
    
    TableColumn suggestedValueCol = new TableColumn(table, 0);
    layout.addColumnData(new ColumnWeightData(1, true));
    suggestedValueCol
      .setText(EditorMessages.AttributeSection_Table_SuggestedValueColumn);
    
    table.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        AttributeSection.this.updateButtons();
      }
    });
    table.addMouseListener(new MouseAdapter()
    {
      public void mouseDoubleClick(MouseEvent e)
      {
        if (((IStructuredSelection)tableViewer.getSelection()).size() > 0) {
          AttributeSection.this.editButtonSelected();
        }
      }
    });
    tableViewer = new TableViewer(table);
    tableViewer.setContentProvider(new AdapterFactoryContentProvider(
      getAdapterFactory()));
    tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(
      getAdapterFactory()));
    
    tableViewer.addFilter(new ViewerFilter()
    {
      public boolean select(Viewer viewer, Object parentElement, Object element)
      {
        return 
          FacesConfigPackage.eINSTANCE.getAttributeType().isInstance(element);
      }
    });
    tableViewer.addSelectionChangedListener(this);
  }
  
  private void updateButtons()
  {
    if (((IStructuredSelection)tableViewer.getSelection()).size() > 0)
    {
      editButton.setEnabled(true);
      removeButton.setEnabled(true);
    }
    else
    {
      editButton.setEnabled(false);
      removeButton.setEnabled(false);
    }
  }
  
  private void createButtonsSection(Composite container, FormToolkit toolkit)
  {
    Composite operationContainer = toolkit.createComposite(container);
    GridData gd = new GridData(1042);
    
    operationContainer.setLayoutData(gd);
    GridLayout gl = new GridLayout();
    operationContainer.setLayout(gl);
    
    Button addButton = toolkit.createButton(operationContainer, 
      EditorMessages.UI_Button_Add_more, 
      8);
    gd = new GridData(770);
    
    grabExcessHorizontalSpace = false;
    addButton.setLayoutData(gd);
    
    editButton = toolkit.createButton(operationContainer, 
      EditorMessages.UI_Button_Edit_more, 
      8);
    gd = new GridData(770);
    
    grabExcessHorizontalSpace = false;
    editButton.setLayoutData(gd);
    
    removeButton = toolkit.createButton(operationContainer, 
      EditorMessages.UI_Button_Remove, 
      8);
    gd = new GridData(770);
    
    grabExcessHorizontalSpace = false;
    removeButton.setLayoutData(gd);
    
    addButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        AttributeSection.this.addButtonSelected();
      }
    });
    editButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        AttributeSection.this.editButtonSelected();
      }
    });
    removeButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        AttributeSection.this.removeButtonSelected();
      }
    });
  }
  
  public void refreshAll()
  {
    tableViewer.setInput(getInput());
    updateButtons();
  }
  
  public void refresh()
  {
    super.refresh();
    tableViewer.refresh();
    updateButtons();
  }
  
  private void addButtonSelected()
  {
    Shell shell = EditorPlugin.getActiveShell();
    
    AddEditAttributeDialog dialog = new AddEditAttributeDialog(shell, true);
    dialog.setProject((IProject)getPage().getEditor().getAdapter(
      IProject.class));
    if (dialog.open() == 0)
    {
      AttributeType newAttribute = FacesConfigFactory.eINSTANCE
        .createAttributeType();
      if (dialog.getAttributeName().length() > 0)
      {
        AttributeNameType attributeNameType = FacesConfigFactory.eINSTANCE
          .createAttributeNameType();
        attributeNameType.setTextContent(dialog.getAttributeName());
        newAttribute.setAttributeName(attributeNameType);
      }
      if (dialog.getAttributeClass().length() > 0)
      {
        AttributeClassType attributeClassType = FacesConfigFactory.eINSTANCE
          .createAttributeClassType();
        attributeClassType.setTextContent(dialog.getAttributeClass());
        newAttribute.setAttributeClass(attributeClassType);
      }
      if (dialog.getDefaultValue().length() > 0)
      {
        DefaultValueType defaultValueType = FacesConfigFactory.eINSTANCE
          .createDefaultValueType();
        defaultValueType.setTextContent(dialog.getDefaultValue());
        newAttribute.setDefaultValue(defaultValueType);
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 37 38 39 40

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