mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
code format
This commit is contained in:
Binary file not shown.
+3
-6
@@ -10,13 +10,11 @@ import java.util.List;
|
||||
|
||||
import com.diyfever.diylc.model.IComponentInstance;
|
||||
|
||||
public class ComponentSelection extends ArrayList<IComponentInstance> implements
|
||||
Transferable {
|
||||
public class ComponentSelection extends ArrayList<IComponentInstance> implements Transferable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final DataFlavor listFlavor = new DataFlavor(List.class,
|
||||
"Java List");
|
||||
public static final DataFlavor listFlavor = new DataFlavor(List.class, "Java List");
|
||||
|
||||
public ComponentSelection() {
|
||||
super();
|
||||
@@ -27,8 +25,7 @@ public class ComponentSelection extends ArrayList<IComponentInstance> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTransferData(DataFlavor flavor)
|
||||
throws UnsupportedFlavorException, IOException {
|
||||
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
|
||||
if (flavor.equals(listFlavor)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
+6
-8
@@ -17,8 +17,8 @@ public class ControlPointWrapper {
|
||||
private boolean sticky;
|
||||
private VisibilityPolicy visibilityPolicy;
|
||||
|
||||
public ControlPointWrapper(String name, Method getter, Method setter,
|
||||
boolean editable, boolean sticky, VisibilityPolicy visibilityPolicy) {
|
||||
public ControlPointWrapper(String name, Method getter, Method setter, boolean editable,
|
||||
boolean sticky, VisibilityPolicy visibilityPolicy) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.getter = getter;
|
||||
@@ -28,15 +28,13 @@ public class ControlPointWrapper {
|
||||
this.visibilityPolicy = visibilityPolicy;
|
||||
}
|
||||
|
||||
public void readFrom(IComponentInstance component)
|
||||
throws IllegalArgumentException, IllegalAccessException,
|
||||
InvocationTargetException {
|
||||
public void readFrom(IComponentInstance component) throws IllegalArgumentException,
|
||||
IllegalAccessException, InvocationTargetException {
|
||||
value = (Point) getter.invoke(component);
|
||||
}
|
||||
|
||||
public void writeTo(IComponentInstance component)
|
||||
throws IllegalArgumentException, IllegalAccessException,
|
||||
InvocationTargetException {
|
||||
public void writeTo(IComponentInstance component) throws IllegalArgumentException,
|
||||
IllegalAccessException, InvocationTargetException {
|
||||
setter.invoke(component, value);
|
||||
}
|
||||
|
||||
|
||||
+3
-6
@@ -108,8 +108,7 @@ public interface IPlugInPort {
|
||||
* @throws BadPositionException
|
||||
* in case invalid position is specified
|
||||
*/
|
||||
void injectGUIComponent(JComponent component, int position)
|
||||
throws BadPositionException;
|
||||
void injectGUIComponent(JComponent component, int position) throws BadPositionException;
|
||||
|
||||
/**
|
||||
* Injects a custom menu action into application's main menu. If
|
||||
@@ -144,8 +143,7 @@ public interface IPlugInPort {
|
||||
*
|
||||
* @param point
|
||||
*/
|
||||
void mouseClicked(Point point, boolean ctrlDown, boolean shiftDown,
|
||||
boolean altDown);
|
||||
void mouseClicked(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown);
|
||||
|
||||
void mouseMoved(Point point);
|
||||
|
||||
@@ -266,8 +264,7 @@ public interface IPlugInPort {
|
||||
* @param properties
|
||||
* @throws Exception
|
||||
*/
|
||||
void applyPropertiesToSelection(List<PropertyWrapper> properties)
|
||||
throws Exception;
|
||||
void applyPropertiesToSelection(List<PropertyWrapper> properties) throws Exception;
|
||||
|
||||
// void setCursorIcon(Icon icon);
|
||||
|
||||
|
||||
+14
-16
@@ -14,8 +14,8 @@ public class PropertyWrapper implements Cloneable {
|
||||
private Method getter;
|
||||
private boolean defaultable;
|
||||
|
||||
public PropertyWrapper(String name, Class<?> type, Method getter,
|
||||
Method setter, boolean defaultable) {
|
||||
public PropertyWrapper(String name, Class<?> type, Method getter, Method setter,
|
||||
boolean defaultable) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
@@ -24,24 +24,22 @@ public class PropertyWrapper implements Cloneable {
|
||||
this.defaultable = defaultable;
|
||||
}
|
||||
|
||||
public void readFrom(IComponentInstance component)
|
||||
throws IllegalArgumentException, IllegalAccessException,
|
||||
InvocationTargetException {
|
||||
public void readFrom(IComponentInstance component) throws IllegalArgumentException,
|
||||
IllegalAccessException, InvocationTargetException {
|
||||
this.value = getter.invoke(component);
|
||||
}
|
||||
|
||||
// public void readUniqueFrom(IComponentInstance component)
|
||||
// throws IllegalArgumentException, IllegalAccessException,
|
||||
// InvocationTargetException {
|
||||
// Object newValue = getter.invoke(component);
|
||||
// if (!newValue.equals(value)) {
|
||||
// this.value = null;
|
||||
// }
|
||||
// }
|
||||
// public void readUniqueFrom(IComponentInstance component)
|
||||
// throws IllegalArgumentException, IllegalAccessException,
|
||||
// InvocationTargetException {
|
||||
// Object newValue = getter.invoke(component);
|
||||
// if (!newValue.equals(value)) {
|
||||
// this.value = null;
|
||||
// }
|
||||
// }
|
||||
|
||||
public void writeTo(IComponentInstance component)
|
||||
throws IllegalArgumentException, IllegalAccessException,
|
||||
InvocationTargetException {
|
||||
public void writeTo(IComponentInstance component) throws IllegalArgumentException,
|
||||
IllegalAccessException, InvocationTargetException {
|
||||
setter.invoke(component, value);
|
||||
}
|
||||
|
||||
|
||||
+23
-32
@@ -55,10 +55,8 @@ public class DialogFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public PropertyEditorDialog createPropertyEditorDialog(
|
||||
List<PropertyWrapper> properties) {
|
||||
PropertyEditorDialog editor = new PropertyEditorDialog(mainFrame,
|
||||
properties);
|
||||
public PropertyEditorDialog createPropertyEditorDialog(List<PropertyWrapper> properties) {
|
||||
PropertyEditorDialog editor = new PropertyEditorDialog(mainFrame, properties);
|
||||
return editor;
|
||||
}
|
||||
|
||||
@@ -67,33 +65,28 @@ public class DialogFactory {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public File showOpenDialog(FileFilter fileFilter, File initialFile,
|
||||
String defaultExtension, IFileChooserAccessory accessory) {
|
||||
public File showOpenDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
|
||||
IFileChooserAccessory accessory) {
|
||||
JFileChooser openFileChooser = new JFileChooser();
|
||||
initializeFileChooser(openFileChooser, fileFilter, initialFile,
|
||||
defaultExtension, accessory);
|
||||
initializeFileChooser(openFileChooser, fileFilter, initialFile, defaultExtension, accessory);
|
||||
|
||||
int result = openFileChooser.showOpenDialog(mainFrame);
|
||||
|
||||
return processFileChooserResult(result, openFileChooser,
|
||||
defaultExtension);
|
||||
return processFileChooserResult(result, openFileChooser, defaultExtension);
|
||||
}
|
||||
|
||||
public File showSaveDialog(FileFilter fileFilter, File initialFile,
|
||||
String defaultExtension, IFileChooserAccessory accessory) {
|
||||
public File showSaveDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
|
||||
IFileChooserAccessory accessory) {
|
||||
JFileChooser saveFileChooser = new OverwritePromptFileChooser();
|
||||
initializeFileChooser(saveFileChooser, fileFilter, initialFile,
|
||||
defaultExtension, accessory);
|
||||
initializeFileChooser(saveFileChooser, fileFilter, initialFile, defaultExtension, accessory);
|
||||
|
||||
int result = saveFileChooser.showSaveDialog(mainFrame);
|
||||
|
||||
return processFileChooserResult(result, saveFileChooser,
|
||||
defaultExtension);
|
||||
return processFileChooserResult(result, saveFileChooser, defaultExtension);
|
||||
}
|
||||
|
||||
private void initializeFileChooser(JFileChooser fileChooser,
|
||||
FileFilter fileFilter, File initialFile, String defaultExtension,
|
||||
IFileChooserAccessory accessory) {
|
||||
private void initializeFileChooser(JFileChooser fileChooser, FileFilter fileFilter,
|
||||
File initialFile, String defaultExtension, IFileChooserAccessory accessory) {
|
||||
if (accessory != null) {
|
||||
accessory.install(fileChooser);
|
||||
}
|
||||
@@ -101,8 +94,7 @@ public class DialogFactory {
|
||||
fileChooser.removeChoosableFileFilter(filter);
|
||||
}
|
||||
if (fileChooser instanceof OverwritePromptFileChooser) {
|
||||
((OverwritePromptFileChooser) fileChooser).setFileFilter(
|
||||
fileFilter, defaultExtension);
|
||||
((OverwritePromptFileChooser) fileChooser).setFileFilter(fileFilter, defaultExtension);
|
||||
} else {
|
||||
fileChooser.setFileFilter(fileFilter);
|
||||
}
|
||||
@@ -122,19 +114,18 @@ public class DialogFactory {
|
||||
if (fileChooser.getSelectedFile().getAbsolutePath().contains(".")) {
|
||||
return fileChooser.getSelectedFile();
|
||||
} else {
|
||||
return new File(fileChooser.getSelectedFile().getAbsoluteFile()
|
||||
+ "." + defaultExtension);
|
||||
return new File(fileChooser.getSelectedFile().getAbsoluteFile() + "."
|
||||
+ defaultExtension);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public AboutDialog createAboutDialog(String appName, Icon icon,
|
||||
String version, String author, String url, String mail,
|
||||
String htmlContent) {
|
||||
AboutDialog dialog = new AboutDialog(mainFrame, appName, icon, version,
|
||||
author, url, mail, htmlContent);
|
||||
public AboutDialog createAboutDialog(String appName, Icon icon, String version, String author,
|
||||
String url, String mail, String htmlContent) {
|
||||
AboutDialog dialog = new AboutDialog(mainFrame, appName, icon, version, author, url, mail,
|
||||
htmlContent);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@@ -153,10 +144,10 @@ public class DialogFactory {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public ProgressDialog createProgressDialog(String title,
|
||||
String[] buttonCaptions, String description, boolean useProgress) {
|
||||
ProgressDialog dialog = new ProgressDialog(mainFrame, title,
|
||||
buttonCaptions, description, useProgress);
|
||||
public ProgressDialog createProgressDialog(String title, String[] buttonCaptions,
|
||||
String description, boolean useProgress) {
|
||||
ProgressDialog dialog = new ProgressDialog(mainFrame, title, buttonCaptions, description,
|
||||
useProgress);
|
||||
return dialog;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -25,8 +25,7 @@ public interface IView {
|
||||
*
|
||||
* @see IPlugInPort#injectGUIComponent
|
||||
*/
|
||||
void addComponent(JComponent component, int position)
|
||||
throws BadPositionException;
|
||||
void addComponent(JComponent component, int position) throws BadPositionException;
|
||||
|
||||
/**
|
||||
* Adds a menu action.
|
||||
|
||||
+1
-2
@@ -124,8 +124,7 @@ public class MainFrame extends JFrame implements IView {
|
||||
// IView
|
||||
|
||||
@Override
|
||||
public void addComponent(JComponent component, int position)
|
||||
throws BadPositionException {
|
||||
public void addComponent(JComponent component, int position) throws BadPositionException {
|
||||
switch (position) {
|
||||
case SwingConstants.TOP:
|
||||
topPanel.add(component);
|
||||
|
||||
+4
-7
@@ -16,16 +16,13 @@ public class OverwritePromptFileChooser extends JFileChooser {
|
||||
if (getSelectedFile().getAbsolutePath().contains(".")) {
|
||||
lSelectedFile = getSelectedFile();
|
||||
} else {
|
||||
lSelectedFile = new File(getSelectedFile().getAbsoluteFile() + "."
|
||||
+ defaultExtension);
|
||||
lSelectedFile = new File(getSelectedFile().getAbsoluteFile() + "." + defaultExtension);
|
||||
}
|
||||
|
||||
if (lSelectedFile != null && lSelectedFile.exists()) {
|
||||
int lResponse = JOptionPane.showConfirmDialog(this, lSelectedFile
|
||||
.getAbsolutePath()
|
||||
+ " already exists.\nDo you " + "want to replace it?",
|
||||
"Warning", JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
int lResponse = JOptionPane.showConfirmDialog(this, lSelectedFile.getAbsolutePath()
|
||||
+ " already exists.\nDo you " + "want to replace it?", "Warning",
|
||||
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
|
||||
|
||||
if (lResponse != JOptionPane.YES_OPTION) {
|
||||
return;
|
||||
|
||||
+2
-2
@@ -27,8 +27,8 @@ public class ColorEditor extends JLabel {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
Color newColor = JColorChooser.showDialog(ColorEditor.this,
|
||||
"Choose Color", getBackground());
|
||||
Color newColor = JColorChooser.showDialog(ColorEditor.this, "Choose Color",
|
||||
getBackground());
|
||||
if (newColor != null) {
|
||||
property.setValue(newColor);
|
||||
setBackground(newColor);
|
||||
|
||||
+1
-2
@@ -35,8 +35,7 @@ public class MeasureEditor extends Container {
|
||||
add(valueField, BorderLayout.CENTER);
|
||||
try {
|
||||
Method method = measure.getUnit().getClass().getMethod("values");
|
||||
final JComboBox unitBox = new JComboBox((Object[]) method
|
||||
.invoke(measure.getUnit()));
|
||||
final JComboBox unitBox = new JComboBox((Object[]) method.invoke(measure.getUnit()));
|
||||
unitBox.setSelectedItem(measure.getUnit());
|
||||
unitBox.addActionListener(new ActionListener() {
|
||||
|
||||
|
||||
+4
-8
@@ -24,8 +24,7 @@ import com.diyfever.gui.ButtonDialog;
|
||||
|
||||
public class PropertyEditorDialog extends ButtonDialog {
|
||||
|
||||
private static final Logger LOG = Logger
|
||||
.getLogger(PropertyEditorDialog.class);
|
||||
private static final Logger LOG = Logger.getLogger(PropertyEditorDialog.class);
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -35,8 +34,7 @@ public class PropertyEditorDialog extends ButtonDialog {
|
||||
private Set<PropertyWrapper> defaultedProperties;
|
||||
|
||||
public PropertyEditorDialog(JFrame owner, List<PropertyWrapper> properties) {
|
||||
super(owner, "Editor", new String[] { ButtonDialog.OK,
|
||||
ButtonDialog.CANCEL });
|
||||
super(owner, "Editor", new String[] { ButtonDialog.OK, ButtonDialog.CANCEL });
|
||||
|
||||
LOG.debug("Creating property editor for: " + properties);
|
||||
|
||||
@@ -85,8 +83,7 @@ public class PropertyEditorDialog extends ButtonDialog {
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc.weightx = 1;
|
||||
|
||||
editorPanel
|
||||
.add(FieldEditorFactory.createFieldEditor(property), gbc);
|
||||
editorPanel.add(FieldEditorFactory.createFieldEditor(property), gbc);
|
||||
|
||||
if (property.isDefaultable()) {
|
||||
gbc.gridx = 2;
|
||||
@@ -124,8 +121,7 @@ public class PropertyEditorDialog extends ButtonDialog {
|
||||
}
|
||||
|
||||
public static boolean showFor(JFrame owner, List<PropertyWrapper> properties) {
|
||||
PropertyEditorDialog editor = new PropertyEditorDialog(owner,
|
||||
properties);
|
||||
PropertyEditorDialog editor = new PropertyEditorDialog(owner, properties);
|
||||
editor.setVisible(true);
|
||||
if (OK.equals(editor.getSelectedButtonCaption())) {
|
||||
return true;
|
||||
|
||||
+12
-42
@@ -10,48 +10,18 @@ import javax.swing.ImageIcon;
|
||||
*/
|
||||
public enum IconLoader {
|
||||
|
||||
Delete("delete.png"),
|
||||
Add("add.png"),
|
||||
FolderOut("folder_out.png"),
|
||||
Garbage("garbage.png"),
|
||||
DiskBlue("disk_blue.png"),
|
||||
SaveAs("save_as.png"),
|
||||
Exit("exit.png"),
|
||||
DocumentPlainYellow("document_plain_yellow.png"),
|
||||
PhotoScenery("photo_scenery.png"),
|
||||
LightBulbOn("lightbulb_on.png"),
|
||||
LightBulbOff("lightbulb_off.png"),
|
||||
NotebookAdd("notebook_add.png"),
|
||||
FormGreen("form_green.png"),
|
||||
Gears("gears.png"),
|
||||
About("about.png"),
|
||||
Donate("donate.gif"),
|
||||
WindowColors("window_colors.png"),
|
||||
WindowGear("window_gear.png"),
|
||||
NavigateCheck("navigate_check.png"),
|
||||
Undo("undo.png"),
|
||||
Error("error.png"),
|
||||
Warning("warning.png"),
|
||||
ZoomSmall("zoom_small.png"),
|
||||
MoveSmall("move_small.png"),
|
||||
Print("print.png"),
|
||||
PDF("pdf.png"),
|
||||
Excel("excel.png"),
|
||||
CSV("csv.png"),
|
||||
HTML("html.png"),
|
||||
Image("image.png"),
|
||||
Cut("cut.png"),
|
||||
Copy("copy.png"),
|
||||
Paste("paste.png"),
|
||||
Selection("selection.png"),
|
||||
BOM("bom.png"),
|
||||
BlackBoard("blackboard.png"),
|
||||
IdCard("id_card.png"),
|
||||
IdCardAdd("id_card_add.png"),
|
||||
Chest("chest.png"),
|
||||
Upload("upload.png"),
|
||||
Wrench("wrench.png"),
|
||||
;
|
||||
Delete("delete.png"), Add("add.png"), FolderOut("folder_out.png"), Garbage("garbage.png"), DiskBlue(
|
||||
"disk_blue.png"), SaveAs("save_as.png"), Exit("exit.png"), DocumentPlainYellow(
|
||||
"document_plain_yellow.png"), PhotoScenery("photo_scenery.png"), LightBulbOn(
|
||||
"lightbulb_on.png"), LightBulbOff("lightbulb_off.png"), NotebookAdd("notebook_add.png"), FormGreen(
|
||||
"form_green.png"), Gears("gears.png"), About("about.png"), Donate("donate.gif"), WindowColors(
|
||||
"window_colors.png"), WindowGear("window_gear.png"), NavigateCheck("navigate_check.png"), Undo(
|
||||
"undo.png"), Error("error.png"), Warning("warning.png"), ZoomSmall("zoom_small.png"), MoveSmall(
|
||||
"move_small.png"), Print("print.png"), PDF("pdf.png"), Excel("excel.png"), CSV(
|
||||
"csv.png"), HTML("html.png"), Image("image.png"), Cut("cut.png"), Copy("copy.png"), Paste(
|
||||
"paste.png"), Selection("selection.png"), BOM("bom.png"), BlackBoard("blackboard.png"), IdCard(
|
||||
"id_card.png"), IdCardAdd("id_card_add.png"), Chest("chest.png"), Upload("upload.png"), Wrench(
|
||||
"wrench.png"), ;
|
||||
|
||||
protected String name;
|
||||
|
||||
|
||||
+1
-1
@@ -24,5 +24,5 @@ public interface IComponentInstance extends Serializable {
|
||||
*/
|
||||
void draw(Graphics2D g2d, ComponentState componentState);
|
||||
|
||||
// IComponentInstance clone() throws CloneNotSupportedException;
|
||||
// IComponentInstance clone() throws CloneNotSupportedException;
|
||||
}
|
||||
|
||||
+15
-16
@@ -27,8 +27,8 @@ public class Project implements Serializable {
|
||||
height = new Size(21d, SizeUnit.cm);
|
||||
}
|
||||
|
||||
public Project(String title, String author, String description, Size width,
|
||||
Size height, List<IComponentInstance> components) {
|
||||
public Project(String title, String author, String description, Size width, Size height,
|
||||
List<IComponentInstance> components) {
|
||||
super();
|
||||
this.title = title;
|
||||
this.author = author;
|
||||
@@ -92,10 +92,8 @@ public class Project implements Serializable {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((author == null) ? 0 : author.hashCode());
|
||||
result = prime * result
|
||||
+ ((components == null) ? 0 : components.hashCode());
|
||||
result = prime * result
|
||||
+ ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((components == null) ? 0 : components.hashCode());
|
||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((height == null) ? 0 : height.hashCode());
|
||||
result = prime * result + ((title == null) ? 0 : title.hashCode());
|
||||
result = prime * result + ((width == null) ? 0 : width.hashCode());
|
||||
@@ -144,14 +142,15 @@ public class Project implements Serializable {
|
||||
return true;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Project clone() throws CloneNotSupportedException {
|
||||
// List<IComponentInstance> clonedComponents = new ArrayList<IComponentInstance>();
|
||||
// for (IComponentInstance component : components) {
|
||||
// clonedComponents.add(component.clone());
|
||||
// }
|
||||
// Project project = new Project(title, author, description,
|
||||
// width.clone(), height.clone(), clonedComponents);
|
||||
// return project;
|
||||
// }
|
||||
// @Override
|
||||
// public Project clone() throws CloneNotSupportedException {
|
||||
// List<IComponentInstance> clonedComponents = new
|
||||
// ArrayList<IComponentInstance>();
|
||||
// for (IComponentInstance component : components) {
|
||||
// clonedComponents.add(component.clone());
|
||||
// }
|
||||
// Project project = new Project(title, author, description,
|
||||
// width.clone(), height.clone(), clonedComponents);
|
||||
// return project;
|
||||
// }
|
||||
}
|
||||
|
||||
+7
-7
@@ -38,11 +38,11 @@ public @interface ControlPoint {
|
||||
*/
|
||||
boolean sticky() default true;
|
||||
|
||||
// /**
|
||||
// * If true, the control point is the main control point for the component.
|
||||
// * There cannot be more than one control point for a single component.
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// boolean main() default false;
|
||||
// /**
|
||||
// * If true, the control point is the main control point for the component.
|
||||
// * There cannot be more than one control point for a single component.
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// boolean main() default false;
|
||||
}
|
||||
|
||||
+1
-2
@@ -4,8 +4,7 @@ import java.io.Serializable;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.Format;
|
||||
|
||||
public class AbstractMeasure<T extends Enum<? extends Unit>> implements
|
||||
Serializable, Cloneable {
|
||||
public class AbstractMeasure<T extends Enum<? extends Unit>> implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
+1
-2
@@ -6,8 +6,7 @@ public class Size extends AbstractMeasure<SizeUnit> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final int PIXELS_PER_INCH = Toolkit.getDefaultToolkit()
|
||||
.getScreenResolution();
|
||||
public static final int PIXELS_PER_INCH = Toolkit.getDefaultToolkit().getScreenResolution();
|
||||
|
||||
public Size() {
|
||||
super();
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ class CanvasGestureListener implements DragGestureListener {
|
||||
@Override
|
||||
public void dragGestureRecognized(DragGestureEvent dge) {
|
||||
presenter.dragStarted(dge.getDragOrigin());
|
||||
dge.startDrag(Cursor.getDefaultCursor(), new EmptyTransferable(),
|
||||
new CanvasSourceListener(presenter));
|
||||
dge.startDrag(Cursor.getDefaultCursor(), new EmptyTransferable(), new CanvasSourceListener(
|
||||
presenter));
|
||||
}
|
||||
}
|
||||
|
||||
+18
-27
@@ -48,9 +48,9 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
||||
private VolatileImage bufferImage;
|
||||
private GraphicsConfiguration screenGraphicsConfiguration;
|
||||
|
||||
private static final EnumSet<DrawOption> drawOptions = EnumSet.of(
|
||||
DrawOption.GRID, DrawOption.SELECTION, DrawOption.ZOOM,
|
||||
DrawOption.ANTIALIASING, DrawOption.CONTROL_POINTS);
|
||||
private static final EnumSet<DrawOption> drawOptions = EnumSet.of(DrawOption.GRID,
|
||||
DrawOption.SELECTION, DrawOption.ZOOM, DrawOption.ANTIALIASING,
|
||||
DrawOption.CONTROL_POINTS);
|
||||
|
||||
public CanvasPanel(IPlugInPort plugInPort) {
|
||||
super();
|
||||
@@ -59,8 +59,7 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
||||
setFocusable(true);
|
||||
initializeListeners();
|
||||
initializeDnD();
|
||||
GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment
|
||||
.getLocalGraphicsEnvironment();
|
||||
GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices();
|
||||
screenGraphicsConfiguration = devices[0].getDefaultConfiguration();
|
||||
|
||||
@@ -73,9 +72,8 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
||||
|
||||
private void initializeDnD() {
|
||||
// Initialize drag source recognizer.
|
||||
DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
|
||||
this, DnDConstants.ACTION_MOVE,
|
||||
new CanvasGestureListener(plugInPort));
|
||||
DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(this,
|
||||
DnDConstants.ACTION_MOVE, new CanvasGestureListener(plugInPort));
|
||||
// Initialize drop target.
|
||||
new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE,
|
||||
new CanvasTargetListener(plugInPort), true);
|
||||
@@ -96,8 +94,8 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
||||
}
|
||||
|
||||
protected void createBufferImage() {
|
||||
bufferImage = screenGraphicsConfiguration
|
||||
.createCompatibleVolatileImage(getWidth(), getHeight());
|
||||
bufferImage = screenGraphicsConfiguration.createCompatibleVolatileImage(getWidth(),
|
||||
getHeight());
|
||||
bufferImage.validate(screenGraphicsConfiguration);
|
||||
Graphics2D g2d = (Graphics2D) bufferImage.getGraphics();
|
||||
plugInPort.draw(g2d, drawOptions);
|
||||
@@ -157,24 +155,19 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
||||
if (properties.isEmpty()) {
|
||||
|
||||
} else {
|
||||
PropertyEditorDialog editor = DialogFactory
|
||||
.getInstance()
|
||||
PropertyEditorDialog editor = DialogFactory.getInstance()
|
||||
.createPropertyEditorDialog(properties);
|
||||
editor.setVisible(true);
|
||||
if (ButtonDialog.OK.equals(editor
|
||||
.getSelectedButtonCaption())) {
|
||||
if (ButtonDialog.OK.equals(editor.getSelectedButtonCaption())) {
|
||||
try {
|
||||
plugInPort
|
||||
.applyPropertiesToSelection(properties);
|
||||
plugInPort.applyPropertiesToSelection(properties);
|
||||
} catch (Exception e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
for (PropertyWrapper property : editor
|
||||
.getDefaultedProperties()) {
|
||||
for (PropertyWrapper property : editor.getDefaultedProperties()) {
|
||||
if (property.getValue() != null) {
|
||||
plugInPort.setDefaultPropertyValue(
|
||||
property.getName(),
|
||||
plugInPort.setDefaultPropertyValue(property.getName(),
|
||||
property.getValue());
|
||||
}
|
||||
}
|
||||
@@ -182,9 +175,8 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugInPort.mouseClicked(e.getPoint(),
|
||||
e.isControlDown(), e.isShiftDown(), e
|
||||
.isAltDown());
|
||||
plugInPort.mouseClicked(e.getPoint(), e.isControlDown(), e.isShiftDown(), e
|
||||
.isAltDown());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,14 +187,13 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
||||
|
||||
@Override
|
||||
public void autoscroll(Point cursorLocn) {
|
||||
scrollRectToVisible(new Rectangle(cursorLocn.x - 15, cursorLocn.y - 15,
|
||||
30, 30));
|
||||
scrollRectToVisible(new Rectangle(cursorLocn.x - 15, cursorLocn.y - 15, 30, 30));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets getAutoscrollInsets() {
|
||||
Rectangle rect = getVisibleRect();
|
||||
return new Insets(rect.y - 15, rect.x - 15, rect.y + rect.height + 15,
|
||||
rect.x + rect.width + 15);
|
||||
return new Insets(rect.y - 15, rect.x - 15, rect.y + rect.height + 15, rect.x + rect.width
|
||||
+ 15);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-12
@@ -33,8 +33,7 @@ public class CanvasPlugin implements IPlugIn {
|
||||
this.plugInPort = plugInPort;
|
||||
canvasPanel = new CanvasPanel(plugInPort);
|
||||
try {
|
||||
plugInPort.injectGUIComponent(getScrollPane(),
|
||||
SwingConstants.CENTER);
|
||||
plugInPort.injectGUIComponent(getScrollPane(), SwingConstants.CENTER);
|
||||
} catch (BadPositionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -42,10 +41,9 @@ public class CanvasPlugin implements IPlugIn {
|
||||
|
||||
private RulerScrollPane getScrollPane() {
|
||||
if (scrollPane == null) {
|
||||
scrollPane = new RulerScrollPane(canvasPanel,
|
||||
new ProjectDrawingProvider(plugInPort));
|
||||
Boolean metric = (Boolean) ConfigurationManager.getInstance()
|
||||
.getConfigurationItem(METRIC_KEY);
|
||||
scrollPane = new RulerScrollPane(canvasPanel, new ProjectDrawingProvider(plugInPort));
|
||||
Boolean metric = (Boolean) ConfigurationManager.getInstance().getConfigurationItem(
|
||||
METRIC_KEY);
|
||||
if (metric == null) {
|
||||
metric = true;
|
||||
}
|
||||
@@ -54,8 +52,7 @@ public class CanvasPlugin implements IPlugIn {
|
||||
|
||||
@Override
|
||||
public void unitsChanged(boolean isMetric) {
|
||||
ConfigurationManager.getInstance().setConfigurationItem(
|
||||
METRIC_KEY, isMetric);
|
||||
ConfigurationManager.getInstance().setConfigurationItem(METRIC_KEY, isMetric);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -64,8 +61,7 @@ public class CanvasPlugin implements IPlugIn {
|
||||
|
||||
@Override
|
||||
public EnumSet<EventType> getSubscribedEventTypes() {
|
||||
return EnumSet.of(EventType.PROJECT_LOADED, EventType.ZOOM_CHANGED,
|
||||
EventType.REPAINT);
|
||||
return EnumSet.of(EventType.PROJECT_LOADED, EventType.ZOOM_CHANGED, EventType.REPAINT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,8 +77,7 @@ public class CanvasPlugin implements IPlugIn {
|
||||
if ((Boolean) params[1]) {
|
||||
// Scroll to the center.
|
||||
Rectangle visibleRect = canvasPanel.getVisibleRect();
|
||||
visibleRect.setLocation(
|
||||
(canvasPanel.getWidth() - visibleRect.width) / 2,
|
||||
visibleRect.setLocation((canvasPanel.getWidth() - visibleRect.width) / 2,
|
||||
(canvasPanel.getHeight() - visibleRect.height) / 2);
|
||||
canvasPanel.scrollRectToVisible(visibleRect);
|
||||
canvasPanel.revalidate();
|
||||
|
||||
+1
-2
@@ -39,8 +39,7 @@ class CanvasSourceListener implements DragSourceListener {
|
||||
public void dragOver(DragSourceDragEvent dsde) {
|
||||
Point p = dsde.getDragSourceContext().getComponent().getMousePosition();
|
||||
if (p != null) {
|
||||
dsde.getDragSourceContext().getComponent().firePropertyChange(
|
||||
"dragPoint", p.x, p.y);
|
||||
dsde.getDragSourceContext().getComponent().firePropertyChange("dragPoint", p.x, p.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -8,8 +8,7 @@ import java.io.IOException;
|
||||
public class EmptyTransferable implements Transferable {
|
||||
|
||||
@Override
|
||||
public Object getTransferData(DataFlavor flavor)
|
||||
throws UnsupportedFlavorException, IOException {
|
||||
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
|
||||
throw new UnsupportedFlavorException(flavor);
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -8,8 +8,7 @@ import java.io.IOException;
|
||||
|
||||
public class PointTransferable implements Transferable {
|
||||
|
||||
public static final DataFlavor pointFlavor = new DataFlavor(Point.class,
|
||||
"Java Point");
|
||||
public static final DataFlavor pointFlavor = new DataFlavor(Point.class, "Java Point");
|
||||
|
||||
private Point startPoint;
|
||||
|
||||
@@ -19,8 +18,7 @@ public class PointTransferable implements Transferable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTransferData(DataFlavor flavor)
|
||||
throws UnsupportedFlavorException, IOException {
|
||||
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
|
||||
if (flavor.equals(pointFlavor)) {
|
||||
return startPoint;
|
||||
}
|
||||
|
||||
+3
-6
@@ -17,16 +17,14 @@ public class SelectionTransferable implements Transferable {
|
||||
private Point startPoint;
|
||||
private List<IComponentInstance> selection;
|
||||
|
||||
public SelectionTransferable(List<IComponentInstance> selection,
|
||||
Point startPoint) {
|
||||
public SelectionTransferable(List<IComponentInstance> selection, Point startPoint) {
|
||||
super();
|
||||
this.selection = selection;
|
||||
this.startPoint = startPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTransferData(DataFlavor flavor)
|
||||
throws UnsupportedFlavorException, IOException {
|
||||
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
|
||||
if (flavor.equals(selectionFlavor)) {
|
||||
return selection;
|
||||
}
|
||||
@@ -38,8 +36,7 @@ public class SelectionTransferable implements Transferable {
|
||||
|
||||
@Override
|
||||
public DataFlavor[] getTransferDataFlavors() {
|
||||
return new DataFlavor[] { selectionFlavor,
|
||||
PointTransferable.pointFlavor };
|
||||
return new DataFlavor[] { selectionFlavor, PointTransferable.pointFlavor };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+13
-16
@@ -82,8 +82,7 @@ public class ClipboardManager implements IPlugIn, ClipboardOwner {
|
||||
|
||||
@Override
|
||||
public EnumSet<EventType> getSubscribedEventTypes() {
|
||||
return EnumSet.of(EventType.SELECTION_CHANGED,
|
||||
EventType.PROJECT_MODIFIED);
|
||||
return EnumSet.of(EventType.SELECTION_CHANGED, EventType.PROJECT_MODIFIED);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,8 +92,7 @@ public class ClipboardManager implements IPlugIn, ClipboardOwner {
|
||||
refreshActions();
|
||||
break;
|
||||
case PROJECT_MODIFIED:
|
||||
undoHandler.stateChanged((Project) params[0], (Project) params[1],
|
||||
(String) params[2]);
|
||||
undoHandler.stateChanged((Project) params[0], (Project) params[1], (String) params[2]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -104,8 +102,7 @@ public class ClipboardManager implements IPlugIn, ClipboardOwner {
|
||||
cutAction.setEnabled(enabled);
|
||||
copyAction.setEnabled(enabled);
|
||||
try {
|
||||
pasteAction.setEnabled(clipboard
|
||||
.isDataFlavorAvailable(ComponentSelection.listFlavor));
|
||||
pasteAction.setEnabled(clipboard.isDataFlavorAvailable(ComponentSelection.listFlavor));
|
||||
} catch (Exception e) {
|
||||
pasteAction.setEnabled(false);
|
||||
}
|
||||
@@ -118,8 +115,8 @@ public class ClipboardManager implements IPlugIn, ClipboardOwner {
|
||||
public CutAction() {
|
||||
super();
|
||||
putValue(AbstractAction.NAME, "Cut");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_X, ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_X,
|
||||
ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Cut.getIcon());
|
||||
}
|
||||
|
||||
@@ -136,16 +133,16 @@ public class ClipboardManager implements IPlugIn, ClipboardOwner {
|
||||
public CopyAction() {
|
||||
super();
|
||||
putValue(AbstractAction.NAME, "Copy");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_C, ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C,
|
||||
ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Copy.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Copy triggered");
|
||||
clipboard.setContents(cloner.deepClone(plugInPort
|
||||
.getSelectedComponents()), ClipboardManager.this);
|
||||
clipboard.setContents(cloner.deepClone(plugInPort.getSelectedComponents()),
|
||||
ClipboardManager.this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,8 +153,8 @@ public class ClipboardManager implements IPlugIn, ClipboardOwner {
|
||||
public PasteAction() {
|
||||
super();
|
||||
putValue(AbstractAction.NAME, "Paste");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_V, ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_V,
|
||||
ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Paste.getIcon());
|
||||
}
|
||||
|
||||
@@ -182,8 +179,8 @@ public class ClipboardManager implements IPlugIn, ClipboardOwner {
|
||||
public SelectAllAction() {
|
||||
super();
|
||||
putValue(AbstractAction.NAME, "Select All");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_A, ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_A,
|
||||
ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Selection.getIcon());
|
||||
}
|
||||
|
||||
|
||||
+8
-12
@@ -54,9 +54,8 @@ public class BomDialog extends JDialog {
|
||||
private ObjectListTable<BomEntry> getTable() {
|
||||
if (table == null) {
|
||||
try {
|
||||
table = new ObjectListTable<BomEntry>(BomEntry.class,
|
||||
new String[] { "getName", "getValue", "getQuantity",
|
||||
"getNotes/setNotes" }, null);
|
||||
table = new ObjectListTable<BomEntry>(BomEntry.class, new String[] { "getName",
|
||||
"getValue", "getQuantity", "getNotes/setNotes" }, null);
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e) {
|
||||
@@ -115,9 +114,8 @@ public class BomDialog extends JDialog {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
File file = DialogFactory.getInstance().showSaveDialog(
|
||||
FileFilterEnum.CSV.getFilter(), null,
|
||||
FileFilterEnum.CSV.getExtensions()[0], null);
|
||||
File file = DialogFactory.getInstance().showSaveDialog(FileFilterEnum.CSV.getFilter(),
|
||||
null, FileFilterEnum.CSV.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
try {
|
||||
TableExporter.getInstance().exportToCSV(getTable(), file);
|
||||
@@ -141,9 +139,8 @@ public class BomDialog extends JDialog {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
File file = DialogFactory.getInstance().showSaveDialog(
|
||||
FileFilterEnum.HTML.getFilter(), null,
|
||||
FileFilterEnum.HTML.getExtensions()[0], null);
|
||||
File file = DialogFactory.getInstance().showSaveDialog(FileFilterEnum.HTML.getFilter(),
|
||||
null, FileFilterEnum.HTML.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
try {
|
||||
TableExporter.getInstance().exportToHTML(getTable(), file);
|
||||
@@ -167,9 +164,8 @@ public class BomDialog extends JDialog {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
File file = DialogFactory.getInstance().showSaveDialog(
|
||||
FileFilterEnum.PNG.getFilter(), null,
|
||||
FileFilterEnum.PNG.getExtensions()[0], null);
|
||||
File file = DialogFactory.getInstance().showSaveDialog(FileFilterEnum.PNG.getFilter(),
|
||||
null, FileFilterEnum.PNG.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
try {
|
||||
TableExporter.getInstance().exportToPNG(getTable(), file);
|
||||
|
||||
+4
-8
@@ -6,12 +6,9 @@ import javax.swing.filechooser.FileFilter;
|
||||
|
||||
enum FileFilterEnum {
|
||||
|
||||
PNG("PNG Images (*.png)", "png"),
|
||||
PDF("PDF Files (*.pdf)", "pdf"),
|
||||
DIY("DIY Project Files (*.diy)", "diy"),
|
||||
EXCEL("Excel Workbooks (*.xls)", "xls"),
|
||||
CSV("Comma Separated Files (*.csv)", "csv"),
|
||||
HTML("HTML Files (*.html)", "html");
|
||||
PNG("PNG Images (*.png)", "png"), PDF("PDF Files (*.pdf)", "pdf"), DIY(
|
||||
"DIY Project Files (*.diy)", "diy"), EXCEL("Excel Workbooks (*.xls)", "xls"), CSV(
|
||||
"Comma Separated Files (*.csv)", "csv"), HTML("HTML Files (*.html)", "html");
|
||||
|
||||
FileFilter filter;
|
||||
String[] extensions;
|
||||
@@ -23,8 +20,7 @@ enum FileFilterEnum {
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
String fileExt = f.getName();
|
||||
fileExt = fileExt.substring(fileExt.lastIndexOf('.') + 1)
|
||||
.toLowerCase();
|
||||
fileExt = fileExt.substring(fileExt.lastIndexOf('.') + 1).toLowerCase();
|
||||
for (String ext : extensions) {
|
||||
if (ext.equals(fileExt)) {
|
||||
return true;
|
||||
|
||||
+11
-20
@@ -59,8 +59,7 @@ public class FileManager implements IPlugIn {
|
||||
public NewAction() {
|
||||
super();
|
||||
putValue(AbstractAction.NAME, "New");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.DocumentPlainYellow
|
||||
.getIcon());
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.DocumentPlainYellow.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,10 +81,8 @@ public class FileManager implements IPlugIn {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
File file = DialogFactory.getInstance()
|
||||
.showOpenDialog(FileFilterEnum.DIY.getFilter(), null,
|
||||
FileFilterEnum.DIY.getExtensions()[0],
|
||||
new ProjectPreview());
|
||||
File file = DialogFactory.getInstance().showOpenDialog(FileFilterEnum.DIY.getFilter(),
|
||||
null, FileFilterEnum.DIY.getExtensions()[0], new ProjectPreview());
|
||||
if (file != null) {
|
||||
LOG.info("Loading project from file.");
|
||||
FileInputStream fis;
|
||||
@@ -117,10 +114,8 @@ public class FileManager implements IPlugIn {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
File file = DialogFactory.getInstance()
|
||||
.showSaveDialog(FileFilterEnum.DIY.getFilter(), null,
|
||||
FileFilterEnum.DIY.getExtensions()[0],
|
||||
new ProjectPreview());
|
||||
File file = DialogFactory.getInstance().showSaveDialog(FileFilterEnum.DIY.getFilter(),
|
||||
null, FileFilterEnum.DIY.getExtensions()[0], new ProjectPreview());
|
||||
if (file != null) {
|
||||
LOG.info("Saving project to file.");
|
||||
FileOutputStream fos;
|
||||
@@ -151,10 +146,8 @@ public class FileManager implements IPlugIn {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
File file = DialogFactory.getInstance()
|
||||
.showSaveDialog(FileFilterEnum.DIY.getFilter(), null,
|
||||
FileFilterEnum.DIY.getExtensions()[0],
|
||||
new ProjectPreview());
|
||||
File file = DialogFactory.getInstance().showSaveDialog(FileFilterEnum.DIY.getFilter(),
|
||||
null, FileFilterEnum.DIY.getExtensions()[0], new ProjectPreview());
|
||||
if (file != null) {
|
||||
LOG.info("Saving project to file.");
|
||||
FileOutputStream fos;
|
||||
@@ -204,9 +197,8 @@ public class FileManager implements IPlugIn {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
File file = DialogFactory.getInstance().showSaveDialog(
|
||||
FileFilterEnum.PDF.getFilter(), null,
|
||||
FileFilterEnum.PDF.getExtensions()[0], null);
|
||||
File file = DialogFactory.getInstance().showSaveDialog(FileFilterEnum.PDF.getFilter(),
|
||||
null, FileFilterEnum.PDF.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
DrawingExporter.getInstance().exportPDF(drawingProvider, file);
|
||||
}
|
||||
@@ -225,9 +217,8 @@ public class FileManager implements IPlugIn {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
File file = DialogFactory.getInstance().showSaveDialog(
|
||||
FileFilterEnum.PNG.getFilter(), null,
|
||||
FileFilterEnum.PNG.getExtensions()[0], null);
|
||||
File file = DialogFactory.getInstance().showSaveDialog(FileFilterEnum.PNG.getFilter(),
|
||||
null, FileFilterEnum.PNG.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
DrawingExporter.getInstance().exportPNG(drawingProvider, file);
|
||||
}
|
||||
|
||||
+1
-2
@@ -26,8 +26,7 @@ public class ProjectDrawingProvider implements IDrawingProvider {
|
||||
|
||||
@Override
|
||||
public void draw(Graphics g) {
|
||||
plugInPort.draw((Graphics2D) g, EnumSet.of(DrawOption.ZOOM,
|
||||
DrawOption.ANTIALIASING));
|
||||
plugInPort.draw((Graphics2D) g, EnumSet.of(DrawOption.ZOOM, DrawOption.ANTIALIASING));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-4
@@ -35,8 +35,7 @@ import com.thoughtworks.xstream.io.xml.DomDriver;
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public class ProjectPreview extends JPanel implements PropertyChangeListener,
|
||||
IFileChooserAccessory {
|
||||
public class ProjectPreview extends JPanel implements PropertyChangeListener, IFileChooserAccessory {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -148,8 +147,7 @@ public class ProjectPreview extends JPanel implements PropertyChangeListener,
|
||||
presenter.draw(g2d, EnumSet.noneOf(DrawOption.class));
|
||||
|
||||
g2d.setColor(Color.black);
|
||||
g2d.drawRect(0, 0, d.width - (int) (1 / zoomRatio), d.height
|
||||
- (int) (1 / zoomRatio));
|
||||
g2d.drawRect(0, 0, d.width - (int) (1 / zoomRatio), d.height - (int) (1 / zoomRatio));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -37,10 +37,10 @@ public class HelpManager implements IPlugIn {
|
||||
|
||||
private AboutDialog getAboutDialog() {
|
||||
if (aboutDialog == null) {
|
||||
aboutDialog = DialogFactory.getInstance().createAboutDialog(
|
||||
"DIY Layout Creator 4", IconLoader.BlackBoard.getIcon(),
|
||||
plugInPort.getCurrentVersionNumber().toString(),
|
||||
"Bane Stojkovic", "diy-fever.com", "bancika@gmail.com", "");
|
||||
aboutDialog = DialogFactory.getInstance().createAboutDialog("DIY Layout Creator 4",
|
||||
IconLoader.BlackBoard.getIcon(),
|
||||
plugInPort.getCurrentVersionNumber().toString(), "Bane Stojkovic",
|
||||
"diy-fever.com", "bancika@gmail.com", "");
|
||||
}
|
||||
return aboutDialog;
|
||||
}
|
||||
|
||||
+5
-9
@@ -95,8 +95,7 @@ public class OnlineManager implements IPlugIn {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LoginDialog dialog = DialogFactory.getInstance()
|
||||
.createLoginDialog();
|
||||
LoginDialog dialog = DialogFactory.getInstance().createLoginDialog();
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -113,8 +112,7 @@ public class OnlineManager implements IPlugIn {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
NewUserDialog dialog = DialogFactory.getInstance()
|
||||
.createNewUserDialog();
|
||||
NewUserDialog dialog = DialogFactory.getInstance().createNewUserDialog();
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -131,8 +129,7 @@ public class OnlineManager implements IPlugIn {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
UploadDialog dialog = DialogFactory.getInstance()
|
||||
.createUploadDialog();
|
||||
UploadDialog dialog = DialogFactory.getInstance().createUploadDialog();
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -149,9 +146,8 @@ public class OnlineManager implements IPlugIn {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ProgressDialog dialog = DialogFactory.getInstance()
|
||||
.createProgressDialog("Test", new String[] {}, "Some text",
|
||||
false);
|
||||
ProgressDialog dialog = DialogFactory.getInstance().createProgressDialog("Test",
|
||||
new String[] {}, "Some text", false);
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-12
@@ -4,7 +4,6 @@ import org.apache.log4j.BasicConfigurator;
|
||||
|
||||
import com.diyfever.diylc.plugins.online.presenter.LibraryPresenter;
|
||||
|
||||
|
||||
public class Test {
|
||||
|
||||
/**
|
||||
@@ -13,17 +12,17 @@ public class Test {
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
BasicConfigurator.configure();
|
||||
LibraryPresenter pres = new LibraryPresenter();
|
||||
// pres.createUser("bancika", "pwd", "bancika@gmail.com");
|
||||
System.out.println(pres.fetchCategories());
|
||||
pres.login("bancika", "pwd");
|
||||
int id = pres.fetchMyProjectRows().get(0).getId();
|
||||
// InputStream stream = pres.downloadProjectContent(id);
|
||||
// byte[] buf = new byte[100];
|
||||
// int len = stream.read(buf);
|
||||
System.out.println(pres.downloadProjectContent(id));
|
||||
// System.out.println(pres.hashPassword("bancikabancikabancikabancikabancika"));
|
||||
pres.dispose();
|
||||
LibraryPresenter pres = new LibraryPresenter();
|
||||
// pres.createUser("bancika", "pwd", "bancika@gmail.com");
|
||||
System.out.println(pres.fetchCategories());
|
||||
pres.login("bancika", "pwd");
|
||||
int id = pres.fetchMyProjectRows().get(0).getId();
|
||||
// InputStream stream = pres.downloadProjectContent(id);
|
||||
// byte[] buf = new byte[100];
|
||||
// int len = stream.read(buf);
|
||||
System.out.println(pres.downloadProjectContent(id));
|
||||
// System.out.println(pres.hashPassword("bancikabancikabancikabancikabancika"));
|
||||
pres.dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-6
@@ -21,8 +21,7 @@ public class ProjectEntity implements Serializable {
|
||||
super();
|
||||
}
|
||||
|
||||
public ProjectEntity(int id, String name, String description, String owner,
|
||||
String category) {
|
||||
public ProjectEntity(int id, String name, String description, String owner, String category) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
@@ -88,10 +87,8 @@ public class ProjectEntity implements Serializable {
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result
|
||||
+ ((category == null) ? 0 : category.hashCode());
|
||||
result = prime * result
|
||||
+ ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((category == null) ? 0 : category.hashCode());
|
||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + id;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((owner == null) ? 0 : owner.hashCode());
|
||||
|
||||
+20
-28
@@ -53,19 +53,17 @@ public class LibraryPresenter {
|
||||
}
|
||||
}
|
||||
|
||||
public void createUser(String userName, String password, String email)
|
||||
throws SQLException, NotConnectedException, AlreadyExistsException {
|
||||
public void createUser(String userName, String password, String email) throws SQLException,
|
||||
NotConnectedException, AlreadyExistsException {
|
||||
LOG.info("Creating user: " + userName);
|
||||
if (dbManager.isConnected()) {
|
||||
ResultSet resultSet = dbManager.getResultSet(String.format(
|
||||
USER_SQL, userName));
|
||||
ResultSet resultSet = dbManager.getResultSet(String.format(USER_SQL, userName));
|
||||
if (resultSet.next()) {
|
||||
throw new AlreadyExistsException();
|
||||
}
|
||||
dbManager.updateDB(String.format(CREATE_USER_SQL, userName,
|
||||
hashPassword(password), email));
|
||||
resultSet = dbManager.getResultSet(String
|
||||
.format(USER_SQL, userName));
|
||||
dbManager.updateDB(String.format(CREATE_USER_SQL, userName, hashPassword(password),
|
||||
email));
|
||||
resultSet = dbManager.getResultSet(String.format(USER_SQL, userName));
|
||||
if (resultSet.next()) {
|
||||
LOG.info("Logged in as \"" + userName + "\"");
|
||||
currentUserId = resultSet.getInt("user_id");
|
||||
@@ -80,8 +78,7 @@ public class LibraryPresenter {
|
||||
NotConnectedException {
|
||||
LOG.info("Logging in as: " + userName);
|
||||
if (dbManager.isConnected()) {
|
||||
ResultSet resultSet = dbManager.getResultSet(String.format(
|
||||
USER_SQL, userName));
|
||||
ResultSet resultSet = dbManager.getResultSet(String.format(USER_SQL, userName));
|
||||
if (resultSet.next()) {
|
||||
String dbPassword = resultSet.getString("password");
|
||||
String hashPassword = hashPassword(password);
|
||||
@@ -99,15 +96,13 @@ public class LibraryPresenter {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, String> fetchCategories() throws SQLException,
|
||||
NotConnectedException {
|
||||
public Map<Integer, String> fetchCategories() throws SQLException, NotConnectedException {
|
||||
LOG.info("Fetching categories");
|
||||
if (dbManager.isConnected()) {
|
||||
Map<Integer, String> categories = new HashMap<Integer, String>();
|
||||
ResultSet resultSet = dbManager.getResultSet(CATEGORY_SQL);
|
||||
while (resultSet.next()) {
|
||||
categories.put(resultSet.getInt("category_id"), resultSet
|
||||
.getString("name"));
|
||||
categories.put(resultSet.getInt("category_id"), resultSet.getString("name"));
|
||||
}
|
||||
return categories;
|
||||
} else {
|
||||
@@ -116,19 +111,18 @@ public class LibraryPresenter {
|
||||
}
|
||||
}
|
||||
|
||||
public List<ProjectEntity> fetchMyProjectRows()
|
||||
throws NotLoggedInException, NotConnectedException, SQLException {
|
||||
public List<ProjectEntity> fetchMyProjectRows() throws NotLoggedInException,
|
||||
NotConnectedException, SQLException {
|
||||
if (dbManager.isConnected()) {
|
||||
if (isLoggedIn()) {
|
||||
Map<Integer, String> categories = fetchCategories();
|
||||
List<ProjectEntity> projects = new ArrayList<ProjectEntity>();
|
||||
ResultSet resultSet = dbManager.getResultSet(String.format(
|
||||
MY_PROJECTS_SQL, currentUserId));
|
||||
ResultSet resultSet = dbManager.getResultSet(String.format(MY_PROJECTS_SQL,
|
||||
currentUserId));
|
||||
while (resultSet.next()) {
|
||||
projects.add(new ProjectEntity(resultSet
|
||||
.getInt("project_id"), resultSet.getString("name"),
|
||||
resultSet.getString("description"), "", categories
|
||||
.get(resultSet.getInt("category_id"))));
|
||||
projects.add(new ProjectEntity(resultSet.getInt("project_id"), resultSet
|
||||
.getString("name"), resultSet.getString("description"), "", categories
|
||||
.get(resultSet.getInt("category_id"))));
|
||||
}
|
||||
return projects;
|
||||
} else {
|
||||
@@ -141,16 +135,14 @@ public class LibraryPresenter {
|
||||
}
|
||||
}
|
||||
|
||||
public String downloadProjectContent(int projectId)
|
||||
throws NotConnectedException, NotExistsException, SQLException {
|
||||
public String downloadProjectContent(int projectId) throws NotConnectedException,
|
||||
NotExistsException, SQLException {
|
||||
if (dbManager.isConnected()) {
|
||||
ResultSet resultSet = dbManager.getResultSet(String.format(
|
||||
PROJECT_SQL, projectId));
|
||||
ResultSet resultSet = dbManager.getResultSet(String.format(PROJECT_SQL, projectId));
|
||||
if (resultSet.next()) {
|
||||
return resultSet.getString("content");
|
||||
}
|
||||
throw new NotExistsException("Project with id = " + projectId
|
||||
+ " does not exist.");
|
||||
throw new NotExistsException("Project with id = " + projectId + " does not exist.");
|
||||
} else {
|
||||
LOG.error("Not connected");
|
||||
throw new NotConnectedException();
|
||||
|
||||
+29
-32
@@ -82,31 +82,29 @@ public class LoginDialog extends ButtonDialog {
|
||||
this.password = new String(getPasswordField().getPassword());
|
||||
|
||||
JButton okButton = getButton(OK);
|
||||
okButton.setEnabled((this.userName.length() > 0)
|
||||
&& (this.password.length() > 0));
|
||||
okButton.setEnabled((this.userName.length() > 0) && (this.password.length() > 0));
|
||||
}
|
||||
|
||||
private JTextField getUserNameField() {
|
||||
if (userNameField == null) {
|
||||
userNameField = new JTextField();
|
||||
userNameField.getDocument().addDocumentListener(
|
||||
new DocumentListener() {
|
||||
userNameField.getDocument().addDocumentListener(new DocumentListener() {
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
});
|
||||
}
|
||||
return userNameField;
|
||||
}
|
||||
@@ -114,24 +112,23 @@ public class LoginDialog extends ButtonDialog {
|
||||
private JPasswordField getPasswordField() {
|
||||
if (passwordField == null) {
|
||||
passwordField = new JPasswordField();
|
||||
passwordField.getDocument().addDocumentListener(
|
||||
new DocumentListener() {
|
||||
passwordField.getDocument().addDocumentListener(new DocumentListener() {
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
});
|
||||
}
|
||||
return passwordField;
|
||||
}
|
||||
|
||||
+59
-64
@@ -100,8 +100,7 @@ public class NewUserDialog extends ButtonDialog {
|
||||
private void refreshState() {
|
||||
this.userName = getUserNameField().getText();
|
||||
String password = new String(getPasswordField().getPassword());
|
||||
String confirmPassword = new String(getConfirmPasswordField()
|
||||
.getPassword());
|
||||
String confirmPassword = new String(getConfirmPasswordField().getPassword());
|
||||
if (password.equals(confirmPassword)) {
|
||||
this.password = password;
|
||||
} else {
|
||||
@@ -109,31 +108,30 @@ public class NewUserDialog extends ButtonDialog {
|
||||
}
|
||||
this.email = getEmailField().getText();
|
||||
JButton okButton = getButton(OK);
|
||||
okButton.setEnabled((this.userName.length() > 0)
|
||||
&& (this.password != null) && (this.password.length() > 0));
|
||||
okButton.setEnabled((this.userName.length() > 0) && (this.password != null)
|
||||
&& (this.password.length() > 0));
|
||||
}
|
||||
|
||||
private JTextField getUserNameField() {
|
||||
if (userNameField == null) {
|
||||
userNameField = new JTextField();
|
||||
userNameField.getDocument().addDocumentListener(
|
||||
new DocumentListener() {
|
||||
userNameField.getDocument().addDocumentListener(new DocumentListener() {
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
});
|
||||
}
|
||||
return userNameField;
|
||||
}
|
||||
@@ -141,24 +139,23 @@ public class NewUserDialog extends ButtonDialog {
|
||||
private JPasswordField getPasswordField() {
|
||||
if (passwordField == null) {
|
||||
passwordField = new JPasswordField();
|
||||
passwordField.getDocument().addDocumentListener(
|
||||
new DocumentListener() {
|
||||
passwordField.getDocument().addDocumentListener(new DocumentListener() {
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
});
|
||||
}
|
||||
return passwordField;
|
||||
}
|
||||
@@ -166,24 +163,23 @@ public class NewUserDialog extends ButtonDialog {
|
||||
private JPasswordField getConfirmPasswordField() {
|
||||
if (confirmPasswordField == null) {
|
||||
confirmPasswordField = new JPasswordField();
|
||||
confirmPasswordField.getDocument().addDocumentListener(
|
||||
new DocumentListener() {
|
||||
confirmPasswordField.getDocument().addDocumentListener(new DocumentListener() {
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
});
|
||||
}
|
||||
return confirmPasswordField;
|
||||
}
|
||||
@@ -191,24 +187,23 @@ public class NewUserDialog extends ButtonDialog {
|
||||
private JTextField getEmailField() {
|
||||
if (emailField == null) {
|
||||
emailField = new JTextField();
|
||||
emailField.getDocument().addDocumentListener(
|
||||
new DocumentListener() {
|
||||
emailField.getDocument().addDocumentListener(new DocumentListener() {
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
refreshState();
|
||||
}
|
||||
});
|
||||
}
|
||||
return emailField;
|
||||
}
|
||||
|
||||
+3
-6
@@ -34,9 +34,7 @@ public class UploadDialog extends ButtonDialog {
|
||||
+ "You can <b>not</b> use Online Library to advertise products or services.<br>"
|
||||
+ BULLET
|
||||
+ "Users that do not follow these terms may be banned from the server, with or without notice.<br>"
|
||||
+ BULLET
|
||||
+ "Administrator is not responsible for library contents.<br>"
|
||||
+ "</html>";
|
||||
+ BULLET + "Administrator is not responsible for library contents.<br>" + "</html>";
|
||||
|
||||
private JPanel mainPanel;
|
||||
private JLabel termsLabel;
|
||||
@@ -98,9 +96,8 @@ public class UploadDialog extends ButtonDialog {
|
||||
termsLabel = new JLabel();
|
||||
termsLabel.setOpaque(true);
|
||||
termsLabel.setBackground(UIManager.getColor("ToolTip.background"));
|
||||
termsLabel.setBorder(BorderFactory.createCompoundBorder(
|
||||
BorderFactory.createEtchedBorder(), BorderFactory
|
||||
.createEmptyBorder(2, 2, 2, 2)));
|
||||
termsLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory
|
||||
.createEtchedBorder(), BorderFactory.createEmptyBorder(2, 2, 2, 2)));
|
||||
termsLabel.setText(TERMS_HTML);
|
||||
}
|
||||
return termsLabel;
|
||||
|
||||
+5
-10
@@ -49,8 +49,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
|
||||
private JComboBox getZoomBox() {
|
||||
if (zoomBox == null) {
|
||||
zoomBox = new JComboBox(new Double[] { 0.25d, 0.5d, 0.75d, 1d,
|
||||
1.5d, 2d });
|
||||
zoomBox = new JComboBox(new Double[] { 0.25d, 0.5d, 0.75d, 1d, 1.5d, 2d });
|
||||
zoomBox.setSelectedItem(1d);
|
||||
zoomBox.setFocusable(false);
|
||||
zoomBox.setRenderer(new PercentageListCellRenderer());
|
||||
@@ -168,8 +167,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
|
||||
private void refreshStatusText() {
|
||||
if (componentSlot == null) {
|
||||
if ((componentsUnderCursor == null)
|
||||
|| (componentsUnderCursor.isEmpty())) {
|
||||
if ((componentsUnderCursor == null) || (componentsUnderCursor.isEmpty())) {
|
||||
getStatusLabel().setText("");
|
||||
} else {
|
||||
String formattedNames = "";
|
||||
@@ -178,17 +176,14 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
if (n > 1) {
|
||||
formattedNames += ", ";
|
||||
}
|
||||
formattedNames += ComponentProcessor.getInstance()
|
||||
.extractBomName(component)
|
||||
formattedNames += ComponentProcessor.getInstance().extractBomName(component)
|
||||
+ " (<b><font color=\"blue\">" + n++ + "</font></b>)";
|
||||
}
|
||||
getStatusLabel().setText(
|
||||
"<html>" + "Edit: " + formattedNames + "</html>");
|
||||
getStatusLabel().setText("<html>" + "Edit: " + formattedNames + "</html>");
|
||||
}
|
||||
} else {
|
||||
getStatusLabel().setText(
|
||||
"Click on the canvas to create a new "
|
||||
+ componentSlot.getName()
|
||||
"Click on the canvas to create a new " + componentSlot.getName()
|
||||
+ " or press Esc to cancel");
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -23,8 +23,7 @@ class ComponentButton extends JButton {
|
||||
private IPlugInPort plugInPort;
|
||||
private IComponentType componentType;
|
||||
|
||||
public ComponentButton(final IPlugInPort plugInPort,
|
||||
final IComponentType componentType) {
|
||||
public ComponentButton(final IPlugInPort plugInPort, final IComponentType componentType) {
|
||||
super(componentType.getIcon());
|
||||
this.plugInPort = plugInPort;
|
||||
this.componentType = componentType;
|
||||
@@ -62,7 +61,7 @@ class ComponentButton extends JButton {
|
||||
DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
|
||||
this,
|
||||
DnDConstants.ACTION_MOVE,
|
||||
new ToolboxGestureListener(plugInPort, componentType
|
||||
.getComponentInstanceClass().getName()));
|
||||
new ToolboxGestureListener(plugInPort, componentType.getComponentInstanceClass()
|
||||
.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
+3
-6
@@ -19,18 +19,15 @@ class ComponentTabbedPane extends JTabbedPane {
|
||||
public ComponentTabbedPane(IPlugInPort plugInPort) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
Map<String, List<IComponentType>> componentTypes = plugInPort
|
||||
.getComponentTypes();
|
||||
for (Map.Entry<String, List<IComponentType>> entry : componentTypes
|
||||
.entrySet()) {
|
||||
Map<String, List<IComponentType>> componentTypes = plugInPort.getComponentTypes();
|
||||
for (Map.Entry<String, List<IComponentType>> entry : componentTypes.entrySet()) {
|
||||
addTab(entry.getKey(), createComponentPanel(entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
private Container createComponentPanel(List<IComponentType> componentTypes) {
|
||||
Container componentPanel = new Container();
|
||||
componentPanel
|
||||
.setLayout(new BoxLayout(componentPanel, BoxLayout.X_AXIS));
|
||||
componentPanel.setLayout(new BoxLayout(componentPanel, BoxLayout.X_AXIS));
|
||||
for (IComponentType componentType : componentTypes) {
|
||||
JButton button = new ComponentButton(plugInPort, componentType);
|
||||
componentPanel.add(button);
|
||||
|
||||
+1
-2
@@ -14,8 +14,7 @@ public class ToolBox implements IPlugIn {
|
||||
@Override
|
||||
public void connect(IPlugInPort plugInPort) {
|
||||
try {
|
||||
plugInPort.injectGUIComponent(new ComponentTabbedPane(plugInPort),
|
||||
SwingConstants.TOP);
|
||||
plugInPort.injectGUIComponent(new ComponentTabbedPane(plugInPort), SwingConstants.TOP);
|
||||
} catch (BadPositionException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
||||
+2
-3
@@ -26,8 +26,7 @@ class ToolboxGestureListener implements DragGestureListener {
|
||||
@Override
|
||||
public void dragGestureRecognized(DragGestureEvent dge) {
|
||||
presenter.dragStarted(dge.getDragOrigin());
|
||||
dge.startDrag(Cursor.getDefaultCursor(),
|
||||
new StringSelection(className), new ToolboxSourceListener(
|
||||
presenter));
|
||||
dge.startDrag(Cursor.getDefaultCursor(), new StringSelection(className),
|
||||
new ToolboxSourceListener(presenter));
|
||||
}
|
||||
}
|
||||
|
||||
+17
-29
@@ -20,8 +20,7 @@ import com.rits.cloning.Cloner;
|
||||
|
||||
public class ComponentProcessor {
|
||||
|
||||
private static final Logger LOG = Logger
|
||||
.getLogger(ComponentProcessor.class);
|
||||
private static final Logger LOG = Logger.getLogger(ComponentProcessor.class);
|
||||
|
||||
private static ComponentProcessor instance;
|
||||
|
||||
@@ -44,8 +43,7 @@ public class ComponentProcessor {
|
||||
this.controlPointCache = new HashMap<Class<?>, List<ControlPointWrapper>>();
|
||||
}
|
||||
|
||||
public List<PropertyWrapper> extractProperties(
|
||||
Class<? extends IComponentInstance> clazz) {
|
||||
public List<PropertyWrapper> extractProperties(Class<? extends IComponentInstance> clazz) {
|
||||
if (propertyCache.containsKey(clazz)) {
|
||||
return cloner.deepClone(propertyCache.get(clazz));
|
||||
}
|
||||
@@ -53,12 +51,10 @@ public class ComponentProcessor {
|
||||
for (Method method : clazz.getMethods()) {
|
||||
if (method.getName().startsWith("get")) {
|
||||
try {
|
||||
Method setter = clazz.getMethod("set"
|
||||
+ method.getName().substring(3), method
|
||||
Method setter = clazz.getMethod("set" + method.getName().substring(3), method
|
||||
.getReturnType());
|
||||
if (method.isAnnotationPresent(EditableProperty.class)) {
|
||||
EditableProperty annotation = method
|
||||
.getAnnotation(EditableProperty.class);
|
||||
EditableProperty annotation = method.getAnnotation(EditableProperty.class);
|
||||
String name;
|
||||
if (annotation.name().equals("")) {
|
||||
name = method.getName().substring(3);
|
||||
@@ -66,13 +62,12 @@ public class ComponentProcessor {
|
||||
name = annotation.name();
|
||||
}
|
||||
PropertyWrapper property = new PropertyWrapper(name,
|
||||
method.getReturnType(), method, setter,
|
||||
annotation.defaultable());
|
||||
method.getReturnType(), method, setter, annotation.defaultable());
|
||||
properties.add(property);
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
LOG.debug("No matching setter found for \""
|
||||
+ method.getName() + "\". Skipping...");
|
||||
LOG.debug("No matching setter found for \"" + method.getName()
|
||||
+ "\". Skipping...");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,8 +76,7 @@ public class ComponentProcessor {
|
||||
return cloner.deepClone(properties);
|
||||
}
|
||||
|
||||
public List<ControlPointWrapper> extractControlPoints(
|
||||
Class<? extends IComponentInstance> clazz) {
|
||||
public List<ControlPointWrapper> extractControlPoints(Class<? extends IComponentInstance> clazz) {
|
||||
if (controlPointCache.containsKey(clazz)) {
|
||||
return cloner.deepClone(controlPointCache.get(clazz));
|
||||
}
|
||||
@@ -90,27 +84,22 @@ public class ComponentProcessor {
|
||||
for (Method method : clazz.getMethods()) {
|
||||
if (method.getName().startsWith("get")) {
|
||||
try {
|
||||
Method setter = clazz.getMethod("set"
|
||||
+ method.getName().substring(3), method
|
||||
Method setter = clazz.getMethod("set" + method.getName().substring(3), method
|
||||
.getReturnType());
|
||||
if (method.isAnnotationPresent(ControlPoint.class)) {
|
||||
if (method.getReturnType().equals(Point.class)) {
|
||||
ControlPoint annotation = method
|
||||
.getAnnotation(ControlPoint.class);
|
||||
ControlPointWrapper controlPoint = new ControlPointWrapper(
|
||||
method.getName().substring(3), method,
|
||||
setter, annotation.editable(), annotation
|
||||
.sticky(), annotation
|
||||
.visibilityPolicy());
|
||||
ControlPoint annotation = method.getAnnotation(ControlPoint.class);
|
||||
ControlPointWrapper controlPoint = new ControlPointWrapper(method
|
||||
.getName().substring(3), method, setter, annotation.editable(),
|
||||
annotation.sticky(), annotation.visibilityPolicy());
|
||||
controlPoints.add(controlPoint);
|
||||
} else {
|
||||
LOG
|
||||
.debug("Control point return type must be java.awt.Point.");
|
||||
LOG.debug("Control point return type must be java.awt.Point.");
|
||||
}
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
LOG.debug("No matching setter found for \""
|
||||
+ method.getName() + "\". Skipping...");
|
||||
LOG.debug("No matching setter found for \"" + method.getName()
|
||||
+ "\". Skipping...");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,8 +127,7 @@ public class ComponentProcessor {
|
||||
}
|
||||
for (int i = 1; i < selectedComponents.size(); i++) {
|
||||
IComponentInstance component = selectedComponents.get(i);
|
||||
List<PropertyWrapper> newProperties = extractProperties(component
|
||||
.getClass());
|
||||
List<PropertyWrapper> newProperties = extractProperties(component.getClass());
|
||||
for (PropertyWrapper property : newProperties) {
|
||||
try {
|
||||
property.readFrom(component);
|
||||
|
||||
+31
-44
@@ -180,8 +180,7 @@ class G2DWrapper extends Graphics2D {
|
||||
*{@inheritDoc}
|
||||
**/
|
||||
@Override
|
||||
public void drawString(AttributedCharacterIterator iterator, float x,
|
||||
float y) {
|
||||
public void drawString(AttributedCharacterIterator iterator, float x, float y) {
|
||||
canvasGraphics.drawString(iterator, x, y);
|
||||
// FIXME: process map
|
||||
}
|
||||
@@ -441,8 +440,7 @@ class G2DWrapper extends Graphics2D {
|
||||
*{@inheritDoc}
|
||||
**/
|
||||
@Override
|
||||
public void drawArc(int x, int y, int width, int height, int startAngle,
|
||||
int arcAngle) {
|
||||
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
|
||||
canvasGraphics.drawArc(x, y, width, height, startAngle, arcAngle);
|
||||
}
|
||||
|
||||
@@ -459,8 +457,7 @@ class G2DWrapper extends Graphics2D {
|
||||
*{@inheritDoc}
|
||||
**/
|
||||
@Override
|
||||
public boolean drawImage(Image img, int x, int y, Color bgcolor,
|
||||
ImageObserver observer) {
|
||||
public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) {
|
||||
// FIXME: map
|
||||
return canvasGraphics.drawImage(img, x, y, bgcolor, observer);
|
||||
}
|
||||
@@ -469,8 +466,7 @@ class G2DWrapper extends Graphics2D {
|
||||
*{@inheritDoc}
|
||||
**/
|
||||
@Override
|
||||
public boolean drawImage(Image img, int x, int y, int width, int height,
|
||||
ImageObserver observer) {
|
||||
public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) {
|
||||
// FIXME: map
|
||||
return canvasGraphics.drawImage(img, x, y, width, height, observer);
|
||||
}
|
||||
@@ -479,34 +475,30 @@ class G2DWrapper extends Graphics2D {
|
||||
*{@inheritDoc}
|
||||
**/
|
||||
@Override
|
||||
public boolean drawImage(Image img, int x, int y, int width, int height,
|
||||
Color bgcolor, ImageObserver observer) {
|
||||
// FIXME: map
|
||||
return canvasGraphics.drawImage(img, x, y, width, height, bgcolor,
|
||||
observer);
|
||||
}
|
||||
|
||||
/**
|
||||
*{@inheritDoc}
|
||||
**/
|
||||
@Override
|
||||
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2,
|
||||
int sx1, int sy1, int sx2, int sy2, ImageObserver observer) {
|
||||
// FIXME: map
|
||||
return canvasGraphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2,
|
||||
sy2, observer);
|
||||
}
|
||||
|
||||
/**
|
||||
*{@inheritDoc}
|
||||
**/
|
||||
@Override
|
||||
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2,
|
||||
int sx1, int sy1, int sx2, int sy2, Color bgcolor,
|
||||
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor,
|
||||
ImageObserver observer) {
|
||||
// FIXME: map
|
||||
return drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor,
|
||||
observer);
|
||||
return canvasGraphics.drawImage(img, x, y, width, height, bgcolor, observer);
|
||||
}
|
||||
|
||||
/**
|
||||
*{@inheritDoc}
|
||||
**/
|
||||
@Override
|
||||
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
|
||||
int sx2, int sy2, ImageObserver observer) {
|
||||
// FIXME: map
|
||||
return canvasGraphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer);
|
||||
}
|
||||
|
||||
/**
|
||||
*{@inheritDoc}
|
||||
**/
|
||||
@Override
|
||||
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
|
||||
int sx2, int sy2, Color bgcolor, ImageObserver observer) {
|
||||
// FIXME: map
|
||||
return drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -545,8 +537,7 @@ class G2DWrapper extends Graphics2D {
|
||||
*{@inheritDoc}
|
||||
**/
|
||||
@Override
|
||||
public void drawRoundRect(int x, int y, int width, int height,
|
||||
int arcWidth, int arcHeight) {
|
||||
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
|
||||
canvasGraphics.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
|
||||
}
|
||||
|
||||
@@ -554,11 +545,9 @@ class G2DWrapper extends Graphics2D {
|
||||
*{@inheritDoc}
|
||||
**/
|
||||
@Override
|
||||
public void fillArc(int x, int y, int width, int height, int startAngle,
|
||||
int arcAngle) {
|
||||
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
|
||||
canvasGraphics.fillArc(x, y, width, height, startAngle, arcAngle);
|
||||
appendShape(new Arc2D.Double(x, y, width, height, startAngle, arcAngle,
|
||||
Arc2D.PIE));
|
||||
appendShape(new Arc2D.Double(x, y, width, height, startAngle, arcAngle, Arc2D.PIE));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -592,11 +581,9 @@ class G2DWrapper extends Graphics2D {
|
||||
*{@inheritDoc}
|
||||
**/
|
||||
@Override
|
||||
public void fillRoundRect(int x, int y, int width, int height,
|
||||
int arcWidth, int arcHeight) {
|
||||
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
|
||||
canvasGraphics.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
|
||||
appendShape(new RoundRectangle2D.Double(x, y, width, height, arcWidth,
|
||||
arcHeight));
|
||||
appendShape(new RoundRectangle2D.Double(x, y, width, height, arcWidth, arcHeight));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+71
-111
@@ -55,8 +55,7 @@ public class Presenter implements IPlugInPort {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(Presenter.class);
|
||||
|
||||
private static final VersionNumber CURRENT_VERSION = new VersionNumber(0,
|
||||
0, 0);
|
||||
private static final VersionNumber CURRENT_VERSION = new VersionNumber(0, 0, 0);
|
||||
private static final String DEFAULTS_KEY = "defaults";
|
||||
private static final int CONTROL_POINT_SENSITIVITY = 4;
|
||||
|
||||
@@ -104,8 +103,7 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
|
||||
public void installPlugin(IPlugIn plugIn) {
|
||||
LOG.debug(String.format("installPlugin(%s)", plugIn.getClass()
|
||||
.getSimpleName()));
|
||||
LOG.debug(String.format("installPlugin(%s)", plugIn.getClass().getSimpleName()));
|
||||
plugIns.add(plugIn);
|
||||
plugIn.connect(this);
|
||||
messageDispatcher.registerListener(plugIn);
|
||||
@@ -135,10 +133,8 @@ public class Presenter implements IPlugInPort {
|
||||
@Override
|
||||
public Cursor getCursorAt(Point point) {
|
||||
// Scale point to remove zoom factor.
|
||||
Point2D scaledPoint = new Point2D.Double(point.getX() / zoomLevel,
|
||||
point.getY() / zoomLevel);
|
||||
for (Map.Entry<IComponentInstance, Area> entry : componentAreaMap
|
||||
.entrySet()) {
|
||||
Point2D scaledPoint = new Point2D.Double(point.getX() / zoomLevel, point.getY() / zoomLevel);
|
||||
for (Map.Entry<IComponentInstance, Area> entry : componentAreaMap.entrySet()) {
|
||||
if (entry.getValue().contains(scaledPoint)) {
|
||||
return Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
|
||||
}
|
||||
@@ -167,8 +163,7 @@ public class Presenter implements IPlugInPort {
|
||||
LOG.info("Loading project: " + project.getTitle());
|
||||
this.currentProject = project;
|
||||
selectedComponents.clear();
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_LOADED, project,
|
||||
freshStart);
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_LOADED, project, freshStart);
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
|
||||
@@ -177,20 +172,17 @@ public class Presenter implements IPlugInPort {
|
||||
if (componentTypes == null) {
|
||||
LOG.info("Loading component types.");
|
||||
componentTypes = new HashMap<String, List<IComponentType>>();
|
||||
List<Class<?>> componentTypeClasses = JarScanner.getInstance()
|
||||
.scanFolder("library/", IComponentType.class);
|
||||
List<Class<?>> componentTypeClasses = JarScanner.getInstance().scanFolder("library/",
|
||||
IComponentType.class);
|
||||
for (Class<?> clazz : componentTypeClasses) {
|
||||
try {
|
||||
IComponentType componentType = (IComponentType) clazz
|
||||
.newInstance();
|
||||
IComponentType componentType = (IComponentType) clazz.newInstance();
|
||||
List<IComponentType> nestedList;
|
||||
if (componentTypes.containsKey(componentType.getCategory())) {
|
||||
nestedList = componentTypes.get(componentType
|
||||
.getCategory());
|
||||
nestedList = componentTypes.get(componentType.getCategory());
|
||||
} else {
|
||||
nestedList = new ArrayList<IComponentType>();
|
||||
componentTypes.put(componentType.getCategory(),
|
||||
nestedList);
|
||||
componentTypes.put(componentType.getCategory(), nestedList);
|
||||
}
|
||||
nestedList.add(componentType);
|
||||
} catch (InstantiationException e) {
|
||||
@@ -211,8 +203,9 @@ public class Presenter implements IPlugInPort {
|
||||
G2DWrapper g2dWrapper = new G2DWrapper(g2d);
|
||||
|
||||
if (drawOptions.contains(DrawOption.ANTIALIASING)) {
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d
|
||||
.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
}
|
||||
|
||||
AffineTransform initialTx = g2d.getTransform();
|
||||
@@ -236,15 +229,13 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
}
|
||||
|
||||
if ((drawOptions.contains(DrawOption.ZOOM))
|
||||
&& (Math.abs(1.0 - zoomLevel) > 1e-4)) {
|
||||
if ((drawOptions.contains(DrawOption.ZOOM)) && (Math.abs(1.0 - zoomLevel) > 1e-4)) {
|
||||
g2dWrapper.scale(zoomLevel, zoomLevel);
|
||||
}
|
||||
|
||||
g2dWrapper.resetTx();
|
||||
|
||||
List<IComponentInstance> components = getCurrentProject()
|
||||
.getComponents();
|
||||
List<IComponentInstance> components = getCurrentProject().getComponents();
|
||||
componentAreaMap.clear();
|
||||
if (components != null) {
|
||||
for (IComponentInstance component : components) {
|
||||
@@ -253,14 +244,12 @@ public class Presenter implements IPlugInPort {
|
||||
.contains(DrawOption.SELECTION)) ? ComponentState.SELECTED
|
||||
: ComponentState.NORMAL;
|
||||
component.draw(g2dWrapper, state);
|
||||
componentAreaMap.put(component, g2dWrapper
|
||||
.finishedDrawingComponent());
|
||||
componentAreaMap.put(component, g2dWrapper.finishedDrawingComponent());
|
||||
|
||||
// Draw control points
|
||||
if (drawOptions.contains(DrawOption.CONTROL_POINTS)) {
|
||||
List<ControlPointWrapper> controlPoints = ComponentProcessor
|
||||
.getInstance().extractControlPoints(
|
||||
component.getClass());
|
||||
List<ControlPointWrapper> controlPoints = ComponentProcessor.getInstance()
|
||||
.extractControlPoints(component.getClass());
|
||||
for (ControlPointWrapper controlPoint : controlPoints) {
|
||||
try {
|
||||
controlPoint.readFrom(component);
|
||||
@@ -273,9 +262,8 @@ public class Presenter implements IPlugInPort {
|
||||
// .getValue().y - 2, 5, 5);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG
|
||||
.error("Could not obtain control points for component of type "
|
||||
+ component.getClass().getName());
|
||||
LOG.error("Could not obtain control points for component of type "
|
||||
+ component.getClass().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -285,8 +273,7 @@ public class Presenter implements IPlugInPort {
|
||||
g2d.setTransform(initialTx);
|
||||
|
||||
// At the end draw selection rectangle.
|
||||
if (drawOptions.contains(DrawOption.SELECTION)
|
||||
&& (selectionRect != null)) {
|
||||
if (drawOptions.contains(DrawOption.SELECTION) && (selectionRect != null)) {
|
||||
g2d.setColor(Color.white);
|
||||
g2d.drawRect(selectionRect.x, selectionRect.y, selectionRect.width,
|
||||
selectionRect.height);
|
||||
@@ -298,8 +285,7 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectGUIComponent(JComponent component, int position)
|
||||
throws BadPositionException {
|
||||
public void injectGUIComponent(JComponent component, int position) throws BadPositionException {
|
||||
view.addComponent(component, position);
|
||||
}
|
||||
|
||||
@@ -321,8 +307,7 @@ public class Presenter implements IPlugInPort {
|
||||
*/
|
||||
private List<IComponentInstance> findComponentsAt(Point point) {
|
||||
List<IComponentInstance> components = new ArrayList<IComponentInstance>();
|
||||
for (Map.Entry<IComponentInstance, Area> entry : componentAreaMap
|
||||
.entrySet()) {
|
||||
for (Map.Entry<IComponentInstance, Area> entry : componentAreaMap.entrySet()) {
|
||||
if (entry.getValue().contains(point)) {
|
||||
components.add(entry.getKey());
|
||||
}
|
||||
@@ -331,15 +316,13 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(Point point, boolean ctrlDown, boolean shiftDown,
|
||||
boolean altDown) {
|
||||
LOG.debug(String.format("mouseClicked(%s, %s, %s, %s)", point,
|
||||
ctrlDown, shiftDown, altDown));
|
||||
public void mouseClicked(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown) {
|
||||
LOG.debug(String
|
||||
.format("mouseClicked(%s, %s, %s, %s)", point, ctrlDown, shiftDown, altDown));
|
||||
Point scaledPoint = scalePoint(point);
|
||||
if (componentSlot != null) {
|
||||
try {
|
||||
instantiateComponent(componentSlot.getComponentInstanceClass(),
|
||||
scaledPoint);
|
||||
instantiateComponent(componentSlot.getComponentInstanceClass(), scaledPoint);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error instatiating component of type: "
|
||||
+ componentSlot.getComponentInstanceClass().getName());
|
||||
@@ -366,8 +349,7 @@ public class Presenter implements IPlugInPort {
|
||||
selectedComponents.add(component);
|
||||
}
|
||||
}
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
||||
selectedComponents);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
}
|
||||
@@ -377,8 +359,8 @@ public class Presenter implements IPlugInPort {
|
||||
List<IComponentInstance> components = new ArrayList<IComponentInstance>();
|
||||
Point scaledPoint = scalePoint(point);
|
||||
for (IComponentInstance component : currentProject.getComponents()) {
|
||||
List<ControlPointWrapper> currentPoints = ComponentProcessor
|
||||
.getInstance().extractControlPoints(component.getClass());
|
||||
List<ControlPointWrapper> currentPoints = ComponentProcessor.getInstance()
|
||||
.extractControlPoints(component.getClass());
|
||||
for (ControlPointWrapper controlPoint : currentPoints) {
|
||||
if (shouldShowControlPoint(controlPoint, component)) {
|
||||
try {
|
||||
@@ -388,17 +370,15 @@ public class Presenter implements IPlugInPort {
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG
|
||||
.warn("Error reading control point for component of type: "
|
||||
+ component.getClass().getName());
|
||||
LOG.warn("Error reading control point for component of type: "
|
||||
+ component.getClass().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!components.equals(componentsUnderCursor)) {
|
||||
componentsUnderCursor = components;
|
||||
messageDispatcher.dispatchMessage(
|
||||
EventType.AVAILABLE_CTRL_POINTS_CHANGED, components);
|
||||
messageDispatcher.dispatchMessage(EventType.AVAILABLE_CTRL_POINTS_CHANGED, components);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,16 +406,14 @@ public class Presenter implements IPlugInPort {
|
||||
List<IComponentInstance> components = findComponentsAt(scaledPoint);
|
||||
if (components.isEmpty()) {
|
||||
selectedComponents.clear();
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
||||
selectedComponents);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
} else {
|
||||
IComponentInstance component = components.get(0);
|
||||
if (!selectedComponents.contains(component)) {
|
||||
selectedComponents.clear();
|
||||
selectedComponents.add(component);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
||||
selectedComponents);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
}
|
||||
@@ -445,8 +423,7 @@ public class Presenter implements IPlugInPort {
|
||||
public boolean dragOver(Point point) {
|
||||
if (selectedComponents.isEmpty()) {
|
||||
this.selectionRect = Utils.createRectangle(point, dragStartPoint);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_RECT_CHANGED,
|
||||
selectionRect);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_RECT_CHANGED, selectionRect);
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
return true;
|
||||
@@ -462,23 +439,20 @@ public class Presenter implements IPlugInPort {
|
||||
// If there's no selection finalize selectionRect and see which
|
||||
// components intersect with it.
|
||||
if (point != null) {
|
||||
this.selectionRect = Utils.createRectangle(point,
|
||||
dragStartPoint);
|
||||
this.selectionRect = Utils.createRectangle(point, dragStartPoint);
|
||||
}
|
||||
selectedComponents.clear();
|
||||
for (IComponentInstance component : currentProject.getComponents()) {
|
||||
Area area = componentAreaMap.get(component);
|
||||
if ((area != null)
|
||||
&& area.intersects(selectionRect.x / zoomLevel,
|
||||
selectionRect.y / zoomLevel,
|
||||
selectionRect.width / zoomLevel,
|
||||
selectionRect.y / zoomLevel, selectionRect.width / zoomLevel,
|
||||
selectionRect.height / zoomLevel)) {
|
||||
selectedComponents.add(component);
|
||||
}
|
||||
}
|
||||
selectionRect = null;
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
||||
selectedComponents);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
||||
} else {
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
|
||||
@@ -486,9 +460,8 @@ public class Presenter implements IPlugInPort {
|
||||
int dx = (int) ((point.x - dragStartPoint.x) / zoomLevel);
|
||||
int dy = (int) ((point.y - dragStartPoint.y) / zoomLevel);
|
||||
for (IComponentInstance component : selectedComponents) {
|
||||
List<ControlPointWrapper> controlPoints = ComponentProcessor
|
||||
.getInstance().extractControlPoints(
|
||||
component.getClass());
|
||||
List<ControlPointWrapper> controlPoints = ComponentProcessor.getInstance()
|
||||
.extractControlPoints(component.getClass());
|
||||
for (ControlPointWrapper controlPoint : controlPoints) {
|
||||
try {
|
||||
controlPoint.readFrom(component);
|
||||
@@ -497,14 +470,13 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
controlPoint.writeTo(component);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not translate control points: "
|
||||
+ e.getMessage());
|
||||
LOG.error("Could not translate control points: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!oldProject.equals(currentProject)) {
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED,
|
||||
oldProject, cloner.deepClone(currentProject), "Move");
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, cloner
|
||||
.deepClone(currentProject), "Move");
|
||||
}
|
||||
}
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
@@ -512,13 +484,12 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addComponents(List<IComponentInstance> components,
|
||||
Point preferredPoint) {
|
||||
public void addComponents(List<IComponentInstance> components, Point preferredPoint) {
|
||||
LOG.debug(String.format("addComponents(%s)", components));
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
currentProject.getComponents().addAll(components);
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED,
|
||||
oldProject, cloner.deepClone(currentProject), "Add");
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, cloner
|
||||
.deepClone(currentProject), "Add");
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
|
||||
@@ -558,27 +529,23 @@ public class Presenter implements IPlugInPort {
|
||||
// componentClass.getName() + ":" + propertyName);
|
||||
// }
|
||||
public void setDefaultPropertyValue(String propertyName, Object value) {
|
||||
LOG.debug(String.format("setDefaultPropertyValue(%s, %s)",
|
||||
propertyName, value));
|
||||
Map<String, Object> defaultMap = (Map<String, Object>) ConfigurationManager
|
||||
.getInstance().getConfigurationItem(DEFAULTS_KEY);
|
||||
LOG.debug(String.format("setDefaultPropertyValue(%s, %s)", propertyName, value));
|
||||
Map<String, Object> defaultMap = (Map<String, Object>) ConfigurationManager.getInstance()
|
||||
.getConfigurationItem(DEFAULTS_KEY);
|
||||
if (defaultMap == null) {
|
||||
defaultMap = new HashMap<String, Object>();
|
||||
ConfigurationManager.getInstance().setConfigurationItem(
|
||||
DEFAULTS_KEY, defaultMap);
|
||||
ConfigurationManager.getInstance().setConfigurationItem(DEFAULTS_KEY, defaultMap);
|
||||
}
|
||||
for (IComponentInstance component : selectedComponents) {
|
||||
String className = component.getClass().getName();
|
||||
LOG.debug("Default property value set for " + className + ":"
|
||||
+ propertyName);
|
||||
LOG.debug("Default property value set for " + className + ":" + propertyName);
|
||||
defaultMap.put(className + ":" + propertyName, value);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void instantiateComponent(
|
||||
Class<? extends IComponentInstance> componentClass, Point point)
|
||||
throws Exception {
|
||||
private void instantiateComponent(Class<? extends IComponentInstance> componentClass,
|
||||
Point point) throws Exception {
|
||||
LOG.info("Instatiating component of type: " + componentClass.getName());
|
||||
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
@@ -589,8 +556,8 @@ public class Presenter implements IPlugInPort {
|
||||
currentProject.getComponents().add(component);
|
||||
|
||||
// Extract control points.
|
||||
List<ControlPointWrapper> controlPoints = ComponentProcessor
|
||||
.getInstance().extractControlPoints(componentClass);
|
||||
List<ControlPointWrapper> controlPoints = ComponentProcessor.getInstance()
|
||||
.extractControlPoints(componentClass);
|
||||
// Translate them to the desired location.
|
||||
if (point != null) {
|
||||
for (ControlPointWrapper controlPoint : controlPoints) {
|
||||
@@ -601,16 +568,15 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
|
||||
// Extract properties.
|
||||
List<PropertyWrapper> properties = ComponentProcessor.getInstance()
|
||||
.extractProperties(componentClass);
|
||||
List<PropertyWrapper> properties = ComponentProcessor.getInstance().extractProperties(
|
||||
componentClass);
|
||||
// Override with default values if available.
|
||||
for (PropertyWrapper property : properties) {
|
||||
Object defaultValue = null;
|
||||
Map<String, Object> defaultMap = (Map<String, Object>) ConfigurationManager
|
||||
.getInstance().getConfigurationItem(DEFAULTS_KEY);
|
||||
if (defaultMap != null) {
|
||||
defaultValue = defaultMap.get(componentClass.getName() + ":"
|
||||
+ property.getName());
|
||||
defaultValue = defaultMap.get(componentClass.getName() + ":" + property.getName());
|
||||
}
|
||||
if (defaultValue != null) {
|
||||
property.setValue(cloner.deepClone(defaultValue));
|
||||
@@ -620,21 +586,19 @@ public class Presenter implements IPlugInPort {
|
||||
|
||||
// Notify the listeners.
|
||||
if (!oldProject.equals(currentProject)) {
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED,
|
||||
oldProject, cloner.deepClone(currentProject), "Create");
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, cloner
|
||||
.deepClone(currentProject), "Create");
|
||||
}
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PropertyWrapper> getMutualSelectionProperties() {
|
||||
return ComponentProcessor.getInstance().getMutualSelectionProperties(
|
||||
selectedComponents);
|
||||
return ComponentProcessor.getInstance().getMutualSelectionProperties(selectedComponents);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyPropertiesToSelection(List<PropertyWrapper> properties)
|
||||
throws Exception {
|
||||
public void applyPropertiesToSelection(List<PropertyWrapper> properties) throws Exception {
|
||||
LOG.debug(String.format("applyPropertiesToSelection(%s)", properties));
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
try {
|
||||
@@ -646,8 +610,8 @@ public class Presenter implements IPlugInPort {
|
||||
} finally {
|
||||
// Notify the listeners.
|
||||
if (!oldProject.equals(currentProject)) {
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED,
|
||||
oldProject, cloner.deepClone(currentProject), "Edit");
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, cloner
|
||||
.deepClone(currentProject), "Edit");
|
||||
}
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
@@ -655,26 +619,22 @@ public class Presenter implements IPlugInPort {
|
||||
|
||||
@Override
|
||||
public void setNewComponentSlot(IComponentType componentType) {
|
||||
LOG.debug(String.format("setNewComponentSlot(%s)",
|
||||
componentType == null ? null : componentType.getName()));
|
||||
LOG.debug(String.format("setNewComponentSlot(%s)", componentType == null ? null
|
||||
: componentType.getName()));
|
||||
this.componentSlot = componentType;
|
||||
selectedComponents.clear();
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED);
|
||||
messageDispatcher
|
||||
.dispatchMessage(EventType.SLOT_CHANGED, componentSlot);
|
||||
messageDispatcher.dispatchMessage(EventType.SLOT_CHANGED, componentSlot);
|
||||
}
|
||||
|
||||
private Point scalePoint(Point point) {
|
||||
return new Point((int) (point.x / zoomLevel),
|
||||
(int) (point.y / zoomLevel));
|
||||
return new Point((int) (point.x / zoomLevel), (int) (point.y / zoomLevel));
|
||||
}
|
||||
|
||||
private boolean shouldShowControlPoint(ControlPointWrapper controlPoint,
|
||||
IComponentInstance component) {
|
||||
return controlPoint.getVisibilityPolicy().equals(
|
||||
VisibilityPolicy.ALWAYS)
|
||||
|| ((controlPoint.getVisibilityPolicy()
|
||||
.equals(VisibilityPolicy.WHEN_SELECTED)) && (getSelectedComponents()
|
||||
return controlPoint.getVisibilityPolicy().equals(VisibilityPolicy.ALWAYS)
|
||||
|| ((controlPoint.getVisibilityPolicy().equals(VisibilityPolicy.WHEN_SELECTED)) && (getSelectedComponents()
|
||||
.contains(component)));
|
||||
}
|
||||
}
|
||||
|
||||
+3
-5
@@ -7,12 +7,10 @@ import java.awt.Toolkit;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final float GRID = Toolkit.getDefaultToolkit()
|
||||
.getScreenResolution() / 10f;
|
||||
public static final float GRID = Toolkit.getDefaultToolkit().getScreenResolution() / 10f;
|
||||
|
||||
public static final Color GRID_COLOR = new Color(240, 240, 240);
|
||||
|
||||
public static final Stroke dashedStroke = new BasicStroke(1.0f,
|
||||
BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 2.0f,
|
||||
new float[] { 2.0f }, 0.0f);
|
||||
public static final Stroke dashedStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT,
|
||||
BasicStroke.JOIN_MITER, 2.0f, new float[] { 2.0f }, 0.0f);
|
||||
}
|
||||
|
||||
+578
-546
File diff suppressed because it is too large
Load Diff
+17
-24
@@ -57,10 +57,10 @@ public class GhostedDragImage extends AbstractComponentDecorator {
|
||||
* @param imageOffset
|
||||
* offset of the image from the cursor
|
||||
*/
|
||||
public GhostedDragImage(JComponent dragSource, Point screenLocation,
|
||||
Icon icon, Point imageOffset) {
|
||||
this(dragSource, dragSource.getRootPane().getLayeredPane(),
|
||||
screenLocation, icon, imageOffset, true);
|
||||
public GhostedDragImage(JComponent dragSource, Point screenLocation, Icon icon,
|
||||
Point imageOffset) {
|
||||
this(dragSource, dragSource.getRootPane().getLayeredPane(), screenLocation, icon,
|
||||
imageOffset, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,29 +80,26 @@ public class GhostedDragImage extends AbstractComponentDecorator {
|
||||
* if true, creates additional ghosts for all extant frames which
|
||||
* contain a {@link JLayeredPane} where the image can be painted.
|
||||
*/
|
||||
protected GhostedDragImage(JComponent dragSource, JLayeredPane root,
|
||||
Point screenLocation, Icon icon, Point imageOffset,
|
||||
boolean trackFrames) {
|
||||
protected GhostedDragImage(JComponent dragSource, JLayeredPane root, Point screenLocation,
|
||||
Icon icon, Point imageOffset, boolean trackFrames) {
|
||||
super(root);
|
||||
this.dragSource = dragSource;
|
||||
this.icon = icon;
|
||||
this.imageOffset = imageOffset;
|
||||
Point loc = root.getLocationOnScreen();
|
||||
setLocation(screenLocation.x - loc.x + imageOffset.x, screenLocation.y
|
||||
- loc.y + imageOffset.y);
|
||||
setLocation(screenLocation.x - loc.x + imageOffset.x, screenLocation.y - loc.y
|
||||
+ imageOffset.y);
|
||||
if (trackFrames) {
|
||||
Window w = SwingUtilities.getWindowAncestor(root);
|
||||
Frame[] frames = Frame.getFrames();
|
||||
// Log.debug("track " + frames.length + " other frames");
|
||||
for (int i = 0; i < frames.length; i++) {
|
||||
Frame frame = frames[i];
|
||||
if (frame instanceof RootPaneContainer && frame.isShowing()
|
||||
&& frame != w) {
|
||||
if (frame instanceof RootPaneContainer && frame.isShowing() && frame != w) {
|
||||
// Log.debug("Track " + frame);
|
||||
JLayeredPane p = ((RootPaneContainer) frame)
|
||||
.getLayeredPane();
|
||||
GhostedDragImage slave = new GhostedDragImage(dragSource,
|
||||
p, screenLocation, icon, imageOffset, false);
|
||||
JLayeredPane p = ((RootPaneContainer) frame).getLayeredPane();
|
||||
GhostedDragImage slave = new GhostedDragImage(dragSource, p, screenLocation,
|
||||
icon, imageOffset, false);
|
||||
ghosts.add(slave);
|
||||
slave.move(screenLocation);
|
||||
}
|
||||
@@ -143,8 +140,7 @@ public class GhostedDragImage extends AbstractComponentDecorator {
|
||||
* with {@link #returnToOrigin}.
|
||||
*/
|
||||
private void setLocation(int x, int y) {
|
||||
location = SwingUtilities
|
||||
.convertPoint(getComponent(), x, y, dragSource);
|
||||
location = SwingUtilities.convertPoint(getComponent(), x, y, dragSource);
|
||||
if (origin == null)
|
||||
origin = location;
|
||||
setDecorationBounds(x, y, icon.getIconWidth(), icon.getIconHeight());
|
||||
@@ -176,8 +172,7 @@ public class GhostedDragImage extends AbstractComponentDecorator {
|
||||
public void move(Point screen) {
|
||||
// Log.debug("Move to " + screen);
|
||||
Point loc = getComponent().getLocationOnScreen();
|
||||
setLocation(screen.x - loc.x + imageOffset.x, screen.y - loc.y
|
||||
+ imageOffset.y);
|
||||
setLocation(screen.x - loc.x + imageOffset.x, screen.y - loc.y + imageOffset.y);
|
||||
for (Iterator i = ghosts.iterator(); i.hasNext();) {
|
||||
GhostedDragImage g = (GhostedDragImage) i.next();
|
||||
// Log.debug("Move on other frame");
|
||||
@@ -189,8 +184,7 @@ public class GhostedDragImage extends AbstractComponentDecorator {
|
||||
public void paint(Graphics graphics) {
|
||||
Rectangle r = getDecorationBounds();
|
||||
Graphics2D g = (Graphics2D) graphics.create();
|
||||
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
|
||||
ghostAlpha));
|
||||
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, ghostAlpha));
|
||||
g.translate(CURSOR_SIZE, CURSOR_SIZE);
|
||||
icon.paintIcon(getPainter(), g, r.x, r.y);
|
||||
g.dispose();
|
||||
@@ -208,9 +202,8 @@ public class GhostedDragImage extends AbstractComponentDecorator {
|
||||
int dy = (origin.y - location.y) / 2;
|
||||
if (dx != 0 || dy != 0) {
|
||||
Point loc = dragSource.getLocationOnScreen();
|
||||
Point where = new Point(loc.x + location.x + dx
|
||||
- imageOffset.x, loc.y + location.y + dy
|
||||
- imageOffset.y);
|
||||
Point where = new Point(loc.x + location.x + dx - imageOffset.x, loc.y
|
||||
+ location.y + dy - imageOffset.y);
|
||||
move(where);
|
||||
} else {
|
||||
timer.stop();
|
||||
|
||||
+7
-13
@@ -24,22 +24,16 @@ public class TableTest {
|
||||
BasicConfigurator.configure();
|
||||
|
||||
List<ProjectEntity> projects = new ArrayList<ProjectEntity>();
|
||||
projects
|
||||
.add(new ProjectEntity(1, "first", "some text", "bane", "none"));
|
||||
projects.add(new ProjectEntity(2, "second", "anoter text", "bisera",
|
||||
"none"));
|
||||
projects.add(new ProjectEntity(1, "first", "some text", "bane", "none"));
|
||||
projects.add(new ProjectEntity(2, "second", "anoter text", "bisera", "none"));
|
||||
|
||||
ObjectListTable<ProjectEntity> t = new ObjectListTable<ProjectEntity>(
|
||||
ProjectEntity.class, new String[] { "getName",
|
||||
"getDescription", "getCategory", "getOwner",
|
||||
"action:Download" },
|
||||
new IActionProcessor<ProjectEntity>() {
|
||||
ObjectListTable<ProjectEntity> t = new ObjectListTable<ProjectEntity>(ProjectEntity.class,
|
||||
new String[] { "getName", "getDescription", "getCategory", "getOwner",
|
||||
"action:Download" }, new IActionProcessor<ProjectEntity>() {
|
||||
|
||||
@Override
|
||||
public void actionExecuted(ProjectEntity value,
|
||||
String actionColumnName) {
|
||||
System.out.println("row clicked: " + actionColumnName
|
||||
+ " - " + value);
|
||||
public void actionExecuted(ProjectEntity value, String actionColumnName) {
|
||||
System.out.println("row clicked: " + actionColumnName + " - " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+11
-12
@@ -18,20 +18,19 @@ public class Test {
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// XStream xstream = new XStream(new JettisonMappedXmlDriver());
|
||||
// xstream.setMode(XStream.NO_REFERENCES);
|
||||
//
|
||||
// List<ProjectEntity> projects = new ArrayList<ProjectEntity>();
|
||||
//// projects.add(new ProjectEntity(1, "first project", "some text",
|
||||
//// "bancika", "some category"));
|
||||
//// projects.add(new ProjectEntity(2, "second project", "some text",
|
||||
//// "bancika", "some category"));
|
||||
// System.out.println(xstream.toXML(projects));
|
||||
// XStream xstream = new XStream(new JettisonMappedXmlDriver());
|
||||
// xstream.setMode(XStream.NO_REFERENCES);
|
||||
//
|
||||
// List<ProjectEntity> projects = new ArrayList<ProjectEntity>();
|
||||
// // projects.add(new ProjectEntity(1, "first project", "some text",
|
||||
// // "bancika", "some category"));
|
||||
// // projects.add(new ProjectEntity(2, "second project", "some text",
|
||||
// // "bancika", "some category"));
|
||||
// System.out.println(xstream.toXML(projects));
|
||||
|
||||
BasicConfigurator.configure();
|
||||
ProjectSearch search = new ProxyFactory(new PhpFlatProxy())
|
||||
.createProxy(ProjectSearch.class,
|
||||
"http://host07.dwhost.net/~diyfever/diylc/db/");
|
||||
ProjectSearch search = new ProxyFactory(new PhpFlatProxy()).createProxy(
|
||||
ProjectSearch.class, "http://host07.dwhost.net/~diyfever/diylc/db/");
|
||||
List<ProjectEntity> results = search.project_search("TestProject");
|
||||
System.out.println(results);
|
||||
}
|
||||
|
||||
+5
-7
@@ -30,8 +30,8 @@ public class MockComponentInstance implements IComponentInstance {
|
||||
private Point leftTopCorner = new Point(0, 0);
|
||||
private String name = "something";
|
||||
|
||||
public MockComponentInstance(String testField, Capacitance c, Resistance r,
|
||||
Size s, Color color, Point leftTopCorner) {
|
||||
public MockComponentInstance(String testField, Capacitance c, Resistance r, Size s,
|
||||
Color color, Point leftTopCorner) {
|
||||
super();
|
||||
this.testField = testField;
|
||||
this.c = c;
|
||||
@@ -113,16 +113,14 @@ public class MockComponentInstance implements IComponentInstance {
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState) {
|
||||
g2d.setColor(componentState.equals(ComponentState.SELECTED) ? color
|
||||
: color.darker());
|
||||
g2d.setColor(componentState.equals(ComponentState.SELECTED) ? color : color.darker());
|
||||
g2d.fillRect(leftTopCorner.x, leftTopCorner.y, 200, 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MockComponentInstance clone() throws CloneNotSupportedException {
|
||||
MockComponentInstance newInstance = new MockComponentInstance(
|
||||
testField, c.clone(), r.clone(), s.clone(), color,
|
||||
(Point) leftTopCorner.clone());
|
||||
MockComponentInstance newInstance = new MockComponentInstance(testField, c.clone(), r
|
||||
.clone(), s.clone(), color, (Point) leftTopCorner.clone());
|
||||
return newInstance;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -15,16 +15,15 @@ public class ClassProcessorTest {
|
||||
|
||||
@Test
|
||||
public void testExtractProperties() {
|
||||
List<PropertyWrapper> properties = ComponentProcessor.getInstance()
|
||||
.extractProperties(MockComponentInstance.class);
|
||||
List<PropertyWrapper> properties = ComponentProcessor.getInstance().extractProperties(
|
||||
MockComponentInstance.class);
|
||||
assertNotNull(properties);
|
||||
assertEquals(4, properties.size());
|
||||
};
|
||||
|
||||
@Test
|
||||
public void testExtractControlPoints() {
|
||||
List<ControlPointWrapper> controlPoints = ComponentProcessor
|
||||
.getInstance()
|
||||
List<ControlPointWrapper> controlPoints = ComponentProcessor.getInstance()
|
||||
.extractControlPoints(MockComponentInstance.class);
|
||||
assertNotNull(controlPoints);
|
||||
assertEquals(1, controlPoints.size());
|
||||
|
||||
Reference in New Issue
Block a user