Skip to content

Commit

Permalink
Update to most Java files to remove warning messages and to clean up
Browse files Browse the repository at this point in the history
code.
Major refactor of the RexxEditor file as this file now doesn't need to
contain any references to the Content Outline page because this program
now uses the proper method for instantiation.
Added a RexxTokenListToken (because RexxToken was taken) and this allows
for the syntax coloring to be dynamic as the token creates the
    TextAttribute every time it's called. Updates to other parts of the
    program to decouple code and allow syntax highlighting to be created
    dynamically.
  • Loading branch information
RappelBerryPi committed Mar 13, 2020
1 parent b274ce5 commit dad047f
Show file tree
Hide file tree
Showing 35 changed files with 287 additions and 359 deletions.
1 change: 0 additions & 1 deletion .project
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>com.omondo.uml.std.Nature</nature>
</natures>
</projectDescription>
14 changes: 13 additions & 1 deletion META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,20 @@ Require-Bundle: org.eclipse.ui,
com.fasterxml.jackson.core.jackson-core;bundle-version="2.10.3"
Bundle-ActivationPolicy: lazy
Bundle-Vendor: org.imperfectmommy
Export-Package: com.fasterxml.jackson.annotation,
Export-Package: .,
com.fasterxml.jackson.annotation,
com.fasterxml.jackson.core,
com.fasterxml.jackson.core.async,
com.fasterxml.jackson.core.base,
com.fasterxml.jackson.core.exc,
com.fasterxml.jackson.core.filter,
com.fasterxml.jackson.core.format,
com.fasterxml.jackson.core.io,
com.fasterxml.jackson.core.json,
com.fasterxml.jackson.core.json.async,
com.fasterxml.jackson.core.sym,
com.fasterxml.jackson.core.type,
com.fasterxml.jackson.core.util,
com.fasterxml.jackson.databind,
org.imperfectmommy.rexxeditor;
uses:="org.osgi.framework,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified bin/org/imperfectmommy/rexxeditor/editors/RexxConfiguration.class
Binary file not shown.
Binary file not shown.
Binary file modified bin/org/imperfectmommy/rexxeditor/editors/RexxEditor.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified bin/org/imperfectmommy/rexxeditor/scanner/RexxLineScanner.class
Binary file not shown.
Binary file modified bin/org/imperfectmommy/rexxeditor/scanner/RexxTokenList.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 8 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>

<extension point="org.eclipse.ui.editors">
<editor
name="Rexx Editor"
Expand Down Expand Up @@ -64,5 +63,13 @@
id="rexxeditor.launchConfigurationTypeImage">
</launchConfigurationTypeImage>
</extension>

<extension point="org.eclipse.core.runtime.adapters">
<factory
adaptableType="org.imperfectmommy.rexxeditor.editors.RexxEditor"
class="org.imperfectmommy.rexxeditor.contentoutliner.RexxOutlineAdapterFactory">
<adapter type="org.eclipse.ui.views.contentoutline.IContentOutlinePage"/>
</factory>
</extension>

</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.eclipse.jface.text.templates.Template;
import org.osgi.framework.Bundle;

