X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java index fc5da20..6979732 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java @@ -65,6 +65,9 @@ import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.texteditor.ContentAssistAction; @@ -75,22 +78,20 @@ import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.StatusTextEditor; import org.eclipse.ui.texteditor.TextOperationAction; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; +import org.eclipse.update.internal.ui.UpdatePerspective; +import org.eclipse.update.internal.ui.UpdateUIPlugin; +import org.eclipse.update.internal.ui.views.IEmbeddedWebBrowser; /** * PHP specific text editor. */ -public class PHPEditor - extends StatusTextEditor - implements IViewPartInputProvider { // extends TextEditor { +public class PHPEditor extends StatusTextEditor implements IViewPartInputProvider { // extends TextEditor { /** Preference key for showing the line number ruler */ - private final static String LINE_NUMBER_RULER = - PreferenceConstants.EDITOR_LINE_NUMBER_RULER; + private final static String LINE_NUMBER_RULER = PreferenceConstants.EDITOR_LINE_NUMBER_RULER; /** Preference key for the foreground color of the line numbers */ - private final static String LINE_NUMBER_COLOR = - PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR; + private final static String LINE_NUMBER_COLOR = PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR; /** Preference key for the link color */ - private final static String LINK_COLOR = - PreferenceConstants.EDITOR_LINK_COLOR; + private final static String LINK_COLOR = PreferenceConstants.EDITOR_LINK_COLOR; // protected PHPActionGroup fActionGroups; /** The outline page */ @@ -119,8 +120,7 @@ public class PHPEditor public PHPEditor() { super(); JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools(); - setSourceViewerConfiguration( - new PHPSourceViewerConfiguration(textTools, this)); + setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools, this)); setRangeIndicator(new DefaultRangeIndicator()); setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore()); @@ -149,32 +149,32 @@ public class PHPEditor * Update the hovering behavior depending on the preferences. */ private void updateHoverBehavior() { - SourceViewerConfiguration configuration= getSourceViewerConfiguration(); - String[] types= configuration.getConfiguredContentTypes(getSourceViewer()); + SourceViewerConfiguration configuration = getSourceViewerConfiguration(); + String[] types = configuration.getConfiguredContentTypes(getSourceViewer()); - for (int i= 0; i < types.length; i++) { - - String t= types[i]; - - int[] stateMasks= configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t); + for (int i = 0; i < types.length; i++) { - ISourceViewer sourceViewer= getSourceViewer(); + String t = types[i]; + + int[] stateMasks = configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t); + + ISourceViewer sourceViewer = getSourceViewer(); if (sourceViewer instanceof ITextViewerExtension2) { if (stateMasks != null) { - for (int j= 0; j < stateMasks.length; j++) { - int stateMask= stateMasks[j]; - ITextHover textHover= configuration.getTextHover(sourceViewer, t, stateMask); - ((ITextViewerExtension2)sourceViewer).setTextHover(textHover, t, stateMask); + for (int j = 0; j < stateMasks.length; j++) { + int stateMask = stateMasks[j]; + ITextHover textHover = configuration.getTextHover(sourceViewer, t, stateMask); + ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, stateMask); } } else { - ITextHover textHover= configuration.getTextHover(sourceViewer, t); - ((ITextViewerExtension2)sourceViewer).setTextHover(textHover, t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK); + ITextHover textHover = configuration.getTextHover(sourceViewer, t); + ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK); } } else sourceViewer.setTextHover(configuration.getTextHover(sourceViewer, t), t); } } - + /* * @see net.sourceforge.phpdt.internal.ui.viewsupport.IViewPartInputProvider#getViewPartInput() */ @@ -189,16 +189,11 @@ public class PHPEditor public void createPartControl(Composite parent) { super.createPartControl(parent); - IInformationControlCreator informationControlCreator = - new IInformationControlCreator() { + IInformationControlCreator informationControlCreator = new IInformationControlCreator() { public IInformationControl createInformationControl(Shell parent) { boolean cutDown = false; int style = cutDown ? SWT.NONE : (SWT.V_SCROLL | SWT.H_SCROLL); - return new DefaultInformationControl( - parent, - SWT.RESIZE, - style, - new HTMLTextPresenter(cutDown)); + return new DefaultInformationControl(parent, SWT.RESIZE, style, new HTMLTextPresenter(cutDown)); } }; @@ -213,8 +208,7 @@ public class PHPEditor * @return the document's complete text */ public String get() { - IDocument doc = - this.getDocumentProvider().getDocument(this.getEditorInput()); + IDocument doc = this.getDocumentProvider().getDocument(this.getEditorInput()); return doc.get(); } @@ -245,8 +239,7 @@ public class PHPEditor // this, // ISourceViewer.CONTENTASSIST_PROPOSALS)); action = new ContentAssistAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$ - action.setActionDefinitionId( - PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); + action.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); setAction("ContentAssistProposal", action); //$NON-NLS-1$ setAction( @@ -257,21 +250,11 @@ public class PHPEditor this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION)); - action = - new TextOperationAction( - PHPEditorMessages.getResourceBundle(), - "Comment.", - this, - ITextOperationTarget.PREFIX); + action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Comment.", this, ITextOperationTarget.PREFIX); action.setActionDefinitionId(PHPEditorActionDefinitionIds.COMMENT); setAction("Comment", action); - action = - new TextOperationAction( - PHPEditorMessages.getResourceBundle(), - "Uncomment.", - this, - ITextOperationTarget.STRIP_PREFIX); + action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX); action.setActionDefinitionId(PHPEditorActionDefinitionIds.UNCOMMENT); setAction("Uncomment", action); @@ -285,19 +268,15 @@ public class PHPEditor markAsStateDependentAction("Format", true); //$NON-NLS-1$ action = new GotoMatchingBracketAction(this); - action.setActionDefinitionId( - PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET); + action.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET); setAction(GotoMatchingBracketAction.GOTO_MATCHING_BRACKET, action); - fGenerateActionGroup = - new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT); + fGenerateActionGroup = new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT); - fActionGroups = - new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup }); + fActionGroups = new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup }); // We have to keep the context menu group separate to have better control over positioning - fContextMenuGroup = - new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup }); + fContextMenuGroup = new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup }); // rg, // new LocalHistoryActionGroup(this, ITextEditorActionConstants.GROUP_EDIT)}); @@ -317,7 +296,7 @@ public class PHPEditor * disposal actions required by the php editor. */ public void dispose() { - PHPEditorEnvironment.disconnect(this); + // PHPEditorEnvironment.disconnect(this); if (fOutlinePage != null) fOutlinePage.setInput(null); @@ -350,6 +329,11 @@ public class PHPEditor if (a != null) a.run(); } +// if (SWT.getPlatform().equals("win32")) { +// IAction a = ShowExternalPreviewAction.getInstance(); +// if (a != null) +// a.run(); +// } if (fOutlinePage != null) fOutlinePage.update(); } @@ -390,8 +374,7 @@ public class PHPEditor addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "Format"); //$NON-NLS-1$ - ActionContext context = - new ActionContext(getSelectionProvider().getSelection()); + ActionContext context = new ActionContext(getSelectionProvider().getSelection()); fContextMenuGroup.setContext(context); fContextMenuGroup.fillContextMenu(menu); fContextMenuGroup.setContext(null); @@ -470,8 +453,7 @@ public class PHPEditor if (value instanceof Integer) { sourceViewer.getTextWidget().setTabs(((Integer) value).intValue()); } else if (value instanceof String) { - sourceViewer.getTextWidget().setTabs( - Integer.parseInt((String) value)); + sourceViewer.getTextWidget().setTabs(Integer.parseInt((String) value)); } return; } @@ -616,13 +598,9 @@ public class PHPEditor if (!store.getBoolean(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) { if (store.contains(PREFERENCE_COLOR_BACKGROUND)) { if (store.isDefault(PREFERENCE_COLOR_BACKGROUND)) - rgb = - PreferenceConverter.getDefaultColor( - store, - PREFERENCE_COLOR_BACKGROUND); + rgb = PreferenceConverter.getDefaultColor(store, PREFERENCE_COLOR_BACKGROUND); else - rgb = - PreferenceConverter.getColor(store, PREFERENCE_COLOR_BACKGROUND); + rgb = PreferenceConverter.getColor(store, PREFERENCE_COLOR_BACKGROUND); } } rulerColumn.setBackground(manager.getColor(rgb)); @@ -654,7 +632,7 @@ public class PHPEditor */ protected void initializeEditor() { IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - PHPEditorEnvironment.connect(this); + // PHPEditorEnvironment.connect(this); // store.addPropertyChangeListener(new IPropertyChangeListener() { // public void propertyChange(PropertyChangeEvent event) { @@ -708,15 +686,12 @@ public class PHPEditor return false; } - private static boolean isSurroundedByBrackets( - IDocument document, - int offset) { + private static boolean isSurroundedByBrackets(IDocument document, int offset) { if (offset == 0 || offset == document.getLength()) return false; try { - return isBracket(document.getChar(offset - 1)) - && isBracket(document.getChar(offset)); + return isBracket(document.getChar(offset - 1)) && isBracket(document.getChar(offset)); } catch (BadLocationException e) { return false; @@ -763,8 +738,7 @@ public class PHPEditor return; int anchor = fBracketMatcher.getAnchor(); - int targetOffset = - (PHPPairMatcher.RIGHT == anchor) ? offset : offset + length - 1; + int targetOffset = (PHPPairMatcher.RIGHT == anchor) ? offset : offset + length - 1; boolean visible = false; if (sourceViewer instanceof ITextViewerExtension3) { @@ -772,9 +746,7 @@ public class PHPEditor visible = (extension.modelOffset2WidgetOffset(targetOffset) > -1); } else { IRegion visibleRegion = sourceViewer.getVisibleRegion(); - visible = - (targetOffset >= visibleRegion.getOffset() - && targetOffset < visibleRegion.getOffset() + visibleRegion.getLength()); + visible = (targetOffset >= visibleRegion.getOffset() && targetOffset < visibleRegion.getOffset() + visibleRegion.getLength()); } if (!visible) { @@ -794,8 +766,7 @@ public class PHPEditor * @param msg message to be set */ protected void setStatusLineErrorMessage(String msg) { - IEditorStatusLine statusLine = - (IEditorStatusLine) getAdapter(IEditorStatusLine.class); + IEditorStatusLine statusLine = (IEditorStatusLine) getAdapter(IEditorStatusLine.class); if (statusLine != null) statusLine.setMessage(true, msg, null); } @@ -809,18 +780,14 @@ public class PHPEditor * @return the line's bidi segmentation * @throws BadLocationException in case lineOffset is not valid in document */ - public static int[] getBidiLineSegments(IDocument document, int lineOffset) - throws BadLocationException { + public static int[] getBidiLineSegments(IDocument document, int lineOffset) throws BadLocationException { IRegion line = document.getLineInformationOfOffset(lineOffset); - ITypedRegion[] linePartitioning = - document.computePartitioning(lineOffset, line.getLength()); + ITypedRegion[] linePartitioning = document.computePartitioning(lineOffset, line.getLength()); List segmentation = new ArrayList(); for (int i = 0; i < linePartitioning.length; i++) { - if (IPHPPartitionScannerConstants - .PHP_STRING - .equals(linePartitioning[i].getType())) + if (IPHPPartitionScannerConstants.PHP_STRING.equals(linePartitioning[i].getType())) segmentation.add(linePartitioning[i]); } @@ -880,10 +847,7 @@ public class PHPEditor /* * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int) */ - protected final ISourceViewer createSourceViewer( - Composite parent, - IVerticalRuler ruler, - int styles) { + protected final ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { ISourceViewer viewer = createJavaSourceViewer(parent, ruler, styles); StyledText text = viewer.getTextWidget(); text.addBidiSegmentListener(new BidiSegmentListener() { @@ -898,10 +862,15 @@ public class PHPEditor /* * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int) */ - protected ISourceViewer createJavaSourceViewer( - Composite parent, - IVerticalRuler ruler, - int styles) { + protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { return super.createSourceViewer(parent, ruler, styles); } + + /* + * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent) + */ + protected boolean affectsTextPresentation(PropertyChangeEvent event) { + JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools(); + return textTools.affectsBehavior(event); + } }