Skip to content
This repository

Added an empty page to the Eclipse Search Dialog #10

Merged
merged 2 commits into from about 1 year ago

2 participants

Mads Hartmann Jensen Mirco Dotta
Mads Hartmann Jensen
Collaborator

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.

This also removes all the dummy files that were generated by the scaffolding project structure.

This fixes issue #3

added some commits February 13, 2013
Mads Hartmann Jensen Removed dummy files 23972c0
Mads Hartmann Jensen 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
e241f44
Mirco Dotta dotta merged commit 509fa90 into from February 13, 2013
Mirco Dotta dotta closed this February 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Feb 13, 2013
Mads Hartmann Jensen Removed dummy files 23972c0
Mads Hartmann Jensen 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
e241f44
This page is out of date. Refresh to see the latest.
1  .gitignore
... ...
@@ -1,2 +1,3 @@
1 1
 .cache
2 2
 target/
  3
+.DS_Store
17  org.scala.tools.eclipse.search.tests/src/org/scala/tools/eclipse/search/SomeInterestingCodeTest.scala
... ...
@@ -1,17 +0,0 @@
1  
-package org.scala.tools.eclipse.search
2  
-
3  
-import org.junit.Test
4  
-import org.junit.Assert._
5  
-import scala.tools.eclipse.testsetup.TestProjectSetup
6  
-
7  
-class SomeInterestingCodeTest extends TestProjectSetup("aProject", bundleName= "org.scala.tools.eclipse.search.tests") {
8  
-  
9  
-  @Test
10  
-  def numberOfTypes() {
11  
-    val compilationUnit= scalaCompilationUnit("org/example/ScalaClass.scala")
12  
-    
13  
-    assertEquals("Wrong number of types", 2, SomeInterestingCode.numberOfTypes(compilationUnit))
14  
-    
15  
-  }
16  
-
17  
-}
BIN  org.scala.tools.eclipse.search/icons/sample.gif
38  org.scala.tools.eclipse.search/plugin.xml
... ...
@@ -1,28 +1,18 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <?eclipse version="3.2"?>
3 3
 <plugin>
4  
-   <extension
5  
-         point="org.eclipse.ui.actionSets">
6  
-      <actionSet
7  
-            id="example.actionSet"
8  
-            label="Sample Action Set"
9  
-            visible="true">
10  
-         <menu
11  
-               id="sampleMenu"
12  
-               label="Sample &amp;Menu">
13  
-            <separator
14  
-                  name="sampleGroup">
15  
-            </separator>
16  
-         </menu>
17  
-         <action
18  
-               class="org.scala.tools.eclipse.search.SampleAction"
19  
-               icon="icons/sample.gif"
20  
-               id="org.scala.tools.eclipse.search.sampleAction"
21  
-               label="&amp;Sample Action"
22  
-               menubarPath="sampleMenu/sampleGroup"
23  
-               toolbarPath="sampleGroup"
24  
-               tooltip="Hello, Scala world">
25  
-         </action>
26  
-      </actionSet>
27  
-   </extension>
  4
+  <!-- Search pages extension point -->
  5
+  <extension point="org.eclipse.search.searchPages">
  6
+    <!-- When we're ready we need to set showScopeSection to true. -->
  7
+    <page
  8
+         id="org.scala.tools.eclipse.search.ui.ScalaSearchPage"
  9
+         label="Scala Search"
  10
+         sizeHint="250,160"
  11
+         tabPosition="1"
  12
+         extensions="scala:90"
  13
+         enabled="true"
  14
+         showScopeSection="false"
  15
+         class="org.scala.tools.eclipse.search.ui.ScalaSearchPage">
  16
+    </page>
  17
+  </extension>
28 18
 </plugin>
