org.eclipse.pde.ds.ui_1.0.100.v20111213-1754

6(this$0, DSComponentSection.access$1(this$0).getModel()
          .getFactory().createImplementation());
        DSComponentSection.access$5(this$0).setClassName(DSComponentSection.access$7(this$0)
          .getValue());
        DSComponentSection.access$1(this$0).addChildNode(DSComponentSection.access$5(this$0), 0, 
          true);
      }
    }
    else {
      DSComponentSection.access$5(this$0).setClassName(DSComponentSection.access$7(this$0).getValue());
    }
  }
  
  public void linkActivated(HyperlinkEvent e)
  {
    String value = DSComponentSection.access$7(this$0).getValue();
    value = DSComponentSection.access$8(this$0, value, false);
    if (value != null) {
      DSComponentSection.access$7(this$0).setValue(value);
    }
  }
  
  public void browseButtonSelected(FormEntry entry)
  {
    DSComponentSection.access$9(this$0, 
      DSComponentSection.access$7(this$0));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.ds.ui.editor.sections.DSComponentSection.6
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.ds.ui.editor.sections;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.pde.core.IModelChangedEvent;
import org.eclipse.pde.internal.ds.core.IDSComponent;
import org.eclipse.pde.internal.ds.core.IDSDocumentFactory;
import org.eclipse.pde.internal.ds.core.IDSImplementation;
import org.eclipse.pde.internal.ds.core.IDSModel;
import org.eclipse.pde.internal.ds.ui.Activator;
import org.eclipse.pde.internal.ds.ui.Messages;
import org.eclipse.pde.internal.ds.ui.SWTUtil;
import org.eclipse.pde.internal.ds.ui.editor.FormEntryAdapter;
import org.eclipse.pde.internal.ds.ui.editor.FormLayoutFactory;
import org.eclipse.pde.internal.ds.ui.parts.FormEntry;
import org.eclipse.pde.internal.ds.ui.wizards.DSNewClassCreationWizard;
import org.eclipse.pde.internal.ui.editor.IContextPart;
import org.eclipse.pde.internal.ui.editor.PDEFormPage;
import org.eclipse.pde.internal.ui.editor.PDESection;
import org.eclipse.pde.internal.ui.util.PDEJavaHelperUI;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;

public class DSComponentSection
  extends PDESection
{
  private IDSComponent fComponent;
  private IDSImplementation fImplementation;
  private FormEntry fClassEntry;
  private FormEntry fNameEntry;
  private FormEntry fActivateEntry;
  private FormEntry fDeactivateEntry;
  private FormEntry fModifiedEntry;
  private IDSModel fModel;
  
  public DSComponentSection(PDEFormPage page, Composite parent)
  {
    super(page, parent, 128);
    createClient(getSection(), page.getEditor().getToolkit());
  }
  
  protected void createClient(Section section, FormToolkit toolkit)
  {
    initializeAttributes();
    
    section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
    GridData data = new GridData(768);
    horizontalSpan = 2;
    section.setLayoutData(data);
    section.setText(Messages.DSSection_title);
    section.setDescription(Messages.DSSection_description);
    
    Composite client = toolkit.createComposite(section);
    client.setLayout(new GridLayout(3, false));
    client.setLayoutData(new GridData(768));
    
    fNameEntry = new FormEntry(client, toolkit, 
      Messages.DSComponentDetails_nameEntry, 0);
    
    fClassEntry = new FormEntry(client, toolkit, 
      Messages.DSImplementationDetails_classEntry, 
      Messages.DSImplementationDetails_browse, isEditable(), 0);
    
    fActivateEntry = new FormEntry(client, toolkit, 
      Messages.DSComponentDetails_activateEntry, 0);
    fActivateEntry.getLabel().setToolTipText(
      Messages.DSComponentDetails_activateTooltip);
    
    fDeactivateEntry = new FormEntry(client, toolkit, 
      Messages.DSComponentDetails_deactivateEntry, 0);
    fDeactivateEntry.getLabel().setToolTipText(
      Messages.DSComponentDetails_deactivateTooltip);
    
    fModifiedEntry = new FormEntry(client, toolkit, 
      Messages.DSComponentDetails_modifiedEntry, 0);
    fModifiedEntry.getLabel().setToolTipText(
      Messages.DSComponentDetails_modifiedTooltip);
    
    setListeners();
    updateUIFields();
    
    toolkit.paintBordersFor(client);
    section.setClient(client);
  }
  
  private void initializeAttributes()
  {
    fModel = ((IDSModel)getPage().getModel());
    fModel.addModelChangedListener(this);
    
    fComponent = fModel.getDSComponent();
    if (fComponent != null) {
      fImplementation = fComponent.getImplementation();
    }
  }
  
  public void commit(boolean onSave)
  {
    fClassEntry.commit();
    fNameEntry.commit();
    fActivateEntry.commit();
    fDeactivateEntry.commit();
    fModifiedEntry.commit();
    super.commit(onSave);
  }
  
  public void modelChanged(IModelChangedEvent e)
  {
    fComponent = fModel.getDSComponent();
    if (fComponent != null) {
      fImplementation = fComponent.getImplementation();
    }
    if (e.getChangeType() == 99) {
      markStale();
    }
    if (fNameEntry != null)
    {
      Display display = fNameEntry.getText().getDisplay();
      if (display.getThread() == Thread.currentThread()) {
        updateUIFields();
      } else {
        display.asyncExec(new Runnable()
        {
          public void run()
          {
            if (!fNameEntry.getText().isDisposed()) {
              updateUIFields();
            }
          }
        });
      }
    }
  }
  
  public void updateUIFields()
  {
    if (fComponent != null)
    {
      if (fComponent.getAttributeName() == null) {
        fNameEntry.setValue("", true);
      } else {
        fNameEntry.setValue(fComponent.getAttributeName(), true);
      }
      fNameEntry.setEditable(isEditable());
      if (fComponent.getActivateMethod() == null) {
        fActivateEntry.setValue("", true);
      } else {
        fActivateEntry.setValue(fComponent.getActivateMethod(), true);
      }
      fActivateEntry.setEditable(isEditable());
      if (fComponent.getDeactivateMethod() == null) {
        fDeactivateEntry.setValue("", true);
      } else {
        fDeactivateEntry.setValue(fComponent.getDeactivateMethod(), 
          true);
      }
      fDeactivateEntry.setEditable(isEditable());
      if (fComponent.getModifiedMethod() == null) {
        fModifiedEntry.setValue("", true);
      } else {
        fModifiedEntry.setValue(fComponent.getModifiedMethod(), true);
      }
      fModifiedEntry.setEditable(isEditable());
    }
    if (fImplementation != null)
    {
      if (fImplementation.getClassName() == null) {
        fClassEntry.setValue("", true);
      } else {
        fClassEntry.setValue(fImplementation.getClassName(), true);
      }
      fClassEntry.setEditable(isEditable());
    }
  }
  
  public void setListeners()
  {
    fNameEntry.setFormEntryListener(new FormEntryAdapter(this)
    {
      public void textValueChanged(FormEntry entry)
      {
        if (fComponent == null) {
          return;
        }
        fComponent.setAttributeName(fNameEntry.getValue());
      }
    });
    fActivateEntry.setFormEntryListener(new FormEntryAdapter(this)
    {
      public void textValueChanged(FormEntry entry)
      {
        if (fComponent == null) {
          return;
        }
        fComponent.setActivateMethod(fActivateEntry.getValue());
      }
    });
    fDeactivateEntry.setFormEntryListener(new FormEntryAdapter(this)
    {
      public void textValueChanged(FormEntry entry)
      {
        if (fComponent == null) {
          return;
        }
        fComponent.setDeactivateMethod(fDeactivateEntry.getValue());
      }
    });
    fModifiedEntry.setFormEntryListener(new FormEntryAdapter(this)
    {
      public void textValueChanged(FormEntry entry)
      {
        if (fComponent == null) {
          return;
        }
        fComponent.setModifiedeMethod(fModifiedEntry.getValue());
      }
    });
    IActionBars actionBars = getPage().getEditor().getEditorSite()
      .getActionBars();
    
    fClassEntry
      .setFormEntryListener(new FormEntryAdapter(this, actionBars)
      {
        public void textValueChanged(FormEntry entry)
        {
          if (fImplementation == null)
          {
            if (fComponent != null)
            {
              fImplementation = fComponent.getModel()
                .getFactory().createImplementation();
              fImplementation.setClassName(fClassEntry
                .getValue());
              fComponent.addChildNode(fImplementation, 0, 
                true);
            }
          }
          else {
            fImplementation.setClassName(fClassEntry.getValue());
          }
        }
        
        public void linkActivated(HyperlinkEvent e)
        {
          String value = fClassEntry.getValue();
          value = DSComponentSection.this.handleLinkActivated(value, false);
          if (value != null) {
            fClassEntry.setValue(value);
          }
        }
        
        public void browseButtonSelected(FormEntry entry)
        {
          DSComponentSection.this.doOpenSelectionDialog(
            fClassEntry);
        }
      });
  }
  
  private String handleLinkActivated(String value, boolean isInter)
  {
    IProject project = getProject();
    try
    {
      if ((project != null) && (project.hasNature("org.eclipse.jdt.core.javanature")))
      {
        IJavaProject javaProject = JavaCore.create(project);
        IJavaElement element = javaProject.findType(value.replace('$', 
          '.'));
        if (element != null)
        {
          JavaUI.openInEditor(element);
        }
        else
        {
          DSNewClassCreationWizard wizard = new DSNewClassCreationWizard(
            project, isInter, value);
          WizardDialog dialog = new WizardDialog(
            Activator.getActiveWorkbenchShell(), wizard);
          dialog.create();
          SWTUtil.setDialogSize(dialog, 400, 500);
          if (dialog.open() == 0) {
            return wizard.getQualifiedName();
          }
        }
      }
    }
    catch (PartInitException localPartInitException) {}catch (CoreException localCoreException) {}
    return null;
  }
  
  private void doOpenSelectionDialog(FormEntry entry)
  {
    String filter = entry.getValue();
    if (filter.length() == 0) {
      filter = "**";
    } else {
      filter = filter.substring(filter.lastIndexOf(".") + 1);
    }
    String type = PDEJavaHelperUI.selectType(
      fModel.getUnderlyingResource(), 
      2, filter, null);
    if (type != null)
    {
      entry.setValue(type);
      entry.commit();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.ds.ui.editor.sections.DSComponentSection
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.ds.ui.editor.sections;

import org.eclipse.pde.internal.ds.core.IDSComponent;
import org.eclipse.pde.internal.ds.core.IDSModel;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;

class DSOptionsSection$1
  extends SelectionAdapter
{
  final DSOptionsSection this$0;
  
  DSOptionsSection$1(DSOptionsSection paramDSOptionsSection)
  {
    this$0 = paramDSOptionsSection;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    DSOptionsSection.access$0(this$0).getDSComponent().setEnabled(
      DSOptionsSection.access$1(this$0).getSelection());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.ds.ui.editor.sections.DSOptionsSection.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.ds.ui.editor.sections;

import org.eclipse.pde.internal.ds.core.IDSComponent;
import org.eclipse.pde.internal.ds.core.IDSModel;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;

class DSOptionsSection$2
  extends SelectionAdapter
{
  final DSOptionsSection this$0;
  
  DSOptionsSection$2(DSOptionsSection paramDSOptionsSection)
  {
    this$0 = paramDSOptionsSection;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    DSOptionsSection.access$0(this$0).getDSComponent().setImmediate(
      DSOptionsSection.access$2(this$0).getSelection());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.ds.ui.editor.sections.DSOptionsSection.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.ds.ui.editor.sections;

import org.eclipse.swt.widgets.Button;

class DSOptionsSection$3
  implements Runnable
{
  final DSOptionsSection this$0;
  
  DSOptionsSection$3(DSOptionsSection paramDSOptionsSection)
  {
    this$0 = paramDSOptionsSection;
  }
  
  public void run()
  {
    if (!DSOptionsSection.access$1(this$0).isDisposed()) {
      this$0.updateUIFields();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.ds.ui.editor.sections.DSOptionsSection.3
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.ds.ui.editor.sections;

import org.eclipse.pde.internal.ds.core.IDSComponent;
import org.eclipse.pde.internal.ds.ui.editor.FormEntryAdapter;
import org.eclipse.pde.internal.ds.ui.parts.FormEntry;
import org.eclipse.pde.internal.ui.editor.IContextPart;

class DSOptionsSection$4
  extends FormEntryAdapter
{
  final DSOptionsSection this$0;
  
  DSOptionsSection$4(DSOptionsSection paramDSOptionsSection, IContextPart $anonymous0)
  {
    super($anonymous0);this$0 = paramDSOptionsSection;
  }
  
  public void textValueChanged(FormEntry entry)
  {
    if (DSOptionsSection.access$3(this$0) == null) {
      return;
    }
    DSOptionsSection.access$3(this$0).setFactory(DSOptionsSection.access$4(this$0).getValue());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.ds.ui.editor.sections.DSOptionsSection.4
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.ds.ui.editor.sections;

import org.eclipse.pde.internal.ds.core.IDSComponent;
import org.eclipse.pde.internal.ds.ui.parts.ComboPart;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;

class DSOptionsSection$5
  implements ModifyListener
{
  final DSOptionsSection this$0;
  
  DSOptionsSection$5(DSOptionsSection paramDSOptionsSection)
  {
    this$0 = paramDSOptionsSection;
  }
  
  public void modifyText(ModifyEvent e)
  {
    if (DSOptionsSection.access$3(this$0) == null) {
      return;
    }
    DSOptionsSection.access$3(this$0).setConfigurationPolicy(DSOptionsSection.access$5(this$0)
      .getSelection());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.ds.ui.editor.sections.DSOptionsSection.5
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.ds.ui.editor.sections;

import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.pde.core.IModelChangedEvent;
import org.eclipse.pde.internal.ds.core.IDSComponent;
import org.eclipse.pde.internal.ds.core.IDSModel;
import org.eclipse.pde.internal.ds.core.IDSProvide;
import org.eclipse.pde.internal.ds.core.IDSService;
import org.eclipse.pde.internal.ds.ui.Messages;
import org.eclipse.pde.internal.ds.ui.editor.FormEntryAdapter;
import org.eclipse.pde.internal.ds.ui.editor.FormLayoutFactory;
import org.eclipse.pde.internal.ds.ui.parts.ComboPart;
import org.eclipse.pde.internal.ds.ui.parts.FormEntry;
import org.eclipse.pde.internal.ui.editor.IContextPart;
import org.eclipse.pde.internal.ui.editor.PDEFormPage;
import org.eclipse.pde.internal.ui.editor.PDESection;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
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.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.FormColors;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;

public class DSOptionsSection
  extends PDESection
{
  private IDSComponent fComponent;
  private FormEntry fFactoryEntry;
  private IDSModel fModel;
  private Button fImmediateButton;
  private Button fEnabledButton;
  private ComboPart fConfigurationPolicy;
  
  public DSOptionsSection(PDEFormPage page, Composite parent)
  {
    super(page, parent, 128);
    createClient(getSection(), page.getEditor().getToolkit());
  }
  
  protected void createClient(Section section, FormToolkit toolkit)
  {
    initializeAttributes();
    
    section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
    GridData data = new GridData(768);
    horizontalSpan = 2;
    section.setLayoutData(data);
    section.setText(Messages.DSOptionsSection_title);
    section.setDescription(Messages.DSOptionsSection_description);
    
    Composite client = toolkit.createComposite(section);
    client.setLayout(new GridLayout(3, false));
    client.setLayoutData(new GridData(768));
    
    fFactoryEntry = new FormEntry(client, toolkit, 
      Messages.DSComponentDetails_factoryEntry, 0);
    
    Label label = toolkit.createLabel(client, 
      Messages.DSComponentDetails_configurationPolicy, 
      64);
    label.setForeground(toolkit.getColors().getColor(
      "org.eclipse.ui.forms.TITLE"));
    fConfigurationPolicy = new ComboPart();
    fConfigurationPolicy.createControl(client, toolkit, 8);
    
    String[] items = {
      "", 
      "optional", 
      "require", 
      "ignore" };
    fConfigurationPolicy.setItems(items);
    GridDataFactory.fillDefaults().grab(true, false).indent(3, 0).applyTo(
      fConfigurationPolicy.getControl());
    
    createButtons(client, toolkit);
    
    setListeners();
    updateUIFields();
    
    toolkit.paintBordersFor(client);
    section.setClient(client);
  }
  
  private void createButtons(Composite parent, FormToolkit toolkit)
  {
    fEnabledButton = toolkit.createButton(parent, 
      Messages.DSServiceComponentSection_enabledButtonMessage, 
      32);
    GridData data = new GridData(768);
    horizontalSpan = 2;
    fEnabledButton.setLayoutData(data);
    fEnabledButton.setEnabled(isEditable());
    fEnabledButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        fModel.getDSComponent().setEnabled(
          fEnabledButton.getSelection());
      }
    });
    fImmediateButton = toolkit.createButton(parent, 
      Messages.DSServiceComponentSection_immediateButtonMessage, 
      32);
    fImmediateButton.setLayoutData(data);
    fImmediateButton.setEnabled(isEditable());
    fImmediateButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        fModel.getDSComponent().setImmediate(
          fImmediateButton.getSelection());
      }
    });
  }
  
  private void initializeAttributes()
  {
    fModel = ((IDSModel)getPage().getModel());
    fModel.addModelChangedListener(this);
    fComponent = fModel.getDSComponent();
  }
  
  public void commit(boolean onSave)
  {
    fFactoryEntry.commit();
    super.commit(onSave);
  }
  
  public void modelChanged(IModelChangedEvent e)
  {
    fComponent = fModel.getDSComponent();
    if (e.getChangeType() == 99) {
      markStale();
    }
    Display display = fEnabledButton.getDisplay();
    if (display.getThread() == Thread.currentThread()) {
      updateUIFields();
    } else {
      display.asyncExec(new Runnable()
      {
        public void run()
        {
          if (!fEnabledButton.isDisposed()) {
            updateUIFields();
          }
        }
      });
    }
  }
  
  public void updateUIFields()
  {
    if (fComponent != null)
    {
      if (fComponent.getFactory() == null) {
        fFactoryEntry.setValue("", true);
      } else {
        fFactoryEntry.setValue(fComponent.getFactory(), true);
      }
      fEnabledButton.setSelection(fComponent.getEnabled());
      fImmediateButton.setSelection(fComponent.getImmediate());
      enableOrDisableImmediate();
      if (fComponent.getConfigurationPolicy() != null) {
        fConfigurationPolicy.setText(fComponent
          .getConfigurationPolicy());
      }
    }
  }
  
  private void enableOrDisableImmediate()
  {
    boolean isService = false;
    boolean isFactory = (fComponent.getFactory() != null) && 
      (!fComponent.getFactory().equals(""));
    boolean isImmediate = fComponent.getImmediate();
    boolean enabled = true;
    if (fComponent.getService() != null)
    {
      IDSProvide[] providedServices = fComponent.getService()
        .getProvidedServices();
      if ((providedServices != null) && (providedServices.length > 0)) {
        isService = true;
      }
    }
    if ((!isService) && (!isFactory) && (!isImmediate)) {
      enabled = false;
    }
    fImmediateButton.setEnabled(enabled);
  }
  
  public void setListeners()
  {
    fFactoryEntry.setFormEntryListener(new FormEntryAdapter(this)
    {
      public void textValueChanged(FormEntry entry)
      {
        if (fComponent == null) {
          return;
        }
        fComponent.setFactory(fFactoryEntry.getValue());
      }
    });
    fConfigurationPolicy.addModifyListener(new ModifyListener()
    {
      public void modifyText(ModifyEvent e)
      {
        if (fComponent == null) {
          return;
        }
        fComponent.setConfigurationPolicy(fConfigurationPolicy
          .getSelection());
      }
    });
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.ds.ui.editor.sections.DSOptionsSection
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.ds.ui.editor.sections;

import org.eclipse.jface.action.Action;

class DSPropertiesSection$1
  extends Action
{
  final DSPropertiesSection this$0;
  
  DSPropertiesSection$1(DSPropertiesSection paramDSPropertiesSection, String $anonymous0)
  {
    super($anonymous0);this$0 = paramDSPropertiesSection;
  }
  
  public void run()
  {
    DSPropertiesSection.access$0(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.ds.ui.editor.sections.DSPropertiesSection.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.ds.ui.editor.sections;

import org.eclipse.jface.action.Action;

class DSPropertiesSection$2
  extends Action
{
  final DSPropertiesSection this$0;
  
  DSPropertiesSection$2(DSPropertiesSection paramDSPropertiesSection, String $anonymous0)
  {
    super($anonymous0);this$0 = paramDSPropertiesSection;
  }
  
  public void run()
  {
    DSPropertiesSection.access$1(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.ds.ui.editor.sections.DSPropertiesSection.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.ds.ui.editor.sections;

import org.eclipse.jface.action.Action;

class DSPropertiesSection$3
  extends Action
{
  final DSPropertiesSection this$0;
  
  DSPropertiesSection$3(DSPropertiesSection paramDSPropertiesSection, String $anonymous0)
  {
    super($anonymous0);this$0 = paramDSPropertiesSection;
  }
  
  public void run()
  {
    DSPropertiesSection.access$2(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.ds.ui.editor.sections.DSPropertiesSection.3
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.ds.ui.editor.sections;

import org.eclipse.jface.action.Action;

class DSPropertiesSection$4
  extends Action
{
  final DSPropertiesSection this$0;
  
  DSPropertiesSection$4(DSPropertiesSection paramDSPropertiesSection, String $anonymous0)
  {
    super($anonymous0);this$0 = paramDSPropertiesSection;
  }
  
  public void run()
  {
    DSPropertiesSection.access$3(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.ds.ui.editor.sections.DSPropertiesSection.4
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.ds.ui.editor.sections;

import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;

class DSPropertiesSection$5
  extends ViewerFilter
{
  final DSPropertiesSection this$0;
  private final IProject val$project;
  
  DSPropertiesSection$5(DSPropertiesSection paramDSPropertiesSection, IProject paramIProject)
  {
    this$0 = paramDSPropertiesSection;val$project = paramIProject;
  }
  
  public boolean select(Viewer viewer, Object parentElement, Object element)
  {
    if ((element instanceof IProject)) {
      return ((IProject)element).equals(val$project);
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.ds.ui.editor.sections.DSPropertiesSection.5
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.ds.ui.editor.sections;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.dialogs.ISelectionStatusValidator;

class DSPropertiesSection$6
  implements ISelectionStatusValidator
{
  final DSPropertiesSection this$0;
  
  DSPropertiesSection$6(DSPropertiesSection paramDSPropertiesSection)
  {
    this$0 = paramDSPropertiesSection;
  }
  
  public IStatus validate(Object[] selection)
  {
    if ((selection != null) && (selection.length > 0) && 
      ((selection[0] instanceof IFile))) {
      return new Status(0, "org.eclipse.pde.ds.ui", 
        0, "", null);
    }
    return new Status(4, "org.eclipse.pde.ds.ui", 
      4, "", null);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.ds.ui.editor.sections.DSPropertiesSection.6
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.ds.ui.editor.sections;

import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.widgets.Table;

class DSPropertiesSection$7
  implements Runnable
{
  final DSPropertiesSection this$0;
  
  DSPropertiesSection$7(DSPropertiesSection paramDSPropertiesSection)
  {
    this$0 = paramDSPropertiesSection;
  }
  
  public void run()
  {
    if (!DSPropertiesSection.access$4(this$0).getTable().isDisposed()) {
      DSPropertiesSection.access$5(this$0);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.ds.ui.editor.sections.DSPropertiesSection.7
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.ds.ui.editor.sections;

import org.eclipse.pde.internal.core.text.IDocumentElementNode;
import org.eclipse.pde.internal.ds.core.IDSComponent;
import org.eclipse.pde.internal.ds.core.IDSModel;
import org.eclipse.pde.internal.ds.core.IDSProperties;
import org.eclipse.pde.internal.ds.core.IDSProperty;
import org.eclipse.pde.internal.ui.elements.DefaultTableProvider;

class DSPropertiesSection$ContentProvider
  extends DefaultTableProvider
{
  final DSPropertiesSection this$0;
  
  DSPropertiesSection$ContentProvider(DSPropertiesSection paramDSPropertiesSection)
  {
    this$0 = paramDSPropertiesSection;
  }
  
  public Object[] getElements(Object inputElement)
  {
    if ((inputElement instanceof IDSModel))
    {
      IDSModel model = (IDSModel)inputElement;
      IDSComponent component = model.getDSComponent();
      if (component != null)
      {
        IDocumentElementNode[] childNodes = component
          .getChildNodes();
        
        int propertyLength = 0;
        int propertiesLength = 0;
        if (component.getPropertyElements() != null) {
          propertyLength = component.getPropertyElements().length;
        }
        if (component.getPropertiesElements() != null) {
          propertiesLength = component.getPropertiesElements().length;
        }
        Object[] props = new Object[propertyLength + 
          propertiesLength];
        int index = 0;
        for (int i = 0; i < childNodes.length; i++)
        {
          IDocumentElementNode child = childNodes[i];
          if (((child instanceof IDSProperties)) || 
            ((child instanceof IDSProperty)))
          {
            props[index] = child;
            index++;
          }
        }
        return props;
      }
    }
    return new Object[0];
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.ds.ui.editor.sections.DSPropertiesSection.ContentProvider
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.ds.ui.editor.sections;

import java.util.Iterator;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.core.IModelChangedEvent;
import org.eclipse.pde.internal.core.text.IDocumentElementNode;
import org.eclipse.pde.internal.ds.core.IDSComponent;
import org.eclipse.pde.internal.ds.core.IDSDocumentFactory;
import org.eclipse.pde.internal.ds.core.IDSModel;
import org.eclipse.pde.internal.ds.core.IDSProperties;
import org.eclipse.pde.internal.ds.core.IDSProperty;
import org.eclipse.pde.internal.ds.ui.Activator;
import org.eclipse.pde.internal.ds.ui.Messages;
import org.eclipse.pde.internal.ds.ui.editor.DSInputContext;
import org.eclipse.pde.internal.ds.ui.editor.DSLabelProvider;
import org.eclipse.pde.internal.ds.ui.editor.FormLayoutFactory;
import org.eclipse.pde.internal.ds.ui.editor.dialogs.DSEditPropertiesDialog;
import org.eclipse.pde.internal.ds.ui.editor.dialogs.DSEditPropertyDialog;
import org.eclipse.pde.internal.ui.editor.PDEFormEditor;
import org.eclipse.pde.internal.ui.editor.PDEFormPage;
import org.eclipse.pde.internal.ui.editor.TableSection;
import org.eclipse.pde.internal.ui.editor.context.InputContextManager;
import org.eclipse.pde.internal.ui.elements.DefaultTableProvider;
import org.eclipse.pde.internal.ui.parts.EditableTablePart;
import org.eclipse.pde.internal.ui.parts.TablePart;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.dialogs.ISelectionStatusValidator;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;

public class DSPropertiesSection
  extends TableSection
{
  private TableViewer fPropertiesTable;
  private Action fRemoveAction;
  private Action fAddPropertiesAction;
  private Action fAddPropertyAction;
  private Action fEditAction;
  private static final int F_UP_FLAG = -1;
  private static final int F_DOWN_FLAG = 1;
  
  class ContentProvider
    extends DefaultTableProvider
  {
    ContentProvider() {}
    
    public Object[] getElements(Object inputElement)
    {
      if ((inputElement instanceof IDSModel))
      {
        IDSModel model = (IDSModel)inputElement;
        IDSComponent component = model.getDSComponent();
        if (component != null)
        {
          IDocumentElementNode[] childNodes = component
            .getChildNodes();
          
          int propertyLength = 0;
          int propertiesLength = 0;
          if (component.getPropertyElements() != null) {
            propertyLength = component.getPropertyElements().length;
          }
          if (component.getPropertiesElements() != null) {
            propertiesLength = component.getPropertiesElements().length;
          }
          Object[] props = new Object[propertyLength + 
            propertiesLength];
          int index = 0;
          for (int i = 0; i < childNodes.length; i++)
          {
            IDocumentElementNode child = childNodes[i];
            if (((child instanceof IDSProperties)) || 
              ((child instanceof IDSProperty)))
            {
              props[index] = child;
              index++;
            }
          }
          return props;
        }
      }
      return new Object[0];
    }
  }
  
  public DSPropertiesSection(PDEFormPage page, Composite parent)
  {
    super(page, parent, 128, new String[] { Messages.DSPropertiesSection_addProperties, Messages.DSPropertiesSection_addProperty, Messages.DSPropertiesSection_edit, Messages.DSPropertiesSection_remove, Messages.DSPropertiesSection_up, Messages.DSPropertiesSection_down });
    createClient(getSection(), page.getEditor().getToolkit());
  }
  
  protected void createClient(Section section, FormToolkit toolkit)
  {
    section.setText(Messages.DSPropertiesSection_title);
    section.setDescription(Messages.DSPropertiesSection_description);
    
    section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
    
    GridData data = new GridData(1808);
    horizontalSpan = 2;
    section.setLayoutData(data);
    
    Composite container = createClientContainer(section, 2, toolkit);
    EditableTablePart tablePart = getTablePart();
    tablePart.setEditable(isEditable());
    
    createViewerPartControl(container, 65538, 2, 
      toolkit);
    fPropertiesTable = tablePart.getTableViewer();
    fPropertiesTable.setContentProvider(new ContentProvider());
    fPropertiesTable.setLabelProvider(new DSLabelProvider());
    
    makeActions();
    
    IDSModel model = getDSModel();
    if (model != null)
    {
      fPropertiesTable.setInput(model);
      model.addModelChangedListener(this);
    }
    toolkit.paintBordersFor(container);
    section.setClient(container);
  }
  
  public void dispose()
  {
    IDSModel model = getDSModel();
    if (model != null) {
      model.removeModelChangedListener(this);
    }
  }
  
  public void refresh()
  {
    fPropertiesTable.refresh();
    updateButtons();
    updateTitle();
  }
  
  private void updateTitle()
  {
    int itemCount = fPropertiesTable.getTable().getItemCount();
    getSection().setText(
      NLS.bind(Messages.DSPropertiesSection_title, new Integer(
      itemCount)));
  }
  
  protected void buttonSelected(int index)
  {
    switch (index)
    {
    case 0: 
      handleAddProperties();
      break;
    case 1: 
      handleAddProperty();
      break;
    case 2: 
      handleEdit();
      break;
    case 3: 
      handleRemove();
      break;
    case 4: 
      handleUpDown(-1);
      break;
    case 5: 
      handleUpDown(1);
    }
  }
  
  private void handleUpDown(int newRelativeIndex)
  {
    ISelection sel = fPropertiesTable.getSelection();
    Object[] array = ((IStructuredSelection)sel).toArray();
    if (newRelativeIndex == -1) {
      moveUp(newRelativeIndex, array);
    } else {
      moveDown(newRelativeIndex, array);
    }
  }
  
  private void moveDown(int newRelativeIndex, Object[] array)
  {
    for (int i = array.length - 1; i >= 0; i--)
    {
      Object object = array[i];
      if (object != null) {
        if ((object instanceof IDocumentElementNode)) {
          getDSModel().getDSComponent().moveChildNode(
            (IDocumentElementNode)object, newRelativeIndex, true);
        }
      }
    }
  }
  
  private void moveUp(int newRelativeIndex, Object[] array)
  {
    for (int i = 0; i < array.length; i++)
    {
      Object object = array[i];
      if (object != null) {
        if ((object instanceof IDocumentElementNode)) {
          getDSModel().getDSComponent().moveChildNode(
            (IDocumentElementNode)object, newRelativeIndex, true);
        }
      }
    }
  }
  
  private void handleAddProperty()
  {
    DSEditPropertyDialog dialog = new DSEditPropertyDialog(
      Activator.getActiveWorkbenchShell(), createPropertyElement(), this, true);
    dialog.open();
  }
  
  private void handleEdit()
  {
    ISelection selection = fPropertiesTable.getSelection();
    if (selection != null)
    {
      int selectionIndex = fPropertiesTable.getTable()
        .getSelectionIndex();
      if (selectionIndex != -1)
      {
        Object selectionElement = fPropertiesTable
          .getElementAt(selectionIndex);
        if ((selectionElement instanceof IDSProperties))
        {
          DSEditPropertiesDialog dialog = new DSEditPropertiesDialog(
            Activator.getActiveWorkbenchShell(), 
            (IDSProperties)selectionElement, this);
          dialog.create();
          dialog.getShell().setSize(500, 200);
          dialog.open();
        }
        else if ((selectionElement instanceof IDSProperty))
        {
          DSEditPropertyDialog dialog = new DSEditPropertyDialog(
            Activator.getActiveWorkbenchShell(), 
            (IDSProperty)selectionElement, this, false);
          dialog.create();
          dialog.getShell().setSize(500, 300);
          dialog.open();
        }
      }
    }
  }
  
  private void makeActions()
  {
    fAddPropertiesAction = new Action(
      Messages.DSPropertiesSection_addProperties)
      {
        public void run()
        {
          DSPropertiesSection.this.handleAddProperties();
        }
      };
      fAddPropertiesAction.setEnabled(isEditable());
      
      fAddPropertyAction = new Action(
        Messages.DSPropertiesSection_addProperty)
        {
          public void run()
          {
            DSPropertiesSection.this.handleAddProperty();
          }
        };
        fAddPropertyAction.setEnabled(isEditable());
        
        fEditAction = new Action(Messages.DSPropertiesSection_edit)
        {
          public void run()
          {
            DSPropertiesSection.this.handleEdit();
          }
        };
        fEditAction.setEnabled(isEditable());
        
        fRemoveAction = new Action(Messages.DSPropertiesSection_remove)
        {
          public void run()
          {
            DSPropertiesSection.this.handleRemove();
          }
        };
        fRemoveAction.setEnabled(isEditable());
      }
      
      private void updateButtons()
      {
        Table table = fPropertiesTable.getTable();
        
        TablePart tablePart = getTablePart();
        tablePart.setButtonEnabled(0, isEditable());
        tablePart.setButtonEnabled(1, isEditable());
        tablePart.setButtonEnabled(2, (isEditable()) && 
          (table.getSelection().length > 0));
        tablePart.setButtonEnabled(3, isEditable());
        tablePart.setButtonEnabled(4, (isEditable()) && 
          (table.getSelection().length > 0) && (!table.isSelected(0)));
        tablePart.setButtonEnabled(5, (isEditable()) && 
          (table.getSelection().length > 0) 
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-2017. Infinite Loop Ltd