}
//}
URL btnIconResourceUrl = getClass().getClassLoader().getResource(
ActivityLabel.getSVGIconPath(activityCls));
ResizableIcon btnSVGIcon = null;
if(btnIconResourceUrl != null) {
btnSVGIcon = SvgBatikResizableIcon.getSvgIcon(btnIconResourceUrl, new Dimension(32, 32));
}
if(btnSVGIcon == null){ //if there's no SVG icon for requested activity type, try to use the GIF image icon instead.
ImageIcon activityGifImageIcon = ActivityLabel.getImageIcon(activityCls);
if(activityGifImageIcon!=null)
btnSVGIcon = new IconWrapperResizableIcon(activityGifImageIcon);
}
if(btnSVGIcon == null){ //if there's no icon even, use default one.
URL defaultIconResourceUrl = getClass().getClassLoader().getResource(
ActivityLabel.getSVGIconPath(DefaultActivity.class));
if(defaultIconResourceUrl!=null)
btnSVGIcon = SvgBatikResizableIcon.getSvgIcon(defaultIconResourceUrl, new Dimension(32, 32));
}
if(btnSVGIcon != null) {
JCommandButton btn = new JCommandButton(name, btnSVGIcon);
activityTypeNameMap.put(activityCls, name);
btn.setToolTipText(clsName);
btn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
ProcessDesigner.this.insertActivity(activityCls);
ProcessDesigner.this.setDocumentChanged(true);
}
});
DragSource dragSource = DragSource.getDefaultDragSource();
dragSource.createDefaultDragGestureRecognizer(
btn, // component where drag originates
DnDConstants.ACTION_COPY_OR_MOVE, // actions
new DragGestureListener(){
/**
* start of D&D framework implementation
*/
public void dragGestureRecognized(DragGestureEvent e) {
e.startDrag(DragSource.DefaultCopyDrop, // cursor
new Transferable(){
public DataFlavor[] getTransferDataFlavors() {
// TODO Auto-generated method stub
return null;
}
public boolean isDataFlavorSupported(DataFlavor flavor) {
// TODO Auto-generated method stub
return false;
}
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
List list = new ArrayList();
list.add(activityCls);
return list;
}
}); // drag source listener
}
public void dragDropEnd(DragSourceDropEvent e) {}
public void dragEnter(DragSourceDragEvent e) {}
public void dragExit(DragSourceEvent e) {}
public void dragOver(DragSourceDragEvent e) {}
public void dropActionChanged(DragSourceDragEvent e) {}
/**
* end of D&D framework implementation
*/
}
); // drag gesture recognizer
if(!activityByBand.containsKey(bandName)){
URL bandIconResourceUrl = getClass().getClassLoader().getResource(
ActivityLabel.getSVGIconPath(activityCls, bandIconName));
ResizableIcon bandSVGIcon = null;
if(bandIconResourceUrl!=null){
bandSVGIcon = SvgBatikResizableIcon.getSvgIcon(
bandIconResourceUrl, new Dimension(25, 25));
}