/* * JBoss, Home of Professional Open Source * Copyright 2008-12, Red Hat Middleware LLC, and others contributors as indicated * by the @authors tag. All rights reserved. * See the copyright.txt in the distribution for a * full listing of individual contributors. * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU Lesser General Public License, v. 2.1. * This program is distributed in the hope that it will be useful, but WITHOUT A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License, * v.2.1 along with this distribution; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ package org.savara.tools.common.properties; import org.eclipse.core.resources.IResource; 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.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.dialogs.PropertyPage; /** * This class provides the base property page for the Savara tools. * */ public class BasePropertyPage extends PropertyPage { private static final String PATH_TITLE = "Path:"; protected static final int DEFAULT_INDEX=0; /** * Default constructor. */ public BasePropertyPage() { super(); } /** * This method provides information about the resource. * * @param parent */ private void addHeaderSection(Composite parent) { Composite composite = createDefaultComposite(parent); //Label for path field Label pathLabel = new Label(composite, SWT.NONE); pathLabel.setText(PATH_TITLE); // Path text field Text pathValueText = new Text(composite, SWT.WRAP | SWT.READ_ONLY); pathValueText.setEnabled(false); pathValueText.setText(((IResource) getElement()).getFullPath().toString()); } /** * This method adds the separator. * * @param parent */ private void addSeparator(Composite parent) { Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; separator.setLayoutData(gridData); } /** * @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); composite.setLayout(layout); GridData data = new GridData(GridData.FILL); data.grabExcessHorizontalSpace = true; composite.setLayoutData(data); addHeaderSection(composite); addSeparator(composite); return composite; } /** * This method creates the default composite. * * @param parent The parent composite * @return The new default composite */ private Composite createDefaultComposite(Composite parent) { Composite composite = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); layout.numColumns = 2; composite.setLayout(layout); GridData data = new GridData(); data.verticalAlignment = GridData.FILL; data.horizontalAlignment = GridData.FILL; composite.setLayoutData(data); return composite; } /** * This method resets the properties to their default values. */ protected void performDefaults() { } /** * This method applies the properties to the persistent * storage associated with the resource. */ public boolean performOk() { return true; } }