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

dListener
{
  public static final String PAGE_ID = "services";
  
  public DSServicesPage(FormEditor editor)
  {
    super(editor, "services", Messages.DSServicesPage_title);
  }
  
  public void modelChanged(IModelChangedEvent event) {}
  
  protected void createFormContent(IManagedForm managedForm)
  {
    super.createFormContent(managedForm);
    ScrolledForm form = managedForm.getForm();
    FormToolkit toolkit = managedForm.getToolkit();
    form.setImage(SharedImages.getImage("icons/obj16/ds_obj.gif"));
    form.setText(Messages.DSServicesPage_title);
    fillBody(managedForm, toolkit);
  }
  
  private void fillBody(IManagedForm managedForm, FormToolkit toolkit)
  {
    Composite body = managedForm.getForm().getBody();
    body.setLayout(FormLayoutFactory.createFormGridLayout(true, 1));
    GridData data = new GridData(1808);
    grabExcessVerticalSpace = true;
    body.setLayoutData(data);
    
    managedForm.addPart(new DSReferenceSection(this, body));
    managedForm.addPart(new DSProvideSection(this, body));
  }
}

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

import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.pde.internal.core.text.IDocumentAttributeNode;
import org.eclipse.pde.internal.core.text.IDocumentElementNode;
import org.eclipse.pde.internal.core.text.IDocumentRange;
import org.eclipse.pde.internal.core.text.IDocumentTextNode;
import org.eclipse.pde.internal.ds.core.text.DSModel;
import org.eclipse.pde.internal.ds.ui.Messages;
import org.eclipse.pde.internal.ui.editor.PDEFormEditor;
import org.eclipse.pde.internal.ui.editor.XMLSourcePage;
import org.eclipse.pde.internal.ui.editor.context.InputContext;
import org.eclipse.pde.internal.ui.editor.text.ChangeAwareSourceViewerConfiguration;
import org.eclipse.pde.internal.ui.editor.text.IColorManager;

public class DSSourcePage
  extends XMLSourcePage
{
  public DSSourcePage(PDEFormEditor editor, String id, String title)
  {
    super(editor, id, title);
  }
  
  public boolean isQuickOutlineEnabled()
  {
    return true;
  }
  
  public ViewerComparator createOutlineComparator()
  {
    return null;
  }
  
  public ITreeContentProvider createOutlineContentProvider()
  {
    return new DSContentProvider();
  }
  
  public ILabelProvider createOutlineLabelProvider()
  {
    return new DSLabelProvider();
  }
  
  protected boolean isSelectionListener()
  {
    return true;
  }
  
  public void updateSelection(Object object)
  {
    if (((object instanceof IDocumentElementNode)) && 
      (!((IDocumentElementNode)object).isErrorNode()))
    {
      setSelectedObject(object);
      setHighlightRange((IDocumentElementNode)object, true);
      setSelectedRange((IDocumentElementNode)object, false);
    }
  }
  
  protected IDocumentRange findRange()
  {
    Object selectedObject = getSelection();
    if ((selectedObject instanceof IDocumentElementNode)) {
      return (IDocumentElementNode)selectedObject;
    }
    return null;
  }
  
  public IDocumentRange getRangeElement(int offset, boolean searchChildren)
  {
    IDocumentElementNode rootNode = ((DSModel)getInputContext().getModel())
      .getDSComponent();
    return findNode(rootNode, offset, searchChildren);
  }
  
  protected void synchronizeOutlinePage(int offset)
  {
    IDocumentRange range = getRangeElement(offset, true);
    updateHighlightRange(range);
    range = adaptRange(range);
    updateOutlinePageSelection(range);
  }
  
  public IDocumentRange adaptRange(IDocumentRange range)
  {
    if ((range instanceof IDocumentAttributeNode)) {
      return adaptRange(((IDocumentAttributeNode)range)
        .getEnclosingElement());
    }
    if ((range instanceof IDocumentTextNode)) {
      return adaptRange(((IDocumentTextNode)range).getEnclosingElement());
    }
    if ((range instanceof IDocumentElementNode)) {
      return range;
    }
    return null;
  }
  
  protected void setPartName(String partName)
  {
    super.setPartName(Messages.DSSourcePage_partName);
  }
  
  public Object getAdapter(Class adapter)
  {
    if (IHyperlinkDetector.class.equals(adapter)) {
      return new DSHyperlinkDetector(this);
    }
    return super.getAdapter(adapter);
  }
  
  public void setActive(boolean active)
  {
    super.setActive(active);
    if (active) {
      updateTextSelection();
    }
  }
  
  protected ChangeAwareSourceViewerConfiguration createSourceViewerConfiguration(IColorManager colorManager)
  {
    return new DSSourceViewerConfiguration(colorManager, this);
  }
}

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