49  org.scala.tools.eclipse.search/src/org/scala/tools/eclipse/search/SampleAction.scala
... ...
@@ -1,49 +0,0 @@
1  
-package org.scala.tools.eclipse.search
2  
-
3  
-import org.eclipse.ui.IWorkbenchWindowActionDelegate
4  
-import org.eclipse.jface.action.IAction
5  
-import org.eclipse.jface.viewers.ISelection
6  
-import org.eclipse.ui.IWorkbenchWindow
7  
-import org.eclipse.ui.IFileEditorInput
8  
-import scala.tools.eclipse.ScalaPlugin
9  
-import org.eclipse.core.resources.IFile
10  
-import org.eclipse.jface.dialogs.MessageDialog
11  
-
12  
-class SampleAction extends IWorkbenchWindowActionDelegate {
13  
-
14  
-  private var window: IWorkbenchWindow = _
15  
-
16  
-  def dispose() {
17  
-  }
18  
-
19  
-  def init(w: IWorkbenchWindow) {
20  
-    window = w
21  
-  }
22  
-
23  
-  def run(action: IAction) {
24  
-    val activeEditor = window.getActivePage.getActiveEditor
25  
-    if (activeEditor != null) {
26  
-      activeEditor.getEditorInput match {
27  
-        case fei: IFileEditorInput =>
28  
-          display(fei.getFile)
29  
-      }
30  
-    }
31  
-  }
32  
-
33  
-  def selectionChanged(action: IAction, selection: ISelection) {
34  
-  }
35  
-
36  
-  def display(file: IFile) {
37  
-    MessageDialog.openInformation(
38  
-      window.getShell(),
39  
-      "TestPDE",
40  
-      getProjectName(file)
41  
-        .map("The Scala project for the current editor is %s".format(_))
42  
-        .getOrElse("The current editor is not part of a Scala project"))
43  
-  }
44  
-
45  
-  def getProjectName(file: IFile): Option[String] = {
46  
-    ScalaPlugin.plugin.asScalaProject(file.getProject).map(_.underlying.getName)
47  
-  }
48  
-
49  
-}
11  org.scala.tools.eclipse.search/src/org/scala/tools/eclipse/search/SomeInterestingCode.scala
... ...
@@ -1,11 +0,0 @@
1  
-package org.scala.tools.eclipse.search
2  
-
3  
-import scala.tools.eclipse.javaelements.ScalaCompilationUnit
4  
-
5  
-object SomeInterestingCode {
6  
-  
7  
-  def numberOfTypes(scalaCompilationUnit: ScalaCompilationUnit): Int = {
8  
-    scalaCompilationUnit.getCompilationUnit.getAllTypes.length
9  
-  }
10  
-
11  
-}
62  org.scala.tools.eclipse.search/src/org/scala/tools/eclipse/search/ui/ScalaSearchPage.scala
... ...
@@ -0,0 +1,62 @@
  1
+package org.scala.tools.eclipse.search.ui
  2
+
  3
+import org.eclipse.search.ui.ISearchPage
  4
+import org.eclipse.jface.dialogs.DialogPage
  5
+import org.eclipse.swt.widgets.Composite
  6
+import org.eclipse.search.ui.ISearchPageContainer
  7
+import org.eclipse.swt.SWT
  8
+import org.eclipse.swt.layout.GridLayout
  9
+import org.eclipse.swt.widgets.Label
  10
+import scala.tools.eclipse.logging.HasLogger
  11
+import org.eclipse.swt.layout.GridData
  12
+import org.eclipse.jface.dialogs.Dialog
  13
+import org.eclipse.swt.widgets.Control
  14
+import org.eclipse.swt.widgets.Group
  15
+import org.eclipse.swt.widgets.Button
  16
+import org.eclipse.swt.events.SelectionAdapter
  17
+import org.eclipse.swt.events.SelectionEvent
  18
+import org.eclipse.swt.widgets.Text
  19
+import org.eclipse.swt.events.ModifyListener
  20
+import org.eclipse.swt.events.ModifyEvent
  21
+
  22
+/**
  23
+ * This is the page that is rendered in the Eclipse search dialog. It is 
  24
+ * Hooked into Eclipse through the SearchPage extension point.
  25
+ */
  26
+class ScalaSearchPage extends DialogPage with ISearchPage with HasLogger {
  27
+
  28
+  /**
  29
+   * This is invoked when the user presses the search button.
  30
+   */
  31
+  override def performAction(): Boolean = {
  32
+    // TODO: Read input and perform a background query
  33
+    true
  34
+  }
  35
+
  36
+  /**
  37
+   * Called when the the page it put inside the container. We need to keep
  38
+   * a reference to this in our page so we can read the scope options the
  39
+   * user has selected.
  40
+   */
  41
+  override def setContainer(container: ISearchPageContainer): Unit = {}
  42
+
  43
+  /**
  44
+   * Called by Eclipse. It is responsible for creating all the UI elements.
  45
+   */
  46
+  override def createControl(parent: Composite): Unit = {
  47
+
  48
+    val page = new Composite(parent, SWT.FILL)
  49
+    val label = new Label(page, SWT.LEFT)
  50
+    val layout = new GridLayout(2, true)
  51
+    layout.horizontalSpacing = 10
  52
+    page.setLayout(layout)
  53
+
  54
+    label.setText("Nothing fancy to see here yet.")
  55
+    label.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false, 2, 1))
  56
+
  57
+    // If we don't call this we get an NPE in Eclipse w/o this class in the stacktrace. Lovely
  58
+    setControl(page)
  59
+    Dialog.applyDialogFont(page)
  60
+  }
  61
+
  62
+}
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.