import com.fasterxml.jackson.annotation.JsonFormat.Feature;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.ObjectMapper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public void setInput(Object input) {
*/
public RexxContentOutlinePage(IDocumentProvider provider, ITextEditor editor) {
super();
elementList = new ArrayList();
elementList = new ArrayList<>();
fDocumentProvider = provider;
fTextEditor = editor;
String[] cat = new String[4];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.imperfectmommy.rexxeditor.contentoutliner;

import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.imperfectmommy.rexxeditor.editors.RexxEditor;

public class RexxOutlineAdapterFactory implements IAdapterFactory {

@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if (IContentOutlinePage.class.equals(adapterType)) {
RexxEditor editor = (RexxEditor) adaptableObject;
return (T) new RexxContentOutlinePage(editor.getDocumentProvider(), editor);
}
return null;
}

@Override
public Class<?>[] getAdapterList() {
return new Class<?>[] { IContentOutlinePage.class };
}

}
71 changes: 0 additions & 71 deletions src/org/imperfectmommy/rexxeditor/editors/ColorManager.java

This file was deleted.

51 changes: 20 additions & 31 deletions src/org/imperfectmommy/rexxeditor/editors/RexxConfiguration.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.imperfectmommy.rexxeditor.editors;

import java.util.ArrayList;

import org.eclipse.jface.resource.StringConverter;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextDoubleClickStrategy;
import org.eclipse.jface.text.TextAttribute;
Expand All @@ -11,43 +10,34 @@
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.presentation.PresentationReconciler;
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
import org.eclipse.jface.text.rules.ITokenScanner;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
import org.imperfectmommy.rexxeditor.Activator;
import org.imperfectmommy.rexxeditor.contentassist.RexxContentAssistProcessor;
import org.imperfectmommy.rexxeditor.contentoutliner.RexxContentElement;
import org.imperfectmommy.rexxeditor.preferences.IRexxPreferenceFields;
import org.imperfectmommy.rexxeditor.scanner.RexxLineScanner;

public class RexxConfiguration extends SourceViewerConfiguration {
private RexxDoubleClickStrategy doubleClickStrategy;
private RexxLineScanner scanner;
private ColorManager colorManager;
private RexxEditor editor;

public RexxConfiguration(ColorManager colorManager, RexxEditor editor) {
this.editor = editor;
this.colorManager = colorManager;
}

@Override
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
return new String[] { IDocument.DEFAULT_CONTENT_TYPE };
}


/*
@Override
public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
IInformationControlCreator creator = new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(Shell parent) {
// TODO Auto-generated method stub
return null;
}
};
}
*/
* @Override public IInformationControlCreator
* getInformationControlCreator(ISourceViewer sourceViewer) {
* IInformationControlCreator creator = new IInformationControlCreator() {
* @Override public IInformationControl createInformationControl(Shell parent) {
* // TODO Auto-generated method stub return null; } }; }
*/

@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
Expand All @@ -71,22 +61,21 @@ public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewe
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
PresentationReconciler reconciler = new RexxPresentationReconciler();
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(this.getRexxScanner());
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(this.getScanner());
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
return reconciler;
}

protected RexxLineScanner getRexxScanner() {
public ITokenScanner getScanner() {
if (this.scanner == null) {
this.scanner = new RexxLineScanner(this.colorManager, this);
this.scanner.setDefaultReturnToken(new Token(new TextAttribute(this.colorManager.getColor(IRexxPreferenceFields.PREF_DEFAULT_COLOR))));
this.scanner = new RexxLineScanner(this);
String rgbString = Activator.getActivator().getPreferenceStore().getString(IRexxPreferenceFields.PREF_DEFAULT_COLOR);
RGB rgb = StringConverter.asRGB(rgbString);
Color color = new Color(Display.getCurrent(), rgb);
Token token = new Token(new TextAttribute(color));
this.scanner.setDefaultReturnToken(token);
}
return this.scanner;
}

public void updateList(ArrayList<RexxContentElement> update) {
this.editor.update(update);
}

}
74 changes: 10 additions & 64 deletions src/org/imperfectmommy/rexxeditor/editors/RexxEditor.java
Original file line number Diff line number Diff line change
@@ -1,78 +1,24 @@
package org.imperfectmommy.rexxeditor.editors;

import java.util.ArrayList;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.imperfectmommy.rexxeditor.Activator;
import org.imperfectmommy.rexxeditor.contentoutliner.RexxContentElement;
import org.imperfectmommy.rexxeditor.contentoutliner.RexxContentOutlinePage;
import org.imperfectmommy.rexxeditor.preferences.RexxPreferencePage;

public class RexxEditor extends TextEditor {
private RexxContentOutlinePage fOutlinePage;
private ColorManager colorManager;

public RexxEditor() {
super();
Activator plugin = Activator.getActivator();
this.colorManager = new ColorManager(plugin.getPreferenceStore());
this.setSourceViewerConfiguration(new RexxConfiguration(this.colorManager, this));
// setPreferenceStore(plugin.getPreferenceStore());
}

@Override
public void dispose() {
this.colorManager.dispose();
if (this.fOutlinePage != null) {
this.fOutlinePage.setInput(null);
}
super.dispose();
}

@Override
public void doSetInput(IEditorInput input) throws CoreException {
super.doSetInput(input);

if (this.fOutlinePage != null) {
this.fOutlinePage.setInput(input);
}
}

@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Class<T> adapter) {
if (IContentOutlinePage.class.equals(adapter)) {
if (this.fOutlinePage == null) {
this.fOutlinePage = new RexxContentOutlinePage(this.getDocumentProvider(), this);
if (this.getEditorInput() != null) {
this.fOutlinePage.setInput(this.getEditorInput());
}
this.setSourceViewerConfiguration(new RexxConfiguration());

Activator.getActivator().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {

@Override
public void propertyChange(PropertyChangeEvent event) {
getSourceViewer().invalidateTextPresentation();
handlePreferenceStoreChanged(event);
}
return (T) this.fOutlinePage;
}
return super.getAdapter(adapter);
}

@Override
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
super.handlePreferenceStoreChanged(event);
});
}

public void update(ArrayList<RexxContentElement> updateList) {
if (this.fOutlinePage != null) {
this.fOutlinePage.update(updateList);
}
}

/*
* protected IVerticalRuler createVerticalRuler() { CompositeRuler ruler = new
* CompositeRuler(); ruler.addDecorator(0, new
* AnnotationRulerColumn(VERTICAL_RULER_WIDTH)); ruler.addDecorator(1,
* createLineNumberRulerColumn()); return ruler; }
*/

}
Loading

0 comments on commit dad047f

Please sign in to comment.