Skip to content

Commit

Permalink
#50 - [v2.0] issues found in early pre-release
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
anb0s committed Jul 5, 2016
1 parent 04c3bb3 commit 6aac781
Show file tree
Hide file tree
Showing 18 changed files with 373 additions and 319 deletions.
2 changes: 1 addition & 1 deletion plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<extension
point="org.eclipse.ui.preferencePages">
<page
class="de.anbos.eclipse.easyshell.plugin.preferences.PresetsPage"
class="de.anbos.eclipse.easyshell.plugin.preferences.CommandsPage"
id="de.anbos.eclipse.easyshell.plugin.preferences.PresetsPage"
name="EasyShell">
</page>
Expand Down
9 changes: 5 additions & 4 deletions plugin/src/de/anbos/eclipse/easyshell/plugin/Activator.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.net.URL;
import java.text.MessageFormat;
import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

Expand All @@ -27,6 +28,7 @@
import org.osgi.framework.BundleContext;

import de.anbos.eclipse.easyshell.plugin.preferences.Constants;
import de.anbos.eclipse.easyshell.plugin.preferences.CommandType;

/**
* The activator class controls the plug-in life cycle
Expand Down Expand Up @@ -96,10 +98,9 @@ public static ImageDescriptor getImageDescriptor(String id) {
}
protected void initializeImageRegistry(ImageRegistry registry) {
Bundle bundle = Platform.getBundle(Constants.PLUGIN_ID);
addImageToRegistry(registry, bundle, Constants.IMAGE_PATH + Constants.IMAGE_OPEN, Constants.IMAGE_OPEN);
addImageToRegistry(registry, bundle, Constants.IMAGE_PATH + Constants.IMAGE_RUN, Constants.IMAGE_RUN);
addImageToRegistry(registry, bundle, Constants.IMAGE_PATH + Constants.IMAGE_EXPLORE, Constants.IMAGE_EXPLORE);
addImageToRegistry(registry, bundle, Constants.IMAGE_PATH + Constants.IMAGE_CLIPBOARD, Constants.IMAGE_CLIPBOARD);
for (String icon : CommandType.getIconsAsList()) {
addImageToRegistry(registry, bundle, Constants.IMAGE_PATH + icon, icon);
}
}

protected void addImageToRegistry(ImageRegistry registry, Bundle bundle, String imagePath, String image_id) {
Expand Down
38 changes: 19 additions & 19 deletions plugin/src/de/anbos/eclipse/easyshell/plugin/UIMessages.properties
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
easyshell.plugin.name=EasyShell
easyshell.properties.main.page.title=EasyShell
easyshell.properties.presets.page.title=Presets
easyshell.properties.commands.page.title=Presets
easyshell.actionset.name=EasyShell

easyshell.preseteditor.table.header.column0.title=Name
easyshell.preseteditor.table.header.column1.title=Command
easyshell.preseteditor.button.add=Add...
easyshell.preseteditor.button.edit=Edit...
easyshell.preseteditor.button.remove=Remove
easyshell.preseteditor.button.up=Up
easyshell.preseteditor.button.down=Down
easyshell.command.editor.table.header.column0.title=Name
easyshell.command.editor.table.header.column1.title=Command
easyshell.command.editor.button.add=Add...
easyshell.command.editor.button.edit=Edit...
easyshell.command.editor.button.remove=Remove
easyshell.command.editor.button.up=Up
easyshell.command.editor.button.down=Down

easyshell.preseteditor.dialog.new.title=Create new preset
easyshell.preseteditor.dialog.edit.title=Edit existing preset
easyshell.preseteditor.dialog.title=Line selection
easyshell.command.editor.dialog.new.title=Create new command
easyshell.command.editor.dialog.edit.title=Edit existing command
easyshell.command.editor.dialog.title=Command definition

easyshell.preseteditor.dialog.error.incompletedata.title=Missing or Wrong command detected
easyshell.preseteditor.dialog.error.type.text=Please choose a type
easyshell.preseteditor.dialog.error.name.text=Please enter a valid name
easyshell.preseteditor.dialog.error.value.text=Please enter a valid command
easyshell.preseteditor.dialog.active.label=set active:
easyshell.preseteditor.dialog.combo.label=select type:
easyshell.preseteditor.dialog.name.label=enter name:
easyshell.preseteditor.dialog.value.label=enter command:
easyshell.command.editor.dialog.error.incompletedata.title=Missing or wrong command detected
easyshell.command.editor.dialog.error.type.text=Please choose a type
easyshell.command.editor.dialog.error.name.text=Please enter a valid name
easyshell.command.editor.dialog.error.value.text=Please enter a valid command
easyshell.command.editor.dialog.active.label=enabled:
easyshell.command.editor.dialog.combo.label=type:
easyshell.command.editor.dialog.name.label=name:
easyshell.command.editor.dialog.value.label=command:
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@
import de.anbos.eclipse.easyshell.plugin.DynamicVariableResolver;
import de.anbos.eclipse.easyshell.plugin.Resource;
import de.anbos.eclipse.easyshell.plugin.ResourceUtils;
import de.anbos.eclipse.easyshell.plugin.preferences.PresetType;
import de.anbos.eclipse.easyshell.plugin.preferences.CommandType;
import de.anbos.eclipse.easyshell.plugin.preferences.Quotes;

public class ActionDelegate implements IObjectActionDelegate {

private Resource[] resource = null;
private IStructuredSelection currentSelection;
private String commandValue = null;
private PresetType commandType = PresetType.presetTypeUnknown;
private CommandType commandType = CommandType.commandTypeUnknown;

public PresetType getCommandType() {
public CommandType getCommandType() {
return commandType;
}

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

Expand Down Expand Up @@ -79,7 +79,7 @@ public void run(IAction action) {

// String for all commands in case of clipboard
String cmdAll = null;
if (commandType == PresetType.presetTypeClipboard) {
if (commandType == CommandType.commandTypeClipboard) {
cmdAll = new String();
}

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

// handling copy to clipboard
if ((commandType == PresetType.presetTypeClipboard) && (cmdAll != null) && (cmdAll.length() != 0)) {
if ((commandType == CommandType.commandTypeClipboard) && (cmdAll != null) && (cmdAll.length() != 0)) {
Clipboard clipboard = new Clipboard(Display.getCurrent());
TextTransfer textTransfer = TextTransfer.getInstance();
Transfer[] transfers = new Transfer[]{textTransfer};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package de.anbos.eclipse.easyshell.plugin.commands;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.swt.SWT;
Expand All @@ -22,8 +23,8 @@
import org.eclipse.ui.services.IServiceLocator;

import de.anbos.eclipse.easyshell.plugin.Activator;
import de.anbos.eclipse.easyshell.plugin.preferences.PresetData;
import de.anbos.eclipse.easyshell.plugin.preferences.PresetsStore;
import de.anbos.eclipse.easyshell.plugin.preferences.CommandData;
import de.anbos.eclipse.easyshell.plugin.preferences.CommandsStore;

public class DefineCommands extends ExtensionContributionFactory {

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

// load the preferences
PresetsStore store = new PresetsStore(Activator.getDefault().getPreferenceStore());
CommandsStore store = new CommandsStore(Activator.getDefault().getPreferenceStore());
store.load();
PresetData[] items = store.getAllEnabledPresets();
for (int i = 0; i < items.length; ++i) {
List<CommandData> items = store.getAllEnabledCommands();
for (CommandData item : items) {
addItem(serviceLocator, additions,
items[i].getMenuName(),
item.getMenuName(),
"de.anbos.eclipse.easyshell.plugin.commands.execute",
"de.anbos.eclipse.easyshell.plugin.commands.parameter.type",
items[i].getTypeAction(),
item.getTypeAction(),
"de.anbos.eclipse.easyshell.plugin.commands.parameter.value",
items[i].getValue(),
items[i].getMenuIcon());
item.getValue(),
item.getMenuIcon());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import de.anbos.eclipse.easyshell.plugin.EditorPropertyTester;
import de.anbos.eclipse.easyshell.plugin.actions.Action;
import de.anbos.eclipse.easyshell.plugin.actions.ActionDelegate;
import de.anbos.eclipse.easyshell.plugin.preferences.PresetType;
import de.anbos.eclipse.easyshell.plugin.preferences.CommandType;

public class CommandHandler extends AbstractHandler {

Expand All @@ -32,7 +32,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
String commandID = event.getCommand().getId();
String commandType = event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.type");
String commanValue = event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.value");
action.setCommandType(PresetType.getFromAction(commandType));
action.setCommandType(CommandType.getFromAction(commandType));
action.setCommandValue(commanValue);
Action act = new Action(commandID);
action.run((IAction)act);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;

public class PresetContentProvider implements IStructuredContentProvider {
public class CommandContentProvider implements IStructuredContentProvider {

private PresetsStore store;
private CommandsStore store;

public Object[] getElements(Object inputElement) {
return store.getAllPresets().toArray();
return store.getAllCommandsArray();
}

public void dispose() {
store = null;
}

public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if(newInput instanceof PresetsStore) {
store = (PresetsStore)newInput;
if(newInput instanceof CommandsStore) {
store = (CommandsStore)newInput;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.StringTokenizer;
import java.util.UUID;

public class PresetData {
public class CommandData {

// Status
private int position = 0;
Expand All @@ -23,18 +23,18 @@ public class PresetData {
// Preset
private String id = UUID.randomUUID().toString();
private String name = "Name";
private PresetType type = PresetType.presetTypeOpen;
private CommandType type = CommandType.commandTypeOpen;
private String command = "command";
private OS os = OS.osWindows;

public PresetData(OS os, String name, PresetType type, String command) {
public CommandData(OS os, String name, CommandType type, String command) {
this.os = os;
this.name = name;
this.type = type;
this.command = command;
}

public PresetData() {
public CommandData() {
}

public int getPosition() {
Expand All @@ -53,7 +53,7 @@ public String getName() {
return name;
}

public PresetType getType() {
public CommandType getType() {
return type;
}

Expand Down Expand Up @@ -81,7 +81,7 @@ public void setName(String name) {
this.name = name;
}

public void setType(PresetType type) {
public void setType(CommandType type) {
this.type = type;
}

Expand All @@ -94,10 +94,10 @@ public void setOs(OS os) {
}

public boolean equals(Object object) {
if(!(object instanceof PresetData)) {
if(!(object instanceof CommandData)) {
return false;
}
PresetData data = (PresetData)object;
CommandData data = (CommandData)object;
if(data.getPosition() == this.getPosition() &
data.getId().equals(this.getId()) &
data.getName().equals(this.getName()) &
Expand Down Expand Up @@ -128,7 +128,7 @@ public boolean fillTokens(String value, String delimiter) {
setEnabled(Boolean.valueOf(enabledStr).booleanValue());
setId(idStr);
setName(nameStr);
setType(PresetType.getFromName(typeStr));
setType(CommandType.getFromName(typeStr));
setValue(valueStr);
setOs(OS.getFromName(osStr));
return true;
Expand Down
Loading

0 comments on commit 6aac781

Please sign in to comment.