import org.eclipse.jface.text.ITextHover;
import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.pde.internal.ds.ui.editor.contentassist.DSContentAssistProcessor;
import org.eclipse.pde.internal.ui.editor.PDESourcePage;
import org.eclipse.pde.internal.ui.editor.text.IColorManager;
import org.eclipse.pde.internal.ui.editor.text.XMLConfiguration;

public class DSSourceViewerConfiguration
  extends XMLConfiguration
{
  private ContentAssistant fContentAssistant;
  private DSContentAssistProcessor fContentAssistProcessor;
  private DSTextHover fTextHover;
  
  public DSSourceViewerConfiguration(IColorManager colorManager, PDESourcePage page)
  {
    super(colorManager, page);
  }
  
  public IContentAssistant getContentAssistant(ISourceViewer sourceViewer)
  {
    if ((sourceViewer.isEditable()) && (fContentAssistant == null))
    {
      fContentAssistProcessor = new DSContentAssistProcessor(fSourcePage);
      fContentAssistant = new ContentAssistant();
      fContentAssistant
        .setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
      fContentAssistant.setContentAssistProcessor(
        fContentAssistProcessor, "__dftl_partition_content_type");
      fContentAssistant.setContentAssistProcessor(
        fContentAssistProcessor, "__xml_tag");
      fContentAssistant
        .setInformationControlCreator(getInformationControlCreator(true));
      fContentAssistant.setShowEmptyList(false);
      fContentAssistant.addCompletionListener(fContentAssistProcessor);
      fContentAssistant.enableAutoInsert(true);
    }
    return fContentAssistant;
  }
  
  public void dispose()
  {
    if (fContentAssistProcessor != null) {
      fContentAssistProcessor.dispose();
    }
    super.dispose();
  }
  
  public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType)
  {
    if ((fTextHover == null) && (fSourcePage != null)) {
      fTextHover = new DSTextHover(fSourcePage);
    }
    return fTextHover;
  }
}

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

import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.pde.core.plugin.IPluginObject;
import org.eclipse.pde.internal.core.text.IDocumentRange;
import org.eclipse.pde.internal.core.text.IDocumentTextNode;
import org.eclipse.pde.internal.ds.core.IDSObject;
import org.eclipse.pde.internal.ui.editor.PDESourcePage;
import org.eclipse.pde.internal.ui.editor.text.PDETextHover;

public class DSTextHover
  extends PDETextHover
{
  private PDESourcePage fSourcePage;
  
  public DSTextHover(PDESourcePage sourcePage)
  {
    fSourcePage = sourcePage;
  }
  
  public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion)
  {
    int offset = hoverRegion.getOffset();
    IDocumentRange range = fSourcePage.getRangeElement(offset, true);
    if ((range instanceof IDocumentTextNode)) {
      return checkTranslatedValue((IDocumentTextNode)range);
    }
    if (!(range instanceof IDSObject)) {
      return null;
    }
    return ((IDSObject)range).getName();
  }
  
  private String checkTranslatedValue(IDocumentTextNode node)
  {
    String value = node.getText();
    if (value.startsWith("%")) {
      return 
        ((IPluginObject)node.getEnclosingElement()).getResourceString(value);
    }
    return null;
  }
}

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

import java.util.ArrayList;
import java.util.List;
import org.eclipse.jdt.ui.dialogs.ITypeInfoFilterExtension;
import org.eclipse.jdt.ui.dialogs.ITypeInfoRequestor;
import org.eclipse.pde.internal.ds.core.IDSProvide;

class DSTypeSelectionExtension$TypeInfoFilterExtension
  implements ITypeInfoFilterExtension
{
  List fProvides;
  final DSTypeSelectionExtension this$0;
  
  public DSTypeSelectionExtension$TypeInfoFilterExtension(DSTypeSelectionExtension arg1, IDSProvide[] provides)
  {
    this$0 = ???;fProvides = new ArrayList(3);
    for (int i = 0; i < provides.length; i++) {
      fProvides.add(provides[i].getInterface());
    }
  }
  
  public boolean select(ITypeInfoRequestor typeInfoRequestor)
  {
    StringBuffer buffer = new StringBuffer(typeInfoRequestor.getPackageName());
    buffer.append(".");
    buffer.append(typeInfoRequestor.getTypeName());
    return !fProvides.contains(buffer.toString());
  }
}

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

import java.util.ArrayList;
import java.util.List;
import org.eclipse.jdt.ui.dialogs.ITypeInfoFilterExtension;
import org.eclipse.jdt.ui.dialogs.ITypeInfoRequestor;
import org.eclipse.jdt.ui.dialogs.TypeSelectionExtension;
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;

