mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
added menu item to edit selection
This commit is contained in:
+1
-2
@@ -301,9 +301,8 @@ public interface IPlugInPort {
|
|||||||
* exception will be thrown.
|
* exception will be thrown.
|
||||||
*
|
*
|
||||||
* @param properties
|
* @param properties
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
void applyPropertiesToSelection(List<PropertyWrapper> properties) throws Exception;
|
void applyPropertiesToSelection(List<PropertyWrapper> properties);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a list of editable properties of the current project.
|
* @return a list of editable properties of the current project.
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ public enum IconLoader {
|
|||||||
"wrench.png"), Group("group.png"), Ungroup("ungroup.png"), TraceMask("trace_mask.png"), Faq(
|
"wrench.png"), Group("group.png"), Ungroup("ungroup.png"), TraceMask("trace_mask.png"), Faq(
|
||||||
"faq.png"), Component("component.png"), Plugin("plugin.png"), Manual("manual.png"), Donate(
|
"faq.png"), Component("component.png"), Plugin("plugin.png"), Manual("manual.png"), Donate(
|
||||||
"donate.png"), Bug("bug.png"), AboutDialog("about_dialog.png"), DocumentEdit(
|
"donate.png"), Bug("bug.png"), AboutDialog("about_dialog.png"), DocumentEdit(
|
||||||
"document_edit.png");
|
"document_edit.png"), EditComponent("edit_component.png");
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
|
|||||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 697 B |
+37
@@ -80,6 +80,8 @@ public class ClipboardManager implements IPlugIn, ClipboardOwner {
|
|||||||
plugInPort.injectMenuAction(pasteAction, EDIT_TITLE);
|
plugInPort.injectMenuAction(pasteAction, EDIT_TITLE);
|
||||||
plugInPort.injectMenuAction(null, EDIT_TITLE);
|
plugInPort.injectMenuAction(null, EDIT_TITLE);
|
||||||
plugInPort.injectMenuAction(new SelectAllAction(), EDIT_TITLE);
|
plugInPort.injectMenuAction(new SelectAllAction(), EDIT_TITLE);
|
||||||
|
plugInPort.injectMenuAction(null, EDIT_TITLE);
|
||||||
|
plugInPort.injectMenuAction(new EditSelectionAction(), EDIT_TITLE);
|
||||||
plugInPort.injectMenuAction(new EditProjectAction(), EDIT_TITLE);
|
plugInPort.injectMenuAction(new EditProjectAction(), EDIT_TITLE);
|
||||||
plugInPort.injectMenuAction(null, EDIT_TITLE);
|
plugInPort.injectMenuAction(null, EDIT_TITLE);
|
||||||
plugInPort.injectMenuAction(new GroupAction(), EDIT_TITLE);
|
plugInPort.injectMenuAction(new GroupAction(), EDIT_TITLE);
|
||||||
@@ -268,6 +270,41 @@ public class ClipboardManager implements IPlugIn, ClipboardOwner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class EditSelectionAction extends AbstractAction {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public EditSelectionAction() {
|
||||||
|
super();
|
||||||
|
putValue(AbstractAction.NAME, "Edit Selection");
|
||||||
|
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_E,
|
||||||
|
ActionEvent.CTRL_MASK));
|
||||||
|
putValue(AbstractAction.SMALL_ICON, IconLoader.EditComponent.getIcon());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
LOG.info("Edit Selection triggered");
|
||||||
|
List<PropertyWrapper> properties = plugInPort.getMutualSelectionProperties();
|
||||||
|
if (properties == null || properties.isEmpty()) {
|
||||||
|
LOG.info("Nothing to edit");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PropertyEditorDialog editor = DialogFactory.getInstance().createPropertyEditorDialog(
|
||||||
|
properties, "Edit Selection");
|
||||||
|
editor.setVisible(true);
|
||||||
|
if (ButtonDialog.OK.equals(editor.getSelectedButtonCaption())) {
|
||||||
|
plugInPort.applyPropertiesToSelection(properties);
|
||||||
|
}
|
||||||
|
// Save default values.
|
||||||
|
for (PropertyWrapper property : editor.getDefaultedProperties()) {
|
||||||
|
if (property.getValue() != null) {
|
||||||
|
plugInPort.setDefaultPropertyValue(property.getName(), property.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ClipboardOwner
|
// ClipboardOwner
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+5
-4
@@ -996,7 +996,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyPropertiesToSelection(List<PropertyWrapper> properties) throws Exception {
|
public void applyPropertiesToSelection(List<PropertyWrapper> properties) {
|
||||||
LOG.debug(String.format("applyPropertiesToSelection(%s)", properties));
|
LOG.debug(String.format("applyPropertiesToSelection(%s)", properties));
|
||||||
Project oldProject = cloner.deepClone(currentProject);
|
Project oldProject = cloner.deepClone(currentProject);
|
||||||
try {
|
try {
|
||||||
@@ -1005,11 +1005,13 @@ public class Presenter implements IPlugInPort {
|
|||||||
property.writeTo(component);
|
property.writeTo(component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("Could not apply selection properties", e);
|
||||||
} finally {
|
} finally {
|
||||||
// Notify the listeners.
|
// Notify the listeners.
|
||||||
if (!oldProject.equals(currentProject)) {
|
if (!oldProject.equals(currentProject)) {
|
||||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, cloner
|
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, cloner
|
||||||
.deepClone(currentProject), "Edit");
|
.deepClone(currentProject), "Edit Selection");
|
||||||
}
|
}
|
||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||||
@@ -1049,8 +1051,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
.deepClone(currentProject), "Edit Project");
|
.deepClone(currentProject), "Edit Project");
|
||||||
}
|
}
|
||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
messageDispatcher.dispatchMessage(EventType.ZOOM_CHANGED, zoomLevel);
|
||||||
calculateSelectionDimension());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user