コード例 #1
0
  /* (non-Javadoc)
   * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
   */
  @Override
  public ISecurity unmarshal(String v) throws Exception {
    if (v == null) {
      return null;
    }

    URI uri = new URI(v);
    if (repositoryService == null) {
      try {
        BundleContext context = CoreActivator.getDefault().getBundle().getBundleContext();
        ServiceReference serviceReference =
            context.getServiceReference(IRepositoryService.class.getName());
        repositoryService = (IRepositoryService) context.getService(serviceReference);
        context.ungetService(serviceReference);
      } catch (Exception e) {
        Status status =
            new Status(
                IStatus.ERROR, CoreActivator.PLUGIN_ID, 0, "Error reading repository service", e);
        CoreActivator.log(status);
      }
    }

    ISecurity security =
        repositoryService != null ? repositoryService.getSecurityFromURI(uri) : null;
    if (security == null) {
      Status status =
          new Status(
              IStatus.WARNING,
              CoreActivator.PLUGIN_ID,
              0,
              "Failed to load security " + uri.toString(),
              null);
      CoreActivator.log(status);
      return new FailsafeSecurity(uri);
    }

    return security;
  }
コード例 #2
0
  /* (non-Javadoc)
   * @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite, org.eclipse.ui.IMemento)
   */
  @Override
  public void init(IViewSite site, IMemento memento) throws PartInitException {
    super.init(site, memento);

    this.memento = memento;
    this.preferenceStore = UIActivator.getDefault().getPreferenceStore();

    try {
      dialogSettings =
          UIActivator.getDefault()
              .getDialogSettings()
              .getSection(K_VIEWS)
              .getSection(site.getSecondaryId());
      uri = new URI(dialogSettings.get(K_URI));

      IRepositoryService repositoryService = UIActivator.getDefault().getRepositoryService();
      security = repositoryService.getSecurityFromURI(uri);

      String privateTemplate = dialogSettings.get(K_PRIVATE_TEMPLATE);
      if (privateTemplate != null) {
        template = unmarshal(privateTemplate);
      }

      if (template == null) {
        IPath templatePath = new Path("data"); // $NON-NLS-1$
        if (dialogSettings.get(K_TEMPLATE) != null) {
          templatePath = templatePath.append(dialogSettings.get(K_TEMPLATE));
        } else {
          templatePath = templatePath.append("basic-template.xml");
        }
        InputStream stream =
            FileLocator.openStream(UIActivator.getDefault().getBundle(), templatePath, false);
        template = unmarshal(stream);
      }
    } catch (Exception e) {
      Status status =
          new Status(
              IStatus.ERROR,
              UIActivator.PLUGIN_ID,
              Messages.ChartViewPart_LoadingErrorMessage + site.getSecondaryId(),
              e);
      UIActivator.getDefault().getLog().log(status);
    }

    site.setSelectionProvider(new SelectionProvider());

    createActions();
    createPeriodActions();

    IActionBars actionBars = site.getActionBars();

    IMenuManager menuManager = actionBars.getMenuManager();
    menuManager.add(new Separator("periods.top")); // $NON-NLS-1$
    menuManager.add(new Separator("periods")); // $NON-NLS-1$
    menuManager.add(new Separator("periods.bottom")); // $NON-NLS-1$
    menuManager.add(currentPriceLineAction);
    menuManager.add(currentBookAction);

    menuManager.appendToGroup("periods.top", periodAllAction); // $NON-NLS-1$
    if (periodActions != null) {
      for (int i = 0; i < periodActions.length; i++) {
        menuManager.appendToGroup("periods", periodActions[i]);
      }
    }

    IToolBarManager toolBarManager = actionBars.getToolBarManager();
    toolBarManager.add(new Separator("additions")); // $NON-NLS-1$
    toolBarManager.add(updateAction);

    TimeSpan periodTimeSpan = TimeSpan.fromString(dialogSettings.get(K_PERIOD));
    TimeSpan resolutionTimeSpan = TimeSpan.fromString(dialogSettings.get(K_RESOLUTION));
    setPeriodActionSelection(periodTimeSpan, resolutionTimeSpan);

    actionBars.setGlobalActionHandler(cutAction.getId(), cutAction);
    actionBars.setGlobalActionHandler(copyAction.getId(), copyAction);
    actionBars.setGlobalActionHandler(pasteAction.getId(), pasteAction);
    actionBars.setGlobalActionHandler(deleteAction.getId(), deleteAction);

    actionBars.setGlobalActionHandler(ActionFactory.PRINT.getId(), printAction);

    ToolAction toolAction =
        new ToolAction(
            Messages.ChartViewPart_LineAction, this, "org.eclipsetrader.ui.charts.tools.line");
    actionBars.setGlobalActionHandler(toolAction.getId(), toolAction);
    toolAction =
        new ToolAction(
            Messages.ChartViewPart_FiboLineAction,
            this,
            "org.eclipsetrader.ui.charts.tools.fiboline");
    actionBars.setGlobalActionHandler(toolAction.getId(), toolAction);
    toolAction =
        new ToolAction(
            Messages.ChartViewPart_FanLineAction,
            this,
            "org.eclipsetrader.ui.charts.tools.fanline");
    actionBars.setGlobalActionHandler(toolAction.getId(), toolAction);
    toolAction =
        new ToolAction(
            Messages.ChartViewPart_FiboArcAction,
            this,
            "org.eclipsetrader.ui.charts.tools.fiboarc");
    actionBars.setGlobalActionHandler(toolAction.getId(), toolAction);

    actionBars.setGlobalActionHandler(zoomInAction.getActionDefinitionId(), zoomInAction);
    actionBars.setGlobalActionHandler(zoomOutAction.getActionDefinitionId(), zoomOutAction);
    actionBars.setGlobalActionHandler(zoomResetAction.getActionDefinitionId(), zoomResetAction);
    actionBars.setGlobalActionHandler(propertiesAction.getId(), propertiesAction);
    actionBars.updateActionBars();
  }