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

Project javaProject = JavaCore.create(project);
        IJavaElement element = javaProject.findType(value.replace('$', 
          '.'));
        if (element != null) {
          JavaUI.openInEditor(element);
        }
      }
    }
    catch (PartInitException e)
    {
      Activator.logException(e);
    }
    catch (CoreException e)
    {
      Activator.logException(e);
    }
  }
}

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

import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.forms.widgets.FormToolkit;

public class ComboPart
{
  protected Control combo;
  
  public void addSelectionListener(SelectionListener listener)
  {
    if ((combo instanceof Combo)) {
      ((Combo)combo).addSelectionListener(listener);
    } else {
      ((CCombo)combo).addSelectionListener(listener);
    }
  }
  
  public int indexOf(String item)
  {
    if ((combo instanceof Combo)) {
      return ((Combo)combo).indexOf(item);
    }
    return ((CCombo)combo).indexOf(item);
  }
  
  public void addModifyListener(ModifyListener listener)
  {
    if ((combo instanceof Combo)) {
      ((Combo)combo).addModifyListener(listener);
    } else {
      ((CCombo)combo).addModifyListener(listener);
    }
  }
  
  public void createControl(Composite parent, FormToolkit toolkit, int style)
  {
    if (toolkit.getBorderStyle() == 2048) {
      combo = new Combo(parent, style | 0x800);
    } else {
      combo = new CCombo(parent, style | 0x800000);
    }
    toolkit.adapt(combo, true, false);
  }
  
  public Control getControl()
  {
    return combo;
  }
  
  public int getSelectionIndex()
  {
    if ((combo instanceof Combo)) {
      return ((Combo)combo).getSelectionIndex();
    }
    return ((CCombo)combo).getSelectionIndex();
  }
  
  public void add(String item, int index)
  {
    if ((combo instanceof Combo)) {
      ((Combo)combo).add(item, index);
    } else {
      ((CCombo)combo).add(item, index);
    }
  }
  
  public void add(String item)
  {
    if ((combo instanceof Combo)) {
      ((Combo)combo).add(item);
    } else {
      ((CCombo)combo).add(item);
    }
  }
  
  public void remove(int index)
  {
    if ((index < 0) || (index >= getItemCount())) {
      return;
    }
    if ((combo instanceof Combo)) {
      ((Combo)combo).remove(index);
    } else {
      ((CCombo)combo).remove(index);
    }
  }
  
  public void select(int index)
  {
    if ((combo instanceof Combo)) {
      ((Combo)combo).select(index);
    } else {
      ((CCombo)combo).select(index);
    }
  }
  
  public String getSelection()
  {
    if ((combo instanceof Combo)) {
      return ((Combo)combo).getText().trim();
    }
    return ((CCombo)combo).getText().trim();
  }
  
  public void setText(String text)
  {
    if ((combo instanceof Combo)) {
      ((Combo)combo).setText(text);
    } else {
      ((CCombo)combo).setText(text);
    }
  }
  
  public void setItems(String[] items)
  {
    if ((combo instanceof Combo)) {
      ((Combo)combo).setItems(items);
    } else {
      ((CCombo)combo).setItems(items);
    }
  }
  
  public void setEnabled(boolean enabled)
  {
    if ((combo instanceof Combo)) {
      ((Combo)combo).setEnabled(enabled);
    } else {
      ((CCombo)combo).setEnabled(enabled);
    }
  }
  
  public int getItemCount()
  {
    if ((combo instanceof Combo)) {
      return ((Combo)combo).getItemCount();
    }
    return ((CCombo)combo).getItemCount();
  }
  
  public String[] getItems()
  {
    if ((combo instanceof Combo)) {
      return ((Combo)combo).getItems();
    }
    return ((CCombo)combo).getItems();
  }
}

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

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class FormEntry$1
  extends SelectionAdapter
{
  final FormEntry this$0;
  
  FormEntry$1(FormEntry paramFormEntry)
  {
    this$0 = paramFormEntry;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    if (FormEntry.access$0(this$0) != null) {
      FormEntry.access$0(this$0).browseButtonSelected(this$0);
    }
  }
}

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

import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;

class FormEntry$2
  extends KeyAdapter
{
  final FormEntry this$0;
  
  FormEntry$2(FormEntry paramFormEntry)
  {
    this$0 = paramFormEntry;
  }
  
  public void keyReleased(KeyEvent e)
  {
    FormEntry.access$1(this$0, e);
  }
}

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

import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;

class FormEntry$3
  implements ModifyListener
{
  final FormEntry this$0;
  
  FormEntry$3(FormEntry paramFormEntry)
  {
    this$0 = paramFormEntry;
  }
  
  public void modifyText(ModifyEvent e)
  {
    FormEntry.access$2(this$0, e);
  }
}

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

import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;

class FormEntry$4
  extends FocusAdapter
{
  final FormEntry this$0;
  
  FormEntry$4(FormEntry paramFormEntry)
  {
    this$0 = paramFormEntry;
  }
  
  public void focusGained(FocusEvent e)
  {
    if (FormEntry.access$0(this$0) != null) {
      FormEntry.access$0(this$0).focusGained(this$0);
    }
  }
  
  public void focusLost(FocusEvent e)
  {
    if (FormEntry.access$3(this$0)) {
      this$0.commit();
    }
  }
}

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

import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
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.Control;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.FormColors;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Hyperlink;
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;

public class FormEntry
{
  private Control fLabel;
  private Text fText;
  private Button fBrowse;
  private String fValue = "";
  private boolean fDirty;
  boolean fIgnoreModify = false;
  private IFormEntryListener fListener;
  public static final int F_DEFAULT_TEXT_WIDTH_HINT = 100;
  
  public FormEntry(Composite parent, FormToolkit toolkit, String labelText, int style)
  {
    createControl(parent, toolkit, labelText, style, null, false, 0, 0);
  }
  
  public FormEntry(Composite parent, FormToolkit toolkit, String labelText, String browseText, boolean linkLabel)
  {
    this(parent, toolkit, labelText, browseText, linkLabel, 0);
  }
  
  public FormEntry(Composite parent, FormToolkit toolkit, String labelText, String browseText, boolean linkLabel, int indent)
  {
    createControl(parent, toolkit, labelText, 4, browseText, 
      linkLabel, indent, 0);
  }
  
  public FormEntry(Composite parent, FormToolkit toolkit, String labelText, int indent, int tcolspan)
  {
    createControl(parent, toolkit, labelText, 4, null, false, 
      indent, tcolspan);
  }
  
  private void createControl(Composite parent, FormToolkit toolkit, String labelText, int style, String browseText, boolean linkLabel, int indent, int tcolspan)
  {
    if (linkLabel)
    {
      Hyperlink link = toolkit.createHyperlink(parent, labelText, 
        0);
      fLabel = link;
    }
    else if (labelText != null)
    {
      fLabel = toolkit.createLabel(parent, labelText);
      fLabel.setForeground(toolkit.getColors().getColor(
        "org.eclipse.ui.forms.TITLE"));
    }
    fText = toolkit.createText(parent, "", style);
    addListeners();
    if (browseText != null)
    {
      fBrowse = toolkit.createButton(parent, browseText, 8);
      fBrowse.addSelectionListener(new SelectionAdapter()
      {
        public void widgetSelected(SelectionEvent e)
        {
          if (fListener != null) {
            fListener.browseButtonSelected(FormEntry.this);
          }
        }
      });
    }
    fillIntoGrid(parent, indent, tcolspan);
    
    setTextWidthHint(100);
  }
  
  public void setEditable(boolean editable)
  {
    fText.setEditable(editable);
    if ((fLabel instanceof Hyperlink)) {
      ((Hyperlink)fLabel).setUnderlined(editable);
    }
    if (fBrowse != null) {
      fBrowse.setEnabled(editable);
    }
  }
  
