/*******************************************************************************
* Copyright (c) 2011 Softberries Krzysztof Grajek.
* 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:
* Softberries Krzysztof Grajek - initial API and implementation
******************************************************************************/
package com.softberries.klerk.commands;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.commands.IHandlerListener;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.part.NullEditorInput;
import com.softberries.klerk.gui.editors.CompaniesEditor;
/**
*
* @author krzysztof.grajek@softberries.com
*
*/
public class OpenCompaniesCommand implements IHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPage page;
IEditorInput input = new NullEditorInput();
page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage ();
try {
page.openEditor(input, CompaniesEditor.ID);
} catch (PartInitException e) {
e.printStackTrace();
}
return null;
}
@Override
public void addHandlerListener(IHandlerListener handlerListener) {
}
@Override
public void dispose() {
}
@Override
public boolean isEnabled() {
//for now make it always enabled (and maybe forever)
return true;
}
@Override
public boolean isHandled() {
return true;
}
@Override
public void removeHandlerListener(IHandlerListener handlerListener) {
}
}