Skip to content

Commit

Permalink
#83 [v2.0] rework "Copy..." and "Show/Edit.." buttons in command dialog
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Bossert <anb0s@anbos.de>
  • Loading branch information
anb0s committed Sep 12, 2016
1 parent 30df796 commit e9c8f72
Show file tree
Hide file tree
Showing 9 changed files with 419 additions and 137 deletions.
19 changes: 13 additions & 6 deletions plugin/src/de/anbos/eclipse/easyshell/plugin/UIMessages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ easyshell.command.page.button.text.new=Add...
easyshell.command.page.button.tooltip.new=Add new command
easyshell.command.page.button.text.copy=Copy...
easyshell.command.page.button.tooltip.copy=Copy selected command to new command
easyshell.command.page.button.text.edit=Show/Edit...
easyshell.command.page.button.text.edit=Edit...
easyshell.command.page.button.tooltip.edit=Show or edit selected command
easyshell.command.page.button.text.remove=Remove...
easyshell.command.page.button.tooltip.remove=Remove selected commands(s)
easyshell.command.page.button.tooltip.remove=Remove selected command(s) or user settings
easyshell.command.page.dialog.remove.title=Remove command(s)
easyshell.command.page.dialog.remove.user.title=Remove user settings
easyshell.command.page.dialog.remove.question=Do you really want to remove selected command(s):\n\n{0}
easyshell.command.page.dialog.remove.user.question=Do you really want to remove user settings from selected command(s):\n\n{0}
easyshell.command.page.dialog.remove.menu.title=Remove command(s) and menu(s)
easyshell.command.page.dialog.remove.menu.user.title=Remove user settings
easyshell.command.page.dialog.remove.menu.question=The selected command(s):\n\n{0}\nis(are) used in menu(s):\n\n{1}\nDo you really want to remove selected command(s) and menu(s) ?
easyshell.command.page.dialog.remove.menu.user.question=The selected command(s):\n\n{0}\nis(are) used in menu(s):\n\n{1}\nDo you really want to remove user settings from selected command(s) ?

easyshell.command.page.dialog.defaults.title=Restore defaults
easyshell.command.page.dialog.defaults.question=All your command definitions will be overwritten!\n\nYou can still use "Cancel" button afterwards for undo.\n\nDo you really want to restore default settings?
Expand All @@ -78,21 +82,24 @@ easyshell.menu.editor.dialog.button.text.new=New...
easyshell.menu.editor.dialog.button.tooltip.new=Add new command
easyshell.menu.editor.dialog.button.text.copy=Copy...
easyshell.menu.editor.dialog.button.tooltip.copy=Copy selected command to new command
easyshell.menu.editor.dialog.button.text.edit=Show/Edit...
easyshell.menu.editor.dialog.button.text.edit=Edit...
easyshell.menu.editor.dialog.button.tooltip.edit=Show or edit selected command
easyshell.menu.editor.dialog.button.text.remove=Remove...
easyshell.menu.editor.dialog.button.tooltip.remove=Remove selected command
easyshell.menu.editor.dialog.button.tooltip.remove=Remove selected command or user settings
easyshell.menu.editor.dialog.title.remove=Remove command
easyshell.menu.editor.dialog.title.user.remove=Remove user settings
easyshell.menu.editor.dialog.question.remove=Do you really want to remove command\n"{0}" ?
easyshell.menu.editor.dialog.question.user.remove=Do you really want to remove user settings from command\n"{0}" ?
easyshell.menu.editor.dialog.title.remove.menu=Remove command and menu(s)
easyshell.menu.editor.dialog.title.remove.user.menu=Remove user settings
easyshell.menu.editor.dialog.question.remove.menu=The selected command:\n\n{0}\n\nis used in other menu(s):\n\n{1}\nDo you really want to remove selected command and menu(s) ?
easyshell.menu.editor.dialog.question.remove.user.menu=The selected command:\n\n{0}\n\nis used in other menu(s):\n\n{1}\nDo you really want to remove user settings from selected command?
easyshell.menu.editor.dialog.title.duplicate=Duplicate usage of command
easyshell.menu.editor.dialog.question.duplicate=The selected command:\n\n{0}\n\nis used in other menu(s) already:\n\n{1}\nDo you really want to use the same command in this menu ?

