📄 main.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: Main.java
package org.gudy.azureus2.ui.swt.test;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
public class Main
{
private Color blue;
private Table table;
private boolean mousePressed;
private TableItem selectedItem;
Rectangle oldBounds;
Image oldImage;
public Main()
{
final Display display = new Display();
blue = new Color(display, 0, 0, 128);
final Shell shell = new Shell(display);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
shell.setLayout(layout);
table = new Table(shell, 0x10804);
GridData gridData = new GridData(1808);
gridData.horizontalSpan = 3;
table.setLayoutData(gridData);
table.setLinesVisible(true);
Font f = table.getFont();
FontData fd = f.getFontData()[0];
fd.setHeight(9);
Font font = new Font(display, fd);
table.setFont(font);
Button bOk = new Button(shell, 8);
bOk.setText("Ok");
gridData = new GridData(896);
gridData.grabExcessHorizontalSpace = true;
gridData.widthHint = 70;
bOk.setLayoutData(gridData);
Button bCancel = new Button(shell, 8);
bCancel.setText("Cancel");
gridData = new GridData(128);
gridData.grabExcessHorizontalSpace = false;
gridData.widthHint = 70;
bCancel.setLayoutData(gridData);
Button bApply = new Button(shell, 8);
bApply.setText("Apply");
gridData = new GridData(128);
gridData.grabExcessHorizontalSpace = false;
gridData.widthHint = 70;
bApply.setLayoutData(gridData);
for (int i = 0; i < 2; i++)
new TableColumn(table, 0);
for (int i = 0; i < 12; i++)
createTableRow(-1, (new StringBuilder()).append("Toto").append(i).toString(), false);
TableItem item = new TableItem(table, 0);
item.setText(1, "---");
table.getColumn(0).setWidth(20);
table.getColumn(1).setWidth(200);
table.addMouseListener(new MouseAdapter() {
final Shell val$shell;
final Main this$0;
public void mouseDown(MouseEvent arg0)
{
mousePressed = true;
selectedItem = table.getItem(new Point(arg0.x, arg0.y));
if (selectedItem.getText(1).equals("---"))
selectedItem = null;
}
public void mouseUp(MouseEvent e)
{
mousePressed = false;
if (oldBounds != null && oldImage != null)
{
GC gc = new GC(table);
gc.drawImage(oldImage, oldBounds.x, oldBounds.y);
oldImage.dispose();
oldImage = null;
oldBounds = null;
}
Point p = new Point(e.x, e.y);
TableItem item = table.getItem(p);
if (item != null && selectedItem != null)
{
int index = table.indexOf(item);
int oldIndex = table.indexOf(selectedItem);
if (index == oldIndex)
return;
String name = (String)selectedItem.getData("name");
Button oldBtn = (Button)selectedItem.getData("button");
boolean selected = oldBtn.getSelection();
oldBtn.dispose();
createTableRow(index, name, selected);
selectedItem.dispose();
Point size = shell.getSize();
shell.setSize(size.x + 1, size.y + 1);
shell.setSize(size);
}
}
{
this$0 = Main.this;
shell = shell1;
MouseAdapter();
}
});
table.addMouseMoveListener(new MouseMoveListener() {
final Display val$display;
final Main this$0;
public void mouseMove(MouseEvent e)
{
if (mousePressed && selectedItem != null)
{
Point p = new Point(e.x, e.y);
TableItem item = table.getItem(p);
if (item != null)
{
GC gc = new GC(table);
Rectangle bounds = item.getBounds(1);
if (oldBounds != null && oldImage != null)
{
gc.drawImage(oldImage, oldBounds.x, oldBounds.y);
oldImage.dispose();
oldImage = null;
oldBounds = null;
}
oldImage = new Image(display, bounds.width, 2);
gc.copyArea(oldImage, bounds.x, bounds.y);
oldBounds = bounds;
gc.setBackground(blue);
gc.fillRectangle(bounds.x, bounds.y, bounds.width, 2);
}
}
}
{
this$0 = Main.this;
display = display1;
Object();
}
});
shell.pack();
shell.open();
do
{
if (shell.isDisposed())
break;
if (!display.readAndDispatch())
display.sleep();
} while (true);
display.dispose();
if (font != null && !font.isDisposed())
font.dispose();
}
private void createTableRow(int index, String name, boolean selected)
{
TableItem item;
if (index == -1)
item = new TableItem(table, 0);
else
item = new TableItem(table, 0, index);
item.setText(1, name);
item.setData("name", name);
TableEditor editor = new TableEditor(table);
Button button = new Button(table, 32);
button.setSelection(selected);
button.pack();
editor.minimumWidth = button.getSize().x;
editor.horizontalAlignment = 0x1000000;
editor.setEditor(button, item, 0);
item.setData("button", button);
}
public static void main(String args[])
{
new Main();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -