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

ghtData;
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.DescriptionType;
import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
import org.eclipse.jst.jsf.facesconfig.emf.FacetNameType;
import org.eclipse.jst.jsf.facesconfig.emf.FacetType;
import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.jst.jsf.facesconfig.ui.dialog.AddEditFacetDialog;
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.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;

public class FacetSection
  extends AbstractFacesConfigSection
{
  private static final int TABLE_DEFAULT_HEIGHT = 160;
  private TableViewer tableViewer;
  private Button removeButton;
  private Button editButton;
  
  public FacetSection(Composite parent, IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit)
  {
    super(parent, managedForm, page, toolkit, null, null);
    getSection().setText(EditorMessages.FacetSection_Name);
    getSection().setDescription(
      EditorMessages.FacetSection_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 facetSection = toolkit.createComposite(container);
    GridLayout gl2 = new GridLayout();
    horizontalSpacing = 0;
    marginWidth = 0;
    numColumns = 2;
    facetSection.setLayout(gl2);
    GridData gd = new GridData(1810);
    
    facetSection.setLayoutData(gd);
    
    createTableSection(facetSection, toolkit);
    createButtonsSection(facetSection, 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 facetNameCol = new TableColumn(table, 0);
    layout.addColumnData(new ColumnWeightData(1, true));
    facetNameCol
      .setText(EditorMessages.FacetSection_Table_FacetNameColumn);
    TableColumn displayNameCol = new TableColumn(table, 0);
    layout.addColumnData(new ColumnWeightData(1, true));
    displayNameCol
      .setText(EditorMessages.FacetSection_Table_DisplayNameColumn);
    
    TableColumn descriptionCol = new TableColumn(table, 0);
    layout.addColumnData(new ColumnWeightData(1, true));
    descriptionCol
      .setText(EditorMessages.FacetSection_Table_DescriptionColumn);
    
    table.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        FacetSection.this.updateButtons();
      }
    });
    table.addMouseListener(new MouseAdapter()
    {
      public void mouseDoubleClick(MouseEvent e)
      {
        if (((IStructuredSelection)tableViewer.getSelection()).size() > 0) {
          FacetSection.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.getFacetType().isInstance(
          element);
      }
    });
    tableViewer.addSelectionChangedListener(this);
  }
  
  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)
      {
        FacetSection.this.addButtonSelected();
      }
    });
    editButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        FacetSection.this.editButtonSelected();
      }
    });
    removeButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        FacetSection.this.removeButtonSelected();
      }
    });
  }
  
  public void refresh()
  {
    super.refresh();
    tableViewer.refresh();
    updateButtons();
  }
  
  public void refreshAll()
  {
    tableViewer.setInput(getInput());
    updateButtons();
  }
  
  private void updateButtons()
  {
    if (((IStructuredSelection)tableViewer.getSelection()).size() > 0)
    {
      editButton.setEnabled(true);
      removeButton.setEnabled(true);
    }
    else
    {
      editButton.setEnabled(false);
      removeButton.setEnabled(false);
    }
  }
  
  private void addButtonSelected()
  {
    Shell shell = EditorPlugin.getActiveShell();
    
    AddEditFacetDialog dialog = new AddEditFacetDialog(shell, true);
    if (dialog.open() == 0)
    {
      String newFacetName = dialog.getFacetName();
      String newDisplayName = dialog.getDisplayName();
      String newDescription = dialog.getDescription();
      
      FacetType newFacet = FacesConfigFactory.eINSTANCE.createFacetType();
      if (newFacetName.length() > 0)
      {
        FacetNameType facetNameType = FacesConfigFactory.eINSTANCE
          .createFacetNameType();
        facetNameType.setTextContent(newFacetName);
        newFacet.setFacetName(facetNameType);
      }
      if (newDisplayName.length() > 0)
      {
        DisplayNameType displayNameType = FacesConfigFactory.eINSTANCE
          .createDisplayNameType();
        displayNameType.setTextContent(newDisplayName);
        newFacet.getDisplayName().add(displayNameType);
      }
      if (newDescription.length() > 0)
      {
        DescriptionType descriptionType = FacesConfigFactory.eINSTANCE
          .createDescriptionType();
        descriptionType.setTextContent(newDescription);
        newFacet.getDescription().add(descriptionType);
      }
      Command addCommand = AddCommand.create(getEditingDomain(), 
        getInput(), FacesConfigPackage.eINSTANCE
        .getComponentType_Facet(), newFacet);
      if (addCommand.canExecute()) {
        getEditingDomain().getCommandStack().execute(addCommand);
      }
    }
  }
  
  private void editButtonSelected()
  {
    FacetType facet = (FacetType)((IStructuredSelection)tableViewer
      .getSelection()).getFirstElement();
    
    Assert.isNotNull(facet);
    
    Shell shell = EditorPlugin.getActiveShell();
    
    AddEditFacetDialog dialog = new AddEditFacetDialog(shell, false);
    if (facet.getFacetName() != null) {
      dialog.setFacetName(facet.getFacetName().getTextContent());
    }
    if (facet.getDisplayName().size() > 0) {
      dialog.setDisplayName(
        ((DisplayNameType)facet.getDisplayName().get(0)).getTextContent());
    }
    if (facet.getDescription().size() > 0) {
      dialog.setDescription(
        ((DescriptionType)facet.getDescription().get(0)).getTextContent());
    }
    if (dialog.open() == 0)
    {
      List commands = new ArrayList(3);
      
      String newFacetName = dialog.getFacetName();
      String newDisplayName = dialog.getDisplayName();
      String newDescription = dialog.getDescription();
      if (facet.getFacetName() != null)
      {
        Command cmd1 = SetCommand.create(getEditingDomain(), facet
          .getFacetName(), FacesConfigPackage.eINSTANCE
          .getFacetNameType_TextContent(), newFacetName);
        commands.add(cmd1);
      }
      else if (newFacetName.length() > 0)
      {
        FacetNameType newFacetNameType = FacesConfigFactory.eINSTANCE
          .createFacetNameType();
        newFacetNameType.setTextContent(newFacetName);
        Command cmd2 = AddCommand.create(getEditingDomain(), facet, 
          FacesConfigPackage.eINSTANCE.getFacetType_FacetName(), 
          newFacetNameType);
        commands.add(cmd2);
      }
      if (facet.getDisplayName().size() > 0)
      {
        DisplayNameType displayNameType = 
          (DisplayNameType)facet.getDisplayName().get(0);
        Command cmd3 = SetCommand.create(getEditingDomain(), 
          displayNameType, FacesConfigPackage.eINSTANCE
          .getDisplayNameType_TextContent(), 
          newDisplayName);
        commands.add(cmd3);
      }
      else if (newDisplayName.length() > 0)
      {
        DisplayNameType newDisplayNameType = FacesConfigFactory.eINSTANCE
          .createDisplayNameType();
        newDisplayNameType.setTextContent(newDisplayName);
        Command cmd4 = 
          AddCommand.create(getEditingDomain(), facet, 
          FacesConfigPackage.eINSTANCE
          .getFacetType_DisplayName(), 
          newDisplayNameType);
        commands.add(cmd4);
      }
      if (facet.getDescription().size() > 0)
      {
        DescriptionType descriptionType = 
          (DescriptionType)facet.getDescription().get(0);
        Command cmd5 = SetCommand.create(getEditingDomain(), 
          descriptionType, FacesConfigPackage.eINSTANCE
          .getDescriptionType_TextContent(), 
          newDescription);
        commands.add(cmd5);
      }
      else if (newDescription.length() > 0)
      {
        DescriptionType newDescriptionType = FacesConfigFactory.eINSTANCE
          .createDescriptionType();
        newDescriptionType.setTextContent(newDescription);
        Command cmd6 = 
          AddCommand.create(getEditingDomain(), facet, 
          FacesConfigPackage.eINSTANCE
          .getFacetType_Description(), 
          newDescriptionType);
        commands.add(cmd6);
      }
      CompoundCommand command = new CompoundCommand(commands);
      if (command.canExecute())
      {
        getEditingDomain().getCommandStack().execute(command);
        tableViewer.refresh(facet);
      }
    }
  }
  
  private void removeButtonSelected()
  {
    FacetType facet = (FacetType)((IStructuredSelection)tableViewer
      .getSelection()).getFirstElement();
    
    Assert.isNotNull(facet);
    Command removeCommand = RemoveCommand.create(getEditingDomain(), 
      getInput(), FacesConfigPackage.eINSTANCE
      .getComponentType_Facet(), facet);
    if (removeCommand.canExecute())
    {
      getEditingDomain().getCommandStack().execute(removeCommand);
      refreshAll();
    }
  }
  
  public ISelection getSelection()
  {
    return tableViewer.getSelection();
  }
  
  public void setSelection(ISelection selection)
  {
    tableViewer.setSelection(selection);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.FacetSection
 * 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 FactorySection$1
  extends ViewerFilter
{
  FactorySection$1(FactorySection paramFactorySection) {}
  
  public boolean select(Viewer viewer, Object parentElement, Object element)
  {
    return FactorySection.access$0(this$0).isInstance(element);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.FactorySection.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.FacesConfigFactory;
import org.eclipse.jst.jsf.facesconfig.emf.FactoryType;
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 FactorySection
  extends OthersPageBaseSection
{
  private EClass factoryChildClass;
  
  public FactorySection(EClass factoryChildClass, Composite parent, IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit, String helpContextId, String helpTooltip)
  {
    super(parent, managedForm, page, toolkit, helpContextId, helpTooltip);
    this.factoryChildClass = factoryChildClass;
  }
  
  public FactorySection(EClass factoryChildClass, Composite parent, IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit)
  {
    this(factoryChildClass, parent, managedForm, page, toolkit, null, null);
  }
  
  public EObject createFactoryChildObject()
  {
    String superType = ModelUtil.getSuperType(factoryChildClass);
    IProject project = (IProject)getPage().getEditor().getAdapter(
      IProject.class);
    String result = DialogUtil.openClassDialog(getSection().getShell(), 
      project, superType, 
      256);
    if (result != null)
    {
      EObject component = FacesConfigFactory.eINSTANCE
        .create(factoryChildClass);
      
      EStructuralFeature feature = 
        (EStructuralFeature)factoryChildClass.getEStructuralFeatures().get(0);
      component.eSet(feature, result);
      return component;
    }
    return null;
  }
  
  protected void setViewerInput(Object input)
  {
    if ((input instanceof FactoryType)) {
      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 factoryChildClass.isInstance(element);
      }
    });
  }
  
  void addButtonSelected(SelectionEvent e)
  {
    EObject obj = createFactoryChildObject();
    if (obj != null)
    {
      boolean needRefreshAll = false;
      Command command = null;
      if ((getInput() instanceof FactoryType))
      {
        FactoryType factory = (FactoryType)getInput();
        command = AddCommand.create(getEditingDomain(), factory, null, 
          obj);
      }
      else
      {
        needRefreshAll = true;
        List list = new ArrayList(2);
        FactoryType factory = FacesConfigFactory.eINSTANCE
          .createFactoryType();
        Command cmd1 = AddCommand.create(getEditingDomain(), factory, 
          null, obj);
        list.add(cmd1);
        Command cmd2 = AddCommand.create(getEditingDomain(), 
          getPage().getInput(), null, factory);
        list.add(cmd2);
        command = new CompoundCommand(list);
      }
      if (command.canExecute())
      {
        getEditingDomain().getCommandStack().execute(command);
        if (needRefreshAll) {
          ((OthersPage)getPage()).resetFactoryInput();
        }
      }
    }
  }
}

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

public abstract interface IDialogFieldGroup
{
  public abstract void setInput(Object paramObject);
  
  public abstract Object getInput();
}

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

public abstract interface IFacesConfigSection
{
  public abstract void setInput(Object paramObject);
  
  public abstract Object getInput();
  
  public abstract void initialize();
  
  public abstract void clearAll();
  
  public abstract void refresh();
  
  public abstract void refreshAll();
}

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

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.RadiosDialogField;

class InitializationSection$1
  implements IDialogFieldApplyListener
{
  InitializationSection$1(InitializationSection paramInitializationSection) {}
  
  public void dialogFieldApplied(DialogField field)
  {
    RadiosDialogField beanTypeField1 = (RadiosDialogField)field;
    
    boolean bChangedSuccess = false;
    if (beanTypeField1.getSelectedIndex() == 0) {
      bChangedSuccess = InitializationSection.access$0(this$0, 
        "managed-property", 
        false);
    } else if (beanTypeField1.getSelectedIndex() == 1) {
      bChangedSuccess = InitializationSection.access$0(this$0, 
        "map-entries", false);
    } else if (beanTypeField1.getSelectedIndex() == 2) {
      bChangedSuccess = InitializationSection.access$0(this$0, 
        "list-entries", false);
    }
    if (bChangedSuccess)
    {
      InitializationSection.access$1(this$0, beanTypeField1.getSelectedIndex());
    }
    else
    {
      beanTypeField1.setSelectedIndexWithoutUpdate(-1);
      beanTypeField1
        .setSelectedIndexWithoutUpdate(InitializationSection.access$2(this$0));
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.InitializationSection.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.command.Command;
import org.eclipse.emf.common.command.CommandStack;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
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.RadiosDialogField;
import org.eclipse.jst.jsf.common.ui.internal.guiutils.Alerts;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
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.IFacesConfigPage;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.part.PageBook;

public class InitializationSection
  extends AbstractFacesConfigSection
{
  private static final String MANAGEDBEAN_GENERAL_CLASS = EditorMessages.InitializationSection_ClassType_General;
  private static final String MANAGEDBEAN_MAP = EditorMessages.InitializationSection_ClassType_Map;
  private static final String MANAGEDBEAN_LIST = EditorMessages.InitializationSection_ClassType_List;
  private Composite propertySection;
  private ManagedPropertyEditGroup managedPropertyGroup;
  private Composite mapSection;
  private MapEntriesEditGroup mapEntryGroup;
  private Composite listSection;
  private ListEntriesEditGroup listEntryGroup;
  private PageBook pageBook;
  private RadiosDialogField beanTypeField;
  private int currentPageIndex = 0;
  
  public InitializationSection(Composite parent, IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit)
  {
    super(parent, managedForm, page, toolkit, null, null);
    getSection().setText(EditorMessages.InitializationSection_Name);
    getSection().setDescription(
      EditorMessages.InitializationSection_Description);
  }
  
  protected void createContents(Composite container, FormToolkit toolkit)
  {
    int numberOfColumns = 3;
    GridLayout gl = new GridLayout(numberOfColumns, false);
    horizontalSpacing = 0;
    marginWidth = 0;
    container.setLayout(gl);
    toolkit.paintBordersFor(container);
    
    createBeanTypeEntry(container, toolkit, numberOfColumns);
    createInitializationEntry(container, toolkit, numberOfColumns);
  }
  
  private void createBeanTypeEntry(Composite container, FormToolkit toolkit, int numberOfColumns)
  {
    beanTypeField = new RadiosDialogField();
    String[] items = { MANAGEDBEAN_GENERAL_CLASS, MANAGEDBEAN_MAP, 
      MANAGEDBEAN_LIST };
    beanTypeField
      .setLabelText(EditorMessages.InitializationSection_ClassType);
    beanTypeField.setItems(items);
    beanTypeField.doFillIntoGrid(toolkit, container, numberOfColumns);
    beanTypeField
      .setDialogFieldApplyListener(new IDialogFieldApplyListener()
      {
        public void dialogFieldApplied(DialogField field)
        {
          RadiosDialogField beanTypeField1 = (RadiosDialogField)field;
          
          boolean bChangedSuccess = false;
          if (beanTypeField1.getSelectedIndex() == 0) {
            bChangedSuccess = InitializationSection.this.switchPage(
              "managed-property", 
              false);
          } else if (beanTypeField1.getSelectedIndex() == 1) {
            bChangedSuccess = InitializationSection.this.switchPage(
              "map-entries", false);
          } else if (beanTypeField1.getSelectedIndex() == 2) {
            bChangedSuccess = InitializationSection.this.switchPage(
              "list-entries", false);
          }
          if (bChangedSuccess)
          {
            currentPageIndex = beanTypeField1.getSelectedIndex();
          }
          else
          {
            beanTypeField1.setSelectedIndexWithoutUpdate(-1);
            beanTypeField1
              .setSelectedIndexWithoutUpdate(currentPageIndex);
          }
        }
      });
  }
  
  private boolean switchPage(String pageID, boolean bForceClearOthers)
  {
    if (pageID == "managed-property")
    {
      if ((clearPage("map-entries", bForceClearOthers)) && 
        (clearPage("list-entries", 
        bForceClearOthers)))
      {
        managedPropertyGroup.refreshAll();
        pageBook.showPage(propertySection);
        
        getSection().setExpanded(false);
        getSection().setExpanded(true);
        return true;
      }
    }
    else if (pageID == "map-entries")
    {
      if (clearPage("managed-property", 
        bForceClearOthers)) {
        if (clearPage("list-entries", 
          bForceClearOthers))
        {
          mapEntryGroup.refreshAll();
          pageBook.showPage(mapSection);
          
          getSection().setExpanded(false);
          getSection().setExpanded(true);
          return true;
        }
      }
    }
    else if ((pageID == "list-entries") && 
      (clearPage("managed-property", 
      bForceClearOthers))) {
      if (clearPage("map-entries", 
        bForceClearOthers))
      {
        listEntryGroup.refreshAll();
        pageBook.showPage(listSection);
        
        getSection().setExpanded(false);
        getSection().setExpanded(true);
        return true;
      }
    }
    return false;
  }
  
  private boolean clearPage(String pageID, boolean bForceClear)
  {
    ManagedBeanType managedBean = (ManagedBeanType)getInput();
    if (pageID == "managed-property")
    {
      if (managedBean.getManagedProperty().size() == 0) {
        return true;
      }
      if ((bForceClear) || 
      
        (EditorPlugin.getAlerts().confirm(
        "ManagedBeanInitializationSection.Remove.Title", 
        "ManagedBeanInitializationSection.RemoveManagedProperty")))
      {
        Command cmd = SetCommand.create(getEditingDomain(), 
          managedBean, FacesConfigPackage.eINSTANCE
          .getManagedBeanType_ManagedProperty(), 
          SetCommand.UNSET_VALUE);
        if (cmd.canExecute())
        {
          getEditingDomain().getCommandStack().execute(cmd);
          return true;
        }
        return false;
      }
    }
    else if (pageID == "map-entries")
    {
      if (managedBean.getMapEntries() == null) {
        return true;
      }
      if ((bForceClear) || 
      
        (EditorPlugin.getAlerts().confirm(
        "ManagedBeanInitializationSection.Remove.Title", 
        "ManagedBeanInitializationSection.RemoveMapEntries")))
      {
        Command cmd = SetCommand.create(getEditingDomain(), 
          managedBean, FacesConfigPackage.eINSTANCE
          .getManagedBeanType_MapEntries(), 
          SetCommand.UNSET_VALUE);
        if (cmd.canExecute())
        {
          getEditingDomain().getCommandStack().execute(cmd);
          return true;
        }
      }
    }
    else if (pageID == "list-entries")
    {
      if (managedBean.getListEntries() == null) {
        return true;
      }
      if ((bForceClear) || 
      
        (EditorPlugin.getAlerts().confirm(
        "ManagedBeanInitializationSection.Remove.Title", 
        "ManagedBeanInitializationSection.RemoveListEntries")))
      {
        Command cmd = SetCommand.create(getEditingDomain(), 
          managedBean, FacesConfigPackage.eINSTANCE
          .getManagedBeanType_ListEntries(), 
          SetCommand.UNSET_VALUE);
        if (cmd.canExecute())
        {
          getEditingDomain().getCommandStack().execute(cmd);
          return true;
        }
      }
    }
    return false;
  }
  
  private void createInitializationEntry(Composite container, FormToolkit toolkit, int numberOfColumns)
  {
    pageBook = new PageBook(container, 0);
    GridData gd = new GridData(1808);
    horizontalSpan = numberOfColumns;
    pageBook.setLayoutData(gd);
    toolkit.paintBordersFor(pageBook);
    
    managedPropertyGroup = new ManagedPropertyEditGroup(this);
    managedPropertyGroup.initialize();
    managedPropertyGroup.addSelectionChangedListener(this);
    
    mapEntryGroup = new MapEntriesEditGroup(this);
    mapEntryGroup.initialize();
    mapEntryGroup.addSelectionChangedListener(this);
    
    listEntryGroup = new ListEntriesEditGroup(this);
    listEntryGroup.initialize();
    listEntryGroup.addSelectionChangedListener(this);
    
    propertySection = toolkit.createComposite(pageBook);
    GridLayout gl = new GridLayout();
    horizontalSpacing = 0;
    marginWidth = 0;
    propertySection.setLayout(gl);
    gd = new GridData(1808);
    propertySection.setLayoutData(gd);
    managedPropertyGroup.layoutDialogFields(toolkit, propertySection);
    
    mapSection = toolkit.createComposite(pageBook);
    mapEntryGroup.layoutDialogFields(toolkit, mapSection);
    
    listSection = toolkit.createComposite(pageBook);
    listEntryGroup.layoutDialogFields(toolkit, listSection);
    
    pageBook.showPage(propertySection);
  }
  
  public void setInput(Object newInput)
  {
    super.setInput(newInput);
    refreshAll();
  }
  
  public void refreshAll()
  {
    if ((getInput() instanceof ManagedBeanType))
    {
      ManagedBeanType managedBean = (ManagedBeanType)getInput();
      managedPropertyGroup.setInput(managedBean);
      mapEntryGroup.setInput(managedBean);
      listEntryGroup.setInput(managedBean);
      if (managedBean.getManagedProperty().size() > 0)
      {
        beanTypeField.setSelectedIndexWithoutUpdate(-1);
        beanTypeField.setSelectedIndex(0);
      }
      else if (managedBean.getMapEntries() != null)
      {
        beanTypeField.setSelectedIndexWithoutUpdate(-1);
        beanTypeField.setSelectedIndex(1);
      }
      else if (managedBean.getListEntries() != null)
      {
        beanTypeField.setSelectedIndexWithoutUpdate(-1);
        beanTypeField.setSelectedIndex(2);
      }
      else
      {
        beanTypeField.setSelectedIndexWithoutUpdate(-1);
        beanTypeField.setSelectedIndex(0);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.InitializationSection
 * 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 LifecycleSection$1
  extends ViewerFilter
{
  LifecycleSection$1(LifecycleSection paramLifecycleSection) {}
  
  public boolean select(Viewer viewer, Object parentElement, Object element)
  {
    return LifecycleSection.access$0(this$0).isInstance(element);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.LifecycleSection.1
 * 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.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.FacesConfigFactory;
import org.eclipse.jst.jsf.facesconfig.emf.LifecycleType;
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 LifecycleSection
  extends OthersPageBaseSection
{
  private EClass lifecycleChildClass;
  
  public LifecycleSection(EClass lifecycleChildClass, Composite parent, IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit, String helpContextId, String helpTooltip)
  {
    super(parent, managedForm, page, toolkit, helpContextId, helpTooltip);
    this.lifecycleChildClass = lifecycleChildClass;
  }
  
  public LifecycleSection(EClass lifecycleChildClass, Composite parent, IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit)
  {
    this(lifecycleChildClass, parent, managedForm, page, toolkit, null, null);
  }
  
  public EObject createLifecycleChildObject()
  {
    String superType = ModelUtil.getSuperType(lifecycleChildClass);
    IProject project = (IProject)getPage().getEditor().getAdapter(
      IProject.class);
    String result = DialogUtil.openClassDialog(getSection().getShell(), 
      project, superType, 
      256);
    if (result != null)
    {
      EObject component = FacesConfigFactory.eINSTANCE
        .create(lifecycleChildClass);
      EStructuralFeature feature = 
        (EStructuralFeature)lifecycleChildClass.getEStructuralFeatures().get(0);
      component.eSet(feature, result);
      return component;
    }
    return null;
  }
  
  protected void setViewerInput(Object input)
  {
    if ((input instanceof LifecycleType)) {
      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 lifecycleChildClass.isInstance(element);
      }
    });
  }
  
  void addButtonSelected(SelectionEvent e)
  {
    EObject obj = createLifecycleChildObject();
    if (obj != null)
    {
      boolean needRefreshAll = false;
      Command command = null;
      if ((getInput() instanceof LifecycleType))
      {
        LifecycleType lifeCycle = (LifecycleType)getInput();
        command = AddCommand.create(getEditingDomain(), lifeCycle, 
          null, obj);
      }
      else
      {
        needRefreshAll = true;
        LifecycleType lifeCycle = FacesConfigFactory.eINSTANCE
          .createLifecycleType();
        lifeCycle.getPhaseListener().add(obj);
        command = AddCommand.create(getEditingDomain(), getPage()
          .getInput(), null, lifeCycle);
      }
      if (command.canExecute())
      {
        getEditingDomain().getCommandStack().execute(command);
        if (needRefreshAll) {
          ((OthersPage)getPage()).resetLifecycleInput();
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.LifecycleSection
 * 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.command.Command;
import org.eclipse.emf.common.command.CommandStack;
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.DialogField;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
import org.eclipse.jst.jsf.facesconfig.emf.ListEntriesType;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType;
import org.eclipse.jst.jsf.facesconfig.emf.ValueClassType;

class ListEntriesEditGroup$1
  implements IDialogFieldApplyListener
{
  ListEntriesEditGroup$1(ListEntriesEditGroup paramListEntriesEditGroup) {}
  
  public void dialogFieldApplied(DialogField field)
  {
    ManagedBeanType managedBean_ = (ManagedBeanType)this$0.getInput();
    String className = ((ClassButtonDialogField)field)
      .getText();
    ValueClassType valueClass = FacesConfigFactory.eINSTANCE
      .createValueClassType();
    valueClass.setTextContent(className);
    EditingDomain editingDomain = ListEntriesEditGroup.access$0(this$0)
      .getEditingDomain();
    Command cmd;
    boolean isNew;
    Command cmd;
    if (managedBean_.getListEntries() == null)
    {
      boolean isNew = true;
      ListEntriesType listEntries = FacesConfigFactory.eINSTANCE
        .createListEntriesType();
      listEntries.setValueClass(valueClass);
      cmd = SetCommand.create(editingDomain, managedBean_, 
        FacesConfigPackage.eINSTANCE
        .getManagedBeanType_ListEntries(), 
        listEntries);
    }
    else
    {
      isNew = false;
      ListEntriesType listEntries = managedBean_
        .getListEntries();
      cmd = SetCommand.create(editingDomain, listEntries, 
        FacesConfigPackage.eINSTANCE
        .getListEntriesType_ValueClass(), 
        valueClass);
    }
    if (cmd.canExecute())
    {
      editingDomain.getCommandStack().execute(cmd);
      if (isNew) {
        this$0.refreshAll();
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.ListEntriesEditGroup.1
 * 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.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;

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

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.ListEntriesEditGroup.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.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;

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

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.ListEntriesEditGroup.3
 * 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 ListEntriesEditGroup$4
  extends ViewerFilter
{
  ListEntriesEditGroup$4(ListEntriesEditGroup paramListEntriesEditGroup) {}
  
  public boolean select(Viewer viewer, Object parentElement, Object element)
  {
    if (!FacesConfigPackage.eINSTANCE.getValueType().isInstance(
      element)) {
      if (!FacesConfigPackage.eINSTANCE.getNullValueType().isInstance(element)) {
        return false;
      }
    }
    return 
    
      true;
  }
}

/* Location:
 * Quali
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