/*******************************************************************************
 * Copyright (c) 2000, 2008 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jdt.ui.examples;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

import org.eclipse.core.runtime.Path;

import org.eclipse.jface.wizard.WizardPage;

import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.JavaCore;

import org.eclipse.jdt.ui.wizards.IClasspathContainerPage;

public class MyClasspathContainerPage extends WizardPage implements IClasspathContainerPage {

	private IClasspathEntry fEntry;

	public MyClasspathContainerPage() {
		super("MyClasspathContainerPage");
		setTitle("My Example Container");
	}

	@Override
	public void createControl(Composite parent) {
		Label label= new Label(parent, SWT.NONE);
		if (fEntry == null) {
			label.setText("Nothing to configure. Press 'Finish' to add new entry");
		} else {
			label.setText("Nothing to configure.");
			setPageComplete(false);
		}
		setControl(label);
	}

	@Override
	public boolean finish() {
		if (fEntry == null) { // new entry
			fEntry= JavaCore.newContainerEntry(new Path("org.eclipse.jdt.EXAMPLE_CONTAINER"));
		}
		return true;
	}

	@Override
	public IClasspathEntry getSelection() {
		return fEntry;
	}

	@Override
	public void setSelection(IClasspathEntry containerEntry) {
		fEntry= containerEntry;
	}

}
