/** * Copyright 2009 Red Hat, Inc. * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.safehaus.penrose.studio.schema.tree; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuManager; import org.eclipse.swt.graphics.Image; import org.safehaus.penrose.schema.ObjectClass; import org.safehaus.penrose.studio.server.ServersView; import org.safehaus.penrose.studio.tree.Node; import org.safehaus.penrose.studio.schema.editor.ObjectClassEditor; import org.safehaus.penrose.studio.schema.editor.ObjectClassEditorInput; import org.safehaus.penrose.studio.dialog.ErrorDialog; import org.apache.log4j.Logger; /** * @author Endi S. Dewata */ public class ObjectClassNode extends Node { Logger log = Logger.getLogger(getClass()); ServersView view; public ObjectClassNode(ServersView view, String name, Image image, Object object, Node parent) { super(name, image, object, parent); this.view = view; } public void showMenu(IMenuManager manager) { manager.add(new Action("Open") { public void run() { try { open(); } catch (Exception e) { log.error(e.getMessage(), e); ErrorDialog.open(e); } } }); } public void open() throws Exception { ObjectClass objectClass = (ObjectClass)getObject(); ObjectClassEditorInput ei = new ObjectClassEditorInput(objectClass); IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchPage page = window.getActivePage(); page.openEditor(ei, ObjectClassEditor.class.getName()); } }