示例#1
0
  public TreeMapLegend(
      Composite parent,
      TreeMap<TaxonomyNode> treeMap,
      TaxonomyModel model,
      TaxonomyNodeRenderer renderer) {
    super(parent, SWT.NONE);

    this.model = model;
    this.renderer = renderer;

    setBackground(parent.getBackground());

    RowLayout layout = new RowLayout(SWT.HORIZONTAL);
    layout.wrap = true;
    layout.pack = true;
    layout.justify = false;
    setLayout(layout);

    treeMap.addSelectionChangeListener(
        new ISelectionChangeListener<TaxonomyNode>() {
          @Override
          public void selectionChanged(
              ITreeModel<IRectangle<TaxonomyNode>> model,
              IRectangle<TaxonomyNode> rectangle,
              String label) {
            TreeMapLegend.this.selectionChanged(model);
          }
        });
  }
示例#2
0
  /** This method initializes compButtons */
  protected void createCompButtons() {
    compButton = new Composite(getShell(), SWT.NONE);
    compButton.setBounds(new Rectangle(100, 520, 700, 40));
    RowLayout rowLayout = new RowLayout();
    rowLayout.wrap = false;
    rowLayout.pack = false;
    rowLayout.justify = true;
    rowLayout.type = SWT.HORIZONTAL;
    rowLayout.spacing = 0;
    compButton.setLayout(rowLayout);
    btnIedeaExport = new Button(compButton, SWT.NONE);
    btnIedeaExport.setText(Messages.getString("NewReports.button.export.iedea")); // $NON-NLS-1$
    btnIedeaExport.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    btnIedeaExport.setLayoutData(new RowData(200, 30));
    btnIedeaExport.setToolTipText(
        Messages.getString("NewReports.button.export.tooltip.iedea")); // $NON-NLS-1$
    btnIedeaExport.addSelectionListener(
        new org.eclipse.swt.events.SelectionAdapter() {
          @Override
          public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            cmdIedeaExportsSelected();
          }
        });

    btnDataExport = new Button(compButton, SWT.NONE);
    btnDataExport.setText(Messages.getString("NewReports.button.export")); // $NON-NLS-1$
    btnDataExport.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    btnDataExport.setLayoutData(new RowData(200, 30));
    btnDataExport.setToolTipText(
        Messages.getString("NewReports.button.export.tooltip")); // $NON-NLS-1$
    btnDataExport.addSelectionListener(
        new org.eclipse.swt.events.SelectionAdapter() {
          @Override
          public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            cmdDataExportsSelected();
          }
        });

    btnDataQuality = new Button(compButton, SWT.NONE);
    btnDataQuality.setText(Messages.getString("NewReports.button.dataQuality")); // $NON-NLS-1$
    btnDataQuality.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    btnDataQuality.setLayoutData(new RowData(200, 30));
    btnDataQuality.setToolTipText(
        Messages.getString("NewReports.button.dataQuality.tooltip")); // $NON-NLS-1$
    btnDataQuality.addSelectionListener(
        new org.eclipse.swt.events.SelectionAdapter() {
          @Override
          public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            cmdDataQualitySelected();
          }
        });
    compButton.layout();
  }
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    RowLayout layout = new RowLayout(SWT.HORIZONTAL);
    layout.wrap = true;
    layout.fill = false;
    layout.justify = true;
    shell.setLayout(layout);

    Button b = new Button(shell, SWT.PUSH);
    b.setText("Button 1");
    b = new Button(shell, SWT.PUSH);

    b.setText("Button 2");

    b = new Button(shell, SWT.PUSH);
    b.setText("Button 3");

    b = new Button(shell, SWT.PUSH);
    b.setText("Not shown");
    b.setVisible(false);
    RowData data = new RowData();
    data.exclude = true;
    b.setLayoutData(data);

    b = new Button(shell, SWT.PUSH);
    b.setText("Button 200 high");
    data = new RowData();
    data.height = 200;
    b.setLayoutData(data);

    b = new Button(shell, SWT.PUSH);
    b.setText("Button 200 wide");
    data = new RowData();
    data.width = 200;
    b.setLayoutData(data);

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
  public Composite createPartControl(Composite parent) {
    content = new Composite(parent, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.wrap = true;
    rowLayout.pack = true;
    rowLayout.fill = true;
    rowLayout.justify = false;
    rowLayout.type = SWT.HORIZONTAL;
    rowLayout.marginLeft = 2;
    rowLayout.marginTop = 2;
    rowLayout.marginRight = 2;
    rowLayout.marginBottom = 2;
    rowLayout.spacing = 3;
    content.setLayout(rowLayout);

    IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
    themeManager.addPropertyChangeListener(themeChangeListener);
    ITheme theme = themeManager.getCurrentTheme();
    setTheme(theme);

    content.addMouseListener(mouseListener);

    return content;
  }
  public DeleteContentsDialog(Browser _browser, String domain, String[] _ids, String[] titles) {
    this.domain = domain;
    this.browser = _browser;
    this.ids = _ids;
    shell = new Shell(browser.getShell(), SWT.CLOSE | SWT.RESIZE | SWT.APPLICATION_MODAL);
    ClientRM clientRM = DeleteDomainPlugin.getResources();
    ApplicationFactory factory = new ApplicationFactory(shell, clientRM, getClass().getName());
    shell.setText(factory.getLabel("title"));
    factory.setComposite(shell);
    shell.setLayout(new GridLayout(1, false));

    shell.addShellListener(
        new ShellAdapter() {
          public void shellClosed(ShellEvent e) {
            new ShellSetter(DeleteContentsDialog.class, shell);
            shell.dispose();
          }
        });

    factory.setComposite(shell);

    RefsDecoder decoder = new RefsDecoder();

    butTitles = new Button[titles.length];
    //    selectors = new DeleteSingleArticleSelector[10];
    for (int i = 0; i < butTitles.length; i++) {
      titles[i] = new String(decoder.decode(titles[i].toCharArray()));
      butTitles[i] = new Button(shell, SWT.CHECK);
      butTitles[i].setSelection(true);
      butTitles[i].setToolTipText(clientRM.getLabel("itemDeleteTooltip"));
      butTitles[i].setText(titles[i]);
      butTitles[i].setLayoutData(new GridData());
    }

    Composite bottom = new Composite(shell, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    // gridData.horizontalSpan = 2;
    bottom.setLayoutData(gridData);
    RowLayout rowLayout = new RowLayout();
    bottom.setLayout(rowLayout);
    rowLayout.justify = true;
    factory.setComposite(bottom);

    factory.createButton(
        "butDeletDomain",
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent evt) {
            deleteDomain();
          }
        });

    SelectionAdapter syncListener =
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent evt) {
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < ids.length; i++) {
              if (!butTitles[i].getSelection()) continue;
              if (builder.length() > 0) builder.append('\n');
              builder.append(ids[i]);
            }
            DeleteContentPlugin.delete(browser, builder.toString());
            shell.dispose();
          }
        };

    factory.createButton("butOk", syncListener);

    factory.createButton(
        "butClose",
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent evt) {
            new ShellSetter(DeleteContentsDialog.class, shell);
            shell.dispose();
          }
        });

    Rectangle displayRect = UIDATA.DISPLAY.getBounds();
    int x = (displayRect.width - 350) / 2;
    int y = (displayRect.height - 300) / 2;
    shell.setImage(browser.getShell().getImage());
    new ShellGetter(DeleteContentsDialog.class, shell, 550, 350, x, y);
    shell.open();
  }
