/******************************************************************************* * Copyright (c) 2012-2015 Codenvy, S.A. * 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: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ package org.eclipse.che.ide.api.editor; import org.eclipse.che.ide.api.project.tree.VirtualFile; import org.eclipse.che.ide.collections.Array; import org.eclipse.che.ide.collections.StringMap; import com.google.gwt.user.client.rpc.AsyncCallback; import javax.annotation.Nonnull; import javax.annotation.Nullable; /** * Editor Agent manages Editors, it allows to open a new editor with given file, * retrieve current active editor and find all the opened editors. * * @author Nikolay Zamosenchuk */ public interface EditorAgent { /** * Open editor with given file * * @param file the file to open */ void openEditor(@Nonnull final VirtualFile file); /** * Open editor with given file, call callback when editor fully loaded and initialized. * @param file the file to open * @param callback */ void openEditor(@Nonnull VirtualFile file, @Nonnull OpenEditorCallback callback); /** * Sets editor as active(switch tabs and pace cursor) * @param editor the editor that must be active */ void activateEditor(@Nonnull EditorPartPresenter editor); /** * Returns array of EditorPartPresenters whose content have changed since the last save operation. * * @return Array<EditorPartPresenter> */ Array<EditorPartPresenter> getDirtyEditors(); /** * Get all opened editors * * @return map with all opened editors */ @Nonnull StringMap<EditorPartPresenter> getOpenedEditors(); /** * Saves all opened files whose content have changed since the last save operation * * @param callback */ void saveAll(AsyncCallback callback); /** * Current active editor * * @return the current active editor */ @Nullable EditorPartPresenter getActiveEditor(); public interface OpenEditorCallback{ void onEditorOpened(EditorPartPresenter editor); } }