diff --git a/core/che-core-api-dto/src/main/java/org/eclipse/che/dto/server/DtoFactory.java b/core/che-core-api-dto/src/main/java/org/eclipse/che/dto/server/DtoFactory.java index 24eae46abf..1aa047ff01 100644 --- a/core/che-core-api-dto/src/main/java/org/eclipse/che/dto/server/DtoFactory.java +++ b/core/che-core-api-dto/src/main/java/org/eclipse/che/dto/server/DtoFactory.java @@ -42,6 +42,8 @@ import java.util.Map; import java.util.ServiceLoader; import java.util.concurrent.ConcurrentHashMap; +import static java.lang.String.format; + /** * Provides implementations of DTO interfaces. * @@ -386,11 +388,41 @@ public final class DtoFactory { private DtoProvider getDtoProvider(Class dtoInterface) { DtoProvider dtoProvider = dtoInterface2Providers.get(dtoInterface); if (dtoProvider == null) { - throw new IllegalArgumentException("Unknown DTO type " + dtoInterface); + if (!dtoInterface.isInterface()) { + throw new IllegalArgumentException(format("Only interfaces can be DTO, but %s is not", dtoInterface)); + } + + if (hasDtoAnnotation(dtoInterface)) { + throw new IllegalArgumentException(format("Provider of implementation for DTO type %s isn't found", dtoInterface)); + } else { + throw new IllegalArgumentException(dtoInterface + " is not a DTO type"); + } } + return (DtoProvider)dtoProvider; } + /** + * Checks if dtoInterface or its parent have DTO annotation. + * + * @param dtoInterface + * DTO interface + * @return true if only dtoInterface or one of its parent have DTO annotation. + */ + private boolean hasDtoAnnotation(Class dtoInterface) { + if (dtoInterface.isAnnotationPresent(DTO.class)) { + return true; + } + + for (Class parent: dtoInterface.getInterfaces()) { + if (hasDtoAnnotation(parent)) { + return true; + } + } + + return false; + } + /** * Registers DtoProvider for DTO interface. * diff --git a/core/che-core-api-dto/src/test/java/org/eclipse/che/dto/ServerDtoTest.java b/core/che-core-api-dto/src/test/java/org/eclipse/che/dto/ServerDtoTest.java index b24b6654e5..bbf8d78d0c 100644 --- a/core/che-core-api-dto/src/test/java/org/eclipse/che/dto/ServerDtoTest.java +++ b/core/che-core-api-dto/src/test/java/org/eclipse/che/dto/ServerDtoTest.java @@ -19,11 +19,11 @@ import com.google.gson.JsonPrimitive; import org.eclipse.che.dto.definitions.ComplicatedDto; import org.eclipse.che.dto.definitions.DTOHierarchy; +import org.eclipse.che.dto.definitions.DTOHierarchy.GrandchildDto; import org.eclipse.che.dto.definitions.DtoWithAny; import org.eclipse.che.dto.definitions.DtoWithDelegate; import org.eclipse.che.dto.definitions.DtoWithFieldNames; import org.eclipse.che.dto.definitions.SimpleDto; -import org.eclipse.che.dto.definitions.DTOHierarchy.GrandchildDto; import org.eclipse.che.dto.definitions.model.Model; import org.eclipse.che.dto.definitions.model.ModelComponentDto; import org.eclipse.che.dto.definitions.model.ModelDto; @@ -108,7 +108,7 @@ public class ServerDtoTest { } @Test - public void testDeerializerWithFieldNames() throws Exception { + public void testDeserializerWithFieldNames() throws Exception { final String fooString = "Something"; final String _default = "test_default_keyword"; @@ -380,4 +380,16 @@ public class ServerDtoTest { assertEquals(childDto.getChildField(), "child-field"); assertEquals(childDto.getParentField(), "parent-field"); } + + @Test(expectedExceptions = IllegalArgumentException.class, + expectedExceptionsMessageRegExp = "Only interfaces can be DTO, but class java.lang.String is not") + public void shouldThrowExceptionWhenThereIsClassType() { + DtoFactory.newDto(String.class); + } + + @Test(expectedExceptions = IllegalArgumentException.class, + expectedExceptionsMessageRegExp = "interface org.eclipse.che.dto.definitions.DTOHierarchy\\$GrandchildWithoutDto is not a DTO type") + public void shouldThrowExceptionWhenInterfaceIsNotAnnotatedAsDto() { + DtoFactory.newDto(DTOHierarchy.GrandchildWithoutDto.class); + } } diff --git a/core/che-core-api-dto/src/test/java/org/eclipse/che/dto/definitions/DTOHierarchy.java b/core/che-core-api-dto/src/test/java/org/eclipse/che/dto/definitions/DTOHierarchy.java index bc5915f9e2..12517d317f 100644 --- a/core/che-core-api-dto/src/test/java/org/eclipse/che/dto/definitions/DTOHierarchy.java +++ b/core/che-core-api-dto/src/test/java/org/eclipse/che/dto/definitions/DTOHierarchy.java @@ -13,6 +13,8 @@ package org.eclipse.che.dto.definitions; import org.eclipse.che.dto.shared.DTO; +import java.io.Closeable; + /** * Keeps DTO interfaces for hierarchy test * @@ -60,4 +62,10 @@ public final class DTOHierarchy { void setShadowedField(GrandchildDto v); } + public interface Child2 extends Parent { + String getChild2Field(); + } + + public interface GrandchildWithoutDto extends Child, Child2 { + } } diff --git a/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.controller.ts b/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.controller.ts index e128311438..0731935c2f 100644 --- a/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.controller.ts +++ b/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.controller.ts @@ -43,9 +43,9 @@ export class ProjectSourceSelectorController { */ private selectedSource: ProjectSource; /** - * button's values by Id. + * State of a button. */ - private buttonValues: { [butonId: string]: boolean } = {}; + private buttonState: { [buttonId: string]: boolean } = {}; /** * Selected button's type. */ @@ -142,13 +142,13 @@ export class ProjectSourceSelectorController { */ updateData({buttonState, buttonType, template = null}: { buttonState: boolean, buttonType: ButtonType, template?: che.IProjectTemplate }): void { - const buttonValue = template + const buttonId = template ? template.name : ButtonType[ButtonType.ADD_PROJECT]; // leave only one selected button - this.buttonValues = { - [buttonValue]: true + this.buttonState = { + [buttonId]: true }; if (!buttonState) { diff --git a/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.html b/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.html index 10e13164f9..a46f16f1e8 100644 --- a/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.html +++ b/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.html @@ -8,14 +8,13 @@ che-font-icon="material-design icon-ic_add_24px" che-on-change="projectSourceSelectorController.updateData({buttonState: state, buttonType: projectSourceSelectorController.buttonType.ADD_PROJECT})" ng-init="projectSourceSelectorController.selectedButtonType = projectSourceSelectorController.buttonType.ADD_PROJECT" - che-value="projectSourceSelectorController.buttonValues['ADD_PROJECT']"> + che-state="projectSourceSelectorController.buttonState['ADD_PROJECT']"> diff --git a/dashboard/src/app/workspaces/create-workspace/stack-selector/stack-library-filter/che-stack-library-filter.directive.ts b/dashboard/src/app/workspaces/create-workspace/stack-selector/stack-library-filter/che-stack-library-filter.directive.ts index 70848bac31..e3fc29af78 100644 --- a/dashboard/src/app/workspaces/create-workspace/stack-selector/stack-library-filter/che-stack-library-filter.directive.ts +++ b/dashboard/src/app/workspaces/create-workspace/stack-selector/stack-library-filter/che-stack-library-filter.directive.ts @@ -48,7 +48,7 @@ export class CheStackLibraryFilter implements ng.IDirective { }; // select suggestion by keys - $element.bind('keypress keydown', (event: any) => { + $element.on('keypress keydown', (event: any) => { if (event.which === 38) { // on press 'up' // select prev suggestion @@ -71,5 +71,15 @@ export class CheStackLibraryFilter implements ng.IDirective { ctrl.selectSuggestion(ctrl.selectedIndex); } }); + + // select suggestion by mouse click + $element.on('click', 'md-chip', (event: any) => { + const suggestions = ctrl.suggestions.map((suggestion: string) => { + return suggestion.toLowerCase(); + }); + const suggestionText = angular.element(event.currentTarget).find('.stack-library-filter-suggestion-text').text().toLowerCase(); + ctrl.selectedIndex = suggestions.indexOf(suggestionText); + ctrl.selectSuggestion(ctrl.selectedIndex); + }); } } diff --git a/dashboard/src/app/workspaces/create-workspace/stack-selector/stack-library-filter/che-stack-library-filter.html b/dashboard/src/app/workspaces/create-workspace/stack-selector/stack-library-filter/che-stack-library-filter.html index 3b63cef032..7d91e60be0 100644 --- a/dashboard/src/app/workspaces/create-workspace/stack-selector/stack-library-filter/che-stack-library-filter.html +++ b/dashboard/src/app/workspaces/create-workspace/stack-selector/stack-library-filter/che-stack-library-filter.html @@ -35,8 +35,10 @@ class="stack-library-filter-suggestions" readonly="true"> -
{{$chip | uppercase}}
-
+
{{$chip | uppercase}}
+
diff --git a/dashboard/src/app/workspaces/create-workspace/stack-selector/stack-selector.html b/dashboard/src/app/workspaces/create-workspace/stack-selector/stack-selector.html index 71fe709309..b4e31e9ea2 100644 --- a/dashboard/src/app/workspaces/create-workspace/stack-selector/stack-selector.html +++ b/dashboard/src/app/workspaces/create-workspace/stack-selector/stack-selector.html @@ -27,7 +27,9 @@ layout="row" layout-align="start center" layout-align-gt-md="end center"> + button-font-icon="fa fa-sliders" + che-popover-trigger-outside-click="true" + ng-class="{'stack-selector-active-tags-filter': stackSelectorController.selectedTags.length}"> diff --git a/dashboard/src/app/workspaces/create-workspace/stack-selector/stack-selector.styl b/dashboard/src/app/workspaces/create-workspace/stack-selector/stack-selector.styl index 30a74a28c8..b425474cd7 100644 --- a/dashboard/src/app/workspaces/create-workspace/stack-selector/stack-selector.styl +++ b/dashboard/src/app/workspaces/create-workspace/stack-selector/stack-selector.styl @@ -2,6 +2,9 @@ $stack-selector-list-header-border = lighten($very-light-grey-color, 4%) $stack-selector-list-header-background = lighten($very-light-grey-color, 28%) + & * + outline none + .stack-selector-buttons-right & > * margin 0 @@ -19,6 +22,9 @@ md-icon font-size 28px + toggle-button-popover.stack-selector-active-tags-filter toggle-single-button md-icon + color $primary-color !important + .stack-selector-list background-color $stack-selector-list-header-background border-top 1px solid $stack-selector-list-header-border diff --git a/dashboard/src/components/widget/popover/che-toggle-button-popover.directive.spec.ts b/dashboard/src/components/widget/popover/che-toggle-button-popover.directive.spec.ts index 8e996103a4..7c36db5fd4 100644 --- a/dashboard/src/components/widget/popover/che-toggle-button-popover.directive.spec.ts +++ b/dashboard/src/components/widget/popover/che-toggle-button-popover.directive.spec.ts @@ -16,7 +16,7 @@ interface ITestScope extends ng.IRootScopeService { } /** - * Test of the WorkspaceRecipeImport + * Test of the CheToggleButtonPopover directive. * @author Oleksii Kurinnyi */ describe('CheToggleButtonPopover >', () => { @@ -50,10 +50,9 @@ describe('CheToggleButtonPopover >', () => { httpBackend.when('OPTIONS', '/api/').respond({}); $rootScope.model = { - popoverButtonTitle: 'Popover Button Title', - initialState: false, - value: false, - popoverContent: 'Simple popover content', + title: 'Popover Button Title', + state: false, + content: 'Simple popover content', onChange: (state: boolean) => { /* tslint:disable */ const newState = state; @@ -63,14 +62,17 @@ describe('CheToggleButtonPopover >', () => { })); + afterEach(() => { + $timeout.verifyNoPendingTasks(); + }); + function getCompiledElement() { const element = $compile(angular.element( - `
-
{{model.popoverContent}}
+
{{model.content}}
` ))($rootScope); $rootScope.$digest(); @@ -87,10 +89,16 @@ describe('CheToggleButtonPopover >', () => { }); it('should have content hidden', () => { - expect(compiledDirective.html()).not.toContain($rootScope.model.popoverContent); + // timeout should be flashed + $timeout.flush(); + + expect(compiledDirective.html()).not.toContain($rootScope.model.content); }); it('should have button disabled', () => { + // timeout should be flashed + $timeout.flush(); + expect(toggleSingleButton.get(0)).toBeTruthy(); expect(toggleSingleButton.hasClass('toggle-single-button-disabled')).toBeTruthy(); }); @@ -106,7 +114,7 @@ describe('CheToggleButtonPopover >', () => { // timeout should be flashed to get callback called and content visible $timeout.flush(); - expect(compiledDirective.html()).toContain($rootScope.model.popoverContent); + expect(compiledDirective.html()).toContain($rootScope.model.content); }); it('should enable button', () => { @@ -127,10 +135,10 @@ describe('CheToggleButtonPopover >', () => { }); - describe(`change value of button-value attribute >`, () => { + describe(`change state of toggle button from outside of directive >`, () => { beforeEach(() => { - $rootScope.model.value = true; + $rootScope.model.state = true; $rootScope.$digest(); }); @@ -138,7 +146,7 @@ describe('CheToggleButtonPopover >', () => { // timeout should be flashed to get callback called and content visible $timeout.flush(); - expect(compiledDirective.html()).toContain($rootScope.model.popoverContent); + expect(compiledDirective.html()).toContain($rootScope.model.content); }); it('should enable button', () => { @@ -167,7 +175,7 @@ describe('CheToggleButtonPopover >', () => { let toggleSingleButton; beforeEach(() => { - $rootScope.model.initialState = true; + $rootScope.model.state = true; compiledDirective = getCompiledElement(); toggleSingleButton = compiledDirective.find('button'); @@ -176,7 +184,7 @@ describe('CheToggleButtonPopover >', () => { }); it('should have content visible', () => { - expect(compiledDirective.html()).toContain($rootScope.model.popoverContent); + expect(compiledDirective.html()).toContain($rootScope.model.content); }); it('should have button enabled', () => { @@ -184,7 +192,6 @@ describe('CheToggleButtonPopover >', () => { expect(toggleSingleButton.hasClass('toggle-single-button-disabled')).toBeFalsy(); }); - describe('click on button >', () => { beforeEach(() => { @@ -193,14 +200,16 @@ describe('CheToggleButtonPopover >', () => { }); it('should make content hidden', () => { - // timeout should be flashed to get callback called and content visible + // timeout should be flashed to get callback called and content hidden + $timeout.flush(); $timeout.flush(); - expect(compiledDirective.html()).not.toContain($rootScope.model.popoverContent); + expect(compiledDirective.html()).not.toContain($rootScope.model.content); }); it('should disable button', () => { - // timeout should be flashed to get callback called and content visible + // timeout should be flashed to get callback called and content hidden + $timeout.flush(); $timeout.flush(); expect(toggleSingleButton.hasClass('toggle-single-button-disabled')).toBeTruthy(); @@ -209,7 +218,8 @@ describe('CheToggleButtonPopover >', () => { it('should call the callback', () => { spyOn($rootScope.model, 'onChange'); - // timeout should be flashed to get callback called and content visible + // timeout should be flashed to get callback called and content hidden + $timeout.flush(); $timeout.flush(); expect($rootScope.model.onChange).toHaveBeenCalledWith(false); @@ -217,23 +227,24 @@ describe('CheToggleButtonPopover >', () => { }); - describe(`change value of button-value attribute >`, () => { + describe(`change state of toggle button from outside of directive >`, () => { beforeEach(() => { - $rootScope.model.value = false; + $rootScope.model.state = false; $rootScope.$digest(); }); it('should make content hidden', () => { - // timeout should be flashed to get callback called and content visible + // timeout should be flashed to get callback called and content hidden $timeout.flush(); $timeout.flush(); - expect(compiledDirective.html()).not.toContain($rootScope.model.popoverContent); + expect(compiledDirective.html()).not.toContain($rootScope.model.content); }); it('should disable button', () => { - // timeout should be flashed to get callback called and content visible + // timeout should be flashed to get callback called and content hidden + $timeout.flush(); $timeout.flush(); expect(toggleSingleButton.hasClass('toggle-single-button-disabled')).toBeTruthy(); @@ -242,7 +253,8 @@ describe('CheToggleButtonPopover >', () => { it('should call the callback', () => { spyOn($rootScope.model, 'onChange'); - // timeout should be flashed to get callback called and content visible + // timeout should be flashed to get callback called and content hidden + $timeout.flush(); $timeout.flush(); expect($rootScope.model.onChange).toHaveBeenCalledWith(false); diff --git a/dashboard/src/components/widget/popover/che-toggle-button-popover.directive.ts b/dashboard/src/components/widget/popover/che-toggle-button-popover.directive.ts index 93a9b80649..8e85bddfb8 100644 --- a/dashboard/src/components/widget/popover/che-toggle-button-popover.directive.ts +++ b/dashboard/src/components/widget/popover/che-toggle-button-popover.directive.ts @@ -10,22 +10,13 @@ */ 'use strict'; -interface IPopoverAttrs extends ng.IAttributes { - buttonTitle: string; - buttonFontIcon: string; - buttonOnChange: string; - buttonState?: string; - buttonValue?: boolean; - chePopoverTitle?: string; - chePopoverPlacement?: string; -} - interface IPopoverScope extends ng.IScope { onChange: Function; isOpenPopover: boolean; - buttonInitState?: boolean; + buttonState?: boolean; buttonOnChange?: Function; buttonOnReset?: Function; + chePopoverTriggerOutsideClick?: boolean; } /** @@ -40,14 +31,14 @@ interface IPopoverScope extends ng.IScope { * * @param {string} button-title button's title * @param {string} button-font-icon button's icon CSS class - * @param {expression=} button-state expression which defines initial state of button. + * @param {expression=} button-state expression which defines state of button. * @param {Function} button-on-change callback on model change - * @param {boolean} button-value button's state * @param {string=} che-popover-title popover's title * @param {string=} che-popover-placement popover's placement + * @param {expression=} che-popover-close-outside-click if true then click outside of popover will close the it * @usage *
My popover
* * @author Oleksii Orel @@ -59,10 +50,10 @@ export class CheToggleButtonPopover implements ng.IDirective { buttonTitle: '@', buttonFontIcon: '@', buttonOnChange: '&?buttonOnChange', - buttonInitState: '=?buttonState', - buttonValue: '=?', + buttonState: '=?buttonState', chePopoverTitle: '@?', - chePopoverPlacement: '@?' + chePopoverPlacement: '@?', + chePopoverTriggerOutsideClick: '=?' }; private $timeout: ng.ITimeoutService; @@ -83,15 +74,15 @@ export class CheToggleButtonPopover implements ng.IDirective { return ``; } - link($scope: IPopoverScope, $element: ng.IAugmentedJQuery, $attrs: IPopoverAttrs, ctrl: any, $transclude: ng.ITranscludeFunction): void { + link($scope: IPopoverScope, $element: ng.IAugmentedJQuery, $attrs: ng.IAttributes, ctrl: any, $transclude: ng.ITranscludeFunction): void { $scope.onChange = (state: boolean) => { this.$timeout(() => { @@ -109,5 +100,32 @@ export class CheToggleButtonPopover implements ng.IDirective { }); }; + if (!$scope.buttonState) { + $scope.buttonState = false; + } + $scope.onChange($scope.buttonState); + + // close popover on Esc is pressed + $element.attr('tabindex', 0); + $element.on('keypress keydown', (event: any) => { + if (event.which === 27) { + // on press 'esc' + $scope.$apply(() => { + $scope.buttonState = false; + }); + } + }); + + if ($scope.chePopoverTriggerOutsideClick) { + // update toggle single button state after popover is closed by outside click + const watcher = $scope.$watch(() => { return $scope.isOpenPopover; }, (newVal: boolean) => { + $scope.buttonState = newVal; + }); + $scope.$on('$destroy', () => { + watcher(); + }); + } + } + } diff --git a/dashboard/src/components/widget/toggle-button/toggle-single-button.directive.spec.ts b/dashboard/src/components/widget/toggle-button/toggle-single-button.directive.spec.ts new file mode 100644 index 0000000000..dca99e3058 --- /dev/null +++ b/dashboard/src/components/widget/toggle-button/toggle-single-button.directive.spec.ts @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2015-2017 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 + */ + +import {CheHttpBackend} from '../../api/test/che-http-backend'; + +interface ITestScope extends ng.IRootScopeService { + model?: any; +} + +/** + * Test of the ToggleSingleButton directive. + * @author Oleksii Kurinnyi + */ +describe('ToggleSingleButton >', () => { + + let $rootScope: ITestScope, + $timeout: ng.ITimeoutService, + $compile: ng.ICompileService, + compiledDirective: ng.IAugmentedJQuery; + + /** + * Backend for handling http operations + */ + let httpBackend: ng.IHttpBackendService; + + /** + * setup module + */ + beforeEach(angular.mock.module('userDashboard')); + + beforeEach(inject((_$timeout_: ng.ITimeoutService, + _$compile_: ng.ICompileService, + _$rootScope_: ng.IRootScopeService, + cheHttpBackend: CheHttpBackend) => { + $rootScope = _$rootScope_.$new(); + $timeout = _$timeout_; + $compile = _$compile_; + + httpBackend = cheHttpBackend.getHttpBackend(); + // avoid tracking requests from branding controller + httpBackend.whenGET(/.*/).respond(200, ''); + httpBackend.when('OPTIONS', '/api/').respond({}); + + $rootScope.model = { + title: 'Toggle Single Button Title', + state: false, + onChange: (state: boolean) => { + /* tslint:disable */ + const newState = state; + /* tslint:enable */ + } + }; + + })); + + afterEach(() => { + $timeout.verifyNoPendingTasks(); + }); + + function getCompiledElement() { + const element = $compile(angular.element( + `
+
` + ))($rootScope); + $rootScope.$digest(); + return element; + } + + describe('initially switched off > ', () => { + + let toggleSingleButton; + + beforeEach(() => { + compiledDirective = getCompiledElement(); + toggleSingleButton = compiledDirective.find('button'); + }); + + it('should have button disabled', () => { + // timeout should be flashed + $timeout.flush(); + + expect(toggleSingleButton.get(0)).toBeTruthy(); + expect(toggleSingleButton.hasClass('toggle-single-button-disabled')).toBeTruthy(); + }); + + describe('click on button >', () => { + + it('should enable button', () => { + toggleSingleButton.click(); + $rootScope.$digest(); + + // timeout should be flashed to get callback called and content visible + $timeout.flush(); + + expect(toggleSingleButton.hasClass('toggle-single-button-disabled')).toBeFalsy(); + }); + + it('should call the callback', () => { + spyOn($rootScope.model, 'onChange'); + + toggleSingleButton.click(); + $rootScope.$digest(); + + // timeout should be flashed to get callback called and content visible + $timeout.flush(); + + expect($rootScope.model.onChange).toHaveBeenCalledWith(true); + }); + + }); + + describe(`change state of toggle button from outside of directive >`, () => { + + it('should enable button', () => { + $rootScope.model.state = true; + $rootScope.$digest(); + + // timeout should be flashed to get callback called and content visible + $timeout.flush(); + + expect(toggleSingleButton.hasClass('toggle-single-button-disabled')).toBeFalsy(); + }); + + it('should call the callback', () => { + spyOn($rootScope.model, 'onChange'); + + $rootScope.model.state = true; + $rootScope.$digest(); + + // timeout should be flashed to get callback called and content visible + $timeout.flush(); + + expect($rootScope.model.onChange).toHaveBeenCalledWith(true); + }); + + }); + + }); + + describe('initially switched on >', () => { + let toggleSingleButton; + + beforeEach(() => { + $rootScope.model.state = true; + + compiledDirective = getCompiledElement(); + toggleSingleButton = compiledDirective.find('button'); + + $timeout.flush(); + }); + + it('should have button enabled', () => { + expect(toggleSingleButton.get(0)).toBeTruthy(); + expect(toggleSingleButton.hasClass('toggle-single-button-disabled')).toBeFalsy(); + }); + + describe('click on button >', () => { + + it('should disable button', () => { + toggleSingleButton.click(); + $rootScope.$digest(); + + expect(toggleSingleButton.hasClass('toggle-single-button-disabled')).toBeTruthy(); + }); + + it('should call the callback', () => { + spyOn($rootScope.model, 'onChange'); + + toggleSingleButton.click(); + $rootScope.$digest(); + + expect($rootScope.model.onChange).toHaveBeenCalledWith(false); + }); + + }); + + describe(`change state of toggle button from outside of directive >`, () => { + + it('should disable button', () => { + $rootScope.model.state = false; + $rootScope.$digest(); + + expect(toggleSingleButton.hasClass('toggle-single-button-disabled')).toBeTruthy(); + }); + + it('should call the callback', () => { + spyOn($rootScope.model, 'onChange'); + + $rootScope.model.state = false; + $rootScope.$digest(); + + expect($rootScope.model.onChange).toHaveBeenCalledWith(false); + }); + + }); + + }); + +}); diff --git a/dashboard/src/components/widget/toggle-button/toggle-single-button.directive.ts b/dashboard/src/components/widget/toggle-button/toggle-single-button.directive.ts index 446ec324ed..b13ad5de1c 100644 --- a/dashboard/src/components/widget/toggle-button/toggle-single-button.directive.ts +++ b/dashboard/src/components/widget/toggle-button/toggle-single-button.directive.ts @@ -23,7 +23,7 @@ * @param {string} che-title button's title * @param {expression=} che-multiline-title allows multi line title if attr exists * @param {string=} che-font-icon button's icon CSS class - * @param {expression=} che-state expression which defines initial state of button. + * @param {expression=} che-state expression which defines state of button. * @param {Function} che-on-change callback on model change * @usage * void; onChange: (data: {state: boolean}) => void; + multilineTitle?: string; } /** @@ -59,31 +64,28 @@ export class ToggleSingleButton { constructor() { // scope values this.scope = { - init: '=?cheState', - state: '=?cheValue', + state: '=?cheState', title: '@cheTitle', multilineTitle: '=?cheMultilineTitle', fontIcon: '@?cheFontIcon', - onChange: '&cheOnChange' + onChange: '&?cheOnChange' }; } - link($scope: IToggleSingleButtonScope, $element: ng.IAugmentedJQuery, $attrs: ng.IAttributes): void { + link($scope: IToggleSingleButtonScope, $element: ng.IAugmentedJQuery, $attrs: IToggleSingleButtonAttrs): void { + if (angular.isDefined($attrs.cheMultilineTitle)) { $scope.multilineTitle = 'true'; } - if ($scope.init) { - $scope.state = $scope.init; - $scope.onChange({state: true}); - } const watcher = $scope.$watch(() => { return $scope.state; }, (newValue: boolean, oldValue: boolean) => { if (newValue === oldValue) { return; } - $scope.onChange({state: newValue}); + $scope.onChange({state: $scope.state}); }); + $scope.$on('$destroy', () => { watcher(); }); diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/annotation/AnnotationModel.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/annotation/AnnotationModel.java index b73a76f889..0b0fa4a0a3 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/annotation/AnnotationModel.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/annotation/AnnotationModel.java @@ -15,7 +15,7 @@ import java.util.Map; import org.eclipse.che.ide.api.editor.text.Position; import org.eclipse.che.ide.api.editor.text.annotation.Annotation; -import org.eclipse.che.ide.api.editor.events.DocumentChangeHandler; +import org.eclipse.che.ide.api.editor.events.DocumentChangedHandler; import org.eclipse.che.ide.api.editor.document.UseDocumentHandle; /** @@ -33,7 +33,7 @@ import org.eclipse.che.ide.api.editor.document.UseDocumentHandle; * using the callback. * */ -public interface AnnotationModel extends UseDocumentHandle, DocumentChangeHandler, QueryAnnotationsHandler { +public interface AnnotationModel extends UseDocumentHandle, DocumentChangedHandler, QueryAnnotationsHandler { /** diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/annotation/AnnotationModelImpl.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/annotation/AnnotationModelImpl.java index d268427029..388bb6cf3c 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/annotation/AnnotationModelImpl.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/annotation/AnnotationModelImpl.java @@ -13,7 +13,7 @@ package org.eclipse.che.ide.api.editor.annotation; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import org.eclipse.che.ide.api.editor.document.DocumentHandle; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; +import org.eclipse.che.ide.api.editor.events.DocumentChangedEvent; import org.eclipse.che.ide.api.editor.partition.DocumentPositionMap; import org.eclipse.che.ide.api.editor.text.BadLocationException; import org.eclipse.che.ide.api.editor.text.BadPositionCategoryException; @@ -261,7 +261,7 @@ public class AnnotationModelImpl implements AnnotationModel { } @Override - public void onDocumentChange(final DocumentChangeEvent event) { + public void onDocumentChanged(final DocumentChangedEvent event) { this.documentChanged = true; } diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/autosave/AutoSaveMode.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/autosave/AutoSaveMode.java index 00d26f1182..85346c1a62 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/autosave/AutoSaveMode.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/autosave/AutoSaveMode.java @@ -11,7 +11,7 @@ package org.eclipse.che.ide.api.editor.autosave; import org.eclipse.che.ide.api.editor.document.UseDocumentHandle; -import org.eclipse.che.ide.api.editor.events.DocumentChangeHandler; +import org.eclipse.che.ide.api.editor.events.DocumentChangedHandler; import org.eclipse.che.ide.api.editor.texteditor.TextEditor; /** @@ -19,7 +19,7 @@ import org.eclipse.che.ide.api.editor.texteditor.TextEditor; * * @author Roman Nikitenko */ -public interface AutoSaveMode extends DocumentChangeHandler, UseDocumentHandle { +public interface AutoSaveMode extends DocumentChangedHandler, UseDocumentHandle { /** * Installs auto save mode on the given editor. diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangeEvent.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangedEvent.java similarity index 77% rename from ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangeEvent.java rename to ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangedEvent.java index 67374dde46..e89c561a12 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangeEvent.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangedEvent.java @@ -13,10 +13,10 @@ package org.eclipse.che.ide.api.editor.events; import org.eclipse.che.ide.api.editor.document.DocumentHandle; import com.google.gwt.event.shared.GwtEvent; -public class DocumentChangeEvent extends GwtEvent { +public class DocumentChangedEvent extends GwtEvent { /** The type instance for this event. */ - public static final Type TYPE = new Type<>(); + public static final Type TYPE = new Type<>(); /** The document handle */ private final DocumentHandle document; @@ -32,7 +32,7 @@ public class DocumentChangeEvent extends GwtEvent { private final int removedCharCount; - public DocumentChangeEvent(final DocumentHandle document, final int offset, final int length, final String text, int removedCharCount) { + public DocumentChangedEvent(final DocumentHandle document, final int offset, final int length, final String text, int removedCharCount) { this.offset = offset; this.length = length; this.text = text; @@ -41,13 +41,13 @@ public class DocumentChangeEvent extends GwtEvent { } @Override - public Type getAssociatedType() { + public Type getAssociatedType() { return TYPE; } @Override - protected void dispatch(final DocumentChangeHandler handler) { - handler.onDocumentChange(this); + protected void dispatch(final DocumentChangedHandler handler) { + handler.onDocumentChanged(this); } public int getOffset() { diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangeHandler.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangedHandler.java similarity index 83% rename from ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangeHandler.java rename to ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangedHandler.java index 0753d5f110..2df251a1c3 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangeHandler.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangedHandler.java @@ -12,7 +12,7 @@ package org.eclipse.che.ide.api.editor.events; import com.google.gwt.event.shared.EventHandler; -public interface DocumentChangeHandler extends EventHandler { +public interface DocumentChangedHandler extends EventHandler { - void onDocumentChange(DocumentChangeEvent event); + void onDocumentChanged(DocumentChangedEvent event); } diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangingEvent.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangingEvent.java new file mode 100644 index 0000000000..11745cac21 --- /dev/null +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangingEvent.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2012-2017 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.events; + +import com.google.gwt.event.shared.GwtEvent; +import org.eclipse.che.ide.api.editor.document.DocumentHandle; + +public class DocumentChangingEvent extends GwtEvent { + + /** The type instance for this event. */ + public static final Type TYPE = new Type<>(); + + /** The document handle */ + private final DocumentHandle document; + + /** The document offset */ + private final int offset; + + /** Length of the replaced document text */ + private final int length; + + /** Text inserted into the document */ + private final String text; + + private final int removedCharCount; + + public DocumentChangingEvent(final DocumentHandle document, final int offset, final int length, final String text, int removedCharCount) { + this.offset = offset; + this.length = length; + this.text = text; + this.document = document; + this.removedCharCount = removedCharCount; + } + + @Override + public Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(final DocumentChangingHandler handler) { + handler.onDocumentChanging(this); + } + + public int getOffset() { + return offset; + } + + public int getLength() { + return length; + } + + public String getText() { + return text; + } + + public DocumentHandle getDocument() { + return document; + } + + public int getRemoveCharCount() { + return removedCharCount; + } +} diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangingHandler.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangingHandler.java new file mode 100644 index 0000000000..78b6bffcbd --- /dev/null +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentChangingHandler.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2012-2017 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.events; + +import com.google.gwt.event.shared.EventHandler; + +public interface DocumentChangingHandler extends EventHandler { + + void onDocumentChanging(DocumentChangingEvent event); +} diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/partition/ConstantPartitioner.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/partition/ConstantPartitioner.java index 5491cdc83a..a9965cfae9 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/partition/ConstantPartitioner.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/partition/ConstantPartitioner.java @@ -13,7 +13,7 @@ package org.eclipse.che.ide.api.editor.partition; import java.util.Collections; import java.util.List; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; +import org.eclipse.che.ide.api.editor.events.DocumentChangedEvent; import org.eclipse.che.ide.api.editor.text.TypedRegion; import org.eclipse.che.ide.api.editor.text.TypedRegionImpl; import org.eclipse.che.ide.api.editor.document.DocumentHandle; @@ -53,7 +53,7 @@ public class ConstantPartitioner implements DocumentPartitioner { } @Override - public void onDocumentChange(final DocumentChangeEvent event) { + public void onDocumentChanged(final DocumentChangedEvent event) { final int removed = event.getLength(); int added = 0; if (event.getText() != null) { diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/partition/DefaultPartitioner.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/partition/DefaultPartitioner.java index 24cdb21af9..27cee38acc 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/partition/DefaultPartitioner.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/partition/DefaultPartitioner.java @@ -14,7 +14,7 @@ import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; +import org.eclipse.che.ide.api.editor.events.DocumentChangedEvent; import org.eclipse.che.ide.api.editor.text.BadLocationException; import org.eclipse.che.ide.api.editor.text.BadPositionCategoryException; import org.eclipse.che.ide.api.editor.text.Position; @@ -87,7 +87,7 @@ public class DefaultPartitioner implements DocumentPartitioner { } @Override - public void onDocumentChange(final DocumentChangeEvent event) { + public void onDocumentChanged(final DocumentChangedEvent event) { this.scanner.setScannedString(event.getDocument().getDocument().getContents()); updatePositions(); } diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/partition/DocumentPartitioner.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/partition/DocumentPartitioner.java index 7780e9437a..5da8510fcb 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/partition/DocumentPartitioner.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/partition/DocumentPartitioner.java @@ -12,7 +12,7 @@ package org.eclipse.che.ide.api.editor.partition; import java.util.List; -import org.eclipse.che.ide.api.editor.events.DocumentChangeHandler; +import org.eclipse.che.ide.api.editor.events.DocumentChangedHandler; import org.eclipse.che.ide.api.editor.text.TypedRegion; import org.eclipse.che.ide.api.editor.document.UseDocumentHandle; @@ -21,7 +21,7 @@ import org.eclipse.che.ide.api.editor.document.UseDocumentHandle; * Partitioners parse a document and splits it in partitions, which are contiguous zones of text * of a specific type (for example comment, literal string, code etc.). */ -public interface DocumentPartitioner extends DocumentChangeHandler, UseDocumentHandle { +public interface DocumentPartitioner extends DocumentChangedHandler, UseDocumentHandle { /** The identifier of the default partition content type. */ String DEFAULT_CONTENT_TYPE = "__dftl_partition_content_type"; diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/reconciler/DefaultReconciler.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/reconciler/DefaultReconciler.java index bf9359f0bc..c725df927b 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/reconciler/DefaultReconciler.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/reconciler/DefaultReconciler.java @@ -15,7 +15,7 @@ import com.google.inject.assistedinject.AssistedInject; import org.eclipse.che.ide.api.editor.document.Document; import org.eclipse.che.ide.api.editor.document.DocumentHandle; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; +import org.eclipse.che.ide.api.editor.events.DocumentChangedEvent; import org.eclipse.che.ide.api.editor.partition.DocumentPartitioner; import org.eclipse.che.ide.api.editor.texteditor.TextEditor; @@ -72,7 +72,7 @@ public class DefaultReconciler implements Reconciler { } @Override - public void onDocumentChange(final DocumentChangeEvent event) { + public void onDocumentChanged(final DocumentChangedEvent event) { } @Override diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/reconciler/Reconciler.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/reconciler/Reconciler.java index d648e086da..d340e52c28 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/reconciler/Reconciler.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/reconciler/Reconciler.java @@ -11,7 +11,7 @@ package org.eclipse.che.ide.api.editor.reconciler; import org.eclipse.che.ide.api.editor.document.UseDocumentHandle; -import org.eclipse.che.ide.api.editor.events.DocumentChangeHandler; +import org.eclipse.che.ide.api.editor.events.DocumentChangedHandler; import org.eclipse.che.ide.api.editor.texteditor.TextEditor; /** @@ -21,7 +21,7 @@ import org.eclipse.che.ide.api.editor.texteditor.TextEditor; * * @author Evgen Vidolob */ -public interface Reconciler extends UseDocumentHandle, DocumentChangeHandler { +public interface Reconciler extends UseDocumentHandle, DocumentChangedHandler { /** * Installs the reconciler on the given text view. After this method has been finished, the reconciler is operational, i.e., it works diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/reconciler/ReconcilerWithAutoSave.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/reconciler/ReconcilerWithAutoSave.java index 6d4f509813..a931e4944f 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/reconciler/ReconcilerWithAutoSave.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/reconciler/ReconcilerWithAutoSave.java @@ -18,7 +18,7 @@ import com.google.inject.assistedinject.AssistedInject; import org.eclipse.che.ide.api.editor.EditorInput; import org.eclipse.che.ide.api.editor.document.Document; import org.eclipse.che.ide.api.editor.document.DocumentHandle; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; +import org.eclipse.che.ide.api.editor.events.DocumentChangedEvent; import org.eclipse.che.ide.api.editor.partition.DocumentPartitioner; import org.eclipse.che.ide.api.editor.text.Region; import org.eclipse.che.ide.api.editor.text.RegionImpl; @@ -177,7 +177,7 @@ public class ReconcilerWithAutoSave implements Reconciler { * * @param event the document event for which to create a dirty region */ - private void createDirtyRegion(final DocumentChangeEvent event) { + private void createDirtyRegion(final DocumentChangedEvent event) { if (event.getLength() == 0 && event.getText() != null) { // Insert dirtyRegionQueue.addDirtyRegion(new DirtyRegion(event.getOffset(), @@ -221,7 +221,7 @@ public class ReconcilerWithAutoSave implements Reconciler { } @Override - public void onDocumentChange(final DocumentChangeEvent event) { + public void onDocumentChanged(final DocumentChangedEvent event) { if (documentHandle == null || !documentHandle.isSameAs(event.getDocument())) { return; } diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/EditorWidget.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/EditorWidget.java index 396c09cd79..0f0aa1e855 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/EditorWidget.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/EditorWidget.java @@ -17,7 +17,7 @@ import com.google.gwt.event.dom.client.HasFocusHandlers; import com.google.gwt.user.client.ui.IsWidget; import com.google.gwt.user.client.ui.RequiresResize; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; +import org.eclipse.che.ide.api.editor.events.DocumentChangedEvent; import org.eclipse.che.ide.api.editor.text.Region; import org.eclipse.che.ide.api.hotkeys.HotKeyItem; import org.eclipse.che.ide.api.editor.codeassist.AdditionalInfoCallback; @@ -56,7 +56,7 @@ public interface EditorWidget extends IsWidget, /** * Sets the content of the editor.
- * The operation must send a {@link DocumentChangeEvent} on the document private event bus. + * The operation must send a {@link DocumentChangedEvent} on the document private event bus. * * @param newValue * the new contents diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/EditorAgentImpl.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/EditorAgentImpl.java index 20bd1e7a42..a05f271aaa 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/EditorAgentImpl.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/EditorAgentImpl.java @@ -286,7 +286,9 @@ public class EditorAgentImpl implements EditorAgent, editor.addCloseHandler(this); workspaceAgent.openPart(editor, EDITING, constraints); - finalizeInit(file, callback, editor, editorProvider); + finalizeInit(file, callback, editor, editorProvider).then(arg -> { + workspaceAgent.setActivePart(editor); + }); } private Promise finalizeInit(final VirtualFile file, @@ -297,7 +299,6 @@ public class EditorAgentImpl implements EditorAgent, openedEditors.add(editor); openedEditorsToProviders.put(editor, editorProvider.getId()); - workspaceAgent.setActivePart(editor); editor.addPropertyListener((source, propId) -> { if (propId == EditorPartPresenter.PROP_INPUT) { promiseCallback.onSuccess(null); diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/autosave/AutoSaveModeImpl.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/autosave/AutoSaveModeImpl.java index 276eda4b19..78564059cb 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/autosave/AutoSaveModeImpl.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/autosave/AutoSaveModeImpl.java @@ -20,7 +20,7 @@ import org.eclipse.che.ide.api.editor.EditorOpenedEventHandler; import org.eclipse.che.ide.api.editor.EditorPartPresenter; import org.eclipse.che.ide.api.editor.autosave.AutoSaveMode; import org.eclipse.che.ide.api.editor.document.DocumentHandle; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; +import org.eclipse.che.ide.api.editor.events.DocumentChangedEvent; import org.eclipse.che.ide.api.editor.reconciler.DirtyRegion; import org.eclipse.che.ide.api.editor.reconciler.DirtyRegionQueue; import org.eclipse.che.ide.api.editor.texteditor.TextEditor; @@ -156,13 +156,13 @@ public class AutoSaveModeImpl implements AutoSaveMode, EditorSettingsChangedHand public void onEditorOpened(EditorOpenedEvent editorOpenedEvent) { if (documentHandle != null && editor == editorOpenedEvent.getEditor()) { HandlerRegistration documentChangeHandlerRegistration = - documentHandle.getDocEventBus().addHandler(DocumentChangeEvent.TYPE, this); + documentHandle.getDocEventBus().addHandler(DocumentChangedEvent.TYPE, this); handlerRegistrations.add(documentChangeHandlerRegistration); } } @Override - public void onDocumentChange(final DocumentChangeEvent event) { + public void onDocumentChanged(final DocumentChangedEvent event) { if (documentHandle == null || !event.getDocument().isSameAs(documentHandle)) { return; } @@ -184,7 +184,7 @@ public class AutoSaveModeImpl implements AutoSaveMode, EditorSettingsChangedHand * @param event * the document event for which to create a dirty region */ - private void createDirtyRegion(final DocumentChangeEvent event) { + private void createDirtyRegion(final DocumentChangedEvent event) { if (event.getRemoveCharCount() == 0 && event.getText() != null && !event.getText().isEmpty()) { // Insert dirtyRegionQueue.addDirtyRegion(new DirtyRegion(event.getOffset(), diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/synchronization/EditorGroupSynchronization.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/synchronization/EditorGroupSynchronization.java index 686809cea7..441b95bdea 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/synchronization/EditorGroupSynchronization.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/synchronization/EditorGroupSynchronization.java @@ -11,7 +11,7 @@ package org.eclipse.che.ide.editor.synchronization; import org.eclipse.che.ide.api.editor.EditorPartPresenter; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; +import org.eclipse.che.ide.api.editor.events.DocumentChangedEvent; import org.eclipse.che.ide.api.event.FileContentUpdateEvent; import org.eclipse.che.ide.resource.Path; @@ -19,7 +19,7 @@ import javax.validation.constraints.NotNull; import java.util.Set; /** - * Contains list of opened files with the same {@link Path} and listens to {@link DocumentChangeEvent} and {@link FileContentUpdateEvent} + * Contains list of opened files with the same {@link Path} and listens to {@link DocumentChangedEvent} and {@link FileContentUpdateEvent} * to provide the synchronization of the content for them. * * @author Roman Nikitenko diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/synchronization/EditorGroupSynchronizationImpl.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/synchronization/EditorGroupSynchronizationImpl.java index 9ee5ed02b7..2391fec6c6 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/synchronization/EditorGroupSynchronizationImpl.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/synchronization/EditorGroupSynchronizationImpl.java @@ -20,8 +20,8 @@ import org.eclipse.che.ide.api.editor.EditorWithAutoSave; import org.eclipse.che.ide.api.editor.document.Document; import org.eclipse.che.ide.api.editor.document.DocumentHandle; import org.eclipse.che.ide.api.editor.document.DocumentStorage; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; -import org.eclipse.che.ide.api.editor.events.DocumentChangeHandler; +import org.eclipse.che.ide.api.editor.events.DocumentChangedEvent; +import org.eclipse.che.ide.api.editor.events.DocumentChangedHandler; import org.eclipse.che.ide.api.editor.text.TextPosition; import org.eclipse.che.ide.api.editor.texteditor.TextEditor; import org.eclipse.che.ide.api.event.FileContentUpdateEvent; @@ -41,7 +41,7 @@ import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMod import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL; import static org.eclipse.che.ide.api.notification.StatusNotification.Status.SUCCESS; -public class EditorGroupSynchronizationImpl implements EditorGroupSynchronization, DocumentChangeHandler, FileContentUpdateHandler { +public class EditorGroupSynchronizationImpl implements EditorGroupSynchronization, DocumentChangedHandler, FileContentUpdateHandler { private final DocumentStorage documentStorage; private final NotificationManager notificationManager; private final HandlerRegistration fileContentUpdateHandlerRegistration; @@ -66,7 +66,7 @@ public class EditorGroupSynchronizationImpl implements EditorGroupSynchronizatio } if (synchronizedEditors.isEmpty()) { - HandlerRegistration handlerRegistration = documentHandle.getDocEventBus().addHandler(DocumentChangeEvent.TYPE, this); + HandlerRegistration handlerRegistration = documentHandle.getDocEventBus().addHandler(DocumentChangedEvent.TYPE, this); synchronizedEditors.put(editor, handlerRegistration); return; } @@ -83,7 +83,7 @@ public class EditorGroupSynchronizationImpl implements EditorGroupSynchronizatio editorDocument.replace(0, oldContent.length(), groupMemberContent); } - HandlerRegistration handlerRegistration = documentHandle.getDocEventBus().addHandler(DocumentChangeEvent.TYPE, this); + HandlerRegistration handlerRegistration = documentHandle.getDocEventBus().addHandler(DocumentChangedEvent.TYPE, this); synchronizedEditors.put(editor, handlerRegistration); } @@ -121,7 +121,7 @@ public class EditorGroupSynchronizationImpl implements EditorGroupSynchronizatio } @Override - public void onDocumentChange(DocumentChangeEvent event) { + public void onDocumentChanged(DocumentChangedEvent event) { DocumentHandle activeEditorDocumentHandle = getDocumentHandleFor(groupLeaderEditor); if (activeEditorDocumentHandle == null || !event.getDocument().isSameAs(activeEditorDocumentHandle)) { return; diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/project/ProjectServiceClient.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/project/ProjectServiceClient.java index 9e83a07dbe..3d448d7762 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/project/ProjectServiceClient.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/project/ProjectServiceClient.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.che.ide.project; -import com.google.gwt.http.client.URL; import com.google.inject.Inject; import org.eclipse.che.api.project.shared.dto.CopyOptions; @@ -39,6 +38,7 @@ import java.util.Map; import static com.google.common.base.Strings.isNullOrEmpty; import static com.google.gwt.http.client.RequestBuilder.DELETE; import static com.google.gwt.http.client.RequestBuilder.PUT; +import static com.google.gwt.safehtml.shared.UriUtils.encodeAllowEscapes; import static org.eclipse.che.api.promises.client.callback.AsyncPromiseHelper.createFromAsyncRequest; import static org.eclipse.che.ide.rest.HTTPHeader.ACCEPT; import static org.eclipse.che.ide.rest.HTTPHeader.CONTENT_TYPE; @@ -112,7 +112,7 @@ public class ProjectServiceClient { * @since 4.4.0 */ public Promise estimate(Path path, String pType) { - final String url = getBaseUrl() + ESTIMATE + path(path.toString()) + "?type=" + pType; + final String url = encodeAllowEscapes(getBaseUrl() + ESTIMATE + path(path.toString()) + "?type=" + pType); return reqFactory.createGetRequest(url) .header(ACCEPT, MimeType.APPLICATION_JSON) @@ -131,7 +131,7 @@ public class ProjectServiceClient { * @since 4.4.0 */ public Promise> resolveSources(Path path) { - final String url = getBaseUrl() + RESOLVE + path(path.toString()); + final String url = encodeAllowEscapes(getBaseUrl() + RESOLVE + path(path.toString())); return reqFactory.createGetRequest(url) .header(ACCEPT, MimeType.APPLICATION_JSON) @@ -154,8 +154,8 @@ public class ProjectServiceClient { public Promise importProject(final Path path, final SourceStorageDto source) { return createFromAsyncRequest(callback -> { - final String url = PROJECT + IMPORT + path(path.toString()); // TODO (spi ide): must be reworked with JSON-RPC +// final String url = encodeAllowEscapes(PROJECT + IMPORT + path(path.toString())); // final Message message = new MessageBuilder(POST, url).data(dtoFactory.toJson(source)) // .header(CONTENTTYPE, APPLICATION_JSON) // .build(); @@ -193,7 +193,8 @@ public class ProjectServiceClient { * @since 4.4.0 */ public Promise> search(QueryExpression expression) { - final String url = getBaseUrl() + SEARCH + (isNullOrEmpty(expression.getPath()) ? Path.ROOT : path(expression.getPath())); + final String url = + encodeAllowEscapes(getBaseUrl() + SEARCH + (isNullOrEmpty(expression.getPath()) ? Path.ROOT : path(expression.getPath()))); StringBuilder queryParameters = new StringBuilder(); if (expression.getName() != null && !expression.getName().isEmpty()) { @@ -254,7 +255,7 @@ public class ProjectServiceClient { * @see ProjectConfigDto */ public Promise> createBatchProjects(List configurations) { - final String url = getBaseUrl() + BATCH_PROJECTS; + final String url = encodeAllowEscapes(getBaseUrl() + BATCH_PROJECTS); final String loaderMessage = configurations.size() > 1 ? "Creating the batch of projects..." : "Creating project..."; return reqFactory.createPostRequest(url, configurations) .header(ACCEPT, MimeType.APPLICATION_JSON) @@ -275,7 +276,7 @@ public class ProjectServiceClient { * @since 4.4.0 */ public Promise createFile(Path path, String content) { - final String url = getBaseUrl() + FILE + path(path.parent().toString()) + "?name=" + URL.encodeQueryString(path.lastSegment()); + final String url = encodeAllowEscapes(getBaseUrl() + FILE + path(path.parent().toString()) + "?name=" + path.lastSegment()); return reqFactory.createPostRequest(url, null) .data(content) @@ -293,7 +294,7 @@ public class ProjectServiceClient { * @since 4.4.0 */ public Promise getFileContent(Path path) { - final String url = getBaseUrl() + FILE + path(path.toString()); + final String url = encodeAllowEscapes(getBaseUrl() + FILE + path(path.toString())); return reqFactory.createGetRequest(url) .loader(loaderFactory.newLoader("Loading file content...")) @@ -312,7 +313,7 @@ public class ProjectServiceClient { * @since 4.4.0 */ public Promise setFileContent(Path path, String content) { - final String url = getBaseUrl() + FILE + path(path.toString()); + final String url = encodeAllowEscapes(getBaseUrl() + FILE + path(path.toString())); return reqFactory.createRequest(PUT, url, null, false) .data(content) @@ -331,7 +332,7 @@ public class ProjectServiceClient { * @since 4.4.0 */ public Promise createFolder(Path path) { - final String url = getBaseUrl() + FOLDER + path(path.toString()); + final String url = encodeAllowEscapes(getBaseUrl() + FOLDER + path(path.toString())); return reqFactory.createPostRequest(url, null) .loader(loaderFactory.newLoader("Creating folder...")) @@ -348,7 +349,7 @@ public class ProjectServiceClient { * @since 4.4.0 */ public Promise deleteItem(Path path) { - final String url = getBaseUrl() + path(path.toString()); + final String url = encodeAllowEscapes(getBaseUrl() + path(path.toString())); return reqFactory.createRequest(DELETE, url, null, false) .loader(loaderFactory.newLoader("Deleting project...")) @@ -371,7 +372,7 @@ public class ProjectServiceClient { * @since 4.4.0 */ public Promise copy(Path source, Path target, String newName, boolean overwrite) { - final String url = getBaseUrl() + COPY + path(source.toString()) + "?to=" + URL.encodeQueryString(target.toString()); + final String url = encodeAllowEscapes(getBaseUrl() + COPY + path(source.toString()) + "?to=" + target.toString()); final CopyOptions copyOptions = dtoFactory.createDto(CopyOptions.class); copyOptions.setName(newName); @@ -398,7 +399,7 @@ public class ProjectServiceClient { * @since 4.4.0 */ public Promise move(Path source, Path target, String newName, boolean overwrite) { - final String url = getBaseUrl() + MOVE + path(source.toString()) + "?to=" + URL.encodeQueryString(target.toString()); + final String url = encodeAllowEscapes(getBaseUrl() + MOVE + path(source.toString()) + "?to=" + target.toString()); final MoveOptions moveOptions = dtoFactory.createDto(MoveOptions.class); moveOptions.setName(newName); @@ -424,7 +425,8 @@ public class ProjectServiceClient { * @since 4.4.0 */ public Promise getTree(Path path, int depth, boolean includeFiles) { - final String url = getBaseUrl() + TREE + path(path.toString()) + "?depth=" + depth + "&includeFiles=" + includeFiles; + final String url = + encodeAllowEscapes(getBaseUrl() + TREE + path(path.toString()) + "?depth=" + depth + "&includeFiles=" + includeFiles); // temporary workaround for CHE-3467, remove loader for disable UI blocking // later this loader should be added with the new mechanism of client-server synchronization @@ -445,7 +447,7 @@ public class ProjectServiceClient { * @since 4.4.0 */ public Promise getItem(Path path) { - final String url = getBaseUrl() + ITEM + path(path.toString()); + final String url = encodeAllowEscapes(getBaseUrl() + ITEM + path(path.toString())); return reqFactory.createGetRequest(url) .header(ACCEPT, MimeType.APPLICATION_JSON) @@ -464,7 +466,7 @@ public class ProjectServiceClient { * @since 4.4.0 */ public Promise getProject(Path path) { - final String url = getBaseUrl() + path(path.toString()); + final String url = encodeAllowEscapes(getBaseUrl() + path(path.toString())); return reqFactory.createGetRequest(url) .header(ACCEPT, MimeType.APPLICATION_JSON) @@ -482,7 +484,7 @@ public class ProjectServiceClient { * @since 4.4.0 */ public Promise updateProject(ProjectConfigDto configuration) { - final String url = getBaseUrl() + path(configuration.getPath()); + final String url = encodeAllowEscapes(getBaseUrl() + path(configuration.getPath())); return reqFactory.createRequest(PUT, url, configuration, false) .header(CONTENT_TYPE, MimeType.APPLICATION_JSON) diff --git a/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/editor/synchronization/EditorGroupSynchronizationImplTest.java b/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/editor/synchronization/EditorGroupSynchronizationImplTest.java index eb7ecf4cc5..62d880e324 100644 --- a/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/editor/synchronization/EditorGroupSynchronizationImplTest.java +++ b/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/editor/synchronization/EditorGroupSynchronizationImplTest.java @@ -21,7 +21,7 @@ import org.eclipse.che.ide.api.editor.document.Document; import org.eclipse.che.ide.api.editor.document.DocumentEventBus; import org.eclipse.che.ide.api.editor.document.DocumentHandle; import org.eclipse.che.ide.api.editor.document.DocumentStorage; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; +import org.eclipse.che.ide.api.editor.events.DocumentChangedEvent; import org.eclipse.che.ide.api.editor.texteditor.TextEditor; import org.eclipse.che.ide.api.notification.NotificationManager; import org.junit.Before; @@ -64,7 +64,7 @@ public class EditorGroupSynchronizationImplTest { @Mock private HandlerRegistration handlerRegistration; @Mock - private DocumentChangeEvent documentChangeEvent; + private DocumentChangedEvent documentChangeEvent; private EditorPartPresenter activeEditor; private EditorPartPresenter openedEditor1; @@ -102,7 +102,7 @@ public class EditorGroupSynchronizationImplTest { editorGroupSynchronization.addEditor(activeEditor); - verify(documentEventBus).addHandler(Matchers.anyObject(), eq(editorGroupSynchronization)); + verify(documentEventBus).addHandler(Matchers.anyObject(), eq(editorGroupSynchronization)); } @Test @@ -118,7 +118,7 @@ public class EditorGroupSynchronizationImplTest { verify((EditorWithAutoSave)openedEditor1).isAutoSaveEnabled(); verify(document, times(2)).getContents(); verify(document).replace(anyInt(), anyInt(), anyString()); - verify(documentEventBus).addHandler(Matchers.anyObject(), eq(editorGroupSynchronization)); + verify(documentEventBus).addHandler(Matchers.anyObject(), eq(editorGroupSynchronization)); } @Test @@ -145,7 +145,7 @@ public class EditorGroupSynchronizationImplTest { when(documentChangeEvent.getDocument()).thenReturn(documentHandle1); when(documentHandle1.isSameAs(documentHandle)).thenReturn(false); - editorGroupSynchronization.onDocumentChange(documentChangeEvent); + editorGroupSynchronization.onDocumentChanged(documentChangeEvent); verify(document, never()).replace(anyInt(), anyInt(), anyString()); } @@ -163,7 +163,7 @@ public class EditorGroupSynchronizationImplTest { when(documentHandle1.isSameAs(documentHandle)).thenReturn(true); addEditorsToGroup(); - editorGroupSynchronization.onDocumentChange(documentChangeEvent); + editorGroupSynchronization.onDocumentChanged(documentChangeEvent); verify(document, times(2)).replace(eq(offset), eq(removeCharCount), eq(text)); } diff --git a/ide/che-core-ide-stacks/src/main/resources/stacks.json b/ide/che-core-ide-stacks/src/main/resources/stacks.json index 0bc9bf852b..9fffc31b96 100644 --- a/ide/che-core-ide-stacks/src/main/resources/stacks.json +++ b/ide/che-core-ide-stacks/src/main/resources/stacks.json @@ -2364,7 +2364,7 @@ "goal": "Build" } }, { - "commandLine": "cd ${current.project.path} && scl enable rh-maven33 'java -jar target/*-fat.jar'", + "commandLine": "scl enable rh-maven33 'mvn vertx:run -f ${current.project.path}'", "name": "run", "type": "custom", "attributes": { diff --git a/ide/che-core-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionDocument.java b/ide/che-core-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionDocument.java index aec1b91114..ee4dacdaf3 100644 --- a/ide/che-core-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionDocument.java +++ b/ide/che-core-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionDocument.java @@ -12,6 +12,16 @@ package org.eclipse.che.ide.editor.orion.client; import com.google.web.bindery.event.shared.HandlerRegistration; +import org.eclipse.che.ide.api.editor.document.AbstractDocument; +import org.eclipse.che.ide.api.editor.document.Document; +import org.eclipse.che.ide.api.editor.events.CursorActivityHandler; +import org.eclipse.che.ide.api.editor.events.DocumentChangedEvent; +import org.eclipse.che.ide.api.editor.events.DocumentChangingEvent; +import org.eclipse.che.ide.api.editor.events.HasCursorActivityHandlers; +import org.eclipse.che.ide.api.editor.position.PositionConverter; +import org.eclipse.che.ide.api.editor.text.LinearRange; +import org.eclipse.che.ide.api.editor.text.TextPosition; +import org.eclipse.che.ide.api.editor.text.TextRange; import org.eclipse.che.ide.api.resources.File; import org.eclipse.che.ide.api.resources.VirtualFile; import org.eclipse.che.ide.editor.orion.client.jso.ModelChangedEventOverlay; @@ -21,15 +31,6 @@ import org.eclipse.che.ide.editor.orion.client.jso.OrionSelectionOverlay; import org.eclipse.che.ide.editor.orion.client.jso.OrionTextModelOverlay; import org.eclipse.che.ide.editor.orion.client.jso.OrionTextModelOverlay.EventHandler; import org.eclipse.che.ide.editor.orion.client.jso.OrionTextViewOverlay; -import org.eclipse.che.ide.api.editor.document.AbstractDocument; -import org.eclipse.che.ide.api.editor.document.Document; -import org.eclipse.che.ide.api.editor.events.CursorActivityHandler; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; -import org.eclipse.che.ide.api.editor.events.HasCursorActivityHandlers; -import org.eclipse.che.ide.api.editor.position.PositionConverter; -import org.eclipse.che.ide.api.editor.text.LinearRange; -import org.eclipse.che.ide.api.editor.text.TextPosition; -import org.eclipse.che.ide.api.editor.text.TextRange; /** * The implementation of {@link Document} for Orion. @@ -60,6 +61,14 @@ public class OrionDocument extends AbstractDocument { fireDocumentChangeEvent(parameter); } }, true); + + this.editorOverlay.getModel().addEventListener("Changing", new EventHandler() { + @Override + public void onEvent(ModelChangedEventOverlay parameter) { + fireDocumentChangingEvent(parameter); + } + }, true); + } private void fireDocumentChangeEvent(final ModelChangedEventOverlay param) { @@ -70,15 +79,33 @@ public class OrionDocument extends AbstractDocument { String text = editorOverlay.getModel().getText(startOffset, startOffset + addedCharCount); - final DocumentChangeEvent event = new DocumentChangeEvent(this, - startOffset, - addedCharCount, - text, - removedCharCount); + final DocumentChangedEvent event = new DocumentChangedEvent(this, + startOffset, + addedCharCount, + text, + removedCharCount); // according to https://github.com/codenvy/che-core/pull/122 getDocEventBus().fireEvent(event); } + private void fireDocumentChangingEvent(final ModelChangedEventOverlay param) { + int startOffset = param.start(); + int addedCharCount = param.addedCharCount(); + int removedCharCount = param.removedCharCount(); + + + String text = editorOverlay.getModel().getText(startOffset, startOffset + addedCharCount); + + final DocumentChangingEvent event = new DocumentChangingEvent(this, + startOffset, + addedCharCount, + text, + removedCharCount); + // according to https://github.com/codenvy/che-core/pull/122 + getDocEventBus().fireEvent(event); + } + + @Override public TextPosition getPositionFromIndex(final int index) { final int line = this.editorOverlay.getModel().getLineAtOffset(index); @@ -112,12 +139,6 @@ public class OrionDocument extends AbstractDocument { return result; } - @Override - public void setCursorPosition(final TextPosition position) { - this.editorOverlay.setCaretOffset(getIndexFromPosition(position)); - - } - @Override public int getLineAtOffset(int offset) { return this.editorOverlay.getTextView().getLineAtOffset(offset); @@ -134,6 +155,12 @@ public class OrionDocument extends AbstractDocument { return getPositionFromIndex(offset); } + @Override + public void setCursorPosition(final TextPosition position) { + this.editorOverlay.setCaretOffset(getIndexFromPosition(position)); + + } + public int getCursorOffset() { return this.editorOverlay.getTextView().getCaretOffset(); } @@ -169,34 +196,6 @@ public class OrionDocument extends AbstractDocument { return this.positionConverter; } - private class OrionPositionConverter implements PositionConverter { - - @Override - public PixelCoordinates textToPixel(TextPosition textPosition) { - final int textOffset = getIndexFromPosition(textPosition); - return offsetToPixel(textOffset); - } - - @Override - public PixelCoordinates offsetToPixel(int textOffset) { - OrionPixelPositionOverlay location = textViewOverlay.getLocationAtOffset(textOffset); - location.setY(location.getY() + textViewOverlay.getLineHeight()); - location = textViewOverlay.convert(location, "document", "page"); - return new PixelCoordinates(location.getX(), location.getY()); - } - - @Override - public TextPosition pixelToText(PixelCoordinates coordinates) { - final int offset = pixelToOffset(coordinates); - return getPositionFromIndex(offset); - } - - @Override - public int pixelToOffset(PixelCoordinates coordinates) { - return textViewOverlay.getOffsetAtLocation(coordinates.getX(), coordinates.getY()); - } - } - public void replace(int offset, int length, String text) { this.editorOverlay.getModel().setText(text, offset, offset + length); updateModificationTimeStamp(); @@ -213,7 +212,7 @@ public class OrionDocument extends AbstractDocument { private void updateModificationTimeStamp() { VirtualFile file = this.getFile(); - if (file instanceof File) { + if (file instanceof File) { ((File)file).updateModificationStamp(editorOverlay.getText()); } } @@ -287,4 +286,32 @@ public class OrionDocument extends AbstractDocument { LinearRange.createWithStart(lineStart + range.getFrom().getCharacter()).andEnd(lineEnd + range.getTo().getCharacter()); setSelectedRange(linearRange, show); } + + private class OrionPositionConverter implements PositionConverter { + + @Override + public PixelCoordinates textToPixel(TextPosition textPosition) { + final int textOffset = getIndexFromPosition(textPosition); + return offsetToPixel(textOffset); + } + + @Override + public PixelCoordinates offsetToPixel(int textOffset) { + OrionPixelPositionOverlay location = textViewOverlay.getLocationAtOffset(textOffset); + location.setY(location.getY() + textViewOverlay.getLineHeight()); + location = textViewOverlay.convert(location, "document", "page"); + return new PixelCoordinates(location.getX(), location.getY()); + } + + @Override + public TextPosition pixelToText(PixelCoordinates coordinates) { + final int offset = pixelToOffset(coordinates); + return getPositionFromIndex(offset); + } + + @Override + public int pixelToOffset(PixelCoordinates coordinates) { + return textViewOverlay.getOffsetAtLocation(coordinates.getX(), coordinates.getY()); + } + } } diff --git a/ide/che-core-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorInit.java b/ide/che-core-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorInit.java index 16443e0828..b872d2a8f8 100644 --- a/ide/che-core-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorInit.java +++ b/ide/che-core-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorInit.java @@ -31,7 +31,7 @@ import org.eclipse.che.ide.api.editor.document.DocumentHandle; import org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration; import org.eclipse.che.ide.api.editor.events.CompletionRequestEvent; import org.eclipse.che.ide.api.editor.events.CompletionRequestHandler; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; +import org.eclipse.che.ide.api.editor.events.DocumentChangedEvent; import org.eclipse.che.ide.api.editor.events.TextChangeEvent; import org.eclipse.che.ide.api.editor.events.TextChangeHandler; import org.eclipse.che.ide.api.editor.formatter.ContentFormatter; @@ -143,7 +143,7 @@ public class OrionEditorInit { final DocumentPartitioner partitioner = configuration.getPartitioner(); if (partitioner != null) { partitioner.setDocumentHandle(documentHandle); - documentHandle.getDocEventBus().addHandler(DocumentChangeEvent.TYPE, partitioner); + documentHandle.getDocEventBus().addHandler(DocumentChangedEvent.TYPE, partitioner); partitioner.initialize(); } } @@ -156,7 +156,7 @@ public class OrionEditorInit { final Reconciler reconciler = configuration.getReconciler(); if (reconciler != null) { reconciler.setDocumentHandle(documentHandle); - documentHandle.getDocEventBus().addHandler(DocumentChangeEvent.TYPE, reconciler); + documentHandle.getDocEventBus().addHandler(DocumentChangedEvent.TYPE, reconciler); reconciler.install(textEditor); } } @@ -175,7 +175,7 @@ public class OrionEditorInit { ((HasAnnotationRendering)textEditor).configure(annotationModel, documentHandle); } annotationModel.setDocumentHandle(documentHandle); - documentHandle.getDocEventBus().addHandler(DocumentChangeEvent.TYPE, annotationModel); + documentHandle.getDocEventBus().addHandler(DocumentChangedEvent.TYPE, annotationModel); // the model listens to QueryAnnotation events documentHandle.getDocEventBus().addHandler(QueryAnnotationsEvent.TYPE, annotationModel); diff --git a/plugins/plugin-debugger/che-plugin-debugger-ide/src/main/java/org/eclipse/che/plugin/debugger/ide/debug/AbstractDebugger.java b/plugins/plugin-debugger/che-plugin-debugger-ide/src/main/java/org/eclipse/che/plugin/debugger/ide/debug/AbstractDebugger.java index f26c77efe1..434f055346 100644 --- a/plugins/plugin-debugger/che-plugin-debugger-ide/src/main/java/org/eclipse/che/plugin/debugger/ide/debug/AbstractDebugger.java +++ b/plugins/plugin-debugger/che-plugin-debugger-ide/src/main/java/org/eclipse/che/plugin/debugger/ide/debug/AbstractDebugger.java @@ -212,6 +212,18 @@ public abstract class AbstractDebugger implements Debugger, DebuggerObservable { } private void openCurrentFile() { + // Handle the situation when resource isn't found in the workspace + // It means that it is impossible to open it. + if (currentLocation.getResourcePath() == null) { + for (DebuggerObserver observer : observers) { + observer.onBreakpointStopped(currentLocation.getTarget(), + currentLocation.getTarget(), + currentLocation.getLineNumber()); + } + + return; + } + //todo we need add possibility to handle few files activeFileHandler.openFile(currentLocation, new AsyncCallback() { diff --git a/plugins/plugin-java-debugger/che-plugin-java-debugger-server/src/main/java/org/eclipse/che/plugin/jdb/server/JavaDebugger.java b/plugins/plugin-java-debugger/che-plugin-java-debugger-server/src/main/java/org/eclipse/che/plugin/jdb/server/JavaDebugger.java index 830d92529b..88d277697d 100644 --- a/plugins/plugin-java-debugger/che-plugin-java-debugger-server/src/main/java/org/eclipse/che/plugin/jdb/server/JavaDebugger.java +++ b/plugins/plugin-java-debugger/che-plugin-java-debugger-server/src/main/java/org/eclipse/che/plugin/jdb/server/JavaDebugger.java @@ -596,7 +596,12 @@ public class JavaDebugger implements EventsHandler, Debugger { setCurrentThread(event.thread()); com.sun.jdi.Location jdiLocation = event.location(); - Location location = debuggerUtil.getLocation(jdiLocation); + Location location; + try { + location = debuggerUtil.getLocation(jdiLocation); + } catch (DebuggerException de) { + location = new LocationImpl(jdiLocation.declaringType().name(), jdiLocation.lineNumber()); + } debuggerCallback.onEvent(new SuspendEventImpl(location)); return false; } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java index 5e0ca61b73..73ab25ca69 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java @@ -18,8 +18,8 @@ import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; import org.eclipse.che.ide.api.editor.document.Document; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; -import org.eclipse.che.ide.api.editor.events.DocumentChangeHandler; +import org.eclipse.che.ide.api.editor.events.DocumentChangedEvent; +import org.eclipse.che.ide.api.editor.events.DocumentChangedHandler; import org.eclipse.che.ide.api.editor.formatter.ContentFormatter; import org.eclipse.che.ide.api.editor.text.TextPosition; import org.eclipse.che.ide.api.editor.text.TextRange; @@ -89,9 +89,9 @@ public class LanguageServerFormatter implements ContentFormatter { this.editor = editor; if (capabilities.getDocumentOnTypeFormattingProvider() != null && capabilities.getDocumentOnTypeFormattingProvider().getFirstTriggerCharacter() != null) { - editor.getDocument().getDocumentHandle().getDocEventBus().addHandler(DocumentChangeEvent.TYPE, new DocumentChangeHandler() { + editor.getDocument().getDocumentHandle().getDocEventBus().addHandler(DocumentChangedEvent.TYPE, new DocumentChangedHandler() { @Override - public void onDocumentChange(DocumentChangeEvent event) { + public void onDocumentChanged(DocumentChangedEvent event) { if (capabilities.getDocumentOnTypeFormattingProvider().getFirstTriggerCharacter().equals(event.getText())) { Document document = event.getDocument().getDocument(); diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerReconcileStrategy.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerReconcileStrategy.java index b38094509a..9134d5bd93 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerReconcileStrategy.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerReconcileStrategy.java @@ -14,11 +14,14 @@ import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import org.eclipse.che.ide.api.editor.document.Document; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; -import org.eclipse.che.ide.api.editor.events.DocumentChangeHandler; +import org.eclipse.che.ide.api.editor.events.DocumentChangedEvent; +import org.eclipse.che.ide.api.editor.events.DocumentChangedHandler; +import org.eclipse.che.ide.api.editor.events.DocumentChangingEvent; +import org.eclipse.che.ide.api.editor.events.DocumentChangingHandler; import org.eclipse.che.ide.api.editor.reconciler.DirtyRegion; import org.eclipse.che.ide.api.editor.reconciler.ReconcilingStrategy; import org.eclipse.che.ide.api.editor.text.Region; +import org.eclipse.che.ide.api.editor.text.TextPosition; import org.eclipse.che.plugin.languageserver.ide.editor.sync.TextDocumentSynchronize; import org.eclipse.che.plugin.languageserver.ide.editor.sync.TextDocumentSynchronizeFactory; import org.eclipse.lsp4j.ServerCapabilities; @@ -35,6 +38,8 @@ public class LanguageServerReconcileStrategy implements ReconcilingStrategy { private final TextDocumentSynchronize synchronize; private int version = 0; + private TextPosition lastEventStart; + private TextPosition lastEventEnd; @Inject public LanguageServerReconcileStrategy(TextDocumentSynchronizeFactory synchronizeFactory, @@ -42,7 +47,7 @@ public class LanguageServerReconcileStrategy implements ReconcilingStrategy { Either sync = serverCapabilities.getTextDocumentSync(); TextDocumentSyncKind documentSync; - if(sync.isLeft()){ + if (sync.isLeft()) { documentSync = sync.getLeft(); } else { documentSync = sync.getRight().getChange(); @@ -53,12 +58,20 @@ public class LanguageServerReconcileStrategy implements ReconcilingStrategy { @Override public void setDocument(Document document) { - document.getDocumentHandle().getDocEventBus().addHandler(DocumentChangeEvent.TYPE, new DocumentChangeHandler() { + document.getDocumentHandle().getDocEventBus().addHandler(DocumentChangedEvent.TYPE, new DocumentChangedHandler() { @Override - public void onDocumentChange(DocumentChangeEvent event) { - synchronize.syncTextDocument(event, ++version); + public void onDocumentChanged(DocumentChangedEvent event) { + synchronize.syncTextDocument(event.getDocument().getDocument(), lastEventStart, lastEventEnd, event.getText(), ++version); } }); + document.getDocumentHandle().getDocEventBus().addHandler(DocumentChangingEvent.TYPE, new DocumentChangingHandler() { + @Override + public void onDocumentChanging(DocumentChangingEvent event) { + lastEventStart = event.getDocument().getDocument().getPositionFromIndex(event.getOffset()); + lastEventEnd = event.getDocument().getDocument().getPositionFromIndex(event.getOffset() + event.getRemoveCharCount()); + } + }); + } @Override diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/LanguageServerSignatureHelp.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/LanguageServerSignatureHelp.java index cdd0a87303..11d07c1314 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/LanguageServerSignatureHelp.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/LanguageServerSignatureHelp.java @@ -20,8 +20,8 @@ import org.eclipse.che.api.promises.client.FunctionException; import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; import org.eclipse.che.ide.api.editor.document.Document; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; -import org.eclipse.che.ide.api.editor.events.DocumentChangeHandler; +import org.eclipse.che.ide.api.editor.events.DocumentChangedEvent; +import org.eclipse.che.ide.api.editor.events.DocumentChangedHandler; import org.eclipse.che.ide.api.editor.signature.SignatureHelp; import org.eclipse.che.ide.api.editor.signature.SignatureHelpProvider; import org.eclipse.che.ide.api.editor.texteditor.HandlesTextOperations; @@ -87,9 +87,9 @@ public class LanguageServerSignatureHelp implements SignatureHelpProvider { if (capabilities.getSignatureHelpProvider() != null && capabilities.getSignatureHelpProvider().getTriggerCharacters() != null) { final List triggerCharacters = capabilities.getSignatureHelpProvider().getTriggerCharacters(); handlerRegistration = editor.getDocument().getDocumentHandle().getDocEventBus() - .addHandler(DocumentChangeEvent.TYPE, new DocumentChangeHandler() { + .addHandler(DocumentChangedEvent.TYPE, new DocumentChangedHandler() { @Override - public void onDocumentChange(DocumentChangeEvent event) { + public void onDocumentChanged(DocumentChangedEvent event) { if (triggerCharacters.contains(event.getText())) { ((HandlesTextOperations)editor) .doOperation(TextEditorOperations.SIGNATURE_HELP); diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/FullTextDocumentSynchronize.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/FullTextDocumentSynchronize.java index 8cc4d0b576..b9234bded1 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/FullTextDocumentSynchronize.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/FullTextDocumentSynchronize.java @@ -12,9 +12,8 @@ package org.eclipse.che.plugin.languageserver.ide.editor.sync; import com.google.inject.Inject; import com.google.inject.Singleton; - import org.eclipse.che.ide.api.editor.document.Document; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; +import org.eclipse.che.ide.api.editor.text.TextPosition; import org.eclipse.che.ide.dto.DtoFactory; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; import org.eclipse.lsp4j.DidChangeTextDocumentParams; @@ -41,8 +40,7 @@ class FullTextDocumentSynchronize implements TextDocumentSynchronize { } @Override - public void syncTextDocument(DocumentChangeEvent event, int version) { - Document document = event.getDocument().getDocument(); + public void syncTextDocument(Document document, TextPosition start, TextPosition end, String insertedText, int version) { DidChangeTextDocumentParams changeDTO = dtoFactory.createDto(DidChangeTextDocumentParams.class); String uri = document.getFile().getLocation().toString(); @@ -53,7 +51,7 @@ class FullTextDocumentSynchronize implements TextDocumentSynchronize { changeDTO.setTextDocument(versionedDocId); TextDocumentContentChangeEvent actualChange = dtoFactory.createDto(TextDocumentContentChangeEvent.class); - actualChange.setText(event.getDocument().getDocument().getContents()); + actualChange.setText(document.getContents()); changeDTO.setContentChanges(Collections.singletonList(actualChange)); textDocumentService.didChange(changeDTO); } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/IncrementalTextDocumentSynchronize.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/IncrementalTextDocumentSynchronize.java index 196e79104d..c81b6a9a7a 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/IncrementalTextDocumentSynchronize.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/IncrementalTextDocumentSynchronize.java @@ -12,9 +12,7 @@ package org.eclipse.che.plugin.languageserver.ide.editor.sync; import com.google.inject.Inject; import com.google.inject.Singleton; - import org.eclipse.che.ide.api.editor.document.Document; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; import org.eclipse.che.ide.api.editor.text.TextPosition; import org.eclipse.che.ide.dto.DtoFactory; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; @@ -44,16 +42,7 @@ class IncrementalTextDocumentSynchronize implements TextDocumentSynchronize { } @Override - public void syncTextDocument(DocumentChangeEvent event, int version) { - Document document = event.getDocument().getDocument(); - TextPosition startPosition = document.getPositionFromIndex(event.getOffset()); - TextPosition endPosition; - if (event.getRemoveCharCount() != 0) { - endPosition = new TextPosition(startPosition.getLine(), startPosition.getCharacter() + event.getRemoveCharCount()); - } else { - endPosition = new TextPosition(startPosition.getLine(), startPosition.getCharacter()); - } - + public void syncTextDocument(Document document, TextPosition startPosition, TextPosition endPosition, String insertedText, int version) { DidChangeTextDocumentParams changeDTO = dtoFactory.createDto(DidChangeTextDocumentParams.class); String uri = document.getFile().getLocation().toString(); changeDTO.setUri(uri); @@ -74,7 +63,7 @@ class IncrementalTextDocumentSynchronize implements TextDocumentSynchronize { TextDocumentContentChangeEvent actualChange = dtoFactory.createDto(TextDocumentContentChangeEvent.class); actualChange.setRange(range); - actualChange.setText(event.getText()); + actualChange.setText(insertedText); changeDTO.setContentChanges(Collections.singletonList(actualChange)); textDocumentService.didChange(changeDTO); diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/TextDocumentSynchronize.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/TextDocumentSynchronize.java index 1af9ca90c4..c673f29beb 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/TextDocumentSynchronize.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/TextDocumentSynchronize.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.che.plugin.languageserver.ide.editor.sync; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; +import org.eclipse.che.ide.api.editor.document.Document; +import org.eclipse.che.ide.api.editor.text.TextPosition; /** * Handle TextDocument synchronization @@ -18,5 +19,5 @@ import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; * @author Evgen Vidolob */ public interface TextDocumentSynchronize { - void syncTextDocument(DocumentChangeEvent event, int version); + void syncTextDocument(Document document, TextPosition start, TextPosition end, String insertedText, int version); } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/TextDocumentSynchronizeFactory.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/TextDocumentSynchronizeFactory.java index 5411c64dc9..98dbc13b6d 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/TextDocumentSynchronizeFactory.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/TextDocumentSynchronizeFactory.java @@ -12,8 +12,8 @@ package org.eclipse.che.plugin.languageserver.ide.editor.sync; import com.google.inject.Inject; import com.google.inject.Singleton; - -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; +import org.eclipse.che.ide.api.editor.document.Document; +import org.eclipse.che.ide.api.editor.text.TextPosition; import org.eclipse.lsp4j.TextDocumentSyncKind; /** @@ -56,8 +56,8 @@ public class TextDocumentSynchronizeFactory { private static class NoneSynchronize implements TextDocumentSynchronize { @Override - public void syncTextDocument(DocumentChangeEvent event, int version) { - //no implementation + public void syncTextDocument(Document document, TextPosition start, TextPosition end, String insertedText, int version) { + // no-op implementation } } }