2
* Created on 2004/May/14
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
package org.gudy.azureus2.pluginsimpl.local.ui.SWT;
19
import org.eclipse.swt.graphics.Image;
20
import org.eclipse.swt.widgets.Display;
22
import org.gudy.azureus2.core3.util.AEMonitor;
23
import org.gudy.azureus2.ui.swt.mainwindow.SWTThread;
24
import org.gudy.azureus2.ui.swt.plugins.UISWTInstance;
26
import com.aelitis.azureus.core.AzureusCoreFactory;
27
import com.aelitis.azureus.ui.UIFunctions;
28
import com.aelitis.azureus.ui.UIFunctionsManager;
29
import com.aelitis.azureus.ui.swt.UIFunctionsSWT;
31
import org.gudy.azureus2.plugins.PluginView;
32
import org.gudy.azureus2.plugins.ui.UIInstance;
33
import org.gudy.azureus2.plugins.ui.UIManager;
34
import org.gudy.azureus2.plugins.ui.UIManagerListener;
35
import org.gudy.azureus2.plugins.ui.SWT.GraphicSWT;
36
import org.gudy.azureus2.plugins.ui.SWT.SWTManager;
37
import org.gudy.azureus2.plugins.ui.model.PluginViewModel;
43
public class SWTManagerImpl
46
protected static SWTManagerImpl singleton;
48
private static AEMonitor class_mon = new AEMonitor( "SWTManager" );
50
public static SWTManagerImpl getSingleton() {
54
if (singleton == null)
55
singleton = new SWTManagerImpl();
63
public Display getDisplay() {
64
SWTThread instance = SWTThread.getInstance();
67
return instance.getDisplay();
70
public GraphicSWT createGraphic(Image img) {
71
return new GraphicSWTImpl(img);
75
public void addView(final PluginView view, final boolean bAutoOpen) {
77
UIManager ui_manager = AzureusCoreFactory.getSingleton().getPluginManager().getDefaultPluginInterface().getUIManager();
79
ui_manager.addUIListener(new UIManagerListener() {
80
public void UIAttached(UIInstance instance) {
81
if (instance instanceof UISWTInstance) {
82
if (view instanceof PluginViewWrapper) {
84
// legacy support for RSSImport plugin
85
// model already registered, no need to do anything as UI will pick it up
88
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
89
if (uiFunctions instanceof UIFunctionsSWT) {
90
((UIFunctionsSWT)uiFunctions).addPluginView(view);
93
((UIFunctionsSWT)uiFunctions).openPluginView(view);
100
public void UIDetached(UIInstance instance) {
104
} catch (Throwable e) {
105
// SWT not available prolly
113
addView(view, false);
118
PluginViewModel model )
120
return( new PluginViewWrapper(model));
128
private PluginViewModel model;
132
PluginViewModel _model )
140
return( model.getName());
145
* Not working due to class loader being different between plugins and
148
public boolean loadImage(String resource,String name) {
150
ImageRepository.loadImage(getDisplay(),resource,name);
152
} catch(Exception e) {
158
public Image getImage(String name) {
159
return ImageRepository.getImage(name);
2
* Created on 2004/May/14
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
package org.gudy.azureus2.pluginsimpl.local.ui.SWT;
19
import org.eclipse.swt.graphics.Image;
20
import org.eclipse.swt.widgets.Display;
22
import org.gudy.azureus2.core3.util.AEMonitor;
23
import org.gudy.azureus2.ui.swt.mainwindow.SWTThread;
24
import org.gudy.azureus2.ui.swt.plugins.UISWTInstance;
26
import com.aelitis.azureus.core.AzureusCoreFactory;
27
import com.aelitis.azureus.ui.UIFunctions;
28
import com.aelitis.azureus.ui.UIFunctionsManager;
29
import com.aelitis.azureus.ui.swt.UIFunctionsSWT;
31
import org.gudy.azureus2.plugins.PluginView;
32
import org.gudy.azureus2.plugins.ui.UIInstance;
33
import org.gudy.azureus2.plugins.ui.UIManager;
34
import org.gudy.azureus2.plugins.ui.UIManagerListener;
35
import org.gudy.azureus2.plugins.ui.SWT.GraphicSWT;
36
import org.gudy.azureus2.plugins.ui.SWT.SWTManager;
37
import org.gudy.azureus2.plugins.ui.model.PluginViewModel;
43
public class SWTManagerImpl
46
protected static SWTManagerImpl singleton;
48
private static AEMonitor class_mon = new AEMonitor( "SWTManager" );
50
public static SWTManagerImpl getSingleton() {
54
if (singleton == null)
55
singleton = new SWTManagerImpl();
63
public Display getDisplay() {
64
SWTThread instance = SWTThread.getInstance();
67
return instance.getDisplay();
70
public GraphicSWT createGraphic(Image img) {
71
return new GraphicSWTImpl(img);
75
public void addView(final PluginView view, final boolean bAutoOpen) {
77
UIManager ui_manager = AzureusCoreFactory.getSingleton().getPluginManager().getDefaultPluginInterface().getUIManager();
79
ui_manager.addUIListener(new UIManagerListener() {
80
public void UIAttached(UIInstance instance) {
81
if (instance instanceof UISWTInstance) {
82
if (view instanceof PluginViewWrapper) {
84
// legacy support for RSSImport plugin
85
// model already registered, no need to do anything as UI will pick it up
88
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
89
if (uiFunctions instanceof UIFunctionsSWT) {
90
((UIFunctionsSWT)uiFunctions).addPluginView(view);
93
((UIFunctionsSWT)uiFunctions).openPluginView(view);
100
public void UIDetached(UIInstance instance) {
104
} catch (Throwable e) {
105
// SWT not available prolly
113
addView(view, false);
118
PluginViewModel model )
120
return( new PluginViewWrapper(model));
128
private PluginViewModel model;
132
PluginViewModel _model )
140
return( model.getName());
145
* Not working due to class loader being different between plugins and
148
public boolean loadImage(String resource,String name) {
150
ImageRepository.loadImage(getDisplay(),resource,name);
152
} catch(Exception e) {
158
public Image getImage(String name) {
159
return ImageRepository.getImage(name);