  private void fillIntoGrid(Composite parent, int indent, int tcolspan)
  {
    Layout layout = parent.getLayout();
    if ((layout instanceof GridLayout))
    {
      int span = numColumns;
      int tspan;
      int tspan;
      if (tcolspan > 0) {
        tspan = tcolspan;
      } else {
        tspan = fBrowse != null ? span - 2 : span - 1;
      }
      if (fLabel != null)
      {
        GridData gd = new GridData(4);
        horizontalIndent = indent;
        fLabel.setLayoutData(gd);
      }
      GridData gd = new GridData(256);
      horizontalSpan = tspan;
      if (fLabel != null) {
        horizontalIndent = 3;
      }
      grabExcessHorizontalSpace = (tspan == 1);
      widthHint = 10;
      fText.setLayoutData(gd);
      if (fBrowse != null)
      {
        gd = new GridData(4);
        fBrowse.setLayoutData(gd);
      }
    }
    else if ((layout instanceof TableWrapLayout))
    {
      int span = numColumns;
      int tspan;
      int tspan;
      if (tcolspan > 0) {
        tspan = tcolspan;
      } else {
        tspan = fBrowse != null ? span - 2 : span - 1;
      }
      if (fLabel != null)
      {
        TableWrapData td = new TableWrapData();
        valign = 32;
        indent = indent;
        fLabel.setLayoutData(td);
      }
      TableWrapData td = new TableWrapData(128);
      colspan = tspan;
      if (fLabel != null) {
        indent = 3;
      }
      grabHorizontal = (tspan == 1);
      valign = 32;
      fText.setLayoutData(td);
      if (fBrowse != null)
      {
        td = new TableWrapData(128);
        valign = 32;
        fBrowse.setLayoutData(td);
      }
    }
  }
  
  public void setFormEntryListener(IFormEntryListener listener)
  {
    if ((fLabel != null) && ((fLabel instanceof Hyperlink)))
    {
      if (fListener != null) {
        ((Hyperlink)fLabel).removeHyperlinkListener(fListener);
      }
      if (listener != null) {
        ((Hyperlink)fLabel).addHyperlinkListener(listener);
      }
    }
    fListener = listener;
  }
  
  private void addListeners()
  {
    fText.addKeyListener(new KeyAdapter()
    {
      public void keyReleased(KeyEvent e)
      {
        FormEntry.this.keyReleaseOccured(e);
      }
    });
    fText.addModifyListener(new ModifyListener()
    {
      public void modifyText(ModifyEvent e)
      {
        FormEntry.this.editOccured(e);
      }
    });
    fText.addFocusListener(new FocusAdapter()
    {
      public void focusGained(FocusEvent e)
      {
        if (fListener != null) {
          fListener.focusGained(FormEntry.this);
        }
      }
      
      public void focusLost(FocusEvent e)
      {
        if (fDirty) {
          commit();
        }
      }
    });
  }
  
  public void commit()
  {
    if (fDirty)
    {
      fValue = fText.getText();
      if (fListener != null) {
        fListener.textValueChanged(this);
      }
    }
    fDirty = false;
  }
  
  public void cancelEdit()
  {
    fDirty = false;
  }
  
  private void editOccured(ModifyEvent e)
  {
    if (fIgnoreModify) {
      return;
    }
    fDirty = true;
    if (fListener != null) {
      fListener.textDirty(this);
    }
  }
  
  public Text getText()
  {
    return fText;
  }
  
  public Control getLabel()
  {
    return fLabel;
  }
  
  public Button getButton()
  {
    return fBrowse;
  }
  
  public String getValue()
  {
    return fValue.trim();
  }
  
  public boolean isDirty()
  {
    return fDirty;
  }
  
  private void keyReleaseOccured(KeyEvent e)
  {
    if (character == '\r')
    {
      if (fDirty) {
        commit();
      }
    }
    else if (character == '\033')
    {
      if (!fValue.equals(fText.getText())) {
        fText.setText(fValue != null ? fValue : "");
      }
      fDirty = false;
    }
    if (fListener != null) {
      fListener.selectionChanged(this);
    }
  }
  
