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.
|
||||
*
|
||||
* @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.
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ public enum IconLoader {
|
||||
"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(
|
||||
"donate.png"), Bug("bug.png"), AboutDialog("about_dialog.png"), DocumentEdit(
|
||||
"document_edit.png");
|
||||
"document_edit.png"), EditComponent("edit_component.png");
|
||||
|
||||
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(null, 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(null, 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
|
||||
|
||||
@Override
|
||||
|
||||
+5
-4
@@ -996,7 +996,7 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyPropertiesToSelection(List<PropertyWrapper> properties) throws Exception {
|
||||
public void applyPropertiesToSelection(List<PropertyWrapper> properties) {
|
||||
LOG.debug(String.format("applyPropertiesToSelection(%s)", properties));
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
try {
|
||||
@@ -1005,11 +1005,13 @@ public class Presenter implements IPlugInPort {
|
||||
property.writeTo(component);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not apply selection properties", e);
|
||||
} finally {
|
||||
// Notify the listeners.
|
||||
if (!oldProject.equals(currentProject)) {
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, cloner
|
||||
.deepClone(currentProject), "Edit");
|
||||
.deepClone(currentProject), "Edit Selection");
|
||||
}
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
@@ -1049,8 +1051,7 @@ public class Presenter implements IPlugInPort {
|
||||
.deepClone(currentProject), "Edit Project");
|
||||
}
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
calculateSelectionDimension());
|
||||
messageDispatcher.dispatchMessage(EventType.ZOOM_CHANGED, zoomLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user