diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/MachineExtension.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/MachineExtension.java index 86830346690..0a5a8aaf9b7 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/MachineExtension.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/MachineExtension.java @@ -34,12 +34,8 @@ import org.eclipse.che.ide.api.parts.PerspectiveManager; import org.eclipse.che.ide.api.workspace.event.WorkspaceStartingEvent; import org.eclipse.che.ide.api.workspace.event.WorkspaceStoppedEvent; -import org.eclipse.che.ide.extension.machine.client.actions.CreateMachineAction; -import org.eclipse.che.ide.extension.machine.client.actions.CreateSnapshotAction; -import org.eclipse.che.ide.extension.machine.client.actions.DestroyMachineAction; import org.eclipse.che.ide.extension.machine.client.actions.EditCommandsAction; import org.eclipse.che.ide.extension.machine.client.actions.ExecuteSelectedCommandAction; -import org.eclipse.che.ide.extension.machine.client.actions.RestartMachineAction; import org.eclipse.che.ide.extension.machine.client.actions.RunCommandAction; import org.eclipse.che.ide.extension.machine.client.actions.SelectCommandComboBox; import org.eclipse.che.ide.extension.machine.client.actions.ShowConsoleTreeAction; @@ -168,12 +164,8 @@ private void prepareActions(MachineLocalizationConstant localizationConstant, ExecuteSelectedCommandAction executeSelectedCommandAction, SelectCommandComboBox selectCommandAction, EditCommandsAction editCommandsAction, - CreateMachineAction createMachine, - RestartMachineAction restartMachine, - DestroyMachineAction destroyMachineAction, StopWorkspaceAction stopWorkspaceAction, SwitchPerspectiveAction switchPerspectiveAction, - CreateSnapshotAction createSnapshotAction, RunCommandAction runCommandAction, NewTerminalAction newTerminalAction, EditTargetsAction editTargetsAction, @@ -183,8 +175,6 @@ private void prepareActions(MachineLocalizationConstant localizationConstant, StopProcessAction stopProcessAction, CloseConsoleAction closeConsoleAction, ShowConsoleTreeAction showConsoleTreeAction) { - final DefaultActionGroup mainMenu = (DefaultActionGroup)actionManager.getAction(GROUP_MAIN_MENU); - final DefaultActionGroup workspaceMenu = (DefaultActionGroup)actionManager.getAction(GROUP_WORKSPACE); final DefaultActionGroup runMenu = (DefaultActionGroup)actionManager.getAction(GROUP_RUN); @@ -195,15 +185,7 @@ private void prepareActions(MachineLocalizationConstant localizationConstant, actionManager.registerAction("editTargets", editTargetsAction); - //add actions in machine menu - final DefaultActionGroup machineMenu = new DefaultActionGroup(localizationConstant.mainMenuMachine(), true, actionManager); - - actionManager.registerAction("machine", machineMenu); - actionManager.registerAction("createMachine", createMachine); - actionManager.registerAction("destroyMachine", destroyMachineAction); - actionManager.registerAction("restartMachine", restartMachine); actionManager.registerAction("stopWorkspace", stopWorkspaceAction); - actionManager.registerAction("createSnapshot", createSnapshotAction); actionManager.registerAction("runCommand", runCommandAction); actionManager.registerAction("newTerminal", newTerminalAction); @@ -215,11 +197,6 @@ private void prepareActions(MachineLocalizationConstant localizationConstant, workspaceMenu.add(stopWorkspaceAction); - mainMenu.add(machineMenu, new Constraints(AFTER, IdeActions.GROUP_PROJECT)); - machineMenu.add(createMachine); - machineMenu.add(restartMachine); - machineMenu.add(destroyMachineAction); - machineMenu.add(createSnapshotAction); if (centralToolbarVisible) { // add actions on center part of toolbar @@ -233,10 +210,6 @@ private void prepareActions(MachineLocalizationConstant localizationConstant, machineToolbarGroup.add(executeToolbarGroup); } - // add actions on right part of toolbar - final DefaultActionGroup rightToolbarGroup = (DefaultActionGroup)actionManager.getAction(GROUP_RIGHT_TOOLBAR); - rightToolbarGroup.add(switchPerspectiveAction); - // add group for list of machines final DefaultActionGroup machinesList = new DefaultActionGroup(GROUP_MACHINES_DROPDOWN, true, actionManager); actionManager.registerAction(GROUP_MACHINES_LIST, machinesList); @@ -261,5 +234,4 @@ private void prepareActions(MachineLocalizationConstant localizationConstant, iconRegistry.registerIcon(new Icon("che.machine.icon", machineResources.devMachine())); } - } diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/actions/CreateMachineAction.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/actions/CreateMachineAction.java deleted file mode 100644 index 9cc4f8bd7e8..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/actions/CreateMachineAction.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * 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.extension.machine.client.actions; - -import com.google.inject.Inject; - -import org.eclipse.che.ide.api.action.AbstractPerspectiveAction; -import org.eclipse.che.ide.api.action.ActionEvent; -import org.eclipse.che.ide.extension.machine.client.MachineLocalizationConstant; -import org.eclipse.che.ide.extension.machine.client.machine.create.CreateMachinePresenter; - -import javax.validation.constraints.NotNull; -import java.util.Collections; - -import static org.eclipse.che.ide.extension.machine.client.perspective.OperationsPerspective.OPERATIONS_PERSPECTIVE_ID; - -/** - * The action contains business logic which calls special method to create machine. - * - * @author Dmitry Shnurenko - */ -public class CreateMachineAction extends AbstractPerspectiveAction { - - private final CreateMachinePresenter createMachinePresenter; - - @Inject - public CreateMachineAction(MachineLocalizationConstant locale, - CreateMachinePresenter createMachinePresenter) { - super(Collections.singletonList(OPERATIONS_PERSPECTIVE_ID), - locale.machineCreateTitle(), - locale.machineCreateDescription(), - null, null); - - this.createMachinePresenter = createMachinePresenter; - } - - /** {@inheritDoc} */ - @Override - public void updateInPerspective(@NotNull ActionEvent event) { - //to do nothing - } - - /** {@inheritDoc} */ - @Override - public void actionPerformed(@NotNull ActionEvent event) { - createMachinePresenter.showDialog(); - } - -} diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/actions/CreateSnapshotAction.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/actions/CreateSnapshotAction.java deleted file mode 100644 index b6c0ef67739..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/actions/CreateSnapshotAction.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * 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.extension.machine.client.actions; - -import org.eclipse.che.ide.CoreLocalizationConstant; -import org.eclipse.che.ide.actions.WorkspaceSnapshotCreator; -import org.eclipse.che.ide.api.action.AbstractPerspectiveAction; -import org.eclipse.che.ide.api.action.ActionEvent; -import org.eclipse.che.ide.api.app.AppContext; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.validation.constraints.NotNull; - -import static java.util.Collections.singletonList; -import static org.eclipse.che.ide.extension.machine.client.perspective.OperationsPerspective.OPERATIONS_PERSPECTIVE_ID; - -/** - * @author Yevhenii Voevodin - * @author Vlad Zhukovskyi - */ -@Singleton -public class CreateSnapshotAction extends AbstractPerspectiveAction { - - private final WorkspaceSnapshotCreator snapshotCreator; - private final AppContext appContext; - - @Inject - public CreateSnapshotAction(CoreLocalizationConstant locale, WorkspaceSnapshotCreator snapshotCreator, AppContext appContext) { - super(singletonList(OPERATIONS_PERSPECTIVE_ID), locale.createSnapshotTitle(), locale.createSnapshotDescription(), null, null); - this.snapshotCreator = snapshotCreator; - this.appContext = appContext; - } - - @Override - public void updateInPerspective(@NotNull ActionEvent event) { - event.getPresentation().setEnabled(!snapshotCreator.isInProgress()); - } - - @Override - public void actionPerformed(ActionEvent event) { - snapshotCreator.createSnapshot(appContext.getWorkspace().getId()); - } -} diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/actions/DestroyMachineAction.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/actions/DestroyMachineAction.java deleted file mode 100644 index 31c6bf7c463..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/actions/DestroyMachineAction.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * 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.extension.machine.client.actions; - -import com.google.inject.Inject; - -import org.eclipse.che.ide.api.action.AbstractPerspectiveAction; -import org.eclipse.che.ide.api.action.ActionEvent; -import org.eclipse.che.ide.api.machine.MachineEntity; -import org.eclipse.che.ide.api.machine.MachineManager; -import org.eclipse.che.ide.extension.machine.client.MachineLocalizationConstant; -import org.eclipse.che.ide.extension.machine.client.perspective.widgets.machine.panel.MachinePanelPresenter; - -import javax.validation.constraints.NotNull; -import java.util.Collections; - -import static org.eclipse.che.ide.extension.machine.client.perspective.OperationsPerspective.OPERATIONS_PERSPECTIVE_ID; - -/** - * The action contains business logic which calls special method to destroy machine. - * - * @author Dmitry Shnurenko - */ -public class DestroyMachineAction extends AbstractPerspectiveAction { - - private final MachineLocalizationConstant locale; - private final MachinePanelPresenter panelPresenter; - private final MachineManager machineManager; - - @Inject - public DestroyMachineAction(final MachineLocalizationConstant locale, - final MachinePanelPresenter panelPresenter, - final MachineManager machineManager) { - super(Collections.singletonList(OPERATIONS_PERSPECTIVE_ID), - locale.machineDestroyTitle(), - locale.machineDestroyDescription(), - null, null); - - this.locale = locale; - this.panelPresenter = panelPresenter; - this.machineManager = machineManager; - } - - /** {@inheritDoc} */ - @Override - public void updateInPerspective(@NotNull ActionEvent event) { - final MachineEntity selectedMachine = panelPresenter.getSelectedMachineState(); - event.getPresentation().setEnabled(selectedMachine != null - && !selectedMachine.getConfig().isDev() - && panelPresenter.isMachineRunning()); - event.getPresentation().setText(selectedMachine != null ? locale.machineDestroyTitle(selectedMachine.getConfig().getName()) - : locale.machineDestroyTitle()); - } - - /** {@inheritDoc} */ - @Override - public void actionPerformed(@NotNull ActionEvent event) { - final MachineEntity selectedMachine = panelPresenter.getSelectedMachineState(); - if (selectedMachine == null) { - return; - } - - machineManager.destroyMachine(selectedMachine); - } -} diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/actions/RestartMachineAction.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/actions/RestartMachineAction.java deleted file mode 100644 index 4b714a4ff19..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/actions/RestartMachineAction.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * 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.extension.machine.client.actions; - -import com.google.inject.Inject; - -import org.eclipse.che.ide.api.action.AbstractPerspectiveAction; -import org.eclipse.che.ide.api.action.ActionEvent; -import org.eclipse.che.ide.api.machine.MachineEntity; -import org.eclipse.che.ide.api.machine.MachineManager; -import org.eclipse.che.ide.extension.machine.client.MachineLocalizationConstant; -import org.eclipse.che.ide.extension.machine.client.perspective.widgets.machine.panel.MachinePanelPresenter; - -import java.util.Collections; - -import static org.eclipse.che.ide.extension.machine.client.perspective.OperationsPerspective.OPERATIONS_PERSPECTIVE_ID; - -/** - * The action contains business logic which calls special method to restart machine. - * - * @author Dmitry Shnurenko - */ -public class RestartMachineAction extends AbstractPerspectiveAction { - - private final MachinePanelPresenter panelPresenter; - private final MachineManager machineManager; - private final MachineLocalizationConstant locale; - - private MachineEntity selectedMachine; - - @Inject - public RestartMachineAction(MachineLocalizationConstant locale, - MachinePanelPresenter panelPresenter, - MachineManager machineManager) { - super(Collections.singletonList(OPERATIONS_PERSPECTIVE_ID), - locale.controlMachineRestartText(), - locale.controlMachineRestartTooltip(), - null, null); - - this.panelPresenter = panelPresenter; - this.locale = locale; - this.machineManager = machineManager; - } - - /** {@inheritDoc} */ - @Override - public void updateInPerspective(ActionEvent event) { - selectedMachine = panelPresenter.getSelectedMachineState(); - - event.getPresentation().setEnabled(selectedMachine != null - && !selectedMachine.getConfig().isDev() - && panelPresenter.isMachineRunning()); - - event.getPresentation().setText(selectedMachine != null ? locale.machineRestartTextByName(selectedMachine.getConfig().getName()) - : locale.controlMachineRestartText()); - } - - /** {@inheritDoc} */ - @Override - public void actionPerformed(ActionEvent event) { - machineManager.restartMachine(selectedMachine); - } -} diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/actions/SwitchPerspectiveAction.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/actions/SwitchPerspectiveAction.java index 8063be3aaa8..7aed5714cf7 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/actions/SwitchPerspectiveAction.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/actions/SwitchPerspectiveAction.java @@ -25,7 +25,6 @@ import org.eclipse.che.ide.extension.machine.client.MachineResources; import org.eclipse.che.ide.ui.radiobuttongroup.RadioButtonGroup; -import static org.eclipse.che.ide.extension.machine.client.perspective.OperationsPerspective.OPERATIONS_PERSPECTIVE_ID; import static org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID; /** @@ -65,14 +64,6 @@ public void onClick(ClickEvent event) { } }); - radioButtonGroup.addButton("", localizationConstant.perspectiveOperationsActionTooltip(), resources.operationsPerspective(), - new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - perspectiveManager.setPerspectiveId(OPERATIONS_PERSPECTIVE_ID); - } - }); - radioButtonGroup.selectButton(0); } diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/inject/MachineGinModule.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/inject/MachineGinModule.java index 3e1f69575b8..8effb47d0fc 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/inject/MachineGinModule.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/inject/MachineGinModule.java @@ -12,7 +12,6 @@ import com.google.gwt.inject.client.AbstractGinModule; import com.google.gwt.inject.client.assistedinject.GinFactoryModuleBuilder; -import com.google.gwt.inject.client.multibindings.GinMapBinder; import com.google.gwt.inject.client.multibindings.GinMultibinder; import com.google.inject.Singleton; import com.google.inject.name.Names; @@ -25,7 +24,6 @@ import org.eclipse.che.ide.api.machine.MachineManager; import org.eclipse.che.ide.api.macro.Macro; import org.eclipse.che.ide.api.outputconsole.OutputConsole; -import org.eclipse.che.ide.api.parts.Perspective; import org.eclipse.che.ide.extension.machine.client.RecipeScriptDownloadServiceClient; import org.eclipse.che.ide.extension.machine.client.RecipeScriptDownloadServiceClientImpl; import org.eclipse.che.ide.extension.machine.client.command.CommandManagerImpl; @@ -48,7 +46,6 @@ import org.eclipse.che.ide.extension.machine.client.outputspanel.console.DefaultOutputConsole; import org.eclipse.che.ide.extension.machine.client.outputspanel.console.OutputConsoleView; import org.eclipse.che.ide.extension.machine.client.outputspanel.console.OutputConsoleViewImpl; -import org.eclipse.che.ide.extension.machine.client.perspective.OperationsPerspective; import org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.button.EditorButtonWidget; import org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.button.EditorButtonWidgetImpl; import org.eclipse.che.ide.extension.machine.client.perspective.widgets.tab.Tab; @@ -73,8 +70,6 @@ import org.eclipse.che.ide.extension.machine.client.targets.categories.ssh.SshView; import org.eclipse.che.ide.extension.machine.client.targets.categories.ssh.SshViewImpl; -import static org.eclipse.che.ide.extension.machine.client.perspective.OperationsPerspective.OPERATIONS_PERSPECTIVE_ID; - /** * GIN module for Machine extension. * @@ -87,10 +82,6 @@ public class MachineGinModule extends AbstractGinModule { @Override protected void configure() { - GinMapBinder.newMapBinder(binder(), String.class, Perspective.class) - .addBinding(OPERATIONS_PERSPECTIVE_ID) - .to(OperationsPerspective.class); - bind(CreateMachineView.class).to(CreateMachineViewImpl.class); bind(OutputConsoleView.class).to(OutputConsoleViewImpl.class); install(new GinFactoryModuleBuilder() diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/perspective/OperationsPerspective.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/perspective/OperationsPerspective.java deleted file mode 100644 index d690ea836b8..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/perspective/OperationsPerspective.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * 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.extension.machine.client.perspective; - -import com.google.gwt.user.client.ui.AcceptsOneWidget; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import com.google.web.bindery.event.shared.EventBus; - -import org.eclipse.che.ide.api.parts.PartStack; -import org.eclipse.che.ide.extension.machine.client.perspective.widgets.machine.appliance.MachineAppliancePresenter; -import org.eclipse.che.ide.extension.machine.client.perspective.widgets.machine.panel.MachinePanelPresenter; -import org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.RecipePartPresenter; -import org.eclipse.che.ide.workspace.PartStackPresenterFactory; -import org.eclipse.che.ide.workspace.PartStackViewFactory; -import org.eclipse.che.ide.workspace.WorkBenchControllerFactory; -import org.eclipse.che.ide.workspace.perspectives.general.AbstractPerspective; -import org.eclipse.che.ide.workspace.perspectives.general.PerspectiveViewImpl; -import org.eclipse.che.providers.DynaProvider; - -import javax.validation.constraints.NotNull; - -import static org.eclipse.che.ide.api.parts.PartStackType.EDITING; -import static org.eclipse.che.ide.api.parts.PartStackType.INFORMATION; -import static org.eclipse.che.ide.api.parts.PartStackType.NAVIGATION; - -/** - * Special view perspective which defines how must main window be displayed when we choose machine perspective. - * - * @author Dmitry Shnurenko - * @author Valeriy Svydenko - */ -@Singleton -public class OperationsPerspective extends AbstractPerspective { - - public final static String OPERATIONS_PERSPECTIVE_ID = "Operations Perspective"; - - @Inject - public OperationsPerspective(PerspectiveViewImpl view, - PartStackViewFactory partViewFactory, - WorkBenchControllerFactory controllerFactory, - PartStackPresenterFactory stackPresenterFactory, - MachinePanelPresenter machinePanel, - RecipePartPresenter recipePanel, - MachineAppliancePresenter infoContainer, - EventBus eventBus, - DynaProvider dynaProvider) { - super(OPERATIONS_PERSPECTIVE_ID, view, stackPresenterFactory, partViewFactory, controllerFactory, eventBus, dynaProvider); - - //central panel - partStacks.put(EDITING, infoContainer); - - addPart(machinePanel, NAVIGATION); - addPart(recipePanel, NAVIGATION); - - setActivePart(machinePanel); - PartStack information = getPartStack(INFORMATION); - PartStack navigation = getPartStack(NAVIGATION); - PartStack editing = getPartStack(EDITING); - - if (information == null || navigation == null || editing == null) { - return; - } - - information.updateStack(); - - information.go(view.getInformationPanel()); - navigation.go(view.getNavigationPanel()); - editing.go(view.getEditorPanel()); - openActivePart(INFORMATION); - openActivePart(NAVIGATION); - } - - /** {@inheritDoc} */ - @Override - public void go(@NotNull AcceptsOneWidget container) { - container.setWidget(view); - } - -} diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/actions/CreateMachineActionTest.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/actions/CreateMachineActionTest.java deleted file mode 100644 index 74766fcf206..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/actions/CreateMachineActionTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * 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.extension.machine.client.actions; - -import org.eclipse.che.ide.api.action.ActionEvent; -import org.eclipse.che.ide.extension.machine.client.MachineLocalizationConstant; -import org.eclipse.che.ide.extension.machine.client.machine.create.CreateMachinePresenter; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - -import static org.mockito.Mockito.verify; - -/** - * @author Dmitry Shnurenko - */ -@RunWith(MockitoJUnitRunner.class) -public class CreateMachineActionTest { - - @Mock - private MachineLocalizationConstant locale; - @Mock - private CreateMachinePresenter createMachinePresenter; - @Mock - private ActionEvent event; - - @InjectMocks - private CreateMachineAction action; - - @Test - public void constructorShouldBeVerified() { - verify(locale).machineCreateTitle(); - verify(locale).machineCreateDescription(); - } - - @Test - public void actionShouldBePerformed() { - action.actionPerformed(event); - - verify(createMachinePresenter).showDialog(); - } -} diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/actions/CreateSnapshotActionTest.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/actions/CreateSnapshotActionTest.java deleted file mode 100644 index 0f108e8afb0..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/actions/CreateSnapshotActionTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * 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.extension.machine.client.actions; - -import com.google.gwtmockito.GwtMockitoTestRunner; - -import org.eclipse.che.api.workspace.shared.dto.WorkspaceDto; -import org.eclipse.che.ide.CoreLocalizationConstant; -import org.eclipse.che.ide.actions.WorkspaceSnapshotCreator; -import org.eclipse.che.ide.api.action.ActionEvent; -import org.eclipse.che.ide.api.action.Presentation; -import org.eclipse.che.ide.api.app.AppContext; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Answers; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import static org.eclipse.che.dto.server.DtoFactory.newDto; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * Tests for {@link CreateSnapshotAction}. - * - * @author Yevhenii Voevodin - */ -@RunWith(GwtMockitoTestRunner.class) -public class CreateSnapshotActionTest { - - @Mock - private WorkspaceSnapshotCreator snapshotCreator; - - @Mock - private CoreLocalizationConstant coreLocalizationConstant; - - @Mock(answer = Answers.RETURNS_MOCKS) - private ActionEvent event; - - @Mock(answer = Answers.RETURNS_MOCKS) - private AppContext appContext; - - @InjectMocks - private CreateSnapshotAction createSnapshotAction; - - @Test - public void shouldSetTitleAndDescription() { - verify(coreLocalizationConstant).createSnapshotTitle(); - verify(coreLocalizationConstant).createSnapshotDescription(); - } - - @Test - public void eventPresentationShouldBeEnabledIfSnapshotCreatorIsNotInProgress() { - when(event.getPresentation()).thenReturn(new Presentation()); - when(snapshotCreator.isInProgress()).thenReturn(false); - - createSnapshotAction.updateInPerspective(event); - - assertTrue(event.getPresentation().isEnabled()); - } - - @Test - public void eventPresentationShouldBeDisabledIfSnapshotCreatorIsInProgress() { - when(event.getPresentation()).thenReturn(new Presentation()); - when(snapshotCreator.isInProgress()).thenReturn(true); - - createSnapshotAction.updateInPerspective(event); - - assertFalse(event.getPresentation().isEnabled()); - } - - @Test - public void shouldCreateSnapshotWithWorkspaceIdFromAppContextWhenActionPerformed() { - when(appContext.getWorkspace()).thenReturn(newDto(WorkspaceDto.class).withId("workspace123")); - - createSnapshotAction.actionPerformed(event); - - verify(snapshotCreator).createSnapshot("workspace123"); - } -} diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/actions/DestroyMachineActionTest.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/actions/DestroyMachineActionTest.java deleted file mode 100644 index 19020cb6480..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/actions/DestroyMachineActionTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * 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.extension.machine.client.actions; - -import org.eclipse.che.ide.api.machine.MachineEntity; -import org.eclipse.che.ide.api.machine.MachineManager; -import org.eclipse.che.ide.api.action.ActionEvent; -import org.eclipse.che.ide.extension.machine.client.MachineLocalizationConstant; -import org.eclipse.che.ide.extension.machine.client.perspective.widgets.machine.panel.MachinePanelPresenter; -import org.eclipse.che.ide.api.dialogs.DialogFactory; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * @author Dmitry Shnurenko - */ -@RunWith(MockitoJUnitRunner.class) -public class DestroyMachineActionTest { - @Mock - private MachineLocalizationConstant locale; - @Mock - private MachinePanelPresenter panelPresenter; - @Mock - private ActionEvent event; - @Mock - private MachineManager machineManager; - @Mock - private DialogFactory dialogFactory; - - @Mock - private MachineEntity machine; - - @InjectMocks - private DestroyMachineAction action; - - @Before - public void setUp() { - when(panelPresenter.getSelectedMachineState()).thenReturn(machine); - } - - @Test - public void constructorShouldBeVerified() { - verify(locale).machineDestroyTitle(); - verify(locale).machineDestroyDescription(); - } - - @Test - public void actionShouldBePerformed() { - action.actionPerformed(event); - - verify(machineManager).destroyMachine(eq(machine)); - } - -// @Test -// public void devMachineShouldNotBeDestroyed() { -// when(machine.isDev()).thenReturn(true); -// MessageDialog dialog = mock(MessageDialog.class); -// when(dialogFactory.createMessageDialog(anyString(), anyString(), any(ConfirmCallback.class))).thenReturn(dialog); -// -// action.actionPerformed(event); -// -// verify(dialogFactory).createMessageDialog(anyString(), anyString(), any(ConfirmCallback.class)); -// verify(dialog).show(); -// verify(machineManager, never()).destroyMachine(eq(machine)); -// } -} diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/actions/RestartMachineActionTest.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/actions/RestartMachineActionTest.java deleted file mode 100644 index 8ab5d85cb8a..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/actions/RestartMachineActionTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * 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.extension.machine.client.actions; - -import com.google.gwtmockito.GwtMockitoTestRunner; - -import org.eclipse.che.api.machine.shared.dto.MachineConfigDto; -import org.eclipse.che.ide.api.action.ActionEvent; -import org.eclipse.che.ide.api.machine.MachineEntity; -import org.eclipse.che.ide.api.machine.MachineManager; -import org.eclipse.che.ide.extension.machine.client.MachineLocalizationConstant; -import org.eclipse.che.ide.extension.machine.client.perspective.widgets.machine.panel.MachinePanelPresenter; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Answers; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * @author Dmitry Shnurenko - */ -@RunWith(GwtMockitoTestRunner.class) -public class RestartMachineActionTest { - - private static final String SOME_TEXT = "someText"; - - //constructors mocks - @Mock - private MachinePanelPresenter panelPresenter; - @Mock - private MachineManager machineManager; - @Mock - private MachineLocalizationConstant locale; - - //additional mocks - @Mock(answer = Answers.RETURNS_DEEP_STUBS) - private ActionEvent event; - @Mock - private MachineEntity machine; - @Mock - private MachineConfigDto machineConfig; - - @InjectMocks - private RestartMachineAction action; - - @Before - public void setUp() { - when(panelPresenter.getSelectedMachineState()).thenReturn(machine); - when(machine.getConfig()).thenReturn(machineConfig); - } - - @Test - public void actionShouldBeUpdatedWhenSelectedMachineIsNotNull() { - when(machineConfig.getName()).thenReturn(SOME_TEXT); - when(locale.machineRestartTextByName(SOME_TEXT)).thenReturn(SOME_TEXT); - - action.updateInPerspective(event); - - verify(panelPresenter).getSelectedMachineState(); - verify(panelPresenter).isMachineRunning(); - - verify(machineConfig).getName(); - verify(locale).machineRestartTextByName(SOME_TEXT); - - verify(event.getPresentation()).setText(SOME_TEXT); - } - - @Test - public void actionShouldBeUpdatedWhenSelectedMachineIsNull() { - reset(locale); - when(panelPresenter.getSelectedMachineState()).thenReturn(null); - when(locale.controlMachineRestartText()).thenReturn(SOME_TEXT); - - action.updateInPerspective(event); - - verify(panelPresenter).getSelectedMachineState(); - verify(event.getPresentation()).setEnabled(false); - - verify(machineConfig, never()).getName(); - verify(locale, never()).machineRestartTextByName(SOME_TEXT); - - verify(locale).controlMachineRestartText(); - - verify(event.getPresentation()).setText(SOME_TEXT); - } - - @Test - public void actionShouldBePerformed() { - action.updateInPerspective(event); - - action.actionPerformed(event); - - verify(machineManager).restartMachine(machine); - } -} diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/actions/SwitchPerspectiveActionTest.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/actions/SwitchPerspectiveActionTest.java index dcdb3dfa207..5145674813c 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/actions/SwitchPerspectiveActionTest.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/actions/SwitchPerspectiveActionTest.java @@ -52,7 +52,7 @@ public class SwitchPerspectiveActionTest { @Test public void buttonsShouldBeCreatedInGroup() { - verify(radioButtonGroup, times(2)).addButton(anyString(), anyString(), any(SVGResource.class), any(ClickHandler.class)); + verify(radioButtonGroup).addButton(anyString(), anyString(), any(SVGResource.class), any(ClickHandler.class)); verify(radioButtonGroup).selectButton(eq(0)); } } diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/perspective/OperationsPerspectiveTest.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/perspective/OperationsPerspectiveTest.java deleted file mode 100644 index dfd5cc76fb2..00000000000 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/perspective/OperationsPerspectiveTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * 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.extension.machine.client.perspective; - -import com.google.gwt.user.client.ui.AcceptsOneWidget; -import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.SimpleLayoutPanel; -import com.google.gwt.user.client.ui.SimplePanel; -import com.google.gwt.user.client.ui.SplitLayoutPanel; -import com.google.gwtmockito.GwtMockitoTestRunner; -import com.google.web.bindery.event.shared.EventBus; - -import org.eclipse.che.ide.api.parts.PartStackType; -import org.eclipse.che.ide.api.parts.PartStackView; -import org.eclipse.che.ide.extension.machine.client.perspective.widgets.machine.appliance.MachineAppliancePresenter; -import org.eclipse.che.ide.extension.machine.client.perspective.widgets.machine.panel.MachinePanelPresenter; -import org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.RecipePartPresenter; -import org.eclipse.che.ide.part.PartStackPresenter; -import org.eclipse.che.ide.workspace.PartStackPresenterFactory; -import org.eclipse.che.ide.workspace.PartStackViewFactory; -import org.eclipse.che.ide.workspace.WorkBenchControllerFactory; -import org.eclipse.che.ide.workspace.WorkBenchPartController; -import org.eclipse.che.ide.workspace.perspectives.general.PerspectiveViewImpl; -import org.eclipse.che.providers.DynaProvider; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; - -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * @author Dmitry Shnurenko - */ -@RunWith(GwtMockitoTestRunner.class) -public class OperationsPerspectiveTest { - - //constructor mocks - @Mock - private PerspectiveViewImpl view; - @Mock - private PartStackViewFactory partViewFactory; - @Mock - private WorkBenchControllerFactory controllerFactory; - @Mock - private PartStackPresenterFactory stackPresenterFactory; - @Mock - private MachinePanelPresenter machinePanel; - @Mock - private MachineAppliancePresenter infoContainer; - @Mock - private RecipePartPresenter recipePanel; - @Mock - private EventBus eventBus; - - //additional mocks - @Mock - private FlowPanel panel; - @Mock - private SplitLayoutPanel layoutPanel; - @Mock - private SimplePanel simplePanel; - @Mock - private SimpleLayoutPanel simpleLayoutPanel; - @Mock - private WorkBenchPartController workBenchController; - @Mock - private PartStackView partStackView; - @Mock - private PartStackPresenter partStackPresenter; - @Mock - private AcceptsOneWidget container; - @Mock - private DynaProvider dynaProvider; - - private OperationsPerspective perspective; - - @Before - public void setUp() { - when(view.getLeftPanel()).thenReturn(panel); - when(view.getRightPanel()).thenReturn(panel); - when(view.getBottomPanel()).thenReturn(panel); - - when(view.getSplitPanel()).thenReturn(layoutPanel); - - when(view.getNavigationPanel()).thenReturn(simplePanel); - when(view.getInformationPanel()).thenReturn(simpleLayoutPanel); - when(view.getToolPanel()).thenReturn(simplePanel); - - when(controllerFactory.createController(Matchers.anyObject(), - Matchers.anyObject())).thenReturn(workBenchController); - - when(partViewFactory.create(Matchers.anyObject(), - Matchers.anyObject())).thenReturn(partStackView); - - when(stackPresenterFactory.create(Matchers.anyObject(), - Matchers.anyObject())).thenReturn(partStackPresenter); - - perspective = new OperationsPerspective(view, - partViewFactory, - controllerFactory, - stackPresenterFactory, - machinePanel, - recipePanel, - infoContainer, - eventBus, - dynaProvider); - } - - @Test - public void perspectiveShouldBeDisplayed() { - perspective.addPart(machinePanel, PartStackType.INFORMATION); - - perspective.go(container); - - verify(view, times(2)).getInformationPanel(); - verify(view, times(2)).getNavigationPanel(); - verify(view).getEditorPanel(); - verify(partStackPresenter).go(simplePanel); - verify(partStackPresenter).go(simpleLayoutPanel); - verify(container).setWidget(view); - - verify(partStackPresenter, times(2)).openPreviousActivePart(); - } - -}