Skip to content

Commit

Permalink
Introduce Intelligent Commands (eclipse-che#4389)
Browse files Browse the repository at this point in the history
Introduce Intelligent Commands
  • Loading branch information
azatsarynnyy authored Mar 23, 2017
1 parent efbca14 commit cbaa2c3
Show file tree
Hide file tree
Showing 342 changed files with 13,972 additions and 4,385 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
outline none
width 24px
height 16px
top 4px
top 9px
background-color $navbar-ide-iframe-button-background-color
color $light-gray-color
font-size 8px
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/app/navbar/navbar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ che-nav-bar

.navbar-iframe-button-left-border
position absolute
top 4px
top 9px
right 0
width 0
height 16px
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public interface IdeActions {

String GROUP_OTHER_MENU = "otherMenu";
String GROUP_LEFT_MAIN_MENU = "leftMainMenu";
@Deprecated
String GROUP_RIGHT_MAIN_MENU = "rightMainMenu";

String GROUP_CENTER_STATUS_PANEL = "centerStatusPanelGroup";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*******************************************************************************
* 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.command;

import java.util.Objects;

/**
* Base implementation of the {@link CommandGoal}.
*
* @author Artem Zatsarynnyi
*/
public class BaseCommandGoal implements CommandGoal {

private final String id;

public BaseCommandGoal(String id) {
this.id = id;
}

@Override
public String getId() {
return id;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}

if (!(o instanceof CommandGoal)) {
return false;
}

CommandGoal other = (CommandGoal)o;

return Objects.equals(getId(), other.getId());
}

@Override
public int hashCode() {
return Objects.hash(id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*******************************************************************************
* 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.command;

import org.eclipse.che.api.core.model.machine.Command;
import org.eclipse.che.api.core.model.machine.Machine;
import org.eclipse.che.ide.api.macro.Macro;

/**
* Allows to execute a command.
*
* @author Artem Zatsarynnyi
*/
public interface CommandExecutor {

/**
* Sends the the given {@code command} to the specified {@code machine} for execution.
* <p><b>Note</b> that all {@link Macro}s will be expanded into
* real values before sending the {@code command} for execution.
*
* @param command
* command to execute
* @param machine
* machine to execute the command
* @see Macro
*/
void executeCommand(Command command, Machine machine);

/**
* Sends the the given {@code command} for execution.
* <p>If any machine is currently selected it will be used as execution target.
* Otherwise user will be asked for choosing execution target.
* <p><b>Note</b> that all {@link Macro}s will be expanded into
* real values before sending the {@code command} for execution.
*
* @param command
* command to execute
* @see Macro
*/
void executeCommand(CommandImpl command);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*******************************************************************************
* 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.command;

/**
* Contract for command goal.
*
* @author Artem Zatsarynnyi
*/
public interface CommandGoal {

/** Returns goal ID. */
String getId();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*******************************************************************************
* 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.command;

import org.eclipse.che.commons.annotation.Nullable;

import java.util.List;
import java.util.Optional;

/**
* Registry of command goals.
*
* @author Artem Zatsarynnyi
*/
public interface CommandGoalRegistry {

/** Returns all registered predefined {@link CommandGoal}s. */
List<CommandGoal> getAllPredefinedGoals();

/** Returns the default command goal which is used for grouping commands which doesn't belong to any goal. */
CommandGoal getDefaultGoal();

/**
* Returns an optional {@link CommandGoal} by the given ID
* or {@code Optional.absent()} if none was registered.
*
* @param id
* the ID of the predefined command goal to get
* @return an optional {@link CommandGoal} or {@code Optional.absent()} if none was registered
*/
Optional<CommandGoal> getPredefinedGoalById(String id);

/**
* Returns a predefined {@link CommandGoal} by the given ID
* or the custom (non-predefined) goal if none was registered
* or the default goal if the given {@code id} is {@code null} or empty string.
*
* @param id
* the ID of the command goal
* @return a predefined {@link CommandGoal} with the given ID
* or the custom (non-predefined) goal if none was registered
* or the default goal if the given {@code id} is {@code null} or empty string. Never null.
*/
CommandGoal getGoalForId(@Nullable String id);
}
Loading

0 comments on commit cbaa2c3

Please sign in to comment.