  public void setValue(String value)
  {
    if (fText != null) {
      fText.setText(value != null ? value : "");
    }
    fValue = (value != null ? value : "");
  }
  
  public void setValue(String value, boolean blockNotification)
  {
    fIgnoreModify = blockNotification;
    setValue(value);
    fIgnoreModify = false;
  }
  
  public void setVisible(boolean visible)
  {
    if (fLabel != null) {
      fLabel.setVisible(visible);
    }
    if (fText != null) {
      fText.setVisible(visible);
    }
    if (fBrowse != null) {
      fBrowse.setVisible(visible);
    }
  }
  
  public void setTextWidthHint(int width)
  {
    Object data = getText().getLayoutData();
    if (data == null) {
      return;
    }
    if ((data instanceof GridData)) {
      widthHint = width;
    } else if ((data instanceof TableWrapData)) {
      maxWidth = width;
    }
  }
}

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

import org.eclipse.ui.forms.events.IHyperlinkListener;

public abstract interface IFormEntryListener
  extends IHyperlinkListener
{
  public abstract void focusGained(FormEntry paramFormEntry);
  
  public abstract void textDirty(FormEntry paramFormEntry);
  
  public abstract void textValueChanged(FormEntry paramFormEntry);
  
  public abstract void browseButtonSelected(FormEntry paramFormEntry);
  
  public abstract void selectionChanged(FormEntry paramFormEntry);
}

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

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.pde.core.IBaseModel;
import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase;
import org.eclipse.pde.internal.ui.util.ModelModification;

class DSCreationOperation$1
  extends ModelModification
{
  final DSCreationOperation this$0;
  
  DSCreationOperation$1(DSCreationOperation paramDSCreationOperation, IProject $anonymous0)
  {
    super($anonymous0);this$0 = paramDSCreationOperation;
  }
  
  protected void modifyModel(IBaseModel model, IProgressMonitor monitor)
    throws CoreException
  {
    if ((model instanceof IBundlePluginModelBase)) {
      DSCreationOperation.access$0(this$0, (IBundlePluginModelBase)model, monitor);
    }
  }
}

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

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.pde.core.IBaseModel;
import org.eclipse.pde.core.build.IBuild;
import org.eclipse.pde.core.build.IBuildEntry;
import org.eclipse.pde.core.build.IBuildModel;
import org.eclipse.pde.core.build.IBuildModelFactory;
import org.eclipse.pde.internal.core.build.WorkspaceBuildModel;
import org.eclipse.pde.internal.core.project.PDEProject;
import org.eclipse.pde.internal.ui.util.ModelModification;

class DSCreationOperation$2
  extends ModelModification
{
  final DSCreationOperation this$0;
  private final IProject val$project;
  
  DSCreationOperation$2(DSCreationOperation paramDSCreationOperation, IFile $anonymous0, IProject paramIProject)
  {
    super($anonymous0);this$0 = paramDSCreationOperation;val$project = paramIProject;
  }
  
  protected void modifyModel(IBaseModel model, IProgressMonitor monitor)
    throws CoreException
  {
    if (!(model instanceof IBuildModel)) {
      return;
    }
    IFile file = PDEProject.getBuildProperties(val$project);
    if (file.exists())
    {
      WorkspaceBuildModel wbm = new WorkspaceBuildModel(file);
      wbm.load();
      if (!wbm.isLoaded()) {
        return;
      }
      IBuildModelFactory factory = wbm.getFactory();
      String path = this$0.fFile.getFullPath().removeFirstSegments(1).toPortableString();
      IBuildEntry entry = wbm.getBuild().getEntry(
        "bin.includes");
      if (entry == null)
      {
        entry = factory.createEntry("bin.includes");
        wbm.getBuild().add(entry);
      }
      entry.addToken(path);
      wbm.save();
    }
  }
}

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

