Package net.sphene.goim.rcp.ui.wizard.addcontact

Source Code of net.sphene.goim.rcp.ui.wizard.addcontact.WizardEnterJabberIdPage

/*
* File    : WizardEnterJabberIdPage.java
* Created : 29.12.2005
* By      : kahless
*
* GOIM - Gamers Own Instant Messenger
* Copyright (C) 2005 Herbert Poul (kahless@sphene.net / herbert.poul@gmail.com)
* http://goim.sphene.net
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
*/
package net.sphene.goim.rcp.ui.wizard.addcontact;

import net.sphene.goim.rcp.beans.GOIMAccount;
import net.sphene.goim.rcp.ui.vCardGUI;

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.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;

public class WizardEnterJabberIdPage extends WizardPage {

  Text txtJabberId;
  private Button buttonViewVCard;
  private GOIMAccount account;

  public WizardEnterJabberIdPage(GOIMAccount account) {
    super("enterJabberId");
    this.account = account;
    this.setTitle("Adding Jabber Contact");
    this.setDescription("Adding a jabber contact to your roster.");
    setPageComplete(false);
  }

  @Override
  public boolean isPageComplete() {
    if(!txtJabberId.getText().matches(".+@.+")) {
      setMessage("Enter Valid JabberId (e.g. kahless@sphene.net )",ERROR);
      buttonViewVCard.setEnabled(false);
      return false;
    }
    buttonViewVCard.setEnabled(true);
    setMessage(null);
    return true;
  }

  public void createControl(Composite parent) {
    Composite topLevel = new Composite(parent,SWT.NULL);
    setControl(topLevel);
   
    topLevel.setLayout(new GridLayout(2,true));
   
    Label lblJabberIdDescr = new Label(topLevel,SWT.NULL);
    lblJabberIdDescr.setText("Enter the Jabber Id of the contact you want to add.");
    lblJabberIdDescr.setLayoutData(new GridData(SWT.FILL,SWT.BEGINNING,true,false,2,1));

    Label lblJabberId = new Label(topLevel,SWT.NULL);
    lblJabberId.setText("Jabber Id");
    lblJabberId.setLayoutData(new GridData(SWT.CENTER,SWT.CENTER,true,false));
   
    txtJabberId = new Text(topLevel,SWT.BORDER);
    txtJabberId.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,true,false));
   
    txtJabberId.addListener(SWT.Modify,new Listener() {
      public void handleEvent(Event event) {
        setPageComplete(isPageComplete());
      }
    });
   
    buttonViewVCard = new Button(topLevel,SWT.PUSH);
    buttonViewVCard.setText("View VCard");
    buttonViewVCard.setLayoutData(new GridData(SWT.CENTER,SWT.CENTER,false,false,2,1));
   
    buttonViewVCard.addListener(SWT.Selection,new Listener() {

      public void handleEvent(Event event) {
        new vCardGUI(account,txtJabberId.getText(),txtJabberId.getShell());
      }});
  }
}
TOP

Related Classes of net.sphene.goim.rcp.ui.wizard.addcontact.WizardEnterJabberIdPage

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.