Revert to the last known working revision of the editor source.

This commit is contained in:
lonnen
2010-06-25 22:11:22 +00:00
parent b5ce02d3d1
commit 58b38feda7
19 changed files with 164 additions and 245 deletions
@@ -2,11 +2,12 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: org.processing.editor
Bundle-SymbolicName: org.processing.editor;singleton:=true
Bundle-Version: 0.0.3
Bundle-Version: 0.0.2
Bundle-Activator: org.processing.editor.ProcessingEditorPlugin
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.jface.text,
org.eclipse.ui.editors
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.eclipse.ui.views.contentoutline
@@ -25,17 +25,12 @@ public class PresentationAction extends TextEditorAction {
* Constructs and updates the action.
*/
public PresentationAction() {
super(ProcessingEditorMessages.getResourceBundle(), "TogglePresentation.", null);
super(ProcessingEditorMessages.getResourceBundle(), "TogglePresentation.", null); //$NON-NLS-1$
update();
}
/**
* Toggles between showing the highlight range only and showing the whole
* document. This isn't currently enabled in the Processing editor, and
* was generated as stub code. I'm not sure how useful it is. I will do
* something better with this later.
*
* [lonnen] june 21 2010
/* (non-Javadoc)
* Method declared on IAction
*/
public void run() {
@@ -47,8 +42,8 @@ public class PresentationAction extends TextEditorAction {
editor.showHighlightRangeOnly(!show);
}
/**
* Changes the PresentationAction in light of changes to the editor.
/* (non-Javadoc)
* Method declared on TextEditorAction
*/
public void update() {
setChecked(getTextEditor() != null && getTextEditor().showsHighlightRangeOnly());
@@ -17,7 +17,7 @@ import org.eclipse.ui.editors.text.TextEditorActionContributor;
import org.eclipse.ui.texteditor.*;
/**
* Contributes content assistance actions to the desktop's Edit menu and the toolbar.
* Contributes interesting Java actions to the desktop's Edit menu and the toolbar.
*/
public class ProcessingActionContributor extends TextEditorActionContributor {
@@ -30,16 +30,15 @@ public class ProcessingActionContributor extends TextEditorActionContributor {
*/
public ProcessingActionContributor() {
super();
fContentAssistProposal= new RetargetTextEditorAction(ProcessingEditorMessages.getResourceBundle(), "ContentAssistProposal.");
fContentAssistProposal= new RetargetTextEditorAction(ProcessingEditorMessages.getResourceBundle(), "ContentAssistProposal."); //$NON-NLS-1$
fContentAssistProposal.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
fContentAssistTip= new RetargetTextEditorAction(ProcessingEditorMessages.getResourceBundle(), "ContentAssistTip.");
fContentAssistTip= new RetargetTextEditorAction(ProcessingEditorMessages.getResourceBundle(), "ContentAssistTip."); //$NON-NLS-1$
fContentAssistTip.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
fTogglePresentation= new PresentationAction();
}
/**
* Initializes the edit menu actions invoking content assistance and the assitance tooltip
* These are functional items, but of (extremely?) limited usefulness.
/*
* @see IEditorActionBarContributor#init(IActionBars)
*/
public void init(IActionBars bars) {
super.init(bars);
@@ -59,8 +58,8 @@ public class ProcessingActionContributor extends TextEditorActionContributor {
}
}
/**
* Adds content assistance and tooltip actions to the Processing Editor
/*
*
*/
private void doSetActiveEditor(IEditorPart part) {
super.setActiveEditor(part);
@@ -76,16 +75,16 @@ public class ProcessingActionContributor extends TextEditorActionContributor {
fTogglePresentation.update();
}
/**
* @see doSetActiveEditor
/*
* @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
*/
public void setActiveEditor(IEditorPart part) {
super.setActiveEditor(part);
doSetActiveEditor(part);
}
/**
* Shut it down
/*
* @see IEditorActionBarContributor#dispose()
*/
public void dispose() {
doSetActiveEditor(null);
@@ -25,9 +25,8 @@ import org.eclipse.jface.text.source.ISourceViewer;
public class ProcessingAnnotationHover implements IAnnotationHover {
/**
* Provides info for a given mouse hover position to the tooltip.
* Currently this means retrieving the text under the mouse.
/* (non-Javadoc)
* Method declared on IAnnotationHover
*/
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
IDocument document= sourceViewer.getDocument();
@@ -81,8 +81,8 @@ public class ProcessingContentOutlinePage extends ContentOutlinePage {
}
}
/**
* {@inheritDoc}
/*
* @see IContentProvider#inputChanged(Viewer, Object, Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (oldInput != null) {
@@ -109,9 +109,7 @@ public class ProcessingContentOutlinePage extends ContentOutlinePage {
}
}
/**
* Shut it down.
*
/*
* @see IContentProvider#dispose
*/
public void dispose() {
@@ -121,29 +119,29 @@ public class ProcessingContentOutlinePage extends ContentOutlinePage {
}
}
/**
* {@inheritDoc}
/*
* @see IContentProvider#isDeleted(Object)
*/
public boolean isDeleted(Object element) {
return false;
}
/**
* {@inheritDoc}
/*
* @see IStructuredContentProvider#getElements(Object)
*/
public Object[] getElements(Object element) {
return fContent.toArray();
}
/**
* {@inheritDoc}
/*
* @see ITreeContentProvider#hasChildren(Object)
*/
public boolean hasChildren(Object element) {
return element == fInput;
}
/**
* {@inheritDoc}
/*
* @see ITreeContentProvider#getParent(Object)
*/
public Object getParent(Object element) {
if (element instanceof Segment)
@@ -151,8 +149,8 @@ public class ProcessingContentOutlinePage extends ContentOutlinePage {
return null;
}
/**
* {@inheritDoc}
/*
* @see ITreeContentProvider#getChildren(Object)
*/
public Object[] getChildren(Object element) {
if (element == fInput)
@@ -177,8 +175,8 @@ public class ProcessingContentOutlinePage extends ContentOutlinePage {
fTextEditor= editor;
}
/**
* {@inheritDoc}
/* (non-Javadoc)
* Method declared on ContentOutlinePage
*/
public void createControl(Composite parent) {
@@ -193,8 +191,8 @@ public class ProcessingContentOutlinePage extends ContentOutlinePage {
viewer.setInput(fInput);
}
/**
* {@inheritDoc}
/* (non-Javadoc)
* Method declared on ContentOutlinePage
*/
public void selectionChanged(SelectionChangedEvent event) {
@@ -17,13 +17,12 @@ import org.eclipse.jface.text.rules.FastPartitioner;
public class ProcessingDocumentSetupParticipant implements IDocumentSetupParticipant {
/**
* The constructor doesn't do much.
*/
public ProcessingDocumentSetupParticipant() {
}
/**
* {@inheritDoc}
/*
* @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument)
*/
public void setup(IDocument document) {
if (document instanceof IDocumentExtension3) {
@@ -44,8 +44,8 @@ import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.TextEditorAction;
import org.eclipse.ui.texteditor.TextOperationAction;
//import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
//import org.eclipse.ui.texteditor.SourceViewerDecorationSupport; // error checking annotations?
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
//import org.eclipse.ui.texteditor.SourceViewerDecorationSupport; // error checking annotations
/**
* Sets up a Processing specific text editor.
@@ -54,10 +54,6 @@ import org.eclipse.ui.texteditor.TextOperationAction;
*/
public class ProcessingEditor extends TextEditor {
/**
* Essentially a factory class that creates code folding regions around
* the currently selected text.
*/
private class DefineFoldingRegionAction extends TextEditorAction {
public DefineFoldingRegionAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
@@ -68,10 +64,7 @@ public class ProcessingEditor extends TextEditor {
return (IAnnotationModel) editor.getAdapter(ProjectionAnnotationModel.class);
}
/**
* Defines a code folding region around a selected region of text
* and puts an annotation in the left gutter that toggles hiding the text.
*
/*
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
@@ -119,16 +112,17 @@ public class ProcessingEditor extends TextEditor {
*/
protected void createActions() {
super.createActions();
// accessing the ResourceBundle was causing an ExceptionInInitializerError, not sure what I changed to fix it [lonnen] June 10 2010
IAction a= new TextOperationAction(ProcessingEditorMessages.getResourceBundle(), "ContentAssistProposal.", this, ISourceViewer.CONTENTASSIST_PROPOSALS); //$NON-NLS-1$
a.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
setAction("ContentAssistProposal", a);
setAction("ContentAssistProposal", a); //$NON-NLS-1$
a= new TextOperationAction(ProcessingEditorMessages.getResourceBundle(), "ContentAssistTip.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$
a.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
setAction("ContentAssistTip", a);
setAction("ContentAssistTip", a); //$NON-NLS-1$
//a= new DefineFoldingRegionAction(ProcessingEditorMessages.getResourceBundle(), "DefineFoldingRegion.", this);
//setAction("DefineFoldingRegion", a);
a= new DefineFoldingRegionAction(ProcessingEditorMessages.getResourceBundle(), "DefineFoldingRegion.", this); //$NON-NLS-1$
setAction("DefineFoldingRegion", a); //$NON-NLS-1$
}
/** The <code>ProcessingEditor</code> implementation of this
@@ -14,42 +14,30 @@ import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* Handles localization stuff using the ProcessingEditorMessages.preferences
* file. This is never instantiated, and all of its variables and methods are
* Processing Editor Messages object handles localization stuff
* using the ProcessingEditorMessages.preferences file. This class
* is never instantiated, and all of its variables and methods are
* static.
*
* @author lonnen
*/
public class ProcessingEditorMessages {
/** location of the resource bundle */
private static final String RESOURCE_BUNDLE= "org.processing.editor.ProcessingEditorMessages";//$NON-NLS-1$
/** the resource bundle object itself*/
static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
private ProcessingEditorMessages() {
}
/**
* Gets a string for the given key from this resource bundle or one of its parents.
* Calling this method is equivalent to calling <code> (String) getObject(key) </code>
*
* @param key the key for the desired string
* @return the string for the given key
*/
public static String getString(String key) {
try {
return fgResourceBundle.getString(key);
} catch (MissingResourceException e) {
return "!" + key + "!";
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
}
}
/**
* Exposes the resource bundle for direct access
* @return this resource bundle
*/
public static ResourceBundle getResourceBundle() {
return fgResourceBundle;
}
@@ -16,7 +16,7 @@ import java.net.URL;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.jface.text.rules.RuleBasedScanner;
//import org.processing.editor.javadoc.JavaDocScanner;
import org.processing.editor.javadoc.JavaDocScanner;
import org.processing.editor.language.ProcessingCodeScanner;
import org.processing.editor.util.ProcessingColorProvider;
@@ -26,14 +26,15 @@ import org.osgi.framework.BundleContext;
/**
* Processing editor plug-in class.
* Manages the startup and shutdown of the plugin. Also uses a singleton pattern to controls
* access to a few objects that need to be shared across the plugin. Access these objects with
* ProcessingEditorPlugin.getDefault().method()
* Uses a singleton pattern to controls access to a few objects that need to be shared
* across the plugin. Access these options with ProcessingEditorPlugin.getDefault().method()
* @since 3.0
*/
public class ProcessingEditorPlugin extends AbstractUIPlugin {
public static final String ID = "org.processing.ProcessingEditor";
public static final String PROCESSING_PARTITIONING= "__processing_partitioning";
public static final String PLUGIN_ID = "org.processing.ProcessingEditor";
//public static final String JAVA_PARTITIONING= "__java_example_partitioning"; //$NON-NLS-1$
public static final String PROCESSING_PARTITIONING= "__processing_partitioning"; //$NON-NLS-1$
// The shared instance
private static ProcessingEditorPlugin fgInstance;
@@ -42,33 +43,35 @@ public class ProcessingEditorPlugin extends AbstractUIPlugin {
private ProcessingPartitionScanner fPartitionScanner;
private ProcessingColorProvider fColorProvider;
private ProcessingCodeScanner fCodeScanner;
//private JavaDocScanner fDocScanner;
private JavaDocScanner fDocScanner;
/**
* Creates a new plug-in instance.
*
* Called when by the Eclipse runtime when the plugin is activated.
*
* @see org.eclipse.core.runtime.Plugin
*/
public ProcessingEditorPlugin() {}
public ProcessingEditorPlugin() {
// [lonnen]
// Java editor example has "fgInstance= this;"
// while the editor template uses the start method to handle
// that and leaves this empty. Since I've been chasing down
// this null pointer error for going on 12 hours, I'm going
// to try it the template's way and see if it works.
//
// That did the trick! On to debugging other problems. [lonnen] June 10 2010
}
/**
* Invoked by the platform the first time any code from this plug-in is
* executed. Due to the platforms time-sensitive constraints, this
* only initializes a shared instance of the plugin itself.
*
/* added from the editor template, not present in the java editor code
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
fgInstance = this;
//System.out.println("fgInstance initialized!");
}
/**
* Invoked by the platform when this plugin is shutting down. Performs a
* simple termination of this plugin's singleton instance.
*
/* added from the editor template, not present in the java editor code
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
@@ -78,19 +81,17 @@ public class ProcessingEditorPlugin extends AbstractUIPlugin {
/**
* Returns the default plug-in instance. This method should be used to
* access any of the other singleton objects in the plugin.
* Returns the default plug-in instance.
*
* @return the default plug-in instance
* @see org.eclipse.ui.plugin.AbstractUIPlugin
*/
public static ProcessingEditorPlugin getDefault() { return fgInstance; }
/**
* Returns a scanner for creating Processing partitions.
* Return a scanner for creating Processing partitions.
* Processing uses Java's commenting scheme, so our partitioner is almost identical. Unlike
* the Java partitioner, however, this Processing scanner treats the JavaDoc style comments
* as simple multiline comments.
* the Java partitioner, however, this Processing one currently treats the JavaDoc style
* comments as simple multiline comments.
*
* @return a scanner for creating Processing partitions
*/
@@ -104,7 +105,6 @@ public class ProcessingEditorPlugin extends AbstractUIPlugin {
* Returns the singleton Processing code scanner.
*
* @return the singleton Processing code scanner
* @see org.processing.editor.language.ProcessingCodeScanner
*/
public RuleBasedScanner getProcessingCodeScanner() {
if (fCodeScanner == null)
@@ -122,39 +122,36 @@ public class ProcessingEditorPlugin extends AbstractUIPlugin {
fColorProvider= new ProcessingColorProvider();
return fColorProvider;
}
//For the time being, we're disabling JavaDoc
// /**
// * Returns the singleton Processingdoc scanner.
// *
// * @return the singleton Processingdoc scanner
// */
// public RuleBasedScanner getProcessingDocScanner() {
// if (fDocScanner == null)
// fDocScanner= new JavaDocScanner(fColorProvider);
// return fDocScanner;
// }
/**
* Returns the singleton Processingdoc scanner.
*
* @return the singleton Processingdoc scanner
*/
public RuleBasedScanner getProcessingDocScanner() {
if (fDocScanner == null)
fDocScanner= new JavaDocScanner(fColorProvider);
return fDocScanner;
}
/**
* Returns a buffered input stream for a file in the plug-in directory.
*
* Used by the CodeScanner to access the keyword list in the plug-in directory.
*
* @param filename the file to be loaded
* @return BufferedInputStream to read the file with
*/
public BufferedInputStream getFileInputStream(String filename) {
//TODO consider replacing this whole function with find (IPath path) and openStream (IPath file)
Bundle bundle = getDefault().getBundle(); // the plugin's root directory, regardless of install directory
try {
URL fileLocation = FileLocator.toFileURL(bundle.getEntry(filename));
BufferedInputStream file = new BufferedInputStream(fileLocation.openStream());
return file;
} catch (IOException e) {
e.printStackTrace();
}
return null; // this should be more explicit than a null pointer from a caught exception, right? [lonnen] June 15, 2010
}
public BufferedInputStream getFileInputStream(String filename) {
Bundle bundle = getDefault().getBundle();
URL fileLocation;
try {
fileLocation = FileLocator.toFileURL(bundle.getEntry(filename));
BufferedInputStream file = new BufferedInputStream(fileLocation.openStream());
return file;
} catch (IOException e) {
e.printStackTrace();
}
return null; // this should be more explicit than a null pointer from a caught exception, right? [lonnen] June 15, 2010
}
}
@@ -75,7 +75,7 @@ public class ProcessingLog {
* @return status object
*/
public static IStatus createStatus(int severity, int code, String message, Throwable exception){
return new Status(severity, ProcessingEditorPlugin.ID, code, message, exception);
return new Status(severity, ProcessingEditorPlugin.PLUGIN_ID, code, message, exception);
}
/**
@@ -62,18 +62,14 @@ public class ProcessingPartitionScanner extends RuleBasedPartitionScanner {
addWord("/**/", fSuccessToken); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*
/*
* @see org.eclipse.jface.text.rules.IPredicateRule#evaluate(ICharacterScanner, boolean)
*/
public IToken evaluate(ICharacterScanner scanner, boolean resume) {
return super.evaluate(scanner);
}
/**
* {@inheritDoc}
*
/*
* @see org.eclipse.jface.text.rules.IPredicateRule#getSuccessToken()
*/
public IToken getSuccessToken() {
@@ -57,21 +57,14 @@ public class ProcessingSourceViewerConfiguration extends SourceViewerConfigurati
public ProcessingSourceViewerConfiguration() {
}
/**
* Starts up the mouse hover tooltips
/* (non-Javadoc)
* Method declared on SourceViewerConfiguration
*/
public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
return new ProcessingAnnotationHover();
}
/**
* Returns the auto-indent strategy used when manipulating text in the editor. To maintain backwards
* compatibility with the Eclipse RCP, this always returns an array containing the auto indent strategy.
*
* @param sourceViewer the source veiwer to be configured
* @param contentType the content type for which the strategies are applicable
* @return an auto indent strategy, or null
* @see org.processing.editor.language.ProcessingAutoIndentStrategy
/*
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAutoEditStrategies(org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
*/
public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
@@ -79,22 +72,15 @@ public class ProcessingSourceViewerConfiguration extends SourceViewerConfigurati
return new IAutoEditStrategy[] { strategy };
}
/**
* Returns the Processing partitioning, because this editor only acts on .pde files
*
* @param sourceViewer the source viewer to be configured
* @return a Processing partitioning
/*
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
*/
public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
return ProcessingEditorPlugin.PROCESSING_PARTITIONING;
}
/**
* Returns the partitioning types to the source viewer so it can distinguish between comments and everything else.
*
* @param sourceViewer the source viewer to be configured
* @return a string array of the content types
/* (non-Javadoc)
* Method declared on SourceViewerConfiguration
*/
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
//Removing JavaDoc support from sketches, but leave in code
@@ -102,12 +88,9 @@ public class ProcessingSourceViewerConfiguration extends SourceViewerConfigurati
return new String[] { IDocument.DEFAULT_CONTENT_TYPE, ProcessingPartitionScanner.JAVA_MULTILINE_COMMENT };
}
/**
* Returns content assistance
*
* @param the source viewer the be configured
* @return a content assistant of dubious utility
*/
/* (non-Javadoc)
* Method declared on SourceViewerConfiguration
*/
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
ContentAssistant assistant= new ContentAssistant();
@@ -117,7 +100,7 @@ public class ProcessingSourceViewerConfiguration extends SourceViewerConfigurati
//assistant.setContentAssistProcessor(new JavaDocCompletionProcessor(), ProcessingPartitionScanner.JAVA_DOC);
assistant.enableAutoActivation(true);
assistant.setAutoActivationDelay(500); // delay before content assist pops up
assistant.setAutoActivationDelay(500);
assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
assistant.setContextInformationPopupBackground(ProcessingEditorPlugin.getDefault().getProcessingColorProvider().getColor(new RGB(150, 150, 0)));
@@ -125,30 +108,29 @@ public class ProcessingSourceViewerConfiguration extends SourceViewerConfigurati
return assistant;
}
/**
* Returns the default prefix to be used by the line-prefix operation in the editor.
* This is used for auto-commenting and uncommenting.
/* (non-Javadoc)
* Method declared on SourceViewerConfiguration
*/
public String getDefaultPrefix(ISourceViewer sourceViewer, String contentType) {
return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? "//" : null); //$NON-NLS-1$
}
/**
* {@inheritDoc}
/* (non-Javadoc)
* Method declared on SourceViewerConfiguration
*/
public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
return new ProcessingDoubleClickSelector();
}
/**
* {@inheritDoc}
/* (non-Javadoc)
* Method declared on SourceViewerConfiguration
*/
public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
return new String[] { "\t", " " };
return new String[] { "\t", " " }; //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* {@inheritDoc}
/* (non-Javadoc)
* Method declared on SourceViewerConfiguration
*/
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
@@ -173,15 +155,15 @@ public class ProcessingSourceViewerConfiguration extends SourceViewerConfigurati
return reconciler;
}
/**
* {@inheritDoc}
/* (non-Javadoc)
* Method declared on SourceViewerConfiguration
*/
public int getTabWidth(ISourceViewer sourceViewer) {
return 4;
}
/**
* {@inheritDoc}
/* (non-Javadoc)
* Method declared on SourceViewerConfiguration
*/
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
return new ProcessingTextHover();
@@ -19,8 +19,8 @@ import org.eclipse.swt.graphics.Point;
*/
public class ProcessingTextHover implements ITextHover {
/**
* {@inheritDoc}
/* (non-Javadoc)
* Method declared on ITextHover
*/
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
if (hoverRegion != null) {
@@ -34,8 +34,8 @@ public class ProcessingTextHover implements ITextHover {
return ProcessingEditorMessages.getString("ProcessingTextHover.emptySelection"); //$NON-NLS-1$
}
/**
* {@inheritDoc}
/* (non-Javadoc)
* Method declared on ITextHover
*/
public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
Point selection= textViewer.getSelectedRange();
@@ -25,13 +25,13 @@ public class ProcessingAutoIndentStrategy extends DefaultIndentLineAutoEditStrat
public ProcessingAutoIndentStrategy() {
}
/**
* {@inheritDoc}
/* (non-Javadoc)
* Method declared on IAutoIndentStrategy
*/
public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
if (c.length == 0 && c.text != null && endsWithDelimiter(d, c.text))
smartIndentAfterNewLine(d, c);
else if ("}".equals(c.text)) {
else if ("}".equals(c.text)) { //$NON-NLS-1$
smartInsertAfterBracket(d, c);
}
}
@@ -23,16 +23,10 @@ import java.util.Set;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.rules.*;
import org.processing.editor.ProcessingEditorPlugin;
import org.processing.editor.ProcessingLog;
import org.processing.editor.util.*;
/**
* Establishes a rule based syntax highlighting scheme.
*
* Reads in a keywords file that was generated by the Processing Development Environment
* and uses the contents to establish syntax highlighting rules for different keyword types.
*
* Also exposes static access to the keywords, though this may be depreciated shortly.
* A Processing code scanner.
*/
public class ProcessingCodeScanner extends RuleBasedScanner {
@@ -96,12 +90,12 @@ public class ProcessingCodeScanner extends RuleBasedScanner {
}
}
}
catch (Exception e){
ProcessingLog.logError("ProcessingCodeScanner init block encountered a problem while reading the keywords file.", e);
catch (Exception e){
e.printStackTrace();
}
try{
fgKeywords1= KeywordMap.containsKey("KEYWORD1") ? (String[]) KeywordMap.get("KEYWORD1").toArray(new String[KeywordMap.get("KEYWORD1").size()]) : new String[] {};
fgKeywords1= KeywordMap.containsKey("KEYWORD1") ? (String[]) KeywordMap.get("KEYWORD1").toArray(new String[KeywordMap.get("KEYWORD1").size()]) : new String[] {"test"};
fgKeywords2= KeywordMap.containsKey("KEYWORD2") ? (String[]) KeywordMap.get("KEYWORD2").toArray(new String[KeywordMap.get("KEYWORD2").size()]) : new String[] {};
fgKeywords3= KeywordMap.containsKey("KEYWORD3") ? (String[]) KeywordMap.get("KEYWORD3").toArray(new String[KeywordMap.get("KEYWORD3").size()]) : new String[] {};
fgLiterals1= KeywordMap.containsKey("LITERAL1") ? (String[]) KeywordMap.get("LITERAL1").toArray(new String[KeywordMap.get("LITERAL1").size()]) : new String[] {};
@@ -111,7 +105,7 @@ public class ProcessingCodeScanner extends RuleBasedScanner {
fgInvalids = KeywordMap.containsKey("INVALIDS") ? (String[]) KeywordMap.get("INVALIDS").toArray(new String[KeywordMap.get("INVALIDS").size()]) : new String[] {}; // unused?
}
catch (Exception e){
ProcessingLog.logError("ProcessingCodeScanner init block encountered a problem while initializing the string arrays.", e);
e.printStackTrace();
}
}
@@ -30,29 +30,29 @@ public class ProcessingCompletionProcessor implements IContentAssistProcessor {
protected int fInstallOffset;
/**
* {@inheritDoc}
/*
* @see IContextInformationValidator#isContextInformationValid(int)
*/
public boolean isContextInformationValid(int offset) {
return Math.abs(fInstallOffset - offset) < 5;
}
/**
* {@inheritDoc}
/*
* @see IContextInformationValidator#install(IContextInformation, ITextViewer, int)
*/
public void install(IContextInformation info, ITextViewer viewer, int offset) {
fInstallOffset= offset;
}
/**
* {@inheritDoc}
/*
* @see org.eclipse.jface.text.contentassist.IContextInformationPresenter#updatePresentation(int, TextPresentation)
*/
public boolean updatePresentation(int documentPosition, TextPresentation presentation) {
return false;
}
}
/**
/*
* The list of proposals that populates the content assistance dialog box.
*
* Dialog assistance is not context sensitive right now, so it will always provide the same suggestions
@@ -90,8 +90,8 @@ public class ProcessingCompletionProcessor implements IContentAssistProcessor {
return result;
}
/**
* {@inheritDoc}
/* (non-Javadoc)
* Method declared on IContentAssistProcessor
*/
public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
IContextInformation[] result= new IContextInformation[5];
@@ -102,29 +102,29 @@ public class ProcessingCompletionProcessor implements IContentAssistProcessor {
return result;
}
/**
* {@inheritDoc}
/* (non-Javadoc)
* Method declared on IContentAssistProcessor
*/
public char[] getCompletionProposalAutoActivationCharacters() {
return new char[] { '.', '(' };
}
/**
* {@inheritDoc}
/* (non-Javadoc)
* Method declared on IContentAssistProcessor
*/
public char[] getContextInformationAutoActivationCharacters() {
return new char[] { '#' };
}
/**
* {@inheritDoc}
/* (non-Javadoc)
* Method declared on IContentAssistProcessor
*/
public IContextInformationValidator getContextInformationValidator() {
return fValidator;
}
/**
* {@inheritDoc}
/* (non-Javadoc)
* Method declared on IContentAssistProcessor
*/
public String getErrorMessage() {
return null;
@@ -29,18 +29,15 @@ public class ProcessingDoubleClickSelector implements ITextDoubleClickStrategy {
protected static char[] fgBrackets= { '{', '}', '(', ')', '[', ']', '"', '"' };
/**
* Create a DoubleClickSelector.
/*
* Create a JavaDoubleClickSelector.
*/
public ProcessingDoubleClickSelector() {
super();
}
/**
* Takes action to highlight a range when the user double clicks in the editor
* if the double click happened near an opening/closing token.
*
* @param text the Processing editor that was double clicked
/* (non-Javadoc)
* Method declared on ITextDoubleClickStrategy
*/
public void doubleClicked(ITextViewer text) {
@@ -13,37 +13,20 @@ package org.processing.editor.language;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* Handles localization stuff using the ProcessingEditorMessages.preferences
* file. This is never instantiated, and all of its variables and methods are
* static.
*
* @author lonnen
*/
public class ProcessingEditorMessages {
/** location of the resource bundle */
private static final String RESOURCE_BUNDLE= "org.processing.editor.ProcessingEditorMessages";//$NON-NLS-1$
/** the resource bundle object itself*/
static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
private ProcessingEditorMessages() {
}
/**
* Gets a string for the given key from this resource bundle or one of its parents.
* Calling this method is equivalent to calling <code> (String) getObject(key) </code>
*
* @param key the key for the desired string
* @return the string for the given key
*/
public static String getString(String key) {
try {
return fgResourceBundle.getString(key);
} catch (MissingResourceException e) {
return "!" + key + "!";
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
}
}
}
@@ -18,10 +18,7 @@ import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
/**
* Manages the colors for the Processing Code Scanner
*
* The expected keyword classes are maintained here with
* values that describe how they will be colored in the text.
* Manager for colors used in the Java editor
*/
public class ProcessingColorProvider {