public ServerDesc() {
    setWidth("100%");
    setHeight("100%");
    setCaption(ViewProperties.getCaption("panel.serverDesc"));
    addStyleName(Reindeer.PANEL_LIGHT);
    addStyleName("server-desc-panel");

    VerticalLayout layout = (VerticalLayout) getContent();
    layout.setWidth("100%");
    layout.setHeight("100%");
    layout.setMargin(false);
    layout.setSpacing(false);
    layout.addStyleName("server-desc-layout");
    tabDesc.addStyleName(Reindeer.TABSHEET_BORDERLESS);
    tabDesc.setWidth("100%");
    tabDesc.setHeight("100%");
    tabDesc.addTab(
        serverDescBasic, ViewProperties.getCaption("tab.serverDescBasic"), Icons.BASIC.resource());
    tabDesc.addTab(
        serverDescDetail,
        ViewProperties.getCaption("tab.serverDescDetail"),
        Icons.DETAIL.resource());
    // タブ用リスナー
    tabDesc.addListener(TabSheet.SelectedTabChangeEvent.class, this, "selectedTabChange");
    addComponent(tabDesc);
  }
Example #2
0
  public CustomerMenu(MshenguMain app, String selectedTab) {
    main = app;

    Label heading = new Label("CREATE A NEW CUSTOMER");
    heading.setSizeUndefined();
    heading.addStyleName("h4");
    VerticalLayout customerDetailsTab = new VerticalLayout();
    customerDetailsTab.setMargin(true);
    customerDetailsTab.addComponent(new CustomerDetailsTab(main));

    customerContractsTab = new CustomerContractsTab(main);
    newCustomerTab = new NewCustomerTab(app);
    //        customerContractsTab.setMargin(true);
    //        customerContractsTab.addComponent(new CustomerContractsTab(main));

    tab = new TabSheet();
    tab.setHeight("100%");
    tab.setWidth("100%");
    tab.addTab(customerDetailsTab, "Customer Details", null);
    tab.addTab(customerContractsTab, "Hiring Terms", null);
    tab.addTab(newCustomerTab, "New Customer Form", null);

    if (selectedTab.equals("LANDING")) {
      tab.setSelectedTab(customerDetailsTab);
    } else if (selectedTab.equals("CONTRACTS")) {
      tab.setSelectedTab(customerContractsTab);
    } else if (selectedTab.equals("New_Customer")) {
      tab.setSelectedTab(newCustomerTab);
    }
    addComponent(heading);
    addComponent(tab);
    setMargin(true);
  }
 private AbstractComponent getTestTabsheet() {
   TabSheet tabsheet = new TabSheet();
   tabsheet.setSizeUndefined();
   tabsheet.addTab(new UndefWideLabel("TAB1"), "TAB1", new ThemeResource(GLOBE_16_PNG));
   tabsheet.addTab(new UndefWideLabel("TAB2"), "TAB2", null);
   return tabsheet;
 }
Example #4
0
  @Override
  protected void init(VaadinRequest vaadinRequest) {

    TabSheet tabs = new TabSheet();

    tabs.setSizeFull();

    tabs.addTab(new PreJava8Tab(), "Pre-Java 8");
    tabs.addTab(new Java8LambdaTab(), "Lambda Java 8");
    tabs.addTab(new DedicatedComponentTab(), "Dedicated Component");
    tabs.addTab(new EventBusTab(), "Event Bus w/ Java 8");

    setContent(tabs);
  }
  /** Constructor initializes View. */
  public EvaluationView() {
    this.setSizeFull();

    // buildMainLayout

    // Tab 1 content
    //		tab1 = new VerticalLayout();
    //		tab1.setMargin(true);
    //		tab1.addComponent(buildTab1Content());

    // Tab 2 content
    tab2 = new VerticalLayout();
    tab2.setMargin(true);
    tab2.addComponent(buildTab2Content());

    // Tab 3 content
    tab3 = new VerticalLayout();
    tab3.setMargin(true);
    tab3.addComponent(buildTab3Content());

    tabsheet = new TabSheet();
    // tabsheet.setSizeFull();
    //		tabsheet.addTab(tab1, "Home");
    tabsheet.addTab(tab2, "Annotation");
    tabsheet.addTab(tab3, "Evaluation");

    // reset to default status
    this.resetComponents();

    this.addComponent(tabsheet);
  }
Example #6
0
 @Override
 public void set(Component newComponent, String name) {
   clear();
   owner.addTab(newComponent, name);
   owner.setSelectedTab(newComponent);
   current = newComponent;
 }
Example #7
0
  @Override
  protected ComponentContainer createBottomPanel() {
    final TabSheet tabContainer = new TabSheet();
    tabContainer.setWidth("100%");

    tabContainer.addTab(
        this.noteListItems, "Notes", MyCollabResource.newResource("icons/16/crm/note.png"));
    tabContainer.addTab(
        this.associateActivityList,
        "Activities",
        MyCollabResource.newResource("icons/16/crm/calendar.png"));
    tabContainer.addTab(
        this.associateOpportunityList,
        "Opportunities",
        MyCollabResource.newResource("icons/16/crm/opportunity.png"));
    return tabContainer;
  }
Example #8
0
  /**
   * Loads a dynamic tab as a <code>Layout</code> which is then added to the given TabSheet given
   * <code>TabSheet</code>
   *
   * @param source Layout to add to the tab, the Layout is responsible for implementing any
   *     interactions by itself
   * @param caption String that the tab should have as its name in the TabSheet
   * @param parent TabSheet to add the new tab to
   */
  private static void createDynamicContentTab(Layout source, String caption, TabSheet parent) {

    GeneralMacros.errorIfContainsNull(source, caption, parent); // Check for null arguments

    source.setCaption(caption);
    source.setMargin(true);
    parent.addTab(source);
  }
  @Override
  protected void setup() {

    TabSheet tabs = new TabSheet();
    tabs.setSizeFull();
    MyCustomComponent mcc = new MyCustomComponent();
    mcc.setSizeUndefined();

    // Doesn't work
    tabs.addTab(mcc, "Doesn't work (CustomComponent)", null);

    // Works:
    tabs.addTab(mcc.buildLayout(), "Works (no CustomComponent, same layout)", null);

    addComponent(tabs);
    getLayout().setSizeFull();
  }
 public void locateComponents() {
   sendOrderButton = new Button("Make order");
   for (Menu menu : menuCollection) {
     tabSheet.addTab(addPanelMenu(menu), menu.getCafeName());
   }
   addComponent(tabSheet);
   addComponent(sendOrderButton);
   sendOrderButton.addListener(new SendOrderButtonListener());
 }
Example #11
0
 /**
  * Receive any contributions.
  *
  * <p>We need to know when to remove the component so we need a map from the factory to the
  * instance so that when the factory is unregistered, we can dispose it.
  *
  * @param factory The DS Component Factory that can make, well, ehh, components.
  */
 @Reference(type = '*', target = "(component.factory=com.vaadin.Component/contribution)")
 protected void setContribution(ComponentFactory factory) {
   ComponentInstance ci = factory.newInstance(null);
   Component c = (Component) ci.getInstance();
   synchronized (this) {
     tabs.addTab(c);
     mapping.put(factory, ci);
   }
 }
