/*
 *  wb_editor_layer.cpp
 *  MySQLWorkbench
 *
 *  Created by Alfredo Kojima on 17/Apr/09.
 *  Copyright 2009 Sun Microsystems Inc. All rights reserved.
 *
 */

#include "stdafx.h"
#include "wb_editor_layer.h"

LayerEditorBE::LayerEditorBE(bec::GRTManager *grtm, const workbench_physical_LayerRef &layer)
: BaseEditor(grtm, layer), _layer(layer)
{
}


bool LayerEditorBE::should_close_on_delete_of(const std::string &oid)
{
  if (_layer.id() == oid || _layer->owner().id() == oid)
    return true;
  
  return false;
}


void LayerEditorBE::set_color(const std::string &color)
{
  if (_layer->color() != color)
  {
    bec::AutoUndoEdit undo(this, _layer, "color");
    _layer->color(color);
    undo.end(_("Change Layer Color"));
  }
}


std::string LayerEditorBE::get_color()
{
  return _layer->color();
}

void LayerEditorBE::set_name(const std::string &name)
{
  if (_layer->name() != name)
  {
    bec::AutoUndoEdit undo(this, _layer, "name");
    _layer->name(name);
    undo.end(_("Change Layer Name"));  
  }
}


std::string LayerEditorBE::get_name()
{
  return _layer->name();
}

