File: toolbar.groovy

package info (click to toggle)
omegat 3.6.0.10%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 63,728 kB
  • sloc: xml: 114,044; java: 74,758; sh: 174; javascript: 108; makefile: 22
file content (36 lines) | stat: -rw-r--r-- 962 bytes parent folder | download | duplicates (2)
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
29
30
31
32
33
34
35
36
import javax.swing.JToolBar;
import javax.swing.JButton;

import java.awt.Dimension;
import java.awt.image.RescaleOp;

import org.omegat.util.Preferences;
import org.omegat.gui.main.DockableScrollPane;
import org.omegat.gui.scripting.ScriptItem;

import java.io.File;

def title = "Scripts";
def toolBar = new JToolBar("Still draggable");

def scriptsDir = new File(Preferences.getPreferenceDefault(Preferences.SCRIPTS_DIRECTORY, "."));

scriptsDir.list().each{ f ->
	if ( f.find(/\.groovy$/) )
	{
		console.println("button \"" + f + "\"")
		def item = new ScriptItem(f, scriptsDir);
		def button = new JButton()
		button.setText(item.name)
		button.setToolTipText(item.description)
		//button.addMouseListener(null)
		toolBar.add(button)
	}
}

toolBar.setPreferredSize(new Dimension(24, 140));
toolBar.setVisible(true);

// XXX Add a SCRIPTTOOLBAR each time it is called. 
mainWindow.addDockable(new DockableScrollPane("SCRIPTTOOLBAR", title, toolBar, true));