1 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 33 public class ImportPage extends ImportExportPage { 34 private static final String STORE_SELECTED_IMPORT_WIZARD_ID = DIALOG_SETTING_SECTION_NAME 35 + "STORE_SELECTED_IMPORT_WIZARD_ID"; 37 private static final String STORE_EXPANDED_IMPORT_CATEGORIES = DIALOG_SETTING_SECTION_NAME 38 + "STORE_EXPANDED_IMPORT_CATEGORIES"; 40 protected CategorizedWizardSelectionTree importTree; 41 42 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 |