diff -r 000000000000 -r ddc9cde0ba07 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/importWizards/ImportWizardPage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/importWizards/ImportWizardPage.java Wed Dec 23 16:09:48 2009 -0800 @@ -0,0 +1,119 @@ +/** + * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the License "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Symbian Foundation - initial contribution. + * Contributors: + * Description: + * Overview: + * Details: + * Platforms/Drives/Compatibility: + * Assumptions/Requirement/Pre-requisites: + * Failures and causes: + */ +package org.symbian.tools.wrttools.importWizards; +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.preference.FileFieldEditor; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.dialogs.WizardNewFileCreationPage; + + +public class ImportWizardPage extends WizardNewFileCreationPage { + + protected FileFieldEditor editor; + + public ImportWizardPage(String pageName, IStructuredSelection selection) { + super(pageName, selection); + setTitle(pageName); //NON-NLS-1 + setDescription("Import a file from the local file system into the workspace"); //NON-NLS-1 + } + + /* (non-Javadoc) + * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#createAdvancedControls(org.eclipse.swt.widgets.Composite) + */ + protected void createAdvancedControls(Composite parent) { + Composite fileSelectionArea = new Composite(parent, SWT.NONE); + GridData fileSelectionData = new GridData(GridData.GRAB_HORIZONTAL + | GridData.FILL_HORIZONTAL); + fileSelectionArea.setLayoutData(fileSelectionData); + + GridLayout fileSelectionLayout = new GridLayout(); + fileSelectionLayout.numColumns = 3; + fileSelectionLayout.makeColumnsEqualWidth = false; + fileSelectionLayout.marginWidth = 0; + fileSelectionLayout.marginHeight = 0; + fileSelectionArea.setLayout(fileSelectionLayout); + + editor = new FileFieldEditor("fileSelect","Select File: ",fileSelectionArea); //NON-NLS-1 //NON-NLS-2 + editor.getTextControl(fileSelectionArea).addModifyListener(new ModifyListener(){ + public void modifyText(ModifyEvent e) { + IPath path = new Path(ImportWizardPage.this.editor.getStringValue()); + setFileName(path.lastSegment()); + } + }); + String[] extensions = new String[] { "*.*" }; //NON-NLS-1 + editor.setFileExtensions(extensions); + fileSelectionArea.moveAbove(null); + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#createLinkTarget() + */ + protected void createLinkTarget() { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#getInitialContents() + */ + protected InputStream getInitialContents() { + try { + return new FileInputStream(new File(editor.getStringValue())); + } catch (FileNotFoundException e) { + return null; + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#getNewFileLabel() + */ + protected String getNewFileLabel() { + return "New File Name:"; //NON-NLS-1 + } + + /* (non-Javadoc) + * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#validateLinkedResource() + */ + protected IStatus validateLinkedResource() { + return new Status(IStatus.OK, "org.symbian.tools.wrt", IStatus.OK, "", null); //NON-NLS-1 //NON-NLS-2 + } +}