| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * 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: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| */ |
| package org.eclipse.osbp.wizard.ui.basic; |
| |
| import org.eclipse.core.runtime.IStatus; |
| import org.eclipse.jface.dialogs.Dialog; |
| import org.eclipse.jface.wizard.WizardPage; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.layout.GridData; |
| import org.eclipse.swt.layout.GridLayout; |
| import org.eclipse.swt.widgets.Composite; |
| import org.eclipse.ui.PlatformUI; |
| import org.eclipse.ui.internal.ide.IIDEHelpContextIds; |
| import org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea.IErrorMessageReporter; |
| import org.slf4j.Logger; |
| import org.slf4j.LoggerFactory; |
| |
| public abstract class BasicNewProjectWizardPage extends WizardPage { |
| |
| protected static final Logger LOGGER = LoggerFactory.getLogger(BasicNewProjectWizardPage.class); |
| |
| // constants |
| protected static final int SIZING_TEXT_FIELD_WIDTH = 250; |
| |
| public Composite projectGroup; |
| protected GridLayout layout; |
| public GridData data; |
| |
| protected BasicNewProjectWizardPage(BasicNewProjectWizard wizard, String pageName) { |
| super(wizard.translator.getDocumentation(wizard, pageName)); |
| this.wizard = wizard; |
| setTitle(wizard.getWindowTitle()); |
| setDescription(wizard.translator.getDocumentation(wizard, pageName)); |
| setPageComplete(false); |
| } |
| |
| protected final BasicNewProjectWizard wizard; |
| |
| /** (non-Javadoc) |
| * Method declared on IDialogPage. |
| */ |
| public final void createControl(Composite parent) { |
| Composite composite = new Composite(parent, SWT.NULL); |
| |
| initializeDialogUnits(parent); |
| |
| PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, |
| IIDEHelpContextIds.NEW_PROJECT_WIZARD_PAGE); |
| |
| composite.setLayout(new GridLayout()); |
| composite.setLayoutData(new GridData(GridData.FILL_BOTH)); |
| |
| // project specification group |
| projectGroup = new Composite(composite, SWT.NONE); |
| layout = new GridLayout(); |
| layout.numColumns = 2; |
| data = new GridData(GridData.FILL_HORIZONTAL); |
| data.widthHint = SIZING_TEXT_FIELD_WIDTH; |
| projectGroup.setLayout(layout); |
| projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
| |
| createProjectNameGroup(composite); |
| |
| setPageComplete(wizard.validatePage(this)); |
| // Show description on opening |
| setErrorMessage(null); |
| setMessage(null); |
| setControl(composite); |
| Dialog.applyDialogFont(composite); |
| } |
| |
| /** |
| * Get an error reporter for the receiver. |
| * @return IErrorMessageReporter |
| */ |
| protected final IErrorMessageReporter getErrorReporter() { |
| return new IErrorMessageReporter(){ |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea.IErrorMessageReporter#reportError(java.lang.String) |
| */ |
| public void reportError(String errorMessage, boolean infoOnly) { |
| if (infoOnly) { |
| setMessage(errorMessage, IStatus.INFO); |
| setErrorMessage(null); |
| } |
| else |
| setErrorMessage(errorMessage); |
| boolean valid = errorMessage == null; |
| if(valid) { |
| valid = wizard.validatePage(BasicNewProjectWizardPage.this); |
| } |
| setPageComplete(valid); |
| } |
| }; |
| } |
| |
| /** |
| * Creates the project name specification controls. |
| * |
| * @param parent the parent composite |
| */ |
| protected abstract void createProjectNameGroup(Composite parent); |
| |
| /** |
| * Returns the useDefaults. |
| * @return boolean |
| */ |
| public final boolean useDefaults() { |
| return wizard.locationArea.isDefault(); |
| } |
| } |