/*
* Created on 2004/08/03 Author aki@www.xucker.jpn.org License Apache2.0 or
* Common Public License
*/
package org.jpn.xucker.optipngwrapper;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
public class ResultDialog implements SelectionListener {
/**
* @param shell
*
*/
private Table table1;
private Button button1;
Shell shell;
public ResultDialog(Shell shell) {
this.shell = shell;
shell.setText("optipng実行結果");
shell.setBounds(0, 0, 300, 300);
RowLayout layout = new RowLayout();
shell.setLayout(layout);
table1 = new Table(shell, SWT.FULL_SELECTION);
table1.setHeaderVisible(true);
table1.addSelectionListener(this);
RowData table1_data = new RowData();
table1_data.width=270;
table1_data.height=220;
table1.setLayoutData(table1_data);
TableColumn table1_column = new TableColumn(table1, SWT.NULL);
table1_column.setText("ファイル名");
table1_column.setWidth(85);
TableColumn table1_column2 = new TableColumn(table1, SWT.NULL);
table1_column2.setText("減小%");
table1_column2.setWidth(50);
TableColumn table1_column3 = new TableColumn(table1, SWT.NULL);
table1_column3.setText("減小byte");
table1_column3.setWidth(65);
TableColumn table1_column4 = new TableColumn(table1, SWT.NULL);
table1_column4.setText("ディレクトリー");
table1_column4.setWidth(80);
button1 = new Button(shell, SWT.NULL);
button1.setText("閉じる");
button1.addSelectionListener(this);
RowData button1_data = new RowData();
button1.setLayoutData(button1_data);
}
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
ResultDialog main = new ResultDialog(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
public void widgetSelected(SelectionEvent event) {
Object target = event.getSource();
if (target == null) {
//maybe not happen.
System.out.println("target==null");
}
//null1
else if (target == table1) {
do_table1();
}
// null1
else if (target == button1) {
do_button1();
}
}
public void widgetDefaultSelected(SelectionEvent arg0) {
// TODO Auto-generated method stub
}
//null1
public void do_table1() {
//System.out.println("table1");
}
// null1
public void do_button1() {
shell.close();
}
/**
* @param data
*/
public void setResultData(ResultData[] data) {
//
for (int i = 0; i < data.length; i++) {
String values[]=new String[4];
values[0]=data[i].getFile();
values[1]=""+data[i].getPercent()+"%";
values[2]=""+data[i].getBytes();
values[3]=data[i].getDirectory();
TableItem item=new TableItem(table1,SWT.NULL);
item.setText(values);
}
//
}
}
|