Skip to main content
summaryrefslogtreecommitdiffstats
blob: 235f0130b86b077a94346a3ebd8b806d4a697fff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*******************************************************************************
 * Copyright (c) 2003, 2005 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
 *******************************************************************************/
/*
 * Created on May 1, 2003
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package org.eclipse.jst.j2ee.internal.wizard;

import java.util.List;

import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds;
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.PlatformUI;


/**
 * @author Sachin
 * 
 * To change the template for this generated type comment go to Window>Preferences>Java>Code
 * Generation>Code and Comments
 */
public class WizardClassesImportMainPage extends WizardPage {
	Composite composite;

	protected Button importFromDir;
	protected Button importFromZip;

	private List dragAndDropFileNames = null;

	/**
	 * @param pageName
	 */
	public WizardClassesImportMainPage(String pageName) {
		super(pageName);
		setTitle(J2EEUIMessages.getResourceString("DataTransfer.fileSystemTitle")); //$NON-NLS-1$
		setDescription(J2EEUIMessages.getResourceString("FileImport.importFileSystem")); //$NON-NLS-1$
		setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor("import_class_file_wiz_ban")); //$NON-NLS-1$
	}

	public WizardClassesImportMainPage(String pageName, List fileNames) {
		super(pageName);
		setTitle(J2EEUIMessages.getResourceString("DataTransfer.fileSystemTitle")); //$NON-NLS-1$
		setDescription(J2EEUIMessages.getResourceString("FileImport.importFileSystem")); //$NON-NLS-1$
		setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor("import_class_file_wiz_ban")); //$NON-NLS-1$
		dragAndDropFileNames = fileNames;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
	 */
	public void createControl(Composite parent) {
		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IJ2EEUIContextIds.IMPORT_CLASS_WIZARD_P1);
		initializeDialogUnits(parent);
		Composite aComposite = new Composite(parent, SWT.NULL);
		aComposite.setLayout(new GridLayout());
		aComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
		aComposite.setSize(aComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		aComposite.setFont(parent.getFont());
		createImportTypeGroup(aComposite);
		setControl(aComposite);
	}

	protected void createImportTypeGroup(Composite parent) {
		Composite importTypeGroup = new Composite(parent, SWT.NONE);
		GridLayout layout = new GridLayout();
		importTypeGroup.setLayout(layout);
		importTypeGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
		//importTypeGroup.setText(WorkbenchMessages.getString("WizardExportPage.options"));
		// //$NON-NLS-1$

		SelectionListener selectionListener = new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				IWizard wiz = getWizard();
				if (((ClassesImportWizard) wiz).page1 != null) {
					((ClassesImportWizard) wiz).page1.blankPage();
				}
			}
		};
		importFromDir = new Button(importTypeGroup, SWT.RADIO);
		importFromDir.setText(J2EEUIMessages.getResourceString("ClassesImport.fromDir")); //$NON-NLS-1$
		importFromDir.addSelectionListener(selectionListener);

		importFromZip = new Button(importTypeGroup, SWT.RADIO);
		importFromZip.setText(J2EEUIMessages.getResourceString("ClassesImport.fromZip")); //$NON-NLS-1$
		importFromZip.addSelectionListener(selectionListener);

		IWizard wiz = getWizard();
		String fileName = null;
		if (((ClassesImportWizard) wiz).fileNames != null)
			fileName = ((ClassesImportWizard) wiz).fileNames.get(0).toString();
		if (fileName != null && (fileName.endsWith(".zip") || fileName.endsWith(".jar"))) { //$NON-NLS-1$ //$NON-NLS-2$
			importFromDir.setSelection(false);
			importFromZip.setSelection(true);
		} else {
			importFromDir.setSelection(true);
			importFromZip.setSelection(false);
		}
	}

	protected boolean isSetImportFromDir() {
		if (importFromDir != null)
			return importFromDir.getSelection();

		String fileName = dragAndDropFileNames.get(0).toString();
		if (fileName != null && (fileName.endsWith(".zip") || fileName.endsWith(".jar"))) { //$NON-NLS-1$ //$NON-NLS-2$
			return false;
		}
		return true;
	}
}


Back to the top