@Override
public void mouseClicked(MouseEvent e) {
Point p = e.getPoint();
int i = locationToIndex(p);
java.util.List<Client> clients = (java.util.List<Client>) getApi().getClients(getFilter());
Client client = (Client) clients.get(i);
if (e.getButton() == MouseEvent.BUTTON1) {
if (e.getClickCount() == 2) {
if (client.isRunning()) {
client.stop();
} else {
client.start();
}
update();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger()) {
doPop(e);
} else {
//drag started
inDrag = true;
dragged = 0;
}
}
@Override
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
doPop(e);
}
}
private void doPop(MouseEvent e) {
Point p = e.getPoint();
int i = locationToIndex(p);
java.util.List<Client> clients = (java.util.List<Client>) getApi().getClients(getFilter());
final Client client = (Client) clients.get(i);
JPopupMenu menu = new JPopupMenu();
JMenuItem mnuConfigure = null;
if (client.getType().equalsIgnoreCase("plugin")) {
mnuConfigure = new JMenuItem("Configure " + client.getName());
} else {
if (client.getType().equalsIgnoreCase("object")) {
mnuConfigure = new JMenuItem("Add " + client.getName() + " Object");
} else {
mnuConfigure = new JMenuItem("Placeholder menu");
}
}
mnuConfigure.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (client.getType().equalsIgnoreCase("plugin")) {
client.start();
client.showGui();
update();
}
if (client.getType().equalsIgnoreCase("object")) {
ObjectPluginPlaceholder objp = (ObjectPluginPlaceholder) client;
if (parent instanceof MainWindow) {
MainWindow mw = (MainWindow) parent;
objp.startOnEnv(mw.getDrawer().getCurrEnv()); //adds the object to the environment