forked from eclipse-che/che
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce Intelligent Commands (eclipse-che#4389)
Introduce Intelligent Commands
- Loading branch information
1 parent
efbca14
commit cbaa2c3
Showing
342 changed files
with
13,972 additions
and
4,385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/command/BaseCommandGoal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/command/CommandExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
22 changes: 22 additions & 0 deletions
22
ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/command/CommandGoal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
53 changes: 53 additions & 0 deletions
53
ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/command/CommandGoalRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
Oops, something went wrong.