boolean leftButtonPush = (e.getModifiers() & InputEvent.BUTTON1_MASK) != 0;
public void mouseClicked(MouseEvent e) {	ViewState view = ViewState.getInstance();	// check for drags!	int cx = e.getX()-view.getX0();	int cy = e.getY()-view.getY0();	if ((cx>0) && (cy>0) && (cx<width) && (cy<height)) {//		System.out.println("mouseClicked ("+cx+", "+cy+")");		VisibleObject hilited = view.getHilitedObject();		if (hilited!=null) {						// linking support			if (tmplink!=null) {				if (hilited instanceof Record) {					linkCommand(hilited, null);					return;				}				else if (hilited instanceof EPICSVarLink) {					EPICSVarLink varlink = (EPICSVarLink)hilited;					//if ((tmplink.getType()!=DBDConstants.DBF_FWDLINK) ||		// !!! proc					//	varlink.getFieldData().getName().equalsIgnoreCase("PROC")) {						linkCommand((LinkManagerObject)varlink.getParent(), varlink.getFieldData());						return;					//}				}				// support all -> Macro				else if (hilited instanceof Macro) {					Macro macrolink = (Macro)hilited;					linkCommand(null, macrolink.getData());					return;				}				// support port -> EPICSLinkOut				else if ((tmplink instanceof VDBPort || tmplink instanceof VDBTemplateMacro)						 && hilited instanceof EPICSLinkOutIn) {					EPICSLinkOutIn link = (EPICSLinkOutIn)hilited;					linkCommand((LinkManagerObject)link.getParent(), link.getFieldData());					return;				}			}						boolean leftButtonPush = (e.getModifiers() & InputEvent.BUTTON1_MASK) != 0;			if (leftButtonPush)			{				if (e.isControlDown() || (e.getClickCount()==1)) {					if (!e.isControlDown()) view.deselectAll();			// deselect all					if (hilited instanceof Selectable) {				// invert selection						if (view.isSelected(hilited))							view.deselectObject(hilited);						else							view.setAsSelected(hilited);						repaint();					}				}				else if (e.getClickCount()>=2) {							if (hilited instanceof Selectable) {				// invert selection						if (view.isSelected(hilited))							view.deselectObject(hilited);						else							view.setAsSelected(hilited);					}						// shift for template					if (e.isShiftDown() && hilited instanceof Template) {							descendIntoTemplate((Template)hilited);					}					else if (hilited instanceof Inspectable) 						InspectorManager.getInstance().requestInspectorFor((Inspectable)hilited);					else if (hilited instanceof Connector)					{						Connector con = (Connector)hilited;						if (/*con.getMode()==OutLink.INVISIBLE_MODE &&*/ con.getInput()!=null)						{							centerObject((VisibleObject)con.getInput());			// !!! now is always true, but...						}						else if (con.getOutput()!=null /*&& con.getOutput().getMode()==OutLink.INVISIBLE_MODE*/)						{							centerObject((VisibleObject)con.getOutput());			// !!! now is always true, but...						}					} 					else {						if (hilited instanceof Group) {							moveToGroup((Group)hilited);						}					}				}			}		}		else {			pressedX=cx; pressedY=cy;			if((e.getClickCount() >= 1) && (grLine != null))			{				grLine = null;					// cancel action					if (e.getButton() == MouseEvent.BUTTON3)						UndoManager.getInstance().undo();			}			else if((e.getClickCount() >= 1) && (grBox != null))			{				grBox = null;					// cancel action					if (e.getButton() == MouseEvent.BUTTON3)						UndoManager.getInstance().undo();			}			else if((e.getClickCount() >= 1) && (grTextBox != null))			{				grTextBox.setBorder(TextBox.getCurrentBorder());				grTextBox.showChangeTextDialog();					grTextBox = null;					// cancel action					if (e.getButton() == MouseEvent.BUTTON3)						UndoManager.getInstance().undo();			}			else if (e.getClickCount()==1 && e.getButton()==MouseEvent.BUTTON3)			{				showPopup(e);			}			else if (e.getClickCount()>=2)			{				// !!! to be changed...				if(VisualDCT.getInstance().getLineButtonEnabled())					createLine();				else if(VisualDCT.getInstance().getBoxButtonEnabled())					createBox();				else if(VisualDCT.getInstance().getTextBoxButtonEnabled())					createTextBox();				else					CommandManager.getInstance().execute("ShowNewDialog");			}			else if (view.deselectAll()) 				repaint();					// deselect all		}				stopLinking();				}}