Package net.helipilot50.aerospike.wizards

Source Code of net.helipilot50.aerospike.wizards.DBCoordinatesWizardPage

package net.helipilot50.aerospike.wizards;

import net.helipilot50.aerospike.model.ClusterCoordinates;

import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.PojoObservables;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.swt.SWTObservables;
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.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wb.swt.ResourceManager;
import org.eclipse.swt.widgets.Button;

public class DBCoordinatesWizardPage extends WizardPage{
  private DataBindingContext m_bindingContext;
  private ClusterCoordinates dbCoordinates;
  private Text dbNameText;
  private Text hostNameText;
  private Text portText;
  private Text refreshIntervalText;
  private Button btnRefresh;

  /**
   * @wbp.parser.constructor
   */
  public DBCoordinatesWizardPage(ClusterCoordinates dbCoordinates) {
    super("DB Coordinates");
    setImageDescriptor(ResourceManager.getPluginImageDescriptor("CitrusLeafInfo", "icons/repository.gif"));
    setMessage("Enter the coordinates of the database you want to monitor");
    setTitle("Database Coordinates");
    setDescription("This wizard creates a new Citrusleaf Database connection to be monitred.");
    this.dbCoordinates = dbCoordinates;
  }

  @Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);
    container.setLayout(new GridLayout(2, false));
   
    Label lblDatabaseName = new Label(container, SWT.NONE);
    lblDatabaseName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblDatabaseName.setText("Database Name:");
   
    dbNameText = new Text(container, SWT.BORDER);
    dbNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
   
    Label lblHostName = new Label(container, SWT.NONE);
    lblHostName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblHostName.setText("Host Name:");
   
    hostNameText = new Text(container, SWT.BORDER);
    hostNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
   
    Label lblPort = new Label(container, SWT.NONE);
    lblPort.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblPort.setText("Port:");
   
    portText = new Text(container, SWT.BORDER);
    portText.setTextLimit(5);
   
    Label lblRefreshInterval = new Label(container, SWT.NONE);
    lblRefreshInterval.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblRefreshInterval.setText("Refresh Interval:");
   
    refreshIntervalText = new Text(container, SWT.BORDER);
    refreshIntervalText.setToolTipText("THe time interval, in milliseconds, in which the view of this DB will be refreshed.");
    new Label(container, SWT.NONE);
   
    btnRefresh = new Button(container, SWT.CHECK);
    btnRefresh.setText("Refresh");
    m_bindingContext = initDataBindings();
   
   
  }

  public ClusterCoordinates getDbCoordinates() {
    return dbCoordinates;
  }
  protected DataBindingContext initDataBindings() {
    DataBindingContext bindingContext = new DataBindingContext();
    //
    IObservableValue portTextObserveTextObserveWidget = SWTObservables.observeText(portText, SWT.Modify);
    IObservableValue dbCoordinatesPortObserveValue = PojoObservables.observeValue(dbCoordinates, "port");
    bindingContext.bindValue(portTextObserveTextObserveWidget, dbCoordinatesPortObserveValue, null, null);
    //
    IObservableValue dbNameTextObserveTextObserveWidget = SWTObservables.observeText(dbNameText, SWT.Modify);
    IObservableValue dbCoordinatesNameObserveValue = PojoObservables.observeValue(dbCoordinates, "name");
    bindingContext.bindValue(dbNameTextObserveTextObserveWidget, dbCoordinatesNameObserveValue, null, null);
    //
    IObservableValue hostNameTextObserveTextObserveWidget = SWTObservables.observeText(hostNameText, SWT.Modify);
    IObservableValue dbCoordinatesHostNameObserveValue = PojoObservables.observeValue(dbCoordinates, "hostName");
    bindingContext.bindValue(hostNameTextObserveTextObserveWidget, dbCoordinatesHostNameObserveValue, null, null);
    //
    IObservableValue refreshIntervalTextObserveTextObserveWidget = SWTObservables.observeText(refreshIntervalText, SWT.Modify);
    IObservableValue dbCoordinatesRefreshIntervalObserveValue = PojoObservables.observeValue(dbCoordinates, "refreshInterval");
    bindingContext.bindValue(refreshIntervalTextObserveTextObserveWidget, dbCoordinatesRefreshIntervalObserveValue, null, null);
    //
    IObservableValue btnRefreshObserveSelectionObserveWidget = SWTObservables.observeSelection(btnRefresh);
    IObservableValue dbCoordinatesRefreshObserveValue = PojoObservables.observeValue(dbCoordinates, "refresh");
    bindingContext.bindValue(btnRefreshObserveSelectionObserveWidget, dbCoordinatesRefreshObserveValue, null, null);
    //
    return bindingContext;
  }
}
TOP

Related Classes of net.helipilot50.aerospike.wizards.DBCoordinatesWizardPage

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.