|
|
@ -14,6 +14,7 @@ import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.IOUtils; |
|
|
|
import com.fr.general.IOUtils; |
|
|
|
import com.fr.share.ShareConstants; |
|
|
|
import com.fr.share.ShareConstants; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.Icon; |
|
|
|
import javax.swing.Icon; |
|
|
|
import javax.swing.ImageIcon; |
|
|
|
import javax.swing.ImageIcon; |
|
|
@ -52,12 +53,12 @@ import java.io.Serializable; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class ShareWidgetButton extends JPanel implements MouseListener, MouseMotionListener, Serializable { |
|
|
|
public class ShareWidgetButton extends JPanel implements MouseListener, MouseMotionListener, Serializable { |
|
|
|
|
|
|
|
|
|
|
|
private static final Dimension TAB_DEFAULT_SIZE = new Dimension(500, 300); |
|
|
|
protected SharableWidgetProvider bindInfo; |
|
|
|
private SharableWidgetProvider bindInfo; |
|
|
|
protected MouseEvent lastPressEvent; |
|
|
|
private MouseEvent lastPressEvent; |
|
|
|
protected JPanel reportPane; |
|
|
|
private JPanel reportPane; |
|
|
|
protected boolean isEdit; |
|
|
|
private boolean isEdit; |
|
|
|
protected boolean isMarked; |
|
|
|
private boolean isMarked; |
|
|
|
private ShareWidgetUI ui; |
|
|
|
private Icon markedMode = IOUtils.readIcon("/com/fr/design/form/images/marked.png"); |
|
|
|
private Icon markedMode = IOUtils.readIcon("/com/fr/design/form/images/marked.png"); |
|
|
|
private Icon unMarkedMode = IOUtils.readIcon("/com/fr/design/form/images/unmarked.png"); |
|
|
|
private Icon unMarkedMode = IOUtils.readIcon("/com/fr/design/form/images/unmarked.png"); |
|
|
|
private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F); |
|
|
|
private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F); |
|
|
@ -71,9 +72,11 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot |
|
|
|
unMarkedMode.paintIcon(this, g, 0, 0); |
|
|
|
unMarkedMode.paintIcon(this, g, 0, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public ShareWidgetButton(SharableWidgetProvider bindInfo) { |
|
|
|
public ShareWidgetButton(SharableWidgetProvider bindInfo, ShareWidgetUI ui) { |
|
|
|
|
|
|
|
|
|
|
|
this.bindInfo = bindInfo; |
|
|
|
this.bindInfo = bindInfo; |
|
|
|
|
|
|
|
this.ui = ui; |
|
|
|
this.setPreferredSize(new Dimension(108, 68)); |
|
|
|
this.setPreferredSize(new Dimension(108, 68)); |
|
|
|
initUI(); |
|
|
|
initUI(); |
|
|
|
this.setLayout(getCoverLayout()); |
|
|
|
this.setLayout(getCoverLayout()); |
|
|
@ -81,7 +84,12 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot |
|
|
|
this.addMouseMotionListener(this); |
|
|
|
this.addMouseMotionListener(this); |
|
|
|
new DragAndDropDragGestureListener(this, DnDConstants.ACTION_COPY_OR_MOVE); |
|
|
|
new DragAndDropDragGestureListener(this, DnDConstants.ACTION_COPY_OR_MOVE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ShareWidgetButton(SharableWidgetProvider bindInfo) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this(bindInfo, new ShareWidgetUI()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void paint(Graphics g) { |
|
|
|
public void paint(Graphics g) { |
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
Composite oldComposite = g2d.getComposite(); |
|
|
|
Composite oldComposite = g2d.getComposite(); |
|
|
@ -219,21 +227,14 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot |
|
|
|
if (creatorSource != null) { |
|
|
|
if (creatorSource != null) { |
|
|
|
((AbstractBorderStyleWidget)creatorSource).addWidgetAttrMark(new SharableAttrMark(true)); |
|
|
|
((AbstractBorderStyleWidget)creatorSource).addWidgetAttrMark(new SharableAttrMark(true)); |
|
|
|
//tab布局WCardMainBorderLayout通过反射出来的大小是960*480
|
|
|
|
//tab布局WCardMainBorderLayout通过反射出来的大小是960*480
|
|
|
|
XCreator xCreator = null; |
|
|
|
XCreator xCreator = ui.createXCreator(creatorSource, shareId, no.getBindInfo()); |
|
|
|
if (creatorSource instanceof WCardMainBorderLayout) { |
|
|
|
|
|
|
|
xCreator = XCreatorUtils.createXCreator(creatorSource, TAB_DEFAULT_SIZE); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
xCreator = XCreatorUtils.createXCreator(creatorSource); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
xCreator.setBackupBound(new Rectangle(no.getBindInfo().getWidth(), no.getBindInfo().getHeight())); |
|
|
|
|
|
|
|
xCreator.setShareId(shareId); |
|
|
|
|
|
|
|
WidgetToolBarPane.getTarget().startDraggingBean(xCreator); |
|
|
|
WidgetToolBarPane.getTarget().startDraggingBean(xCreator); |
|
|
|
lastPressEvent = null; |
|
|
|
lastPressEvent = null; |
|
|
|
this.setBorder(null); |
|
|
|
this.setBorder(null); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mouseMoved(MouseEvent e) { |
|
|
|
public void mouseMoved(MouseEvent e) { |
|
|
|
|
|
|
|
|
|
|
@ -283,9 +284,31 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Object getTransferData(DataFlavor df) throws UnsupportedFlavorException, IOException { |
|
|
|
public Object getTransferData(DataFlavor df) throws UnsupportedFlavorException, IOException { |
|
|
|
return widget; |
|
|
|
return widget; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 抽出来,专门为了创建 ui 来搞 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static class ShareWidgetUI { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final Dimension TAB_DEFAULT_SIZE = new Dimension(500, 300); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@NotNull |
|
|
|
|
|
|
|
public XCreator createXCreator(Widget creatorSource, String shareId, SharableWidgetProvider provider) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
XCreator xCreator = null; |
|
|
|
|
|
|
|
if (creatorSource instanceof WCardMainBorderLayout) { |
|
|
|
|
|
|
|
xCreator = XCreatorUtils.createXCreator(creatorSource, TAB_DEFAULT_SIZE); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
xCreator = XCreatorUtils.createXCreator(creatorSource, new Dimension(provider.getWidth(), provider.getHeight())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
xCreator.setBackupBound(new Rectangle(provider.getWidth(), provider.getHeight())); |
|
|
|
|
|
|
|
xCreator.setShareId(shareId); |
|
|
|
|
|
|
|
return xCreator; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|