mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
added nudge
fixed ctrl/meta handling
This commit is contained in:
@@ -30,7 +30,8 @@ import org.diylc.core.Theme;
|
||||
* @see IMessageListener
|
||||
* @see EventType
|
||||
*/
|
||||
public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyProcessor, ITemplateProcessor, IBlockProcessor {
|
||||
public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyProcessor, ITemplateProcessor,
|
||||
IBlockProcessor {
|
||||
|
||||
public static final String ANTI_ALIASING_KEY = "antiAliasing";
|
||||
public static final String HI_QUALITY_RENDER_KEY = "hiQualityRender";
|
||||
@@ -198,10 +199,11 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
/**
|
||||
* Sets default value for the specified property name for projects.
|
||||
*
|
||||
* @param clazz class to set defaults to
|
||||
* @param propertyName display name for property
|
||||
* @param value new default value, must not be null
|
||||
*/
|
||||
void setProjectDefaultPropertyValue(String propertyName, Object value);
|
||||
void setDefaultPropertyValue(Class<?> clazz, String propertyName, Object value);
|
||||
|
||||
/**
|
||||
* @return a list of properties that are mutual for all the selected components. Resulting list
|
||||
@@ -214,15 +216,18 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
|
||||
/**
|
||||
* @return a list of editable properties of the current project.
|
||||
*
|
||||
* @param obj
|
||||
*/
|
||||
List<PropertyWrapper> getProjectProperties();
|
||||
List<PropertyWrapper> getProperties(Object obj);
|
||||
|
||||
/**
|
||||
* Applies specified properties to the current project.
|
||||
*
|
||||
* @param obj
|
||||
* @param properties
|
||||
*/
|
||||
void applyPropertiesToProject(List<PropertyWrapper> properties);
|
||||
void applyProperties(Object obj, List<PropertyWrapper> properties);
|
||||
|
||||
/**
|
||||
* Gets the current new component slot.
|
||||
@@ -255,8 +260,8 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
void setLayerLocked(int layerZOrder, boolean locked);
|
||||
|
||||
/**
|
||||
* Shows or hides the specified layer. All components within +- 0.5 range will be affected by
|
||||
* the change as well.
|
||||
* Shows or hides the specified layer. All components within +- 0.5 range will be affected by the
|
||||
* change as well.
|
||||
*
|
||||
* @param layerZOrder
|
||||
* @param visible
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.List;
|
||||
|
||||
import org.diylc.core.ExpansionMode;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.measures.Size;
|
||||
|
||||
public interface ISelectionProcessor {
|
||||
|
||||
@@ -81,4 +82,13 @@ public interface ISelectionProcessor {
|
||||
* @return
|
||||
*/
|
||||
Rectangle2D getSelectionBounds();
|
||||
|
||||
/**
|
||||
* Moves selection for the specified offset.
|
||||
*
|
||||
* @param xOffset
|
||||
* @param yOffset
|
||||
* @param affectStuckComponents
|
||||
*/
|
||||
void nudgeSelection(Size xOffset, Size yOffset, boolean affectStuckComponents);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.diylc.core.measures;
|
||||
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
|
||||
public class Nudge {
|
||||
|
||||
private Size xOffset;
|
||||
private Size yOffset;
|
||||
private boolean affectStuckComponents;
|
||||
|
||||
@EditableProperty(name = "X-axis", sortOrder = 1)
|
||||
public Size getxOffset() {
|
||||
return xOffset;
|
||||
}
|
||||
|
||||
public void setxOffset(Size xOffset) {
|
||||
this.xOffset = xOffset;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Y-axis", sortOrder = 2)
|
||||
public Size getyOffset() {
|
||||
return yOffset;
|
||||
}
|
||||
|
||||
public void setyOffset(Size yOffset) {
|
||||
this.yOffset = yOffset;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Include stuck", sortOrder = 10)
|
||||
public boolean getAffectStuckComponents() {
|
||||
return affectStuckComponents;
|
||||
}
|
||||
|
||||
public void setAffectStuckComponents(boolean affectStuckComponents) {
|
||||
this.affectStuckComponents = affectStuckComponents;
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,7 @@ import org.diylc.core.Project;
|
||||
import org.diylc.core.Template;
|
||||
import org.diylc.core.Theme;
|
||||
import org.diylc.core.annotations.IAutoCreator;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@@ -854,6 +855,42 @@ public class Presenter implements IPlugInPort {
|
||||
return totalArea.getBounds2D();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nudgeSelection(Size xOffset, Size yOffset, boolean affectStuckComponents) {
|
||||
if (selectedComponents == null || selectedComponents.isEmpty())
|
||||
return;
|
||||
|
||||
LOG.debug(String.format("nudgeSelection(%s, %s)", xOffset, yOffset));
|
||||
Map<IDIYComponent<?>, Set<Integer>> controlPointMap = new HashMap<IDIYComponent<?>, Set<Integer>>();
|
||||
// If there aren't any control points, try to add all the selected
|
||||
// components with all their control points. That will allow the
|
||||
// user to drag the whole components.
|
||||
for (IDIYComponent<?> c : selectedComponents) {
|
||||
Set<Integer> pointIndices = new HashSet<Integer>();
|
||||
if (c.getControlPointCount() > 0) {
|
||||
for (int i = 0; i < c.getControlPointCount(); i++) {
|
||||
pointIndices.add(i);
|
||||
}
|
||||
controlPointMap.put(c, pointIndices);
|
||||
}
|
||||
}
|
||||
if (controlPointMap.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (affectStuckComponents) {
|
||||
includeStuckComponents(controlPointMap);
|
||||
}
|
||||
|
||||
int dx = (int) xOffset.convertToPixels();
|
||||
int dy = (int) yOffset.convertToPixels();
|
||||
|
||||
Project oldProject = currentProject.clone();
|
||||
moveComponents(controlPointMap, dx, dy, false);
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(), "Move Selection");
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionNumber getCurrentVersionNumber() {
|
||||
return CURRENT_VERSION;
|
||||
@@ -1403,10 +1440,10 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectDefaultPropertyValue(String propertyName, Object value) {
|
||||
LOG.info(String.format("setProjectDefaultPropertyValue(%s, %s)", propertyName, value));
|
||||
public void setDefaultPropertyValue(Class<?> clazz, String propertyName, Object value) {
|
||||
LOG.info(String.format("setProjectDefaultPropertyValue(%s, %s, %s)", clazz.getName(), propertyName, value));
|
||||
LOG.debug("Default property value set for " + Project.class.getName() + ":" + propertyName);
|
||||
ConfigurationManager.getInstance().writeValue(DEFAULTS_KEY_PREFIX + Project.class.getName() + ":" + propertyName,
|
||||
ConfigurationManager.getInstance().writeValue(DEFAULTS_KEY_PREFIX + clazz.getName() + ":" + propertyName,
|
||||
value);
|
||||
}
|
||||
|
||||
@@ -1849,14 +1886,14 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PropertyWrapper> getProjectProperties() {
|
||||
List<PropertyWrapper> properties = ComponentProcessor.getInstance().extractProperties(Project.class);
|
||||
public List<PropertyWrapper> getProperties(Object object) {
|
||||
List<PropertyWrapper> properties = ComponentProcessor.getInstance().extractProperties(object.getClass());
|
||||
try {
|
||||
for (PropertyWrapper property : properties) {
|
||||
property.readFrom(currentProject);
|
||||
property.readFrom(object);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not get project properties", e);
|
||||
LOG.error("Could not get object properties", e);
|
||||
return null;
|
||||
}
|
||||
Collections.sort(properties, ComparatorFactory.getInstance().getDefaultPropertyComparator());
|
||||
@@ -1864,16 +1901,16 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyPropertiesToProject(List<PropertyWrapper> properties) {
|
||||
LOG.debug(String.format("applyPropertiesToProject(%s)", properties));
|
||||
public void applyProperties(Object obj, List<PropertyWrapper> properties) {
|
||||
LOG.debug(String.format("applyProperties(%s, %s)", obj, properties));
|
||||
Project oldProject = currentProject.clone();
|
||||
try {
|
||||
for (PropertyWrapper property : properties) {
|
||||
property.writeTo(currentProject);
|
||||
property.writeTo(obj);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not apply project properties", e);
|
||||
view.showMessage("Could not apply changes to the project. Check the log for details.", "Error",
|
||||
LOG.error("Could not apply properties", e);
|
||||
view.showMessage("Could not apply changes. Check the log for details.", "Error",
|
||||
IView.ERROR_MESSAGE);
|
||||
} finally {
|
||||
// Notify the listeners.
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -39,7 +39,7 @@ public enum IconLoader {
|
||||
"messages.png"), SearchBox("search-box.png"), Screwdriver("screwdriver.png"), Hammer("hammer.png"), FlipHorizontal(
|
||||
"flip_horizontal.png"), FlipVertical("flip_vertical.png"), MagicWand("magic_wand.png"), PinGrey("pin_grey.png"), PinGreen(
|
||||
"pin_green.png"), CoffeebeanEdit("coffeebean_edit.png"), ApplicationEdit("application_edit.png"), ComponentAdd(
|
||||
"component_add.png"), History("history.png"), DocumentPlain("document_plain.png");
|
||||
"component_add.png"), History("history.png"), DocumentPlain("document_plain.png"), FitToSize("fit_to_size.png");
|
||||
|
||||
protected String name;
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 550 B |
@@ -25,7 +25,11 @@ import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.core.ExpansionMode;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.Theme;
|
||||
import org.diylc.core.measures.Nudge;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.images.IconLoader;
|
||||
import org.diylc.presenter.Presenter;
|
||||
import org.diylc.swing.gui.DialogFactory;
|
||||
@@ -162,6 +166,10 @@ public class ActionFactory {
|
||||
return new BringToFrontAction(plugInPort);
|
||||
}
|
||||
|
||||
public NudgeAction createNudgeAction(IPlugInPort plugInPort) {
|
||||
return new NudgeAction(plugInPort);
|
||||
}
|
||||
|
||||
// Config actions.
|
||||
|
||||
public ConfigAction createConfigAction(IPlugInPort plugInPort, String title, String configKey, boolean defaultValue) {
|
||||
@@ -204,16 +212,17 @@ public class ActionFactory {
|
||||
return;
|
||||
}
|
||||
plugInPort.createNewProject();
|
||||
List<PropertyWrapper> properties = plugInPort.getProjectProperties();
|
||||
PropertyEditorDialog editor = DialogFactory.getInstance().createPropertyEditorDialog(properties, "Edit Project");
|
||||
List<PropertyWrapper> properties = plugInPort.getProperties(plugInPort.getCurrentProject());
|
||||
PropertyEditorDialog editor =
|
||||
DialogFactory.getInstance().createPropertyEditorDialog(properties, "Edit Project", true);
|
||||
editor.setVisible(true);
|
||||
if (ButtonDialog.OK.equals(editor.getSelectedButtonCaption())) {
|
||||
plugInPort.applyPropertiesToProject(properties);
|
||||
plugInPort.applyProperties(plugInPort.getCurrentProject(), properties);
|
||||
}
|
||||
// Save default values.
|
||||
for (PropertyWrapper property : editor.getDefaultedProperties()) {
|
||||
if (property.getValue() != null) {
|
||||
plugInPort.setProjectDefaultPropertyValue(property.getName(), property.getValue());
|
||||
plugInPort.setDefaultPropertyValue(Project.class, property.getName(), property.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -795,21 +804,60 @@ public class ActionFactory {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Edit Project triggered");
|
||||
List<PropertyWrapper> properties = plugInPort.getProjectProperties();
|
||||
PropertyEditorDialog editor = DialogFactory.getInstance().createPropertyEditorDialog(properties, "Edit Project");
|
||||
List<PropertyWrapper> properties = plugInPort.getProperties(plugInPort.getCurrentProject());
|
||||
PropertyEditorDialog editor =
|
||||
DialogFactory.getInstance().createPropertyEditorDialog(properties, "Edit Project", true);
|
||||
editor.setVisible(true);
|
||||
if (ButtonDialog.OK.equals(editor.getSelectedButtonCaption())) {
|
||||
plugInPort.applyPropertiesToProject(properties);
|
||||
plugInPort.applyProperties(plugInPort.getCurrentProject(), properties);
|
||||
}
|
||||
// Save default values.
|
||||
for (PropertyWrapper property : editor.getDefaultedProperties()) {
|
||||
if (property.getValue() != null) {
|
||||
plugInPort.setProjectDefaultPropertyValue(property.getName(), property.getValue());
|
||||
plugInPort.setDefaultPropertyValue(Project.class, property.getName(), property.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class NudgeAction extends AbstractAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private IPlugInPort plugInPort;
|
||||
|
||||
public NudgeAction(IPlugInPort plugInPort) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Nudge");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.FitToSize.getIcon());
|
||||
putValue(AbstractAction.ACCELERATOR_KEY,
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Nudge triggered");
|
||||
Nudge n = new Nudge();
|
||||
boolean metric = ConfigurationManager.getInstance().readBoolean(Presenter.METRIC_KEY, true);
|
||||
if (metric) {
|
||||
n.setxOffset(new Size(0d, SizeUnit.mm));
|
||||
n.setyOffset(new Size(0d, SizeUnit.mm));
|
||||
} else {
|
||||
n.setxOffset(new Size(0d, SizeUnit.in));
|
||||
n.setyOffset(new Size(0d, SizeUnit.in));
|
||||
}
|
||||
List<PropertyWrapper> properties = plugInPort.getProperties(n);
|
||||
PropertyEditorDialog editor =
|
||||
DialogFactory.getInstance().createPropertyEditorDialog(properties, "Nudge Selection", false);
|
||||
editor.setVisible(true);
|
||||
if (ButtonDialog.OK.equals(editor.getSelectedButtonCaption())) {
|
||||
plugInPort.applyProperties(n, properties);
|
||||
plugInPort.nudgeSelection(n.getxOffset(), n.getyOffset(), n.getAffectStuckComponents());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class EditSelectionAction extends AbstractAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -57,12 +57,12 @@ public class DialogFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public PropertyEditorDialog createPropertyEditorDialog(List<PropertyWrapper> properties, String title) {
|
||||
return createPropertyEditorDialog(mainFrame, properties, title);
|
||||
public PropertyEditorDialog createPropertyEditorDialog(List<PropertyWrapper> properties, String title, boolean saveDefaults) {
|
||||
return createPropertyEditorDialog(mainFrame, properties, title, saveDefaults);
|
||||
}
|
||||
|
||||
public PropertyEditorDialog createPropertyEditorDialog(JFrame owner, List<PropertyWrapper> properties, String title) {
|
||||
PropertyEditorDialog editor = new PropertyEditorDialog(owner, properties, title);
|
||||
public PropertyEditorDialog createPropertyEditorDialog(JFrame owner, List<PropertyWrapper> properties, String title, boolean saveDefaults) {
|
||||
PropertyEditorDialog editor = new PropertyEditorDialog(owner, properties, title, saveDefaults);
|
||||
return editor;
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ public class MainFrame extends JFrame implements ISwingUI {
|
||||
|
||||
@Override
|
||||
public boolean editProperties(List<PropertyWrapper> properties, Set<PropertyWrapper> defaultedProperties) {
|
||||
PropertyEditorDialog editor = DialogFactory.getInstance().createPropertyEditorDialog(properties, "Edit Selection");
|
||||
PropertyEditorDialog editor = DialogFactory.getInstance().createPropertyEditorDialog(properties, "Edit Selection", true);
|
||||
editor.setVisible(true);
|
||||
defaultedProperties.addAll(editor.getDefaultedProperties());
|
||||
return ButtonDialog.OK.equals(editor.getSelectedButtonCaption());
|
||||
|
||||
@@ -32,16 +32,17 @@ public class PropertyEditorDialog extends ButtonDialog {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static boolean SHOW_DEFAULT_BOXES = true;
|
||||
private static final String DEFAULT_BOX_TOOLTIP =
|
||||
"<html>If this box is checked application will use the current value as a<br>default when creating new components of the same type</html>";
|
||||
|
||||
private List<PropertyWrapper> properties;
|
||||
private Set<PropertyWrapper> defaultedProperties;
|
||||
private Component componentToFocus = null;
|
||||
private boolean saveDefaults;
|
||||
|
||||
public PropertyEditorDialog(JFrame owner, List<PropertyWrapper> properties, String title) {
|
||||
public PropertyEditorDialog(JFrame owner, List<PropertyWrapper> properties, String title, boolean saveDefaults) {
|
||||
super(owner, title, new String[] {ButtonDialog.OK, ButtonDialog.CANCEL});
|
||||
this.saveDefaults = saveDefaults;
|
||||
|
||||
LOG.debug("Creating property editor for: " + properties);
|
||||
|
||||
@@ -112,7 +113,7 @@ public class PropertyEditorDialog extends ButtonDialog {
|
||||
gbc.fill = GridBagConstraints.NONE;
|
||||
gbc.weightx = 0;
|
||||
|
||||
if (SHOW_DEFAULT_BOXES) {
|
||||
if (saveDefaults) {
|
||||
editorPanel.add(createDefaultCheckBox(property), gbc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import javax.swing.SwingUtilities;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.IConfigListener;
|
||||
import org.diylc.appframework.miscutils.Utils;
|
||||
import org.diylc.common.BadPositionException;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
@@ -71,6 +72,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
private ActionFactory.UngroupAction ungroupAction;
|
||||
private ActionFactory.SendToBackAction sendToBackAction;
|
||||
private ActionFactory.BringToFrontAction bringToFrontAction;
|
||||
private ActionFactory.NudgeAction nudgeAction;
|
||||
private ActionFactory.ExpandSelectionAction expandSelectionAllAction;
|
||||
private ActionFactory.ExpandSelectionAction expandSelectionImmediateAction;
|
||||
private ActionFactory.ExpandSelectionAction expandSelectionSameTypeAction;
|
||||
@@ -148,6 +150,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
getExpandSelectionSameTypeAction().setEnabled(enabled);
|
||||
getGroupAction().setEnabled(enabled);
|
||||
getUngroupAction().setEnabled(enabled);
|
||||
getNudgeAction().setEnabled(enabled);
|
||||
getSendToBackAction().setEnabled(enabled);
|
||||
getBringToFrontAction().setEnabled(enabled);
|
||||
getRotateClockwiseAction().setEnabled(enabled);
|
||||
@@ -169,7 +172,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (plugInPort.keyPressed(e.getKeyCode(), e.isControlDown() || e.isMetaDown(), e.isShiftDown(), e.isAltDown())) {
|
||||
if (plugInPort.keyPressed(e.getKeyCode(), Utils.isMac() ? e.isMetaDown() : e.isControlDown(), e.isShiftDown(), e.isAltDown())) {
|
||||
e.consume();
|
||||
}
|
||||
}
|
||||
@@ -180,7 +183,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
canvasPanel.setCursor(plugInPort.getCursorAt(e.getPoint()));
|
||||
plugInPort.mouseMoved(e.getPoint(), e.isControlDown() || e.isMetaDown(), e.isShiftDown(), e.isAltDown());
|
||||
plugInPort.mouseMoved(e.getPoint(), Utils.isMac() ? e.isMetaDown() : e.isControlDown(), e.isShiftDown(), e.isAltDown());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -188,7 +191,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
plugInPort.mouseClicked(e.getPoint(), e.getButton(), e.isControlDown() || e.isMetaDown(), e.isShiftDown(),
|
||||
plugInPort.mouseClicked(e.getPoint(), e.getButton(), Utils.isMac() ? e.isMetaDown() : e.isControlDown(), e.isShiftDown(),
|
||||
e.isAltDown(), e.getClickCount());
|
||||
}
|
||||
});
|
||||
@@ -218,7 +221,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
boolean wheelZoom = ConfigurationManager.getInstance().readBoolean(IPlugInPort.WHEEL_ZOOM_KEY, false);
|
||||
|
||||
if (wheelZoom || e.isControlDown() || e.isMetaDown()) {
|
||||
if (wheelZoom || (Utils.isMac() ? e.isMetaDown() : e.isControlDown())) {
|
||||
// disable scrolling
|
||||
scrollPane.setWheelScrollingEnabled(false);
|
||||
|
||||
@@ -319,6 +322,8 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
transformMenu.add(getMirrorHorizontallyAction());
|
||||
transformMenu.add(getMirrorVerticallyAction());
|
||||
transformMenu.addSeparator();
|
||||
transformMenu.add(getNudgeAction());
|
||||
transformMenu.addSeparator();
|
||||
transformMenu.add(getSendToBackAction());
|
||||
transformMenu.add(getBringToFrontAction());
|
||||
transformMenu.addSeparator();
|
||||
@@ -492,6 +497,13 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
return bringToFrontAction;
|
||||
}
|
||||
|
||||
public ActionFactory.NudgeAction getNudgeAction() {
|
||||
if (nudgeAction == null) {
|
||||
nudgeAction = ActionFactory.getInstance().createNudgeAction(plugInPort);
|
||||
}
|
||||
return nudgeAction;
|
||||
}
|
||||
|
||||
public ActionFactory.ExpandSelectionAction getExpandSelectionAllAction() {
|
||||
if (expandSelectionAllAction == null) {
|
||||
expandSelectionAllAction = ActionFactory.getInstance().createExpandSelectionAction(plugInPort, ExpansionMode.ALL);
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.awt.Insets;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JCheckBox;
|
||||
@@ -27,6 +28,7 @@ import javax.swing.event.ChangeListener;
|
||||
|
||||
import org.diylc.common.DrawOption;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.swing.gui.components.HTMLTextArea;
|
||||
import org.diylc.swingframework.ButtonDialog;
|
||||
import org.diylc.utils.KeywordExtractor;
|
||||
@@ -204,10 +206,12 @@ public class UploadDialog extends ButtonDialog {
|
||||
if (nameField == null) {
|
||||
nameField = new JTextField();
|
||||
|
||||
List<PropertyWrapper> props = plugInPort.getProperties(plugInPort.getCurrentProject());
|
||||
|
||||
// set default from the project
|
||||
for (int i = 0; i < plugInPort.getProjectProperties().size(); i++)
|
||||
if (plugInPort.getProjectProperties().get(i).getName().equals("Title"))
|
||||
nameField.setText(plugInPort.getProjectProperties().get(i).getValue().toString());
|
||||
for (int i = 0; i < props.size(); i++)
|
||||
if (props.get(i).getName().equals("Title"))
|
||||
nameField.setText(props.get(i).getValue().toString());
|
||||
}
|
||||
return nameField;
|
||||
}
|
||||
@@ -232,11 +236,13 @@ public class UploadDialog extends ButtonDialog {
|
||||
if (descriptionArea == null) {
|
||||
descriptionArea = new HTMLTextArea();
|
||||
|
||||
List<PropertyWrapper> props = plugInPort.getProperties(plugInPort.getCurrentProject());
|
||||
|
||||
// set default from the project
|
||||
for (int i = 0; i < plugInPort.getProjectProperties().size(); i++)
|
||||
if (plugInPort.getProjectProperties().get(i).getName().equals("Description"))
|
||||
for (int i = 0; i < props.size(); i++)
|
||||
if (props.get(i).getName().equals("Description"))
|
||||
try {
|
||||
descriptionArea.setText(plugInPort.getProjectProperties().get(i).getValue().toString());
|
||||
descriptionArea.setText(props.get(i).getValue().toString());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
descriptionArea.setBorder(null);
|
||||
|
||||
+1
-1
@@ -327,7 +327,7 @@ public class ResultsScrollPanel extends JScrollPane {
|
||||
List<PropertyWrapper> projectProperties = CloudPresenter.Instance.getProjectProperties(project);
|
||||
PropertyEditorDialog editor =
|
||||
DialogFactory.getInstance().createPropertyEditorDialog(cloudUI.getOwnerFrame(), projectProperties,
|
||||
"Edit Published Project");
|
||||
"Edit Published Project", true);
|
||||
editor.setVisible(true);
|
||||
if (ButtonDialog.OK.equals(editor.getSelectedButtonCaption())) {
|
||||
// Update the project
|
||||
|
||||
@@ -41,6 +41,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
private ActionFactory.UngroupAction ungroupAction;
|
||||
private ActionFactory.SendToBackAction sendToBackAction;
|
||||
private ActionFactory.BringToFrontAction bringToFrontAction;
|
||||
private ActionFactory.NudgeAction nudgeAction;
|
||||
private ActionFactory.RenumberAction renumberXAxisAction;
|
||||
private ActionFactory.RenumberAction renumberYAxisAction;
|
||||
private ActionFactory.ExpandSelectionAction expandSelectionAllAction;
|
||||
@@ -145,6 +146,13 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
return bringToFrontAction;
|
||||
}
|
||||
|
||||
public ActionFactory.NudgeAction getNudgeAction() {
|
||||
if (nudgeAction == null) {
|
||||
nudgeAction = ActionFactory.getInstance().createNudgeAction(plugInPort);
|
||||
}
|
||||
return nudgeAction;
|
||||
}
|
||||
|
||||
public ActionFactory.RenumberAction getRenumberXAxisAction() {
|
||||
if (renumberXAxisAction == null) {
|
||||
renumberXAxisAction = ActionFactory.getInstance().createRenumberAction(plugInPort, true);
|
||||
@@ -249,6 +257,8 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
swingUI.injectMenuAction(getMirrorHorizontallyAction(), TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(getMirrorVerticallyAction(), TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(null, TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(getNudgeAction(), TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(null, TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(getSendToBackAction(), TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(getBringToFrontAction(), TRANSFORM_TITLE);
|
||||
swingUI.injectMenuAction(null, TRANSFORM_TITLE);
|
||||
@@ -306,6 +316,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
getExpandSelectionAllAction().setEnabled(enabled);
|
||||
getExpandSelectionImmediateAction().setEnabled(enabled);
|
||||
getExpandSelectionSameTypeAction().setEnabled(enabled);
|
||||
getNudgeAction().setEnabled(enabled);
|
||||
getUngroupAction().setEnabled(enabled);
|
||||
getSendToBackAction().setEnabled(enabled);
|
||||
getBringToFrontAction().setEnabled(enabled);
|
||||
|
||||
@@ -22,6 +22,7 @@ import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import org.diylc.appframework.miscutils.Utils;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -68,7 +69,7 @@ public class ComponentButtonFactory {
|
||||
}
|
||||
}
|
||||
// Ctrl appends selection
|
||||
if (e.isControlDown() || e.isMetaDown()) {
|
||||
if (Utils.isMac() ? e.isMetaDown() : e.isControlDown()) {
|
||||
newSelection.addAll(plugInPort.getSelectedComponents());
|
||||
}
|
||||
plugInPort.updateSelection(newSelection);
|
||||
@@ -82,7 +83,8 @@ public class ComponentButtonFactory {
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
plugInPort.keyPressed(e.getKeyCode(), e.isControlDown() || e.isMetaDown(), e.isShiftDown(), e.isAltDown());
|
||||
plugInPort.keyPressed(e.getKeyCode(), Utils.isMac() ? e.isMetaDown() : e.isControlDown(), e.isShiftDown(),
|
||||
e.isAltDown());
|
||||
}
|
||||
});
|
||||
return button;
|
||||
|
||||
Reference in New Issue
Block a user