📄 uiswtinstanceimpl.java
字号:
try {
uiFunctions.addPluginView(view);
if (bAutoOpen) {
uiFunctions.openPluginView(view);
}
} catch (Throwable e) {
// SWT not available prolly
}
}
public void removeView(UISWTPluginView view) {
try {
uiFunctions.removePluginView(view);
} catch (Throwable e) {
// SWT not available prolly
}
}
public void
addView(
final UISWTAWTPluginView view,
boolean auto_open )
{
UISWTPluginView v =
new UISWTPluginView()
{
Composite composite;
Component component;
boolean first_paint = true;
public String
getPluginViewName()
{
return( view.getPluginViewName());
}
public String
getFullTitle()
{
return( view.getPluginViewName());
}
public void
initialize(
Composite _composite )
{
first_paint = true;
composite = _composite;
Composite frame_composite = new Composite(composite, SWT.EMBEDDED);
GridData data = new GridData(GridData.FILL_BOTH);
frame_composite.setLayoutData(data);
Frame f = SWT_AWT.new_Frame(frame_composite);
BorderLayout layout =
new BorderLayout()
{
public void
layoutContainer(Container parent)
{
try{
super.layoutContainer( parent );
}finally{
if ( first_paint ){
first_paint = false;
view.open( component );
}
}
}
};
Panel pan = new Panel( layout );
f.add( pan );
component = view.create();
pan.add( component, BorderLayout.CENTER );
}
public Composite
getComposite()
{
return( composite );
}
public void
delete()
{
super.delete();
view.delete( component );
}
};
awt_view_map.put( view, v );
addView( v, auto_open );
}
public void
removeView(
UISWTAWTPluginView view )
{
UISWTPluginView v = (UISWTPluginView)awt_view_map.remove(view );
if ( v != null ){
removeView( v );
}
}
public void
detach()
throws UIException
{
throw( new UIException( "not supported" ));
}
public void addView(String sParentID, final String sViewID,
final UISWTViewEventListener l) {
Map subViews = (Map) views.get(sParentID);
if (subViews == null) {
subViews = new HashMap();
views.put(sParentID, subViews);
}
subViews.put(sViewID, l);
if (sParentID.equals(UISWTInstance.VIEW_MAIN)) {
Utils.execSWTThread(new AERunnable() {
public void runSupport() {
try {
uiFunctions.addPluginView(sViewID, l);
} catch (Throwable e) {
// SWT not available prolly
}
}
});
}
}
// TODO: Remove views from PeersView, etc
public void removeViews(String sParentID, final String sViewID) {
Map subViews = (Map) views.get(sParentID);
if (subViews == null)
return;
if (sParentID.equals(UISWTInstance.VIEW_MAIN)) {
Utils.execSWTThread(new AERunnable() {
public void runSupport() {
try {
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null) {
uiFunctions.removePluginView(sViewID);
}
} catch (Throwable e) {
// SWT not available prolly
}
}
});
}
subViews.remove(sViewID);
}
public boolean openView(final String sParentID, final String sViewID,
final Object dataSource) {
Map subViews = (Map) views.get(sParentID);
if (subViews == null) {
return false;
}
final UISWTViewEventListener l = (UISWTViewEventListener) subViews.get(sViewID);
if (l == null) {
return false;
}
Utils.execSWTThread(new AERunnable() {
public void runSupport() {
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null) {
uiFunctions.openPluginView(sParentID, sViewID, l, dataSource,
!bUIAttaching);
}
}
});
return true;
}
public void openMainView(final String sViewID,
final UISWTViewEventListener l, final Object dataSource) {
Utils.execSWTThread(new AERunnable() {
public void runSupport() {
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null) {
uiFunctions.openPluginView(UISWTInstance.VIEW_MAIN, sViewID, l, dataSource, !bUIAttaching);
}
}
});
}
public UISWTView[] getOpenViews(String sParentID) {
if (sParentID.equals(UISWTInstance.VIEW_MAIN)) {
try {
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null) {
return uiFunctions.getPluginViews();
}
} catch (Throwable e) {
// SWT not available prolly
}
}
return new UISWTView[0];
}
public int promptUser(String title, String text, String[] options,
int defaultOption) {
return MessageBoxShell.open(uiFunctions.getMainShell(), title, text,
options, defaultOption);
}
// Core Functions
// ==============
public Map getViewListeners(String sParentID) {
return (Map)views.get(sParentID);
}
public UIInputReceiver getInputReceiver() {
return new SimpleTextEntryWindow(getDisplay());
}
protected static class
instanceWrapper
implements UISWTInstance
{
private PluginInterface pi;
private UISWTInstanceImpl delegate;
protected
instanceWrapper(
PluginInterface _pi,
UISWTInstanceImpl _delegate )
{
pi = _pi;
delegate = _delegate;
}
public void
detach()
throws UIException
{
delegate.detach();
}
public Display
getDisplay()
{
return( delegate.getDisplay());
}
public Image
loadImage(
String resource )
{
return( delegate.loadImage( pi, resource ));
}
public UISWTGraphic
createGraphic(
Image img )
{
return( delegate.createGraphic( img ));
}
public void
addView(String sParentID, String sViewID, UISWTViewEventListener l)
{
delegate.addView( sParentID, sViewID, l );
}
public void
openMainView(String sViewID, UISWTViewEventListener l,Object dataSource)
{
delegate.openMainView( sViewID, l, dataSource );
}
public void
removeViews(String sParentID, String sViewID)
{
delegate.removeViews(sParentID, sViewID );
}
public UISWTView[]
getOpenViews(String sParentID)
{
return( delegate.getOpenViews(sParentID));
}
public void
addView(UISWTPluginView view, boolean autoOpen)
{
delegate.addView( view, autoOpen );
}
public void
removeView(UISWTPluginView view)
{
delegate.removeView( view );
}
public void
addView(UISWTAWTPluginView view, boolean auto_open)
{
delegate.addView( view, auto_open );
}
public void
removeView(UISWTAWTPluginView view)
{
delegate.removeView( view );
}
public int promptUser(String title, String text, String[] options,
int defaultOption) {
return delegate.promptUser(title, text, options, defaultOption);
}
public boolean openView(String sParentID, String sViewID, Object dataSource) {
return delegate.openView(sParentID, sViewID, dataSource);
}
public UIInputReceiver getInputReceiver() {
return delegate.getInputReceiver();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -