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 export wizard is selected.
028: *
029: * @since 3.2
030: *
031: */
032: public class ExportPage extends ImportExportPage {
033: private static final String STORE_SELECTED_EXPORT_WIZARD_ID = DIALOG_SETTING_SECTION_NAME
034: + "STORE_SELECTED_EXPORT_WIZARD_ID"; //$NON-NLS-1$
035:
036: private static final String STORE_EXPANDED_EXPORT_CATEGORIES = DIALOG_SETTING_SECTION_NAME
037: + "STORE_EXPANDED_EXPORT_CATEGORIES"; //$NON-NLS-1$
038:
039: CategorizedWizardSelectionTree exportTree;
040:
041: /**
042: * Constructor for export wizard selection page.
043: *
044: * @param aWorkbench
045: * @param currentSelection
046: */
047: public ExportPage(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.EXPORT_WIZARD_SELECTION_WIZARD_PAGE);
058: }
059:
060: protected Composite createTreeViewer(Composite parent) {
061: IWizardCategory root = WorkbenchPlugin.getDefault()
062: .getExportWizardRegistry().getRootCategory();
063: exportTree = new CategorizedWizardSelectionTree(root,
064: WorkbenchMessages.ExportWizard_selectDestination);
065: Composite exportComp = exportTree.createControl(parent);
066: exportTree.getViewer().addSelectionChangedListener(
067: new ISelectionChangedListener() {
068: public void selectionChanged(
069: SelectionChangedEvent event) {
070: listSelectionChanged(event.getSelection());
071: }
072: });
073: exportTree.getViewer().addDoubleClickListener(
074: new IDoubleClickListener() {
075: public void doubleClick(DoubleClickEvent event) {
076: treeDoubleClicked(event);
077: }
078: });
079: setTreeViewer(exportTree.getViewer());
080: return exportComp;
081: }
082:
083: public void saveWidgetValues() {
084: storeExpandedCategories(STORE_EXPANDED_EXPORT_CATEGORIES,
085: exportTree.getViewer());
086: storeSelectedCategoryAndWizard(STORE_SELECTED_EXPORT_WIZARD_ID,
087: exportTree.getViewer());
088: super .saveWidgetValues();
089: }
090:
091: protected void restoreWidgetValues() {
092: IWizardCategory exportRoot = WorkbenchPlugin.getDefault()
093: .getExportWizardRegistry().getRootCategory();
094: expandPreviouslyExpandedCategories(
095: STORE_EXPANDED_EXPORT_CATEGORIES, exportRoot,
096: exportTree.getViewer());
097: selectPreviouslySelected(STORE_SELECTED_EXPORT_WIZARD_ID,
098: exportRoot, exportTree.getViewer());
099: super .restoreWidgetValues();
100: }
101:
102: protected ITriggerPoint getTriggerPoint() {
103: return getWorkbench().getActivitySupport()
104: .getTriggerPointManager().getTriggerPoint(
105: WorkbenchTriggerPoints.EXPORT_WIZARDS);
106: }
107:
108: protected void updateMessage() {
109: setMessage(WorkbenchMessages.ImportExportPage_chooseExportDestination);
110: super.updateMessage();
111: }
112: }
|