mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
consolidated menus
This commit is contained in:
@@ -6,6 +6,8 @@ public interface IKeyProcessor {
|
||||
public static final int VK_UP = 0x26;
|
||||
public static final int VK_RIGHT = 0x27;
|
||||
public static final int VK_DOWN = 0x28;
|
||||
public static final int VK_H = 0x48;
|
||||
public static final int VK_V = 0x56;
|
||||
|
||||
/**
|
||||
* Notifies the presenter that a key hes been pressed on the canvas.
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -559,7 +559,7 @@ public class Presenter implements IPlugInPort {
|
||||
|| !newSelection.contains(topComponent)) {
|
||||
newSelection.clear();
|
||||
}
|
||||
|
||||
|
||||
newSelection.addAll(findAllGroupedComponents(topComponent));
|
||||
}
|
||||
}
|
||||
@@ -575,7 +575,8 @@ public class Presenter implements IPlugInPort {
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int key, boolean ctrlDown, boolean shiftDown, boolean altDown) {
|
||||
if (key != VK_DOWN && key != VK_LEFT && key != VK_UP && key != VK_RIGHT) {
|
||||
if (key != VK_DOWN && key != VK_LEFT && key != VK_UP && key != VK_RIGHT && key != IKeyProcessor.VK_H
|
||||
&& key != IKeyProcessor.VK_V) {
|
||||
return false;
|
||||
}
|
||||
LOG.debug(String.format("keyPressed(%s, %s, %s, %s)", key, ctrlDown, shiftDown, altDown));
|
||||
@@ -609,6 +610,12 @@ public class Presenter implements IPlugInPort {
|
||||
} else if (key == IKeyProcessor.VK_LEFT) {
|
||||
oldProject = currentProject.clone();
|
||||
rotateComponents(this.selectedComponents, -1, snapToGrid);
|
||||
} else if (key == IKeyProcessor.VK_H) {
|
||||
oldProject = currentProject.clone();
|
||||
mirrorSelection(ISelectionProcessor.HORIZONTAL);
|
||||
} else if (key == IKeyProcessor.VK_V) {
|
||||
oldProject = currentProject.clone();
|
||||
mirrorSelection(ISelectionProcessor.VERTICAL);
|
||||
} else
|
||||
return false;
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(),
|
||||
@@ -1898,12 +1905,14 @@ public class Presenter implements IPlugInPort {
|
||||
ComponentType selectedType = null;
|
||||
Iterator<IDIYComponent<?>> iterator = this.selectedComponents.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ComponentType type = ComponentProcessor.getInstance().extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) iterator.next().getClass());
|
||||
ComponentType type =
|
||||
ComponentProcessor.getInstance().extractComponentTypeFrom(
|
||||
(Class<? extends IDIYComponent<?>>) iterator.next().getClass());
|
||||
if (selectedType == null)
|
||||
selectedType = type;
|
||||
else if (selectedType.getInstanceClass() != type.getInstanceClass())
|
||||
throw new RuntimeException("Template can be applied on multiple components of the same type only");
|
||||
}
|
||||
}
|
||||
return getTemplatesFor(selectedType.getCategory(), selectedType.getName());
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -37,7 +37,7 @@ public enum IconLoader {
|
||||
"nav_right_blue.png"), MissingImage("missing_image.png"), CloudBg("cloud_bg.png"), CloudBig("cloud_big.png"), CloudWait(
|
||||
"cloud_wait.png"), Spinning("spinning.gif"), Megaphone("megaphone.png"), Download("download.png"), Eye("eye.png"), Messages(
|
||||
"messages.png"), SearchBox("search-box.png"), Screwdriver("screwdriver.png"), Hammer("hammer.png"), FlipHorizontal("flip_horizontal.png"),
|
||||
FlipVertical("flip_vertical.png");
|
||||
FlipVertical("flip_vertical.png"), MagicWand("magic_wand.png");
|
||||
|
||||
protected String name;
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 902 B |
@@ -144,7 +144,7 @@ public class ActionFactory {
|
||||
public RotateSelectionAction createRotateSelectionAction(IPlugInPort plugInPort, int direction) {
|
||||
return new RotateSelectionAction(plugInPort, direction);
|
||||
}
|
||||
|
||||
|
||||
public MirrorSelectionAction createMirrorSelectionAction(IPlugInPort plugInPort, int direction) {
|
||||
return new MirrorSelectionAction(plugInPort, direction);
|
||||
}
|
||||
@@ -771,7 +771,7 @@ public class ActionFactory {
|
||||
public EditProjectAction(IPlugInPort plugInPort) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Edit Project");
|
||||
putValue(AbstractAction.NAME, "Edit Project Settings");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.DocumentEdit.getIcon());
|
||||
}
|
||||
|
||||
@@ -926,7 +926,7 @@ public class ActionFactory {
|
||||
plugInPort.rotateSelection(direction);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class MirrorSelectionAction extends AbstractAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -940,10 +940,12 @@ public class ActionFactory {
|
||||
this.direction = direction;
|
||||
if (direction == ISelectionProcessor.HORIZONTAL) {
|
||||
putValue(AbstractAction.NAME, "Mirror Horizontally");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.FlipHorizontal.getIcon());
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.FlipHorizontal.getIcon());
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.ALT_MASK));
|
||||
} else {
|
||||
putValue(AbstractAction.NAME, "Mirror Vertically");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.FlipVertical.getIcon());
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.FlipVertical.getIcon());
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.ALT_MASK));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1043,7 +1045,7 @@ public class ActionFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentBrowserAction extends AbstractAction {
|
||||
public static class ComponentBrowserAction extends AbstractAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -1055,8 +1057,10 @@ public class ActionFactory {
|
||||
putValue(AbstractAction.NAME, browserType);
|
||||
putValue(IView.RADIO_BUTTON_GROUP_KEY, "componentBrowser");
|
||||
|
||||
putValue(AbstractAction.SELECTED_KEY,
|
||||
browserType.equals(ConfigurationManager.getInstance().readString(ConfigPlugin.COMPONENT_BROWSER, ConfigPlugin.SEARCHABLE_TREE)));
|
||||
putValue(
|
||||
AbstractAction.SELECTED_KEY,
|
||||
browserType.equals(ConfigurationManager.getInstance().readString(ConfigPlugin.COMPONENT_BROWSER,
|
||||
ConfigPlugin.SEARCHABLE_TREE)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -138,6 +138,10 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
getUngroupAction().setEnabled(enabled);
|
||||
getSendToBackAction().setEnabled(enabled);
|
||||
getBringToFrontAction().setEnabled(enabled);
|
||||
getRotateClockwiseAction().setEnabled(enabled);
|
||||
getRotateCounterclockwiseAction().setEnabled(enabled);
|
||||
getMirrorHorizontallyAction().setEnabled(enabled);
|
||||
getMirrorVerticallyAction().setEnabled(enabled);
|
||||
|
||||
getSaveAsTemplateAction().setEnabled(plugInPort.getSelectedComponents().size() == 1);
|
||||
|
||||
@@ -280,14 +284,18 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
public JMenu getTransformMenu() {
|
||||
if (transformMenu == null) {
|
||||
transformMenu = new JMenu("Transform Selection");
|
||||
transformMenu.setIcon(IconLoader.MagicWand.getIcon());
|
||||
transformMenu.add(getRotateClockwiseAction());
|
||||
transformMenu.add(getRotateCounterclockwiseAction());
|
||||
transformMenu.addSeparator();
|
||||
transformMenu.add(getMirrorHorizontallyAction());
|
||||
transformMenu.add(getMirrorVerticallyAction());
|
||||
transformMenu.add(getGroupAction());
|
||||
transformMenu.add(getUngroupAction());
|
||||
transformMenu.addSeparator();
|
||||
transformMenu.add(getSendToBackAction());
|
||||
transformMenu.add(getBringToFrontAction());
|
||||
transformMenu.addSeparator();
|
||||
transformMenu.add(getGroupAction());
|
||||
transformMenu.add(getUngroupAction());
|
||||
}
|
||||
return transformMenu;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.diylc.appframework.undo.UndoHandler;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ISelectionProcessor;
|
||||
import org.diylc.core.ExpansionMode;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.images.IconLoader;
|
||||
@@ -22,6 +23,7 @@ import org.diylc.swing.ISwingUI;
|
||||
public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
|
||||
private static final String EDIT_TITLE = "Edit";
|
||||
private static final String TRANSFORM_TITLE = "Transform Selection";
|
||||
private static final String RENUMBER_TITLE = "Renumber Selection";
|
||||
private static final String EXPAND_TITLE = "Expand Selection";
|
||||
|
||||
@@ -47,6 +49,8 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
private ActionFactory.SaveAsTemplateAction saveAsTemplateAction;
|
||||
private ActionFactory.RotateSelectionAction rotateClockwiseAction;
|
||||
private ActionFactory.RotateSelectionAction rotateCounterClockwiseAction;
|
||||
private ActionFactory.MirrorSelectionAction mirrorHorizontallyAction;
|
||||
private ActionFactory.MirrorSelectionAction mirrorVerticallyAction;
|
||||
|
||||
private UndoHandler<Project> undoHandler;
|
||||
|
||||
@@ -197,6 +201,22 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
}
|
||||
return rotateCounterClockwiseAction;
|
||||
}
|
||||
|
||||
public ActionFactory.MirrorSelectionAction getMirrorHorizontallyAction() {
|
||||
if (mirrorHorizontallyAction == null) {
|
||||
mirrorHorizontallyAction =
|
||||
ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, ISelectionProcessor.HORIZONTAL);
|
||||
}
|
||||
return mirrorHorizontallyAction;
|
||||
}
|
||||
|
||||
public ActionFactory.MirrorSelectionAction getMirrorVerticallyAction() {
|
||||
if (mirrorVerticallyAction == null) {
|
||||
mirrorVerticallyAction =
|
||||
ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, ISelectionProcessor.VERTICAL);
|
||||
}
|
||||
return mirrorVerticallyAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(IPlugInPort plugInPort) {
|
||||
@@ -214,14 +234,20 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
swingUI.injectMenuAction(actionFactory.createSelectAllAction(plugInPort), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getEditSelectionAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getDeleteSelectionAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getRotateClockwiseAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getRotateCounterclockwiseAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getSendToBackAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getBringToFrontAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getGroupAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getUngroupAction(), EDIT_TITLE);
|
||||
swingUI.injectSubmenu(TRANSFORM_TITLE, IconLoader.MagicWand.getIcon(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getRotateClockwiseAction(), TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(getRotateCounterclockwiseAction(), TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(null, TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(getMirrorHorizontallyAction(), TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(getMirrorVerticallyAction(), TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(null, TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(getSendToBackAction(), TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(getBringToFrontAction(), TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(null, TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(getGroupAction(), TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(getUngroupAction(), TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(null, EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getSaveAsTemplateAction(), EDIT_TITLE);
|
||||
// swingUI.injectMenuAction(getSaveAsTemplateAction(), EDIT_TITLE);
|
||||
swingUI.injectSubmenu(RENUMBER_TITLE, IconLoader.Sort.getIcon(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getRenumberXAxisAction(), RENUMBER_TITLE);
|
||||
swingUI.injectMenuAction(getRenumberYAxisAction(), RENUMBER_TITLE);
|
||||
@@ -277,6 +303,8 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
getBringToFrontAction().setEnabled(enabled);
|
||||
getRotateClockwiseAction().setEnabled(enabled);
|
||||
getRotateCounterclockwiseAction().setEnabled(enabled);
|
||||
getMirrorHorizontallyAction().setEnabled(enabled);
|
||||
getMirrorVerticallyAction().setEnabled(enabled);
|
||||
getSaveAsTemplateAction().setEnabled(enabled);
|
||||
}
|
||||
|
||||
|
||||
@@ -1508,6 +1508,26 @@
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>3</major>
|
||||
<minor>35</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2016-12-30 20:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Mirror selection horizontally and vertically</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Consolidated context menu items</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
</a>
|
||||
</java.util.Arrays_-ArrayList>
|
||||
Reference in New Issue
Block a user