示例#6
0
  private void initIcons(ApplicationFactory factory) {
    Composite center = null;
    if (Application.LICENSE == Install.PERSONAL) {
      center = new Composite(this, SWT.TRANSPARENCY_ALPHA);
      GridData gridData = new GridData(GridData.FILL_BOTH);
      center.setLayoutData(gridData);

      GridLayout gridLayout = new GridLayout(2, false);
      center.setLayout(gridLayout);

      Browser widget = null;

      //      ClientLog.getInstance().setMessage(getShell(), new Exception( "buoc 1 da chay vao day
      // roi " + widget.toString()));

      try {
        widget = new Browser(center, SWT.NONE);
        //        ClientLog.getInstance().setMessage(getShell(), new Exception( " da chay vao day
        // roi " + widget.toString()));
      } catch (Exception e) {
        widget = new Browser(center, SWT.NONE);
        ClientLog.getInstance().setException(null, e);
      }
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.verticalSpan = 2;
      widget.setLayoutData(gridData);
      if (Application.GROUPS.length > 0 && Application.GROUPS[0].equals("XML")) {
        widget.setUrl("http://vietspider.org/webextractor/");
        toolbar.setText("http://vietspider.org/webextractor/");
      } else {
        widget.setUrl("http://nik.vn/tin/");
        //      widget.setUrl("http://*****:*****@SuppressWarnings("unused")
          public void linkActivated(HyperlinkEvent e) {
            BrowserWidget browser = workspace.getTab().createItem();
            browser.viewPage();
          }
        };
    browserImageLink.addHyperlinkListener(listener);
    //    browserLink.addHyperlinkListener(listener);

    composite = createItem(top);
    final ImageHyperlink creatorImageLink =
        new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
    creatorImageLink.setImage(factory.loadImage("large.createsource.png"));
    //    creatorImageLink.setBackground(getBackground());
    creatorImageLink.setToolTipText(factory.getLabel("creatorLink"));
    //    final Hyperlink creatorLink = createLink(composite);
    //    creatorLink.setText(factory.getLabel("creatorLink"));
    //    creatorLink.setForeground(color);
    listener =
        new HyperlinkAdapter() {
          @SuppressWarnings("unused")
          public void linkEntered(HyperlinkEvent e) {
            //        creatorLink.setUnderlined(true);
          }

          @SuppressWarnings("unused")
          public void linkExited(HyperlinkEvent e) {
            //        creatorLink.setUnderlined(false);
          }

          @SuppressWarnings("unused")
          public void linkActivated(HyperlinkEvent e) {
            //        creatorLink.setUnderlined(false);
            try {
              ChannelWizard wizard =
                  (ChannelWizard)
                      workspace.getTab().createTool(ChannelWizard.class, false, SWT.CLOSE);
            } catch (Exception exp) {
              ClientLog.getInstance().setException(null, exp);
            }
            //        try {
            //          Creator creator = (Creator)workspace.getTab().createTool(
            //              Creator.class, false,  SWT.CLOSE);
            //          creator.selectData(new Worker[0], null, null);
            //        } catch (Exception exp) {
            //          ClientLog.getInstance().setException(null, exp);
            //        }
          }
        };
    creatorImageLink.addHyperlinkListener(listener);
    //    creatorLink.addHyperlinkListener(listener);

    ////////////////////////////////////////////////////////////////////////////////////////////////

    Composite bottom = new Composite(center, SWT.TRANSPARENCY_ALPHA);
    if (Application.LICENSE == Install.PERSONAL) {
      gridData = new GridData();
      gridData.widthHint = 350;
    } else {
      gridData = new GridData(GridData.FILL_BOTH);
    }
    bottom.setLayoutData(gridData);
    //    bottom.setBackground(getBackground());

    rowLayout = new RowLayout();
    rowLayout.wrap = true;
    rowLayout.pack = true;
    rowLayout.justify = true;
    rowLayout.type = SWT.HORIZONTAL;
    rowLayout.marginLeft = 5;
    rowLayout.marginTop = 5;
    rowLayout.marginRight = 5;
    rowLayout.marginBottom = 5;
    rowLayout.spacing = 20;
    bottom.setLayout(rowLayout);

    if (Application.LICENSE != Install.PERSONAL) {
      composite = createItem(top);
    } else {
      composite = createItem(bottom);
    }
    final ImageHyperlink crawlerImageLink =
        new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
    crawlerImageLink.setImage(factory.loadImage("large.crawler.png"));
    //    crawlerImageLink.setBackground(getBackground());
    crawlerImageLink.setToolTipText(factory.getLabel("crawlerLink"));
    //    final Hyperlink crawlerLink = createLink(composite);
    //    crawlerLink.setText(factory.getLabel("crawlerLink"));
    //    crawlerLink.setForeground(color);
    listener =
        new HyperlinkAdapter() {
          @SuppressWarnings("unused")
          public void linkEntered(HyperlinkEvent e) {
            //        crawlerLink.setUnderlined(true);
          }

          @SuppressWarnings("unused")
          public void linkExited(HyperlinkEvent e) {
            //        crawlerLink.setUnderlined(false);
          }

          @SuppressWarnings("unused")
          public void linkActivated(HyperlinkEvent e) {
            //        crawlerLink.setUnderlined(false);
            try {
              workspace.getTab().createTool(Crawler.class, true, SWT.CLOSE);
            } catch (Exception exp) {
              ClientLog.getInstance().setException(getShell(), exp);
            }
          }
        };
    crawlerImageLink.addHyperlinkListener(listener);
    //    crawlerLink.addHyperlinkListener(listener);

    if (Application.LICENSE != Install.PERSONAL) {
      composite = createItem(bottom);
      final ImageHyperlink monitorImageLink =
          new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
      monitorImageLink.setImage(factory.loadImage("large.log.png"));
      //      monitorImageLink.setBackground(getBackground());
      monitorImageLink.setToolTipText(factory.getLabel("logLink"));
      //      final Hyperlink monitorLink = createLink(composite);
      //      monitorLink.setText(factory.getLabel("monitorLink"));
      //      monitorLink.setForeground(color);
      listener =
          new HyperlinkAdapter() {
            @SuppressWarnings("unused")
            public void linkActivated(HyperlinkEvent e) {
              try {
                workspace.getTab().createTool(LogViewer2.class, true, SWT.CLOSE);
              } catch (Exception exp) {
                ClientLog.getInstance().setException(workspace.getShell(), exp);
              }
            }
          };
      monitorImageLink.addHyperlinkListener(listener);
      //      monitorLink.addHyperlinkListener(listener);
    }

    /*if(Application.LICENSE  != Install.PERSONAL) {
          composite = createItem(bottom);
          final ImageHyperlink userImageLink =
            new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
          userImageLink.setImage(factory.loadImage("large.userfolder.png"));
    //      userImageLink.setBackground(getBackground());
          userImageLink.setToolTipText(factory.getLabel("userLink"));
    //      final Hyperlink userLink = createLink(composite);
    //      userLink.setText(factory.getLabel("userLink"));
    //      userLink.setForeground(color);
          listener = new HyperlinkAdapter() {
            @SuppressWarnings("unused")
            public void linkEntered(HyperlinkEvent e) {
    //          userLink.setUnderlined(true);
            }

            @SuppressWarnings("unused")
            public void linkExited(HyperlinkEvent e) {
    //          userLink.setUnderlined(false);
    //          userLink.setFont(UIDATA.FONT_9VB);
            }
            @SuppressWarnings("unused")
            public void linkActivated(HyperlinkEvent e) {
    //          userLink.setUnderlined(false);
              try {
                workspace.getTab().createTool(Organization.class, true,  SWT.CLOSE);
              }catch (Exception exp) {
                ClientLog.getInstance().setException(workspace.getShell(), exp);
              }
            }
          };
          userImageLink.addHyperlinkListener(listener);
    //      userLink.addHyperlinkListener(listener);
        }*/

    composite = createItem(bottom);

    final ImageHyperlink configImageLink =
        new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
    configImageLink.setImage(factory.loadImage("large.settingsfolder.png"));
    //    configImageLink.setBackground(getBackground());
    configImageLink.setToolTipText(factory.getLabel("configLink"));
    //    final Hyperlink configLink = createLink(composite);
    //    configLink.setText(factory.getLabel("configLink"));
    //    configLink.setForeground(color);
    listener =
        new HyperlinkAdapter() {
          @SuppressWarnings("unused")
          public void linkEntered(HyperlinkEvent e) {
            //        configLink.setUnderlined(true);
          }

          @SuppressWarnings("unused")
          public void linkExited(HyperlinkEvent e) {
            //        configLink.setUnderlined(false);
          }

          @SuppressWarnings("unused")
          public void linkActivated(HyperlinkEvent e) {
            //        configLink.setUnderlined(false);
            try {
              workspace.getTab().createTool(Config.class, true, SWT.CLOSE);
            } catch (Exception exp) {
              ClientLog.getInstance().setException(workspace.getShell(), exp);
            }
          }
        };
    configImageLink.addHyperlinkListener(listener);
  }
示例#7
0
  private void initGUI() {
    try {

      this.setOrientation(SWT.VERTICAL);

      this.setBackground(MainGui.cHART_DARKER);
      Color innerBgColor = MainGui.cHART_LIGHT;

      this.addDisposeListener(
          new DisposeListener() {

            public void widgetDisposed(DisposeEvent evt) {
              rootShellClosed(evt);
            }
          });

      this.addListener(
          SWT.Hide,
          new Listener() {

            @Override
            public void handleEvent(Event event) {
              ChartsComposite.this.shutDownDisplay();
            }
          });

      {
        try {
          // Set cross-platform Java L&F (also called "Metal")
          UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        } catch (UnsupportedLookAndFeelException e) {
          LOGGER.error(e);
        } catch (ClassNotFoundException e) {
          LOGGER.error(e);
        } catch (InstantiationException e) {
          LOGGER.error(e);
        } catch (IllegalAccessException e) {
          LOGGER.error(e);
        }

        mainChartComposite = new Composite(this, SWT.EMBEDDED | SWT.NO_BACKGROUND);
        final Frame chartFrame = SWT_AWT.new_Frame(mainChartComposite);
        final Panel rootHeavyPanel = new Panel();
        rootHeavyPanel.setLayout(new BorderLayout());
        chartFrame.add(rootHeavyPanel);

        mainChartWraper =
            new ChartMain(ChartsComposite.DEFAULT_START_DATE, JFreeChartTimePeriod.DAY);
        mainChartPanel =
            new ChartPanel(
                mainChartWraper.initChart(stripedCloseFunction), true, true, true, false, true) {
              private static final long serialVersionUID = 1L;

              @Override
              public void restoreAutoBounds() {
                // Do nothing (disable mouse left drag zoom)
              }
            };
        mainChartPanel.setMouseZoomable(false, false);
        mainChartPanel.setMinimumDrawWidth(0);
        mainChartPanel.setMinimumDrawHeight(0);
        mainChartPanel.setMaximumDrawWidth(Display.getCurrent().getClientArea().width);
        mainChartPanel.setMaximumDrawHeight(Display.getCurrent().getClientArea().height);

        mainChartPanel.getPopupMenu().addSeparator();
        JMenuItem deleteVLines = new JMenuItem("Remove vertical lines");
        deleteVLines.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                chartDisplayStrategy.removeVLines();
              }
            });
        mainChartPanel.getPopupMenu().add(deleteVLines);
        JMenuItem deleteHLines = new JMenuItem("Remove horizontal lines");
        deleteHLines.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                chartDisplayStrategy.removeHLines();
              }
            });
        mainChartPanel.getPopupMenu().add(deleteHLines);

        mainChartPanel.getPopupMenu().addSeparator();
        JMenuItem lookAndFeelInfoItem = new JMenuItem("Look and feel Info");
        lookAndFeelInfoItem.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                LOGGER.info(UIManager.getLookAndFeel());
              }
            });
        mainChartPanel.getPopupMenu().add(lookAndFeelInfoItem);

        mainChartPanel.addMouseListener(
            new ClickListener() {

              @Override
              public void singleClick(final MouseEvent event) {

                Display.getDefault()
                    .asyncExec(
                        new Runnable() {

                          @Override
                          public void run() {
                            Boolean isSlidingArea =
                                getMainChartWraper()
                                    .isSlidingArea(
                                        mainChartComposite.getSize().y, event.getPoint().y);
                            if (isSlidingArea) return;

                            int button = event.getButton();
                            if (button == MouseEvent.BUTTON1) {
                              Point2D clickPoint =
                                  mainChartPanel.translateScreenToJava2D(event.getPoint());
                              Rectangle2D plotArea = mainChartPanel.getScreenDataArea();

                              if (plotArea.getMaxY() > clickPoint.getY()
                                  && clickPoint.getY() > plotArea.getY()
                                  && plotArea.getMaxX() > clickPoint.getX()
                                  && clickPoint.getX() > plotArea.getX()) {
                                chartDisplayStrategy.addVLineAt(clickPoint, plotArea);
                              }
                            }
                          }
                        });
              }

              @Override
              public void doubleClick(final MouseEvent event) {

                Display.getDefault()
                    .asyncExec(
                        new Runnable() {

                          @Override
                          public void run() {
                            Boolean isSlidingArea =
                                getMainChartWraper()
                                    .isSlidingArea(
                                        mainChartComposite.getSize().y, event.getPoint().y);
                            if (isSlidingArea) return;

                            int button = event.getButton();
                            if (button == MouseEvent.BUTTON1) {
                              Point2D clickPoint = getPointCoordinates(event.getPoint());
                              Rectangle2D plotArea = mainChartPanel.getScreenDataArea();

                              if (plotArea.getMaxY() > clickPoint.getY()
                                  && clickPoint.getY() > plotArea.getY()
                                  && plotArea.getMaxX() > clickPoint.getX()
                                  && clickPoint.getX() > plotArea.getX()) {
                                chartDisplayStrategy.removeVLineAt(clickPoint, plotArea);
                                chartDisplayStrategy.removeHLineAt(clickPoint, plotArea);
                              }
                            }
                          }
                        });
              }
            });

        // Slider
        chartPanelFocusGain = false;
        mainChartPanel.addMouseListener(
            new MouseAdapter() {

              @Override
              public void mouseEntered(MouseEvent e) {
                chartPanelFocusGain = true;
              }

              @Override
              public void mouseExited(MouseEvent e) {
                chartPanelFocusGain = false;
              }

              @Override
              public void mousePressed(final MouseEvent e) {
                panelClickPosition = e.getPoint();
                Display.getDefault()
                    .asyncExec(
                        new Runnable() {

                          @Override
                          public void run() {
                            Boolean isSlidingArea =
                                getMainChartWraper()
                                    .isSlidingArea(mainChartComposite.getSize().y, e.getPoint().y);
                            if (isSlidingArea) {
                              isInPanelChartSlider = true;
                            } else {
                              isInPanelChartSlider = false;
                            }
                          }
                        });
              }

              @Override
              public void mouseReleased(final MouseEvent e) {
                Display.getDefault()
                    .asyncExec(
                        new Runnable() {

                          @Override
                          public void run() {
                            if (isInPanelChartSlider != null
                                && isInPanelChartSlider
                                && panelClickPosition != null) {
                              int indicChartSlideIncrement =
                                  (int)
                                      ((((double) panelClickPosition.y - e.getPoint().y)
                                              / (double) mainChartComposite.getSize().y)
                                          * 100);
                              chartDisplayStrategy.slideChart(indicChartSlideIncrement);
                            }
                            isInPanelChartSlider = false;
                          }
                        });
              }
            });

        // focus bizz (useful?)
        mainChartPanel.addMouseMotionListener(
            new MouseMotionListener() {

              @Override
              public void mouseMoved(final MouseEvent e) {

                // Sliding
                if (!closeRequested) {
                  Display.getDefault()
                      .asyncExec(
                          new Runnable() {

                            @Override
                            public void run() {

                              if (!closeRequested) {
                                try {
                                  Cursor cursor = ChartsComposite.this.getCursor();
                                  if (cursor == null
                                      || (!cursor.equals(CursorFactory.getCursor(SWT.CURSOR_WAIT))
                                          && !cursor.equals(
                                              CursorFactory.getCursor(SWT.CURSOR_APPSTARTING)))) {
                                    Boolean isSlidingArea =
                                        getMainChartWraper()
                                            .isSlidingArea(
                                                mainChartComposite.getSize().y, e.getPoint().y);
                                    if (isSlidingArea) {
                                      ChartsComposite.this.setCursor(
                                          CursorFactory.getCursor(SWT.CURSOR_SIZENS));
                                    } else {
                                      ChartsComposite.this.setCursor(
                                          CursorFactory.getCursor(SWT.CURSOR_ARROW));
                                    }
                                  }

                                } catch (Throwable e) {
                                  try {
                                    ChartsComposite.this.setCursor(
                                        CursorFactory.getCursor(SWT.CURSOR_ARROW));
                                  } catch (Throwable e1) {
                                    LOGGER.warn(e1, e1);
                                  }
                                  LOGGER.warn(e, e);
                                }
                              }
                            }
                          });
                }

                // Gain focus mgt
                if (!closeRequested) {
                  Display.getDefault()
                      .asyncExec(
                          new Runnable() {
                            public void run() {
                              try {
                                if (!closeRequested) {
                                  if (!mainChartComposite.isDisposed()
                                      && !mainChartComposite.isFocusControl()) {
                                    int cpt = 0;
                                    while (chartPanelFocusGain && cpt < 200) {
                                      Thread.sleep(10);
                                      cpt++;
                                    }
                                    if (chartPanelFocusGain && !mainChartComposite.isDisposed()) {
                                      mainChartComposite.forceFocus();
                                    }
                                  }
                                }
                              } catch (Throwable e) {
                                LOGGER.warn(e, e);
                              }
                            }
                          });
                }
              }

              @Override
              public void mouseDragged(MouseEvent e) {
                // Nothing
              }
            });

        mainChartComposite.addKeyListener(
            new org.eclipse.swt.events.KeyListener() {

              @Override
              public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
                if (((e.stateMask & SWT.CTRL) == SWT.CTRL)
                    && ((e.stateMask & SWT.ALT) == SWT.ALT)
                    && (e.keyCode == 'p')) {
                  try {
                    chartDisplayStrategy.exportBarChartPng();
                  } catch (InvalidParameterException exception) {
                    chartDisplayStrategy.showPopupDialog(exception.getMessage(), "Ok", null, null);
                  }
                }
                if (e.keyCode == SWT.ARROW_UP) {
                  chartDisplayStrategy.slideChart(+1);
                }
                if (e.keyCode == SWT.ARROW_DOWN) {
                  chartDisplayStrategy.slideChart(-1);
                }
              }

              @Override
              public void keyPressed(org.eclipse.swt.events.KeyEvent e) {
                //
              }
            });

        mainChartComposite.addMouseTrackListener(
            new MouseTrackListener() {

              @Override
              public void mouseHover(org.eclipse.swt.events.MouseEvent e) {}

              @Override
              public void mouseExit(org.eclipse.swt.events.MouseEvent e) {}

              @Override
              public void mouseEnter(org.eclipse.swt.events.MouseEvent e) {
                mainChartPanel.requestFocusInWindow();
              }
            });

        rootHeavyPanel.add(mainChartPanel);
        chartFrame.pack();
        chartFrame.setVisible(true);
      }
      {
        chartBoutonsGroup = new Group(this, SWT.NONE);
        chartBoutonsGroup.setBackground(innerBgColor);
        GridLayout portfolioBoutonsGroupLayout = new GridLayout();
        portfolioBoutonsGroupLayout.numColumns = 1;
        portfolioBoutonsGroupLayout.verticalSpacing = 0;
        portfolioBoutonsGroupLayout.marginHeight = 0;
        chartBoutonsGroup.setLayout(portfolioBoutonsGroupLayout);
        GridData portfolioInfosGroupData = new GridData(GridData.FILL_HORIZONTAL);
        chartBoutonsGroup.setLayoutData(portfolioInfosGroupData);

        chartBoutonsGroup.setText("Portfolios charting : ");
        chartBoutonsGroup.setFont(MainGui.DEFAULTFONT);
        chartBoutonsGroup.setBackground(innerBgColor);

        {
          popusGroup = new Group(chartBoutonsGroup, SWT.NONE);
          GridData popusGroupData = new GridData(SWT.FILL, SWT.FILL, true, false);
          popusGroup.setLayoutData(popusGroupData);
          popusGroup.setBackground(innerBgColor);
          RowLayout popusGroupL = new RowLayout(SWT.HORIZONTAL);
          popusGroupL.justify = true;
          popusGroupL.fill = true;
          popusGroupL.wrap = false;
          popusGroupL.marginHeight = 0;
          popusGroup.setLayout(popusGroupL);
        }

        // Sliding
        {
          slidingGroup = new Group(chartBoutonsGroup, SWT.NONE);
          GridData slidingGroupData = new GridData(SWT.FILL, SWT.FILL, true, false);
          slidingGroup.setLayoutData(slidingGroupData);
          slidingGroup.setBackground(innerBgColor);
          GridLayout slidingGroupL = new GridLayout();
          slidingGroupL.numColumns = 5;
          slidingGroupL.marginHeight = 0;
          slidingGroupL.verticalSpacing = 0;
          slidingGroup.setLayout(slidingGroupL);
          /// start
          {
            startDateLabel = new Label(slidingGroup, SWT.NONE);
            GridData startOneYearBackData = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
            startOneYearBackData.horizontalSpan = 2;
            startDateLabel.setLayoutData(startOneYearBackData);
            startDateLabel.setText(
                DateFormat.getDateInstance(DateFormat.MEDIUM).format(slidingStartDate) + "");
            startDateLabel.setBackground(innerBgColor);
            startDateLabel.setFont(MainGui.DEFAULTFONT);
          }
          /// sliding sliders
          Composite slidingSliderGroup = new Composite(slidingGroup, SWT.NONE);
          slidingSliderGroup.setSize(1000, SWT.DEFAULT);
          GridData slidersGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
          slidersGridData.verticalSpan = 2;
          slidingSliderGroup.setLayoutData(slidersGridData);
          slidingSliderGroup.setBackground(innerBgColor);
          slidingSliderGroup.setForeground(innerBgColor);
          FillLayout slidingSliderGroupL = new FillLayout(SWT.VERTICAL);
          slidingSliderGroup.setLayout(slidingSliderGroupL);
          {
            sliderStartDate = new Slider(slidingSliderGroup, SWT.HORIZONTAL);
            sliderStartDate.setThumb(1);
            sliderStartDate.setMaximum(100);
            sliderStartDate.addListener(
                SWT.MouseExit,
                new Listener() {

                  public void handleEvent(Event arg0) {
                    sliderChangesApply();
                  }
                });
          }
          {
            sliderEndDate = new Slider(slidingSliderGroup, SWT.HORIZONTAL);
            sliderEndDate.setThumb(1);
            sliderEndDate.setMinimum(0);
            sliderEndDate.setSelection(100);
            sliderEndDate.addListener(
                SWT.MouseExit,
                new Listener() {

                  public void handleEvent(Event arg0) {
                    sliderChangesApply();
                  }
                });
          }
          // end
          {
            endDateLabel = new Label(slidingGroup, SWT.NONE);
            GridData endOneYearBackData = new GridData(SWT.END, SWT.FILL, false, false);
            endOneYearBackData.horizontalSpan = 2;
            endDateLabel.setLayoutData(endOneYearBackData);
            endDateLabel.setText(
                DateFormat.getDateInstance(DateFormat.MEDIUM).format(slidingEndDate));
            endDateLabel.setBackground(innerBgColor);
            endDateLabel.setFont(MainGui.DEFAULTFONT);
          }

          // but start
          {
            Button startOneYearBack = new Button(slidingGroup, SWT.ARROW | SWT.LEFT);
            GridData startOneYearBackData = new GridData(SWT.END, SWT.FILL, false, true);
            startOneYearBack.setLayoutData(startOneYearBackData);
            startOneYearBack.setToolTipText("Move start date one year backward.");
            startOneYearBack.addSelectionListener(
                new SelectionListener() {

                  @Override
                  public void widgetSelected(SelectionEvent e) {
                    handle();
                  }

                  private void handle() {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(slidingStartDate);
                    calendar.add(Calendar.YEAR, -1);
                    firstStartDate = calendar.getTime();
                    sliderStartDate.setSelection(0);
                    startSliderUpdateConditional(
                        sliderStartDate, startDateLabel, sliderEndDate, endDateLabel);
                  }

                  @Override
                  public void widgetDefaultSelected(SelectionEvent e) {
                    handle();
                  }
                });
            startOneYearBack.addListener(
                SWT.MouseExit,
                new Listener() {

                  @Override
                  public void handleEvent(Event event) {
                    sliderChangesApply();
                  }
                });
          }

          {
            Button startOneYearForward = new Button(slidingGroup, SWT.ARROW | SWT.RIGHT);
            GridData startOneYearBackData = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
            startOneYearForward.setLayoutData(startOneYearBackData);
            startOneYearForward.setToolTipText("Move start date one year forward.");
            startOneYearForward.addSelectionListener(
                new SelectionListener() {

                  @Override
                  public void widgetSelected(SelectionEvent e) {
                    handle();
                  }

                  private void handle() {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(slidingStartDate);
                    calendar.add(Calendar.YEAR, +1);
                    if (calendar.getTime().before(slidingEndDate)) {
                      firstStartDate = calendar.getTime();
                      sliderStartDate.setSelection(0);
                      startSliderUpdateConditional(
                          sliderStartDate, startDateLabel, sliderEndDate, endDateLabel);
                    } else {
                      chartDisplayStrategy.showPopupDialog(
                          "To move the start date further forward, you will need to move the end date first.",
                          "Ok",
                          null,
                          null);
                    }
                  }

                  @Override
                  public void widgetDefaultSelected(SelectionEvent e) {
                    handle();
                  }
                });
            startOneYearForward.addListener(
                SWT.MouseExit,
                new Listener() {

                  @Override
                  public void handleEvent(Event event) {
                    sliderChangesApply();
                  }
                });
          }
          /// but end

          {
            Button endOneYearBack = new Button(slidingGroup, SWT.ARROW | SWT.LEFT);
            GridData endOneYearBackData = new GridData(SWT.END, SWT.FILL, false, true);
            endOneYearBack.setLayoutData(endOneYearBackData);
            endOneYearBack.setToolTipText("Move end date one year backward.");
            endOneYearBack.addSelectionListener(
                new SelectionListener() {

                  @Override
                  public void widgetSelected(SelectionEvent e) {
                    handle();
                  }

                  private void handle() {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(slidingEndDate);
                    calendar.add(Calendar.YEAR, -1);
                    if (calendar.getTime().after(slidingStartDate)) {
                      lastEndDate = calendar.getTime();
                      sliderEndDate.setSelection(100);
                      endSliderUpdateConditional(
                          sliderEndDate, endDateLabel, sliderStartDate, startDateLabel);
                    } else {
                      chartDisplayStrategy.showPopupDialog(
                          "To move the end date further backward, you will need to move the start date first.",
                          "Ok",
                          null,
                          null);
                    }
                  }

                  @Override
                  public void widgetDefaultSelected(SelectionEvent e) {
                    handle();
                  }
                });
            endOneYearBack.addListener(
                SWT.MouseExit,
                new Listener() {

                  @Override
                  public void handleEvent(Event event) {
                    sliderChangesApply();
                  }
                });
          }
          {
            Button endOneYearForward = new Button(slidingGroup, SWT.ARROW | SWT.RIGHT);
            GridData endOneYearBackData = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
            endOneYearForward.setLayoutData(endOneYearBackData);
            endOneYearForward.setToolTipText("Move end date one year forward.");
            endOneYearForward.addSelectionListener(
                new SelectionListener() {

                  @Override
                  public void widgetSelected(SelectionEvent e) {
                    handle();
                  }

                  private void handle() {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(slidingEndDate);
                    calendar.add(Calendar.YEAR, +1);
                    Date newDate = EventSignalConfig.getNewDate();
                    if (calendar.getTime().after(newDate)) {
                      calendar.setTime(newDate);
                    }
                    lastEndDate = calendar.getTime();
                    sliderEndDate.setSelection(100);
                    endSliderUpdateConditional(
                        sliderEndDate, endDateLabel, sliderStartDate, startDateLabel);
                  }

                  @Override
                  public void widgetDefaultSelected(SelectionEvent e) {
                    handle();
                  }
                });
            endOneYearForward.addListener(
                SWT.MouseExit,
                new Listener() {

                  @Override
                  public void handleEvent(Event event) {
                    sliderChangesApply();
                  }
                });
          }

          sliderStartDate.addListener(
              SWT.Selection,
              new Listener() {
                public void handleEvent(Event event) {
                  startSliderUpdateConditional(
                      sliderStartDate, startDateLabel, sliderEndDate, endDateLabel);
                }
              });

          sliderEndDate.addListener(
              SWT.Selection,
              new Listener() {

                public void handleEvent(Event event) {
                  endSliderUpdateConditional(
                      sliderEndDate, endDateLabel, sliderStartDate, startDateLabel);
                }
              });

          slidingGroup.layout();
        }
      }

      this.layout();
      this.pack();

    } catch (Exception e) {
      LOGGER.error("", e);
    }
  }
  @Override
  public void createPartControl(Composite parent) {

    super.createPartControl(parent);

    messages.traceTech("init the form...", getClass());

    toolkit = new FormToolkit(parent.getDisplay());
    parent.setLayout(new FillLayout());
    form = toolkit.createScrolledForm(parent);

    RowLayout layout = new RowLayout(SWT.VERTICAL);
    layout.center = false;
    layout.fill = false;
    layout.pack = true;
    layout.justify = false;
    form.getBody().setLayout(layout);

    form.getBody()
        .addControlListener(
            new ControlListener() {

              @Override
              public void controlResized(ControlEvent e) {
                manageResized();
              }

              @Override
              public void controlMoved(ControlEvent e) {}
            });

    labelIteration = toolkit.createLabel(form.getBody(), "not data displayed yet");
    // TODO separator toolkit.createSeparator(form.getBody(), );
    compositeCharts = toolkit.createComposite(form.getBody());
    compositeCharts.setLayoutData(new RowData());
    compositeCharts.setLayout(new GridLayout(1, false));

    // create the chart

    // create dataset
    dataset = new DefaultCategoryDataset();

    // create plot
    plot = new EnhancedSpiderWebPlot(dataset);
    plot.setMaxValue(1.0);
    plot.setWebFilled(true);
    plot.setInteriorGap(0.2D);
    plot.setBackgroundPaint(Color.WHITE);

    // create chart
    chart = new JFreeChart("1th Pareto front", TextTitle.DEFAULT_FONT, plot, false);
    LegendTitle legendtitle = new LegendTitle(plot);
    legendtitle.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendtitle);
    chart.getPlot().setBackgroundPaint(Color.white);
    chart.setBackgroundPaint(Color.WHITE);

    // create host composite
    chartComposites =
        new ChartComposite(
            compositeCharts, SWT.NONE, chart, true // use a buffer
            );
    chartComposites.setSize(preferedWidth, preferedHeight);
    chartComposites.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    chartComposites.setBackground(compositeCharts.getBackground());

    // update display
    form.getBody().layout(true);

    form.reflow(true);
  }
