mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
code cleanup
This commit is contained in:
+3
-9
@@ -271,15 +271,9 @@ public interface IPlugInPort {
|
||||
*/
|
||||
List<PropertyWrapper> getMutualSelectionProperties();
|
||||
|
||||
/**
|
||||
* Applies specified properties to all the selected components. If some of
|
||||
* the properties are not applicable to some of the selected components an
|
||||
* exception will be thrown.
|
||||
*
|
||||
* @param properties
|
||||
*/
|
||||
void applyPropertiesToSelection(List<PropertyWrapper> properties);
|
||||
|
||||
|
||||
void editSelection();
|
||||
|
||||
/**
|
||||
* @return a list of editable properties of the current project.
|
||||
*/
|
||||
|
||||
+3
-3
@@ -483,7 +483,8 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
}
|
||||
|
||||
private void editSelection() {
|
||||
@Override
|
||||
public void editSelection() {
|
||||
List<PropertyWrapper> properties = getMutualSelectionProperties();
|
||||
if (properties != null && !properties.isEmpty()) {
|
||||
Set<PropertyWrapper> defaultedProperties = new HashSet<PropertyWrapper>();
|
||||
@@ -1192,8 +1193,7 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyPropertiesToSelection(List<PropertyWrapper> properties) {
|
||||
private void applyPropertiesToSelection(List<PropertyWrapper> properties) {
|
||||
LOG.debug(String.format("applyPropertiesToSelection(%s)", properties));
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
try {
|
||||
|
||||
+1
-13
@@ -727,19 +727,7 @@ public class ActionFactory {
|
||||
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.setSelectionDefaultPropertyValue(property.getName(), property
|
||||
.getValue());
|
||||
}
|
||||
}
|
||||
plugInPort.editSelection();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-63
@@ -21,22 +21,14 @@ import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.VolatileImage;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.common.DrawOption;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.presenter.Presenter;
|
||||
import org.diylc.swing.gui.DialogFactory;
|
||||
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
||||
|
||||
import com.diyfever.gui.ButtonDialog;
|
||||
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||
|
||||
/**
|
||||
@@ -46,8 +38,6 @@ import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||
*/
|
||||
class CanvasPanel extends JComponent implements Autoscroll {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(CanvasPanel.class);
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private IPlugInPort plugInPort;
|
||||
@@ -190,61 +180,8 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getButton() == MouseEvent.BUTTON1) {
|
||||
// if (e.getClickCount() == 2) {
|
||||
// List<PropertyWrapper> properties = plugInPort
|
||||
// .getMutualSelectionProperties();
|
||||
// if (properties == null || properties.isEmpty()) {
|
||||
// // properties = plugInPort.getProjectProperties();
|
||||
// // PropertyEditorDialog editor =
|
||||
// // DialogFactory.getInstance()
|
||||
// // .createPropertyEditorDialog(properties,
|
||||
// // "Edit Project");
|
||||
// // editor.setVisible(true);
|
||||
// // if
|
||||
// //
|
||||
// (ButtonDialog.OK.equals(editor.getSelectedButtonCaption()))
|
||||
// // {
|
||||
// // plugInPort.applyPropertiesToProject(properties);
|
||||
// // // Save default values.
|
||||
// // for (PropertyWrapper property :
|
||||
// // editor.getDefaultedProperties()) {
|
||||
// // if (property.getValue() != null) {
|
||||
// //
|
||||
// plugInPort.setProjectDefaultPropertyValue(property.getName(),
|
||||
// // property.getValue());
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// } else {
|
||||
// PropertyEditorDialog editor = DialogFactory.getInstance()
|
||||
// .createPropertyEditorDialog(properties,
|
||||
// "Edit Selection");
|
||||
// editor.setVisible(true);
|
||||
// if
|
||||
// (ButtonDialog.OK.equals(editor.getSelectedButtonCaption()))
|
||||
// {
|
||||
// try {
|
||||
// plugInPort.applyPropertiesToSelection(properties);
|
||||
// } catch (Exception e1) {
|
||||
// JOptionPane.showMessageDialog(CanvasPanel.this,
|
||||
// "Error occured while editing selection. Check the log for details.",
|
||||
// "Error", JOptionPane.ERROR_MESSAGE);
|
||||
// LOG.error("Error applying properties", e1);
|
||||
// }
|
||||
// // Save default values.
|
||||
// for (PropertyWrapper property :
|
||||
// editor.getDefaultedProperties()) {
|
||||
// if (property.getValue() != null) {
|
||||
// plugInPort.setSelectionDefaultPropertyValue(property
|
||||
// .getName(), property.getValue());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
plugInPort.mouseClicked(e.getPoint(), e.isControlDown(), e.isShiftDown(), e
|
||||
.isAltDown(), e.getClickCount());
|
||||
// }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user