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

fied Name:     org.eclipse.jst.jsf.facesconfig.ui.section.ListEntriesEditGroup.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 ListEntriesEditGroup$5
  extends SelectionAdapter
{
  ListEntriesEditGroup$5(ListEntriesEditGroup paramListEntriesEditGroup) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    ListEntriesEditGroup.access$4(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.ListEntriesEditGroup.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 ListEntriesEditGroup$6
  extends SelectionAdapter
{
  ListEntriesEditGroup$6(ListEntriesEditGroup paramListEntriesEditGroup) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    ListEntriesEditGroup.access$3(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.ListEntriesEditGroup.6
 * 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 ListEntriesEditGroup$7
  extends SelectionAdapter
{
  ListEntriesEditGroup$7(ListEntriesEditGroup paramListEntriesEditGroup) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    ListEntriesEditGroup.access$5(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.ListEntriesEditGroup.7
 * 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.core.resources.IProject;
import org.eclipse.core.runtime.IStatus;
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.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.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
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.common.ui.internal.dialogfield.ClassButtonDialogField;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogFieldBase;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogFieldGroup;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil;
import org.eclipse.jst.jsf.common.ui.internal.guiutils.SWTUtils;
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.NullValueType;
import org.eclipse.jst.jsf.facesconfig.emf.ValueClassType;
import org.eclipse.jst.jsf.facesconfig.emf.ValueType;
import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.jst.jsf.facesconfig.ui.dialog.EditValueDialog;
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.events.SelectionListener;
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.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.widgets.FormToolkit;

public class ListEntriesEditGroup
  extends DialogFieldGroup
  implements IDialogFieldGroup, ISelectionProvider, ISelectionChangedListener
{
  private ClassButtonDialogField valueClassField;
  private static final int TABLE_DEFAULT_HEIGHT = 160;
  private IProject currentProject;
  private TableViewer tableViewer;
  private Button removeButton;
  private Button editButton;
  private ManagedBeanType managedBean;
  private AbstractFacesConfigSection section;
  private List selectionChangedListeners = new ArrayList();
  
  public ListEntriesEditGroup(AbstractFacesConfigSection section)
  {
    this.section = section;
  }
  
  public void initialize() {}
  
  public void refreshData() {}
  
  public void layoutDialogFields(FormToolkit toolkit, Composite parent)
  {
    GridData data = new GridData(1808);
    parent.setLayoutData(data);
    
    GridLayout gl = new GridLayout();
    verticalSpacing = 0;
    marginHeight = 0;
    parent.setLayout(gl);
    
    layoutListTypeSelectionSection(toolkit, parent);
    
    createAndLayoutListValueSection(toolkit, parent);
  }
  
  private void layoutListTypeSelectionSection(FormToolkit toolkit, Composite container)
  {
    Composite typeSelectionSection = null;
    if (toolkit != null)
    {
      typeSelectionSection = toolkit.createComposite(container);
      toolkit.paintBordersFor(typeSelectionSection);
    }
    else
    {
      typeSelectionSection = 
        SWTUtils.createComposite(container, 0);
    }
    GridData gd = new GridData(768);
    typeSelectionSection.setLayoutData(gd);
    
    int numberOfColumns = 4;
    GridLayout gl = new GridLayout(numberOfColumns, false);
    typeSelectionSection.setLayout(gl);
    valueClassField = new ClassButtonDialogField(getProject());
    
    valueClassField
      .setLabelText(EditorMessages.InitializationSection_MapType_ValueClass);
    valueClassField
      .setDialogFieldApplyListener(new IDialogFieldApplyListener()
      {
        public void dialogFieldApplied(DialogField field)
        {
          ManagedBeanType managedBean_ = (ManagedBeanType)getInput();
          String className = ((ClassButtonDialogField)field)
            .getText();
          ValueClassType valueClass = FacesConfigFactory.eINSTANCE
            .createValueClassType();
          valueClass.setTextContent(className);
          EditingDomain editingDomain = section
            .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) {
              refreshAll();
            }
          }
        }
      });
    valueClassField.doFillIntoGrid(toolkit, typeSelectionSection, 
      numberOfColumns);
    LayoutUtil.setHorizontalGrabbing(valueClassField.getTextControl(
      toolkit, container));
  }
  
  private void createAndLayoutListValueSection(FormToolkit toolkit, Composite parent)
  {
    Composite listValueSection = null;
    if (toolkit != null)
    {
      listValueSection = toolkit.createComposite(parent);
      toolkit.paintBordersFor(listValueSection);
    }
    else
    {
      listValueSection = SWTUtils.createComposite(parent, 0);
    }
    GridData gd = new GridData(1808);
    listValueSection.setLayoutData(gd);
    
    int numberOfColumns = 3;
    GridLayout gl = new GridLayout(numberOfColumns, false);
    listValueSection.setLayout(gl);
    DialogFieldBase valuesTitle = new DialogFieldBase();
    valuesTitle
      .setLabelText(EditorMessages.InitializationSection_MapTable_Title);
    valuesTitle.doFillIntoGrid(toolkit, listValueSection, numberOfColumns);
    Table listTable;
    Table listTable;
    if (toolkit == null) {
      listTable = new Table(listValueSection, 68352);
    } else {
      listTable = new Table(listValueSection, 68352);
    }
    listTable.addSelectionListener(new SelectionListener()
    {
      public void widgetSelected(SelectionEvent e)
      {
        ListEntriesEditGroup.this.updateButtons();
      }
      
      public void widgetDefaultSelected(SelectionEvent e)
      {
        ListEntriesEditGroup.this.updateButtons();
      }
    });
    gd = new GridData(1808);
    horizontalSpan = 1;
    heightHint = 160;
    listTable.setLayoutData(gd);
    listTable.setHeaderVisible(true);
    listTable.setLinesVisible(true);
    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(1, true));
    listTable.setLayout(layout);
    TableColumn valueCol = new TableColumn(listTable, 0);
    layout.addColumnData(new ColumnWeightData(1, true));
    valueCol
      .setText(EditorMessages.InitializationSection_MapTable_Value);
    valueCol.setResizable(true);
    
    listTable.addMouseListener(new MouseAdapter()
    {
      public void mouseDoubleClick(MouseEvent e)
      {
        if (((IStructuredSelection)tableViewer.getSelection()).size() > 0) {
          ListEntriesEditGroup.this.editButtonSelected();
        }
      }
    });
    tableViewer = new TableViewer(listTable);
    tableViewer.setContentProvider(new AdapterFactoryContentProvider(
      section.getAdapterFactory()));
    tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(section
      .getAdapterFactory()));
    
    tableViewer.addFilter(new ViewerFilter()
    {
      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;
      }
    });
    tableViewer.addSelectionChangedListener(this);
    
    Composite operationContainer = null;
    if (toolkit != null) {
      operationContainer = toolkit.createComposite(listValueSection);
    } else {
      operationContainer = SWTUtils.createComposite(listValueSection, 
        0);
    }
    gd = new GridData(1040);
    operationContainer.setLayoutData(gd);
    gl = new GridLayout();
    operationContainer.setLayout(gl);
    
    Button addButton = null;
    if (toolkit != null) {
      addButton = toolkit.createButton(operationContainer, 
        EditorMessages.UI_Button_Add_more, 
        8);
    } else {
      addButton = SWTUtils.createPushButton(operationContainer, 
        EditorMessages.UI_Button_Add_more);
    }
    gd = new GridData(770);
    
    grabExcessHorizontalSpace = false;
    addButton.setLayoutData(gd);
    
    editButton = null;
    if (toolkit != null) {
      editButton = toolkit.createButton(operationContainer, 
        EditorMessages.UI_Button_Edit_more, 8);
    } else {
      editButton = SWTUtils.createPushButton(operationContainer, 
        EditorMessages.UI_Button_Edit_more);
    }
    gd = new GridData(770);
    
    grabExcessHorizontalSpace = false;
    editButton.setLayoutData(gd);
    
    removeButton = null;
    if (toolkit != null) {
      removeButton = toolkit.createButton(operationContainer, 
        EditorMessages.UI_Button_Remove, 
        8);
    } else {
      removeButton = SWTUtils.createPushButton(operationContainer, 
        EditorMessages.UI_Button_Remove);
    }
    gd = new GridData(770);
    
    grabExcessHorizontalSpace = false;
    removeButton.setLayoutData(gd);
    
    addButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        ListEntriesEditGroup.this.addButtonSelected();
      }
    });
    editButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        ListEntriesEditGroup.this.editButtonSelected();
      }
    });
    removeButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        ListEntriesEditGroup.this.removeButtonSelected();
      }
    });
  }
  
  private void addButtonSelected()
  {
    EditValueDialog dialog = new EditValueDialog(
      EditorPlugin.getActiveShell(), true, false, null);
    if (dialog.open() == 0)
    {
      EditingDomain editingDomain = section.getEditingDomain();
      if (managedBean.getListEntries() == null)
      {
        ListEntriesType listEntries = FacesConfigFactory.eINSTANCE
          .createListEntriesType();
        if (dialog.isNullValue())
        {
          NullValueType nullValue = FacesConfigFactory.eINSTANCE
            .createNullValueType();
          listEntries.getNullValue().add(nullValue);
        }
        else
        {
          ValueType value = FacesConfigFactory.eINSTANCE
            .createValueType();
          value.setTextContent((String)dialog.getResultData());
          listEntries.getValue().add(value);
        }
        Command cmd1 = SetCommand.create(editingDomain, managedBean, 
          FacesConfigPackage.eINSTANCE
          .getManagedBeanType_ListEntries(), listEntries);
        if (cmd1.canExecute())
        {
          editingDomain.getCommandStack().execute(cmd1);
          refreshAll();
        }
      }
      else
      {
        ListEntriesType listEntries = managedBean.getListEntries();
        Command cmd;
        Command cmd;
        if (dialog.isNullValue())
        {
          NullValueType nullValue = FacesConfigFactory.eINSTANCE
            .createNullValueType();
          cmd = AddCommand.create(editingDomain, listEntries, 
            FacesConfigPackage.eINSTANCE
            .getListEntriesType_NullValue(), nullValue);
        }
        else
        {
          ValueType value = FacesConfigFactory.eINSTANCE
            .createValueType();
          value.setTextContent((String)dialog.getResultData());
          cmd = AddCommand.create(editingDomain, listEntries, 
            FacesConfigPackage.eINSTANCE
            .getListEntriesType_Value(), value);
        }
        if (cmd.canExecute()) {
          editingDomain.getCommandStack().execute(cmd);
        }
      }
    }
  }
  
  private void editButtonSelected()
  {
    Object select = ((IStructuredSelection)tableViewer.getSelection())
      .getFirstElement();
    
    String valueText = null;
    boolean isNullValue;
    boolean isNullValue;
    if ((select instanceof NullValueType))
    {
      isNullValue = true;
    }
    else
    {
      isNullValue = false;
      valueText = ((ValueType)select).getTextContent();
    }
    ListEntriesType listEntries = managedBean.getListEntries();
    EditValueDialog dialog = new EditValueDialog(
      EditorPlugin.getActiveShell(), true, isNullValue, valueText);
    if (dialog.open() == 0)
    {
      EditingDomain editingDomain = section.getEditingDomain();
      Command cmd = null;
      if ((isNullValue) && (!dialog.isNullValue()))
      {
        List commands = new ArrayList();
        Command cmd1 = RemoveCommand.create(editingDomain, listEntries, 
          FacesConfigPackage.eINSTANCE
          .getListEntriesType_NullValue(), select);
        commands.add(cmd1);
        
        ValueType value = FacesConfigFactory.eINSTANCE
          .createValueType();
        value.setTextContent((String)dialog.getResultData());
        Command cmd2 = 
          AddCommand.create(editingDomain, listEntries, 
          FacesConfigPackage.eINSTANCE
          .getListEntriesType_Value(), value);
        commands.add(cmd2);
        cmd = new CompoundCommand(commands);
      }
      else if ((!isNullValue) && (dialog.isNullValue()))
      {
        List commands = new ArrayList();
        Command cmd1 = 
          RemoveCommand.create(editingDomain, listEntries, 
          FacesConfigPackage.eINSTANCE
          .getListEntriesType_Value(), select);
        commands.add(cmd1);
        NullValueType nullValue = FacesConfigFactory.eINSTANCE
          .createNullValueType();
        Command cmd2 = AddCommand.create(editingDomain, listEntries, 
          FacesConfigPackage.eINSTANCE
          .getListEntriesType_NullValue(), nullValue);
        commands.add(cmd2);
        cmd = new CompoundCommand(commands);
      }
      else if ((!isNullValue) && (!dialog.isNullValue()))
      {
        cmd = 
          SetCommand.create(editingDomain, select, 
          FacesConfigPackage.eINSTANCE
          .getValueType_TextContent(), dialog
          .getResultData());
      }
      if ((cmd != null) && (cmd.canExecute())) {
        editingDomain.getCommandStack().execute(cmd);
      }
    }
  }
  
  private void removeButtonSelected()
  {
    Object select = ((IStructuredSelection)tableViewer.getSelection())
      .getFirstElement();
    ListEntriesType listEntries = managedBean.getListEntries();
    EditingDomain editingDomain = section.getEditingDomain();
    Command cmd;
    Command cmd;
    if ((select instanceof NullValueType)) {
      cmd = 
        RemoveCommand.create(editingDomain, listEntries, 
        FacesConfigPackage.eINSTANCE
        .getListEntriesType_NullValue(), select);
    } else {
      cmd = RemoveCommand.create(editingDomain, listEntries, 
        FacesConfigPackage.eINSTANCE.getListEntriesType_Value(), 
        select);
    }
    if (cmd.canExecute()) {
      editingDomain.getCommandStack().execute(cmd);
    }
  }
  
  public void setInput(Object newInput)
  {
    if ((newInput != null) && ((newInput instanceof ManagedBeanType)))
    {
      managedBean = ((ManagedBeanType)newInput);
      if (managedBean.getListEntries() != null) {
        refreshAll();
      }
    }
  }
  
  public void refreshAll()
  {
    if ((managedBean.getListEntries() != null) && 
      (managedBean.getListEntries().getValueClass() != null)) {
      valueClassField.setTextWithoutUpdate(managedBean
        .getListEntries().getValueClass().getTextContent());
    } else {
      valueClassField.setTextWithoutUpdate(null);
    }
    tableViewer.setInput(((ManagedBeanType)getInput()).getListEntries());
    updateButtons();
  }
  
  public Object getInput()
  {
    return managedBean;
  }
  
  private IProject getProject()
  {
    if (currentProject == null) {
      currentProject = 
        ((IProject)section.getPage().getEditor().getAdapter(IProject.class));
    }
    return currentProject;
  }
  
  private void updateButtons()
  {
    if (((IStructuredSelection)tableViewer.getSelection()).size() > 0)
    {
      editButton.setEnabled(true);
      removeButton.setEnabled(true);
    }
    else
    {
      editButton.setEnabled(false);
      removeButton.setEnabled(false);
    }
  }
  
  public IStatus[] validateDialogFields()
  {
    return null;
  }
  
  public void addSelectionChangedListener(ISelectionChangedListener listener)
  {
    selectionChangedListeners.add(listener);
  }
  
  public ISelection getSelection()
  {
    return null;
  }
  
  public void removeSelectionChangedListener(ISelectionChangedListener listener)
  {
    selectionChangedListeners.remove(listener);
  }
  
  public void setSelection(ISelection selection) {}
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    for (Iterator listeners = selectionChangedListeners.iterator(); listeners
          .hasNext();)
    {
      ISelectionChangedListener listener = 
        (ISelectionChangedListener)listeners.next();
      listener.selectionChanged(new SelectionChangedEvent(this, event
        .getSelection()));
    }
  }
}

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

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