import org.eclipse.core.resources.IFile;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.pde.internal.ds.ui.Activator;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.ISetSelectionTarget;

class DSCreationOperation$3
  implements Runnable
{
  final DSCreationOperation this$0;
  
  DSCreationOperation$3(DSCreationOperation paramDSCreationOperation)
  {
    this$0 = paramDSCreationOperation;
  }
  
  public void run()
  {
    IWorkbenchWindow window = Activator.getActiveWorkbenchWindow();
    if (window == null) {
      return;
    }
    IWorkbenchPage page = window.getActivePage();
    if ((page == null) || (!this$0.fFile.exists())) {
      return;
    }
    IWorkbenchPart focusPart = page.getActivePart();
    if ((focusPart instanceof ISetSelectionTarget))
    {
      ISelection selection = new StructuredSelection(this$0.fFile);
      ((ISetSelectionTarget)focusPart).selectReveal(selection);
    }
    try
    {
      IDE.openEditor(page, this$0.fFile);
    }
    catch (PartInitException localPartInitException) {}
  }
}

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

import java.lang.reflect.InvocationTargetException;
import java.util.StringTokenizer;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.pde.core.IBaseModel;
import org.eclipse.pde.core.build.IBuild;
import org.eclipse.pde.core.build.IBuildEntry;
import org.eclipse.pde.core.build.IBuildModel;
import org.eclipse.pde.core.build.IBuildModelFactory;
import org.eclipse.pde.internal.core.build.WorkspaceBuildModel;
import org.eclipse.pde.internal.core.ibundle.IBundle;
import org.eclipse.pde.internal.core.ibundle.IBundleModel;
import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase;
import org.eclipse.pde.internal.core.natures.PDE;
import org.eclipse.pde.internal.core.project.PDEProject;
import org.eclipse.pde.internal.core.util.CoreUtility;
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.core.text.DSModel;
import org.eclipse.pde.internal.ds.ui.Activator;
import org.eclipse.pde.internal.ds.ui.Messages;
import org.eclipse.pde.internal.ui.util.ModelModification;
import org.eclipse.pde.internal.ui.util.PDEModelUtility;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.ISetSelectionTarget;

