Package de.innovationgate.eclipse.utils.ui

Source Code of de.innovationgate.eclipse.utils.ui.ValidatedDialog

/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.utils.ui;

import java.util.List;

import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.StatusDialog;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Shell;

import de.innovationgate.eclipse.utils.Activator;

public abstract class ValidatedDialog extends StatusDialog implements ModifyListener {

  public ValidatedDialog(Shell parent) {
    super(parent);
  }
 
  public abstract List<String> validate();
 
  public abstract void computeResponse();

  public void modifyText(ModifyEvent e) {
    performValidation();
  }
 
  protected boolean performValidation() {
    List<String> validationMessages = validate();
    if (!validationMessages.isEmpty()) {
      updateStatus(new Status(Status.ERROR, Activator.PLUGIN_ID, validationMessages.get(0)));
      return false;
    } else {
      updateStatus(Status.OK_STATUS);
      return true;
   
  }
 
 
 

 
 
 

  @Override
  protected void okPressed() {   
    if (performValidation()) {
      computeResponse();
      super.okPressed();
    }
  }
}
TOP

Related Classes of de.innovationgate.eclipse.utils.ui.ValidatedDialog

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.