class LocaleConfigSection$LocaleConfigAdapter$1
  implements Runnable
{
  LocaleConfigSection$LocaleConfigAdapter$1(LocaleConfigSection.LocaleConfigAdapter paramLocaleConfigAdapter) {}
  
  public void run()
  {
    LocaleConfigSection.LocaleConfigAdapter.access$0(this$1).setInput(LocaleConfigSection.LocaleConfigAdapter.access$0(this$1).getInput());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.LocaleConfigSection.LocaleConfigAdapter.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 LocaleConfigSection$LocaleConfigAdapter
  extends AdapterImpl
{
  LocaleConfigSection$LocaleConfigAdapter(LocaleConfigSection paramLocaleConfigSection) {}
  
  public boolean isAdapterForType(Object type)
  {
    if (type == LocaleConfigSection.class) {
      return true;
    }
    return false;
  }
  
  public void notifyChanged(Notification msg)
  {
    if (((msg.getEventType() == 3) || 
      (msg.getEventType() == 4)) && 
      (msg.getFeature() == FacesConfigPackage.eINSTANCE
      .getApplicationType_LocaleConfig())) {
      if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) {
        this$0.setInput(this$0.getInput());
      } else {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
        {
          public void run()
          {
            this$0.setInput(this$0.getInput());
          }
        });
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.LocaleConfigSection.LocaleConfigAdapter
 * 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.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandStack;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.notify.Adapter;
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.EClass;
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.command.SetCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.jst.jsf.facesconfig.emf.ApplicationType;
import org.eclipse.jst.jsf.facesconfig.emf.DefaultLocaleType;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
import org.eclipse.jst.jsf.facesconfig.emf.LocaleConfigType;
import org.eclipse.jst.jsf.facesconfig.emf.SupportedLocaleType;
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.swt.events.SelectionEvent;
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.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;

public class LocaleConfigSection
  extends ApplicationSection
  implements ICheckStateListener
{
  private LocaleConfigAdapter _localeConfigAdapter;
  
  public LocaleConfigSection(EClass componentClass, Composite parent, IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit, String helpContextId, String helpTooltip)
  {
    super(componentClass, parent, managedForm, page, toolkit, helpContextId, helpTooltip);
  }
  
  public LocaleConfigSection(EClass componentClass, Composite parent, IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit)
  {
    this(componentClass, parent, managedForm, page, toolkit, null, null);
  }
  
  public void dispose()
  {
    ((CheckboxTableViewer)tableViewer).removeCheckStateListener(this);
    super.dispose();
  }
  
  protected TableViewer createTableViewer(Composite parent)
  {
    CheckboxTableViewer tableViewer1 = CheckboxTableViewer.newCheckList(
      parent, 2818);
    tableViewer1.addCheckStateListener(this);
    tableViewer1.setSorter(new ViewerSorter());
    return tableViewer1;
  }
  
  protected void configTableViewer(TableViewer tableViewer1)
  {
    tableViewer1.addFilter(new ViewerFilter()
    {
      public boolean select(Viewer viewer, Object parentElement, Object element)
      {
        if (!FacesConfigPackage.eINSTANCE.getSupportedLocaleType().isInstance(element)) {
          if (!FacesConfigPackage.eINSTANCE.getDefaultLocaleType().isInstance(element)) {
            return false;
          }
        }
        return 
        
          true;
      }
    });
  }
  
  public SupportedLocaleType createSupportedLocaleObject()
  {
    ArrayList locales = new ArrayList();
    if (((getInput() instanceof ApplicationType)) && 
      (((ApplicationType)getInput()).getLocaleConfig().size() > 0))
    {
      LocaleConfigType localeConfigType = 
        (LocaleConfigType)((ApplicationType)getInput()).getLocaleConfig().get(0);
      if (localeConfigType.getDefaultLocale() != null)
      {
        String locale = localeConfigType.getDefaultLocale()
          .getTextContent();
        if (locale != null) {
          locales.add(locale);
        }
      }
      List list = localeConfigType.getSupportedLocale();
      int i = 0;
      for (int n = list.size(); i < n; i++)
      {
        String locale = ((SupportedLocaleType)list.get(i))
          .getTextContent();
        if (locale != null) {
          locales.add(locale);
        }
      }
    }
    String result = DialogUtil.openLocaleDialog(getSection().getShell(), 
      locales);
    if (result != null)
    {
      SupportedLocaleType component = FacesConfigFactory.eINSTANCE
        .createSupportedLocaleType();
      component.setTextContent(result);
      return component;
    }
    return null;
  }
  
  void addButtonSelected(SelectionEvent e)
  {
    SupportedLocaleType obj = createSupportedLocaleObject();
    if (obj != null)
    {
      boolean needRefreshAll = false;
      Command command = null;
      if ((getInput() instanceof ApplicationType))
      {
        ApplicationType application = (ApplicationType)getInput();
        if (application.getLocaleConfig().size() > 0)
        {
          LocaleConfigType localeConfig = 
            (LocaleConfigType)application.getLocaleConfig().get(0);
          command = AddCommand.create(getEditingDomain(), 
            localeConfig, null, obj);
        }
        else
        {
          LocaleConfigType localeConfig = FacesConfigFactory.eINSTANCE
            .createLocaleConfigType();
          localeConfig.getSupportedLocale().add(obj);
          command = AddCommand.create(getEditingDomain(), 
            application, null, localeConfig);
        }
      }
      else
      {
        needRefreshAll = true;
        ApplicationType application = FacesConfigFactory.eINSTANCE
          .createApplicationType();
        LocaleConfigType localeConfig = FacesConfigFactory.eINSTANCE
          .createLocaleConfigType();
        localeConfig.getSupportedLocale().add(obj);
        application.getLocaleConfig().add(localeConfig);
        command = AddCommand.create(getEditingDomain(), getPage()
          .getInput(), null, application);
      }
      if (command.canExecute())
      {
        getEditingDomain().getCommandStack().execute(command);
        if (needRefreshAll) {
          ((OthersPage)getPage()).resetApplicationInput();
        }
      }
    }
  }
  
  public void checkStateChanged(CheckStateChangedEvent event)
  {
    boolean checked = event.getChecked();
    if (event.getElement() == null) {
      return;
    }
    EObject node = (EObject)event.getElement();
    LocaleConfigType localeConfigType = 
      (LocaleConfigType)((ApplicationType)getInput()).getLocaleConfig().get(0);
    CompoundCommand compoundCommand = new CompoundCommand();
    if (checked)
    {
      if (localeConfigType.getDefaultLocale() != null)
      {
        Command command = RemoveCommand.create(getEditingDomain(), 
          localeConfigType, null, localeConfigType
          .getDefaultLocale());
        
        compoundCommand.append(command);
        
        SupportedLocaleType supportedLocale = FacesConfigFactory.eINSTANCE
          .createSupportedLocaleType();
        supportedLocale.setTextContent(localeConfigType
          .getDefaultLocale().getTextContent());
        command = AddCommand.create(getEditingDomain(), 
          localeConfigType, FacesConfigPackage.eINSTANCE
          .getLocaleConfigType_SupportedLocale(), 
          supportedLocale);
        compoundCommand.append(command);
      }
      SupportedLocaleType supportedLocale = (SupportedLocaleType)node;
      Command command = RemoveCommand.create(getEditingDomain(), 
        localeConfigType, FacesConfigPackage.eINSTANCE
        .getLocaleConfigType_SupportedLocale(), 
        supportedLocale);
      compoundCommand.append(command);
      
      DefaultLocaleType defaultLocale = FacesConfigFactory.eINSTANCE
        .createDefaultLocaleType();
      defaultLocale.setTextContent(supportedLocale.getTextContent());
      command = 
        SetCommand.create(getEditingDomain(), localeConfigType, 
        FacesConfigPackage.eINSTANCE
        .getLocaleConfigType_DefaultLocale(), 
        defaultLocale);
      compoundCommand.append(command);
    }
    else
    {
      DefaultLocaleType defaultLocale = (DefaultLocaleType)node;
      Command command = RemoveCommand.create(getEditingDomain(), 
        localeConfigType, null, defaultLocale);
      compoundCommand.append(command);
      
      SupportedLocaleType supportedLocale = FacesConfigFactory.eINSTANCE
        .createSupportedLocaleType();
      supportedLocale.setTextContent(defaultLocale.getTextContent());
      command = AddCommand.create(getEditingDomain(), localeConfigType, 
        null, supportedLocale);
      compoundCommand.append(command);
    }
    if (compoundCommand.canExecute())
    {
      getEditingDomain().getCommandStack().execute(compoundCommand);
      refresh();
      setTableViewerCheckedState();
    }
  }
  
  private void setTableViewerCheckedState()
  {
    if ((getInput() instanceof ApplicationType))
    {
      ApplicationType application = (ApplicationType)getInput();
      if (application.getLocaleConfig().size() > 0)
      {
        LocaleConfigType localeConfigType = 
          (LocaleConfigType)application.getLocaleConfig().get(0);
        if (localeConfigType.getDefaultLocale() != null) {
          ((CheckboxTableViewer)getTableViewer()).setChecked(
            localeConfigType.getDefaultLocale(), true);
        }
      }
    }
  }
  
  protected void addAdaptersOntoInput(Object input)
  {
    super.addAdaptersOntoInput(input);
    if ((input != null) && ((input instanceof ApplicationType)))
    {
      ApplicationType application = (ApplicationType)input;
      if (EcoreUtil.getExistingAdapter(application, 
        LocaleConfigSection.class) == null) {
        application.eAdapters().add(getLocaleConfigAdapter());
      }
    }
  }
  
  private Adapter getLocaleConfigAdapter()
  {
    if (_localeConfigAdapter == null) {
      _localeConfigAdapter = new LocaleConfigAdapter();
    }
    return _localeConfigAdapter;
  }
  
  protected void removeAdaptersFromInput(Object input)
  {
    if ((input != null) && ((input instanceof ApplicationType)) && (_localeConfigAdapter != null))
    {
      ApplicationType application = (ApplicationType)input;
      application.eAdapters().remove(_localeConfigAdapter);
    }
    super.removeAdaptersFromInput(input);
  }
  
  protected void setViewerInput(Object input)
  {
    if ((input instanceof ApplicationType))
    {
      ApplicationType application = (ApplicationType)input;
      if (application.getLocaleConfig().size() > 0) {
        tableViewer.setInput(application.getLocaleConfig().get(0));
      } else {
        tableViewer.setInput(null);
      }
    }
    else
    {
      tableViewer.setInput(null);
    }
  }
  
  public void refreshAll()
  {
    super.refreshAll();
    setTableViewerCheckedState();
  }
  
  class LocaleConfigAdapter
    extends AdapterImpl
  {
    LocaleConfigAdapter() {}
    
    public boolean isAdapterForType(Object type)
    {
      if (type == LocaleConfigSection.class) {
        return true;
      }
      return false;
    }
    
    public void notifyChanged(Notification msg)
    {
      if (((msg.getEventType() == 3) || 
        (msg.getEventType() == 4)) && 
        (msg.getFeature() == FacesConfigPackage.eINSTANCE
        .getApplicationType_LocaleConfig())) {
        if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) {
          setInput(getInput());
        } else {
          PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
          {
            public void run()
            {
              setInput(getInput());
            }
          });
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.LocaleConfigSection
 * 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.DialogField;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener;
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.ManagedBeanNameType;
import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType;

class ManagedBeanGeneralSection$1
  implements IDialogFieldApplyListener
{
  ManagedBeanGeneralSection$1(ManagedBeanGeneralSection paramManagedBeanGeneralSection) {}
  
  public void dialogFieldApplied(DialogField field)
  {
    String mbNameValue = ((StringDialogField)field)
      .getText();
    Command cmd = null;
    ManagedBeanType managedBean = (ManagedBeanType)this$0.getInput();
    
    ManagedBeanNameType newManagedBeanName = FacesConfigFactory.eINSTANCE
      .createManagedBeanNameType();
    newManagedBeanName.setTextContent(mbNameValue);
    cmd = SetCommand.create(this$0.getEditingDomain(), 
      managedBean, FacesConfigPackage.eINSTANCE
      .getManagedBeanType_ManagedBeanName(), 
      newManagedBeanName);
    if (cmd.canExecute()) {
      this$0.getEditingDomain().getCommandStack().execute(cmd);
    }
  }
}

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

class ManagedBeanGeneralSection$2
  implements IDialogFieldApplyListener
{
  ManagedBeanGeneralSection$2(ManagedBeanGeneralSection paramManagedBeanGeneralSection) {}
  
  public void dialogFieldApplied(DialogField field)
  {
    String newValue = ((StringDialogField)field).getText();
    Command cmd = null;
    ManagedBeanType managedBean = (ManagedBeanType)this$0.getInput();
    
    ManagedBeanClassType newManagedBeanClass = FacesConfigFactory.eINSTANCE
      .createManagedBeanClassType();
    newManagedBeanClass.setTextContent(newValue);
    cmd = SetCommand.create(this$0.getEditingDomain(), 
      managedBean, FacesConfigPackage.eINSTANCE
      .getManagedBeanType_ManagedBeanClass(), 
      newManagedBeanClass);
    if (cmd.canExecute()) {
      this$0.getEditingDomain().getCommandStack().execute(cmd);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.section.ManagedBeanGeneralSection.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.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.ComboDialogField;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldChangeListene
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