Example #12
0
  public UtilitiesMenu(MainLayout main, String selectedTab) {
    this.main = main;
    VerticalLayout statusTab = new VerticalLayout();
    statusTab.setMargin(true);
    statusTab.addComponent(new StatusTab(main));

    VerticalLayout funderTab = new VerticalLayout();
    funderTab.setMargin(true);
    funderTab.addComponent(new FunderTab(main));

    VerticalLayout currencyTab = new VerticalLayout();
    currencyTab.setMargin(true);
    currencyTab.addComponent(new CurrencyTab(main));

    VerticalLayout disciplineActionTypeListTab = new VerticalLayout();
    disciplineActionTypeListTab.setMargin(true);
    disciplineActionTypeListTab.addComponent(new DisciplineActionTypeListTab(main));

    VerticalLayout accidentTypeListTab = new VerticalLayout();
    accidentTypeListTab.setMargin(true);
    accidentTypeListTab.addComponent(new AccidentTypeListTab(main));

    tab = new TabSheet();
    tab.setHeight("100%");
    tab.setWidth("100%");

    tab.addTab(disciplineActionTypeListTab, "Discipline  ACTION", null);
    tab.addTab(statusTab, "Status  LIST", null);
    tab.addTab(funderTab, "Funders LIST", null);
    tab.addTab(currencyTab, "Currencies  LIST", null);
    tab.addTab(accidentTypeListTab, "Accident Type  LIST", null);
    if (selectedTab.equals("LANDING")) {
      tab.setSelectedTab(disciplineActionTypeListTab);
    } else if (selectedTab.equals("STATUS")) {
      tab.setSelectedTab(statusTab);
    } else if (selectedTab.equals("FUNDER")) {
      tab.setSelectedTab(funderTab);
    } else if (selectedTab.equals("CURRENCY")) {
      tab.setSelectedTab(currencyTab);
    } else if (selectedTab.equals("ACCIDENT")) {
      tab.setSelectedTab(accidentTypeListTab);
    }
    addComponent(tab);
  }
Example #13
0
  @AutoGenerated
  private TabSheet buildTabSheetClient() {
    // common part: create layout
    tabSheetClient = new TabSheet();
    tabSheetClient.setImmediate(true);
    tabSheetClient.setWidth("100.0%");
    tabSheetClient.setHeight("100.0%");

    // generalLayout
    generalLayout = buildGeneralLayout();
    tabSheetClient.addTab(generalLayout, "General", null);

    // addressLayout
    addressLayout = buildAddressLayout();
    tabSheetClient.addTab(addressLayout, "Dirección", null);

    // securityLayout
    securityLayout = buildSecurityLayout();
    tabSheetClient.addTab(securityLayout, "Seguridad", null);

    // organizationLayout
    organizationLayout = buildOrganizationLayout();
    tabSheetClient.addTab(organizationLayout, "Organización", null);

    // applicationverticalLayout
    applicationverticalLayout = buildApplicationverticalLayout();
    tabSheetClient.addTab(applicationverticalLayout, "Aplicaciones", null);

    // rolLayout
    rolLayout = buildRolLayout();
    tabSheetClient.addTab(rolLayout, "Rol", null);

    return tabSheetClient;
  }
