Skip to content

Commit

Permalink
#136 [v2.0] possibility to change menu icons
Browse files Browse the repository at this point in the history
- dialog
- set and reset handling
- tooltips

Signed-off-by: Andre Bossert <anb0s@anbos.de>
  • Loading branch information
anb0s committed Apr 21, 2017
1 parent 2823511 commit 60326e1
Show file tree
Hide file tree
Showing 7 changed files with 464 additions and 429 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ easyshell.main.page.dialog.defaults.title=Restore defaults
easyshell.main.page.dialog.defaults.question=All your settings will be overwritten!\n\nYou can still use "Cancel" button afterwards for undo.\n\nDo you really want to restore default settings?
easyshell.main.page.dialog.migration.title=Migration
easyshell.main.page.dialog.migration.question=You have canceled the migration of settings from previous version.\n\nAll your settings will be written now and migration will be skipped completely!\n\nDo you really want to overwrite the migrated settings?
easyshell.main.page.error.title.incompletedata=Missing or wrong parameters
easyshell.error.title.incompletedata=Missing or wrong parameters
easyshell.main.page.error.text.debug=Please choose a valid debug type

easyshell.main.page.title.group1=General
Expand Down Expand Up @@ -101,6 +101,10 @@ easyshell.menu.editor.dialog.label.combo.pattern=Pattern:
easyshell.menu.editor.dialog.combo.tooltip.pattern=Select the name pattern for menu item
easyshell.menu.editor.dialog.label.name=Preview:
easyshell.menu.editor.dialog.label.tooltip.name=Preview of menu item
easyshell.menu.editor.dialog.button.tooltip.image=Select menu icon
easyshell.menu.editor.dialog.image.title=Menu icon selection
easyshell.menu.editor.dialog.image.text=Select the icon from the tree:
easyshell.menu.editor.dialog.image.none=reset to icon from command category
easyshell.menu.editor.dialog.label.pattern=Name:
easyshell.menu.editor.dialog.label.tooltip.pattern=The selected or entered name pattern
easyshell.menu.editor.dialog.label.text.filter=Filter:
Expand Down Expand Up @@ -141,7 +145,6 @@ easyshell.command.editor.dialog.title.group2=Usable variables
easyshell.command.editor.dialog.tooltip.group2=Double click at variable name copies it to clipboard
easyshell.command.editor.dialog.title.group3=Usable converters
easyshell.command.editor.dialog.tooltip.group3=Double click at converter name copies it to clipboard
easyshell.command.editor.dialog.error.title.incompletedata=Missing or wrong parameters
easyshell.command.editor.dialog.error.text.resource=Please choose a valid resource type
easyshell.command.editor.dialog.error.text.category=Please choose a valid category
easyshell.command.editor.dialog.error.text.type=Please choose a valid command type
Expand Down
32 changes: 17 additions & 15 deletions plugin/src/de/anbos/eclipse/easyshell/plugin/misc/UtilsUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,40 @@ static public void createLabel(Composite parent, String name, String tooltip) {
label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
label.setText(name);
if (tooltip != null) {
label.setToolTipText(tooltip);
label.setToolTipText(tooltip);
}
}

static public Label createLabel(Composite parent, String imageId, String text, String tooltip) {
Label label = new Label(parent, SWT.LEFT);
label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
if (text != null) {
label.setText(text);
label.setToolTipText(tooltip);
}
if (text != null) {
label.setText(text);
label.setToolTipText(tooltip);
}
label.setImage(Activator.getImage(imageId));
return label;
}

static public Label createImageLabel(Composite parent, String imageId) {
return createLabel(parent, imageId, null, null);
return createLabel(parent, imageId, null, null);
}

static public Button createButton(Composite parent, String imageId, String text, String tooltip) {
Button button = new Button(parent, SWT.LEFT);
button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
if (text!=null) {
button.setText(text);
button.setToolTipText(tooltip);
}
button.setImage(Activator.getImage(imageId));
Button button = new Button(parent, SWT.LEFT);
button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
if (text!=null) {
button.setText(text);
}
if (tooltip != null) {
button.setToolTipText(tooltip);
}
button.setImage(Activator.getImage(imageId));
return button;
}

static public Button createImageButton(Composite parent, String imageId) {
return createButton(parent, imageId, null, null);
static public Button createImageButton(Composite parent, String imageId, String tooltip) {
return createButton(parent, imageId, null, tooltip);
}

static public void refreshWidget(Widget widget) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,19 @@ public String getCommand() {
}

public String getImageId() {
if (!imageId.equals(Constants.IMAGE_NONE)) {
return imageId;
} else {
return getCategory().getImageId();
}
if (imageId.equals(Constants.IMAGE_NONE)) {
return getCategoryImageId();
} else {
return imageId;
}
}

public String getCategoryImageId() {
return getCategory().getImageId();
}

public String getImageIdOwn() {
return imageId;
return imageId;
}

public String getCommandAsComboName() {
Expand Down Expand Up @@ -184,7 +188,7 @@ public void removeModifyData() {

public void addOrRemoveModifyData(CommandDataBasic modifyData) {
if (checkIfUserDataOverridesPreset(modifyData)) {
addModifyData(modifyData);
addModifyData(modifyData);
} else {
removeModifyData();
}
Expand All @@ -203,37 +207,37 @@ public void setCategory(Category category) {
}

private void setImageId(String imageId) {
if (imageId != null) {
this.imageId = imageId;
} else {
this.imageId = Constants.IMAGE_NONE;
}
}
if (imageId == null || imageId.equals(Constants.IMAGE_NONE) || imageId.equals(getCategoryImageId())) {
this.imageId = Constants.IMAGE_NONE;
} else {
this.imageId = imageId;
}
}

public void setCommandType(CommandType cmdType) {
this.commandType = cmdType;
}

public boolean equals(Object object) {
if(!(object instanceof CommandData)) {
return false;
}
CommandData data = (CommandData)object;
if(data.getId().equals(this.getId())
/*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;
}
return false;
}

public boolean deserialize(Version version, String value, StringTokenizer tokenizer, String delimiter) {
public boolean equals(Object object) {
if(!(object instanceof CommandData)) {
return false;
}
CommandData data = (CommandData)object;
if(data.getId().equals(this.getId())
/*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;
}
return false;
}

public boolean deserialize(Version version, String value, StringTokenizer tokenizer, String delimiter) {
if((value == null || value.length() <= 0) && tokenizer == null) {
return false;
}
Expand All @@ -242,11 +246,11 @@ public boolean deserialize(Version version, String value, StringTokenizer tokeni
}
// set internal members
setPosition(Integer.parseInt(tokenizer.nextToken()));
setId(tokenizer.nextToken());
// set command data members
String presetTypeStr = tokenizer.nextToken();
setId(tokenizer.nextToken());
// set command data members
String presetTypeStr = tokenizer.nextToken();
if (version.getId() < Version.v2_1_001.getId() && presetTypeStr.equals("presetPluginAndUser")) {
presetTypeStr = "presetPluginModify";
presetTypeStr = "presetPluginModify";
}
presetType = PresetType.getFromEnum(presetTypeStr);
setOs(OS.getFromEnum(tokenizer.nextToken()));
Expand All @@ -257,49 +261,49 @@ public boolean deserialize(Version version, String value, StringTokenizer tokeni
resourceTypeStr = "resourceTypeDirectory";
}
basicData.setResourceType(ResourceType.getFromEnum(resourceTypeStr));
// handling of working directory, category and imageId
// handling of working directory, category and imageId
String imageIdStr = Constants.IMAGE_NONE;
if (version.getId() >= Version.v2_0_003.getId()) {
basicData.setUseWorkingDirectory(Boolean.valueOf(tokenizer.nextToken()).booleanValue());
basicData.setWorkingDirectory(tokenizer.nextToken());
String categoryStr = tokenizer.nextToken();
if (version.getId() < Version.v2_0_005.getId() && categoryStr.equals("categoryOther")) {
categoryStr = "categoryUser";
}
setCategory(Category.getFromEnum(categoryStr));
if (version.getId() >= Version.v2_1_005.getId()) {
imageIdStr = tokenizer.nextToken();
}
setCommandType(CommandType.getFromEnum(tokenizer.nextToken()));
} else {
basicData.setUseWorkingDirectory(false);
basicData.setWorkingDirectory("${easyshell:container_loc}");
String commandTypeStr = tokenizer.nextToken();
setCategory(Category.getFromDeprecatedCommandTypeEnum(commandTypeStr));
setCommandType(CommandType.getFromDeprecatedCommandTypeEnum(commandTypeStr));
}
setImageId(imageIdStr);
// go on compatible
String commandTokenizer = CommandTokenizer.commandTokenizerSpaces.toString();
if (version.getId() >= Version.v2_0_003.getId()) {
basicData.setUseWorkingDirectory(Boolean.valueOf(tokenizer.nextToken()).booleanValue());
basicData.setWorkingDirectory(tokenizer.nextToken());
String categoryStr = tokenizer.nextToken();
if (version.getId() < Version.v2_0_005.getId() && categoryStr.equals("categoryOther")) {
categoryStr = "categoryUser";
}
setCategory(Category.getFromEnum(categoryStr));
if (version.getId() >= Version.v2_1_005.getId()) {
imageIdStr = tokenizer.nextToken();
}
setCommandType(CommandType.getFromEnum(tokenizer.nextToken()));
} else {
basicData.setUseWorkingDirectory(false);
basicData.setWorkingDirectory("${easyshell:container_loc}");
String commandTypeStr = tokenizer.nextToken();
setCategory(Category.getFromDeprecatedCommandTypeEnum(commandTypeStr));
setCommandType(CommandType.getFromDeprecatedCommandTypeEnum(commandTypeStr));
}
setImageId(imageIdStr);
// go on compatible
String commandTokenizer = CommandTokenizer.commandTokenizerSpaces.toString();
if (version.getId() >= Version.v2_1_001.getId()) {
String oldCommandTokenizer = tokenizer.nextToken();
if (version.getId() >= Version.v2_1_003.getId()) {
commandTokenizer = oldCommandTokenizer;
}
String oldCommandTokenizer = tokenizer.nextToken();
if (version.getId() >= Version.v2_1_003.getId()) {
commandTokenizer = oldCommandTokenizer;
}
}
basicData.setCommandTokenizer(CommandTokenizer.getFromEnum(commandTokenizer));
basicData.setCommand(tokenizer.nextToken());
if (version.getId() >= Version.v2_0_005.getId()) {
if (version.getId() < Version.v2_1_001.getId()) {
// let read modifyData if there
if (getPresetType() == PresetType.presetPluginModify) {
setModifyData(new CommandDataBasic(getId()));
modifyData.deserialize(version, null, tokenizer, delimiter);
}
}
}
return true;
}
basicData.setCommand(tokenizer.nextToken());
if (version.getId() >= Version.v2_0_005.getId()) {
if (version.getId() < Version.v2_1_001.getId()) {
// let read modifyData if there
if (getPresetType() == PresetType.presetPluginModify) {
setModifyData(new CommandDataBasic(getId()));
modifyData.deserialize(version, null, tokenizer, delimiter);
}
}
}
return true;
}

public boolean deserialize(String value, StringTokenizer tokenizer, String delimiter) {
return deserialize(Version.actual, value, tokenizer, delimiter);
Expand All @@ -310,9 +314,9 @@ public String serialize(Version version, String delimiter) {
ret += getId() + delimiter;
PresetType presetTypeTemp = getPresetType();
if (version.getId() >= Version.v2_1_001.getId()) {
if (presetTypeTemp == PresetType.presetPluginModify) {
presetTypeTemp = PresetType.presetPlugin;
}
if (presetTypeTemp == PresetType.presetPluginModify) {
presetTypeTemp = PresetType.presetPlugin;
}
}
ret += presetTypeTemp.toString() + delimiter;
ret += getOs().toString() + delimiter;
Expand All @@ -323,20 +327,20 @@ public String serialize(Version version, String delimiter) {
ret += basicData.getWorkingDirectory() + delimiter;
ret += getCategory().toString() + delimiter;
if (version.getId() >= Version.v2_1_005.getId()) {
ret += getImageIdOwn() + delimiter;
ret += getImageIdOwn() + delimiter;
}
}
ret += getCommandType().toString() + delimiter;
if (version.getId() >= Version.v2_1_001.getId()) {
ret += basicData.getCommandTokenizer().toString() + delimiter;
ret += basicData.getCommandTokenizer().toString() + delimiter;
}
ret += basicData.getCommand() + delimiter;
if (version.getId() >= Version.v2_0_005.getId()) {
if (version.getId() < Version.v2_1_001.getId()) {
if (getPresetType() == PresetType.presetPluginModify) {
ret += modifyData.serialize(version, delimiter);
}
}
if (version.getId() < Version.v2_1_001.getId()) {
if (getPresetType() == PresetType.presetPluginModify) {
ret += modifyData.serialize(version, delimiter);
}
}
}
return ret;
}
Expand All @@ -345,17 +349,17 @@ public String serialize(String delimiter) {
return serialize(Version.actual, delimiter);
}

public void setSelected(boolean selected) {
this.selected = selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}

public boolean isSelected() {
return this.selected;
}
public boolean isSelected() {
return this.selected;
}

@Override
public boolean verify() {
return super.verify() && basicData != null && basicData.verify();
}
public boolean verify() {
return super.verify() && basicData != null && basicData.verify();
}

}
Loading

0 comments on commit 60326e1

Please sign in to comment.