public class DSCreationOperation
  extends WorkspaceModifyOperation
{
  protected IFile fFile;
  private String fComponentName;
  private String fImplementationClass;
  private final String DS_MANIFEST_KEY = "Service-Component";
  
  public DSCreationOperation(IFile file, String componentName, String implementationClass)
  {
    fFile = file;
    fComponentName = componentName;
    fImplementationClass = implementationClass;
  }
  
  protected void execute(IProgressMonitor monitor)
    throws CoreException, InvocationTargetException, InterruptedException
  {
    monitor.beginTask(Messages.DSCreationOperation_title, 3);
    createContent();
    monitor.worked(1);
    openFile();
    if (PDE.hasPluginNature(fFile.getProject()))
    {
      writeManifest(fFile.getProject(), new SubProgressMonitor(
        monitor, 1));
      writeBuildProperties(fFile.getProject(), new SubProgressMonitor(
        monitor, 1));
    }
    monitor.done();
  }
  
  private void writeManifest(IProject project, SubProgressMonitor monitor)
  {
    PDEModelUtility.modifyModel(new ModelModification(project)
    {
      protected void modifyModel(IBaseModel model, IProgressMonitor monitor)
        throws CoreException
      {
        if ((model instanceof IBundlePluginModelBase)) {
          DSCreationOperation.this.updateManifest((IBundlePluginModelBase)model, monitor);
        }
      }
    }, monitor);
    monitor.done();
  }
  
  private void writeBuildProperties(IProject project, SubProgressMonitor monitor)
  {
    PDEModelUtility.modifyModel(new ModelModification(
      PDEProject.getBuildProperties(project))
      {
        private final IProject val$project;
        
        protected void modifyModel(IBaseModel model, IProgressMonitor monitor)
          throws CoreException
        {
          if (!(model instanceof IBuildModel)) {
            return;
          }
          IFile file = PDEProject.getBuildProperties(val$project);
          if (file.exists())
          {
            WorkspaceBuildModel wbm = new WorkspaceBuildModel(file);
            wbm.load();
            if (!wbm.isLoaded()) {
              return;
            }
            IBuildModelFactory factory = wbm.getFactory();
            String path = fFile.getFullPath().removeFirstSegments(1).toPortableString();
            IBuildEntry entry = wbm.getBuild().getEntry(
              "bin.includes");
            if (entry == null)
            {
              entry = factory.createEntry("bin.includes");
              wbm.getBuild().add(entry);
            }
            entry.addToken(path);
            wbm.save();
          }
        }
      }, null);
    
    monitor.done();
  }
  
  private void updateManifest(IBundlePluginModelBase model, IProgressMonitor monitor)
    throws CoreException
  {
    IBundleModel bundleModel = model.getBundleModel();
    
    IContainer root = PDEProject.getBundleRoot(fFile.getProject());
    String filePath = fFile.getFullPath()
      .makeRelativeTo(root.getFullPath()).toPortableString();
    
    String header = bundleModel.getBundle().getHeader("Service-Component");
    if (header != null)
    {
      if (containsValue(header, filePath)) {
        return;
      }
      filePath = header + ", " + filePath;
    }
    bundleModel.getBundle().setHeader("Service-Component", filePath);
  }
  
  private boolean containsValue(String header, String value)
  {
    value = value.trim();
    StringTokenizer st = new StringTokenizer(header, ",");
    while (st.hasMoreElements())
    {
      String token = st.nextToken();
      if (value.equals(token.trim())) {
        return true;
      }
    }
    return false;
  }
  
  protected void createContent()
    throws CoreException
  {
    IDSModel model = new DSModel(CoreUtility.getTextDocument(fFile
      .getContents()), false);
    model.setUnderlyingResource(fFile);
    initializeDS(model.getDSComponent(), fFile);
    model.save();
    model.dispose();
  }
  
  protected void initializeDS(IDSComponent component, IFile file)
  {
    IDSDocumentFactory factory = component.getModel().getFactory();
    
    IDSImplementation implementation = factory.createImplementation();
    implementation.setClassName(fImplementationClass);
    component.setImplementation(implementation);
    component.setAttributeName(fComponentName);
    try
    {
      IProject project = file.getProject();
      IProjectDescription description = project.getDescription();
      ICommand[] commands = description.getBuildSpec();
      for (int i = 0; i < commands.length; i++) {
        if (commands[i].getBuilderName().equals("org.eclipse.pde.ds.core.builder")) {
          return;
        }
      }
      ICommand[] newCommands = new ICommand[commands.length + 1];
      System.arraycopy(commands, 0, newCommands, 0, commands.length);
      ICommand command = description.newCommand();
      command.setBuilderName("org.eclipse.pde.ds.core.builder");
      newCommands[(newCommands.length - 1)] = command;
      description.setBuildSpec(newCommands);
      project.setDescription(description, null);
    }
    catch (CoreException e)
    {
      Activator.logException(e, null, null);
    }
  }
  
  private void openFile()
  {
    Display.getCurrent().asyncExec(new Runnable()
    {
      public void run()
      {
        IWorkbenchWindow window = Activator.getActiveWorkbenchWindow();
        if (window == null) {
          return;
        }
        IWorkbenchPage page = window.getActivePage();
        if ((page == null) || (!fFile.exists())) {
          return;
        }
        IWorkbenchPart focusPart = page.getActivePart();
        if ((focusPart instanceof ISetSelectionTarget))
        {
          ISelection selection = new StructuredSelection(fFile);
          ((ISetSelectionTarget)focusPart).selectReveal(selection);
        }
        try
        {
          IDE.openEditor(page, fFile);
        }
        catch (PartInitException localPartInitException) {}
      }
    });
  }
}

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