Example #14
0
  /**
   * Loads a Static tab with {@link #cz.nkp.differ.gui.tabs.TabLoader} and adds it to the given
   * <code>TabSheet</code>
   *
   * @param source String identifying the proper load resource as recognized by <code>TabLoader
   *     </code>
   * @param caption String that the tab should have as its name in the TabSheet
   * @param parent TabSheet to add the new tab to
   */
  private static void createStaticContentTab(String source, String caption, TabSheet parent) {

    GeneralMacros.errorIfContainsNull(source, caption, parent); // Check for null arguments

    try {
      VerticalLayout tab = new TabLoader(source);
      tab.setMargin(true);
      tab.setCaption(caption);
      parent.addTab(tab);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  @AutoGenerated
  private TabSheet buildLogintab() {
    // common part: create layout
    logintab = new TabSheet();
    logintab.setStyleName("background");
    logintab.setImmediate(true);
    logintab.setWidth("479px");
    logintab.setHeight("450px");

    // loginTab
    loginTab = buildLoginTab();
    logintab.addTab(loginTab, "Login", null);

    // registerTab
    registerTab = buildRegisterTab();
    logintab.addTab(registerTab, "Register", null);

    // forgotTab
    forgotTab = buildForgotTab();
    logintab.addTab(forgotTab, "Forgot Something?", null);

    return logintab;
  }
Example #16
0
  @AutoGenerated
  private TabSheet buildTabSheet_1() {
    // common part: create layout
    tabSheet_1 = new TabSheet();
    tabSheet_1.setImmediate(true);
    tabSheet_1.setWidth("100.0%");
    tabSheet_1.setHeight("100.0%");

    // parentForm_1
    parentForm_1 = new ParentForm();
    parentForm_1.setImmediate(false);
    parentForm_1.setWidth("100.0%");
    parentForm_1.setHeight("100.0%");
    tabSheet_1.addTab(parentForm_1, "Parents", null);

    // stockPriceForm_1
    stockPriceForm_1 = new StockPriceForm();
    stockPriceForm_1.setImmediate(false);
    stockPriceForm_1.setWidth("100.0%");
    stockPriceForm_1.setHeight("100.0%");
    tabSheet_1.addTab(stockPriceForm_1, "Stock", null);

    return tabSheet_1;
  }
  @Override
  public void init() {
    Window mainWindow = new Window("SplitButton Demo Application");
    setMainWindow(mainWindow);

    setTheme("splitbuttondemo-reindeer");

    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();
    mainLayout.setMargin(true);
    mainWindow.setContent(mainLayout);

    Label headerLabel = new Label("SplitButton");
    headerLabel.setStyleName(Reindeer.LABEL_H1);
    mainLayout.addComponent(headerLabel);

    TabSheet tabSheet = new TabSheet();
    tabSheet.setSizeFull();
    mainLayout.addComponent(tabSheet);
    mainLayout.setExpandRatio(tabSheet, 1);

    tabSheet.addTab(createChameleonTab(), "Chameleon", null);
    tabSheet.addTab(createReindeerTab(), "Reindeer", null);
  }
  @Override
  protected void setup(VaadinRequest request) {

    final TabSheet tabsheet = new TabSheet();
    tabsheet.setWidth("400px");

    Component lastLabel = null;

    for (int i = 1; i <= 5; i++) {
      String caption = "Tab " + i;
      Label label = new Label(caption);
      tabsheet.addTab(label, caption);

      lastLabel = label;
    }

    tabsheet.setSelectedTab(0);

    final Component lastTab = lastLabel;

    tabsheet.addSelectedTabChangeListener(
        new SelectedTabChangeListener() {

          @Override
          public void selectedTabChange(SelectedTabChangeEvent event) {
            if (tabsheet.getSelectedTab().equals(lastTab)) {

              // Set focus back to first tab in tabsheet
              tabsheet.setSelectedTab(0);
              Notification.show("Focus set back to tab at position 0");
            }
          }
        });

    addComponent(tabsheet);

    addButton(
        "Select Last Tab",
        new ClickListener() {

          @Override
          public void buttonClick(ClickEvent event) {
            tabsheet.setSelectedTab(lastTab);
          }
        });
  }
  @Override
  protected ComponentContainer createSectionWidget(
      ComponentContainer previousSectionWidget,
      String section,
      Map<String, String> attributes,
      ComponentContainer container,
      VaadinMetawidget metawidget) {

    TabSheet tabSheet;

    // Whole new tabbed pane?

    if (previousSectionWidget == null) {

      tabSheet = new TabSheet();
      tabSheet.setWidth("100%");

      // Add to parent container

      Map<String, String> tabbedPaneAttributes = CollectionUtils.newHashMap();
      tabbedPaneAttributes.put(LABEL, "");
      tabbedPaneAttributes.put(LARGE, TRUE);
      getDelegate().layoutWidget(tabSheet, PROPERTY, tabbedPaneAttributes, container, metawidget);
    } else {
      tabSheet = (TabSheet) previousSectionWidget.getParent();
    }

    // New tab

    Panel tabPanel = new Panel();

    // Tab name (possibly localized)

    String localizedSection = metawidget.getLocalizedKey(StringUtils.camelCase(section));

    if (localizedSection == null) {
      localizedSection = section;
    }

    tabSheet.addTab(tabPanel, localizedSection, null);

    return tabPanel;
  }
Example #20
0
  private void prepareTabs() throws Exception {
    Locale locale = getApplication().getLocale();
    GsonBuilder gb = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
    Gson gson = gb.create();
    Type collectionType = new TypeToken<LinkedHashMap<Integer, String>>() {}.getType();
    TreeMap<Integer, String> tabList = new TreeMap<Integer, String>();
    String metaDataString =
        getPbApplication().getBpmModule().getMetaData("PROCESSBASE_TABSHEETS_LIST");
    if (metaDataString != null) {
      LinkedHashMap<Integer, String> tabs2 = gson.fromJson(metaDataString, collectionType);
      if (!tabs2.isEmpty()) {
        tabList.putAll(tabs2);
      }
    }

    PbPanelModuleService pms = getPbApplication().getPanelModuleService();

    for (Entry<String, PbPanelModule> pm : pms.getModules().entrySet()) {
      System.out.println("moduleName = " + pm.getKey());

      if (pm != null) {
        try {
          PbPanelModule panel = pm.getValue();
          if (CollectionUtils.containsAny(Arrays.asList(panel.getRoles()), accessSet)) {
            tabs.addTab(panel, panel.getTitle(locale), null);
          } else {
            System.out.println("No rights for module = " + pm.getKey());
          }
        } catch (Exception ex) {
          System.out.println("Exception with pm = " + pm.getKey());
          ex.printStackTrace();
          throw new RuntimeException(ex);
        }
      }
    }
    if (tabs.getSelectedTab() != null && tabs.getSelectedTab() instanceof PbPanel) {
      PbPanel first = (PbPanel) tabs.getSelectedTab();
      first.initUI();
      first.setInitialized(true);
      first.setSizeFull();
    }
  }
  @Override
  public TabSheet createTabs(Object itemId) throws RpcException {
    final TabSheet tabsheet = new TabSheet();
    tabsheet.addSelectedTabChangeListener(this);
    tabsheet.addTab(new GenericForm("pac", session, itemId, "name"), I18N.getText("pac"));
    final HSTab usersTab = new HSTab("user", session, "pac", itemId, "name");
    usersTab.fillTable();
    tabsheet.addTab(usersTab, I18N.getText("user"));
    final HSTab aliasTab = new HSTab("emailalias", session, "pac", itemId, "name");
    tabsheet.addTab(aliasTab, I18N.getText("emailalias"));
    final HSTab domainTab = new HSTab("domain", session, "pac", itemId, "name");
    tabsheet.addTab(domainTab, I18N.getText("domain"));

    final HSTab mysqluserTab = new HSTab("mysqluser", session, "pac", itemId, "name");
    tabsheet.addTab(mysqluserTab, I18N.getText("mysqluser"));
    final HSTab mysqldbTab = new HSTab("mysqldb", session, "pac", itemId, "name");
    tabsheet.addTab(mysqldbTab, I18N.getText("mysqldb"));
    final HSTab postgresqluserTab = new HSTab("postgresqluser", session, "pac", itemId, "name");
    tabsheet.addTab(postgresqluserTab, I18N.getText("postgresqluser"));
    final HSTab postgresqldbTab = new HSTab("postgresqldb", session, "pac", itemId, "name");
    tabsheet.addTab(postgresqldbTab, I18N.getText("postgresqldb"));
    return tabsheet;
  }
Example #22
0
  @Override
  protected void init(final VaadinRequest request) {
    final TabSheet tabLayout = new TabSheet();
    final VerticalLayout layout = new VerticalLayout();
    layout.addComponent(tabLayout);
    setContent(layout);

    final BinderCollection<MarathonData> binders = new BinderCollection<MarathonData>();

    binders.commitHandler();

    final FormLayout competitionParameters = new FormLayout();
    binders.appendBinder(showOverviewData(competitionParameters));
    tabLayout.addTab(competitionParameters, "Übersicht");

    final FormLayout phaseATabContent = new FormLayout();
    binders.appendBinder(showPhaseData(phaseATabContent, Phase.A));
    tabLayout.addTab(phaseATabContent, "Phase A");

    final FormLayout phaseDTabContent = new FormLayout();
    binders.appendBinder(showPhaseData(phaseDTabContent, Phase.D));
    tabLayout.addTab(phaseDTabContent, "Phase D");

    final FormLayout phaseETabContent = new FormLayout();
    binders.appendBinder(showPhaseData(phaseETabContent, Phase.E));
    tabLayout.addTab(phaseETabContent, "Phase E");

    final VerticalLayout outputLayout = new VerticalLayout();
    final FormLayout outputParameters = new FormLayout();

    final BeanItemContainer<String> driverDataSource = new BeanItemContainer<String>(String.class);
    final ComboBox selectDriverCombo = new ComboBox("Fahrer", driverDataSource);
    selectDriverCombo.setNewItemsAllowed(false);
    selectDriverCombo.setImmediate(true);
    outputLayout.addComponent(selectDriverCombo);
    binders.appendBinder(
        new DataBinder<MarathonData>() {

          private MarathonData data;

          @Override
          public void bindData(final MarathonData data) {
            this.data = data;
            driverDataSource.removeAllItems();
            driverDataSource.addAll(data.getDrivers().keySet());
          }

          @Override
          public void commitHandler() {}

          @Override
          public MarathonData getCurrentData() {
            return data;
          }
        });

    // new Button("Erstelle PDF");

    outputLayout.setSizeFull();
    outputLayout.addComponent(outputParameters);
    outputLayout.setExpandRatio(outputParameters, 0);

    final MarathonData marathonData = loadMarathonData("default");
    binders.bindData(marathonData);

    final StreamResource source =
        new StreamResource(
            new StreamSource() {

              @Override
              public InputStream getStream() {
                final ByteArrayOutputStream os = new ByteArrayOutputStream();
                new GeneratePdf()
                    .makePdf(os, binders.getCurrentData(), (String) selectDriverCombo.getValue());
                return new ByteArrayInputStream(os.toByteArray());
              }
            },
            makeOutputFilename());
    source.setMIMEType("application/pdf");
    final BrowserFrame pdf = new BrowserFrame("Output", source);
    pdf.setSizeFull();
    outputLayout.addComponent(pdf);
    outputLayout.setExpandRatio(pdf, 1);
    tabLayout.addTab(outputLayout, "Resultat");
    tabLayout.setSizeFull();
    layout.setExpandRatio(tabLayout, 1);

    layout.setSizeFull();

    selectDriverCombo.addValueChangeListener(
        new ValueChangeListener() {

          @Override
          public void valueChange(final ValueChangeEvent event) {
            binders.commitHandler();
            saveMarathonData(binders.getCurrentData());
            source.setFilename(makeOutputFilename());
            pdf.markAsDirty();
          }
        });

    final Button saveButton =
        new Button(
            "Übernehmen",
            new ClickListener() {
              @Override
              public void buttonClick(final ClickEvent event) {
                binders.commitHandler();
                saveMarathonData(binders.getCurrentData());
                source.setFilename(makeOutputFilename());
                pdf.markAsDirty();
              }
            });
    layout.addComponent(saveButton);
  }
Example #23
0
 private void buildAnalytics() {
   analytics = new CorrelatorPoolAnalytics(this, correlatorPool);
   mainLayout.addTab(analytics, "Analytics");
   analytics.setHeight("400px");
   analytics.setWidth("400px");
 }
Example #24
0
  private void buildWorkSpace() {
    mainLayout.addTab(workSpace, "Work Space");
    workSpace.setSizeFull();

    final TextField className = new TextField("Correlator Class Name");
    final TextArea classCode = new TextArea("Correlator Code");

    final TextField builderClassName = new TextField("Builder Class Name");
    final TextArea builderClassCode = new TextArea("Builder Code");

    final CheckBox withBuilder = new CheckBox("Correlator comes with builder?");
    withBuilder.setImmediate(true);
    withBuilder.addListener(
        new Property.ValueChangeListener() {
          public void valueChange(Property.ValueChangeEvent event) {
            if (withBuilder.booleanValue()) {
              builderClassName.setVisible(true);
              builderClassCode.setVisible(true);
            } else {
              builderClassName.setVisible(false);
              builderClassCode.setVisible(false);
            }
          }
        });

    final Button compile = new Button("Add Correlator");
    compile.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {

            if (!withBuilder.booleanValue()) {
              CorrelatorFromCodeFactory.createCorrelator(
                  (String) helper.getBean("classPath"),
                  className.getValue().toString(),
                  classCode.getValue().toString(),
                  correlatorBuilderManager,
                  feed,
                  correlatorPool,
                  null,
                  null,
                  null);
            } else {
              RuntimeJavaFileCompiler.compile(
                  (String) helper.getBean("classPath"),
                  className.getValue().toString(),
                  classCode.getValue().toString());
              CorrelatorBuilderFromCodeFactory.createCorrelatorBuilder(
                  (String) helper.getBean("classPath"),
                  builderClassName.getValue().toString(),
                  builderClassCode.getValue().toString(),
                  correlatorBuilderManager,
                  feed,
                  correlatorPool);
            }
          }
        });

    workSpace.addComponent(className);
    workSpace.addComponent(classCode);
    workSpace.addComponent(withBuilder);
    workSpace.addComponent(builderClassName);
    workSpace.addComponent(builderClassCode);
    builderClassName.setVisible(false);
    builderClassCode.setVisible(false);
    workSpace.addComponent(compile);

    classCode.setWidth("100%");
    classCode.setHeight("500px");
    builderClassCode.setWidth("100%");
    builderClassCode.setHeight("500px");
  }
  @Override
  protected void init(VaadinRequest request) {
    CssLayout rootLayout = new CssLayout();
    rootLayout.setSizeFull();
    setContent(rootLayout);

    TabSheet tabs = new TabSheet();
    tabs.setSizeFull();
    rootLayout.addComponent(tabs);

    VerticalLayout mapContent = new VerticalLayout();
    mapContent.setSizeFull();
    tabs.addTab(mapContent, "The map map");
    tabs.addTab(new Label("An another tab"), "The other tab");

    googleMap = new GoogleMap(null, null, null);
    googleMap.setCenter(new LatLon(60.440963, 22.25122));
    googleMap.setZoom(10);
    googleMap.setSizeFull();
    kakolaMarker.setAnimationEnabled(false);
    googleMap.addMarker(kakolaMarker);
    googleMap.addMarker(
        "DRAGGABLE: Paavo Nurmi Stadion",
        new LatLon(60.442423, 22.26044),
        true,
        "VAADIN/1377279006_stadium.png");
    googleMap.addMarker(
        "NOT DRAGGABLE: Iso-Heikkilä", new LatLon(60.450403, 22.230399), false, null);
    googleMap.setMinZoom(4);
    googleMap.setMaxZoom(16);

    kakolaInfoWindow.setWidth("400px");
    kakolaInfoWindow.setHeight("500px");

    mapContent.addComponent(googleMap);
    mapContent.setExpandRatio(googleMap, 1.0f);

    Panel console = new Panel();
    console.setHeight("100px");
    final CssLayout consoleLayout = new CssLayout();
    console.setContent(consoleLayout);
    mapContent.addComponent(console);

    HorizontalLayout buttonLayoutRow1 = new HorizontalLayout();
    buttonLayoutRow1.setHeight("26px");
    mapContent.addComponent(buttonLayoutRow1);

    HorizontalLayout buttonLayoutRow2 = new HorizontalLayout();
    buttonLayoutRow2.setHeight("26px");
    mapContent.addComponent(buttonLayoutRow2);

    OpenInfoWindowOnMarkerClickListener infoWindowOpener =
        new OpenInfoWindowOnMarkerClickListener(googleMap, kakolaMarker, kakolaInfoWindow);
    googleMap.addMarkerClickListener(infoWindowOpener);

    googleMap.addMarkerClickListener(
        new MarkerClickListener() {
          @Override
          public void markerClicked(GoogleMapMarker clickedMarker) {
            Label consoleEntry =
                new Label(
                    "Marker \""
                        + clickedMarker.getCaption()
                        + "\" at ("
                        + clickedMarker.getPosition().getLat()
                        + ", "
                        + clickedMarker.getPosition().getLon()
                        + ") clicked.");
            consoleLayout.addComponent(consoleEntry, 0);
          }
        });

    googleMap.addMapMoveListener(
        new MapMoveListener() {
          @Override
          public void mapMoved(int zoomLevel, LatLon center, LatLon boundsNE, LatLon boundsSW) {
            Label consoleEntry =
                new Label(
                    "Map moved to ("
                        + center.getLat()
                        + ", "
                        + center.getLon()
                        + "), zoom "
                        + zoomLevel
                        + ", boundsNE: ("
                        + boundsNE.getLat()
                        + ", "
                        + boundsNE.getLon()
                        + "), boundsSW: ("
                        + boundsSW.getLat()
                        + ", "
                        + boundsSW.getLon()
                        + ")");
            consoleLayout.addComponent(consoleEntry, 0);
          }
        });

    googleMap.addMapClickListener(
        new MapClickListener() {
          @Override
          public void mapClicked(LatLon position) {
            Label consoleEntry =
                new Label("Map click to (" + position.getLat() + ", " + position.getLon() + ")");
            consoleLayout.addComponent(consoleEntry, 0);
          }
        });

    googleMap.addMarkerDragListener(
        new MarkerDragListener() {
          @Override
          public void markerDragged(GoogleMapMarker draggedMarker, LatLon oldPosition) {
            Label consoleEntry =
                new Label(
                    "Marker \""
                        + draggedMarker.getCaption()
                        + "\" dragged from ("
                        + oldPosition.getLat()
                        + ", "
                        + oldPosition.getLon()
                        + ") to ("
                        + draggedMarker.getPosition().getLat()
                        + ", "
                        + draggedMarker.getPosition().getLon()
                        + ")");
            consoleLayout.addComponent(consoleEntry, 0);
          }
        });

    googleMap.addInfoWindowClosedListener(
        new InfoWindowClosedListener() {

          @Override
          public void infoWindowClosed(GoogleMapInfoWindow window) {
            Label consoleEntry = new Label("InfoWindow \"" + window.getContent() + "\" closed");
            consoleLayout.addComponent(consoleEntry, 0);
          }
        });

    Button moveCenterButton =
        new Button(
            "Move over Luonnonmaa (60.447737, 21.991668), zoom 12",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                googleMap.setCenter(new LatLon(60.447737, 21.991668));
                googleMap.setZoom(12);
              }
            });
    buttonLayoutRow1.addComponent(moveCenterButton);

    Button limitCenterButton =
        new Button(
            "Limit center between (60.619324, 22.712753), (60.373484, 21.945083)",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                googleMap.setCenterBoundLimits(
                    new LatLon(60.619324, 22.712753), new LatLon(60.373484, 21.945083));
                event.getButton().setEnabled(false);
              }
            });
    buttonLayoutRow1.addComponent(limitCenterButton);

    Button limitVisibleAreaButton =
        new Button(
            "Limit visible area between (60.494439, 22.397835), (60.373484, 21.945083)",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                googleMap.setVisibleAreaBoundLimits(
                    new LatLon(60.494439, 22.397835), new LatLon(60.420632, 22.138626));
                event.getButton().setEnabled(false);
              }
            });
    buttonLayoutRow1.addComponent(limitVisibleAreaButton);

    Button zoomToBoundsButton =
        new Button(
            "Zoom to bounds",
            new Button.ClickListener() {

              @Override
              public void buttonClick(ClickEvent event) {
                googleMap.fitToBounds(
                    new LatLon(60.45685853323144, 22.320034754486073),
                    new LatLon(60.4482979242303, 22.27887893936156));
              }
            });
    buttonLayoutRow1.addComponent(zoomToBoundsButton);
    Button addPolyOverlayButton =
        new Button(
            "Add overlay over Luonnonmaa",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                ArrayList<LatLon> points = new ArrayList<LatLon>();
                points.add(new LatLon(60.484715, 21.923706));
                points.add(new LatLon(60.446636, 21.941387));
                points.add(new LatLon(60.422496, 21.99546));
                points.add(new LatLon(60.427326, 22.06464));
                points.add(new LatLon(60.446467, 22.064297));

                GoogleMapPolygon overlay =
                    new GoogleMapPolygon(points, "#ae1f1f", 0.8, "#194915", 0.5, 3);
                googleMap.addPolygonOverlay(overlay);
                event.getButton().setEnabled(false);
              }
            });
    buttonLayoutRow2.addComponent(addPolyOverlayButton);

    Button addPolyLineButton =
        new Button(
            "Draw line from Turku to Raisio",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                ArrayList<LatLon> points = new ArrayList<LatLon>();
                points.add(new LatLon(60.448118, 22.253738));
                points.add(new LatLon(60.455144, 22.24198));
                points.add(new LatLon(60.460222, 22.211939));
                points.add(new LatLon(60.488224, 22.174602));
                points.add(new LatLon(60.486025, 22.169195));

                GoogleMapPolyline overlay = new GoogleMapPolyline(points, "#d31717", 0.8, 10);
                googleMap.addPolyline(overlay);
                event.getButton().setEnabled(false);
              }
            });
    buttonLayoutRow2.addComponent(addPolyLineButton);
    Button addPolyLineButton2 =
        new Button(
            "Draw line from Turku to Raisio2",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                ArrayList<LatLon> points2 = new ArrayList<LatLon>();
                points2.add(new LatLon(60.448118, 22.253738));
                points2.add(new LatLon(60.486025, 22.169195));
                GoogleMapPolyline overlay2 = new GoogleMapPolyline(points2, "#d31717", 0.8, 10);
                googleMap.addPolyline(overlay2);
                event.getButton().setEnabled(false);
              }
            });
    buttonLayoutRow2.addComponent(addPolyLineButton2);
    Button changeToTerrainButton =
        new Button(
            "Change to terrain map",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                googleMap.setMapType(GoogleMap.MapType.Terrain);
                event.getButton().setEnabled(false);
              }
            });
    buttonLayoutRow2.addComponent(changeToTerrainButton);

    Button changeControls =
        new Button(
            "Remove street view control",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                googleMap.removeControl(GoogleMapControl.StreetView);
                event.getButton().setEnabled(false);
              }
            });
    buttonLayoutRow2.addComponent(changeControls);

    Button addInfoWindowButton =
        new Button(
            "Add InfoWindow to Kakola marker",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                googleMap.openInfoWindow(kakolaInfoWindow);
              }
            });
    buttonLayoutRow2.addComponent(addInfoWindowButton);

    Button moveMarkerButton =
        new Button(
            "Move kakola marker",
            new Button.ClickListener() {

              @Override
              public void buttonClick(ClickEvent event) {
                kakolaMarker.setPosition(new LatLon(60.3, 22.242415));
                googleMap.addMarker(kakolaMarker);
              }
            });
    buttonLayoutRow2.addComponent(moveMarkerButton);

    Button addKmlLayerButton =
        new Button(
            "Add KML layer",
            new Button.ClickListener() {

              @Override
              public void buttonClick(ClickEvent event) {
                googleMap.addKmlLayer(
                    new GoogleMapKmlLayer(
                        "http://maps.google.it/maps/"
                            + "ms?authuser=0&ie=UTF8&hl=it&oe=UTF8&msa=0&"
                            + "output=kml&msid=212897908682884215672.0004ecbac547d2d635ff5"));
              }
            });
    buttonLayoutRow2.addComponent(addKmlLayerButton);

    Button clearMarkersButton =
        new Button(
            "Remove all markers",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent clickEvent) {
                googleMap.clearMarkers();
              }
            });
    buttonLayoutRow2.addComponent(clearMarkersButton);
  }
  public void buildView() {

    // PANEL
    panelUtamaList.setSizeFull();
    panelUtamaDetil.setSizeFull();
    panelFormDetil.setSizeFull();
    content.setSizeFull();

    tabSheet.setSizeFull();

    // ::LIST
    layoutList.setSizeFull();
    layoutList.setMargin(true);
    VerticalLayout layoutTopList = new VerticalLayout();
    HorizontalLayout layoutTopList1 = new HorizontalLayout();
    layoutTopList.addComponent(layoutTopList1);

    layoutTopList1.addComponent(fieldSearch1);
    //		layoutTopList1.addComponent(fieldSearch2);
    layoutTopList1.addComponent(btnSearch);
    layoutTopList1.setComponentAlignment(btnSearch, Alignment.BOTTOM_CENTER);

    tableList.setSizeFull();

    VerticalLayout layoutMiddleList = new VerticalLayout();
    layoutMiddleList.setSizeFull();
    layoutMiddleList.addComponent(tableList);

    layoutList.addComponent(layoutTopList);
    layoutList.addComponent(layoutMiddleList);
    layoutList.setExpandRatio(layoutMiddleList, 1);

    // :::DETIL
    layoutDetil.setSizeFull();
    layoutDetil.setMargin(true);
    // KOMPONEN ATAS
    VerticalLayout layoutTopDetil = new VerticalLayout();
    HorizontalLayout layoutTopDetil1 = new HorizontalLayout();
    HorizontalLayout layoutTopDetil2 = new HorizontalLayout();
    layoutTopDetil.addComponent(layoutTopDetil1);
    layoutTopDetil.addComponent(layoutTopDetil2);
    layoutTopDetil.setComponentAlignment(layoutTopDetil2, Alignment.MIDDLE_RIGHT);

    layoutTopDetil1.addComponent(fieldNomor);
    //		layoutTopDetil1.addComponent(fieldInvoiceno);
    //		layoutTopDetil1.addComponent(comboTipeopname);
    layoutTopDetil1.addComponent(dateFieldTrdate);
    layoutTopDetil1.addComponent(dateFieldEntrydate);
    //		layoutTopDetil1.addComponent(comboWarehouse);
    //		layoutTopDetil1.addComponent(comboWarehouseTo);
    //		layoutTopDetil1.addComponent(checkSaldo);
    layoutTopDetil1.addComponent(checkPosting);
    layoutTopDetil1.addComponent(checkEndofday);

    layoutTopDetil2.addComponent(btnNewForm);
    layoutTopDetil2.addComponent(btnEditForm);
    layoutTopDetil2.addComponent(btnDeleteForm);
    layoutTopDetil2.addComponent(btnPosting);
    //		layoutTopDetil2.addComponent(btnLapselisih);
    layoutTopDetil2.addComponent(btnPostingBatal);

    layoutTopDetil2.addComponent(btnSeparator1);

    layoutTopDetil2.addComponent(btnSaveForm);
    layoutTopDetil2.addComponent(btnCancelForm);

    layoutTopDetil2.addComponent(btnSeparator2);

    layoutTopDetil2.addComponent(btnAddItem);
    layoutTopDetil2.addComponent(btnEditItem);
    layoutTopDetil2.addComponent(btnRemoveItem);

    layoutTopDetil2.setComponentAlignment(btnNewForm, Alignment.BOTTOM_CENTER);
    layoutTopDetil2.setComponentAlignment(btnEditForm, Alignment.BOTTOM_CENTER);
    layoutTopDetil2.setComponentAlignment(btnDeleteForm, Alignment.BOTTOM_CENTER);
    layoutTopDetil2.setComponentAlignment(btnPosting, Alignment.BOTTOM_CENTER);
    //		layoutTopDetil2.setComponentAlignment(btnLapselisih, Alignment.BOTTOM_CENTER);

    // KOMPONEN TENGAH
    // INIT COMPONENT TENGAH
    tableDetil.setSizeFull();

    VerticalLayout layoutMiddleDetil = new VerticalLayout();
    layoutMiddleDetil.setSizeFull();
    layoutMiddleDetil.addComponent(tableDetil);

    HorizontalLayout layoutBottomDetil = new HorizontalLayout();
    FormLayout layoutBottomDetil1 = new FormLayout();
    //		layoutBottomDetil1.setSizeFull();
    layoutBottomDetil1.addComponent(fieldAmount);
    layoutBottomDetil1.addComponent(fieldAmountafterppn);

    HorizontalLayout layoutDisc1 = new HorizontalLayout();
    layoutDisc1.setCaption("Diskon1");
    layoutDisc1.addComponent(fieldDisc1);
    layoutDisc1.addComponent(fieldDisc1rp);
    layoutDisc1.addComponent(fieldDisc1rpafterppn);
    //		layoutBottomDetil1.addComponent(layoutDisc1);

    HorizontalLayout layoutDisc2 = new HorizontalLayout();
    //		layoutDisc2.setCaption("Diskon2");
    layoutDisc2.addComponent(fieldDisc2);
    layoutDisc2.addComponent(fieldDisc2rp);
    layoutDisc2.addComponent(fieldDisc2rpafterppn);

    HorizontalLayout layoutDisc = new HorizontalLayout();
    layoutDisc.setCaption("+Disc");
    layoutDisc.addComponent(fieldDisc);
    layoutDisc.addComponent(fieldDiscrp);
    layoutDisc.addComponent(fieldDiscrpafterppn);
    //		layoutBottomDetil1.addComponent(layoutDisc);

    layoutBottomDetil1.addComponent(fieldAmountafterdisc);
    layoutBottomDetil1.addComponent(fieldPpnpercent);
    layoutBottomDetil1.addComponent(fieldPpnrp);
    layoutBottomDetil1.addComponent(fieldAmountafterdiscafterppn);
    layoutBottomDetil1.addComponent(fieldAmountpay);
    layoutBottomDetil1.addComponent(fieldAmountpayfaterppn);

    layoutBottomDetil.addComponent(layoutBottomDetil1);

    layoutDetil.addComponent(layoutTopDetil);
    layoutDetil.addComponent(layoutMiddleDetil);
    layoutDetil.addComponent(layoutBottomDetil);
    layoutDetil.setExpandRatio(layoutMiddleDetil, 1);
    layoutDetil.setExpandRatio(layoutMiddleDetil, 1);
    layoutDetil.setComponentAlignment(layoutBottomDetil, Alignment.TOP_RIGHT);

    panelUtamaList.setContent(layoutList);
    panelUtamaDetil.setContent(layoutDetil);

    tabSheet.addTab(panelUtamaList, "LIST");
    tabSheet.addTab(panelUtamaDetil, "DETIL");

    content.addComponent(tabSheet);
    setCompositionRoot(content);
  }