public class DSTypeSelectionExtension
  extends TypeSelectionExtension
{
  private IDSModel fModel;
  public DSTypeSelectionExtension() {}
  
  class TypeInfoFilterExtension
    implements ITypeInfoFilterExtension
  {
    List fProvides = new ArrayList(3);
    
    public TypeInfoFilterExtension(IDSProvide[] provides)
    {
      for (int i = 0; i < provides.length; i++) {
        fProvides.add(provides[i].getInterface());
      }
    }
    
    public boolean select(ITypeInfoRequestor typeInfoRequestor)
    {
      StringBuffer buffer = new StringBuffer(typeInfoRequestor.getPackageName());
      buffer.append(".");
      buffer.append(typeInfoRequestor.getTypeName());
      return !fProvides.contains(buffer.toString());
    }
  }
  
  public DSTypeSelectionExtension(IDSModel model)
  {
    fModel = model;
  }
  
  public ITypeInfoFilterExtension getFilterExtension()
  {
    IDSService service = fModel.getDSComponent().getService();
    if (service != null) {
      return new TypeInfoFilterExtension(service.getProvidedServices());
    }
    return null;
  }
}

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

import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.pde.internal.ds.ui.parts.FormEntry;
import org.eclipse.pde.internal.ds.ui.parts.IFormEntryListener;
import org.eclipse.pde.internal.ui.editor.IContextPart;
import org.eclipse.pde.internal.ui.editor.PDEFormEditor;
import org.eclipse.pde.internal.ui.editor.PDEFormEditorContributor;
import org.eclipse.pde.internal.ui.editor.PDEFormPage;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.forms.events.HyperlinkEvent;

public class FormEntryAdapter
  implements IFormEntryListener
{
  private IContextPart contextPart;
  protected IActionBars actionBars;
  
  public FormEntryAdapter(IContextPart contextPart)
  {
    this(contextPart, null);
  }
  
  public FormEntryAdapter(IContextPart contextPart, IActionBars actionBars)
  {
    this.contextPart = contextPart;
    this.actionBars = actionBars;
  }
  
  public void focusGained(FormEntry entry)
  {
    ITextSelection selection = new TextSelection(1, 1);
    contextPart.getPage().getPDEEditor().getContributor()
      .updateSelectableActions(selection);
  }
  
  public void textDirty(FormEntry entry)
  {
    contextPart.fireSaveNeeded();
  }
  
  public void textValueChanged(FormEntry entry) {}
  
  public void browseButtonSelected(FormEntry entry) {}
  
  public void linkEntered(HyperlinkEvent e)
  {
    if (actionBars == null) {
      return;
    }
    IStatusLineManager mng = actionBars.getStatusLineManager();
    mng.setMessage(e.getLabel());
  }
  
  public void linkExited(HyperlinkEvent e)
  {
    if (actionBars == null) {
      return;
    }
    IStatusLineManager mng = actionBars.getStatusLineManager();
    mng.setMessage(null);
  }
  
  public void linkActivated(HyperlinkEvent e) {}
  
  public void selectionChanged(FormEntry entry)
  {
    ITextSelection selection = new TextSelection(1, 1);
    contextPart.getPage().getPDEEditor().getContributor()
      .updateSelectableActions(selection);
  }
}

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

import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.forms.widgets.TableWrapLayout;

public class FormLayoutFactory
{
  public static final int DEFAULT_CLEAR_MARGIN = 2;
  public static final int CONTROL_HORIZONTAL_INDENT = 3;
  public static final int FORM_BODY_MARGIN_TOP = 12;
  public static final int FORM_BODY_MARGIN_BOTTOM = 12;
  public static final int FORM_BODY_MARGIN_LEFT = 6;
  public static final int FORM_BODY_MARGIN_RIGHT = 6;
  public static final int FORM_BODY_HORIZONTAL_SPACING = 20;
  public static final int FORM_BODY_VERTICAL_SPACING = 17;
  public static final int FORM_BODY_MARGIN_HEIGHT = 0;
  public static final int FORM_BODY_MARGIN_WIDTH = 0;
  public static final int SECTION_CLIENT_MARGIN_TOP = 5;
  public static final int SECTION_CLIENT_MARGIN_BOTTOM = 5;
  public static final int SECTION_CLIENT_MARGIN_LEFT = 2;
  public static final int SECTION_CLIENT_MARGIN_RIGHT = 2;
  public static final int SECTION_CLIENT_HORIZONTAL_SPACING = 5;
  public static final int SECTION_CLIENT_VERTICAL_SPACING = 5;
  public static final int SECTION_CLIENT_MARGIN_HEIGHT = 0;
  public static final int SECTION_CLIENT_MARGIN_WIDTH = 0;
  public static final int SECTION_HEADER_VERTICAL_SPACING = 6;
  public static final int CLEAR_MARGIN_TOP = 2;
  public static final int CLEAR_MARGIN_BOTTOM = 2;
  public static final int CLEAR_MARGIN_LEFT = 2;
  public static final int CLEAR_MARGIN_RIGHT = 2;
  public static final int CLEAR_HORIZONTAL_SPACING = 0;
  public static final int CLEAR_VERTICAL_SPACING = 0;
  public static final int CLEAR_MARGIN_HEIGHT = 0;
  public static final int CLEAR_MARGIN_WIDTH = 0;
  public static final int FORM_PANE_MARGIN_TOP = 0;
  public static final int FORM_PANE_MARGIN_BOTTOM = 0;
  public static final int FORM_PANE_MARGIN_LEFT = 0;
  public static final int FORM_PANE_MARGIN_RIGHT = 0;
  public static final int FORM_PANE_HORIZONTAL_SPACING = 20;
  public static final int FORM_PANE_VERTICAL_SPACING = 17;
  public static final int FORM_PANE_MARGIN_HEIGHT = 0;
  public static final int FORM_PANE_MARGIN_WIDTH = 0;
  public static final int MASTER_DETAILS_MARGIN_TOP = 0;
  public static final int MASTER_DETAILS_MARGIN_BOTTOM = 0;
  public static final int MASTER_DETAILS_MARGIN_LEFT = 0;
  public static final int MASTER_DETAILS_MARGIN_RIGHT = 1;
  public static final int MASTER_DETAILS_HORIZONTAL_SPACING = 20;
  public static final int MASTER_DETAILS_VERTICAL_SPACING = 17;
  public static final int MASTER_DETAILS_MARGIN_HEIGHT = 0;
  public static final int MASTER_DETAILS_MARGIN_WIDTH = 0;
  
