X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaSourceViewer.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaSourceViewer.java deleted file mode 100644 index 2dae127..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaSourceViewer.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package net.sourceforge.phpeclipse.phpeditor; - - -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.IRewriteTarget; -import org.eclipse.jface.text.Region; -import org.eclipse.jface.text.formatter.FormattingContextProperties; -import org.eclipse.jface.text.formatter.IContentFormatterExtension2; -import org.eclipse.jface.text.formatter.IFormattingContext; -import org.eclipse.jface.text.information.IInformationPresenter; -import org.eclipse.jface.text.source.IOverviewRuler; -import org.eclipse.jface.text.source.IVerticalRuler; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.jface.text.source.SourceViewerConfiguration; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; - -//import net.sourceforge.phpdt.ui.text.JavaSourceViewerConfiguration; - - - -public class JavaSourceViewer extends SourceViewer { - - /** - * Text operation code for requesting the outline for the current input. - */ - public static final int SHOW_OUTLINE= 51; - - /** - * Text operation code for requesting the outline for the element at the current position. - */ - public static final int OPEN_STRUCTURE= 52; - - - private IInformationPresenter fOutlinePresenter; - private IInformationPresenter fStructurePresenter; - - public JavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles) { - super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles); - } - - /* - * @see ITextOperationTarget#doOperation(int) - */ - public void doOperation(int operation) { - if (getTextWidget() == null) - return; - - switch (operation) { - case SHOW_OUTLINE: - fOutlinePresenter.showInformation(); - return; - case OPEN_STRUCTURE: - fStructurePresenter.showInformation(); - return; - case FORMAT : - { - final Point selection= rememberSelection(); - - final IDocument document= getDocument(); - IRegion region= new Region(selection.x, selection.y); - if (region.getLength()==0) { - region = new Region(0, document.getLength()); - } - final IRewriteTarget target= getRewriteTarget(); - final IFormattingContext context= createFormattingContext(); - - if (selection.y == 0) { - context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.TRUE); - } else { - context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.FALSE); - context.setProperty(FormattingContextProperties.CONTEXT_REGION, region); - } - try { - setRedraw(false); - startSequentialRewriteMode(false); - target.beginCompoundChange(); - - final String rememberedContents= document.get(); - - try { - - if (fContentFormatter instanceof IContentFormatterExtension2) { - - final IContentFormatterExtension2 extension= (IContentFormatterExtension2)fContentFormatter; - extension.format(document, context); - - } else - fContentFormatter.format(document, region); - - } catch (RuntimeException x) { - // firewall for https://bugs.eclipse.org/bugs/show_bug.cgi?id=47472 - // if something went wrong we undo the changes we just did - // TODO to be removed - document.set(rememberedContents); - throw x; - } - - } finally { - - target.endCompoundChange(); - stopSequentialRewriteMode(); - setRedraw(true); - - restoreSelection(); - context.dispose(); - } - return; - } - } - - super.doOperation(operation); - } - - /* - * @see ITextOperationTarget#canDoOperation(int) - */ - public boolean canDoOperation(int operation) { - if (operation == SHOW_OUTLINE) - return fOutlinePresenter != null; - if (operation == OPEN_STRUCTURE) - return fStructurePresenter != null; - return super.canDoOperation(operation); - } - - /* - * @see ISourceViewer#configure(SourceViewerConfiguration) - */ - public void configure(SourceViewerConfiguration configuration) { - super.configure(configuration); - if (configuration instanceof PHPSourceViewerConfiguration) { - fOutlinePresenter= ((PHPSourceViewerConfiguration)configuration).getOutlinePresenter(this, false); - fOutlinePresenter.install(this); - } - if (configuration instanceof PHPSourceViewerConfiguration) { - fStructurePresenter= ((PHPSourceViewerConfiguration)configuration).getOutlinePresenter(this, true); - fStructurePresenter.install(this); - } - } - - /* - * @see TextViewer#handleDispose() - */ - protected void handleDispose() { - if (fOutlinePresenter != null) { - fOutlinePresenter.uninstall(); - fOutlinePresenter= null; - } - if (fStructurePresenter != null) { - fStructurePresenter.uninstall(); - fStructurePresenter= null; - } - super.handleDispose(); - } -}