zeta
1.1. 개요 ¶Zeta는 작은 미니 응용프로그램을 만들고 구동시킬 수 있는 툴입니다. 익숙한 자바
언어와 SWT로 손쉽게 프로그램을 만들 수 있으며, XML만을 사용할 수도 있습니다.
제작 방법은 홈페이지와 demo 디렉터리의 예제들을 참고하세요. Zeta Pure는 JDK와
SWT가 지원되는 모든 플랫폼에서 사용 가능하며, 윈도우용으로는 GCJ로 컴파일된
바이너리를 배포합니다.
현재 이 프로젝트는 GCJ, SWT, BeanShell, CookXML을 이용하며, 추후 Groovy, Jython,
Javascript등을 기본 지원할 예정입니다.
1.4. 개발 환경 ¶Zeta 0.1 - 0.2 :
1.6. 달라진 점 ¶0.1 : 최초 공개 버전.
0.2 :
2. Zeta용 프로그램 제작 ¶현재 bsh와 cookswt를 사용한 xml로 만들 수 있습니다.
사용법은 트레이의 zeta 아이콘의 메뉴를 열어 Load를 선택한 뒤 파일을 선택하면 됩니다.
콘솔을 열면 프롬프트에서 빈셸 스크립팅 및 예외 발생 등에 대한 기록을 볼 수 있으며,
여러 셸을 띄운 상태에서 zeta 아이콘을 클릭하는 것으로
console을 제외한 모든 셸을 보이게 하거나 감출 수 있습니다.
2.1.1. demo/HelloWorld1.bsh ¶zeta는 bsh 파일을 읽어들일 수 있습니다.
다음은 SWT로 간단한 창을 출력하는 bsh 스크립트입니다.
class Hello{
public Hello(){
Display d = Display.getCurrent();
Shell s = new Shell(d, SWT.SHELL_TRIM | SWT.TOOL);
Label l = new Label(s, SWT.CENTER);
s.setLayout(new FillLayout());
String str = "Hello, Zeta!";
l.setText(str);
s.setText(str);
s.pack();
s.open();
}
}
new Hello();
2.1.2. demo/HelloWorld4.xml ¶zeta는 xml 파일을 cookswt를 이용해 파싱합니다.
다음과 같이 스크립트를 xml에 내장할 수 있습니다.
<!-- original source by http://cookxml.sourceforge.net/cookbsh/ -->
<shell style="SHELL_TRIM | TOOL" text="Hello World!" size="320,240">
<filllayout type="VERTICAL">
<clabel id="label" style="BORDER | CENTER" text="Hello, Zeta! 4"/>
<button text="Click!">
<bsh func="addSelectionListener">
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.events.SelectionEvent;
widgetSelected( e )
{
label.setText(e.source.getText () + " Pressed");
}
widgetDefaultSelected( e )
{
}
return (SelectionListener)this;
</bsh>
</button>
<!-- calling an external BSH code (identical to the bsh code above) -->
<!--button text="Button 2">
<bsh func="addActionListener" src="examples/cookbsh/action.bsh"/>
</button-->
</filllayout>
</shell>
2.1.3. PropertyCat.xml ¶자바의 프로퍼티들을 출력하는 간단한 예제.
<shell style="SHELL_TRIM | TOOL" text="PropertyCat" size="320,240">
<filllayout type="VERTICAL">
<textarea style="BORDER | MULTI | V_SCROLL | H_SCROLL">
<bsh setas="text">
String getProperty(){
java.util.Properties p = System.getProperties();
java.util.Enumeration e = System.getProperties().propertyNames();
StringBuilder sb = new StringBuilder();
while(e.hasMoreElements()){
String str = e.nextElement().toString();
sb.append(str);
sb.append(" : ");
sb.append(p.getProperty(str));
sb.append("\n");
}
return sb.toString();
}
return getProperty();
</bsh>
</textarea>
</filllayout>
</shell>
2.1.4. GlobalHook.bsh ¶SWT 내부 클래스를 이용한 윈도우 메시지 훅 예제입니다.
W2K 이상에서 동작하며, 실행하면 윈도상에서의 모든 키보드 입력을 확인할 수 있습니다.
import org.eclipse.swt.internal.Callback;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.internal.win32.MSG;
class GlobalHook {
static Shell s = new Shell(Display.getCurrent());
static Text t = new Text(s, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
static int hHook = 0;
Shell show(){
s.setText("GlobalHook");
s.setLayout(new FillLayout());
s.setSize(500, 500);
startHook();
return s;
}
static int getMsgProc(int code, int wParam, int lParam) {
MSG msg = new MSG();
OS.MoveMemory(msg, lParam, MSG.sizeof);
t.append(msg.message + "\n");
return OS.CallNextHookEx(hHook, code, wParam, lParam);
}
void startHook(){
Callback callback = new Callback(GlobalHook.class, "getMsgProc", 3);
int address = callback.getAddress();
int threadId = OS.GetCurrentThreadId();
hHook = OS.SetWindowsHookEx(13, address, OS.GetLibraryHandle(), 0);
if (hHook == 0) {
callback.dispose();
return;
}
}
}
new GlobalHook().show();
2.1.5. KLDP_Reader.bsh ¶ informa를 사용한 간단한 RssReader 예제.
JRE상에서 구동되는 Zeta/Pure에서는 다음과 같이 외부 패키지를 불러올 수 있습니다.
addClassPath("demo/informa_0.6.5.jar");
addClassPath("demo/commons-logging.jar");
addClassPath("demo/jdom.jar");
import de.nava.informa.core.ChannelIF;
import de.nava.informa.core.ItemIF;
import de.nava.informa.impl.basic.ChannelBuilder;
import de.nava.informa.parsers.FeedParser;
Shell s = new Shell(Display.getCurrent(), SWT.SHELL_TRIM | SWT.TOOL);
s.setText("KLDP Reader");
s.setLayout(new FillLayout(SWT.VERTICAL));
ChannelIF channel = FeedParser.parse(
new ChannelBuilder(), new URL("http://kldp.org/node/feed"));
Iterator i = channel.getItems().iterator();
Button btn;
while(i.hasNext()){
ItemIF item = (ItemIF)i.next();
btn = new Button(s, SWT.PUSH);
btn.setText(item.getTitle());
btn.addListener(SWT.Selection, new Listener(){
URL url = item.getLink();
public void handleEvent(Event event) {
Program.launch(url.toString());
}
});
}
s.pack();
s.open();
3. 스크린샷 ¶
|
To criticize the incompetent is easy; it is more difficult to criticize the competent. |











![[http]](/imgs/http.png)