org.eclipse.ui.workbench.texteditor_3.7.0.v20110928-1504

16:48:31.936 INFO  jd.cli.Main - Decompiling org.eclipse.ui.workbench.texteditor_3.7.0.v20110928-1504.jar
package org.eclipse.ui.contentassist;

import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;

class ContentAssistHandler$1
  implements DisposeListener
{
  final ContentAssistHandler this$0;
  
  ContentAssistHandler$1(ContentAssistHandler paramContentAssistHandler)
  {
    this$0 = paramContentAssistHandler;
  }
  
  public void widgetDisposed(DisposeEvent e)
  {
    this$0.setEnabled(false);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.contentassist.ContentAssistHandler.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.contentassist;

import org.eclipse.jface.bindings.TriggerSequence;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.texteditor.NLSUtility;
import org.eclipse.ui.keys.IBindingService;

class ContentAssistHandler$2
  extends LabelProvider
{
  final ContentAssistHandler this$0;
  
  ContentAssistHandler$2(ContentAssistHandler paramContentAssistHandler)
  {
    this$0 = paramContentAssistHandler;
  }
  
  public String getText(Object element)
  {
    Class tmp6_3 = ContentAssistHandler.class$0;
    if (tmp6_3 == null)
    {
      tmp6_3;
      try
      {
        tmpTernaryOp = (ContentAssistHandler.class$0 = Class.forName("org.eclipse.ui.keys.IBindingService"));
      }
      catch (ClassNotFoundException localClassNotFoundException)
      {
        throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
      }
    }
    IBindingService bindingService = (IBindingService)PlatformUI.getWorkbench().getAdapter(tmp6_3);
    TriggerSequence[] activeBindings = bindingService.getActiveBindingsFor("org.eclipse.ui.edit.text.contentAssist.proposals");
    if (activeBindings.length == 0) {
      return ContentAssistMessages.ContentAssistHandler_contentAssistAvailable;
    }
    return NLSUtility.format(ContentAssistMessages.ContentAssistHandler_contentAssistAvailableWithKeyBinding, activeBindings[0].format());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.contentassist.ContentAssistHandler.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.contentassist;

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

class ContentAssistHandler$3
  implements FocusListener
{
  final ContentAssistHandler this$0;
  
  ContentAssistHandler$3(ContentAssistHandler paramContentAssistHandler)
  {
    this$0 = paramContentAssistHandler;
  }
  
  public void focusGained(FocusEvent e)
  {
    if (ContentAssistHandler.access$0(this$0) == null) {
      ContentAssistHandler.access$1(this$0);
    }
  }
  
  public void focusLost(FocusEvent e)
  {
    if (ContentAssistHandler.access$0(this$0) != null) {
      ContentAssistHandler.access$2(this$0);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.contentassist.ContentAssistHandler.3
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.contentassist;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.contentassist.SubjectControlContentAssistant;

class ContentAssistHandler$4
  extends AbstractHandler
{
  final ContentAssistHandler this$0;
  
  ContentAssistHandler$4(ContentAssistHandler paramContentAssistHandler)
  {
    this$0 = paramContentAssistHandler;
  }
  
  public Object execute(ExecutionEvent event)
    throws ExecutionException
  {
    if (this$0.isEnabled()) {
      ContentAssistHandler.access$3(this$0).showPossibleCompletions();
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.contentassist.ContentAssistHandler.4
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.contentassist;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.jface.bindings.TriggerSequence;
import org.eclipse.jface.contentassist.AbstractControlContentAssistSubjectAdapter;
import org.eclipse.jface.contentassist.ComboContentAssistSubjectAdapter;
import org.eclipse.jface.contentassist.SubjectControlContentAssistant;
import org.eclipse.jface.contentassist.TextContentAssistSubjectAdapter;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.IHandlerActivation;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.internal.texteditor.NLSUtility;
import org.eclipse.ui.keys.IBindingService;

/**
 * @deprecated
 */
public class ContentAssistHandler
{
  private Control fControl;
  private AbstractControlContentAssistSubjectAdapter fContentAssistSubjectAdapter;
  private SubjectControlContentAssistant fContentAssistant;
  private FocusListener fFocusListener;
  private IHandlerActivation fHandlerActivation;
  static Class class$0;
  
  public static ContentAssistHandler createHandlerForCombo(Combo combo, SubjectControlContentAssistant contentAssistant)
  {
    return new ContentAssistHandler(combo, new ComboContentAssistSubjectAdapter(combo), contentAssistant);
  }
  
  public static ContentAssistHandler createHandlerForText(Text text, SubjectControlContentAssistant contentAssistant)
  {
    return new ContentAssistHandler(text, new TextContentAssistSubjectAdapter(text), contentAssistant);
  }
  
  private ContentAssistHandler(Control control, AbstractControlContentAssistSubjectAdapter subjectAdapter, SubjectControlContentAssistant contentAssistant)
  {
    fControl = control;
    fContentAssistant = contentAssistant;
    fContentAssistSubjectAdapter = subjectAdapter;
    setEnabled(true);
    fControl.addDisposeListener(new DisposeListener()
    {
      public void widgetDisposed(DisposeEvent e)
      {
        setEnabled(false);
      }
    });
  }
  
  public boolean isEnabled()
  {
    return fFocusListener != null;
  }
  
  public void setEnabled(boolean enable)
  {
    if (enable == isEnabled()) {
      return;
    }
    if (enable) {
      enable();
    } else {
      disable();
    }
  }
  
  private void enable()
  {
    if (!fControl.isDisposed())
    {
      fContentAssistant.install(fContentAssistSubjectAdapter);
      installCueLabelProvider();
      installFocusListener();
      if (fControl.isFocusControl()) {
        activateHandler();
      }
    }
  }
  
  private void disable()
  {
    if (!fControl.isDisposed())
    {
      fContentAssistant.uninstall();
      fContentAssistSubjectAdapter.setContentAssistCueProvider(null);
      fControl.removeFocusListener(fFocusListener);
      fFocusListener = null;
      if (fHandlerActivation != null) {
        deactivateHandler();
      }
    }
  }
  
  private void installCueLabelProvider()
  {
    ILabelProvider labelProvider = new LabelProvider()
    {
      public String getText(Object element)
      {
        Class tmp6_3 = ContentAssistHandler.class$0;
        if (tmp6_3 == null)
        {
          tmp6_3;
          try
          {
            tmpTernaryOp = (ContentAssistHandler.class$0 = Class.forName("org.eclipse.ui.keys.IBindingService"));
          }
          catch (ClassNotFoundException localClassNotFoundException)
          {
            throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
          }
        }
        IBindingService bindingService = (IBindingService)PlatformUI.getWorkbench().getAdapter(tmp6_3);
        TriggerSequence[] activeBindings = bindingService.getActiveBindingsFor("org.eclipse.ui.edit.text.contentAssist.proposals");
        if (activeBindings.length == 0) {
          return ContentAssistMessages.ContentAssistHandler_contentAssistAvailable;
        }
        return NLSUtility.format(ContentAssistMessages.ContentAssistHandler_contentAssistAvailableWithKeyBinding, activeBindings[0].format());
      }
    };
    fContentAssistSubjectAdapter.setContentAssistCueProvider(labelProvider);
  }
  
  private void installFocusListener()
  {
    fFocusListener = new FocusListener()
    {
      public void focusGained(FocusEvent e)
      {
        if (fHandlerActivation == null) {
          ContentAssistHandler.this.activateHandler();
        }
      }
      
      public void focusLost(FocusEvent e)
      {
        if (fHandlerActivation != null) {
          ContentAssistHandler.this.deactivateHandler();
        }
      }
    };
    fControl.addFocusListener(fFocusListener);
  }
  
  private void activateHandler()
  {
    IHandlerService handlerService = (IHandlerService)PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
    if (handlerService == null) {
      return;
    }
    IHandler handler = new AbstractHandler()
    {
      public Object execute(ExecutionEvent event)
        throws ExecutionException
      {
        if (isEnabled()) {
          fContentAssistant.showPossibleCompletions();
        }
        return null;
      }
    };
    fHandlerActivation = handlerService.activateHandler("org.eclipse.ui.edit.text.contentAssist.proposals", handler);
  }
  
  private void deactivateHandler()
  {
    IHandlerService handlerService = (IHandlerService)PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
    if (handlerService != null) {
      handlerService.deactivateHandler(fHandlerActivation);
    }
    fHandlerActivation = null;
  }
}

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

import org.eclipse.osgi.util.NLS;

final class ContentAssistMessages
  extends NLS
{
  private static final String BUNDLE_NAME = ContentAssistMessages.class.getName();
  public static String ContentAssistHandler_contentAssistAvailable;
  public static String ContentAssistHandler_contentAssistAvailableWithKeyBinding;
  
  static
  {
    NLS.initializeMessages(BUNDLE_NAME, ContentAssistMessages.class);
  }
}

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

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IExecutionListener;
import org.eclipse.core.commands.NotHandledException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.VerifyEvent;

final class CompoundEditExitStrategy$EventListener
  implements MouseListener, FocusListener, VerifyKeyListener, IExecutionListener
{
  final CompoundEditExitStrategy this$0;
  
  private CompoundEditExitStrategy$EventListener(CompoundEditExitStrategy paramCompoundEditExitStrategy)
  {
    this$0 = paramCompoundEditExitStrategy;
  }
  
  CompoundEditExitStrategy$EventListener(CompoundEditExitStrategy paramCompoundEditExitStrategy, EventListener paramEventListener)
  {
    this(paramCompoundEditExitStrategy);
  }
  
  public void mouseDoubleClick(MouseEvent e)
  {
    CompoundEditExitStrategy.access$0(this$0);
  }
  
  public void mouseDown(MouseEvent e)
  {
    CompoundEditExitStrategy.access$0(this$0);
  }
  
  public void focusLost(FocusEvent e)
  {
    CompoundEditExitStrategy.access$0(this$0);
  }
  
  public void preExecute(String commandId, ExecutionEvent event)
  {
    for (int i = 0; i < CompoundEditExitStrategy.access$1(this$0).length; i++) {
      if (commandId.equals(CompoundEditExitStrategy.access$1(this$0)[i])) {
        return;
      }
    }
    CompoundEditExitStrategy.access$0(this$0);
  }
  
  public void verifyKey(VerifyEvent event)
  {
    int maskWithoutShift = SWT.MODIFIER_MASK & 0xFFFDFFFF;
    if (((keyCode & SWT.MODIFIER_MASK) == 0) && ((stateMask & maskWithoutShift) == 0)) {
      CompoundEditExitStrategy.access$0(this$0);
    }
  }
  
  public void mouseUp(MouseEvent e) {}
  
  public void focusGained(FocusEvent e) {}
  
  public void notHandled(String commandId, NotHandledException exception) {}
  
  public void postExecuteFailure(String commandId, ExecutionException exception) {}
  
  public void postExecuteSuccess(String commandId, Object returnValue) {}
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.texteditor.CompoundEditExitStrategy.EventListener
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.texteditor;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IExecutionListener;
import org.eclipse.core.commands.NotHandledException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;

public final class CompoundEditExitStrategy
{
  private final String[] fCommandIds;
  
  private final class EventListener
    implements MouseListener, FocusListener, VerifyKeyListener, IExecutionListener
  {
    EventListener(EventListener paramEventListener)
    {
      this();
    }
    
    public void mouseDoubleClick(MouseEvent e)
    {
      CompoundEditExitStrategy.this.fireEndCompoundEdit();
    }
    
    public void mouseDown(MouseEvent e)
    {
      CompoundEditExitStrategy.this.fireEndCompoundEdit();
    }
    
    public void focusLost(FocusEvent e)
    {
      CompoundEditExitStrategy.this.fireEndCompoundEdit();
    }
    
    public void preExecute(String commandId, ExecutionEvent event)
    {
      for (int i = 0; i < fCommandIds.length; i++) {
        if (commandId.equals(fCommandIds[i])) {
          return;
        }
      }
      CompoundEditExitStrategy.this.fireEndCompoundEdit();
    }
    
    public void verifyKey(VerifyEvent event)
    {
      int maskWithoutShift = SWT.MODIFIER_MASK & 0xFFFDFFFF;
      if (((keyCode & SWT.MODIFIER_MASK) == 0) && ((stateMask & maskWithoutShift) == 0)) {
        CompoundEditExitStrategy.this.fireEndCompoundEdit();
      }
    }
    
    private EventListener() {}
    
    public void mouseUp(MouseEvent e) {}
    
    public void focusGained(FocusEvent e) {}
    
    public void notHandled(String commandId, NotHandledException exception) {}
    
    public void postExecuteFailure(String commandId, ExecutionException exception) {}
    
    public void postExecuteSuccess(String commandId, Object returnValue) {}
  }
  
  private final EventListener fEventListener = new EventListener(null);
  private final ListenerList fListenerList = new ListenerList(1);
  private ITextViewer fViewer;
  private StyledText fWidgetEventSource;
  
  public CompoundEditExitStrategy(String commandId)
  {
    if (commandId == null) {
      throw new NullPointerException("commandId");
    }
    fCommandIds = new String[] { commandId };
  }
  
  public CompoundEditExitStrategy(String[] commandIds)
  {
    for (int i = 0; i < commandIds.length; i++) {
      if (commandIds[i] == null) {
        throw new NullPointerException("commandIds[" + i + "]");
      }
    }
    fCommandIds = new String[commandIds.length];
    System.arraycopy(commandIds, 0, fCommandIds, 0, commandIds.length);
  }
  
  public void arm(ITextViewer viewer)
  {
    disarm();
    if (viewer == null) {
      throw new NullPointerException("editor");
    }
    fViewer = viewer;
    addListeners(fViewer);
  }
  
  public void disarm()
  {
    if (isInstalled())
    {
      removeListeners();
      fViewer = null;
    }
  }
  
  private void addListeners(ITextViewer viewer)
  {
    fWidgetEventSource = viewer.getTextWidget();
    if (fWidgetEventSource != null)
    {
      fWidgetEventSource.addVerifyKeyListener(fEventListener);
      fWidgetEventSource.addMouseListener(fEventListener);
      fWidgetEventSource.addFocusListener(fEventListener);
    }
    ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getAdapter(ICommandService.class);
    if (commandService != null) {
      commandService.addExecutionListener(fEventListener);
    }
  }
  
  private void removeListeners()
  {
    ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getAdapter(ICommandService.class);
    if (commandService != null) {
      commandService.removeExecutionListener(fEventListener);
    }
    if (fWidgetEventSource != null)
    {
      fWidgetEventSource.removeFocusListener(fEventListener);
      fWidgetEventSource.removeMouseListener(fEventListener);
      fWidgetEventSource.removeVerifyKeyListener(fEventListener);
      fWidgetEventSource = null;
    }
  }
  
  private boolean isInstalled()
  {
    return fViewer != null;
  }
  
  private void fireEndCompoundEdit()
  {
    disarm();
    Object[] listeners = fListenerList.getListeners();
    for (int i = 0; i < listeners.length; i++)
    {
      ICompoundEditListener listener = (ICompoundEditListener)listeners[i];
      try
      {
        listener.endCompoundEdit();
      }
      catch (Exception e)
      {
        IStatus status = new Status(4, "org.eclipse.ui.workbench.texteditor", 0, "listener notification failed", e);
        TextEditorPlugin.getDefault().getLog().log(status);
      }
    }
  }
  
  public void addCompoundListener(ICompoundEditListener listener)
  {
    fListenerList.add(listener);
  }
  
  public void removeCompoundListener(ICompoundEditListener listener)
  {
    fListenerList.remove(listener);
  }
}

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

import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.text.Position;
import org.eclipse.ui.IEditorInput;

public final class EditPosition
{
  private final IEditorInput fEditorInput;
  private final String fEditorId;
  private final Position fPosition;
  
  public EditPosition(IEditorInput editorInput, String editorId, Position pos)
  {
    Assert.isNotNull(editorInput);
    Assert.isNotNull(editorId);
    fEditorId = editorId;
    fEditorInput = editorInput;
    fPosition = pos;
  }
  
  public IEditorInput getEditorInput()
  {
    return fEditorInput;
  }
  
  public String getEditorId()
  {
    return fEditorId;
  }
  
  public Position getPosition()
  {
    return fPosition;
  }
}

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

import org.eclipse.osgi.util.NLS;

final class EditorMessages
  extends NLS
{
  private static final String BUNDLE_NAME = EditorMessages.class.getName();
  public static String Editor_error_gotoLastEditPosition_title;
  public static String Editor_error_gotoLastEditPosition_message;
  
  static
  {
    NLS.initializeMessages(BUNDLE_NAME, EditorMessages.class);
  }
}

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

import org.eclipse.jface.text.DefaultInformationControl;
import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.swt.widgets.Shell;

class FocusedInformationPresenter$DefaultInformationControlCreator
  implements IInformationControlCreator
{
  FocusedInformationPresenter$DefaultInformationControlCreator(DefaultInformationControlCreator paramDefaultInformationControlCreator)
  {
    this();
  }
  
  public IInformationControl createInformationControl(Shell shell)
  {
    return new DefaultInformationControl(shell, true);
  }
  
  private FocusedInformationPresenter$DefaultInformationControlCreator() {}
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.texteditor.FocusedInformationPresenter.DefaultInformationControlCreator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.texteditor;

import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.information.IInformationProvider;
import org.eclipse.jface.text.information.IInformationProviderExtension;
import org.eclipse.jface.text.information.IInformationProviderExtension2;

public final class FocusedInformationPresenter$InformationProvider
  implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2
{
  private IRegion fHoverRegion;
  private Object fHoverInfo;
  private IInformationControlCreator fControlCreator;
  
  public FocusedInformationPresenter$InformationProvider(IRegion hoverRegion, Object hoverInfo, IInformationControlCreator controlCreator)
  {
    fHoverRegion = hoverRegion;
    fHoverInfo = hoverInfo;
    fControlCreator = controlCreator;
  }
  
  public IRegion getSubject(ITextViewer textViewer, int invocationOffset)
  {
    return fHoverRegion;
  }
  
  /**
   * @deprecated
   */
  public String getInformation(ITextViewer textViewer, IRegion subject)
  {
    return fHoverInfo == null ? null : fHoverInfo.toString();
  }
  
  public Object getInformation2(ITextViewer textViewer, IRegion subject)
  {
    return fHoverInfo;
  }
  
  public IInformationControlCreator getInformationPresenterControlCreator()
  {
    return fControlCreator;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.texteditor.FocusedInformationPresenter.InformationProvider
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.texteditor;

import org.eclipse.jface.text.AbstractInformationControlManager;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DefaultInformationControl;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextUtilities;
import org.eclipse.jface.text.information.IInformationProvider;
import org.eclipse.jface.text.information.IInformationProviderExtension;
import org.eclipse.jface.text.information.IInformationProviderExtension2;
import org.eclipse.jface.text.information.InformationPresenter;
import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.IAnnotationHoverExtension;
import org.eclipse.jface.text.source.ILineRange;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.swt.widgets.Shell;

public class FocusedInformationPresenter
  extends InformationPresenter
{
  private final ISourceViewer fSourceViewer;
  private final SourceViewerConfiguration fSourceViewerConfiguration;
  
  public static final class InformationProvider
    implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2
  {
    private IRegion fHoverRegion;
    private Object fHoverInfo;
    private IInformationControlCreator fControlCreator;
    
    public InformationProvider(IRegion hoverRegion, Object hoverInfo, IInformationControlCreator controlCreator)
    {
      fHoverRegion = hoverRegion;
      fHoverInfo = hoverInfo;
      fControlCreator = controlCreator;
    }
    
    public IRegion getSubject(ITextViewer textViewer, int invocationOffset)
    {
      return fHoverRegion;
    }
    
    /**
     * @deprecated
     */
    public String getInformation(ITextViewer textViewer, IRegion subject)
    {
      return fHoverInfo == null ? null : fHoverInfo.toString();
    }
    
    public Object getInformation2(ITextViewer textViewer, IRegion subject)
    {
      return fHoverInfo;
    }
    
    public IInformationControlCreator getInformationPresenterControlCreator()
    {
      return fControlCreator;
    }
  }
  
  private static class DefaultInformationControlCreator
    implements IInformationControlCreator
  {
    DefaultInformationControlCreator(DefaultInformationControlCreator paramDefaultInformationControlCreator)
    {
      this();
    }
    
    public IInformationControl createInformationControl(Shell shell)
    {
      return new DefaultInformationControl(shell, true);
    }
    
    private DefaultInformationControlCreator() {}
  }
  
  public FocusedInformationPresenter(ISourceViewer sourceViewer, SourceViewerConfiguration sourceViewerConfiguration)
  {
    super(new DefaultInformationControlCreator(null));
    fSourceViewer = sourceViewer;
    fSourceViewerConfiguration = sourceViewerConfiguration;
    
    setSizeConstraints(100, 12, true, true);
    install(sourceViewer);
    setDocumentPartitioning(sourceViewerConfiguration.getConfiguredDocumentPartitioning(sourceViewer));
  }
  
  public boolean openFocusedAnnotationHover(IAnnotationHover annotationHover, int line)
  {
    try
    {
      Object hoverInfo;
      Object hoverInfo;
      if ((annotationHover instanceof IAnnotationHoverExtension))
      {
        IAnnotationHoverExtension extension = (IAnnotationHoverExtension)annotationHover;
        ILineRange hoverLineRange = extension.getHoverLineRange(fSourceViewer, line);
        if (hoverLineRange == null) {
          return false;
        }
        hoverInfo = extension.getHoverInfo(fSourceViewer, hoverLineRange, Integer.MAX_VALUE);
      }
      else
      {
        hoverInfo = annotationHover.getHoverInfo(fSourceViewer, line);
      }
      IDocument document = fSourceViewer.getDocument();
      int offset = document.getLineOffset(line);
      String contentType = TextUtilities.getContentType(document, fSourceViewerConfiguration.getConfiguredDocumentPartitioning(fSourceViewer), offset, true);
      
      IInformationControlCreator controlCreator = null;
      if ((annotationHover instanceof IInformationProviderExtension2)) {
        controlCreator = ((IInformationProviderExtension2)annotationHover).getInformationPresenterControlCreator();
      } else if ((annotationHover instanceof IAnnotationHoverExtension)) {
        controlCreator = ((IAnnotationHoverExtension)annotationHover).getHoverControlCreator();
      }
      IInformationProvider informationProvider = new InformationProvider(new Region(offset, 0), hoverInfo, controlCreator);
      
      setOffset(offset);
      setAnchor(AbstractInformationControlManager.ANCHOR_RIGHT);
      setMargins(4, 0);
      setInformationProvider(informationProvider, contentType);
      showInformation();
      
      return true;
    }
    catch (BadLocationException localBadLocationException) {}
    return false;
  }
}

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

import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.FindReplaceDocumentAdapter;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;

class HippieCompletionEngine$HippieCompletionBackwardIterator
  extends HippieCompletionEngine.HippieCompletionIterator
{
  private int fLastSearchPos;
  final HippieCompletionEngine this$0;
  
  HippieCompletionEngine$HippieCompletionBackwardIterator(HippieCompletionEngine paramHippieCompletionEngine, IDocument paramIDocument, CharSequence paramCharSequence, int paramInt, HippieCompletionBackwardIterator paramHippieCompletionBackwardIterator)
  {
    this(paramHippieCompletionEngine, paramIDocument, paramCharSequence, paramInt);
  }
  
  private HippieCompletionEngine$HippieCompletionBackwardIterator(HippieCompletionEngine paramHippieCompletionEngine, IDocument document, CharSequence prefix, int firstPosition)
  {
    super(paramHippieCompletionEngine, document, prefix, firstPosition);this$0 = paramHippieCompletionEngine;fLastSearchPos = -1;
    calculateFirst();
  }
  
  protected void calculateNext()
    throws BadLocationException
  {
    if (fCurrentState == 0)
    {
      fCurrentState = 1;
      if (fFirstPosition <= 1)
      {
        fNext = null;
        fHasNext = false;
        return;
      }
      fSearcher = new FindReplaceDocumentAdapter(fDocument);
      
      fSearchPattern = ("(^|[\\s\\p{Z}[\\p{P}&&[\\P{Pc}]][\\p{S}&&[\\P{Sc}]]]+)" + HippieCompletionEngine.access$1(this$0, fPrefix));
      
      int length = fDocument.getLength();
      fNextPos = fFirstPosition;
      if (fNextPos >= length) {
        fNextPos = (length - 1);
      }
    }
    IRegion word;
    do
    {
      if (fNextPos <= 0)
      {
        fNext = null;
        fHasNext = false;
        return;
      }
      Assert.isTrue(fLastSearchPos != fNextPos, "Position did not change in loop (this would lead to recursion -- and should never happen).");
      
      fLastSearchPos = fNextPos;
      IRegion reg = fSearcher.find(fNextPos, fSearchPattern, false, true, false, true);
      if (reg == null)
      {
        fNext = null;
        fHasNext = false;
        return;
      }
      int wordSearchPos = reg.getOffset() + reg.getLength() - fPrefix.length();
      
      word = fSearcher.find(wordSearchPos, "[\\p{L}[\\p{Mn}[\\p{Pc}[\\p{Nd}[\\p{Nl}[\\p{Sc}]]]]]]+", true, true, false, true);
      fNextPos = (word.getOffset() - 1);
    } while ((word.getOffset() + word.getLength() > fFirstPosition) || 
    
      (word.getLength() <= fPrefix.length()));
    String found = fDocument.get(word.getOffset(), word.getLength());
    fHasNext = true;
    fNext = found.substring(fPrefix.length());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.texteditor.HippieCompletionEngine.HippieCompletionBackwardIterator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.texteditor;

import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.FindReplaceDocumentAdapter;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;

class HippieCompletionEngine$HippieCompletionForwardIterator
  extends HippieCompletionEngine.HippieCompletionIterator
{
  private boolean fCurrentWordLast;
  private String fCurrentWordCompletion;
  final HippieCompletionEngine this$0;
  
  HippieCompletionEngine$HippieCompletionForwardIterator(HippieCompletionEngine paramHippieCompletionEngine, IDocument paramIDocument, CharSequence paramCharSequence, int paramInt, boolean paramBoolean, HippieCompletionForwardIterator paramHippieCompletionForwardIterator)
  {
    this(paramHippieCompletionEngine, paramIDocument, paramCharSequence, paramInt, paramBoolean);
  }
  
  private HippieCompletionEngine$HippieCompletionForwardIterator(HippieCompletionEngine paramHippieCompletionEngine, IDocument document, CharSequence prefix, int firstPosition, boolean currentWordLast)
  {
    super(paramHippieCompletionEngine, document, prefix, firstPosition);this$0 = paramHippieCompletionEngine;fCurrentWordCompletion = null;
    fCurrentWordLast = currentWordLast;
    calculateFirst();
  }
  
  protected void calculateNext()
    throws BadLocationException
  {
    if (fCurrentState == 0)
    {
      if (fFirstPosition == fDocument.getLength())
      {
        fHasNext = false;
        return;
      }
      fSearcher = new FindReplaceDocumentAdapter(fDocument);
      if (fFirstPosition > 0)
      {
        fFirstPosition -= 1;
        
        fSearchPattern = ("[\\s\\p{Z}[\\p{P}&&[\\P{Pc}]][\\p{S}&&[\\P{Sc}]]]+" + HippieCompletionEngine.access$1(this$0, fPrefix));
      }
      else
      {
        fSearchPattern = ("(^|[\\s\\p{Z}[\\p{P}&&[\\P{Pc}]][\\p{S}&&[\\P{Sc}]]]+)" + HippieCompletionEngine.access$1(this$0, fPrefix));
      }
      fNextPos = fFirstPosition;
      fCurrentState = 1;
    }
    if (fCurrentState == 1)
    {
      fHasNext = false;
      IRegion reg = fSearcher.find(fNextPos, fSearchPattern, true, true, false, true);
      while (reg != null)
      {
        IRegion word = checkRegion(reg);
        fNextPos = (word.getOffset() + word.getLength());
        if (fNextPos >= fDocument.getLength())
        {
          fCurrentState = 2;
          if (!fHasNext) {
            break;
          }
          return;
        }
        if (fHasNext) {
          return;
        }
        reg = fSearcher.find(fNextPos, fSearchPattern, true, true, false, true);
      }
      fCurrentState = 2;
    }
    if (fCurrentState == 2)
    {
      fCurrentState = 3;
      if (fCurrentWordCompletion != null)
      {
        fNext = fCurrentWordCompletion;
        fHasNext = true;
        return;
      }
    }
    fNext = null;
    fHasNext = false;
  }
  
  private IRegion checkRegion(IRegion reg)
    throws BadLocationException
  {
    int wordSearchPos = reg.getOffset() + reg.getLength() - fPrefix.length();
    
    IRegion word = fSearcher.find(wordSearchPos, "[\\p{L}[\\p{Mn}[\\p{Pc}[\\p{Nd}[\\p{Nl}[\\p{Sc}]]]]]]+", true, true, false, true);
    if (word.getLength() > fPrefix.length())
    {
      String wholeWord = fDocument.get(word.getOffset(), word.getLength());
      String completion = wholeWord.substring(fPrefix.length());
      if ((fCurrentWordLast) && (reg.getOffset() == fFirstPosition))
      {
        if (fCurrentWordCompletion == null) {
          fCurrentWordCompletion = completion;
        }
      }
      else
      {
        fNext = completion;
        fHasNext = true;
      }
    }
    return word;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.texteditor.HippieCompletionEngine.HippieCompletionForwardIterator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.texteditor;

import java.util.Iterator;
import java.util.NoSuchElementException;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.FindReplaceDocumentAdapter;
import org.eclipse.jface.text.IDocument;

abstract class HippieCompletionEngine$HippieCompletionIterator
  implements Iterator
{
  protected IDocument fDocument;
  protected CharSequence fPrefix;
  protected int fFirstPosition;
  protected boolean fHasNext;
  protected String fNext;
  protected int fCurrentState;
  protected FindReplaceDocumentAdapter fSearcher;
  protected String fSearchPattern;
  protected int fNextPos;
  final HippieCompletionEngine this$0;
  
  public HippieCompletionEngine$HippieCompletionIterator(HippieCompletionEngine paramHippieCompletionEngine, IDocument document, CharSequence prefix, int firstPosition)
  {
    this$0 = paramHippieCompletionEngine;fCurrentState = 0;
    fDocument = document;
    fPrefix = prefix;
    fFirstPosition = firstPosition;
  }
  
  protected void calculateFirst()
  {
    try
    {
      calculateNext();
    }
    catch (BadLocationException e)
    {
      HippieCompletionEngine.access$0(this$0, e);
      fHasNext = false;
      fNext = null;
    }
  }
  
  public boolean hasNext()
  {
    return fHasNext;
  }
  
  public Object next()
  {
    if (!fHasNext) {
      throw new NoSuchElementException();
    }
    String ret = fNext;
    try
    {
      calculateNext();
    }
    catch (BadLocationException e)
    {
      HippieCompletionEngine.access$0(this$0, e);
      fHasNext = false;
      fNext = null;
    }
    return ret;
  }
  
  public void remove()
  {
    throw new UnsupportedOperationException();
  }
  
  protected abstract void calculateNext()
    throws BadLocationException;
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.texteditor.HippieCompletionEngine.HippieCompletionIterator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.texteditor;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import org.eclipse.jface.text.IDocument;

final class HippieCompletionEngine$MultipleDocumentsIterator
  implements Iterator
{
  private String fNext;
  private int fCurrLocation;
  private final List fSuggestions;
  private int fCurrSuggestion;
  private final CharSequence fPrefix;
  private final List fOtherDocuments;
  private final IDocument fOpenDocument;
  private final int fSelectionOffset;
  private boolean fAddedEmpty;
  private Iterator fCompletionsForwardIterator;
  private Iterator fCompletionsBackwardIterator;
  final HippieCompletionEngine this$0;
  
  HippieCompletionEngine$MultipleDocumentsIterator(HippieCompletionEngine paramHippieCompletionEngine, IDocument paramIDocument, List paramList, CharSequence paramCharSequence, int paramInt, MultipleDocumentsIterator paramMultipleDocumentsIterator)
  {
    this(paramHippieCompletionEngine, paramIDocument, paramList, paramCharSequence, paramInt);
  }
  
  private HippieCompletionEngine$MultipleDocumentsIterator(HippieCompletionEngine paramHippieCompletionEngine, IDocument openDocument, List otherDocuments, CharSequence prefix, int selectionOffset)
  {
    this$0 = paramHippieCompletionEngine;fCurrLocation = -1;fCurrSuggestion = 0;fAddedEmpty = false;
    
    fPrefix = prefix;
    fSuggestions = new ArrayList();
    fOtherDocuments = otherDocuments;
    fSelectionOffset = selectionOffset;
    fOpenDocument = openDocument;
    calculateNext();
  }
  
  private void calculateNext()
  {
    if (fCurrLocation == -1)
    {
      fCompletionsBackwardIterator = this$0.getBackwardIterator(
        fOpenDocument, fPrefix, fSelectionOffset);
      
      fCompletionsForwardIterator = this$0.getForwardIterator(
        fOpenDocument, fPrefix, fSelectionOffset - fPrefix.length(), true);
      fCurrLocation += 1;
    }
    if (checkNext()) {
      return;
    }
    while (fCurrLocation < fOtherDocuments.size())
    {
      fCompletionsForwardIterator = this$0.getForwardIterator(
        (IDocument)fOtherDocuments.get(fCurrLocation), fPrefix, 0, false);
      fCurrLocation += 1;
      if (checkNext()) {
        return;
      }
    }
    if (!fAddedEmpty)
    {
      fSuggestions.add("");
      fAddedEmpty = true;
    }
    checkNext();
  }
  
  private boolean checkNext()
  {
    if (fCompletionsBackwardIterator != null) {
      if (fCompletionsBackwardIterator.hasNext()) {
        fSuggestions.add(fCompletionsBackwardIterator.next());
      } else {
        fCompletionsBackwardIterator = null;
      }
    }
    if (fCompletionsBackwardIterator == null) {
      if ((fCompletionsForwardIterator != null) && (fCompletionsForwardIterator.hasNext())) {
        fSuggestions.add(fCompletionsForwardIterator.next());
      }
    }
    if (fSuggestions.size() > fCurrSuggestion)
    {
      fNext = ((String)fSuggestions.get(fCurrSuggestion));
      fCurrSuggestion += 1;
      r
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

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