Example #27
0
  private void buildFeedControl() {
    mainLayout.addTab(feedControl, "Feed Management");
    feedControl.setSizeFull();

    HorizontalLayout h1 = new HorizontalLayout();
    final TextField feedPath = new TextField("Feeds Folder:");
    h1.addComponent(feedPath);
    final Button updateFeedPath = new Button("Update");
    h1.addComponent(updateFeedPath);
    h1.setComponentAlignment(updateFeedPath, Alignment.BOTTOM_RIGHT);
    feedControl.addComponent(h1);

    updateFeedPath.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            feed.reset();
            feedsPath = feedPath.getValue().toString();
            feed.setFeedsPath(feedsPath);
            buildFeedSelect();
          }
        });

    HorizontalLayout h2 = new HorizontalLayout();
    final Select pairSelect = buildPairSelect();
    h2.addComponent(pairSelect);
    h2.addComponent(feedSelect);
    final Button addPairFeed = new Button("Add");
    h2.addComponent(addPairFeed);
    h2.setComponentAlignment(addPairFeed, Alignment.BOTTOM_RIGHT);
    feedControl.addComponent(h2);

    addPairFeed.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            feed.addPairFeed((Pair) pairSelect.getValue(), feedSelect.getValue().toString());
          }
        });

    HorizontalLayout h3 = new HorizontalLayout();
    final TextField maxPopulation = new TextField("Maximum Population:");
    maxPopulation.setValue("200");
    h3.addComponent(maxPopulation);
    final Button updateMaxPop = new Button("Update");
    h3.addComponent(updateMaxPop);
    h3.setComponentAlignment(updateMaxPop, Alignment.BOTTOM_RIGHT);
    feedControl.addComponent(h3);

    updateMaxPop.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            correlatorPool.setMaxPopulation(Integer.parseInt(maxPopulation.getValue().toString()));
          }
        });

    final Button startSim = new Button("Start Learning");

    feedControl.addComponent(startSim);

    startSim.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            try {
              emulator.startEmulation();
              // emulator.run();
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });

    final Button endSim = new Button("End Learning");

    feedControl.addComponent(endSim);

    endSim.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            try {
              emulator.die();
              // emulator.stop();
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });

    final Button pauseFeed = new Button("Pause Feed");

    feedControl.addComponent(pauseFeed);

    pauseFeed.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            feed.pause();
          }
        });

    final Button resumeFeed = new Button("Resume Feed");

    feedControl.addComponent(resumeFeed);

    resumeFeed.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            feed.resume();
          }
        });

    final Button testInit = new Button("Use Test Init");

    feedControl.addComponent(testInit);

    testInit.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            feed.reset();
            feedsPath = "C:\\Users\\Oblene\\Desktop\\Sandbox\\Data";
            // feedsPath = "/app/testing/hans/WebApps/Data";
            feed.setFeedsPath(feedsPath);
            buildFeedSelect();

            feed.addPairFeed(Pair.EURUSD, "EURUSD_5 Mins_Bid_2008.01.01_2012.12.31.csv");
            feed.addPairFeed(Pair.GBPUSD, "GBPUSD_5 Mins_Bid_2008.01.01_2012.12.31.csv");
            feed.addPairFeed(Pair.USDCHF, "USDCHF_5 Mins_Bid_2008.01.01_2012.12.31.csv");
            // feed.addPairFeed(Pair.USDJPY, "USDJPY_5 Mins_Bid_2008.01.01_2012.12.31.csv");
            feed.addPairFeed(Pair.AUDUSD, "AUDUSD_5 Mins_Bid_2008.01.01_2012.12.31.csv");
            feed.addPairFeed(Pair.NZDUSD, "NZDUSD_5 Mins_Bid_2008.01.01_2012.12.31.csv");
            feed.addCalendarFeed("Calendar_2008.csv");

            CorrelatorFromCodeFactory.createCorrelator(
                (String) helper.getBean("classPath"),
                "MovingAverageCorrelator",
                "import com.bluesmoke.farm.correlator.CorrelatorPool;\n"
                    + "import com.bluesmoke.farm.correlator.GenericCorrelator;\n"
                    + "import com.bluesmoke.farm.correlator.builder.CorrelatorBuilderManager;\n"
                    + "import com.bluesmoke.farm.model.tickdata.Tick;\n"
                    + "import com.bluesmoke.farm.service.feed.FeedService;\n"
                    + "import com.bluesmoke.farm.enumeration.PairResolution;\n"
                    + "import com.bluesmoke.farm.enumeration.Pair;\n"
                    + "\n"
                    + "import java.util.HashMap;\n"
                    + "import java.util.TreeMap;\n"
                    + "import java.util.Random;\n"
                    + "\n"
                    + "public class MovingAverageCorrelator extends GenericCorrelator{\n"
                    + "\n"
                    + "    private int refresh = 0;\n"
                    + "    private double ma;\n"
                    + "    private double sum = 0;\n"
                    + "    private Pair statePair;"
                    + "    private double statePairResolution;"
                    + "\n"
                    + "    public MovingAverageCorrelator(String id, CorrelatorBuilderManager correlatorBuilderManager, CorrelatorPool pool, FeedService feed, GenericCorrelator aggressiveParent, GenericCorrelator passiveParent, HashMap<String, Object> config)\n"
                    + "    {\n"
                    + "        super(\"MovingAverage_\" + pool.getNextID(), correlatorBuilderManager, pool, feed, aggressiveParent, passiveParent, config);\n"
                    + "        Random rand = new Random();\n"
                    + "        this.config.put(\"price_type\", rand.nextInt(4));\n"
                    + "        TreeMap<Double, Pair> randMap = new TreeMap<Double, Pair>();\n"
                    + "        for(Pair pair : Pair.values())\n"
                    + "        {\n"
                    + "            randMap.put(Math.random(), pair);\n"
                    + "        }\n"
                    + "\n"
                    + "        statePair = randMap.firstEntry().getValue();"
                    + "        this.config.put(\"statePair\", statePair);\n"
                    + "        statePairResolution = PairResolution.getResolution(statePair);\n"
                    + "        this.config.put(\"statePairResolution\", statePairResolution);"
                    + "    }\n"
                    + "\n"
                    + "\n"
                    + "    @Override\n"
                    + "    public void createMutant() {\n"
                    + "        new MovingAverageCorrelator(\"MovingAverage_\" + pool.getNextID(), correlatorBuilderManager, pool, feed, null, null, config);\n"
                    + "    }\n"
                    + "\n"
                    + "    @Override\n"
                    + "    public String createState() {\n"
                    + "\n"
                    + "        if(refresh == 0)\n"
                    + "        {\n"
                    + "            refresh = 1000;\n"
                    + "            sum = 0;\n"
                    + "            boolean passedFirst = false;\n"
                    + "            for(Tick tick : ticks)\n"
                    + "            {\n"
                    + "                   double price = 0;\n"
                    + "                   switch ((Integer)config.get(\"price_type\"))\n"
                    + "                   {\n"
                    + "                       case 0:\n"
                    + "                           price = tick.getPairData(statePair.name()).getOpen();\n"
                    + "                           break;\n"
                    + "                       case 1:\n"
                    + "                           price = tick.getPairData(statePair.name()).getClose();\n"
                    + "                           break;\n"
                    + "                       case 2:\n"
                    + "                           price = tick.getPairData(statePair.name()).getHigh();\n"
                    + "                           break;\n"
                    + "                       case 3:\n"
                    + "                           price = tick.getPairData(statePair.name()).getLow();\n"
                    + "                           break;\n"
                    + "                   }"
                    + "                if(passedFirst)\n"
                    + "                {\n"
                    + "                    sum += price;\n"
                    + "                }\n"
                    + "                else {\n"
                    + "                    passedFirst = true;\n"
                    + "                }\n"
                    + "            }\n"
                    + "            ma = sum/(ticks.size() - 1);\n"
                    + "        }\n"
                    + "        else {\n"
                    + "           double priceRemove = 0;"
                    + "           double priceAdd = 0;"
                    + "           switch ((Integer)config.get(\"price_type\"))\n"
                    + "                   {\n"
                    + "                       case 0:\n"
                    + "                           priceRemove = ticks.get(0).getPairData(statePair.name()).getOpen();\n"
                    + "                           priceAdd = currentTick.getPairData(statePair.name()).getOpen();\n"
                    + "                           break;\n"
                    + "                       case 1:\n"
                    + "                           priceRemove = ticks.get(0).getPairData(statePair.name()).getClose();\n"
                    + "                           priceAdd = currentTick.getPairData(statePair.name()).getClose();\n"
                    + "                           break;\n"
                    + "                       case 2:\n"
                    + "                           priceRemove = ticks.get(0).getPairData(statePair.name()).getHigh();\n"
                    + "                           priceAdd = currentTick.getPairData(statePair.name()).getHigh();\n"
                    + "                           break;\n"
                    + "                       case 3:\n"
                    + "                           priceRemove = ticks.get(0).getPairData(statePair.name()).getLow();\n"
                    + "                           priceAdd = currentTick.getPairData(statePair.name()).getLow();\n"
                    + "                           break;\n"
                    + "                   }"
                    + "            sum -= priceRemove;\n"
                    + "            sum += priceAdd;\n"
                    + "            ma = sum/(ticks.size() - 1);\n"
                    + "        }\n"
                    + "        currentUnderlyingComponents.put(\"MA\", ma);\n"
                    + "        refresh--;\n"
                    + "        return \"\" + (int)(ma/(100 * statePairResolution));\n"
                    + "    }\n"
                    + "}\n",
                correlatorBuilderManager,
                feed,
                correlatorPool,
                null,
                null,
                null);

            CorrelatorFromCodeFactory.createCorrelator(
                (String) helper.getBean("classPath"),
                "PriceCorrelator",
                "import com.bluesmoke.farm.correlator.CorrelatorPool;\n"
                    + "import com.bluesmoke.farm.correlator.GenericCorrelator;\n"
                    + "import com.bluesmoke.farm.correlator.builder.CorrelatorBuilderManager;\n"
                    + "import com.bluesmoke.farm.model.tickdata.Tick;\n"
                    + "import com.bluesmoke.farm.service.feed.FeedService;\n"
                    + "import com.bluesmoke.farm.enumeration.PairResolution;\n"
                    + "import com.bluesmoke.farm.enumeration.Pair;\n"
                    + "\n"
                    + "import java.util.HashMap;\n"
                    + "import java.util.TreeMap;\n"
                    + "import java.util.Random;\n"
                    + "\n"
                    + "public class PriceCorrelator extends GenericCorrelator{\n"
                    + "\n"
                    + "    private Pair statePair;"
                    + "    private double statePairResolution;"
                    + "    public PriceCorrelator(String id, CorrelatorBuilderManager correlatorBuilderManager, CorrelatorPool pool, FeedService feed, GenericCorrelator aggressiveParent, GenericCorrelator passiveParent, HashMap<String, Object> config)\n"
                    + "    {\n"
                    + "        super(\"Price_\" + pool.getNextID(), correlatorBuilderManager, pool, feed, aggressiveParent, passiveParent, config);\n"
                    + "        Random rand = new Random();\n"
                    + "        this.config.put(\"price_type\", rand.nextInt(4));\n"
                    + "        "
                    + "        TreeMap<Double, Pair> randMap = new TreeMap<Double, Pair>();\n"
                    + "        for(Pair pair : Pair.values())\n"
                    + "        {\n"
                    + "            randMap.put(Math.random(), pair);\n"
                    + "        }\n"
                    + "\n"
                    + "        statePair = randMap.firstEntry().getValue();"
                    + "        this.config.put(\"statePair\", statePair);\n"
                    + "        statePairResolution = PairResolution.getResolution(statePair);\n"
                    + "        this.config.put(\"statePairResolution\", statePairResolution);"
                    + "    }\n"
                    + "\n"
                    + "\n"
                    + "    @Override\n"
                    + "    public void createMutant() {\n"
                    + "        new PriceCorrelator(\"Price_\" + pool.getNextID(), correlatorBuilderManager, pool, feed, null, null, config);\n"
                    + "    }\n"
                    + "\n"
                    + "    @Override\n"
                    + "    public String createState() {\n"
                    + "\n"
                    + "        double price = 0;\n"
                    + "        switch ((Integer)config.get(\"price_type\"))\n"
                    + "        {\n"
                    + "            case 0:\n"
                    + "                price = currentTick.getPairData(statePair.name()).getOpen();\n"
                    + "                break;\n"
                    + "            case 1:\n"
                    + "                price = currentTick.getPairData(statePair.name()).getClose();\n"
                    + "                break;\n"
                    + "            case 2:\n"
                    + "                price = currentTick.getPairData(statePair.name()).getHigh();\n"
                    + "                break;\n"
                    + "            case 3:\n"
                    + "                price = currentTick.getPairData(statePair.name()).getLow();\n"
                    + "                break;\n"
                    + "        }\n"
                    + "        currentUnderlyingComponents.put(\"price\", price);\n"
                    + "        return \"\" + (int)(price/(10 * statePairResolution));\n"
                    + "    }\n"
                    + "}\n",
                correlatorBuilderManager,
                feed,
                correlatorPool,
                null,
                null,
                null);
          }
        });

    final Button checkPool = new Button("Check Pool");

    feedControl.addComponent(checkPool);

    checkPool.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            System.out.println(correlatorPool.getHandlesInfo());
          }
        });
  }
