code cleanup

This commit is contained in:
bancika
2011-02-24 00:05:27 +00:00
parent 4154225e71
commit ab5c9ad143
4 changed files with 7 additions and 88 deletions
@@ -271,14 +271,8 @@ public interface IPlugInPort {
*/ */
List<PropertyWrapper> getMutualSelectionProperties(); List<PropertyWrapper> getMutualSelectionProperties();
/**
* Applies specified properties to all the selected components. If some of void editSelection();
* the properties are not applicable to some of the selected components an
* exception will be thrown.
*
* @param properties
*/
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.
@@ -483,7 +483,8 @@ public class Presenter implements IPlugInPort {
} }
} }
private void editSelection() { @Override
public void editSelection() {
List<PropertyWrapper> properties = getMutualSelectionProperties(); List<PropertyWrapper> properties = getMutualSelectionProperties();
if (properties != null && !properties.isEmpty()) { if (properties != null && !properties.isEmpty()) {
Set<PropertyWrapper> defaultedProperties = new HashSet<PropertyWrapper>(); Set<PropertyWrapper> defaultedProperties = new HashSet<PropertyWrapper>();
@@ -1192,8 +1193,7 @@ public class Presenter implements IPlugInPort {
} }
} }
@Override private void applyPropertiesToSelection(List<PropertyWrapper> properties) {
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 {
@@ -727,19 +727,7 @@ public class ActionFactory {
LOG.info("Nothing to edit"); LOG.info("Nothing to edit");
return; return;
} }
PropertyEditorDialog editor = DialogFactory.getInstance().createPropertyEditorDialog( plugInPort.editSelection();
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());
}
}
} }
} }
@@ -21,22 +21,14 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.image.VolatileImage; import java.awt.image.VolatileImage;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import org.apache.log4j.Logger;
import org.diylc.common.DrawOption; import org.diylc.common.DrawOption;
import org.diylc.common.IPlugInPort; 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; import com.diyfever.gui.miscutils.ConfigurationManager;
/** /**
@@ -46,8 +38,6 @@ import com.diyfever.gui.miscutils.ConfigurationManager;
*/ */
class CanvasPanel extends JComponent implements Autoscroll { class CanvasPanel extends JComponent implements Autoscroll {
private static final Logger LOG = Logger.getLogger(CanvasPanel.class);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private IPlugInPort plugInPort; private IPlugInPort plugInPort;
@@ -190,61 +180,8 @@ class CanvasPanel extends JComponent implements Autoscroll {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) { 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 plugInPort.mouseClicked(e.getPoint(), e.isControlDown(), e.isShiftDown(), e
.isAltDown(), e.getClickCount()); .isAltDown(), e.getClickCount());
// }
} }
} }
}); });