KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > part > services > DefaultCompositeFactory


1 /*******************************************************************************
2  * Copyright (c) 2004, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.part.services;
12
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.layout.FillLayout;
15 import org.eclipse.swt.widgets.Composite;
16 import org.eclipse.swt.widgets.Display;
17 import org.eclipse.swt.widgets.Shell;
18 import org.eclipse.ui.internal.components.framework.ComponentFactory;
19 import org.eclipse.ui.internal.components.framework.ComponentHandle;
20 import org.eclipse.ui.internal.components.framework.IDisposable;
21 import org.eclipse.ui.internal.components.framework.IServiceProvider;
22
23 /**
24  * @since 3.1
25  */

26 public class DefaultCompositeFactory extends ComponentFactory {
27
28     private final static class CompositeHandle extends ComponentHandle implements IDisposable {
29         
30         public CompositeHandle(Composite toWrap) {
31             super(toWrap);
32         }
33         
34         public IDisposable getDisposable() {
35             return this;
36         }
37         
38         public void dispose() {
39             ((Composite)getInstance()).dispose();
40         }
41
42     };
43     
44     /* (non-Javadoc)
45      * @see org.eclipse.core.component.ComponentAdapter#createInstance(org.eclipse.core.component.IContainer)
46      */

47     public ComponentHandle createHandle(IServiceProvider availableServices) {
48         Shell result = new Shell(Display.getCurrent(), SWT.NONE);
49         result.setLayout(new FillLayout());
50         result.open();
51         return new CompositeHandle(result);
52     }
53
54 }
55
Popular Tags