  public static GridLayout createFormGridLayout(boolean makeColumnsEqualWidth, int numColumns)
  {
    GridLayout layout = new GridLayout();
    
    marginHeight = 0;
    marginWidth = 0;
    
    marginTop = 12;
    marginBottom = 12;
    marginLeft = 6;
    marginRight = 6;
    
    horizontalSpacing = 20;
    verticalSpacing = 17;
    
    makeColumnsEqualWidth = makeColumnsEqualWidth;
    numColumns = numColumns;
    
    return layout;
  }
  
  public static GridLayout createClearGridLayout(boolean makeColumnsEqualWidth, int numColumns)
  {
    GridLayout layout = new GridLayout();
    
    marginHeight = 0;
    marginWidth = 0;
    
    marginTop = 2;
    marginBottom = 2;
    marginLeft = 2;
    marginRight = 2;
    
    horizontalSpacing = 0;
    verticalSpacing = 0;
    
    makeColumnsEqualWidth = makeColumnsEqualWidth;
    numColumns = numColumns;
    
    return layout;
  }
  
  public static TableWrapLayout createFormTableWrapLayout(boolean makeColumnsEqualWidth, int numColumns)
  {
    TableWrapLayout layout = new TableWrapLayout();
    
    topMargin = 12;
    bottomMargin = 12;
    leftMargin = 6;
    rightMargin = 6;
    
    horizontalSpacing = 20;
    verticalSpacing = 17;
    
    makeColumnsEqualWidth = makeColumnsEqualWidth;
    numColumns = numColumns;
    
    return layout;
  }
  
  public static TableWrapLayout createFormPaneTableWrapLayout(boolean makeColumnsEqualWidth, int numColumns)
  {
    TableWrapLayout layout = new TableWrapLayout();
    
    topMargin = 0;
    bottomMargin = 0;
    leftMargin = 0;
    rightMargin = 0;
    
    horizontalSpacing = 20;
    verticalSpacing = 17;
    
    makeColumnsEqualWidth = makeColumnsEqualWidth;
    numColumns = numColumns;
    
    return layout;
  }
  
  public static GridLayout createFormPaneGridLayout(boolean makeColumnsEqualWidth, int numColumns)
  {
    GridLayout layout = new GridLayout();
    
    marginHeight = 0;
    marginWidth = 0;
    
    marginTop = 0;
    marginBottom = 0;
    marginLeft = 0;
    marginRight = 0;
    
    horizontalSpacing = 20;
    verticalSpacing = 17;
    
    makeColumnsEqualWidth = makeColumnsEqualWidth;
    numColumns = numColumns;
    
    return layout;
  }
  
  public static TableWrapLayout createClearTableWrapLayout(boolean makeColumnsEqualWidth, int numColumns)
  {
    TableWrapLayout layout = new TableWrapLayout();
    
    topMargin = 2;
    bottomMargin = 2;
    leftMargin = 2;
    rightMargin = 2;
    
    horizontalSpacing = 0;
    verticalSpacing = 0;
    
    makeColumnsEqualWidth = makeColumnsEqualWidth;
    numColumns = numColumns;
    
    return layout;
  }
  
  public static GridLayout createMasterGridLayout(boolean makeColumnsEqualWidth, int numColumns)
  {
    GridLayout layout = new GridLayout();
    
    marginHeight = 0;
    marginWidth = 0;
    
    marginTop = 0;
    marginBottom = 0;
    marginLeft = 0;
    
    int marginRight = 20;
    if (marginRight > 0)
    {
      marginRight /= 2;
      if (marginRight > 0) {
        marginRight--;
      }
    }
    marginRight = marginRight;
    
    horizontalSpacing = 20;
    verticalSpacing = 17;
    
    makeColumnsEqualWidth = makeColumnsEqualWidth;
    numColumns = numColumns;
    
    return layout;
  }
  
  public static GridLayout createDetailsGridLayout(boolean makeColumnsEqualWidth, int numColumns)
  {
    GridLayout layout = new GridLayout();
    
    marginHeight = 0;
    marginWidth = 0;
    
    marginTop = 0;
    marginBottom = 0;
    
    int marginLeft = 20;
    if (marginLeft > 0)
    {
      marginLeft /= 2;
      if (marginLeft > 0) {
        marginLeft--;
      }
    }
    marginLeft = marginLeft;
    marginRight = 1;
    
    horizontalSpacing = 20;
    verticalSpacing = 17;
    
    makeColumnsEqualWidth = makeColumnsEqualWidth;
    numColumns = numColumns;
    
    return layout;
  }
  
  public static GridLayout createSectionClientGridLayout(boolean makeColumnsEqualWidth, int numColumns)
  {
    GridLayout layout = new GridLayout();
    
    marginHeight = 0;
    marginWidth = 0;
    
    marginTop = 5;
    marginBottom = 5;
    marginLeft = 2;
    marginRight = 2;
    
    horizontalSpacing = 5;
    verticalSpacing = 5;
    
    makeColumnsEqualWidth = makeColumnsEqualWidth;
    numColumns = numColumns;
    
    return layout;
  }
  
  public static TableWrapLayout createSectionClientTableWrapLayout(boolean makeColumnsEqualWidth, int numColumns)
  {
    TableWrapLayout layout = new TableWrapLayout();
    
    topMargin = 5;
    bottomMargin = 5;
    leftMargin = 2;
    rightMargin = 2;
    
    horizontalSpacing = 5;
    verticalSpacing = 5;
    
    makeColumnsEqualWidth = makeColumnsEqualWidth;
    numColumns = numColumns;
    
    return layout;
  }
  
  public static void visualizeLayoutArea(Composite container, int color)
  {
    container.setBackground(Display.getCurrent().getSystemColor(color));
  }
}

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

import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.pde.internal.ds.ui.SharedImages;
import org.eclipse.swt.graphics.Point;

public class DSAttrCompletionProposal
  extends TypeCompletionProposal
  implements ICompletionProposal
{
  public DSAttrCompletionProposal(String string, int startOffset, int length)
  {
    super(getReplacementString(string), SharedImages.getImage("icons/obj16/attribute_obj.gif"), string, startOffset, length);
  }
  
  public Point getSelection(IDocument document)
  {
    return new Point(fBeginInsertPoint + fReplacementString.length() - 
      1, 0);
  }
  
  private static String getReplacementString(String attribute)
  {
    String replacementString = null;
    if (attribute == null) {
      return null;
    }
    String string1 = "=\"";
    String string2 = "\"";
    if (attribute.equals("enabled")) {
      replacementString = 
      
        attribute + string1 + "true" + string2;
    } else if (attribute.equals("immediate")) {
      replacementString = 
      
        attribute + string1 + "false" + string2;
    } else if (attribute.equals("type")) {
      replacementString = 
        attribute + string1 + "String" + string2;
    } else if (attribute.equals("servicefactory")) {
      replacementString = 
      
        attribute + string1 + "false" + string2;
    } else if (attribute.equals("target")) {
      replacementString = 
        attribute + string1 + "(name=value)" + string2;
    } else if (attribute.equals("cardinality")) {
      replacementString = 
      
        attribute + string1 + "1..1" + string2;
    } else if (attribute.equals("policy")) {
      replacementString = 
        attribute + string1 + "static" + string2;
    } else if (attribute.equals("configuration-policy")) {
      replacementString = 
      
        attribute + string1 + "optional" + string2;
    } else {
      replacementString = 
        attribute + string1 + attribute + string2;
    }
    return replacementString;
  }
}

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

import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.pde.internal.ds.core.IDSObject;
import org.eclipse.pde.internal.ds.ui.SharedImages;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;

