Package org.latexlab.docs.client.content.windows

Source Code of org.latexlab.docs.client.content.windows.ToolbarWindowLogical

package org.latexlab.docs.client.content.windows;

import org.latexlab.docs.client.commands.SystemPasteCommand;
import org.latexlab.docs.client.content.latex.LatexCommand;
import org.latexlab.docs.client.content.latex.SetLogical;
import org.latexlab.docs.client.widgets.LatexCommandToolbar;
import org.latexlab.docs.client.widgets.WindowManager;

import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
import com.google.gwt.user.client.rpc.AsyncCallback;

/**
* A toolbar containing LaTeX commands.
*/
public class ToolbarWindowLogical extends LatexCommandToolbar {

  protected static ToolbarWindowLogical instance;

  /**
   * Retrieves the single instance of this class.
   *
   * @param manager the window manager
   */
  public static ToolbarWindowLogical get(final WindowManager manager) {
    if (instance == null) {
      instance = new ToolbarWindowLogical();
      instance.registeredDragController = manager.getWindowController().getPickupDragController();
      instance.hide();
      manager.getWindowController().makeResizable(instance);
      manager.getBoundaryPanel().add(instance, 500, 120);
    }
    return instance;
  }

  protected ToolbarWindowLogical() {
  super(SetLogical.TITLE);
  }

  @Override
  protected void getToolbarContents(final AsyncCallback<ToolbarWindowContents> callback) {
    GWT.runAsync(new RunAsyncCallback() {
    @Override
    public void onFailure(Throwable reason) {
      callback.onFailure(reason);
    }
    @Override
    public void onSuccess() {
      ToolbarWindowContents contents = new ToolbarWindowContents();
      SetLogical commandSet = SetLogical.get();
      for (LatexCommand cmd : commandSet.getCommands()) {
        contents.addButton(cmd.getIcon(), cmd.getTitle(), false,
          new SystemPasteCommand(cmd.getText()));
      }
    }
    });
  }

}
TOP

Related Classes of org.latexlab.docs.client.content.windows.ToolbarWindowLogical

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.