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