KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > dialogs > ImportPage


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 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.dialogs;
12
13 import org.eclipse.jface.viewers.DoubleClickEvent;
14 import org.eclipse.jface.viewers.IDoubleClickListener;
15 import org.eclipse.jface.viewers.ISelectionChangedListener;
16 import org.eclipse.jface.viewers.IStructuredSelection;
17 import org.eclipse.jface.viewers.SelectionChangedEvent;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.ui.IWorkbench;
20 import org.eclipse.ui.activities.ITriggerPoint;
21 import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
22 import org.eclipse.ui.internal.WorkbenchMessages;
23 import org.eclipse.ui.internal.WorkbenchPlugin;
24 import org.eclipse.ui.internal.activities.ws.WorkbenchTriggerPoints;
25 import org.eclipse.ui.wizards.IWizardCategory;
26
27 /**
28  * Wizard page class from which an import wizard is selected.
29  *
30  * @since 3.2
31  *
32  */

33 public class ImportPage extends ImportExportPage {
34     private static final String JavaDoc STORE_SELECTED_IMPORT_WIZARD_ID = DIALOG_SETTING_SECTION_NAME
35             + "STORE_SELECTED_IMPORT_WIZARD_ID"; //$NON-NLS-1$
36

37     private static final String JavaDoc STORE_EXPANDED_IMPORT_CATEGORIES = DIALOG_SETTING_SECTION_NAME
38             + "STORE_EXPANDED_IMPORT_CATEGORIES"; //$NON-NLS-1$
39

40     protected CategorizedWizardSelectionTree importTree;
41     
42     /**
43      * Constructor for import wizard selection page.
44      *
45      * @param aWorkbench
46      * @param currentSelection
47      */

48     public ImportPage(IWorkbench aWorkbench,
49             IStructuredSelection currentSelection) {
50         super(aWorkbench, currentSelection);
51     }
52
53     protected void initialize() {
54         workbench.getHelpSystem().setHelp(
55                 getControl(),
56                 IWorkbenchHelpContextIds.IMPORT_WIZARD_SELECTION_WIZARD_PAGE);
57     }
58
59     protected Composite createTreeViewer(Composite parent) {
60         IWizardCategory root = WorkbenchPlugin.getDefault()
61             .getImportWizardRegistry().getRootCategory();
62         importTree = new CategorizedWizardSelectionTree(
63                 root, WorkbenchMessages.ImportWizard_selectSource);
64         Composite importComp = importTree.createControl(parent);
65         importTree.getViewer().addSelectionChangedListener(new ISelectionChangedListener(){
66             public void selectionChanged(SelectionChangedEvent event) {
67                 listSelectionChanged(event.getSelection());
68             }
69         });
70         importTree.getViewer().addDoubleClickListener(new IDoubleClickListener(){
71             public void doubleClick(DoubleClickEvent event) {
72                 treeDoubleClicked(event);
73             }
74         });
75         setTreeViewer(importTree.getViewer());
76         return importComp;
77     }
78     
79     public void saveWidgetValues(){
80         storeExpandedCategories(STORE_EXPANDED_IMPORT_CATEGORIES, importTree.getViewer());
81         storeSelectedCategoryAndWizard(STORE_SELECTED_IMPORT_WIZARD_ID, importTree.getViewer());
82         super.saveWidgetValues();
83     }
84     
85     protected void restoreWidgetValues(){
86         IWizardCategory importRoot = WorkbenchPlugin.getDefault().getImportWizardRegistry().getRootCategory();
87         expandPreviouslyExpandedCategories(STORE_EXPANDED_IMPORT_CATEGORIES, importRoot,importTree.getViewer());
88         selectPreviouslySelected(STORE_SELECTED_IMPORT_WIZARD_ID, importRoot, importTree.getViewer());
89         super.restoreWidgetValues();
90     }
91
92     protected ITriggerPoint getTriggerPoint(){
93         return getWorkbench().getActivitySupport()
94             .getTriggerPointManager().getTriggerPoint(WorkbenchTriggerPoints.IMPORT_WIZARDS);
95     }
96     
97     protected void updateMessage(){
98         setMessage(WorkbenchMessages.ImportExportPage_chooseImportSource);
99         super.updateMessage();
100     }
101 }
102
Popular Tags