Revision: 3859
Author: [email protected]
Date: Mon Aug 9 15:23:27 2010
Log: Created the PlayPenLabel, which displays text as a PlayPenComponent.
It does not yet support drag and drop, or have proper font support.
http://code.google.com/p/power-architect/source/detail?r=3859
Added:
/trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenLabel.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/CreateLabelAction.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/EditLabelAction.java
/trunk/src/main/resources/icons/label16.png
Modified:
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectSessionPersister.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/BasicTablePaneUI.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPen.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/CreateTableAction.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/EditSelectedAction.java
/trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages.properties
=======================================
--- /dev/null
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenLabel.java
Mon Aug 9 15:23:27 2010
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2010, SQL Power Group Inc.
+ *
+ * This file is part of SQL Power Architect.
+ *
+ * SQL Power Architect is free software; you can redistribute it and/or
modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SQL Power Architect is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package ca.sqlpower.architect.swingui;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.awt.Insets;
+import java.awt.Point;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import ca.sqlpower.architect.swingui.event.SelectionEvent;
+import ca.sqlpower.object.AbstractSPListener;
+import ca.sqlpower.object.SPLabel;
+import ca.sqlpower.object.SPObject;
+import ca.sqlpower.object.annotation.Constructor;
+import ca.sqlpower.object.annotation.ConstructorParameter;
+import ca.sqlpower.object.annotation.NonBound;
+import ca.sqlpower.object.annotation.NonProperty;
+import ca.sqlpower.object.annotation.ConstructorParameter.ParameterType;
+import ca.sqlpower.swingui.ColourScheme;
+
+public class PlayPenLabel extends PlayPenComponent {
+
+ public static final List<Class<? extends SPObject>> allowedChildTypes =
+ Collections.unmodifiableList(new ArrayList<Class<? extends
SPObject>>(
+ Arrays.asList(SPLabel.class)));
+
+ private final class LabelUI implements PlayPenComponentUI {
+
+ Insets insets = new Insets(1, 3, 3, 3);
+
+ @Override
+ public boolean contains(Point p) {
+ return getBounds().contains(p);
+ }
+
+ @Override
+ public Point getPointForModelObject(Object modelObject) {
+ return getLocation();
+ }
+
+ @Override
+ public Dimension getPreferredSize() {
+ String[] textToRender = label.getText().split("\n");
+ FontMetrics fm =
getPlayPen().getFontMetrics(getPlayPen().getFont());
+ int textHeight = fm.getHeight() * textToRender.length;
+ int textWidth = 0;
+ for (String line : textToRender) {
+ int lineWidth = fm.stringWidth(line);
+ if (lineWidth > textWidth) textWidth = lineWidth;
+ }
+ return new Dimension(textWidth + insets.left + insets.right,
textHeight + insets.top + insets.bottom);
+ }
+
+ @Override
+ public void installUI(PlayPenComponent c) {
+ // no-op
+ }
+
+ @Override
+ public void paint(Graphics2D g2) {
+ if (label.getBackgroundColour() != null) {
+ g2.setColor(label.getBackgroundColour());
+ g2.fillRect(0, 0, getWidth(), getHeight());
+ }
+
+ if (isSelected()) {
+ g2.setColor(ColourScheme.SQLPOWER_ORANGE);
+ } else {
+ g2.setColor(Color.BLACK);
+ }
+ g2.drawRect(0, 0, getWidth(), getHeight());
+ g2.translate(insets.left, insets.top);
+ g2.setColor(Color.BLACK);
+
+ String[] textToRender = label.getText().split("\n");
+ g2.setFont(getPlayPen().getFont());
+ FontMetrics fm = g2.getFontMetrics();
+ int textHeight = fm.getHeight() * textToRender.length;
+
+ double y =
label.getVerticalAlignment().calculateStartY(getHeight(), textHeight, fm);
+ for (String text : textToRender) {
+ int textWidth = (int) fm.getStringBounds(text,
g2).getWidth();
+ double x =
label.getHorizontalAlignment().computeStartX(getWidth() -
(insets.left+insets.right), textWidth);
+ g2.drawString(text, (int)x, (int)y);
+ y += fm.getHeight();
+ }
+ }
+
+ @Override
+ public void revalidate() {
+ // no-op
+ }
+
+ @Override
+ public void uninstallUI(PlayPenComponent c) {
+ // no-op
+ }
+ }
+
+ private final SPLabel label;
+
+ @Constructor
+ public PlayPenLabel(
+ @ConstructorParameter(parameterType = ParameterType.CHILD,
propertyName = "label") SPLabel label,
+ @ConstructorParameter(propertyName = "name") String name) {
+ super(name);
+ label.setParent(this);
+ this.label = label;
+ label.addSPListener(new AbstractSPListener() {
+ @Override
+ public void propertyChanged(PropertyChangeEvent evt) {
+ revalidate();
+ }
+ });
+ }
+
+ @Override
+ public List<Class<? extends SPObject>> getAllowedChildTypes() {
+ return allowedChildTypes;
+ }
+
+ @Override
+ public List<SPLabel> getChildren() {
+ return Collections.singletonList(label);
+ }
+
+ @Override
+ public Object getModel() {
+ return null;
+ }
+
+ @Override
+ public String getModelName() {
+ return null;
+ }
+
+ @Override
+ public void handleMouseEvent(MouseEvent evt) {
+ PlayPen pp = getPlayPen();
+
+ Point p = evt.getPoint();
+ pp.unzoomPoint(p);
+ p.translate(-getX(), -getY());
+ if (evt.getID() == MouseEvent.MOUSE_CLICKED) {
+ if ((evt.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
+ if (evt.getClickCount() == 2) { // double click
+ if (isSelected()) {
+ ArchitectFrame af =
pp.getSession().getArchitectFrame();
+ af.getEditLabelAction().actionPerformed
+ (new ActionEvent(this,
ActionEvent.ACTION_PERFORMED, PlayPen.ACTION_COMMAND_SRC_PLAYPEN));
+ }
+ } else {
+ setSelected(true, SelectionEvent.SINGLE_SELECT);
+ }
+ }
+ }
+ }
+
+ @Override
+ public PlayPenComponentUI getUI() {
+ return new LabelUI();
+ }
+
+ @NonBound
+ public Font getFont() {
+ Font font = label.getFont();
+ if (font != null) {
+ return font;
+ } else {
+ return getPlayPen().getFont();
+ }
+ }
+
+ @NonProperty
+ public SPLabel getLabel() {
+ return label;
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/CreateLabelAction.java
Mon Aug 9 15:23:27 2010
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2010, SQL Power Group Inc.
+ *
+ * This file is part of SQL Power Architect.
+ *
+ * SQL Power Architect is free software; you can redistribute it and/or
modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SQL Power Architect is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package ca.sqlpower.architect.swingui.action;
+
+import java.awt.Font;
+import java.awt.Point;
+import java.awt.event.ActionEvent;
+
+import ca.sqlpower.architect.swingui.AbstractPlacer;
+import ca.sqlpower.architect.swingui.ArchitectFrame;
+import ca.sqlpower.architect.swingui.ArchitectSwingSession;
+import ca.sqlpower.architect.swingui.PlayPen;
+import ca.sqlpower.architect.swingui.PlayPenLabel;
+import ca.sqlpower.architect.swingui.event.SelectionEvent;
+import ca.sqlpower.object.SPLabel;
+import ca.sqlpower.sqlobject.SQLObjectException;
+import ca.sqlpower.swingui.DataEntryPanel;
+import ca.sqlpower.swingui.LabelEditorPanel;
+
+public class CreateLabelAction extends AbstractArchitectAction {
+
+ public CreateLabelAction(ArchitectFrame frame) {
+ super(frame, "New Label...", "New Label", "label");
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ PlayPen playpen = getPlaypen();
+ playpen.fireCancel();
+
+ SPLabel spLabel = new ArchitectLabel();
+ spLabel.setName("label");
+ PlayPenLabel ppLabel = new PlayPenLabel(spLabel, "label");
+ LabelPlacer labelPlacer = new LabelPlacer(playpen, ppLabel);
+ labelPlacer.dirtyup();
+ }
+
+ public static final class ArchitectLabel extends SPLabel {
+ @Override
+ public Font getFont() {
+ return null;
+ }
+
+ @Override
+ public void setFont(Font font) {
+ // no-op, Architect does not persist font properties yet.
+ }
+ }
+
+ private class LabelPlacer extends AbstractPlacer {
+
+ private final PlayPenLabel label;
+
+ LabelPlacer(PlayPen pp, PlayPenLabel label) {
+ super(pp);
+ this.label = label;
+ }
+
+ @Override
+ protected String getEditDialogTitle() {
+ return "Label Properties";
+ }
+
+ @Override
+ public DataEntryPanel place(final Point p) throws
SQLObjectException {
+ label.setLocation(p);
+ LabelEditorPanel editPanel = frame.getEditLabelAction().new
PlayPenLabelEditorPanel(label.getLabel(), false) {
+ @Override
+ public boolean applyChanges() {
+ ArchitectSwingSession session = getSession();
+ try {
+ session.getWorkspace().begin("Creating a
PlayPenLabel");
+ if (super.applyChanges()) {
+ playpen.selectNone();
+ playpen.addLabel(label, p);
+ label.setSelected(true,
SelectionEvent.SINGLE_SELECT);
+ session.getWorkspace().commit();
+ return true;
+ } else {
+ session.getWorkspace().rollback("Error
creating label");
+ return false;
+ }
+ } catch (Throwable t) {
+ session.getWorkspace().rollback("Error creating
label");
+ throw new RuntimeException(t);
+ }
+ }
+ };
+
+ return editPanel;
+ }
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/EditLabelAction.java
Mon Aug 9 15:23:27 2010
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2010, SQL Power Group Inc.
+ *
+ * This file is part of SQL Power Architect.
+ *
+ * SQL Power Architect is free software; you can redistribute it and/or
modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SQL Power Architect is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package ca.sqlpower.architect.swingui.action;
+
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+import java.util.Collections;
+import java.util.List;
+
+import javax.swing.JDialog;
+import javax.swing.JOptionPane;
+
+import ca.sqlpower.architect.swingui.ArchitectFrame;
+import ca.sqlpower.architect.swingui.PlayPenComponent;
+import ca.sqlpower.architect.swingui.PlayPenLabel;
+import ca.sqlpower.object.SPLabel;
+import ca.sqlpower.object.SPVariableHelper;
+import ca.sqlpower.swingui.DataEntryPanel;
+import ca.sqlpower.swingui.DataEntryPanelBuilder;
+import ca.sqlpower.swingui.FontSelector;
+import ca.sqlpower.swingui.LabelEditorPanel;
+
+public class EditLabelAction extends AbstractArchitectAction {
+
+ public class PlayPenLabelEditorPanel extends LabelEditorPanel {
+
+ public PlayPenLabelEditorPanel(SPLabel label, boolean variables) {
+ super(label, variables);
+ }
+
+ @Override
+ public SPVariableHelper getVariablesHelper() {
+ return null;
+ }
+
+ @Override
+ public FontSelector getFontSelector() {
+ return new FontSelector(getPlaypen().getFont(), new
String[]{getPlaypen().getFont().getName()}, null);
+ }
+
+ @Override
+ public List<Color> getBackgroundColours() {
+ return Collections.singletonList(Color.WHITE);
+ }
+ }
+
+ public EditLabelAction(ArchitectFrame frame) {
+ super(frame, "Label Properties...", "Label Properties");
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ List<PlayPenComponent> selection = getPlaypen().getSelectedItems();
+ if (selection.size() < 1) {
+ JOptionPane.showMessageDialog(getPlaypen(),
Messages.getString("EditLabelAction.noLabelsSelected")); //$NON-NLS-1$
+ } else if (selection.size() > 1) {
+ JOptionPane.showMessageDialog(getPlaypen(),
Messages.getString("EditLabelAction.multipleItemsSelected")); //$NON-NLS-1$
+ } else if (selection.get(0) instanceof PlayPenLabel) {
+ PlayPenLabel label = (PlayPenLabel) selection.get(0);
+ showDialog(label);
+ } else {
+ JOptionPane.showMessageDialog(getPlaypen(),
Messages.getString("EditLabelAction.pleaseSelectLabel")); //$NON-NLS-1$
+ }
+ }
+
+ private void showDialog(final PlayPenLabel label) {
+ DataEntryPanel panel = new
PlayPenLabelEditorPanel(label.getLabel(), false);
+ JDialog editDialog =
DataEntryPanelBuilder.createDataEntryPanelDialog(
+ panel, frame,
+ Messages.getString("EditLabelAction.dialogTitle"),
//$NON-NLS-1$
+ DataEntryPanelBuilder.OK_BUTTON_LABEL);
+ editDialog.pack();
+ editDialog.setLocationRelativeTo(frame);
+ editDialog.setVisible(true);
+ }
+
+}
=======================================
--- /dev/null
+++ /trunk/src/main/resources/icons/label16.png Mon Aug 9 15:23:27 2010
Binary file, no diff available.
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectSessionPersister.java
Thu Aug 5 12:09:29 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectSessionPersister.java
Mon Aug 9 15:23:27 2010
@@ -22,11 +22,6 @@
import java.util.ArrayList;
import java.util.List;
-import ca.sqlpower.architect.SnapshotCollection;
-import ca.sqlpower.architect.ddl.critic.CriticManager;
-import ca.sqlpower.architect.etl.kettle.KettleSettings;
-import ca.sqlpower.architect.olap.OLAPRootObject;
-import ca.sqlpower.architect.profile.ProfileManagerImpl;
import ca.sqlpower.architect.swingui.ArchitectSwingProject;
import ca.sqlpower.dao.PersistedSPOProperty;
import ca.sqlpower.dao.PersistedSPObject;
@@ -35,7 +30,6 @@
import ca.sqlpower.dao.session.SessionPersisterSuperConverter;
import ca.sqlpower.object.SPObject;
import ca.sqlpower.sqlobject.SQLDatabase;
-import ca.sqlpower.sqlobject.SQLObjectRoot;
/**
* An architect specific persister.
@@ -53,7 +47,7 @@
pso.getUUID(), "rootObject", persistedProperties);
PersistedSPObject persistedRootObject =
AbstractSPPersisterHelper.findPersistedSPObject(
- pso.getUUID(), SQLObjectRoot.class.getName(),
rootObjectUUID, persistedObjects);
+ pso.getUUID(), rootObjectUUID, persistedObjects);
ArchitectSwingProject architectProject = (ArchitectSwingProject)
root;
architectProject.getRootObject().setUUID(rootObjectUUID);
persistedRootObject.setLoaded(true);
@@ -64,7 +58,7 @@
//Null for system projects.
if (profileManagerUUID != null) {
PersistedSPObject persistedProfileManager =
AbstractSPPersisterHelper.findPersistedSPObject(
- pso.getUUID(), ProfileManagerImpl.class.getName(),
profileManagerUUID, persistedObjects);
+ pso.getUUID(), profileManagerUUID, persistedObjects);
architectProject.getProfileManager().setUUID(profileManagerUUID);
persistedProfileManager.setLoaded(true);
}
@@ -73,7 +67,7 @@
pso.getUUID(), "olapRootObject", persistedProperties);
PersistedSPObject persistedOlapRootObject =
AbstractSPPersisterHelper.findPersistedSPObject(
- pso.getUUID(), OLAPRootObject.class.getName(),
olapRootObjectUUID, persistedObjects);
+ pso.getUUID(), olapRootObjectUUID, persistedObjects);
architectProject.getOlapRootObject().setUUID(olapRootObjectUUID);
persistedOlapRootObject.setLoaded(true);
@@ -81,7 +75,7 @@
pso.getUUID(), "kettleSettings", persistedProperties);
PersistedSPObject persistedKettleSettings =
AbstractSPPersisterHelper.findPersistedSPObject(
- pso.getUUID(), KettleSettings.class.getName(),
kettleSettingsUUID, persistedObjects);
+ pso.getUUID(), kettleSettingsUUID, persistedObjects);
persistedKettleSettings.setLoaded(true);
architectProject.getKettleSettings().setUUID(kettleSettingsUUID);
@@ -89,7 +83,7 @@
pso.getUUID(), "criticManager", persistedProperties);
PersistedSPObject criticManager =
AbstractSPPersisterHelper.findPersistedSPObject(
- pso.getUUID(), CriticManager.class.getName(),
criticManagerUUID, persistedObjects);
+ pso.getUUID(), criticManagerUUID, persistedObjects);
architectProject.getCriticManager().setUUID(criticManagerUUID);
criticManager.setLoaded(true);
@@ -99,7 +93,7 @@
pso.getUUID(), "snapshotCollection", persistedProperties);
PersistedSPObject snapshotCollectionSettings =
AbstractSPPersisterHelper.findPersistedSPObject(
- pso.getUUID(), SnapshotCollection.class.getName(),
snapshotCollectionUUID, persistedObjects);
+ pso.getUUID(), snapshotCollectionUUID, persistedObjects);
snapshotCollectionSettings.setLoaded(true);
architectProject.getSnapshotCollection().setUUID(snapshotCollectionUUID);
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java
Mon Aug 9 12:21:06 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java
Mon Aug 9 15:23:27 2010
@@ -104,6 +104,7 @@
import ca.sqlpower.architect.swingui.action.DeleteSelectedAction;
import ca.sqlpower.architect.swingui.action.EditColumnAction;
import ca.sqlpower.architect.swingui.action.EditCriticSettingsAction;
+import ca.sqlpower.architect.swingui.action.EditLabelAction;
import ca.sqlpower.architect.swingui.action.EditRelationshipAction;
import ca.sqlpower.architect.swingui.action.EditSelectedAction;
import ca.sqlpower.architect.swingui.action.EditSelectedIndexAction;
@@ -483,6 +484,8 @@
private JMenuItem saveAllProjectsMenu;
+ private EditLabelAction editLabelAction;
+
/**
* Sets up a new ArchitectFrame, which represents a window containing
one or
* more {...@link ArchitectSwingSession}s. It will not become visible
until
@@ -754,6 +757,7 @@
editSelectedAction = new EditSelectedAction(this);
insertColumnAction = new InsertColumnAction(this);
insertIndexAction = new InsertIndexAction(this);
+ editLabelAction = new EditLabelAction(this);
editTableAction = new EditTableAction(this);
editIndexAction = new EditSelectedIndexAction(this);
searchReplaceAction = new SearchReplaceAction(this);
@@ -1614,6 +1618,10 @@
public ArchitectStatusBar getStatusBar() {
return statusBar;
}
+
+ public EditLabelAction getEditLabelAction() {
+ return editLabelAction;
+ }
private class TabDropTargetListener implements DropTargetListener {
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/BasicTablePaneUI.java
Tue Jul 6 13:57:33 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/BasicTablePaneUI.java
Mon Aug 9 15:23:27 2010
@@ -109,8 +109,7 @@
paint(g,tablePane);
}
- public void paint(Graphics g, PlayPenComponent c) {
- TablePane tp = (TablePane) c;
+ public void paint(Graphics g, TablePane tp) {
try {
Graphics2D g2 = (Graphics2D) g;
Stroke oldStroke = g2.getStroke();
@@ -137,33 +136,33 @@
}
// We don't want to paint inside the insets or borders.
- Insets insets = c.getInsets();
+ Insets insets = tp.getInsets();
//builds a little buffer to reduce the clipping problem
//this only seams to work at a non-zoomed level. This
could
//use a little work (better fix)
g.setColor(Color.WHITE);
- g.fillRect(0, 0, c.getWidth(), c.getHeight());
+ g.fillRect(0, 0, tp.getWidth(), tp.getHeight());
g.translate(insets.left, insets.top);
- int width = c.getWidth() - insets.left - insets.right;
- int height = c.getHeight() - insets.top - insets.bottom;
-
- Font font = c.getFont();
+ int width = tp.getWidth() - insets.left - insets.right;
+ int height = tp.getHeight() - insets.top -
insets.bottom;
+
+ Font font = tp.getFont();
if (font == null) {
// This happens when the table exists but has no
visible ancestor.
// Don't ask me why it's being asked to paint under those
circumstances!
//logger.error("paint(): Null font in TablePane
"+c);
return;
}
- FontMetrics metrics = c.getFontMetrics(font);
+ FontMetrics metrics = tp.getFontMetrics(font);
int fontHeight = metrics.getHeight();
int ascent = metrics.getAscent();
int maxDescent = metrics.getMaxDescent();
int y = 0;
- g2.setColor(c.getPlayPen().getBackground());
+ g2.setColor(tp.getPlayPen().getBackground());
g2.fillRect(0, 0, width, height);
// no need to reset to foreground: next operation always changes the
colour
@@ -175,9 +174,9 @@
}
if (tp.isRounded()) {
- g2.fillRoundRect(0, 0, c.getWidth(), fontHeight, ARC_LENGTH,
ARC_LENGTH);
+ g2.fillRoundRect(0, 0, tp.getWidth(), fontHeight, ARC_LENGTH,
ARC_LENGTH);
} else {
- g2.fillRect(0, 0, c.getWidth(), fontHeight);
+ g2.fillRect(0, 0, tp.getWidth(), fontHeight);
}
g2.setColor(tp.getForegroundColor());
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPen.java Thu Jul
22 12:40:28 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPen.java Mon
Aug 9 15:23:27 2010
@@ -719,7 +719,7 @@
* index of insertion for c in the child list.
*/
protected void addImpl(PlayPenComponent c, Object constraints) {
- if (c instanceof Relationship || c instanceof UsageComponent) {
+ if (c instanceof Relationship || c instanceof UsageComponent || c
instanceof PlayPenLabel) {
contentPane.addChild(c,
contentPane.getFirstDependentComponentIndex());
} else if (c instanceof ContainerPane<?, ?>) {
if (constraints instanceof Point) {
@@ -1110,6 +1110,10 @@
public void addTablePane(TablePane tp, Point point) {
addImpl(tp, point);
}
+
+ public void addLabel(PlayPenLabel label, Point point) {
+ addImpl(label, point);
+ }
/**
* This method is primarily for loading project files. Use at your own
risk!
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/CreateTableAction.java
Wed Jul 21 07:16:53 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/CreateTableAction.java
Mon Aug 9 15:23:27 2010
@@ -92,9 +92,7 @@
@Override
public DataEntryPanel place(final Point p) throws
SQLObjectException {
- DataEntryPanel editPanel = null;
-
- editPanel = new TableEditPanel(playpen.getSession(),
tp.getModel()) {
+ TableEditPanel editPanel = new
TableEditPanel(playpen.getSession(), tp.getModel()) {
@Override
public boolean applyChanges() {
String warnings = generateWarnings();
@@ -125,10 +123,10 @@
}
}
};
-
- ((TableEditPanel)
editPanel).setNameText(tp.getModel().getName());
- ((TableEditPanel)
editPanel).setPhysicalNameText(tp.getModel().getPhysicalName());
- ((TableEditPanel)
editPanel).setPkNameText(tp.getModel().getName() + "_pk");
+
+ editPanel.setNameText(tp.getModel().getName());
+ editPanel.setPhysicalNameText(tp.getModel().getPhysicalName());
+ editPanel.setPkNameText(tp.getModel().getName() + "_pk");
return editPanel;
}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/EditSelectedAction.java
Mon Jul 12 08:21:11 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/EditSelectedAction.java
Mon Aug 9 15:23:27 2010
@@ -28,6 +28,7 @@
import ca.sqlpower.architect.swingui.ArchitectFrame;
import ca.sqlpower.architect.swingui.PlayPenComponent;
+import ca.sqlpower.architect.swingui.PlayPenLabel;
import ca.sqlpower.architect.swingui.Relationship;
import ca.sqlpower.architect.swingui.Selectable;
import ca.sqlpower.architect.swingui.TablePane;
@@ -54,6 +55,7 @@
boolean tablesSelected = false;
boolean relationshipsSelected = false;
boolean columnsSelected = false;
+ boolean labelsSelected = false;
for (PlayPenComponent ppc : selection) {
if (ppc instanceof TablePane) {
@@ -65,17 +67,21 @@
}
} else if (ppc instanceof Relationship) {
relationshipsSelected = true;
+ } else if (ppc instanceof PlayPenLabel) {
+ labelsSelected = true;
}
}
- if (columnsSelected && !relationshipsSelected) {
+ if (columnsSelected && !relationshipsSelected && !labelsSelected) {
// note: we expect tables to be selected too in this case, but
we ignore that
// and let the column selections take precedence
frame.getEditColumnAction().actionPerformed(e);
- } else if (tablesSelected && !relationshipsSelected) {
+ } else if (tablesSelected && !relationshipsSelected
&& !labelsSelected) {
frame.getEditTableAction().actionPerformed(e);
- } else if (relationshipsSelected && !tablesSelected) {
+ } else if (relationshipsSelected && !tablesSelected
&& !labelsSelected) {
frame.getEditRelationshipAction().actionPerformed(e);
+ } else if (labelsSelected && !tablesSelected
&& !relationshipsSelected) {
+ frame.getEditLabelAction().actionPerformed(e);
} else if (selection.size() > 0) {
JOptionPane.showMessageDialog(frame,
Messages.getString("EditSelectedAction.multipleItemsSelected"));
//$NON-NLS-1$
} else {
=======================================
---
/trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages.properties
Wed Jun 30 09:06:21 2010
+++
/trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages.properties
Mon Aug 9 15:23:27 2010
@@ -58,6 +58,10 @@
EditColumnAction.specificColumnShortDescription=Editing {0}
EditIndexAction.dialogTitle=Index Properties
EditIndexAction.okOption=OK
+EditLabelAction.dialogTitle=Edit Label
+EditLabelAction.noLabelsSelected=Select a Label (by clicking on it) and
try again.
+EditLabelAction.multipleItemsSelected=You have selected multiple labels,
but you can only edit one at a time.
+EditLabelAction.pleaseSelectLabel=Please select the label you would like
to edit.
EditRelationshipAction.description=Relationship Properties
EditRelationshipAction.dialogTitle=Relationship Properties
EditRelationshipAction.mappingsTab=Mappings