Package de.innovationgate.eclipse.utils.ui

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

/*******************************************************************************
* 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.io.IOException;
import java.util.HashMap;
import java.util.Map;

import net.java.dev.genesis.annotation.ViewHandler;
import net.java.dev.genesis.ui.swt.SWTBinder;

import org.eclipse.core.runtime.Status;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbenchPropertyPage;
import org.eclipse.ui.dialogs.PropertyPage;

import de.innovationgate.eclipse.utils.Activator;
import de.innovationgate.wga.model.Model;

@ViewHandler
public abstract class GenesisBoundPropertyPage extends PropertyPage implements IWorkbenchPropertyPage {

  protected SWTBinder _binder;
 
  protected Map<String, Control> _fields = new HashMap<String, Control>();

  public GenesisBoundPropertyPage() {
    super();
  }
 

  protected void bind(Composite container) {
        _binder = new SWTBinder(container, getModel(), this);
        _binder.setBindingStrategy(SWTBinder.BINDING_STRATEGY_PROPERTY);
        _binder.bind();
  }
 
  protected void bind(Composite container, String bindingStrategy) {
        _binder = new SWTBinder(container, getModel(), this);
        _binder.setBindingStrategy(bindingStrategy);
        _binder.bind();
  }

  public abstract Model getModel()
 
  public void refresh() throws IOException {
    getModel().reload();
    if (_binder != null) {         
      _binder.refresh();
    }
  }
 
  @Override
  protected void performDefaults() {
    try {
      getModel().restoreDefaults();
      if (_binder != null) {         
        _binder.refresh();
      }
    } catch (IOException e) {
      Activator.getDefault().getLog().log(new Status(Status.ERROR, Activator.PLUGIN_ID, "Unable to restore property page defaults.", e));
    }
  }
 
}
TOP

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

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.