public class DSCompletionProposal
  implements ICompletionProposal
{
  private IDSObject fObject;
  private int fStartOffset;
  private int fLength;
  
  public DSCompletionProposal(IDSObject object, int startOffset)
  {
    this(object, startOffset, 0);
  }
  
  public DSCompletionProposal(IDSObject object, int startOffset, int length)
  {
    fObject = object;
    fStartOffset = startOffset;
    fLength = length;
  }
  
  public void apply(IDocument document)
  {
    try
    {
      document.replace(fStartOffset, fLength, fObject.toString());
    }
    catch (BadLocationException localBadLocationException) {}
  }
  
  public String getAdditionalProposalInfo()
  {
    return null;
  }
  
  public IContextInformation getContextInformation()
  {
    return null;
  }
  
  public String getDisplayString()
  {
    return getTextbyType(fObject.getType());
  }
  
  private String getTextbyType(int type)
  {
    switch (type)
    {
    case 2: 
      return "properties";
    case 3: 
      return "property";
    case 5: 
      return "provide";
    case 6: 
      return "reference";
    case 4: 
      return "service";
    case 1: 
      return "implementation";
    case 0: 
      return "component";
    }
    return null;
  }
  
  public Image getImage()
  {
    if (fObject.getType() == 1) {
      return SharedImages.getImage("icons/obj16/class_obj.gif");
    }
    if (fObject.getType() == 2) {
      return SharedImages.getImage("icons/obj16/properties_obj.gif");
    }
    if (fObject.getType() == 3) {
      return SharedImages.getImage("icons/obj16/property_obj.gif");
    }
    if (fObject.getType() == 5) {
      return SharedImages.getImage("icons/obj16/int_obj.gif");
    }
    if (fObject.getType() == 6) {
      return SharedImages.getImage("icons/obj16/reference_obj.gif");
    }
    if (fObject.getType() == 0) {
      return SharedImages.getImage("icons/obj16/component_obj.gif");
    }
    if (fObject.getType() == 4) {
      return SharedImages.getImage("icons/obj16/service_obj.gif");
    }
    return null;
  }
  
  public Point getSelection(IDocument document)
  {
    return new Point(fStartOffset + fObject.toString().length(), 0);
  }
}

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

import java.util.ArrayList;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.contentassist.ContentAssistEvent;
import org.eclipse.jface.text.contentassist.ICompletionListener;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.pde.core.IBaseModel;
import org.eclipse.pde.internal.core.text.AbstractEditingModel;
import org.eclipse.pde.internal.core.text.IDocumentAttributeNode;
import org.eclipse.pde.internal.core.text.IDocumentElementNode;
import org.eclipse.pde.internal.core.text.IDocumentRange;
import org.eclipse.pde.internal.core.text.IDocumentTextNode;
import org.eclipse.pde.internal.core.text.IReconcilingParticipant;
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.IDSObject;
import org.eclipse.pde.internal.ds.core.IDSProvide;
import org.eclipse.pde.internal.ds.core.IDSService;
import org.eclipse.pde.internal.ds.core.text.DSModel;
import org.eclipse.pde.internal.ui.editor.PDESourcePage;
import org.eclipse.pde.internal.ui.editor.context.InputContext;

