Examples of ITypedRegion


Examples of org.eclipse.jface.text.ITypedRegion

  public IReconcilableModel getModel() {
    return getInputModel();
  }

  public String getPartitionType(IDocument doc, int offset) {
    ITypedRegion tr = getPartition(doc, offset);
    return (tr != null) ? tr.getType() : IStructuredPartitions.UNKNOWN_PARTITION;
  }
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

   
    //remove in reverse order as to not effect offset of other regions
    for(int i = commentRegions.size()-1; i >= 0; --i) {
      try {
        //get the comment region
        ITypedRegion typedRegion = (ITypedRegion)commentRegions.get(i);
        IRegion commentRegion = new Region(typedRegion.getOffset(), typedRegion.getLength());

        /* because of the nature of structured regions the comment region could actually be a
         * sub region that needs to be drilled down too
         */
        if(!this.alreadyCommenting(document, commentRegion)) {
          IStructuredDocumentRegion structuredRegion =
            document.getRegionAtCharacterOffset(commentRegion.getOffset());
         
          commentRegion = new Region(structuredRegion.getStartOffset(), structuredRegion.getLength());
         
          if(!this.alreadyCommenting(document, commentRegion)) {
            ITextRegion enclosedRegion = structuredRegion.getRegionAtCharacterOffset(typedRegion.getOffset());
            int enclosedOffset = structuredRegion.getStartOffset(enclosedRegion);
            commentRegion = new Region(enclosedOffset, structuredRegion.getTextEndOffset(enclosedRegion)-enclosedOffset);
          }
        }
       
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

   * @param textSelection
   * @return
   */
  private FindOccurrencesProcessor getProcessorForCurrentSelection(IDocument document, ITextSelection textSelection) {
    // check if we have an action that's enabled on the current partition
    ITypedRegion tr = getPartition(document, textSelection);
    String partition = tr != null ? tr.getType() : ""; //$NON-NLS-1$

    Iterator it = getProcessors().iterator();
    FindOccurrencesProcessor processor = null;
    while (it.hasNext()) {
      processor = (FindOccurrencesProcessor) it.next();
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

    }
    return null;
  }

  private ITypedRegion getPartition(IDocument document, ITextSelection textSelection) {
    ITypedRegion region = null;
    if (textSelection != null) {
      try {
        region = document.getPartition(textSelection.getOffset());
      }
      catch (BadLocationException e) {
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

        public Image getColumnImage(Object element, int columnIndex) {
          return null;
        }

        public String getColumnText(Object element, int columnIndex) {
          ITypedRegion partition = (ITypedRegion) element;
          String text = null;
          switch (columnIndex) {
            case 0 :
              text = Integer.toString(partition.getOffset());
              break;
            case 1 :
              text = Integer.toString(partition.getLength());
              break;
            case 2 :
              text = partition.getType();
              break;
          }
          if (text == null)
            text = ""; //$NON-NLS-1$
          return text;
        }

        public boolean isLabelProperty(Object element, String property) {
          return false;
        }

        public void removeListener(ILabelProviderListener listener) {
        }
      });
      TableLayout tlayout = new TableLayout();
      CellEditor[] cellEditors = new CellEditor[columns.length];
      int columnWidths[] = new int[]{Display.getCurrent().getBounds().width / 14, Display.getCurrent().getBounds().width / 14, Display.getCurrent().getBounds().width / 5};
      for (int i = 0; i < columns.length; i++) {
        tlayout.addColumnData(new ColumnWeightData(1));
        TableColumn tc = new TableColumn(fPartitionTable.getTable(), SWT.NONE);
        tc.setText(columns[i]);
        tc.setResizable(true);
        tc.setWidth(columnWidths[i]);
      }
      fPartitionTable.setCellEditors(cellEditors);
      fPartitionTable.setColumnProperties(columns);
      final String[] partitionings = (fDocument instanceof IDocumentExtension3) ? ((IDocumentExtension3) fDocument).getPartitionings() : new String[]{IDocumentExtension3.DEFAULT_PARTITIONING};
      partitioningCombo.setItems(partitionings);
      partitioningCombo.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
          ISelection sel = fTextEditor.getSelectionProvider().getSelection();
          ITextSelection textSelection = (ITextSelection) sel;
          try {
            String partitionerText = fDocument instanceof IDocumentExtension3 ? ((IDocumentExtension3) fDocument).getDocumentPartitioner(partitioningCombo.getItem(partitioningCombo.getSelectionIndex())).toString() : ("" + fDocument.getDocumentPartitioner()); //$NON-NLS-1$
            partitionerInstanceLabel.setText(SSEUIMessages.OffsetStatusLineContributionItem_13 + partitionerText); //$NON-NLS-1$
            fPartitionTable.setInput(TextUtilities.computePartitioning(fDocument, partitioningCombo.getItem(partitioningCombo.getSelectionIndex()), textSelection.getOffset(), textSelection.getLength(), true));
          }
          catch (BadLocationException e1) {
            fPartitionTable.setInput(new ITypedRegion[0]);
          }
        }
      });
      try {
        if (partitionings.length > 0) {
          String selectedPartitioning = partitioningCombo.getItem(0);
          if (Utilities.contains(partitionings, IStructuredPartitioning.DEFAULT_STRUCTURED_PARTITIONING)) {
            selectedPartitioning = IStructuredPartitioning.DEFAULT_STRUCTURED_PARTITIONING;
            for (int i = 0; i < partitionings.length; i++) {
              if (partitionings[i].equals(IStructuredPartitioning.DEFAULT_STRUCTURED_PARTITIONING)) {
                partitioningCombo.select(i);
              }
            }
          }
          else {
            partitioningCombo.select(0);
          }
          ISelection sel = fTextEditor.getSelectionProvider().getSelection();
          ITextSelection textSelection = (ITextSelection) sel;
          ITypedRegion[] partitions = TextUtilities.computePartitioning(fDocument, selectedPartitioning, textSelection.getOffset(), textSelection.getLength(), true);
          fPartitionTable.setInput(partitions);
          String partitionerText = fDocument instanceof IDocumentExtension3 ? ((IDocumentExtension3) fDocument).getDocumentPartitioner(partitioningCombo.getItem(partitioningCombo.getSelectionIndex())).toString() : ("" + fDocument.getDocumentPartitioner()); //$NON-NLS-1$
          partitionerInstanceLabel.setText(SSEUIMessages.OffsetStatusLineContributionItem_13 + partitionerText); //$NON-NLS-1$
        }
        else {
          ISelection sel = fTextEditor.getSelectionProvider().getSelection();
          ITextSelection textSelection = (ITextSelection) sel;
          fPartitionTable.setInput(fDocument.computePartitioning(textSelection.getOffset(), textSelection.getLength()));
        }
      }
      catch (BadLocationException e1) {
        fPartitionTable.setInput(new ITypedRegion[0]);
      }
      partitioningCombo.setFocus();


      final StyledText text = new StyledText(sash, SWT.MULTI | SWT.READ_ONLY);
      fPartitionTable.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
          if (event.getSelection() instanceof IStructuredSelection) {
            IRegion partition = (IRegion) ((IStructuredSelection) event.getSelection()).getFirstElement();
            IDocument document = fTextEditor.getDocumentProvider().getDocument(fTextEditor.getEditorInput());
            String source;
            try {
              source = document.get(partition.getOffset(), partition.getLength());
              text.setEnabled(true);
              text.setText(source);
            }
            catch (BadLocationException e) {
              e.printStackTrace();
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

      fDocumentChanging= true;
      if (fCachedRedrawState) {
        try {
          int offset= e.getOffset() + e.getLength();
          ITypedRegion region= getPartition(e.getDocument(), offset);
          fRememberedPosition= new TypedPosition(region);
          e.getDocument().addPosition(fPositionCategory, fRememberedPosition);
        } catch (BadLocationException x) {
          // can not happen
        } catch (BadPositionCategoryException x) {
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

    catch (BadLocationException e1) {
    }
    finally {
      if (type == null) {
        try {
          ITypedRegion region = document.getPartition(offset);
          if (region != null) {
            type = region.getType();
          }
        }
        catch (BadLocationException e) {
          type = null;
        }
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

    fPartitionTypes = new HashSet();
  }

  public ReconcileAnnotationKey createKey(IStructuredDocumentRegion sdRegion, int scope) {

    ITypedRegion tr = getPartition(sdRegion);
    String partitionType = (tr != null) ? tr.getType() : IStructuredPartitions.UNKNOWN_PARTITION;
    return createKey(partitionType, scope);
  }
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

  /**
   * @param sdRegion
   * @return
   */
  protected ITypedRegion getPartition(IStructuredDocumentRegion sdRegion) {
    ITypedRegion tr = null;
    if (!sdRegion.isDeleted())
      tr = getPartition(sdRegion.getParentDocument(), sdRegion.getStartOffset());
    return tr;
  }
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

      tr = getPartition(sdRegion.getParentDocument(), sdRegion.getStartOffset());
    return tr;
  }

  private ITypedRegion getPartition(IDocument doc, int offset) {
    ITypedRegion tr = null;
    // not sure why document would ever be null, but put in this
    // guard for
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=86069
    if (doc != null) {
      try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.