import java.util.*;
import com.dukascopy.api.*;
import com.dukascopy.api.feed.util.TimePeriodAggregationFeedDescriptor;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
public class Strategy implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;
private GUIPanel GuiPanel;
public void onStart(IContext context) throws JFException {
this.engine = context.getEngine();
this.console = context.getConsole();
this.history = context.getHistory();
this.context = context;
this.indicators = context.getIndicators();
this.userInterface = context.getUserInterface();
JPanel myTab = userInterface.getBottomTab("Context Test");
myTab.setLayout(new BorderLayout());
GuiPanel = new GUIPanel(context);
myTab.add(GuiPanel, BorderLayout.CENTER);
}
public void onAccount(IAccount account) throws JFException {
}
public void onMessage(IMessage message) throws JFException {
}
public void onStop() throws JFException {
}
public void onTick(Instrument instrument, ITick tick) throws JFException {
}
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
}
}
class GUIPanel extends JPanel {
private JPanel JPanel_Test;
private JPopupMenu popupMenu = new JPopupMenu();
public IContext tabcontext;
public GUIPanel(IContext context) {
this.setLayout(new BorderLayout());
tabcontext = context;
tabcontext.openChart(new TimePeriodAggregationFeedDescriptor(Instrument.CADJPY,
Period.DAILY,
OfferSide.ASK,
Filter.WEEKENDS));
JButton testbutton = new JButton("test");
testbutton.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
tabcontext.openChart(new TimePeriodAggregationFeedDescriptor(Instrument.AUDJPY,
Period.DAILY,
OfferSide.ASK,
Filter.WEEKENDS)); }
});
add(testbutton);
}
}