Skip to content

Commit

Permalink
Merge pull request #394 from codenvy/IDEX-3485
Browse files Browse the repository at this point in the history
IDEX-3485: hide JS content assist box after switching to another file
  • Loading branch information
azatsarynnyy committed Nov 17, 2015
2 parents 6d392be + 0fbbbd8 commit 5d83090
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@
import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.OperationException;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.event.SelectionChangedEvent;
import org.eclipse.che.ide.api.event.SelectionChangedHandler;
import org.eclipse.che.ide.api.text.Region;
import org.eclipse.che.ide.api.text.RegionImpl;
import org.eclipse.che.ide.api.texteditor.HandlesUndoRedo;
import org.eclipse.che.ide.editor.orion.client.jso.OrionCodeEditWidgetOverlay;
import org.eclipse.che.ide.editor.orion.client.jso.OrionContentAssistOverlay;
import org.eclipse.che.ide.editor.orion.client.jso.OrionEditorOverlay;
import org.eclipse.che.ide.editor.orion.client.jso.OrionEditorViewOverlay;
import org.eclipse.che.ide.editor.orion.client.jso.OrionSelectionOverlay;
Expand Down Expand Up @@ -522,6 +525,16 @@ public void apply(OrionEditorViewOverlay arg) throws OperationException {
editorViewOverlay = arg;
editorOverlay = arg.getEditor();

final OrionContentAssistOverlay contentAssist = editorOverlay.getContentAssist();
eventBus.addHandler(SelectionChangedEvent.TYPE, new SelectionChangedHandler() {
@Override
public void onSelectionChanged(SelectionChangedEvent event) {
if (contentAssist.isActive()) {
contentAssist.deactivate();
}
}
});

final OrionTextViewOverlay textView = editorOverlay.getTextView();
keyModeInstances.add(VI, getViKeyMode(moduleHolder.getModule("OrionVi"), textView));
keyModeInstances.add(EMACS, getEmacsKeyMode(moduleHolder.getModule("OrionEmacs"), textView));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*******************************************************************************
* Copyright (c) 2014-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.editor.orion.client.jso;

import com.google.gwt.core.client.JavaScriptObject;

/**
* JavaScript overlay over Orion ContentAssist object.
*
* @author Artem Zatsarynnyy
*/
public class OrionContentAssistOverlay extends JavaScriptObject {

protected OrionContentAssistOverlay() {
}

/** Checks whether the content assist is active or not. */
public final native boolean isActive() /*-{
return this.isActive();
}-*/;

/** Deactivates the content assist. */
public final native void deactivate() /*-{
this.deactivate();
}-*/;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public final native OrionTextViewOverlay getTextView() /*-{
return this.getTextView();
}-*/;

/** Returns the content assist of the editor. */
public final native OrionContentAssistOverlay getContentAssist() /*-{
return this.getContentAssist();
}-*/;

public final native void focus() /*-{
this.focus();
}-*/;
Expand Down

0 comments on commit 5d83090

Please sign in to comment.