Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added an empty page to the Eclipse Search Dialog

By using the proper Eclipse extension point I've
hooked our own custom view into the Search Dialog.
The view only contains a label for now.

Fix #3
  • Loading branch information...
commit e241f44aa81a0ba02fab9388076b6c4ef8621189 1 parent 23972c0
@mads379 mads379 authored
View
38 org.scala.tools.eclipse.search/plugin.xml
@@ -1,28 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
- <extension
- point="org.eclipse.ui.actionSets">
- <actionSet
- id="example.actionSet"
- label="Sample Action Set"
- visible="true">
- <menu
- id="sampleMenu"
- label="Sample &amp;Menu">
- <separator
- name="sampleGroup">
- </separator>
- </menu>
- <action
- class="org.scala.tools.eclipse.search.SampleAction"
- icon="icons/sample.gif"
- id="org.scala.tools.eclipse.search.sampleAction"
- label="&amp;Sample Action"
- menubarPath="sampleMenu/sampleGroup"
- toolbarPath="sampleGroup"
- tooltip="Hello, Scala world">
- </action>
- </actionSet>
- </extension>
+ <!-- Search pages extension point -->
+ <extension point="org.eclipse.search.searchPages">
+ <!-- When we're ready we need to set showScopeSection to true. -->
+ <page
+ id="org.scala.tools.eclipse.search.ui.ScalaSearchPage"
+ label="Scala Search"
+ sizeHint="250,160"
+ tabPosition="1"
+ extensions="scala:90"
+ enabled="true"
+ showScopeSection="false"
+ class="org.scala.tools.eclipse.search.ui.ScalaSearchPage">
+ </page>
+ </extension>
</plugin>
View
62 org.scala.tools.eclipse.search/src/org/scala/tools/eclipse/search/ui/ScalaSearchPage.scala
@@ -0,0 +1,62 @@
+package org.scala.tools.eclipse.search.ui
+
+import org.eclipse.search.ui.ISearchPage
+import org.eclipse.jface.dialogs.DialogPage
+import org.eclipse.swt.widgets.Composite
+import org.eclipse.search.ui.ISearchPageContainer
+import org.eclipse.swt.SWT
+import org.eclipse.swt.layout.GridLayout
+import org.eclipse.swt.widgets.Label
+import scala.tools.eclipse.logging.HasLogger
+import org.eclipse.swt.layout.GridData
+import org.eclipse.jface.dialogs.Dialog
+import org.eclipse.swt.widgets.Control
+import org.eclipse.swt.widgets.Group
+import org.eclipse.swt.widgets.Button
+import org.eclipse.swt.events.SelectionAdapter
+import org.eclipse.swt.events.SelectionEvent
+import org.eclipse.swt.widgets.Text
+import org.eclipse.swt.events.ModifyListener
+import org.eclipse.swt.events.ModifyEvent
+
+/**
+ * This is the page that is rendered in the Eclipse search dialog. It is
+ * Hooked into Eclipse through the SearchPage extension point.
+ */
+class ScalaSearchPage extends DialogPage with ISearchPage with HasLogger {
+
+ /**
+ * This is invoked when the user presses the search button.
+ */
+ override def performAction(): Boolean = {
+ // TODO: Read input and perform a background query
+ true
+ }
+
+ /**
+ * Called when the the page it put inside the container. We need to keep
+ * a reference to this in our page so we can read the scope options the
+ * user has selected.
+ */
+ override def setContainer(container: ISearchPageContainer): Unit = {}
+
+ /**
+ * Called by Eclipse. It is responsible for creating all the UI elements.
+ */
+ override def createControl(parent: Composite): Unit = {
+
+ val page = new Composite(parent, SWT.FILL)
+ val label = new Label(page, SWT.LEFT)
+ val layout = new GridLayout(2, true)
+ layout.horizontalSpacing = 10
+ page.setLayout(layout)
+
+ label.setText("Nothing fancy to see here yet.")
+ label.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false, 2, 1))
+
+ // If we don't call this we get an NPE in Eclipse w/o this class in the stacktrace. Lovely
+ setControl(page)
+ Dialog.applyDialogFont(page)
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.