easyshell.command.editor.dialog.title.new=Create new command
easyshell.command.editor.dialog.title.copy=Copy to new command
easyshell.command.editor.dialog.title.edit=Edit command (defined by user)
easyshell.command.editor.dialog.title.show=Show command (defined by plugin)
easyshell.command.editor.dialog.title.edit=Edit command defined by {0}
easyshell.command.editor.dialog.title.group1=Command
easyshell.command.editor.dialog.tooltip.group1=Add your command here
easyshell.command.editor.dialog.title.group2=Usable variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,46 +27,57 @@
public class CommandData extends Data {

// command
private CommandDataBasic basicData = null;
private PresetType presetType = PresetType.presetUnknown;
private OS os = OS.osUnknown;
private String name = "";
private ResourceType resourceType = ResourceType.resourceTypeUnknown;
private boolean useWorkingDirectory = false;
private String workingDirectory = "";
private Category category = Category.categoryUnknown;
private CommandType commandType = CommandType.commandTypeUnknown;
private String command = "";
private CommandDataBasic userData = null;

public CommandData(String id, PresetType presetType, OS os, String name, ResourceType resType, boolean useWorkingDirectory, String workingDirectory, Category category, CommandType cmdType, String command) {
public CommandData(String id, CommandDataBasic basicData, PresetType presetType, OS os, Category category, CommandType cmdType, CommandDataBasic userData) {
super(id);
setBasicData(basicData);
setPresetType(presetType);
setOs(os);
setName(name);
setResourceType(resType);
setUseWorkingDirectory(useWorkingDirectory);
setWorkingDirectory(workingDirectory);
setCategory(category);
setCommandType(cmdType);
setCommand(command);
setUserData(userData);
}

public CommandData(String id, PresetType presetType, OS os, String name, ResourceType resType, boolean useWorkingDirectory, String workingDirectory, Category category, CommandType cmdType, String command) {
this(id, new CommandDataBasic(name, resType, useWorkingDirectory, workingDirectory, command), presetType, os, category, cmdType, null);
}

public CommandData(String id, PresetType presetType, OS os, String name, ResourceType resType, Category category, CommandType cmdType, String command) {
this(id, presetType, os, name, resType, false, null, category, cmdType, command);
}

public CommandData(CommandData commandData, String newId) {
this(newId, commandData.getPresetType(), commandData.getOs(), commandData.getName(), commandData.getResourceType(), commandData.isUseWorkingDirectory(), commandData.getWorkingDirectory(), commandData.getCategory(), commandData.getCommandType(), commandData.getCommand());
this(newId, commandData.getBasicData(), commandData.getPresetType(), commandData.getOs(), commandData.getCategory(), commandData.getCommandType(), commandData.getUserData());
}

public CommandData(CommandData commandData, boolean generateNewId) {
this(commandData, generateNewId ? UUID.randomUUID().toString() : commandData.getId());
}

public CommandData() {
basicData = new CommandDataBasic();
}

public CommandDataBasic getBasicData() {
return basicData;
}

public CommandDataBasic getUserData() {
return userData;
}

public String getName() {
return name;
if (getPresetType() == PresetType.presetPluginAndUser) {
return userData.getName();
} else {
return basicData.getName();
}
}

public OS getOs() {
Expand All @@ -78,15 +89,27 @@ public PresetType getPresetType() {
}

public ResourceType getResourceType() {
return resourceType;
if (getPresetType() == PresetType.presetPluginAndUser) {
return userData.getResourceType();
} else {
return basicData.getResourceType();
}
}

public boolean isUseWorkingDirectory() {
return useWorkingDirectory;
if (getPresetType() == PresetType.presetPluginAndUser) {
return userData.isUseWorkingDirectory();
} else {
return basicData.isUseWorkingDirectory();
}
}

public String getWorkingDirectory() {
return workingDirectory;
if (getPresetType() == PresetType.presetPluginAndUser) {
return userData.getWorkingDirectory();
} else {
return basicData.getWorkingDirectory();
}
}

public Category getCategory() {
Expand All @@ -98,18 +121,56 @@ public CommandType getCommandType() {
}

public String getCommand() {
return command;
if (getPresetType() == PresetType.presetPluginAndUser) {
return userData.getCommand();
} else {
return basicData.getCommand();
}
}

public Image getCategoryImage() {
return new Image(null, Activator.getImageDescriptor(getCategory().getIcon()).getImageData());
}

public String getCommandAsComboName() {
return getCategory().getName() + " - " + getName() + " (" + getPresetType().getName() + ")" /*+ getOs().getName() + " - "*/;
}

public boolean checkIfUserDataOverridesPreset(CommandDataBasic userData) {
if (getPresetType() == PresetType.presetPlugin) {
return !basicData.equals(userData);
}
return false;
}

public void setBasicData(CommandDataBasic basicData) {
this.basicData = basicData;
}

public void setUserData(CommandDataBasic userData) {
this.userData = userData;
}

public void addUserData(CommandDataBasic userData) {
if (getPresetType() != PresetType.presetPluginAndUser) {
setPresetType(PresetType.presetPluginAndUser);
}
setUserData(userData);
}

public void removeUserData() {
if (getPresetType() == PresetType.presetPluginAndUser) {
setPresetType(PresetType.presetPlugin);
}
setUserData(null);
}

public void setName(String name) {
this.name = name;
if (getPresetType() == PresetType.presetPluginAndUser) {
userData.setName(name);
} else {
basicData.setName(name);
}
}

public void setOs(OS os) {
Expand All @@ -121,18 +182,26 @@ public void setPresetType(PresetType presetType) {
}

public void setResourceType(ResourceType resType) {
this.resourceType = resType;
if (getPresetType() == PresetType.presetPluginAndUser) {
userData.setResourceType(resType);
} else {
basicData.setResourceType(resType);
}
}

public void setUseWorkingDirectory(boolean useWorkingDirectory) {
this.useWorkingDirectory = useWorkingDirectory;
if (getPresetType() == PresetType.presetPluginAndUser) {
userData.setUseWorkingDirectory(useWorkingDirectory);
} else {
basicData.setUseWorkingDirectory(useWorkingDirectory);
}
}

public void setWorkingDirectory(String workingDirectory) {
if (workingDirectory != null) {
this.workingDirectory = workingDirectory;
if (getPresetType() == PresetType.presetPluginAndUser) {
userData.setWorkingDirectory(workingDirectory);
} else {
this.workingDirectory = "${easyshell:container_loc}";
basicData.setWorkingDirectory(workingDirectory);
}
}

Expand All @@ -145,7 +214,11 @@ public void setCommandType(CommandType cmdType) {
}

public void setCommand(String command) {
this.command = command;
if (getPresetType() == PresetType.presetPluginAndUser) {
userData.setCommand(command);
} else {
basicData.setCommand(command);
}
}

public boolean equals(Object object) {
Expand All @@ -154,13 +227,12 @@ public boolean equals(Object object) {
}
CommandData data = (CommandData)object;
if(data.getId().equals(this.getId())
/*data.getPosition() == this.getPosition() &&*/
/*data.getName().equals(this.getName()) &&
data.getOS() == this.getOS() &&
data.getPresetType() == this.getPresetType() &&
data.getResourceType() == this.getResourceType() &&
data.getCommandType() == this.getCommandType() &&
data.getCommand().equals(this.getCommand()*/
/*data.getPosition() == this.getPosition() &&
data.getBasicData().equals(this.getBasicData()) &&
data.getPresetType() == this.getPresetType() &&
data.getOS() == this.getOS() &&
data.getCategory() == this.getCategory() &&
data.getCommandType() == this.getCommandType() &&*/
)
{
return true;
Expand All @@ -179,25 +251,32 @@ public boolean deserialize(Version version, String value, StringTokenizer tokeni
setPosition(Integer.parseInt(tokenizer.nextToken()));
setId(tokenizer.nextToken());
// set command data members
setPresetType(PresetType.getFromEnum(tokenizer.nextToken()));
presetType = PresetType.getFromEnum(tokenizer.nextToken());
setOs(OS.getFromEnum(tokenizer.nextToken()));
setName(tokenizer.nextToken());
setResourceType(ResourceType.getFromEnum(tokenizer.nextToken()));
basicData.setName(tokenizer.nextToken());
basicData.setResourceType(ResourceType.getFromEnum(tokenizer.nextToken()));
// handling of working directory
if (version.getId() >= Version.v2_0_003.getId()) {
setUseWorkingDirectory(Boolean.valueOf(tokenizer.nextToken()).booleanValue());
setWorkingDirectory(tokenizer.nextToken());
basicData.setUseWorkingDirectory(Boolean.valueOf(tokenizer.nextToken()).booleanValue());
basicData.setWorkingDirectory(tokenizer.nextToken());
setCategory(Category.getFromEnum(tokenizer.nextToken()));
setCommandType(CommandType.getFromEnum(tokenizer.nextToken()));
} else {
setUseWorkingDirectory(false);
setWorkingDirectory("${easyshell:container_loc}");
basicData.setUseWorkingDirectory(false);
basicData.setWorkingDirectory("${easyshell:container_loc}");
String commandTypeStr = tokenizer.nextToken();
setCategory(Category.getFromDeprecatedCommandTypeEnum(commandTypeStr));
setCommandType(CommandType.getFromDeprecatedCommandTypeEnum(commandTypeStr));
}
// go on compatible
setCommand(tokenizer.nextToken());
basicData.setCommand(tokenizer.nextToken());
if (version.getId() >= Version.v2_0_005.getId()) {
// let read userData if there
if (getPresetType() == PresetType.presetPluginAndUser) {
setUserData(new CommandDataBasic());
userData.deserialize(version, null, tokenizer, delimiter);
}
}
return true;
}

Expand All @@ -210,15 +289,20 @@ public String serialize(Version version, String delimiter) {
ret += getId() + delimiter;
ret += getPresetType().toString() + delimiter;
ret += getOs().toString() + delimiter;
ret += getName() + delimiter;
ret += getResourceType().toString() + delimiter;
ret += basicData.getName() + delimiter;
ret += basicData.getResourceType().toString() + delimiter;
if (version.getId() >= Version.v2_0_003.getId()) {
ret += Boolean.toString(isUseWorkingDirectory()) + delimiter;
ret += getWorkingDirectory() + delimiter;
ret += Boolean.toString(basicData.isUseWorkingDirectory()) + delimiter;
ret += basicData.getWorkingDirectory() + delimiter;
ret += getCategory().toString() + delimiter;
}
ret += getCommandType().toString() + delimiter;
ret += getCommand() + delimiter;
ret += basicData.getCommand() + delimiter;
if (version.getId() >= Version.v2_0_005.getId()) {
if (getPresetType() == PresetType.presetPluginAndUser) {
ret += userData.serialize(version, delimiter);
}
}
return ret;
}

Expand Down
Loading

0 comments on commit e9c8f72

Please sign in to comment.