Example #28
0
 private void assembleInputUserLayout() {
   logger.info(
       "Company ID : "
           + companyid
           + " | User Name : "
           + username
           + " > "
           + "Assembling search layout");
   // Remove all components in search layout
   hlUserInputLayout.removeAllComponents();
   flSmsPurHdr1 = new FormLayout();
   flSmsPurHdr2 = new FormLayout();
   flSmsPurHdr3 = new FormLayout();
   flSmsPurHdr4 = new FormLayout();
   flSmsPurHdr1.addComponent(tfEnqNo);
   flSmsPurHdr1.addComponent(cbBranch);
   flSmsPurHdr2.addComponent(lsVendorName);
   cbEnqStatus.setWidth("130px");
   cbEnqStatus.setHeight("24px");
   flSmsPurHdr3.addComponent(dfEnqDate);
   flSmsPurHdr3.addComponent(dfDueDate);
   flSmsPurHdr3.addComponent(cbEnqStatus);
   flSmsPurHdr4.addComponent(taEnqRem);
   HorizontalLayout hlSmsEnqHDR = new HorizontalLayout();
   hlSmsEnqHDR.addComponent(flSmsPurHdr1);
   hlSmsEnqHDR.addComponent(flSmsPurHdr2);
   hlSmsEnqHDR.addComponent(flSmsPurHdr3);
   lbl = new Label(" ");
   hlSmsEnqHDR.addComponent(lbl);
   hlSmsEnqHDR.addComponent(flSmsPurHdr4);
   tfEnqNo.setReadOnly(true);
   hlSmsEnqHDR.setSpacing(true);
   hlSmsEnqHDR.setMargin(true);
   // Adding SmsEnqDtl components
   // Add components for User Input Layout
   flSmsPurDtl1 = new FormLayout();
   flSmsPurDtl2 = new FormLayout();
   flSmsPurDtl3 = new FormLayout();
   flSmsPurDtl4 = new FormLayout();
   flSmsPurDtl5 = new FormLayout();
   flSmsPurDtl6 = new FormLayout();
   flSmsPurDtl1.addComponent(lsProduct);
   HorizontalLayout hlQtyUom = new HorizontalLayout();
   hlQtyUom.addComponent(tfEnqQty);
   hlQtyUom.addComponent(cbUom);
   hlQtyUom.setCaption("Enquiry Qty");
   flSmsPurDtl2.addComponent(hlQtyUom);
   flSmsPurDtl2.setComponentAlignment(hlQtyUom, Alignment.TOP_LEFT);
   flSmsPurDtl4.addComponent(taEnqDtlRem);
   flSmsPurDtl5.addComponent(cbEnqDtlStatus);
   VerticalLayout btn = new VerticalLayout();
   btn.addComponent(btnaddSpec);
   btn.addComponent(btndelete);
   flSmsPurDtl5.addComponent(btn);
   HorizontalLayout hlSmsEnqdTL = new HorizontalLayout();
   hlSmsEnqdTL.addComponent(flSmsPurDtl1);
   hlSmsEnqdTL.addComponent(flSmsPurDtl2);
   hlSmsEnqdTL.addComponent(flSmsPurDtl3);
   hlSmsEnqdTL.addComponent(flSmsPurDtl4);
   hlSmsEnqdTL.addComponent(flSmsPurDtl5);
   hlSmsEnqdTL.addComponent(flSmsPurDtl6);
   hlSmsEnqdTL.setSpacing(true);
   hlSmsEnqdTL.setMargin(true);
   VerticalLayout vlSmsEnqHDR = new VerticalLayout();
   vlSmsEnqHDR = new VerticalLayout();
   vlSmsEnqHDR.addComponent(hlSmsEnqdTL);
   vlSmsEnqHDR.addComponent(tblSmsEnqDtl);
   vlSmsEnqHDR.setSpacing(true);
   TabSheet dtlTab = new TabSheet();
   dtlTab.addTab(vlSmsEnqHDR, "Purchase Enquiry Detail");
   dtlTab.addTab(vlTableForm, "Comments");
   VerticalLayout vlSmsEnqHdrdTL = new VerticalLayout();
   vlSmsEnqHdrdTL = new VerticalLayout();
   vlSmsEnqHdrdTL.addComponent(GERPPanelGenerator.createPanel(hlSmsEnqHDR));
   vlSmsEnqHdrdTL.addComponent(GERPPanelGenerator.createPanel(dtlTab));
   vlSmsEnqHdrdTL.setSpacing(true);
   vlSmsEnqHdrdTL.setWidth("100%");
   hlUserInputLayout.addComponent(vlSmsEnqHdrdTL);
   hlUserInputLayout.setSizeFull();
   hlUserInputLayout.setWidth("100%");
   hlUserInputLayout.setMargin(false);
   hlUserInputLayout.setSpacing(true);
 }