示例#9
0
  /** build the view */
  private void buildView() {
    GridLayout gridLayout = new GridLayout(2, false);
    final Composite comp = new Composite(shell, SWT.NONE);

    shell.setLayout(new FillLayout());

    comp.setLayout(gridLayout);

    GridData gridData = new GridData();

    dataList = new List(comp, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
    gridData = new GridData();
    gridData.widthHint = 200;
    gridData.verticalAlignment = SWT.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.verticalSpan = 2;
    dataList.setLayoutData(gridData);
    dataList.addListener(SWT.Selection, new ListListener());

    dataTable = new Table(comp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    dataTable.setLinesVisible(true);
    dataTable.setHeaderVisible(true);

    gridData = new GridData();
    gridData.verticalAlignment = SWT.FILL;
    gridData.horizontalAlignment = SWT.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.grabExcessHorizontalSpace = true;
    dataTable.setLayoutData(gridData);

    final TableColumn column1 = new TableColumn(dataTable, SWT.NONE);
    final TableColumn column2 = new TableColumn(dataTable, SWT.NONE);

    column1.setText("Time");
    column2.setText("Value");
    column1.setWidth(180);
    column2.setWidth(270);

    Composite buttonsComp = new Composite(comp, SWT.NONE);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = 40;
    buttonsComp.setLayoutData(gridData);
    RowLayout rowLayout = new RowLayout();
    rowLayout.type = SWT.HORIZONTAL;

    rowLayout.justify = true;
    rowLayout.pack = true;
    buttonsComp.setLayout(rowLayout);

    ButtonListener bl = new ButtonListener();

    Button refreshButton = new Button(buttonsComp, SWT.NONE);
    refreshButton.setText("Refresh");
    refreshButton.addSelectionListener(bl);

    Button exportButton = new Button(buttonsComp, SWT.NONE);
    exportButton.setText("Export");
    exportButton.addSelectionListener(bl);

    Button deleteButton = new Button(buttonsComp, SWT.NONE);
    deleteButton.setText("Delete Selection");
    deleteButton.addSelectionListener(bl);

    Button deleteallButton = new Button(buttonsComp, SWT.NONE);
    deleteallButton.setText("Delete all");
    deleteallButton.addSelectionListener(bl);
  }