| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.seasar.uruma.rcp.ui; |
| 17 | |
|
| 18 | |
import java.util.List; |
| 19 | |
|
| 20 | |
import org.eclipse.ui.IPageLayout; |
| 21 | |
import org.eclipse.ui.IPerspectiveFactory; |
| 22 | |
import org.seasar.uruma.component.Template; |
| 23 | |
import org.seasar.uruma.component.rcp.ViewPartComponent; |
| 24 | |
import org.seasar.uruma.core.TemplateManager; |
| 25 | |
import org.seasar.uruma.rcp.UrumaService; |
| 26 | |
import org.seasar.uruma.rcp.util.UrumaServiceUtil; |
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
public class AutoPerspectiveFactory implements IPerspectiveFactory { |
| 34 | |
protected UrumaService service; |
| 35 | |
|
| 36 | |
protected TemplateManager templateManager; |
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | 0 | public AutoPerspectiveFactory() { |
| 42 | 0 | this.service = UrumaServiceUtil.getService(); |
| 43 | 0 | this.templateManager = (TemplateManager) service.getContainer() |
| 44 | |
.getComponent(TemplateManager.class); |
| 45 | 0 | } |
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
public void createInitialLayout(final IPageLayout layout) { |
| 51 | |
|
| 52 | 0 | layout.setEditorAreaVisible(false); |
| 53 | |
|
| 54 | 0 | List<Template> templates = templateManager |
| 55 | |
.getTemplates(ViewPartComponent.class); |
| 56 | |
|
| 57 | 0 | int size = templates.size(); |
| 58 | 0 | for (int i = 0; i < size; i++) { |
| 59 | 0 | Template template = templates.get(i); |
| 60 | 0 | ViewPartComponent viewPart = (ViewPartComponent) template |
| 61 | |
.getRootComponent(); |
| 62 | |
|
| 63 | |
|
| 64 | 0 | float ratio = (1 / (float) (size - i)); |
| 65 | 0 | int position = IPageLayout.LEFT; |
| 66 | 0 | if (i == (templates.size() - 1)) { |
| 67 | 0 | position = IPageLayout.RIGHT; |
| 68 | |
} |
| 69 | |
|
| 70 | 0 | layout.addStandaloneView(service.createRcpId(viewPart.getId()), |
| 71 | |
true, position, ratio, layout.getEditorArea()); |
| 72 | |
} |
| 73 | 0 | } |
| 74 | |
} |