Package hidb2.gui.action

Source Code of hidb2.gui.action.AddAttributAction

/**
* This file is part of HIDB2.
*
* HIDB2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HIDB2 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 Lesser Public License for more details.
*
* You should have received a copy of the GNU Lesser Public License
* along with HIDB2.  If not, see <http://www.gnu.org/licenses/>.
*/
package hidb2.gui.action;

import static hidb2.kern.AttrType.T_String;
import hidb2.gui.ressources.RscMan;
import hidb2.gui.util.PoserTableViewer;
import hidb2.kern.Attribut;
import hidb2.kern.AttributedDescription;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.ui.ISharedImages;

/**
* Add an attribut to the current attributed description
*
*/
public class AddAttributAction extends Action
  {
  private TableViewer viewer;

  private AttributedDescription _descr;

  public AddAttributAction(PoserTableViewer viewer)
    {
    this.viewer = viewer;
    setText("Add Attribut");
    setToolTipText("Create a new attribut");
    setImageDescriptor(RscMan.getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD));
    }

  public void run(AttributedDescription attrDescr)
    {
    _descr = attrDescr;
    run();
    }

  public void run()
    {
    if (viewer != null)
      {
      try
        {
//        ISelection selection = viewer.getSelection();
//        Object obj = ((IStructuredSelection) selection).getFirstElement();

        Attribut at0 = new Attribut(_descr.getID(), T_String);

        _descr.addAttribut(at0, 0);

        viewer.refresh();
        }

      catch (/*PartInit*/Exception e)
        {
        MessageDialog.openError(viewer.getControl().getShell(), "Error", "Error : " + e.getMessage());
        e.printStackTrace();
        }
      }
    }

  }
TOP

Related Classes of hidb2.gui.action.AddAttributAction

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.