📄 shelldocker.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: ShellDocker.java
package org.gudy.azureus2.ui.swt.shells;
import com.aelitis.azureus.ui.swt.UIFunctionsManagerSWT;
import com.aelitis.azureus.ui.swt.UIFunctionsSWT;
import java.io.PrintStream;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.ui.swt.Utils;
// Referenced classes of package org.gudy.azureus2.ui.swt.shells:
// DockPosition, Offset
public class ShellDocker
{
private DockPosition anchorControlPosition;
private boolean isDocked;
private boolean moveWithShell;
private boolean resizeWithShell;
private Listener dockingEnabler;
private Control anchorControl;
private Shell dockedShell;
private Shell mainShell;
public ShellDocker(Control anchorControl, Shell dockedShell)
{
anchorControlPosition = new DockPosition();
isDocked = true;
moveWithShell = true;
resizeWithShell = false;
dockingEnabler = null;
this.anchorControl = null;
this.dockedShell = null;
mainShell = null;
if (null == anchorControl || anchorControl.isDisposed())
throw new NullPointerException("anchorControl cannot be null or disposed");
if (null == dockedShell || dockedShell.isDisposed())
{
throw new NullPointerException("dockedShell cannot be null or disposed");
} else
{
this.anchorControl = anchorControl;
this.dockedShell = dockedShell;
mainShell = anchorControl.getShell();
return;
}
}
public void openShell()
{
openShell(isDocked(), false);
}
public void openShell(boolean isDocked)
{
openShell(isDocked, false);
}
public void openShell(boolean isDocked, boolean isAnimated)
{
setDocked(isDocked);
if (!isDocked)
{
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (null == uiFunctions)
Utils.centreWindow(dockedShell);
else
Utils.centerWindowRelativeTo(dockedShell, uiFunctions.getMainShell());
}
if (!isAnimated)
dockedShell.open();
else
dockedShell.open();
}
public boolean isDocked()
{
return isDocked;
}
public void setDocked(boolean isDocked)
{
this.isDocked = isDocked;
if (isDocked)
{
performDocking();
if (null == dockingEnabler)
dockingEnabler = new Listener() {
final ShellDocker this$0;
public void handleEvent(Event event)
{
if (event.type == 11)
{
if (isResizeWithShell())
System.out.println("resizing");
else
performDocking();
} else
if (event.type == 10)
performDocking();
}
{
this$0 = ShellDocker.this;
super();
}
};
if (null != mainShell && !mainShell.isDisposed())
{
if (isMoveWithShell())
mainShell.addListener(10, dockingEnabler);
if (isResizeWithShell())
mainShell.addListener(11, dockingEnabler);
anchorControl.addListener(10, dockingEnabler);
anchorControl.addListener(11, dockingEnabler);
}
anchorControl.addDisposeListener(new DisposeListener() {
final ShellDocker this$0;
public void widgetDisposed(DisposeEvent e)
{
setDocked(false);
}
{
this$0 = ShellDocker.this;
super();
}
});
dockedShell.addListener(21, new Listener() {
final ShellDocker this$0;
public void handleEvent(Event e)
{
setDocked(false);
}
{
this$0 = ShellDocker.this;
super();
}
});
} else
{
if (null != mainShell && !mainShell.isDisposed() && null != dockingEnabler)
{
mainShell.removeListener(10, dockingEnabler);
mainShell.removeListener(11, dockingEnabler);
}
if (null != anchorControl && !anchorControl.isDisposed() && null != dockingEnabler)
{
anchorControl.removeListener(10, dockingEnabler);
anchorControl.removeListener(11, dockingEnabler);
}
}
}
private void performDocking()
{
if (isAlive())
switch (anchorControlPosition.getPosition())
{
case 1: // '\001'
{
dockedShell.setLocation(mainShell.toDisplay(anchorControl.getLocation()));
break;
}
case 2: // '\002'
{
Point p = mainShell.toDisplay(anchorControl.getLocation());
p.x += anchorControlPosition.getOffset().xOffset;
p.y += anchorControlPosition.getOffset().yOffset;
p.y += anchorControl.getSize().y;
dockedShell.setLocation(p);
break;
}
case 4: // '\004'
{
Point p = mainShell.toDisplay(anchorControl.getLocation());
p.x += anchorControlPosition.getOffset().xOffset;
p.y += anchorControlPosition.getOffset().yOffset;
p.x += anchorControl.getSize().x;
p.y += anchorControl.getSize().y;
dockedShell.setLocation(p);
break;
}
}
}
private boolean isAlive()
{
if (null == mainShell || mainShell.isDisposed())
{
System.err.println("\tmainshell is disposed?");
return false;
}
if (null == dockedShell || dockedShell.isDisposed())
{
System.err.println("\tdockedShell is disposed?");
return false;
}
if (null == anchorControl || anchorControl.isDisposed())
{
System.err.println("\tanchorControl is disposed?");
return false;
} else
{
return true;
}
}
public boolean isMoveWithShell()
{
return moveWithShell;
}
public void setMoveWithShell(boolean moveWithShell)
{
this.moveWithShell = moveWithShell;
}
public boolean isResizeWithShell()
{
return resizeWithShell;
}
public void setResizeWithShell(boolean resizeWithShell)
{
this.resizeWithShell = resizeWithShell;
}
public DockPosition getAnchorControlPosition()
{
return anchorControlPosition;
}
public void setAnchorControlPosition(DockPosition anchorControlPosition)
{
this.anchorControlPosition = anchorControlPosition;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -