Skip to content

Commit 6aac781

Browse files
committed
#50 - [v2.0] issues found in early pre-release
Adressed 1. There is a NPE if you create an item and then change its "type" to "Other" (and you click "OK") 2. Would be nice to list the new names to use as arguments since "{1}", "{2}", etc. don't work anymore. 3. Another small bug: when you click the "Edit" button for an item, its "type" is always reset to "Open". 4. Another small bug in this alpha version: when you edit an item, it doesn't keep its place, it is moved as the first item of the list. - fixed checked state after "Restore Defaults" - renamed preset to command - made dialog bigger and enable resizing Signed-off-by: Andre Bossert <anb0s@anbos.de>
1 parent 04c3bb3 commit 6aac781

18 files changed

+373
-319
lines changed

plugin/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<extension
6161
point="org.eclipse.ui.preferencePages">
6262
<page
63-
class="de.anbos.eclipse.easyshell.plugin.preferences.PresetsPage"
63+
class="de.anbos.eclipse.easyshell.plugin.preferences.CommandsPage"
6464
id="de.anbos.eclipse.easyshell.plugin.preferences.PresetsPage"
6565
name="EasyShell">
6666
</page>

plugin/src/de/anbos/eclipse/easyshell/plugin/Activator.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import java.net.URL;
1515
import java.text.MessageFormat;
16+
import java.util.List;
1617
import java.util.MissingResourceException;
1718
import java.util.ResourceBundle;
1819

@@ -27,6 +28,7 @@
2728
import org.osgi.framework.BundleContext;
2829

2930
import de.anbos.eclipse.easyshell.plugin.preferences.Constants;
31+
import de.anbos.eclipse.easyshell.plugin.preferences.CommandType;
3032

3133
/**
3234
* The activator class controls the plug-in life cycle
@@ -96,10 +98,9 @@ public static ImageDescriptor getImageDescriptor(String id) {
9698
}
9799
protected void initializeImageRegistry(ImageRegistry registry) {
98100
Bundle bundle = Platform.getBundle(Constants.PLUGIN_ID);
99-
addImageToRegistry(registry, bundle, Constants.IMAGE_PATH + Constants.IMAGE_OPEN, Constants.IMAGE_OPEN);
100-
addImageToRegistry(registry, bundle, Constants.IMAGE_PATH + Constants.IMAGE_RUN, Constants.IMAGE_RUN);
101-
addImageToRegistry(registry, bundle, Constants.IMAGE_PATH + Constants.IMAGE_EXPLORE, Constants.IMAGE_EXPLORE);
102-
addImageToRegistry(registry, bundle, Constants.IMAGE_PATH + Constants.IMAGE_CLIPBOARD, Constants.IMAGE_CLIPBOARD);
101+
for (String icon : CommandType.getIconsAsList()) {
102+
addImageToRegistry(registry, bundle, Constants.IMAGE_PATH + icon, icon);
103+
}
103104
}
104105

105106
protected void addImageToRegistry(ImageRegistry registry, Bundle bundle, String imagePath, String image_id) {
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
easyshell.plugin.name=EasyShell
22
easyshell.properties.main.page.title=EasyShell
3-
easyshell.properties.presets.page.title=Presets
3+
easyshell.properties.commands.page.title=Presets
44
easyshell.actionset.name=EasyShell
55

6-
easyshell.preseteditor.table.header.column0.title=Name
7-
easyshell.preseteditor.table.header.column1.title=Command
8-
easyshell.preseteditor.button.add=Add...
9-
easyshell.preseteditor.button.edit=Edit...
10-
easyshell.preseteditor.button.remove=Remove
11-
easyshell.preseteditor.button.up=Up
12-
easyshell.preseteditor.button.down=Down
6+
easyshell.command.editor.table.header.column0.title=Name
7+
easyshell.command.editor.table.header.column1.title=Command
8+
easyshell.command.editor.button.add=Add...
9+
easyshell.command.editor.button.edit=Edit...
10+
easyshell.command.editor.button.remove=Remove
11+
easyshell.command.editor.button.up=Up
12+
easyshell.command.editor.button.down=Down
1313

14-
easyshell.preseteditor.dialog.new.title=Create new preset
15-
easyshell.preseteditor.dialog.edit.title=Edit existing preset
16-
easyshell.preseteditor.dialog.title=Line selection
14+
easyshell.command.editor.dialog.new.title=Create new command
15+
easyshell.command.editor.dialog.edit.title=Edit existing command
16+
easyshell.command.editor.dialog.title=Command definition
1717

18-
easyshell.preseteditor.dialog.error.incompletedata.title=Missing or Wrong command detected
19-
easyshell.preseteditor.dialog.error.type.text=Please choose a type
20-
easyshell.preseteditor.dialog.error.name.text=Please enter a valid name
21-
easyshell.preseteditor.dialog.error.value.text=Please enter a valid command
22-
easyshell.preseteditor.dialog.active.label=set active:
23-
easyshell.preseteditor.dialog.combo.label=select type:
24-
easyshell.preseteditor.dialog.name.label=enter name:
25-
easyshell.preseteditor.dialog.value.label=enter command:
18+
easyshell.command.editor.dialog.error.incompletedata.title=Missing or wrong command detected
19+
easyshell.command.editor.dialog.error.type.text=Please choose a type
20+
easyshell.command.editor.dialog.error.name.text=Please enter a valid name
21+
easyshell.command.editor.dialog.error.value.text=Please enter a valid command
22+
easyshell.command.editor.dialog.active.label=enabled:
23+
easyshell.command.editor.dialog.combo.label=type:
24+
easyshell.command.editor.dialog.name.label=name:
25+
easyshell.command.editor.dialog.value.label=command:

plugin/src/de/anbos/eclipse/easyshell/plugin/actions/ActionDelegate.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@
3030
import de.anbos.eclipse.easyshell.plugin.DynamicVariableResolver;
3131
import de.anbos.eclipse.easyshell.plugin.Resource;
3232
import de.anbos.eclipse.easyshell.plugin.ResourceUtils;
33-
import de.anbos.eclipse.easyshell.plugin.preferences.PresetType;
33+
import de.anbos.eclipse.easyshell.plugin.preferences.CommandType;
3434
import de.anbos.eclipse.easyshell.plugin.preferences.Quotes;
3535

3636
public class ActionDelegate implements IObjectActionDelegate {
3737

3838
private Resource[] resource = null;
3939
private IStructuredSelection currentSelection;
4040
private String commandValue = null;
41-
private PresetType commandType = PresetType.presetTypeUnknown;
41+
private CommandType commandType = CommandType.commandTypeUnknown;
4242

43-
public PresetType getCommandType() {
43+
public CommandType getCommandType() {
4444
return commandType;
4545
}
4646

47-
public void setCommandType(PresetType commandType) {
47+
public void setCommandType(CommandType commandType) {
4848
this.commandType = commandType;
4949
}
5050

@@ -79,7 +79,7 @@ public void run(IAction action) {
7979

8080
// String for all commands in case of clipboard
8181
String cmdAll = null;
82-
if (commandType == PresetType.presetTypeClipboard) {
82+
if (commandType == CommandType.commandTypeClipboard) {
8383
cmdAll = new String();
8484
}
8585

@@ -133,7 +133,7 @@ public void run(IAction action) {
133133
// variable format
134134
DynamicVariableResolver.setArgs(args);
135135
// handling copy to clipboard
136-
if (commandType == PresetType.presetTypeClipboard) {
136+
if (commandType == CommandType.commandTypeClipboard) {
137137
String cmd = fixQuotes(variableManager.performStringSubstitution(target, false), quotes);
138138
//Activator.getDefault().sysout(true, "--- clp: >");
139139
cmdAll += cmd;
@@ -185,7 +185,7 @@ public void run(IAction action) {
185185
}
186186

187187
// handling copy to clipboard
188-
if ((commandType == PresetType.presetTypeClipboard) && (cmdAll != null) && (cmdAll.length() != 0)) {
188+
if ((commandType == CommandType.commandTypeClipboard) && (cmdAll != null) && (cmdAll.length() != 0)) {
189189
Clipboard clipboard = new Clipboard(Display.getCurrent());
190190
TextTransfer textTransfer = TextTransfer.getInstance();
191191
Transfer[] transfers = new Transfer[]{textTransfer};

plugin/src/de/anbos/eclipse/easyshell/plugin/commands/DefineCommands.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
package de.anbos.eclipse.easyshell.plugin.commands;
1313

1414
import java.util.HashMap;
15+
import java.util.List;
1516
import java.util.Map;
1617

1718
import org.eclipse.swt.SWT;
@@ -22,8 +23,8 @@
2223
import org.eclipse.ui.services.IServiceLocator;
2324

2425
import de.anbos.eclipse.easyshell.plugin.Activator;
25-
import de.anbos.eclipse.easyshell.plugin.preferences.PresetData;
26-
import de.anbos.eclipse.easyshell.plugin.preferences.PresetsStore;
26+
import de.anbos.eclipse.easyshell.plugin.preferences.CommandData;
27+
import de.anbos.eclipse.easyshell.plugin.preferences.CommandsStore;
2728

2829
public class DefineCommands extends ExtensionContributionFactory {
2930

@@ -35,18 +36,18 @@ public void createContributionItems(IServiceLocator serviceLocator,
3536
IContributionRoot additions) {
3637

3738
// load the preferences
38-
PresetsStore store = new PresetsStore(Activator.getDefault().getPreferenceStore());
39+
CommandsStore store = new CommandsStore(Activator.getDefault().getPreferenceStore());
3940
store.load();
40-
PresetData[] items = store.getAllEnabledPresets();
41-
for (int i = 0; i < items.length; ++i) {
41+
List<CommandData> items = store.getAllEnabledCommands();
42+
for (CommandData item : items) {
4243
addItem(serviceLocator, additions,
43-
items[i].getMenuName(),
44+
item.getMenuName(),
4445
"de.anbos.eclipse.easyshell.plugin.commands.execute",
4546
"de.anbos.eclipse.easyshell.plugin.commands.parameter.type",
46-
items[i].getTypeAction(),
47+
item.getTypeAction(),
4748
"de.anbos.eclipse.easyshell.plugin.commands.parameter.value",
48-
items[i].getValue(),
49-
items[i].getMenuIcon());
49+
item.getValue(),
50+
item.getMenuIcon());
5051
}
5152
}
5253

plugin/src/de/anbos/eclipse/easyshell/plugin/handlers/CommandHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import de.anbos.eclipse.easyshell.plugin.EditorPropertyTester;
2222
import de.anbos.eclipse.easyshell.plugin.actions.Action;
2323
import de.anbos.eclipse.easyshell.plugin.actions.ActionDelegate;
24-
import de.anbos.eclipse.easyshell.plugin.preferences.PresetType;
24+
import de.anbos.eclipse.easyshell.plugin.preferences.CommandType;
2525

2626
public class CommandHandler extends AbstractHandler {
2727

@@ -32,7 +32,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
3232
String commandID = event.getCommand().getId();
3333
String commandType = event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.type");
3434
String commanValue = event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.value");
35-
action.setCommandType(PresetType.getFromAction(commandType));
35+
action.setCommandType(CommandType.getFromAction(commandType));
3636
action.setCommandValue(commanValue);
3737
Action act = new Action(commandID);
3838
action.run((IAction)act);

plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/PresetContentProvider.java renamed to plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandContentProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@
1414
import org.eclipse.jface.viewers.IStructuredContentProvider;
1515
import org.eclipse.jface.viewers.Viewer;
1616

17-
public class PresetContentProvider implements IStructuredContentProvider {
17+
public class CommandContentProvider implements IStructuredContentProvider {
1818

19-
private PresetsStore store;
19+
private CommandsStore store;
2020

2121
public Object[] getElements(Object inputElement) {
22-
return store.getAllPresets().toArray();
22+
return store.getAllCommandsArray();
2323
}
2424

2525
public void dispose() {
2626
store = null;
2727
}
2828

2929
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
30-
if(newInput instanceof PresetsStore) {
31-
store = (PresetsStore)newInput;
30+
if(newInput instanceof CommandsStore) {
31+
store = (CommandsStore)newInput;
3232
}
3333
}
3434

plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/PresetData.java renamed to plugin/src/de/anbos/eclipse/easyshell/plugin/preferences/CommandData.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import java.util.StringTokenizer;
1515
import java.util.UUID;
1616

17-
public class PresetData {
17+
public class CommandData {
1818

1919
// Status
2020
private int position = 0;
@@ -23,18 +23,18 @@ public class PresetData {
2323
// Preset
2424
private String id = UUID.randomUUID().toString();
2525
private String name = "Name";
26-
private PresetType type = PresetType.presetTypeOpen;
26+
private CommandType type = CommandType.commandTypeOpen;
2727
private String command = "command";
2828
private OS os = OS.osWindows;
2929

30-
public PresetData(OS os, String name, PresetType type, String command) {
30+
public CommandData(OS os, String name, CommandType type, String command) {
3131
this.os = os;
3232
this.name = name;
3333
this.type = type;
3434
this.command = command;
3535
}
3636

37-
public PresetData() {
37+
public CommandData() {
3838
}
3939

4040
public int getPosition() {
@@ -53,7 +53,7 @@ public String getName() {
5353
return name;
5454
}
5555

56-
public PresetType getType() {
56+
public CommandType getType() {
5757
return type;
5858
}
5959

@@ -81,7 +81,7 @@ public void setName(String name) {
8181
this.name = name;
8282
}
8383

84-
public void setType(PresetType type) {
84+
public void setType(CommandType type) {
8585
this.type = type;
8686
}
8787

@@ -94,10 +94,10 @@ public void setOs(OS os) {
9494
}
9595

9696
public boolean equals(Object object) {
97-
if(!(object instanceof PresetData)) {
97+
if(!(object instanceof CommandData)) {
9898
return false;
9999
}
100-
PresetData data = (PresetData)object;
100+
CommandData data = (CommandData)object;
101101
if(data.getPosition() == this.getPosition() &
102102
data.getId().equals(this.getId()) &
103103
data.getName().equals(this.getName()) &
@@ -128,7 +128,7 @@ public boolean fillTokens(String value, String delimiter) {
128128
setEnabled(Boolean.valueOf(enabledStr).booleanValue());
129129
setId(idStr);
130130
setName(nameStr);
131-
setType(PresetType.getFromName(typeStr));
131+
setType(CommandType.getFromName(typeStr));
132132
setValue(valueStr);
133133
setOs(OS.getFromName(osStr));
134134
return true;

0 commit comments

Comments
 (0)