Package gui.dialogs

Source Code of gui.dialogs.CommunicationChannelConfigDialog

package gui.dialogs;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
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.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import resources.SWTResourceManager;
import resources.digesters.ClassManager;
import resources.digesters.Plugin;
import utils.ErrorMessage;

import components.ComponentGUIInteface;
import components.commchannel.CommunicationChannel;
import components.commchannel.CommunicationChannelGUI;


/**
* Esta clase implementa el di�logo para la configuraci�n
* del canal de comunicaciones.
*/
public abstract class CommunicationChannelConfigDialog extends Dialog implements ComponentGUIInteface
{

  private Shell          dialogShell;
  private Composite         top;
  private Label           separatorHead;
  private CLabel           headLabel;
  private Composite         Header;
  private Text           commentEdit;
  private Label           comment;
  private Text           nameEdit;
  private Label           name;
  private Label           separatorButtons;
  private Button           okButton;
  private Button           applyButton;
  private Composite         buttonBar;
  private Label           separator;
  private Composite         back;
  private CommunicationChannel   commChannel;
  private Composite         customSpace;
 

 
  public CommunicationChannelConfigDialog(Shell parent, int style, CommunicationChannel commChannel)
  {
    super(parent, style);
  }

 
  public void open()
  {
    try
    {
      Shell parent = getParent();
      dialogShell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

        {
          //Register as a resource user - SWTResourceManager will
          //handle the obtaining and disposing of resources
          SWTResourceManager.registerResourceUser(dialogShell);
        }


      GridLayout dialogShellLayout = new GridLayout();
      dialogShell.setLayout(dialogShellLayout);
      dialogShellLayout.horizontalSpacing = 0;
      dialogShellLayout.marginHeight = 0;
      dialogShellLayout.marginWidth = 0;
      dialogShellLayout.verticalSpacing = 0;
      dialogShell.layout();
      dialogShell.pack();
      dialogShell.setSize(422, 250);
      {
        back = new Composite(dialogShell, SWT.NONE);
        GridLayout backLayout = new GridLayout();
        backLayout.makeColumnsEqualWidth = true;
        backLayout.horizontalSpacing = 0;
        backLayout.marginHeight = 0;
        backLayout.marginWidth = 0;
        backLayout.verticalSpacing = 0;
        GridData backLData = new GridData();
        backLData.horizontalAlignment = GridData.FILL;
        backLData.verticalAlignment = GridData.FILL;
        backLData.grabExcessHorizontalSpace = true;
        backLData.grabExcessVerticalSpace = true;
        back.setLayoutData(backLData);
        back.setLayout(backLayout);
        {
          Header = new Composite(back, SWT.NONE);
          GridLayout HeaderLayout = new GridLayout();
          HeaderLayout.makeColumnsEqualWidth = true;
          Header.setLayout(HeaderLayout);
          {
            headLabel = new CLabel(Header, SWT.NONE);
            headLabel.setText("Cofiguracion del Canal de Comunicaci�n");
            headLabel.setImage(SWTResourceManager.getImage("resources/icons/icon32x32/enable/Connection Configuration.png"));
            headLabel.setFont(SWTResourceManager.getFont("Tahoma", 8, 1, false, false));
          }
        }
        {
          GridData separatorHeadLData = new GridData();
          separatorHeadLData.grabExcessHorizontalSpace = true;
          separatorHeadLData.horizontalAlignment = GridData.FILL;
          separatorHead = new Label(back, SWT.SEPARATOR
            | SWT.HORIZONTAL);
          separatorHead.setLayoutData(separatorHeadLData);
        }
        {
          top = new Composite(back, SWT.NONE);
          GridLayout topLayout = new GridLayout();
          topLayout.makeColumnsEqualWidth = true;
          topLayout.numColumns = 2;
          GridData topLData = new GridData();
          topLData.grabExcessHorizontalSpace = true;
          topLData.horizontalAlignment = GridData.FILL;
          topLData.verticalAlignment = GridData.FILL;
          top.setLayoutData(topLData);
          top.setLayout(topLayout);
          {
            name = new Label(top, SWT.NONE);
            GridData nameLData = new GridData();
            nameLData.horizontalAlignment = GridData.END;
            name.setLayoutData(nameLData);
            name.setText("Nombre:");
          }
          {
            nameEdit = new Text(top, SWT.NONE);
            GridData nameEditLData = new GridData();
            nameEditLData.widthHint = 163;
            nameEditLData.heightHint = 13;
            nameEdit.setLayoutData(nameEditLData);
            nameEdit.setText("Ingrese Nombre...");
          }
          {
            comment = new Label(top, SWT.NONE);
            GridData commentLData = new GridData();
            commentLData.horizontalAlignment = GridData.END;
            comment.setLayoutData(commentLData);
            comment.setText("Decripcion");
          }
          {
            commentEdit = new Text(top, SWT.NONE);
            GridData commentEditLData = new GridData();
            commentEditLData.widthHint = 163;
            commentEditLData.heightHint = 13;
            commentEdit.setLayoutData(commentEditLData);
            commentEdit.setText("Ingrese Comentario...");
          }
        }
        {
          separator = new Label(back, SWT.SEPARATOR | SWT.HORIZONTAL);
          GridData separatorLData = new GridData();
          separatorLData.horizontalAlignment = GridData.FILL;
          separator.setLayoutData(separatorLData);
        }
        {
          customSpace = new Composite(back, SWT.NONE);
          GridLayout customSpaceLayout = new GridLayout();
          customSpaceLayout.numColumns = 1;
          customSpace.setLayout(customSpaceLayout);
          GridData bottonLData = new GridData();
          bottonLData.grabExcessHorizontalSpace = true;
          bottonLData.horizontalAlignment = GridData.FILL;
          bottonLData.verticalAlignment = GridData.FILL;
          bottonLData.grabExcessVerticalSpace = true;
          customSpace.setLayoutData(bottonLData);
         
          {
            Plugin commChannelPlugin = ClassManager.getInstance().getPluginByName(commChannel.getClass().getCanonicalName());
            if (commChannelPlugin != null)
            {
              CommunicationChannelGUI commChannelConfig = (CommunicationChannelGUI) commChannelPlugin.makeGUInstance(commChannel);
              //customPannel = commChannelConfig.getConfigPannel(customSpace,customSpace.getStyle());
              commChannelConfig.getConfigPannel(customSpace,customSpace.getStyle());
            }
           
          }
        }
        {
          GridData separatorButtonsLData = new GridData();
          separatorButtonsLData.grabExcessHorizontalSpace = true;
          separatorButtonsLData.horizontalAlignment = GridData.FILL;
          separatorButtons = new Label(back, SWT.SEPARATOR
            | SWT.HORIZONTAL);
          separatorButtons.setLayoutData(separatorButtonsLData);
        }
        {
          buttonBar = new Composite(back, SWT.NONE);
          GridLayout buttonBarLayout = new GridLayout();
          buttonBarLayout.makeColumnsEqualWidth = true;
          buttonBarLayout.numColumns = 2;
          buttonBarLayout.marginLeft = 300;
          buttonBarLayout.marginWidth = 0;
          buttonBarLayout.verticalSpacing = 0;
          buttonBarLayout.marginHeight = 3;
          GridData buttonBarLData = new GridData();
          buttonBarLData.grabExcessHorizontalSpace = true;
          buttonBarLData.horizontalAlignment = GridData.FILL;
          buttonBarLData.heightHint = 29;
          buttonBar.setLayoutData(buttonBarLData);
          buttonBar.setLayout(buttonBarLayout);
          {
            applyButton = new Button(buttonBar, SWT.PUSH
              | SWT.CENTER);
            GridData applyButtonLData = new GridData();
            applyButtonLData.widthHint = 50;
            applyButtonLData.heightHint = 23;
            applyButtonLData.horizontalAlignment = GridData.CENTER;
            applyButton.setLayoutData(applyButtonLData);
            applyButton.setText("Aplicar");
            applyButton.setSize(50, 23);
          }
          {
            okButton = new Button(buttonBar, SWT.PUSH | SWT.CENTER);
            GridData okButtonLData = new GridData();
            okButtonLData.horizontalAlignment = GridData.CENTER;
            okButton.setLayoutData(okButtonLData);
            okButton.setText("Aceptar");
          }
         
        }
      }
      dialogShell.open();
      Display display = dialogShell.getDisplay();
      while (!dialogShell.isDisposed()) {
        if (!display.readAndDispatch())
          display.sleep();
      }
    }
    catch (Exception e)
    {
      ErrorMessage.customMessage(e.getMessage(), ErrorMessage.ERROR_MESSAGE, getParent() );
    }
  }
 
 
  public abstract Composite getConfigPannel(Composite composite);
 
  public abstract void saveConfig();
 
  public abstract void applyChanges();
 
}
TOP

Related Classes of gui.dialogs.CommunicationChannelConfigDialog

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.