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

r;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanScopeType;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType;

class ManagedBeanGeneralSection$3
  implements IDialogFieldChangeListener
{
  ManagedBeanGeneralSection$3(ManagedBeanGeneralSection paramManagedBeanGeneralSection) {}
  
  public void dialogFieldChanged(DialogField field)
  {
    String newValue = ((ComboDialogField)field).getText();
    Command cmd = null;
    ManagedBeanType managedBean = (ManagedBeanType)this$0.getInput();
    
    ManagedBeanScopeType newManagedBeanScope = FacesConfigFactory.eINSTANCE
      .createManagedBeanScopeType();
    newManagedBeanScope.setTextContent(newValue);
    cmd = SetCommand.create(this$0.getEditingDomain(), 
      managedBean, FacesConfigPackage.eINSTANCE
      .getManagedBeanType_ManagedBeanScope(), 
      newManagedBeanScope);
    if (cmd.canExecute()) {
      this$0.getEditingDomain().getCommandStack().execute(cmd);
    }
  }
}

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

class ManagedBeanGeneralSection$ManagedBeanGeneralSectionAdapter$1
  implements Runnable
{
  ManagedBeanGeneralSection$ManagedBeanGeneralSectionAdapter$1(ManagedBeanGeneralSection.ManagedBeanGeneralSectionAdapter paramManagedBeanGeneralSectionAdapter) {}
  
  public void run()
  {
    ManagedBeanGeneralSection.ManagedBeanGeneralSectionAdapter.access$0(this$1).refresh();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.ManagedBeanGeneralSection.ManagedBeanGeneralSectionAdapter.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.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

class ManagedBeanGeneralSection$ManagedBeanGeneralSectionAdapter
  extends AdapterImpl
{
  ManagedBeanGeneralSection$ManagedBeanGeneralSectionAdapter(ManagedBeanGeneralSection paramManagedBeanGeneralSection) {}
  
  public boolean isAdapterForType(Object type)
  {
    if (type == ManagedBeanGeneralSection.class) {
      return true;
    }
    return false;
  }
  
  public void notifyChanged(Notification msg)
  {
    if (((msg.getEventType() == 3) || 
      (msg.getEventType() == 4) || 
      (msg.getEventType() == 1)) && (
      (msg.getFeature() == FacesConfigPackage.eINSTANCE
      .getManagedBeanType_ManagedBeanName()) || 
      (msg.getFeature() == FacesConfigPackage.eINSTANCE
      .getManagedBeanType_ManagedBeanClass()) || 
      (msg.getFeature() == FacesConfigPackage.eINSTANCE
      .getManagedBeanType_ManagedBeanScope()))) {
      if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) {
        this$0.refresh();
      } else {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
        {
          public void run()
          {
            this$0.refresh();
          }
        });
      }
    }
  }
}

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

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.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ComboDialogField;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldChangeListener;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanClassType;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanNameType;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanScopeType;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType;
import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages;
import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
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 ManagedBeanGeneralSection
  extends AbstractFacesConfigSection
{
  private StringDialogField mbNameField;
  private ClassButtonDialogField mbClassField;
  private ComboDialogField mbScopeField;
  private ManagedBeanGeneralSectionAdapter managedBeanGeneralSectionAdapter;
  
  public ManagedBeanGeneralSection(Composite parent, IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit)
  {
    super(parent, managedForm, page, toolkit, null, null);
    getSection().setText(
      EditorMessages.ManagedBeanGeneralSection_Name);
    getSection().setDescription(
      EditorMessages.ManagedBeanGeneralSection_Desc);
  }
  
  protected void createContents(Composite container, FormToolkit toolkit)
  {
    int numberOfColumns = 4;
    GridLayout layout = new GridLayout(numberOfColumns, false);
    container.setLayout(layout);
    
    toolkit.paintBordersFor(container);
    
    createMBNameEntry(container, toolkit, numberOfColumns);
    
    createMBClassEntry(container, toolkit, numberOfColumns);
    
    createMBScopeEntry(container, toolkit, numberOfColumns);
  }
  
  private void createMBNameEntry(Composite container, FormToolkit toolkit, int numberOfColumns)
  {
    mbNameField = new StringDialogField();
    mbNameField
      .setLabelText(EditorMessages.ManagedBeanGeneralSection_ManagedBeanName);
    mbNameField.doFillIntoGrid(toolkit, container, numberOfColumns);
    LayoutUtil.setHorizontalGrabbing(mbNameField.getTextControl(toolkit, 
      container));
    mbNameField
      .setDialogFieldApplyListener(new IDialogFieldApplyListener()
      {
        public void dialogFieldApplied(DialogField field)
        {
          String mbNameValue = ((StringDialogField)field)
            .getText();
          Command cmd = null;
          ManagedBeanType managedBean = (ManagedBeanType)getInput();
          
          ManagedBeanNameType newManagedBeanName = FacesConfigFactory.eINSTANCE
            .createManagedBeanNameType();
          newManagedBeanName.setTextContent(mbNameValue);
          cmd = SetCommand.create(getEditingDomain(), 
            managedBean, FacesConfigPackage.eINSTANCE
            .getManagedBeanType_ManagedBeanName(), 
            newManagedBeanName);
          if (cmd.canExecute()) {
            getEditingDomain().getCommandStack().execute(cmd);
          }
        }
      });
  }
  
  private void createMBClassEntry(Composite container, FormToolkit toolkit, int numberOfColumns)
  {
    mbClassField = new ClassButtonDialogField(null);
    mbClassField
      .setLabelText(EditorMessages.ManagedBeanGeneralSection_ManagedBeanClass);
    mbClassField.setProject((IProject)getPage().getEditor().getAdapter(
      IProject.class));
    mbClassField.doFillIntoGrid(toolkit, container, numberOfColumns);
    LayoutUtil.setHorizontalGrabbing(mbClassField.getTextControl(toolkit, 
      container));
    
    mbClassField
      .setDialogFieldApplyListener(new IDialogFieldApplyListener()
      {
        public void dialogFieldApplied(DialogField field)
        {
          String newValue = ((StringDialogField)field).getText();
          Command cmd = null;
          ManagedBeanType managedBean = (ManagedBeanType)getInput();
          
          ManagedBeanClassType newManagedBeanClass = FacesConfigFactory.eINSTANCE
            .createManagedBeanClassType();
          newManagedBeanClass.setTextContent(newValue);
          cmd = SetCommand.create(getEditingDomain(), 
            managedBean, FacesConfigPackage.eINSTANCE
            .getManagedBeanType_ManagedBeanClass(), 
            newManagedBeanClass);
          if (cmd.canExecute()) {
            getEditingDomain().getCommandStack().execute(cmd);
          }
        }
      });
  }
  
  private void createMBScopeEntry(Composite container, FormToolkit toolkit, int numberOfColumns)
  {
    mbScopeField = new ComboDialogField(2060);
    mbScopeField
      .setLabelText(EditorMessages.ManagedBeanGeneralSection_ManagedBeanScope);
    mbScopeField.doFillIntoGrid(toolkit, container, numberOfColumns);
    LayoutUtil.setHorizontalGrabbing(mbScopeField.getComboControl(toolkit, 
      container));
    
    mbScopeField.setItems(ManagedBeanScopeTreeItem.scopeItems);
    
    mbScopeField
      .setDialogFieldChangeListener(new IDialogFieldChangeListener()
      {
        public void dialogFieldChanged(DialogField field)
        {
          String newValue = ((ComboDialogField)field).getText();
          Command cmd = null;
          ManagedBeanType managedBean = (ManagedBeanType)getInput();
          
          ManagedBeanScopeType newManagedBeanScope = FacesConfigFactory.eINSTANCE
            .createManagedBeanScopeType();
          newManagedBeanScope.setTextContent(newValue);
          cmd = SetCommand.create(getEditingDomain(), 
            managedBean, FacesConfigPackage.eINSTANCE
            .getManagedBeanType_ManagedBeanScope(), 
            newManagedBeanScope);
          if (cmd.canExecute()) {
            getEditingDomain().getCommandStack().execute(cmd);
          }
        }
      });
  }
  
  public void refreshAll()
  {
    refresh();
  }
  
  public void refresh()
  {
    super.refresh();
    Object input = getInput();
    if ((input instanceof ManagedBeanType))
    {
      ManagedBeanType component = (ManagedBeanType)input;
      refreshControls(component);
    }
  }
  
  private void refreshControls(ManagedBeanType component)
  {
    if (component.getManagedBeanName() != null) {
      mbNameField.setTextWithoutUpdate(component.getManagedBeanName()
        .getTextContent());
    } else {
      mbNameField.setTextWithoutUpdate("");
    }
    if (component.getManagedBeanClass() != null) {
      mbClassField.setTextWithoutUpdate(component
        .getManagedBeanClass().getTextContent());
    } else {
      mbClassField.setTextWithoutUpdate("");
    }
    if (component.getManagedBeanScope() != null) {
      mbScopeField.setTextWithoutUpdate(component
        .getManagedBeanScope().getTextContent());
    } else {
      mbScopeField.setTextWithoutUpdate("session");
    }
  }
  
  protected void addAdaptersOntoInput(Object newInput)
  {
    super.addAdaptersOntoInput(newInput);
    ManagedBeanType managedBean = (ManagedBeanType)newInput;
    if (EcoreUtil.getExistingAdapter(managedBean, 
      ManagedBeanGeneralSection.class) == null) {
      managedBean.eAdapters().add(getManagedBeanGeneralSectionAdatper());
    }
  }
  
  protected void removeAdaptersFromInput(Object oldInput)
  {
    super.removeAdaptersFromInput(oldInput);
    ManagedBeanType managedBean = (ManagedBeanType)oldInput;
    if (EcoreUtil.getExistingAdapter(managedBean, 
      ManagedBeanGeneralSection.class) != null) {
      managedBean.eAdapters().remove(
        getManagedBeanGeneralSectionAdatper());
    }
  }
  
  private ManagedBeanGeneralSectionAdapter getManagedBeanGeneralSectionAdatper()
  {
    if (managedBeanGeneralSectionAdapter == null) {
      managedBeanGeneralSectionAdapter = new ManagedBeanGeneralSectionAdapter();
    }
    return managedBeanGeneralSectionAdapter;
  }
  
  class ManagedBeanGeneralSectionAdapter
    extends AdapterImpl
  {
    ManagedBeanGeneralSectionAdapter() {}
    
    public boolean isAdapterForType(Object type)
    {
      if (type == ManagedBeanGeneralSection.class) {
        return true;
      }
      return false;
    }
    
    public void notifyChanged(Notification msg)
    {
      if (((msg.getEventType() == 3) || 
        (msg.getEventType() == 4) || 
        (msg.getEventType() == 1)) && (
        (msg.getFeature() == FacesConfigPackage.eINSTANCE
        .getManagedBeanType_ManagedBeanName()) || 
        (msg.getFeature() == FacesConfigPackage.eINSTANCE
        .getManagedBeanType_ManagedBeanClass()) || 
        (msg.getFeature() == FacesConfigPackage.eINSTANCE
        .getManagedBeanType_ManagedBeanScope()))) {
        if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) {
          refresh();
        } else {
          PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
          {
            public void run()
            {
              refresh();
            }
          });
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.ManagedBeanGeneralSection
 * 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.EObject;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;

class ManagedBeanMasterSection$ManagedBeanMasterSectionAdapter$1
  implements Runnable
{
  ManagedBeanMasterSection$ManagedBeanMasterSectionAdapter$1(ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter paramManagedBeanMasterSectionAdapter, EObject paramEObject) {}
  
  public void run()
  {
    ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter.access$0(this$1).getStructuredViewer().refresh(true);
    IStructuredSelection selection = new StructuredSelection(
      val$mbean);
    ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter.access$0(this$1).getStructuredViewer().setSelection(selection);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter.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.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.viewers.StructuredViewer;

class ManagedBeanMasterSection$ManagedBeanMasterSectionAdapter$2
  implements Runnable
{
  ManagedBeanMasterSection$ManagedBeanMasterSectionAdapter$2(ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter paramManagedBeanMasterSectionAdapter, EObject paramEObject) {}
  
  public void run()
  {
    ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter.access$0(this$1).getStructuredViewer().refresh(true);
    if (EcoreUtil.getExistingAdapter(val$mbean, 
      ManagedBeanMasterSection.class) == null) {
      val$mbean.eAdapters().remove(
        ManagedBeanMasterSection.access$0(ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter.access$0(this$1)));
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter.2
 * 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.StructuredViewer;

class ManagedBeanMasterSection$ManagedBeanMasterSectionAdapter$3
  implements Runnable
{
  ManagedBeanMasterSection$ManagedBeanMasterSectionAdapter$3(ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter paramManagedBeanMasterSectionAdapter, Object paramObject) {}
  
  public void run()
  {
    ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter.access$0(this$1).getStructuredViewer().refresh(val$mbean, true);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter.3
 * 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.StructuredViewer;

class ManagedBeanMasterSection$ManagedBeanMasterSectionAdapter$4
  implements Runnable
{
  ManagedBeanMasterSection$ManagedBeanMasterSectionAdapter$4(ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter paramManagedBeanMasterSectionAdapter, Object paramObject) {}
  
  public void run()
  {
    ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter.access$0(this$1).getStructuredViewer().refresh(val$bean, true);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter.4
 * 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.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;

class ManagedBeanMasterSection$ManagedBeanMasterSectionAdapter$5
  implements Runnable
{
  ManagedBeanMasterSection$ManagedBeanMasterSectionAdapter$5(ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter paramManagedBeanMasterSectionAdapter, Object paramObject) {}
  
  public void run()
  {
    ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter.access$0(this$1).getStructuredViewer().refresh();
    IStructuredSelection selection = new StructuredSelection(
      val$mbean);
    ManagedBeanMasterSection.ManagedBeanMasterSectionAdapter.access$0(this$1).getStructuredViewer().setSelection(selection);
  }
}

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

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

class ManagedBeanMasterSection$ManagedBeanMasterSectionAdapter
  extends AdapterImpl
{
  ManagedBeanMasterSection$ManagedBeanMasterSectionAdapter(ManagedBeanMasterSection paramManagedBeanMasterSection) {}
  
  public boolean isAdapterForType(Object type)
  {
    if (type == ManagedBeanMasterSection.class) {
      return true;
    }
    return false;
  }
  
  public void notifyChanged(Notification msg)
  {
    super.notifyChanged(msg);
    if (msg.getFeature() == FacesConfigPackage.eINSTANCE
      .getFacesConfigType_ManagedBean())
    {
      if (msg.getEventType() == 3)
      {
        final EObject mbean = (EObject)msg.getNewValue();
        if (EcoreUtil.getExistingAdapter(mbean, 
          ManagedBeanMasterSection.class) == null) {
          mbean.eAdapters().add(
            ManagedBeanMasterSection.access$0(this$0));
        }
        if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread())
        {
          this$0.getStructuredViewer().refresh(true);
          IStructuredSelection selection = new StructuredSelection(
            mbean);
          this$0.getStructuredViewer().setSelection(selection);
        }
        else
        {
          PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
          {
            public void run()
            {
              this$0.getStructuredViewer().refresh(true);
              IStructuredSelection selection = new StructuredSelection(
                mbean);
              this$0.getStructuredViewer().setSelection(selection);
            }
          });
        }
      }
      else if (msg.getEventType() == 4)
      {
        final EObject mbean = (EObject)msg.getOldValue();
        if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread())
        {
          this$0.getStructuredViewer().refresh(true);
          if (EcoreUtil.getExistingAdapter(mbean, 
            ManagedBeanMasterSection.class) == null) {
            mbean.eAdapters().remove(
              ManagedBeanMasterSection.access$0(this$0));
          }
        }
        else
        {
          PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
          {
            public void run()
            {
              this$0.getStructuredViewer().refresh(true);
              if (EcoreUtil.getExistingAdapter(mbean, 
                ManagedBeanMasterSection.class) == null) {
                mbean.eAdapters().remove(
                  ManagedBeanMasterSection.access$0(this$0));
              }
            }
          });
        }
      }
      else if (msg.getEventType() == 1)
      {
        final Object mbean = msg.getNewValue();
        if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) {
          this$0.getStructuredViewer().refresh(mbean, true);
        } else {
          PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
          {
            public void run()
            {
              this$0.getStructuredViewer().refresh(mbean, true);
            }
          });
        }
      }
      if ((msg.getFeature() == FacesConfigPackage.eINSTANCE
        .getManagedBeanType_ManagedBeanClass()) || 
        (msg.getFeature() == FacesConfigPackage.eINSTANCE
        .getManagedBeanType_ManagedBeanName()))
      {
        final Object bean = msg.getNotifier();
        if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) {
          this$0.getStructuredViewer().refresh(bean, true);
        } else {
          PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
          {
            public void run()
            {
              this$0.getStructuredViewer().refresh(bean, true);
            }
          });
        }
      }
      else if (msg.getFeature() == FacesConfigPackage.eINSTANCE
        .getManagedBeanType_ManagedBeanScope())
      {
        final Object mbean = msg.getNotifier();
        if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread())
        {
          this$0.getStructuredViewer().refresh();
          IStructuredSelection selection = new StructuredSelection(
            mbean);
          this$0.getStructuredViewer().setSelection(selection);
        }
        else
        {
          PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
          {
            public void run()
            {
              this$0.getStructuredViewer().refresh();
              IStructuredSelection selection = new StructuredSelection(
                mbean);
              this$0.getStructuredViewer().setSelection(selection);
            }
          });
        }
      }
    }
  }
}

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

import java.util.Iterator;
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.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType;
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.emf.ManagedBeanClassType;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanNameType;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanScopeType;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType;
import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.jst.jsf.facesconfig.ui.page.FacesConfigMasterDetailPage;
import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage;
import org.eclipse.jst.jsf.facesconfig.ui.provider.ManagedBeanContentProvider;
import org.eclipse.jst.jsf.facesconfig.ui.provider.ManagedBeanLabelProvider;
import org.eclipse.jst.jsf.facesconfig.ui.wizard.NewManagedBeanWizard;
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.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
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 ManagedBeanMasterSection
  extends FacesConfigMasterSection
{
  private ManagedBeanMasterSectionAdapter managedBeanMasterSectionAdapter;
  
  public ManagedBeanMasterSection(Composite parent, IManagedForm managedForm, FormToolkit toolkit, FacesConfigMasterDetailPage page)
  {
    super(parent, managedForm, toolkit, page, null, null);
    getSection().setText(EditorMessages.ManagedBeanMasterSection_Name);
    getSection().setDescription(
      EditorMessages.ManagedBeanMasterSection_Description);
  }
  
  protected StructuredViewer createViewer(Composite parent, FormToolkit toolkit)
  {
    Composite treeContainer = toolkit.createComposite(parent);
    toolkit.paintBordersFor(treeContainer);
    
    GridData gd = new GridData(1808);
    treeContainer.setLayoutData(gd);
    GridLayout layout = new GridLayout();
    treeContainer.setLayout(layout);
    
    TreeViewer treeViewer = new TreeViewer(treeContainer, 2820);
    
    gd = new GridData(1808);
    treeViewer.getControl().setLayoutData(gd);
    
    treeViewer.setContentProvider(new ManagedBeanContentProvider());
    treeViewer.setLabelProvider(new ManagedBeanLabelProvider());
    treeViewer.addSelectionChangedListener(this);
    
    treeViewer.setAutoExpandLevel(3);
    return treeViewer;
  }
  
  protected void addButtonSelected(SelectionEvent e)
  {
    IProject project = (IProject)getPage().getEditor().getAdapter(
      IProject.class);
    
    NewManagedBeanWizard wizard = new NewManagedBeanWizard(project);
    IStructuredSelection selection = (IStructuredSelection)
      getSelection();
    if ((selection.getFirstElement() instanceof ManagedBeanScopeTreeItem))
    {
      ManagedBeanScopeTreeItem scopeTreeItem = (ManagedBeanScopeTreeItem)selection
        .getFirstElement();
      wizard.setDefaultScope(scopeTreeItem.getScope());
    }
    wizard.setForcePreviousAndNextButtons(true);
    
    Shell shell = EditorPlugin.getActiveShell();
    WizardDialog wizardDialog = new WizardDialog(shell, wizard);
    wizardDialog.create();
    wizardDialog.setBlockOnOpen(true);
    if (wizardDialog.open() == 0)
    {
      ManagedBeanType managedBean = FacesConfigFactory.eINSTANCE
        .createManagedBeanType();
      
      ManagedBeanNameType name = FacesConfigFactory.eINSTANCE
        .createManagedBeanNameType();
      name.setTextContent(wizard.getManagedBeanName());
      managedBean.setManagedBeanName(name);
      
      ManagedBeanClassType clazz = FacesConfigFactory.eINSTANCE
        .createManagedBeanClassType();
      clazz.setTextContent(wizard.getManagedBeanClass());
      managedBean.setManagedBeanClass(clazz);
      
      ManagedBeanScopeType scope = FacesConfigFactory.eINSTANCE
        .createManagedBeanScopeType();
      scope.setTextContent(wizard.getManagedBeanScope());
      managedBean.setManagedBeanScope(scope);
      
      String desc = wizard.getManagedBeanDescription();
      if ((desc != null) && (desc.trim().length() > 0))
      {
        DescriptionType description = FacesConfigFactory.eINSTANCE
          .createDescriptionType();
        description.setTextContent(wizard.getManagedBeanDescription());
        managedBean.getDescription().add(description);
      }
      Command cmd = AddCommand.create(getEditingDomain(), getInput(), 
        null, managedBean);
      if (cmd.canExecute()) {
        getEditingDomain().getCommandStack().execute(cmd);
      }
    }
  }
  
  protected void removeButtonSelected(SelectionEvent e)
  {
    IStructuredSelection ssel = StructuredSelection.EMPTY;
    ISelection selection = getSelection();
    if ((selection instanceof IStructuredSelection)) {
      ssel = (IStructuredSelection)selection;
    }
    if ((!ssel.isEmpty()) && 
      ((ssel.getFirstElement() instanceof ManagedBeanType)))
    {
      ManagedBeanType element = (ManagedBeanType)ssel
        .getFirstElement();
      Command command = RemoveCommand.create(getEditingDomain(), 
        getInput(), FacesConfigPackage.eINSTANCE
        .getFacesConfigType_ManagedBean(), element);
      if (command.canExecute()) {
        getEditingDomain().getCommandStack().execute(command);
      }
    }
  }
  
  protected void updateButtons()
  {
    IStructuredSelection ssel = (IStructuredSelection)getStructuredViewer()
      .getSelection();
    boolean isRemoveEnable = false;
    if (!ssel.isEmpty())
    {
      Object s1 = ssel.getFirstElement();
      if ((s1 instanceof ManagedBeanType)) {
        isRemoveEnable = true;
      }
    }
    getRemoveButton().setEnabled(isRemoveEnable);
  }
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    if ((event != null) && 
      (event.getSelection() != null) && 
      ((((IStructuredSelection)event.getSelection())
      .getFirstElement() instanceof ManagedBeanScopeTreeItem))) {
      event = new SelectionChangedEvent(this, StructuredSelection.EMPTY);
    }
    super.selectionChanged(event);
    updateButtons();
  }
  
  protected void addAdaptersOntoInput(Object newInput)
  {
    super.addAdaptersOntoInput(newInput);
    
    FacesConfigType facesConfig = (FacesConfigType)newInput;
    if (EcoreUtil.getExistingAdapter(facesConfig, 
      ManagedBeanMasterSection.class) == null) {
      facesConfig.eAdapters().add(getManagedBeanMasterSectionAdapter());
    }
    List managedbeans = facesConfig.getManagedBean();
    for (Iterator it = managedbeans.iterator(); it.hasNext();)
    {
      ManagedBeanType managedbean = (ManagedBeanType)it.next();
      if (EcoreUtil.getExistingAdapter(managedbean, 
        ManagedBeanMasterSection.class) == null) {
        managedbean.eAdapters().add(
          getManagedBeanMasterSectionAdapter());
      }
    }
  }
  
  protected void removeAdaptersFromInput(Object oldInput)
  {
    FacesConfigType facesConfig = (FacesConfigType)oldInput;
    if (EcoreUtil.getExistingAdapter(facesConfig, 
      ManagedBeanMasterSection.class) != null) {
      facesConfig.eAdapters().remove(getManagedBeanMasterSectionAdapter());
    }
    List managedbeans = facesConfig.getManagedBean();
    for (Iterator it = managedbeans.iterator(); it.hasNext();)
    {
      ManagedBeanType managedbean = (ManagedBeanType)it.next();
      if (EcoreUtil.getExistingAdapter(managedbean, 
        ManagedBeanMasterSection.class) != null) {
        managedbean.eAdapters().remove(
          getManagedBeanMasterSectionAdapter());
      }
    }
    super.removeAdaptersFromInput(oldInput);
  }
  
  private ManagedBeanMasterSectionAdapter getManagedBeanMasterSectionAdapter()
  {
    if (managedBeanMasterSectionAdapter == null) {
      managedBeanMasterSectionAdapter = new ManagedBeanMasterSectionAdapter();
    }
    return managedBeanMasterSectionAdapter;
  }
  
  class ManagedBeanMasterSectionAdapter
    extends AdapterImpl
  {
    ManagedBeanMasterSectionAdapter() {}
    
    public boolean isAdapterForType(Object type)
    {
      if (type == ManagedBeanMasterSection.class) {
        return true;
      }
      return false;
    }
    
    public void notifyChanged(Notification msg)
    {
      super.notifyChanged(msg);
      if (msg.getFeature() == FacesConfigPackage.eINSTANCE
        .getFacesConfigType_ManagedBean())
      {
        if (msg.getEventType() == 3)
        {
          final EObject mbean = (EObject)msg.getNewValue();
          if (EcoreUtil.getExistingAdapter(mbean, 
            ManagedBeanMasterSection.class) == null) {
            mbean.eAdapters().add(
              ManagedBeanMasterSection.this.getManagedBeanMasterSectionAdapter());
          }
          if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread())
          {
            getStructuredViewer().refresh(true);
            IStructuredSelection selection = new StructuredSelection(
              mbean);
            getStructuredViewer().setSelection(selection);
          }
          else
          {
            PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
            {
              public void run()
              {
                getStructuredViewer().refresh(true);
                IStructuredSelection selection = new StructuredSelection(
                  mbean);
                getStructuredViewer().setSelection(selection);
              }
            });
          }
        }
        else if (msg.getEventType() == 4)
        {
          final EObject mbean = (EObject)msg.getOldValue();
          if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread())
          {
            getStructuredViewer().refresh(true);
            if (EcoreUtil.getExistingAdapter(mbean, 
              ManagedBeanMasterSection.class) == null) {
              mbean.eAdapters().remove(
                ManagedBeanMasterSection.this.getManagedBeanMasterSectionAdapter());
            }
          }
          else
          {
            PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
            {
              public void run()
              {
                getStructuredViewer().refresh(true);
                if (EcoreUtil.getExistingAdapter(mbean, 
                  ManagedBeanMasterSection.class) == null) {
                  mbean.eAdapters().remove(
                    ManagedBeanMasterSection.this.getManagedBeanMasterSectionAdapter());
                }
              }
            });
          }
        }
        else if (msg.getEventType() == 1)
        {
          final Object mbean = msg.getNewValue();
          if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) {
            getStructuredViewer().refresh(mbean, true);
          } else {
            PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
            {
              public void run()
              {
                getStructuredViewer().refresh(mbean, true);
              }
            });
          }
        }
        if ((msg.getFeature() == FacesConfigPackage.eINSTANCE
          .getManagedBeanType_ManagedBeanClass()) || 
          (msg.getFeature() == FacesConfigPackage.eINSTANCE
          .getManagedBeanType_ManagedBeanName()))
        {
          final Object bean = msg.getNotifier();
          if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) {
            getStructuredViewer().refresh(bean, true);
          } else {
            PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
            {
              public void run()
              {
                getStructuredViewer().refresh(bean, true);
              }
            });
          }
        }
        else if (msg.getFeature() == FacesConfigPackage.eINSTANCE
          .getManagedBeanType_ManagedBeanScope())
        {
          final Object mbean = msg.getNotifier();
          if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread())
          {
            getStructuredViewer().refresh();
            IStructuredSelection selection = new StructuredSelection(
              mbean);
            getStructuredViewer().setSelection(selection);
          }
          else
          {
            PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
            {
              public void run()
              {
                getStructuredViewer().refresh();
                IStructuredSelection selection = new StructuredSelection(
                  mbean);
                getStructuredViewer().setSelection(selection);
              }
            });
          }
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.ManagedBeanMasterSection
 * 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.jst.jsf.facesconfig.emf.FacesConfigType;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanScopeType;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType;

public class ManagedBeanScopeTreeItem
{
  public static final String[] scopeItems = {
    "session", 
    "request", 
    "application", 
    "none" };
  private String scope;
  private FacesConfigType facesConfig;
  
  public ManagedBeanScopeTreeItem(String managedBeanScope, FacesConfigType facesConfig)
  {
    scope = managedBeanScope;
    
    this.facesConfig = facesConfig;
  }
  
  public Object getParent()
  {
    return facesConfig;
  }
  
  public boolean hasChildren()
  {
    return !getChildren().isEmpty();
  }
  
  public String getScope()
  {
    return scope;
  }
  
  public List getChildren()
  {
    List result = new ArrayList();
    List managedBeans = facesConfig.getManagedBean();
    for (Iterator it = managedBeans.iterator(); it.hasNext();)
    {
      ManagedBeanType managedBean = (ManagedBeanType)it.next();
      if ((managedBean.getManagedBeanScope() != null) && 
        (scope.equals(managedBean.getManagedBeanScope()
        .getTextContent()))) {
        result.add(managedBean);
      }
    }
    return result;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.ManagedBeanScopeTreeItem
 * 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 ManagedPropertyEditGro
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