hakobe (owner)

Revisions

gist: 139600 Download_button fork
public
Public Clone URL: git://gist.github.com/139600.git
Embed All Files: show embed
MySWT.scala #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import org.eclipse.swt._
import org.eclipse.swt.layout._
import org.eclipse.swt.widgets._
import org.eclipse.swt.events._
 
object MySWT {
  def main(args:Array[String]) = {
    val display = new Display()
 
    val shell = new Shell(display)
    shell.setText("MySWT")
    shell.setSize(200, 100)
    shell.setLayout(new GridLayout());
 
    val l1 = new Label(shell, SWT.PUSH);
    l1.setText("Hello");
 
    shell.open()
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep()
      }
    }
    display.dispose()
  }
}
 
Rakefile #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
SCALAC = 'scalac'
SCALA = 'scala'
JAVACMD = '/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java'
JAVA_OPTS = '-XstartOnFirstThread'
CLASSPATH = %w(
/Applications/eclipse/plugins/org.eclipse.swt.cocoa.macosx_3.5.0.v3550b.jar
)
 
PROJECT = 'MySWT'
SRCS = FileList['*.scala']
 
def opt_classpath
  classpath = CLASSPATH
  classpath.unshift('.')
  "-classpath \"#{classpath.join(':')}\""
end
 
task :default => ['compile', 'run']
 
task 'compile' do
  sh "#{SCALAC} #{opt_classpath} #{PROJECT}.scala"
end
 
task 'run' do
  sh "env JAVACMD=#{JAVACMD} JAVA_OPTS=#{JAVA_OPTS} #{SCALA} #{opt_classpath} #{PROJECT}"
end