public class DSContentAssistProcessor
  extends TypePackageCompletionProcessor
  implements IContentAssistProcessor, ICompletionListener
{
  protected boolean fAssistSessionStarted;
  private PDESourcePage fSourcePage;
  private IDocumentRange fRange;
  private static final int F_NO_ASSIST = 0;
  private static final int F_ADD_ATTRIB = 1;
  private static final int F_ADD_CHILD = 2;
  private static final int F_OPEN_TAG = 3;
  
  public DSContentAssistProcessor(PDESourcePage sourcePage)
  {
    fSourcePage = sourcePage;
  }
  
  public void assistSessionEnded(ContentAssistEvent event)
  {
    fRange = null;
  }
  
  public void assistSessionStarted(ContentAssistEvent event)
  {
    fAssistSessionStarted = true;
  }
  
  public void selectionChanged(ICompletionProposal proposal, boolean smartToggle) {}
  
  public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset)
  {
    IDocument doc = viewer.getDocument();
    IBaseModel model = fSourcePage.getInputContext().getModel();
    if (((model instanceof AbstractEditingModel)) && (fSourcePage.isDirty()) && 
      (((AbstractEditingModel)model).isStale()) && (fRange == null))
    {
      ((AbstractEditingModel)model).reconciled(doc);
    }
    else if (fAssistSessionStarted)
    {
      ((AbstractEditingModel)model).reconciled(doc);
      fAssistSessionStarted = false;
    }
    if (fRange == null)
    {
      assignRange(offset);
    }
    else
    {
      boolean resetAndReconcile = false;
      if (!(fRange instanceof IDocumentAttributeNode)) {
        resetAndReconcile = true;
      }
      if (resetAndReconcile)
      {
        fRange = null;
        if ((model instanceof IReconcilingParticipant)) {
          ((IReconcilingParticipant)model).reconciled(doc);
        }
      }
    }
    DSContentAssistText caText = DSContentAssistText.parse(offset, doc);
    if (caText != null) {
      return computeCATextProposal(doc, offset, caText);
    }
    if ((fRange instanceof IDocumentAttributeNode)) {
      return computeCompletionProposal((IDocumentAttributeNode)fRange, 
        offset, doc);
    }
    if ((fRange instanceof IDocumentElementNode)) {
      return computeCompletionProposal((IDocumentElementNode)fRange, 
        offset, doc);
    }
    return null;
  }
  
  private ICompletionProposal[] computeCATextProposal(IDocument doc, int offset, DSContentAssistText caText)
  {
    fRange = fSourcePage.getRangeElement(offset, true);
    if ((fRange != null) && ((fRange instanceof IDocumentTextNode))) {
      fRange = ((IDocumentTextNode)fRange).getEnclosingElement();
    }
    if ((fRange != null) && ((fRange instanceof IDocumentElementNode))) {
      return computeAddChildProposal((IDocumentElementNode)fRange, 
        caText.getStartOffset(), doc, caText.getText());
    }
    return null;
  }
  
  private ICompletionProposal[] computeCompletionProposal(IDocumentAttributeNode attr, int offset, IDocument doc)
  {
    if (offset < attr.getValueOffset()) {
      return null;
    }
    int[] offests = { offset, offset, offset };
    String[] guess = guessContentRequest(offests, doc, false);
    if (guess == null) {
      return null;
    }
    String element = guess[0];
    
    String attribute = guess[1];
    
    String attrValue = guess[2];
    
    int attrValueLength = attrValue == null ? 0 : attrValue.length();
    int startOffset = offests[2] + 1;
    if ((element != null) && 
      (element.equals("scr:component")))
    {
      boolean isAttrImmediate = attribute == null ? false : attribute
        .equals("immediate");
      boolean isAttrEnabled = attribute == null ? false : attribute
        .equals("enabled");
      boolean isAttrConfigPolicy = attribute == null ? false : attribute
        .equals("configuration-policy");
      if ((isAttrImmediate) || (isAttrEnabled)) {
        return getCompletionBooleans(startOffset, attrValueLength);
      }
      if (isAttrConfigPolicy) {
        return getConfigurationPolicyValues(attrValueLength, 
          startOffset);
      }
    }
    else if ((element != null) && 
      (element.equals("service")))
    {
      boolean isAttrServFactory = attribute == null ? false : attribute
        .equals("servicefactory");
      if (isAttrServFactory) {
        return getCompletionBooleans(startOffset, attrValueLength);
      }
    }
    else if ((element != null) && 
      (element.equals("reference")))
    {
      boolean isAttrCardinality = attribute == null ? false : attribute
        .equals("cardinality");
      boolean isAttrPolicy = attribute == null ? false : attribute
        .equals("policy");
      if (isAttrCardinality) {
        return getReferenceCardinalityValues(attrValueLength, 
          startOffset);
      }
      if (isAttrPolicy) {
        return getReferencePolicyValues(attrValueLength, startOffset);
      }
    }
    else if ((element != null) && 
      (element.equals("property")))
    {
      boolean isAttrType = attribute == null ? false : attribute
        .equals("type");
      if (isAttrType) {
        return getPropertyTypeValues(attrValueLength, startOffset);
      }
    }
    return null;
  }
  
  private ICompletionProposal[] getReferencePolicyValues(int attrValueLength, int startOffset)
  {
    return new ICompletionProposal[] {
      new TypeCompletionProposal(
      "static", null, 
      "static", 
      startOffset, 
      attrValueLength), 
      new TypeCompletionProposal(
      "dynamic", null, 
      "dynamic", 
      startOffset, attrValueLength) };
  }
  
  private ICompletionProposal[] getConfigurationPolicyValues(int attrValueLength, int startOffset)
  {
    return new ICompletionProposal[] {
      new TypeCompletionProposal(
      "ignore", 
      null, 
      "ignore", 
      startOffset, attrValueLength), 
      new TypeCompletionProposal(
      "optional", null, 
      "optional", 
      startOffset, attrValueLength), 
      new TypeCompletionProposal(
      "require", null, 
      "require", 
      startOffset, attrValueLength) };
  }
  
  private ICompletionProposal[] getReferenceCardinalityValues(int attrValueLength, int startOffset)
  {
    return new ICompletionProposal[] {
      new TypeCompletionProposal(
      "0..1", 
      null, 
      "0..1", 
      startOffset, 
      attrValueLength), 
      new TypeCompletionProposal(
      "0..n", null, 
      "0..n", 
      startOffset, attrValueLength), 
      new TypeCompletionProposal(
      "1..1", null, 
      "1..1", 
      startOffset, attrValueLength), 
      new TypeCompletionProposal(
      "1..n", null, 
      "1..n", 
      startOffset, attrValueLength) };
  }
  
  private ICompletionProposal[] getPropertyTypeValues(int attrValueLength, int startOffset)
  {
    return new ICompletionProposal[] {
      new TypeCompletionProposal(
      "String", null, 
      "String", startOffset, 
      attrValueLength), 
      new TypeCompletionProposal(
      "Long", null, 
      "Long", startOffset, 
      attrValueLength), 
      new TypeCompletionProposal(
      "Double", null, 
      "Double", startOffset, 
      attrValueLength), 
      new TypeCompletionProposal(
      "Float", null, 
      "Float", startOffset, 
      attrValueLength), 
      new TypeCompletionProposal(
      "Integer", null, 
      "Integer", startOffset, 
      attrValueLength), 
      new TypeCompletionProposal(
      "Byte", null, 
      "Byte", startOffset, 
      attrValueLength), 
      new TypeCompletionProposal(
      "Character", null, 
      "Character", startOffset, 
      attrValueLength), 
      new TypeCompletionProposal(
      "Boolean", null, 
      "Boolean", startOffset, 
      attrValueLength), 
      new TypeCompletionProposal(
      "Short", null, 
      "Short", startOffset, 
      attrValueLength) };
  }
  
  private ICompletionProposal[] getCompletionBooleans(int startOffset, int attrValueLength)
  {
    return new ICompletionProposal[] {
      new TypeCompletionProposal("true", null, 
      "true", startOffset, attrValueLength), 
      new TypeCompletionProposal("false", null, 
      "false", startOffset, attrValueLength) };
  }
  
  private ICompletionProposal[] computeCompletionProposal(IDocumentElementNode node, int offset, IDocument doc)
  {
    int prop_type = determineAssistType(node, doc, offset);
    switch (prop_type)
    {
    case 1: 
      return computeAddAttributeProposal(node, offset, doc, null, node
        .getXMLTagName());
    case 2: 
      return computeAddChildProposal(node, offset, doc, null);
    }
    return null;
  }
  
  private ICompletionProposal[] computeAddAttributeProposal(IDocumentElementNode node, int offset, IDocument doc, String filter, String tag)
  {
    ArrayList proposals = new ArrayList();
    if (!(node instanceof IDSObject)) {
      return null;
    }
    String[] attributesList = ((IDSObject)node).getAttributesNames();
    if ((attributesList == null) || (attributesList.length == 0)) {
      return null;
    }
    for (int i = 0; i < attributesList.length; i++)
    {
      String attribute = attributesList[i];
      
      IDocumentAttributeNode[] nodeAttributes = node
        .getNodeAttributes();
      boolean EqualToAnyItem = false;
      for (int j = 0; j < nodeAttributes.length; j++)
      {
        IDocumentAttributeNode documentAttributeNode = nodeAttributes[j];
        
        EqualToAnyItem = EqualToAnyItem | attribute.equals(documentAttributeNode.getAttributeName());
      }
      if (!EqualToAnyItem)
      {
        DSAttrCompletionProposal dsAttrCompletionProposal = new DSAttrCompletionProposal(
          attributesList[i], offset, 0);
        addFilteredProposal(offset, proposals, 
          dsAttrCompletionProposal, filter);
      }
    }
    if (proposals.size() > 0)
    {
      ICompletionProposal[] proposalsArray = new ICompletionProposal[proposals
        .size()];
      for (int i = 0; i < proposals.size(); i++) {
        proposalsArray[i] = ((ICompletionProposal)proposals.get(i));
      }
      return proposalsArray;
    }
    return null;
  }
  
  private ICompletionProposal[] computeAddChildProposal(IDocumentElementNode node, int offset, IDocument doc, String filter)
  {
    if ((node instanceof IDSComponent)) {
      return computeRootNodeProposals(node, offset, filter);
    }
    if ((node instanceof IDSService))
    {
      DSModel model = (DSModel)fSourcePage.getInputContext().getModel();
      IDSProvide provide = model.getFactory().createProvide();
      return new DSCompletionProposal[] { new DSCompletionProposal(
        provide, offset) };
    }
    return null;
  }
  
  private ICompletionProposal[] computeRootNodeProposals(IDocumentElementNode node, int offset, String filter)
  {
    ArrayList proposals = new ArrayList();
    IDSModel model = (DSModel)fSourcePage.getInputContext().getModel();
    
    IDSComponent component = model.getDSComponent();
    
    int length = filter != null ? filter.length() : 0;
    
    addFilteredProposal(offset, proposals, new DSCompletionProposal(model
      .getFactory().createProperty(), offset, length), 
      filter);
    addFilteredProposal(offset, proposals, new DSCompletionProposal(model
      .getFactory().createProperties(), offset, length), 
      filter);
    addFilteredProposal(offset, proposals, new DSCompletionProposal(model
      .getFactory().createReference(), offset, length), 
      filter);
    boolean hasService = component.getService() != null;
    if (!hasService) {
      addFilteredProposal(offset, proposals, new DSCompletionProposal(
        model.getFactory().createService(), offset, length), filter);
    }
    if (component.getImplementation() == null) {
      addFilteredProposal(offset, proposal
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