import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;

class DSFileWizardPage$1
  implements ModifyListener
{
  final DSFileWizardPage this$0;
  
  DSFileWizardPage$1(DSFileWizardPage paramDSFileWizardPage)
  {
    this$0 = paramDSFileWizardPage;
  }
  
  public void modifyText(ModifyEvent e)
  {
    this$0.setPageComplete(this$0.isPageComplete());
  }
}

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

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.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.pde.internal.ds.ui.Activator;
import org.eclipse.pde.internal.ds.ui.SWTUtil;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PartInitException;

class DSFileWizardPage$2
  extends SelectionAdapter
{
  final DSFileWizardPage this$0;
  
  DSFileWizardPage$2(DSFileWizardPage paramDSFileWizardPage)
  {
    this$0 = paramDSFileWizardPage;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    String value = DSFileWizardPage.access$0(this$0).getText();
    value = handleLinkActivated(value, false);
    if (value != null) {
      DSFileWizardPage.access$0(this$0).setText(value);
    }
  }
  
  private String handleLinkActivated(String value, boolean isInter)
  {
    Object object = DSFileWizardPage.access$1(this$0).getFirstElement();
    if (object != null)
    {
      IProject project = DSFileWizardPage.access$2(this$0, object);
      try
      {
        if (project != null) {
          if (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;
  }
}

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

import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;

class DSFileWizardPage$3
  implements ModifyListener
{
  final DSFileWizardPage this$0;
  
  DSFileWizardPage$3(DSFileWizardPage paramDSFileWizardPage)
  {
    this$0 = paramDSFileWizardPage;
  }
  
  public void modifyText(ModifyEvent e)
  {
    this$0.setPageComplete(this$0.isPageComplete());
  }
}

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

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.pde.internal.ds.ui.Activator;
import org.eclipse.pde.internal.ds.ui.Messages;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.SelectionDialog;

class DSFileWizardPage$4
  implements MouseListener
{
  final DSFileWizardPage this$0;
  
  DSFileWizardPage$4(DSFileWizardPage paramDSFileWizardPage)
  {
    this$0 = paramDSFileWizardPage;
  }
  
  public void mouseDoubleClick(MouseEvent e) {}
  
  public void mouseDown(MouseEvent e) {}
  
  public void mouseUp(MouseEvent e)
  {
    doOpenSelectionDialog(
      2, 
      DSFileWizardPage.access$0(this$0));
  }
  
  private void doOpenSelectionDialog(int scopeType, Text entry)
  {
    try
    {
      String filter = entry.getText();
      filter = filter.substring(filter.lastIndexOf(".") + 1);
      SelectionDialog dialog = JavaUI.createTypeDialog(
        Activator.getActiveWorkbenchShell(), 
        PlatformUI.getWorkbench().getProgressService(), 
        SearchEngine.createWorkspaceScope(), scopeType, false, filter);
      dialog.setTitle(Messages.DSFileWizardPage_selectType);
      if (dialog.open() == 0)
      {
        IType type = (IType)dialog.getResult()[0];
        entry.setText(type.getFullyQualifiedName('$'));
      }
    }
    catch (CoreException e)
    {
      Activator.logException(e);
    }
  }
}

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

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.internal.ui.packageview.ClassPathContainer;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.pde.internal.core.bundle.WorkspaceBundlePluginModel;
import org.eclipse.pde.internal.core.ibundle.IBundle;
import org.eclipse.pde.internal.core.ibundle.IBundleModel;
import org.eclipse.pde.internal.core.project.PDEProject;
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.SharedImages;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
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.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.SelectionDialog;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;

public class DSFileWizardPage
  extends WizardNewFileCreationPage
{
  public static final String F_PAGE_NAME = "ds";
  private static final String F_FILE_EXTENSION = "xml";
  private static final String F_DEFAULT_COMPONENT_NAME = "component.xml";
  private static final String S_COMPONENT_NAME = "component";
  private Group fGroup;
  private Text fDSComponentNameText;
  private Label fDSComponentNameLabel;
  private Text fDSImplementationClassText;
  private Link fDSImplementationClassHyperlink;
  private Button fDSImplementationClassButton;
  private IStructuredSelection fSelection;
  
  public DSFileWizardPage(IStructuredSelection selection)
  {
    super("ds", selection);
    fSelection = selection;
    initialize();
  }
  
  protected void initialize()
  {
    setTitle(Messages.DSFileWizardPage_title);
    setDescription(Messages.DSFileWizardPage_description);
    setImageDescriptor(
      SharedImages.getImageDescriptor("icons/wizban/defcon_wiz.png"));
    
    setFileExtension("xml");
  }
  
  private void setComponentName()
  {
    Object element = fSelection.getFirstElement();
    if (element != null)
    {
      IProject project = getProject(element);
      if (project != null) {
        setComponentNameText(project);
      }
    }
    if (fDSComponentNameText.getText().trim().length() == 0) {
      fDSComponentNameText.setText(Messages.DSFileWizardPage_ExampleComponentName);
    }
  }
  
  private IProject getProject(Object element)
  {
    IProject project = null;
    if ((element instanceof IResource)) {
      project = ((IResource)element).getProject();
    } else if ((element instanceof IJavaElement)) {
      project = ((IJavaElement)element).getJavaProject().getProject();
    } else if ((element instanceof ClassPathContainer)) {
      project = 
        ((ClassPathContainer)element).getJavaProject().getProject();
    }
    return project;
  }
  
  private void setComponentNameText(IProject project)
  {
    try
    {
      if (project.hasNature("org.eclipse.pde.PluginNature"))
      {
        WorkspaceBundlePluginModel model = new WorkspaceBundlePluginModel(
          PDEProject.getManifest(project), 
          null);
        model.load();
        String header = model.getBundleModel().getBundle().getHeader(
          "Bundle-SymbolicName");
        String[] h = header.split(";");
        fDSComponentNameText.setText(h[0]);
      }
    }
    catch (CoreException localCoreException) {}
  }
  
  protected void createAdvancedControls(Composite parent)
  {
    IDialogSettings settings = getDialogSettings();
    if (settings != null)
    {
      String component = settings.get("component");
      if ((component != null) && (!component.equals(""))) {
        setFileName(component);
      } else {
        setFileName("component.xml");
      }
    }
    else
    {
      setFileName("component.xml");
    }
    fGroup = new Group(parent, 0);
    fGroup.setText(Messages.DSFileWizardPage_group);
    fGroup.setLayout(new GridLayout(3, false));
    fGroup.setLayoutData(new GridData(768));
    
    GridData nameTextGridData = new GridData(768);
    horizontalSpan = 2;
    horizontalIndent = 3;
    
    fDSComponentNameLabel = new Label(fGroup, 0);
    fDSComponentNameLabel.setText(Messages.DSFileWizardPage_component_name);
    
    fDSComponentNameText = new Text(fGroup, 2052);
    fDSComponentNameText.setLayoutData(nameTextGridData);
    fDSComponentNameText.setText("");
    fDSComponentNameText.addModifyListener(new ModifyListener()
    {
      public void modifyText(ModifyEvent e)
      {
        setPageComplete(isPageComplete());
      }
    });
    setComponentName();
    
    fDSImplementationClassHyperlink = new Link(fGroup, 0);
    fDSImplementationClassHyperlink.setText("<a>" + 
      Messages.DSFileWizardPage_implementation_class + "</a>");
    fDSImplementationClassHyperlink.setForeground(Display.getDefault()
      .getSystemColor(9));
    fDSImplementationClassHyperlink
      .addSelectionListener(new SelectionAdapter()
      {
        public void widgetSelected(SelectionEvent e)
        {
          String value = fDSImplementationClassText.getText();
          value = handleLinkActivated(value, false);
         
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