001: /*******************************************************************************
002: * Copyright (c) 2005, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.internal.dialogs;
011:
012: import org.eclipse.jface.viewers.DoubleClickEvent;
013: import org.eclipse.jface.viewers.IDoubleClickListener;
014: import org.eclipse.jface.viewers.ISelectionChangedListener;
015: import org.eclipse.jface.viewers.IStructuredSelection;
016: import org.eclipse.jface.viewers.SelectionChangedEvent;
017: import org.eclipse.swt.widgets.Composite;
018: import org.eclipse.ui.IWorkbench;
019: import org.eclipse.ui.activities.ITriggerPoint;
020: import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
021: import org.eclipse.ui.internal.WorkbenchMessages;
022: import org.eclipse.ui.internal.WorkbenchPlugin;
023: import org.eclipse.ui.internal.activities.ws.WorkbenchTriggerPoints;
024: import org.eclipse.ui.wizards.IWizardCategory;
025:
026: /**
027: * Wizard page class from which an import wizard is selected.
028: *
029: * @since 3.2
030: *
031: */
032: public class ImportPage extends ImportExportPage {
033: private static final String STORE_SELECTED_IMPORT_WIZARD_ID = DIALOG_SETTING_SECTION_NAME
034: + "STORE_SELECTED_IMPORT_WIZARD_ID"; //$NON-NLS-1$
035:
036: private static final String STORE_EXPANDED_IMPORT_CATEGORIES = DIALOG_SETTING_SECTION_NAME
037: + "STORE_EXPANDED_IMPORT_CATEGORIES"; //$NON-NLS-1$
038:
039: protected CategorizedWizardSelectionTree importTree;
040:
041: /**
042: * Constructor for import wizard selection page.
043: *
044: * @param aWorkbench
045: * @param currentSelection
046: */
047: public ImportPage(IWorkbench aWorkbench,
048: IStructuredSelection currentSelection) {
049: super (aWorkbench, currentSelection);
050: }
051:
052: protected void initialize() {
053: workbench
054: .getHelpSystem()
055: .setHelp(
056: getControl(),
057: IWorkbenchHelpContextIds.IMPORT_WIZARD_SELECTION_WIZARD_PAGE);
058: }
059:
060: protected Composite createTreeViewer(Composite parent) {
061: IWizardCategory root = WorkbenchPlugin.getDefault()
062: .getImportWizardRegistry().getRootCategory();
063: importTree = new CategorizedWizardSelectionTree(root,
064: WorkbenchMessages.ImportWizard_selectSource);
065: Composite importComp = importTree.createControl(parent);
066: importTree.getViewer().addSelectionChangedListener(
067: new ISelectionChangedListener() {
068: public void selectionChanged(
069: SelectionChangedEvent event) {
070: listSelectionChanged(event.getSelection());
071: }
072: });
073: importTree.getViewer().addDoubleClickListener(
074: new IDoubleClickListener() {
075: public void doubleClick(DoubleClickEvent event) {
076: treeDoubleClicked(event);
077: }
078: });
079: setTreeViewer(importTree.getViewer());
080: return importComp;
081: }
082:
083: public void saveWidgetValues() {
084: storeExpandedCategories(STORE_EXPANDED_IMPORT_CATEGORIES,
085: importTree.getViewer());
086: storeSelectedCategoryAndWizard(STORE_SELECTED_IMPORT_WIZARD_ID,
087: importTree.getViewer());
088: super .saveWidgetValues();
089: }
090:
091: protected void restoreWidgetValues() {
092: IWizardCategory importRoot = WorkbenchPlugin.getDefault()
093: .getImportWizardRegistry().getRootCategory();
094: expandPreviouslyExpandedCategories(
095: STORE_EXPANDED_IMPORT_CATEGORIES, importRoot,
096: importTree.getViewer());
097: selectPreviouslySelected(STORE_SELECTED_IMPORT_WIZARD_ID,
098: importRoot, importTree.getViewer());
099: super .restoreWidgetValues();
100: }
101:
102: protected ITriggerPoint getTriggerPoint() {
103: return getWorkbench().getActivitySupport()
104: .getTriggerPointManager().getTriggerPoint(
105: WorkbenchTriggerPoints.IMPORT_WIZARDS);
106: }
107:
108: protected void updateMessage() {
109: setMessage(WorkbenchMessages.ImportExportPage_chooseImportSource);
110: super.updateMessage();
111: }
112: }
|