
org.fosstrak.llrp.commander.dialogs.ConnectDialog Maven / Gradle / Ivy
/*
*
* Fosstrak LLRP Commander (www.fosstrak.org)
*
* Copyright (C) 2008 ETH Zurich
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
*
*/
package org.fosstrak.llrp.commander.dialogs;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
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.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
/**
* superclass for all the connect dialogs. all subclasses have to instantiate
* the two members FIELDS and DEFAULTS as arrays providing the labels and the
* default values for the fields available.
*
* FIELDS = new String[]{ "test", "me" };
* DEFAULTS = new String [] { "myTestDefault", "memuuDefault" };
* will create two fields with labels "test" and "me" with the respective
* default values.
*
* @author sawielan
*
*/
public abstract class ConnectDialog extends org.eclipse.jface.dialogs.Dialog {
/** the label of the fields. */
public String [] FIELDS;
/** the default values for the fields. */
public String [] DEFAULTS;
/** the values collected from the fields. */
public String [] values;
/** the text fields. */
protected Text []txts;
/** the caption. */
protected final String caption;
/** the grid settings for the label fields. */
protected GridData gridLabel = new GridData(GridData.FILL_BOTH);
/** the grid settings for the text fields. */
protected GridData gridText = new GridData(GridData.FILL_BOTH);
/** the grid settings for a horizontal filler. */
protected GridData gridAll = new GridData(GridData.FILL_BOTH);
/**
* create a new connect dialog.
* @param shell the parent shell.
* @param caption the caption for the dialog.
*/
public ConnectDialog(Shell shell, String caption) {
super(shell);
this.caption = caption;
}
/**
* sets the layout for the dialog.
* @param parent the parent where to set the layout.
*/
protected void setLayout(Composite parent) {
GridLayout layout = new GridLayout();
layout.numColumns = 3;
gridLabel.verticalSpan = 1;
gridLabel.horizontalSpan = 1;
gridLabel.widthHint=100;
gridLabel.heightHint = 20;
gridText.verticalSpan = 1;
gridText.horizontalSpan = 2;
gridText.widthHint=200;
gridText.heightHint = 20;
gridAll.verticalSpan = 1;
gridAll.horizontalSpan = 3;
gridAll.heightHint = 20;
parent.getShell().setLayout(layout);
parent.getShell().setText(caption);
}
/**
* registers listeners to the text fields with the OK button as the parent.
* @param btnOK the ok button to use as parent.
*/
protected void registerTextFieldListeners(Button btnOK) {
// add the selection listeners.
for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy