org.eclipse.emf.edit.ui_2.7.0.v20120130-0943

rue;
  }
  
  protected boolean isCorrect(Object value)
  {
    if (validateAsValue) {
      value = valueHandler.toString(value);
    }
    return super.isCorrect(value);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.PropertyDescriptor.EDataTypeCellEditor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import java.util.List;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EFactory;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.util.Diagnostician;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.viewers.ICellEditorValidator;

public class PropertyDescriptor$EDataTypeValueHandler
  implements ICellEditorValidator, IInputValidator
{
  protected EDataType eDataType;
  
  public PropertyDescriptor$EDataTypeValueHandler(EDataType eDataType)
  {
    this.eDataType = eDataType;
  }
  
  public String isValid(Object object)
  {
    try
    {
      value = eDataType.getEPackage().getEFactoryInstance().createFromString(eDataType, (String)object);
    }
    catch (Exception exception)
    {
      Object value;
      String message = exception.getClass().getName();
      int index = message.lastIndexOf('.');
      if (index >= 0) {
        message = message.substring(index + 1);
      }
      if (exception.getLocalizedMessage() != null) {}
      return message + ": " + exception.getLocalizedMessage();
    }
    Object value;
    Diagnostic diagnostic = Diagnostician.INSTANCE.validate(eDataType, value);
    if (diagnostic.getSeverity() == 0) {
      return null;
    }
    return ((Diagnostic)diagnostic.getChildren().get(0)).getMessage().replaceAll("'", "''").replaceAll("\\{", "'{'");
  }
  
  public String isValid(String text)
  {
    return isValid(text);
  }
  
  public Object toValue(String string)
  {
    return EcoreUtil.createFromString(eDataType, string);
  }
  
  public String toString(Object value)
  {
    String result = EcoreUtil.convertToString(eDataType, value);
    return result == null ? "" : result;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.PropertyDescriptor.EDataTypeValueHandler
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import org.eclipse.jface.viewers.ICellEditorValidator;

class PropertyDescriptor$FloatCellEditor$1
  implements ICellEditorValidator
{
  PropertyDescriptor$FloatCellEditor$1(PropertyDescriptor.FloatCellEditor paramFloatCellEditor) {}
  
  public String isValid(Object object)
  {
    if ((object instanceof Float)) {
      return null;
    }
    String string = (String)object;
    try
    {
      Float.parseFloat(string);
      return null;
    }
    catch (NumberFormatException exception)
    {
      return exception.getMessage();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.PropertyDescriptor.FloatCellEditor.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import org.eclipse.jface.viewers.ICellEditorValidator;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.swt.widgets.Composite;

@Deprecated
public class PropertyDescriptor$FloatCellEditor
  extends TextCellEditor
{
  public PropertyDescriptor$FloatCellEditor(Composite composite)
  {
    super(composite);
    setValidator(
      new ICellEditorValidator()
      {
        public String isValid(Object object)
        {
          if ((object instanceof Float)) {
            return null;
          }
          String string = (String)object;
          try
          {
            Float.parseFloat(string);
            return null;
          }
          catch (NumberFormatException exception)
          {
            return exception.getMessage();
          }
        }
      });
  }
  
  public Object doGetValue()
  {
    return new Float(Float.parseFloat((String)super.doGetValue()));
  }
  
  public void doSetValue(Object value)
  {
    super.doSetValue(value.toString());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.PropertyDescriptor.FloatCellEditor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import org.eclipse.jface.viewers.ICellEditorValidator;

class PropertyDescriptor$IntegerCellEditor$1
  implements ICellEditorValidator
{
  PropertyDescriptor$IntegerCellEditor$1(PropertyDescriptor.IntegerCellEditor paramIntegerCellEditor) {}
  
  public String isValid(Object object)
  {
    if ((object instanceof Integer)) {
      return null;
    }
    String string = (String)object;
    try
    {
      Integer.parseInt(string);
      return null;
    }
    catch (NumberFormatException exception)
    {
      return exception.getMessage();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.PropertyDescriptor.IntegerCellEditor.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import org.eclipse.jface.viewers.ICellEditorValidator;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.swt.widgets.Composite;

@Deprecated
public class PropertyDescriptor$IntegerCellEditor
  extends TextCellEditor
{
  public PropertyDescriptor$IntegerCellEditor(Composite composite)
  {
    super(composite);
    setValidator(
      new ICellEditorValidator()
      {
        public String isValid(Object object)
        {
          if ((object instanceof Integer)) {
            return null;
          }
          String string = (String)object;
          try
          {
            Integer.parseInt(string);
            return null;
          }
          catch (NumberFormatException exception)
          {
            return exception.getMessage();
          }
        }
      });
  }
  
  public Object doGetValue()
  {
    return Integer.valueOf(Integer.parseInt((String)super.doGetValue()));
  }
  
  public void doSetValue(Object value)
  {
    super.doSetValue(value.toString());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.PropertyDescriptor.IntegerCellEditor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

class PropertyDescriptor$MultiLineInputDialog
  extends InputDialog
{
  public PropertyDescriptor$MultiLineInputDialog(Shell parentShell, String title, String message, String initialValue, IInputValidator validator)
  {
    super(parentShell, title, message, initialValue, validator);
    setShellStyle(getShellStyle() | 0x10);
  }
  
  protected Text createText(Composite composite)
  {
    Text text = new Text(composite, 2818);
    GridData data = new GridData(1808);
    heightHint = (5 * text.getLineHeight());
    widthHint = convertHorizontalDLUsToPixels(200);
    text.setLayoutData(data);
    return text;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.PropertyDescriptor.MultiLineInputDialog
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.ui.celleditor.ExtendedComboBoxCellEditor;
import org.eclipse.emf.common.ui.celleditor.ExtendedDialogCellEditor;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EFactory;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.util.Diagnostician;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.emf.edit.ui.celleditor.FeatureEditorDialog;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ICellEditorValidator;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.views.properties.IPropertyDescriptor;

public class PropertyDescriptor
  implements IPropertyDescriptor
{
  protected Object object;
  protected IItemPropertyDescriptor itemPropertyDescriptor;
  
  public PropertyDescriptor(Object object, IItemPropertyDescriptor itemPropertyDescriptor)
  {
    this.object = object;
    this.itemPropertyDescriptor = itemPropertyDescriptor;
  }
  
  public String getCategory()
  {
    return itemPropertyDescriptor.getCategory(object);
  }
  
  public String getDescription()
  {
    return itemPropertyDescriptor.getDescription(object);
  }
  
  public String getDisplayName()
  {
    return itemPropertyDescriptor.getDisplayName(object);
  }
  
  public String[] getFilterFlags()
  {
    return itemPropertyDescriptor.getFilterFlags(object);
  }
  
  public Object getHelpContextIds()
  {
    return itemPropertyDescriptor.getHelpContextIds(object);
  }
  
  public Object getId()
  {
    return itemPropertyDescriptor.getId(object);
  }
  
  public ILabelProvider getLabelProvider()
  {
    final IItemLabelProvider itemLabelProvider = itemPropertyDescriptor.getLabelProvider(object);
    
    new LabelProvider()
    {
      public String getText(Object object)
      {
        return itemLabelProvider.getText(object);
      }
      
      public Image getImage(Object object)
      {
        return ExtendedImageRegistry.getInstance().getImage(itemLabelProvider.getImage(object));
      }
    };
  }
  
  protected ILabelProvider getEditLabelProvider()
  {
    return getLabelProvider();
  }
  
  public boolean isCompatibleWith(IPropertyDescriptor anotherProperty)
  {
    return false;
  }
  
  protected static class EDataTypeValueHandler
    implements ICellEditorValidator, IInputValidator
  {
    protected EDataType eDataType;
    
    public EDataTypeValueHandler(EDataType eDataType)
    {
      this.eDataType = eDataType;
    }
    
    public String isValid(Object object)
    {
      try
      {
        value = eDataType.getEPackage().getEFactoryInstance().createFromString(eDataType, (String)object);
      }
      catch (Exception exception)
      {
        Object value;
        String message = exception.getClass().getName();
        int index = message.lastIndexOf('.');
        if (index >= 0) {
          message = message.substring(index + 1);
        }
        if (exception.getLocalizedMessage() != null) {}
        return message + ": " + exception.getLocalizedMessage();
      }
      Object value;
      Diagnostic diagnostic = Diagnostician.INSTANCE.validate(eDataType, value);
      if (diagnostic.getSeverity() == 0) {
        return null;
      }
      return ((Diagnostic)diagnostic.getChildren().get(0)).getMessage().replaceAll("'", "''").replaceAll("\\{", "'{'");
    }
    
    public String isValid(String text)
    {
      return isValid(text);
    }
    
    public Object toValue(String string)
    {
      return EcoreUtil.createFromString(eDataType, string);
    }
    
    public String toString(Object value)
    {
      String result = EcoreUtil.convertToString(eDataType, value);
      return result == null ? "" : result;
    }
  }
  
  public static class EDataTypeCellEditor
    extends TextCellEditor
  {
    protected EDataType eDataType;
    protected PropertyDescriptor.EDataTypeValueHandler valueHandler;
    
    public EDataTypeCellEditor(EDataType eDataType, Composite parent)
    {
      super();
      this.eDataType = eDataType;
      valueHandler = new PropertyDescriptor.EDataTypeValueHandler(eDataType);
      setValidator(valueHandler);
    }
    
    public Object doGetValue()
    {
      return valueHandler.toValue((String)super.doGetValue());
    }
    
    public void doSetValue(Object value)
    {
      value = valueHandler.toString(value);
      super.doSetValue(value);
    }
    
    protected boolean validateAsValue = true;
    
    protected void editOccured(ModifyEvent e)
    {
      validateAsValue = false;
      super.editOccured(e);
      validateAsValue = true;
    }
    
    protected boolean isCorrect(Object value)
    {
      if (validateAsValue) {
        value = valueHandler.toString(value);
      }
      return super.isCorrect(value);
    }
  }
  
  private static class MultiLineInputDialog
    extends InputDialog
  {
    public MultiLineInputDialog(Shell parentShell, String title, String message, String initialValue, IInputValidator validator)
    {
      super(title, message, initialValue, validator);
      setShellStyle(getShellStyle() | 0x10);
    }
    
    protected Text createText(Composite composite)
    {
      Text text = new Text(composite, 2818);
      GridData data = new GridData(1808);
      heightHint = (5 * text.getLineHeight());
      widthHint = convertHorizontalDLUsToPixels(200);
      text.setLayoutData(data);
      return text;
    }
  }
  
  protected CellEditor createEDataTypeCellEditor(EDataType eDataType, Composite composite)
  {
    if (itemPropertyDescriptor.isMultiLine(object)) {
      new ExtendedDialogCellEditor(composite, getEditLabelProvider())
      {
        protected PropertyDescriptor.EDataTypeValueHandler valueHandler;
        
        protected Object openDialogBox(Control cellEditorWindow)
        {
          InputDialog dialog = new PropertyDescriptor.MultiLineInputDialog(
            cellEditorWindow.getShell(), 
            EMFEditUIPlugin.INSTANCE.getString(
            "_UI_FeatureEditorDialog_title", new Object[] { getDisplayName(), getEditLabelProvider().getText(object) }), 
            EMFEditUIPlugin.INSTANCE.getString("_UI_MultiLineInputDialog_message"), 
            valueHandler.toString(getValue()), 
            valueHandler);
          return dialog.open() == 0 ? valueHandler.toValue(dialog.getValue()) : null;
        }
      };
    }
    return new EDataTypeCellEditor(eDataType, composite);
  }
  
  @Deprecated
  public static class IntegerCellEditor
    extends TextCellEditor
  {
    public IntegerCellEditor(Composite composite)
    {
      super();
      setValidator(
        new ICellEditorValidator()
        {
          public String isValid(Object object)
          {
            if ((object instanceof Integer)) {
              return null;
            }
            String string = (String)object;
            try
            {
              Integer.parseInt(string);
              return null;
            }
            catch (NumberFormatException exception)
            {
              return exception.getMessage();
            }
          }
        });
    }
    
    public Object doGetValue()
    {
      return Integer.valueOf(Integer.parseInt((String)super.doGetValue()));
    }
    
    public void doSetValue(Object value)
    {
      super.doSetValue(value.toString());
    }
  }
  
  @Deprecated
  public static class FloatCellEditor
    extends TextCellEditor
  {
    public FloatCellEditor(Composite composite)
    {
      super();
      setValidator(
        new ICellEditorValidator()
        {
          public String isValid(Object object)
          {
            if ((object instanceof Float)) {
              return null;
            }
            String string = (String)object;
            try
            {
              Float.parseFloat(string);
              return null;
            }
            catch (NumberFormatException exception)
            {
              return exception.getMessage();
            }
          }
        });
    }
    
    public Object doGetValue()
    {
      return new Float(Float.parseFloat((String)super.doGetValue()));
    }
    
    public void doSetValue(Object value)
    {
      super.doSetValue(value.toString());
    }
  }
  
  protected static final EcorePackage ecorePackage = EcorePackage.eINSTANCE;
  
  public CellEditor createPropertyEditor(Composite composite)
  {
    if (!itemPropertyDescriptor.canSetProperty(object)) {
      return null;
    }
    CellEditor result = null;
    
    Object genericFeature = itemPropertyDescriptor.getFeature(object);
    if ((genericFeature instanceof EReference[]))
    {
      result = new ExtendedComboBoxCellEditor(
        composite, 
        new ArrayList(itemPropertyDescriptor.getChoiceOfValues(object)), 
        getEditLabelProvider(), 
        itemPropertyDescriptor.isSortChoices(object));
    }
    else if ((genericFeature instanceof EStructuralFeature))
    {
      final EStructuralFeature feature = (EStructuralFeature)genericFeature;
      EClassifier eType = feature.getEType();
      final Collection<?> choiceOfValues = itemPropertyDescriptor.getChoiceOfValues(object);
      if (choiceOfValues != null)
      {
        if (itemPropertyDescriptor.isMany(object))
        {
          boolean valid = true;
          for (Object choice : choiceOfValues) {
            if (!eType.isInstance(choice))
            {
              valid = false;
              break;
            }
          }
          if (valid)
          {
            final ILabelProvider editLabelProvider = getEditLabelProvider();
            result = 
              new ExtendedDialogCellEditor(composite, editLabelProvider)
              {
                protected Object openDialogBox(Control cellEditorWindow)
                {
                  FeatureEditorDialog dialog = new FeatureEditorDialog(
                    cellEditorWindow.getShell(), 
                    editLabelProvider, 
                    object, 
                    feature.getEType(), 
                    (List)doGetValue(), 
                    getDisplayName(), 
                    new ArrayList(choiceOfValues), 
                    false, 
                    itemPropertyDescriptor.isSortChoices(object), 
                    feature.isUnique());
                  dialog.open();
                  return dialog.getResult();
                }
              };
            }
          }
          if (result == null) {
            result = 
              new ExtendedComboBoxCellEditor(
              composite, new ArrayList(choiceOfValues), getEditLabelProvider(), itemPropertyDescriptor.isSortChoices(object));
          }
        }
        else if ((eType instanceof EDataType))
        {
          EDataType eDataType = (EDataType)eType;
          if (eDataType.isSerializable()) {
            if (itemPropertyDescriptor.isMany(object))
            {
              final ILabelProvider editLabelProvider = getEditLabelProvider();
              result = 
                new ExtendedDialogCellEditor(composite, editLabelProvider)
                {
                  protected Object openDialogBox(Control cellEditorWindow)
                  {
                    FeatureEditorDialog dialog = new FeatureEditorDialog(
                      cellEditorWindow.getShell(), 
                      editLabelProvider, 
                      object, 
                      feature.getEType(), 
                      (List)doGetValue(), 
                      getDisplayName(), 
                      null, 
                      itemPropertyDescriptor.isMultiLine(object), 
                      false, 
                      feature.isUnique());
                    dialog.open();
                    return dialog.getResult();
                  }
                };
              }
              else if ((eDataType.getInstanceClass() == Boolean.class) || (eDataType.getInstanceClass() == Boolean.TYPE))
              {
                result = new ExtendedComboBoxCellEditor(
                  composite, 
                  Arrays.asList(new Object[] { Boolean.FALSE, Boolean.TRUE }), 
                  getEditLabelProvider(), 
                  itemPropertyDescriptor.isSortChoices(object));
              }
              else
              {
                result = createEDataTypeCellEditor(eDataType, composite);
              }
            }
          }
        }
        return result;
      }
    }

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.PropertyDescriptor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;

public class PropertySource
  implements IPropertySource
{
  protected Object object;
  protected IItemPropertySource itemPropertySource;
  
  public PropertySource(Object object, IItemPropertySource itemPropertySource)
  {
    this.object = object;
    this.itemPropertySource = itemPropertySource;
  }
  
  public Object getEditableValue()
  {
    return itemPropertySource.getEditableValue(object);
  }
  
  public IPropertyDescriptor[] getPropertyDescriptors()
  {
    Collection<IPropertyDescriptor> result = new ArrayList();
    List<IItemPropertyDescriptor> itemPropertyDescriptors = itemPropertySource.getPropertyDescriptors(object);
    if (itemPropertyDescriptors != null) {
      for (IItemPropertyDescriptor itemPropertyDescriptor : itemPropertyDescriptors) {
        result.add(createPropertyDescriptor(itemPropertyDescriptor));
      }
    }
    return (IPropertyDescriptor[])result.toArray(new IPropertyDescriptor[result.size()]);
  }
  
  protected IPropertyDescriptor createPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor)
  {
    return new PropertyDescriptor(object, itemPropertyDescriptor);
  }
  
  public Object getPropertyValue(Object propertyId)
  {
    return itemPropertySource.getPropertyDescriptor(object, propertyId).getPropertyValue(object);
  }
  
  public boolean isPropertySet(Object propertyId)
  {
    return itemPropertySource.getPropertyDescriptor(object, propertyId).isPropertySet(object);
  }
  
  public void resetPropertyValue(Object propertyId)
  {
    itemPropertySource.getPropertyDescriptor(object, propertyId).resetPropertyValue(object);
  }
  
  public void setPropertyValue(Object propertyId, Object value)
  {
    itemPropertySource.getPropertyDescriptor(object, propertyId).setPropertyValue(object, value);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.PropertySource
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.ImageData;

class URLImageDescriptor
  extends ImageDescriptor
{
  protected URL url;
  protected String key1;
  protected String key2;
  
  URLImageDescriptor(URL url, String key1, String key2)
  {
    this.url = url;
    this.key1 = key1;
    this.key2 = key2;
  }
  
  public ImageData getImageData()
  {
    InputStream in = null;
    try
    {
      ImageData localImageData;
      if (key1 != null)
      {
        ImageDataSynthesizer imageDataSynthesizer = new ImageDataSynthesizer(url);
        in = imageDataSynthesizer.generateGIF(key1, key2);
        return new ImageData(in);
      }
      in = url.openStream();
      
      return new ImageData(in);
    }
    catch (IOException e)
    {
      return null;
    }
    finally
    {
      if (in != null) {
        try
        {
          in.close();
        }
        catch (IOException e)
        {
          return null;
        }
      }
    }
  }
  
  protected InputStream getStream()
    throws IOException
  {
    return url.openStream();
  }
  
  public int hashCode()
  {
    return url.hashCode() | (key1 == null ? 0 : key1.hashCode()) | (key2 == null ? 0 : key2.hashCode());
  }
  
  public boolean equals(Object that)
  {
    if ((that instanceof URLImageDescriptor))
    {
      URLImageDescriptor otherURLImageDescriptor = (URLImageDescriptor)that;
      
      return (url.equals(url)) && (key1 == null ? key1 == null : key1.equals(key1)) && (key2 == null ? key2 == null : key2.equals(key2));
    }
    return false;
  }
  
  public String toString()
  {
    return getClass().getName() + "(" + url + "#" + key1 + "/" + key2 + ")";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.URLImageDescriptor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;

class UnwrappingSelectionProvider$1
  implements ISelectionChangedListener
{
  UnwrappingSelectionProvider$1(UnwrappingSelectionProvider paramUnwrappingSelectionProvider) {}
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    this$0.setSelection(event.getSelection());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import java.util.List;
import org.eclipse.emf.common.util.UniqueEList.FastCompare;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
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.StructuredSelection;

public class UnwrappingSelectionProvider
  implements ISelectionProvider
{
  protected ISelection selection;
  protected List<ISelectionChangedListener> listeners = new UniqueEList.FastCompare();
  protected ISelectionChangedListener selectionChangedListener = new ISelectionChangedListener()
  {
    public void selectionChanged(SelectionChangedEvent event)
    {
      setSelection(event.getSelection());
    }
  };
  
  public UnwrappingSelectionProvider(ISelectionProvider selectionProvider)
  {
    selectionProvider.addSelectionChangedListener(selectionChangedListener);
    setSelection(selectionProvider.getSelection());
  }
  
  public void addSelectionChangedListener(ISelectionChangedListener listener)
  {
    listeners.add(listener);
  }
  
  public ISelection getSelection()
  {
    return selection;
  }
  
  public void removeSelectionChangedListener(ISelectionChangedListener listener)
  {
    listeners.remove(listener);
  }
  
  public void setSelection(ISelection selection)
  {
    if ((selection instanceof IStructuredSelection))
    {
      Object[] objects = ((IStructuredSelection)selection).toArray();
      for (int i = 0; i < objects.length; i++) {
        objects[i] = unwrap(objects[i]);
      }
      this.selection = new StructuredSelection(objects);
    }
    else
    {
      this.selection = selection;
    }
    fireSelectionChanged();
  }
  
  protected Object unwrap(Object object)
  {
    return AdapterFactoryEditingDomain.unwrap(object);
  }
  
  protected void fireSelectionChanged()
  {
    for (ISelectionChangedListener selectionChangedListener : listeners) {
      selectionChangedListener.selectionChanged(new SelectionChangedEvent(this, selection));
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.util;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.common.ui.MarkerHelper;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.Resource.Diagnostic;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.URIConverter;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin.Implementation;

public class EditUIMarkerHelper
  extends MarkerHelper
{
  protected IFile getFile(Object datum)
  {
    if ((datum instanceof Resource))
    {
      Resource resource = (Resource)datum;
      URI uri = resource.getURI();
      uri = resource.getResourceSet().getURIConverter().normalize(uri);
      return getFile(uri);
    }
    if ((datum instanceof EObject)) {
      return getFile(((EObject)datum).eResource());
    }
    if ((datum instanceof Resource.Diagnostic))
    {
      String location = ((Resource.Diagnostic)datum).getLocation();
      if (location != null) {
        return getFile(URI.createURI(location));
      }
    }
    return super.getFile(datum);
  }
  
  protected void adjustMarker(IMarker marker, Diagnostic diagnostic, Diagnostic parentDiagnostic)
    throws CoreException
  {
    if ((!adjustMarker(marker, diagnostic)) && (parentDiagnostic != null)) {
      adjustMarker(marker, parentDiagnostic);
    }
  }
  
  protected boolean adjustMarker(IMarker marker, Diagnostic diagnostic)
    throws CoreException
  {
    if (diagnostic.getData() != null) {
      for (Object element : diagnostic.getData()) {
        if ((element instanceof Resource.Diagnostic))
        {
          Resource.Diagnostic resourceDiagnostic = (Resource.Diagnostic)element;
          if (resourceDiagnostic.getLocation() != null)
          {
            marker.setAttribute(
              "location", 
              EMFEditUIPlugin.getPlugin().getString(
              "_UI_MarkerLocation", 
              
              new String[] {
              Integer.toString(resourceDiagnostic.getLine()), 
              Integer.toString(resourceDiagnostic.getColumn()) }));
            
            marker.setAttribute("lineNumber", resourceDiagnostic.getLine());
            return true;
          }
        }
      }
    }
    return false;
  }
  
  public boolean hasMarkers(Object object, boolean includeSubtypes, int depth)
  {
    int i;
    if ((object instanceof ResourceSet))
    {
      ResourceSet resourceSet = (ResourceSet)object;
      List<Resource> resources = resourceSet.getResources();
      i = 0;
      for (int size = resources.size(); i < size; i++) {
        if (hasMarkers(resources.get(i), includeSubtypes, depth)) {
          return true;
        }
      }
      return false;
    }
    if ((object instanceof Diagnostic))
    {
      List<?> data = ((Diagnostic)object).getData();
      if (data != null) {
        for (Object datum : data) {
          if ((datum instanceof ResourceSet)) {
            return hasMarkers(datum, includeSubtypes, depth);
          }
        }
      }
    }
    return super.hasMarkers(object, includeSubtypes, depth);
  }
  
  public void deleteMarkers(Object object, boolean includeSubtypes, int depth)
  {
    int i;
    if ((object instanceof ResourceSet))
    {
      ResourceSet resourceSet = (ResourceSet)object;
      List<Resource> resources = resourceSet.getResources();
      i = 0;
      for (int size = resources.size(); i < size; i++) {
        deleteMarkers(resources.get(i), includeSubtypes, depth);
      }
    }
    else if ((object instanceof Diagnostic))
    {
      List<?> data = ((Diagnostic)object).getData();
      if (data != null) {
        for (Object datum : data) {
          if ((datum instanceof ResourceSet))
          {
            deleteMarkers(datum, includeSubtypes, depth);
            return;
          }
        }
      }
    }
    super.deleteMarkers(object, includeSubtypes, depth);
  }
  
  public List<?> getTargetObjects(Object object, IMarker marker)
  {
    if ((object instanceof AdapterFactoryEditingDomain))
    {
      ArrayList<Object> result = new ArrayList();
      AdapterFactoryEditingDomain editingDomain = (AdapterFactoryEditingDomain)object;
      String uriAttribute = marker.getAttribute("uri", null);
      if (uriAttribute != null)
      {
        URI uri = URI.createURI(uriAttribute);
        EObject eObject = editingDomain.getResourceSet().getEObject(uri, true);
        if (eObject != null) {
          result.add(editingDomain.getWrapper(eObject));
        }
      }
      String relatedURIsAttribute = marker.getAttribute("relatedURIs", null);
      if (relatedURIsAttribute != null)
      {
        String[] arrayOfString;
        int j = (arrayOfString = relatedURIsAttribute.split(" ")).length;
        for (int i = 0; i < j; i++)
        {
          String relatedURI = arrayOfString[i];
          
          URI uri = URI.createURI(URI.decode(relatedURI));
          EObject eObject = editingDomain.getResourceSet().getEObject(uri, true);
          if (eObject != null) {
            result.add(editingDomain.getWrapper(eObject));
          }
        }
      }
      return result;
    }
    return super.getTargetObjects(object, marker);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.util.EditUIMarkerHelper
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.util;

import java.lang.reflect.Method;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IURIEditorInput;
import org.eclipse.ui.part.FileEditorInput;
import org.osgi.framework.Bundle;

class EditUIUtil$EclipseUtil
{
  static final Class<?> FILE_CLASS;
  static final Class<?> FILE_REVISION_CLASS;
  static final Method FILE_REVISION_GET_URI_METHOD;
  static final Class<?> URI_EDITOR_INPUT_CLASS;
  
  static
  {
    Class<?> fileClass = null;
    try
    {
      fileClass = IFile.class;
    }
    catch (Throwable localThrowable) {}
    FILE_CLASS = fileClass;
    
    Class<?> fileRevisionClass = null;
    Method fileRevisionGetURIMethod = null;
    Bundle bundle = Platform.getBundle("org.eclipse.team.core");
    if ((bundle != null) && ((bundle.getState() & 0x2C) != 0)) {
      try
      {
        fileRevisionClass = bundle.loadClass("org.eclipse.team.core.history.IFileRevision");
        fileRevisionGetURIMethod = fileRevisionClass.getMethod("getURI", new Class[0]);
      }
      catch (Throwable localThrowable1) {}
    }
    FILE_REVISION_CLASS = fileRevisionClass;
    FILE_REVISION_GET_URI_METHOD = fileRevisionGetURIMethod;
    
    Class<?> uriEditorInputClass = null;
    try
    {
      uriEditorInputClass = IURIEditorInput.class;
    }
    catch (Throwable localThrowable2) {}
    URI_EDITOR_INPUT_CLASS = uriEditorInputClass;
  }
  
  public static org.eclipse.emf.common.util.URI getURI(IEditorInput editorInput)
  {
    if (FILE_CLASS != null)
    {
      IFile file = (IFile)editorInput.getAdapter(FILE_CLASS);
      if (file != null) {
        return org.eclipse.emf.common.util.URI.createPlatformResourceURI(file.getFullPath().toString(), true);
      }
    }
    if (FILE_REVISION_CLASS != null)
    {
      Object fileRevision = editorInput.getAdapter(FILE_REVISION_CLASS);
      if (fileRevision != null) {
        try
        {
          return org.eclipse.emf.common.util.URI.createURI(((java.net.URI)FILE_REVISION_GET_URI_METHOD.invoke(fileRevision, new Object[0])).toString());
        }
        catch (Throwable exception)
        {
          EMFEditUIPlugin.INSTANCE.log(exception);
        }
      }
    }
    if (URI_EDITOR_INPUT_CLASS != null) {
      if ((editorInput instanceof IURIEditorInput)) {
        return org.eclipse.emf.common.util.URI.createURI(((IURIEditorInput)editorInput).getURI().toString()).trimFragment();
      }
    }
    return null;
  }
  
  public static IEditorInput createFileEditorInput(IFile file)
  {
    return new FileEditorInput(file);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.util.EditUIUtil.EclipseUtil
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.util;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.ui.URIEditorInput;
import org.eclipse.emf.common.util.UniqueEList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.URIConverter;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.IURIEditorInput;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
import org.osgi.framework.Bundle;

public class EditUIUtil
{
  public static boolean openEditor(EObject eObject)
    throws PartInitException
  {
    if (eObject != null)
    {
      Resource resource = eObject.eResource();
      if (resource != null)
      {
        org.eclipse.emf.common.util.URI uri = resource.getURI();
        if (uri != null)
        {
          IEditorInput editorInput = null;
          if (uri.isPlatformResource())
          {
            String path = uri.toPlatformString(true);
            IResource workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(path));
            if ((workspaceResource instanceof IFile)) {
              editorInput = EclipseUtil.createFileEditorInput((IFile)workspaceResource);
            }
          }
          else
          {
            editorInput = new URIEditorInput(uri);
          }
          if (editorInput != null)
          {
            IWorkbench workbench = PlatformUI.getWorkbench();
            IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
            IEditorPart editorPart = page.openEditor(editorInput, workbench.getEditorRegistry().getDefaultEditor(uri.lastSegment()).getId());
            return editorPart != null;
          }
        }
      }
    }
    return false;
  }
  
  public static org.eclipse.emf.common.util.URI getURI(IEditorInput editorInput)
  {
    org.eclipse.emf.common.util.URI result = null;
    if (EMFPlugin.IS_ECLIPSE_RUNNING) {
      result = EclipseUtil.getURI(editorInput);
    }
    if (result == null) {
      if ((editorInput instanceof URIEditorInput)) {
        result = ((URIEditorInput)editorInput).getURI().trimFragment();
      } else {
        result = org.eclipse.emf.common.util.URI.createURI(editorInput.getName());
      }
    }
 
1 2 3 4 5 6 7 8

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-2019. Infinite Loop Ltd