diff --git a/org.scala-ide.play2.tests/src/org/scalaide/play2/routeeditor/lexical/AbstractRouteScannerTest.scala b/org.scala-ide.play2.tests/src/org/scalaide/play2/routeeditor/lexical/AbstractRouteScannerTest.scala index f2be9c7a..9675acaf 100644 --- a/org.scala-ide.play2.tests/src/org/scalaide/play2/routeeditor/lexical/AbstractRouteScannerTest.scala +++ b/org.scala-ide.play2.tests/src/org/scalaide/play2/routeeditor/lexical/AbstractRouteScannerTest.scala @@ -6,7 +6,7 @@ import org.junit.Assert.assertEquals import org.scalaide.play2.PlayPlugin abstract class AbstractRouteScannerTest { - protected val prefStore = PlayPlugin.preferenceStore + protected val prefStore = PlayPlugin.instance().getPreferenceStore protected val scanner : AbstractRouteScanner protected val defaultToken = scanner.getDefaultReturnToken protected val wsToken = Token.WHITESPACE diff --git a/org.scala-ide.play2/src/org/scalaide/play2/Play.scala b/org.scala-ide.play2/src/org/scalaide/play2/Play.scala new file mode 100644 index 00000000..015de54f --- /dev/null +++ b/org.scala-ide.play2/src/org/scalaide/play2/Play.scala @@ -0,0 +1,64 @@ +package org.scalaide.play2 + +import scala.collection.immutable.Seq + +trait Play { + def templateImports: TemplateImports +} + +trait TemplateImports { + def defaultScalaTemplateImports: Seq[String] + def defaultJavaTemplateImports: Seq[String] + def templateResultType: String + def templateFormatterType: String +} + +object Play { + final val SupportedVersion = List("2.4", "2.3", "2.2") + final val DefaultVersion = SupportedVersion.head + + def apply(version: String): Play = version match { + case "2.4" | "2.3" => new Play24 + case _ => ??? + } + + private final class Play24 extends Play { + lazy val templateImports: TemplateImports = new Play24.Play24TemplateImports + } + + private object Play24 { + private final class Play24TemplateImports extends TemplateImports { + // all imports have been copied from play.TemplateImports (see the playframework codebase) + + private def defaultTemplateImports: Seq[String] = List( + "models._", + "controllers._", + "play.api.i18n._", + "play.api.mvc._", + "views.%format%._", + "play.api.templates.PlayMagic._" + ) + + lazy val defaultJavaTemplateImports: Seq[String] = defaultTemplateImports ++ List( + "java.lang._", + "java.util._", + "scala.collection.JavaConversions._", + "scala.collection.JavaConverters._", + "play.core.j.PlayMagicForJava._", + "play.mvc._", + "play.data._", + "play.api.data.Field", + "play.mvc.Http.Context.Implicit._" + ) + + lazy val defaultScalaTemplateImports: Seq[String] = defaultTemplateImports ++ List( + "play.api.mvc._", + "play.api.data._" + ) + + def templateResultType: String = templateFormatterType + ".Appendable" + + def templateFormatterType: String = "play.twirl.api.HtmlFormat" + } + } +} \ No newline at end of file diff --git a/org.scala-ide.play2/src/org/scalaide/play2/PlayPlugin.scala b/org.scala-ide.play2/src/org/scalaide/play2/PlayPlugin.scala index c44e505a..71f0f4f1 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/PlayPlugin.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/PlayPlugin.scala @@ -23,43 +23,45 @@ object PlayPlugin { /** Return the current plugin instace */ def instance(): PlayPlugin = plugin - /** Return the plugin-wide preference store */ - def preferenceStore: IPreferenceStore = plugin.getPreferenceStore + def getImageDescriptor(path: String): ImageDescriptor = + AbstractUIPlugin.imageDescriptorFromPlugin(PluginId, path) - def getImageDescriptor(path: String): ImageDescriptor = { - AbstractUIPlugin.imageDescriptorFromPlugin(PluginId, path); - } - - def log(status: Int, msg: String, ex: Throwable = null): Unit = { + def log(status: Int, msg: String, ex: Throwable = null): Unit = plugin.getLog.log(new Status(status, plugin.getBundle().getSymbolicName(), msg, ex)) + + def isPlayProject(project: IProject): Boolean = asPlayProject(project).isDefined + + def asPlayProject(project: IProject): Option[PlayProject] = { + for { + scalaPlugin <- Option(IScalaPlugin()) + scalaProject <- scalaPlugin.asScalaProject(project) + } yield PlayProject(scalaProject) } } class PlayPlugin extends AbstractUIPlugin { override def start(context: BundleContext): Unit = { - super.start(context) PlayPlugin.plugin = this + super.start(context) initializeProjects() } + private def initializeProjects(): Unit = { + // FIXME: All Scala projects are paying a penalty if the Play2 support is installed. + // I don't like it, but I'm not sure how to fix this. Maybe we should add a + // Play Nature? + // Also, how is the `Play2PropertyTester` used/useful? + for { + project <- ResourcesPlugin.getWorkspace.getRoot.getProjects + if project.isOpen + } PlayPlugin.asPlayProject(project) + } + override def stop(context: BundleContext): Unit = { PlayPlugin.plugin = null super.stop(context) } - def asPlayProject(project: IProject): Option[PlayProject] = { - val scalaProject = IScalaPlugin().asScalaProject(project) - scalaProject map (PlayProject(_)) - } - - private def initializeProjects(): Unit = { - for { - iProject <- ResourcesPlugin.getWorkspace.getRoot.getProjects - if iProject.isOpen - playProject <- asPlayProject(iProject) - } playProject.initialize() - } - override def initializeImageRegistry(reg: ImageRegistry) { reg.put(Images.ROUTES_ICON, Images.ROUTES_ICON_DESCRIPTOR) reg.put(Images.HTTP_METHODS_ICON, Images.HTTP_METHODS_ICON_DESCRIPTOR) diff --git a/org.scala-ide.play2/src/org/scalaide/play2/PlayProject.scala b/org.scala-ide.play2/src/org/scalaide/play2/PlayProject.scala index 15c8e0be..814fa7c3 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/PlayProject.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/PlayProject.scala @@ -7,48 +7,74 @@ import org.eclipse.core.resources.IFile import org.scalaide.play2.templateeditor.TemplateCompilationUnit import org.eclipse.ui.preferences.ScopedPreferenceStore import org.eclipse.core.resources.ProjectScope -import org.scalaide.play2.util.SyncedScopedPreferenceStore import org.eclipse.jface.preference.IPreferenceStore import org.scalaide.play2.properties.PlayPreferences - import scala.collection.mutable +import org.eclipse.jface.util.PropertyChangeEvent -class PlayProject private (val scalaProject: IScalaProject) { - val cachedPreferenceStore = new SyncedScopedPreferenceStore(scalaProject.underlying, PlayPlugin.PluginId) +class PlayProject private (scalaProject: IScalaProject) { + @volatile private var _playSupport: Play = Play(Play.DefaultVersion) - /** Return additional imports that are automatically added to template files. - * - * @return The additional imports, or the empty string if none defined. - */ - def additionalTemplateImports(extension: String): String = { - cachedPreferenceStore.getString(PlayPreferences.TemplateImports).replace("%format%", extension); - } + def playSupport: Play = _playSupport + + lazy val projectPrefStore = generateScopedPreferenceStore /** Return a new project-scoped preference store for this project. */ def generateScopedPreferenceStore: IPreferenceStore = new ScopedPreferenceStore(new ProjectScope(scalaProject.underlying), PlayPlugin.PluginId) - /** Tries to load the scala template files - */ - def initialize() { - val templateCompilationUnits = for ( - r <- scalaProject.underlying.members() if r.isInstanceOf[IFile] && r.getFullPath().toString().endsWith("." + PlayPlugin.TemplateExtension) - ) yield TemplateCompilationUnit(r.asInstanceOf[IFile], false) - templateCompilationUnits foreach (_.initialReconcile()) - // TODO: Why was there a second round of ask reload here? - // templateCompilationUnits.reverse foreach (_.askReload()) + /** Tries to load the scala template files */ + private def initialize() { + initializePreferences() + initializeTemplates() + } + + private def initializePreferences(): Unit = { + import org.scalaide.util.eclipse.SWTUtils.fnToPropertyChangeListener + projectPrefStore.addPropertyChangeListener((event: PropertyChangeEvent) => event.getProperty() match { + case PlayPreferences.PlayVersion => + val value = event.getNewValue().toString() + _playSupport = Play(value) + import org.eclipse.core.runtime.IStatus + PlayPlugin.log(IStatus.OK, s"Value of ${PlayPreferences.PlayVersion} is ${value}") + // do something with the new value + case PlayPreferences.TemplateImports => + val value = event.getNewValue().toString() + import org.eclipse.core.runtime.IStatus + PlayPlugin.log(IStatus.OK, s"Value of ${PlayPreferences.TemplateImports} is ${value}") + case other => + import org.eclipse.core.runtime.IStatus + PlayPlugin.log(IStatus.OK, s"Not interested on $other") + }); } + private def initializeTemplates(): Unit = { + for { + r <- scalaProject.underlying.members() + if r.isInstanceOf[IFile] && r.getFullPath().toString().endsWith("." + PlayPlugin.TemplateExtension) + } { + // FIXME: I wonder what happens is the presentation compiler is restarted. + // Will the template compilation units still be loaded? + // If not, then why do we actually need to load them in the first place? + val unit = TemplateCompilationUnit(r.asInstanceOf[IFile], false) + unit.initialReconcile() + } + } + /** FIXME: This method should probably not exist. * Template files can be anywhere * * @return the absolute location of the project directory */ - lazy val sourceDir = scalaProject.underlying.getLocation().toFile() + private[play2] lazy val sourceDir = scalaProject.underlying.getLocation().toFile() } object PlayProject { + // FIXME: This is a source of memory leaks. We should remove the project from the map if it's deleted. private val projects = (new mutable.HashMap) withDefault {(scalaProject: IScalaProject) => new PlayProject(scalaProject)} + def apply(scalaProject: IScalaProject): PlayProject = { - projects(scalaProject) + val project = projects(scalaProject) + project.initialize() + project } } \ No newline at end of file diff --git a/org.scala-ide.play2/src/org/scalaide/play2/properties/PlayPreferences.scala b/org.scala-ide.play2/src/org/scalaide/play2/properties/PlayPreferences.scala index 70594fe3..3090df01 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/properties/PlayPreferences.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/properties/PlayPreferences.scala @@ -18,6 +18,8 @@ object PlayPreferences { */ final val TemplateImports = "templateImports" + final val PlayVersion = "playVersion" + // Regex used for the operations on the templateImports preference. private val importsRegex = "import ([^\n]+)\n".r diff --git a/org.scala-ide.play2/src/org/scalaide/play2/properties/PreferenceInitializer.scala b/org.scala-ide.play2/src/org/scalaide/play2/properties/PreferenceInitializer.scala index 43e3b16b..5bb18426 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/properties/PreferenceInitializer.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/properties/PreferenceInitializer.scala @@ -4,9 +4,7 @@ import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer import org.scalaide.play2.PlayPlugin class PreferenceInitializer extends AbstractPreferenceInitializer { - - override def initializeDefaultPreferences() { - PlayPlugin.preferenceStore.setDefault(PlayPreferences.TemplateImports, "import play.api.templates._\nimport play.api.templates.PlayMagic._\n") + override def initializeDefaultPreferences(): Unit = { + PlayPlugin.instance().getPreferenceStore().setDefault(PlayPreferences.TemplateImports, "") } - } \ No newline at end of file diff --git a/org.scala-ide.play2/src/org/scalaide/play2/properties/ProjectPropertyPage.scala b/org.scala-ide.play2/src/org/scalaide/play2/properties/ProjectPropertyPage.scala index 1cdd121a..ed1fcadb 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/properties/ProjectPropertyPage.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/properties/ProjectPropertyPage.scala @@ -13,14 +13,48 @@ import org.eclipse.swt.widgets.Composite import org.eclipse.swt.widgets.Display import org.eclipse.ui.IWorkbenchPropertyPage import org.scalaide.play2.PlayPlugin +import org.scalaide.play2.Play +import org.eclipse.ui.IWorkbench +import org.eclipse.ui.IWorkbenchPreferencePage /** Preference page displayed in the property dialog of (play) projects. * Used from the UI thread. */ class ProjectPropertyPage extends FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) with IWorkbenchPropertyPage { - /** Preference field to display the list of extra imports. - */ + private var prefStore: IPreferenceStore = _ + + override protected def createFieldEditors() { + import ProjectPropertyPage._ + addField(new PlayProjectVersion(getFieldEditorParent())) + addField(new ImportsFieldEditor(PlayPreferences.TemplateImports, "Template default imports", getFieldEditorParent())) + } + + override protected def doGetPreferenceStore(): IPreferenceStore = prefStore + + // Members declared in org.eclipse.ui.IWorkbenchPropertyPage + + // doesn't seem to be a real function for this method. + // It looks like it leaked from the implementation of PropertyPage. + override def getElement(): IAdaptable = null + + override def setElement(element: IAdaptable): Unit = { + prefStore = element match { + case project: IProject => + PlayPlugin.asPlayProject(project).get.generateScopedPreferenceStore + case project: IJavaProject => + PlayPlugin.asPlayProject(project.getProject()).get.generateScopedPreferenceStore + case _ => null + } + } +} + +object ProjectPropertyPage { + import org.eclipse.jface.preference.ComboFieldEditor + private def supportedVersions = Play.SupportedVersion.toArray.map(version => Array(version, version)) + class PlayProjectVersion(parent:Composite) extends ComboFieldEditor(PlayPreferences.PlayVersion, "Play version", supportedVersions, parent) + + /** Preference field to display the list of extra imports. */ private class ImportsFieldEditor(name: String, labelText: String, parent: Composite) extends ListEditor(name, labelText, parent) { override protected def createList(entries: Array[String]): String = @@ -30,7 +64,6 @@ class ProjectPropertyPage extends FieldEditorPreferencePage(FieldEditorPreferenc PlayPreferences.deserializeImports(s) override protected def getNewInputObject(): String = { - val dlg = new InputDialog( Display.getCurrent().getActiveShell(), "Play template import", @@ -46,38 +79,5 @@ class ProjectPropertyPage extends FieldEditorPreferencePage(FieldEditorPreferenc null } } - - } - - // The preference store being edited. - // The data require to get the store is provided by the workbench during the page lifecycle. - private var prefStore: IPreferenceStore = _ - - // Members declared in org.eclipse.jface.preference.FieldEditorPreferencePage - - override def createFieldEditors() { - addField(new ImportsFieldEditor(PlayPreferences.TemplateImports, "Template default imports", getFieldEditorParent())) - } - - // Members declared in org.eclipse.ui.IWorkbenchPropertyPage - - // doesn't seem to be a real function for this method. - // It looks like it leaked from the implementation of PropertyPage. - override def getElement(): IAdaptable = null - - override def setElement(element: IAdaptable) { - prefStore = element match { - case project: IProject => - PlayPlugin.instance().asPlayProject(project).get.generateScopedPreferenceStore - case project: IJavaProject => - PlayPlugin.instance().asPlayProject(project.getProject()).get.generateScopedPreferenceStore - } } - - // ---- - - override def doGetPreferenceStore(): IPreferenceStore = { - prefStore - } - } \ No newline at end of file diff --git a/org.scala-ide.play2/src/org/scalaide/play2/routeeditor/RouteEditor.scala b/org.scala-ide.play2/src/org/scalaide/play2/routeeditor/RouteEditor.scala index 29446741..b3dfcf04 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/routeeditor/RouteEditor.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/routeeditor/RouteEditor.scala @@ -21,7 +21,7 @@ import org.eclipse.ui.texteditor.TextOperationAction import org.scalaide.play2.PlayPlugin class RouteEditor extends TextEditor with ISourceViewerEditor with HasLogger with HasScalaProject { self => - private lazy val preferenceStore = new ChainedPreferenceStore(Array(PlayPlugin.preferenceStore, EditorsUI.getPreferenceStore)) + private lazy val preferenceStore = new ChainedPreferenceStore(Array(PlayPlugin.instance().getPreferenceStore(), EditorsUI.getPreferenceStore)) private val config = new RouteConfiguration(preferenceStore, this) this.setPreferenceStore(preferenceStore) @@ -57,7 +57,7 @@ class RouteEditor extends TextEditor with ISourceViewerEditor with HasLogger wit HandlerUtil.getActiveEditor(event) match { case routeEditor: RouteEditor if routeEditor eq self => { val isSaveAction = commandid == "org.eclipse.ui.file.save" - val shouldFormatOnSave = PlayPlugin.preferenceStore.getBoolean(PlayPlugin.RouteFormatterFormatOnSaveId) + val shouldFormatOnSave = PlayPlugin.instance().getPreferenceStore().getBoolean(PlayPlugin.RouteFormatterFormatOnSaveId) if (isSaveAction && shouldFormatOnSave) { val document = routeEditor.getSourceViewer.getDocument routeEditor.config.getContentFormatter(routeEditor.getSourceViewer).format(document, new Region(0, document.getLength)) diff --git a/org.scala-ide.play2/src/org/scalaide/play2/routeeditor/formatter/RouteFormattingStrategy.scala b/org.scala-ide.play2/src/org/scalaide/play2/routeeditor/formatter/RouteFormattingStrategy.scala index 6487ea79..7ff122b2 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/routeeditor/formatter/RouteFormattingStrategy.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/routeeditor/formatter/RouteFormattingStrategy.scala @@ -132,7 +132,7 @@ class RouteFormattingStrategy(val editor: ITextEditor) extends IFormattingStrate import RouteFormattingStrategy._ val lines = getLines(document) - val margin = PlayPlugin.preferenceStore.getInt(PlayPlugin.RouteFormatterMarginId) + val margin = PlayPlugin.instance().getPreferenceStore().getInt(PlayPlugin.RouteFormatterMarginId) val maxHttpVerbLength = getMaxHttpVerbLength(lines) + margin val maxUriLength = getMaxUriLength(lines) + margin val eclipseEdits = lines flatMap { route => diff --git a/org.scala-ide.play2/src/org/scalaide/play2/routeeditor/properties/RouteColorPreferenceInitializer.scala b/org.scala-ide.play2/src/org/scalaide/play2/routeeditor/properties/RouteColorPreferenceInitializer.scala index 45501756..d56aa399 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/routeeditor/properties/RouteColorPreferenceInitializer.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/routeeditor/properties/RouteColorPreferenceInitializer.scala @@ -14,7 +14,7 @@ class RouteColorPreferenceInitializer extends AbstractPreferenceInitializer { } private def doInitializeDefaultPreferences() { - val prefStore = PlayPlugin.preferenceStore + val prefStore = PlayPlugin.instance().getPreferenceStore() setDefaultsForSyntaxClasses(prefStore) prefStore.setDefault(PlayPlugin.RouteFormatterMarginId, 3) // for formatter } diff --git a/org.scala-ide.play2/src/org/scalaide/play2/routeeditor/properties/RouteFormatterPreferencePage.scala b/org.scala-ide.play2/src/org/scalaide/play2/routeeditor/properties/RouteFormatterPreferencePage.scala index 6251b68a..7291bf94 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/routeeditor/properties/RouteFormatterPreferencePage.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/routeeditor/properties/RouteFormatterPreferencePage.scala @@ -8,8 +8,11 @@ import org.scalaide.play2.PlayPlugin class RouteFormatterPreferencePage extends FieldEditorPreferencePage with IWorkbenchPreferencePage { - setPreferenceStore(PlayPlugin.preferenceStore) - + override protected def init(workbench: IWorkbench): Unit = { + setPreferenceStore(PlayPlugin.instance().getPreferenceStore()); + setDescription("Play routes preference page"); + } + override def createFieldEditors() { val marginField = new IntegerFieldEditor(PlayPlugin.RouteFormatterMarginId, "Number of spaces between columns", getFieldEditorParent) marginField.setValidRange(1, 10) @@ -18,7 +21,4 @@ class RouteFormatterPreferencePage extends FieldEditorPreferencePage with IWorkb val formatOnSaveToggle = new org.eclipse.jface.preference.BooleanFieldEditor(PlayPlugin.RouteFormatterFormatOnSaveId, "Format on save", getFieldEditorParent) addField(formatOnSaveToggle); } - - def init(workbench: IWorkbench) {} - } \ No newline at end of file diff --git a/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/TemplateEditor.scala b/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/TemplateEditor.scala index fc08c043..f5d518b6 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/TemplateEditor.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/TemplateEditor.scala @@ -29,7 +29,7 @@ trait AbstractTemplateEditor extends SourceCodeEditor { self: TextEditor => class TemplateEditor extends TextEditor with AbstractTemplateEditor { - override protected lazy val preferenceStore: IPreferenceStore = new ChainedPreferenceStore(Array((EditorsUI.getPreferenceStore()), PlayPlugin.preferenceStore)) + override protected lazy val preferenceStore: IPreferenceStore = new ChainedPreferenceStore(Array((EditorsUI.getPreferenceStore()), PlayPlugin.instance().getPreferenceStore())) private val sourceViewConfiguration = new TemplateConfiguration(preferenceStore, this) private val documentProvider = new TemplateDocumentProvider() diff --git a/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/compiler/CompilerUsing.scala b/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/compiler/CompilerUsing.scala index 5a4dfb9c..228e6822 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/compiler/CompilerUsing.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/compiler/CompilerUsing.scala @@ -19,15 +19,7 @@ import org.scalaide.core.compiler.ScalaCompilationProblem * a helper for using template compiler */ object CompilerUsing extends HasLogger { - val templateCompiler = TwirlCompiler - val defaultTemplateImports = """ -import models._ -import controllers._ -import play.api.i18n._ -import play.api.mvc._ -import play.api.data._ -import views.html._ -""" + private val templateCompiler = TwirlCompiler /** * invokes compile method of template compiler and returns generated source object or @@ -39,15 +31,17 @@ import views.html._ logger.debug(s"Template file '${source.getAbsolutePath}' must be located in '$sourcePath' or one of its subfolders!") val extension = source.getName.split('.').last + val templateImports = playProject.playSupport.templateImports Try { templateCompiler.compileVirtual( content, source, playProject.sourceDir, - "play.api.templates.Html", - "play.api.templates.HtmlFormat", - defaultTemplateImports + playProject.additionalTemplateImports(extension), + templateImports.templateResultType, + templateImports.templateFormatterType, + formatImports(templateImports.defaultScalaTemplateImports, extension), + // formatImports(playProject.additionalTemplateImports(extension), extension), Codec.default, inclusiveDot ) @@ -62,6 +56,9 @@ import views.html._ } } + private def formatImports(templateImports: Seq[String], extension: String): String = { + templateImports.map("import " + _.replace("%format%", extension)).mkString("\n") + } } case class TemplateToScalaCompilationError(source: File, message: String, offset: Int, line: Int, column: Int) extends RuntimeException(message) { diff --git a/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/properties/TemplateColorPreferenceInitializer.scala b/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/properties/TemplateColorPreferenceInitializer.scala index 7866f64c..5e4ad443 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/properties/TemplateColorPreferenceInitializer.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/properties/TemplateColorPreferenceInitializer.scala @@ -20,7 +20,7 @@ class TemplateColorPreferenceInitializer extends AbstractPreferenceInitializer { } private def doInitializeDefaultPreferences() { - setDefaultsForSyntaxClasses(PlayPlugin.preferenceStore) + setDefaultsForSyntaxClasses(PlayPlugin.instance().getPreferenceStore()) } private def setDefaultsForSyntaxClass( diff --git a/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/sse/TemplateStructuredEditor.scala b/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/sse/TemplateStructuredEditor.scala index f5e63ccb..c3423267 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/sse/TemplateStructuredEditor.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/sse/TemplateStructuredEditor.scala @@ -22,7 +22,7 @@ import scala.concurrent._ class TemplateStructuredEditor extends StructuredTextEditor with AbstractTemplateEditor { override protected lazy val preferenceStore: IPreferenceStore = - new ChainedPreferenceStore(Array((EditorsUI.getPreferenceStore()), PlayPlugin.preferenceStore)) + new ChainedPreferenceStore(Array((EditorsUI.getPreferenceStore()), PlayPlugin.instance().getPreferenceStore())) /* This is a nasty hack. * The problem: The TemplateStructuredTextViewerConfiguration needs the pref store and a reference to the editor. diff --git a/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/sse/lexical/TemplateRegionParser.scala b/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/sse/lexical/TemplateRegionParser.scala index 4303a29a..dc3d17c9 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/sse/lexical/TemplateRegionParser.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/sse/lexical/TemplateRegionParser.scala @@ -463,7 +463,7 @@ private class TemplateTextRegionConverter(documentContent: String, tokens: Seq[I } private object TemplateTextRegionConverter { - val preferenceStore = new ChainedPreferenceStore(Array((EditorsUI.getPreferenceStore()), PlayPlugin.preferenceStore)) + val preferenceStore = new ChainedPreferenceStore(Array((EditorsUI.getPreferenceStore()), PlayPlugin.instance().getPreferenceStore())) } // This is a copy and pasted implementation of AttributeNameRegion, with the only change being that adjustTextLength diff --git a/org.scala-ide.play2/src/org/scalaide/play2/util/Play2PropertyTester.scala b/org.scala-ide.play2/src/org/scalaide/play2/util/Play2PropertyTester.scala index ebab06a3..9077a944 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/util/Play2PropertyTester.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/util/Play2PropertyTester.scala @@ -22,9 +22,9 @@ class Play2PropertyTester() extends PropertyTester { case IsPlayProject => receiver match { case project: IProject => - PlayPlugin.instance().asPlayProject(project).isDefined + PlayPlugin.isPlayProject(project) case project: IJavaProject => - PlayPlugin.instance().asPlayProject(project.getProject()).isDefined + PlayPlugin.isPlayProject(project.getProject()) case _ => false } diff --git a/org.scala-ide.play2/src/org/scalaide/play2/util/SyncedScopedPreferenceStore.scala b/org.scala-ide.play2/src/org/scalaide/play2/util/SyncedScopedPreferenceStore.scala deleted file mode 100644 index 99912303..00000000 --- a/org.scala-ide.play2/src/org/scalaide/play2/util/SyncedScopedPreferenceStore.scala +++ /dev/null @@ -1,16 +0,0 @@ -package org.scalaide.play2.util - -import org.eclipse.core.resources.IProject -import org.eclipse.core.resources.ProjectScope -import org.eclipse.ui.preferences.ScopedPreferenceStore - -class SyncedScopedPreferenceStore(project: IProject, pluginId: String) { - - private val preferenceStore = new ScopedPreferenceStore(new ProjectScope(project), pluginId) - - def getString(name: String): String = { - preferenceStore.synchronized { - preferenceStore.getString(name) - } - } -} \ No newline at end of file