Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intelligent Commands bug fixes and code refactoring #4745

Merged
merged 3 commits into from
Apr 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*******************************************************************************
* 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 com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

/**
* Event fired when new command has been added.
* <p><b>Note:</b> this event is not intended to be fired by clients.
*/
public class CommandAddedEvent extends GwtEvent<CommandAddedEvent.CommandAddedHandler> {

/** Handler type. */
private static Type<CommandAddedHandler> TYPE;

/** Added command. */
private final CommandImpl command;

/**
* Creates new event.
* <p><b>Note:</b> this event is not intended to be fired by clients.
*/
public CommandAddedEvent(CommandImpl command) {
this.command = command;
}

/**
* Gets the type associated with this event.
*
* @return returns the handler type
*/
public static Type<CommandAddedHandler> getType() {
return TYPE != null ? TYPE : (TYPE = new Type<>());
}

@Override
public Type<CommandAddedHandler> getAssociatedType() {
return TYPE;
}

@Override
protected void dispatch(CommandAddedHandler handler) {
handler.onCommandAdded(this);
}

/** Returns added command. */
public CommandImpl getCommand() {
return command;
}

/** Handler for {@link CommandAddedEvent}. */
public interface CommandAddedHandler extends EventHandler {

/**
* Called when new command has been added.
*
* @param event
* the event
*/
void onCommandAdded(CommandAddedEvent event);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
import java.util.Map;
import java.util.Optional;

/**
* Facade for command management.
*
* @see CommandImpl
*/
/** Facade for command management. */
public interface CommandManager {

/** Returns all commands. */
Expand Down Expand Up @@ -129,39 +125,4 @@ Promise<CommandImpl> createCommand(String goalId,

/** Removes command with the specified {@code commandName}. */
Promise<Void> removeCommand(String commandName);

void addCommandLoadedListener(CommandLoadedListener listener);

void removeCommandLoadedListener(CommandLoadedListener listener);

void addCommandChangedListener(CommandChangedListener listener);

void removeCommandChangedListener(CommandChangedListener listener);

/** Listener to notify when all commands have been loaded. */
interface CommandLoadedListener {

/** Called when all commands have been loaded. */
void onCommandsLoaded();
}

/** Listener to notify when command has been changed. */
interface CommandChangedListener {

/** Called when command has been added. */
void onCommandAdded(CommandImpl command);

/**
* Called when command has been updated.
*
* @param previousCommand
* command before updating
* @param command
* updated command
*/
void onCommandUpdated(CommandImpl previousCommand, CommandImpl command);

/** Called when command has been removed. */
void onCommandRemoved(CommandImpl command);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*******************************************************************************
* 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 com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

/**
* Event fired when command has been removed.
* <p><b>Note:</b> this event is not intended to be fired by clients.
*/
public class CommandRemovedEvent extends GwtEvent<CommandRemovedEvent.CommandRemovedHandler> {

/** Handler type. */
private static Type<CommandRemovedHandler> TYPE;

/** Removed command. */
private final CommandImpl command;

/**
* Creates new event.
* <p><b>Note:</b> this event is not intended to be fired by clients.
*/
public CommandRemovedEvent(CommandImpl command) {
this.command = command;
}

/**
* Gets the type associated with this event.
*
* @return returns the handler type
*/
public static Type<CommandRemovedHandler> getType() {
return TYPE != null ? TYPE : (TYPE = new Type<>());
}

@Override
public Type<CommandRemovedHandler> getAssociatedType() {
return TYPE;
}

@Override
protected void dispatch(CommandRemovedHandler handler) {
handler.onCommandRemoved(this);
}

/** Returns removed command. */
public CommandImpl getCommand() {
return command;
}

/** Handler for {@link CommandRemovedEvent}. */
public interface CommandRemovedHandler extends EventHandler {

/**
* Called when command has been removed.
*
* @param event
* the event
*/
void onCommandRemoved(CommandRemovedEvent event);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
*******************************************************************************/
package org.eclipse.che.ide.api.command;

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

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

/**
* Registry for command types.
Expand All @@ -22,15 +21,14 @@
public interface CommandTypeRegistry {

/**
* Returns {@link CommandType} with the specified ID or {@code null} if none.
* Returns {@code Optional} {@link CommandType} with the specified ID or {@code Optional.absent()} if none.
*
* @param id
* the ID of the command type
* @return command type or {@code null}
* @return {@link CommandType} or {@code Optional.absent()}
*/
@Nullable
CommandType getCommandTypeById(String id);
Optional<CommandType> getCommandTypeById(String id);

/** Returns all registered {@link CommandType}s. */
List<CommandType> getCommandTypes();
/** Returns set of all registered {@link CommandType}s. */
Set<CommandType> getCommandTypes();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*******************************************************************************
* 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 com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

/**
* Event fired when command has been updated.
* <p><b>Note:</b> this event is not intended to be fired by clients.
*/
public class CommandUpdatedEvent extends GwtEvent<CommandUpdatedEvent.CommandUpdatedHandler> {

/** Handler type. */
private static Type<CommandUpdatedHandler> TYPE;

/** Initial command. */
private final CommandImpl initialCommand;
/** Updated command. */
private final CommandImpl updatedCommand;

/**
* Creates new event.
* <p><b>Note:</b> this event is not intended to be fired by clients.
*/
public CommandUpdatedEvent(CommandImpl initialCommand, CommandImpl updatedCommand) {
this.initialCommand = initialCommand;
this.updatedCommand = updatedCommand;
}

/**
* Gets the type associated with this event.
*
* @return returns the handler type
*/
public static Type<CommandUpdatedHandler> getType() {
return TYPE != null ? TYPE : (TYPE = new Type<>());
}

@Override
public Type<CommandUpdatedHandler> getAssociatedType() {
return TYPE;
}

@Override
protected void dispatch(CommandUpdatedHandler handler) {
handler.onCommandUpdated(this);
}

/** Returns initial command. */
public CommandImpl getInitialCommand() {
return initialCommand;
}

/** Returns updated command. */
public CommandImpl getUpdatedCommand() {
return updatedCommand;
}

/** Handler for {@link CommandUpdatedEvent}. */
public interface CommandUpdatedHandler extends EventHandler {

/**
* Called when some command has been updated.
*
* @param event
* the event
*/
void onCommandUpdated(CommandUpdatedEvent event);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*******************************************************************************
* 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 com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

/**
* Event fired when all commands are loaded.
* <p><b>Note:</b> this event is not intended to be fired by clients.
*/
public class CommandsLoadedEvent extends GwtEvent<CommandsLoadedEvent.CommandsLoadedHandler> {

/** Handler type. */
private static Type<CommandsLoadedHandler> TYPE;

/**
* Gets the type associated with this event.
*
* @return returns the handler type
*/
public static Type<CommandsLoadedHandler> getType() {
return TYPE != null ? TYPE : (TYPE = new Type<>());
}

@Override
public Type<CommandsLoadedHandler> getAssociatedType() {
return TYPE;
}

@Override
protected void dispatch(CommandsLoadedHandler handler) {
handler.onCommandsLoaded(this);
}

/** Handler for {@link CommandsLoadedEvent}. */
public interface CommandsLoadedHandler extends EventHandler {

/**
* Called when all commands are loaded.
*
* @param event
* the event
*/
void onCommandsLoaded(CommandsLoadedEvent event);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.ide.command.toolbar.processes;
package org.eclipse.che.ide.api.machine.events;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

/** Event should be fired for activating particular process's output panel. */
/** Event for activating particular process's output panel. */
public class ActivateProcessOutputEvent extends GwtEvent<ActivateProcessOutputEvent.Handler> {

public static final Type<ActivateProcessOutputEvent.Handler> TYPE = new Type<>();
Expand Down
Loading