Esempio n. 1
0
  /** Creates a new instance of Triggers */
  public Triggers(Composite parent, int style) {
    super(parent, style);
    setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
    final RowLayout layout = new RowLayout(SWT.HORIZONTAL);
    layout.fill = true;
    layout.wrap = false;
    layout.spacing = 0;
    setLayout(layout);
    action =
        new SpherePanel(this, SWT.DOUBLE_BUFFERED, DemoResources.YELLOW_SPHERE, "B-Click", true);
    focus = new SpherePanel(this, SWT.DOUBLE_BUFFERED, DemoResources.BLUE_SPHERE, "Key-Foc", false);
    armed = new SpherePanel(this, SWT.DOUBLE_BUFFERED, DemoResources.RED_SPHERE, "M-Press", true);
    over = new SpherePanel(this, SWT.DOUBLE_BUFFERED, DemoResources.GREEN_SPHERE, "M-Enter", false);
    timing = new SpherePanel(this, SWT.DOUBLE_BUFFERED, DemoResources.GRAY_SPHERE, "1-Stop", true);

    /*
     * Add triggers for each sphere, depending on what we want to trigger them.
     */
    TriggerUtility.addEventTrigger(triggerButton, SWT.Selection, action.getAnimator());
    TriggerUtility.addFocusTrigger(triggerButton, focus.getAnimator(), FocusTriggerEvent.IN, true);
    TriggerUtility.addMouseTrigger(triggerButton, armed.getAnimator(), MouseTriggerEvent.PRESS);
    TriggerUtility.addMouseTrigger(
        triggerButton, over.getAnimator(), MouseTriggerEvent.ENTER, true);
    TriggerUtility.addTimingTrigger(
        action.getAnimator(), timing.getAnimator(), TimingTriggerEvent.STOP);
  }
  public PerspectiveSwitcherBuilder(final Composite parent, final String subSetId) {
    super(parent, subSetId);
    GridLayout glayout = new GridLayout();
    glayout.marginBottom = 0;
    glayout.marginHeight = 0;

    parent.setLayout(glayout);
    background = new Composite(parent, SWT.NONE);
    background.setData(RWT.CUSTOM_VARIANT, ICSSConstants.COMP_TRANS); // $NON-NLS-1$
    background.setLayoutData(new GridData(SWT.RIGHT, SWT.BOTTOM, true, true, 1, 1));
    RowLayout layout = new RowLayout();
    background.setLayout(layout);
    layout.spacing = 4;
    layout.marginBottom = 0;
    layout.marginRight = 10;
    layout.marginTop = 0;
    layout.wrap = false;
    layout.pack = false;
    perspectiveButtonMap = new HashMap<IPerspectiveDescriptor, Button>();
    buttonPerspectiveMap = new HashMap<Button, IPerspectiveDescriptor>();
    buttonList = new ArrayList<Button>();
    perspectiveList = new ArrayList<String>();
    // images
    bgActive = getImage(ILayoutSetConstants.PERSP_BG_ACTIVE);
  }
  /*
   * (non-Javadoc)
   *
   * @see net.refractions.udig.style.sld.SLDEditorPart#createPartControl(org.eclipse.swt.widgets.Composite)
   */
  protected Control createPartControl(Composite parent) {
    myparent = parent;
    RowLayout layout = new RowLayout();
    myparent.setLayout(layout);
    layout.pack = false;
    layout.wrap = true;
    layout.type = SWT.HORIZONTAL;

    /* Border Opacity */
    Group borderOpacityArea = new Group(myparent, SWT.NONE);
    borderOpacityArea.setLayout(new GridLayout(2, false));
    borderOpacityArea.setText("Raster Opacity"); // $NON-NLS-1$

    opacityScale = new Scale(borderOpacityArea, SWT.HORIZONTAL);
    opacityScale.setMinimum(0);
    opacityScale.setMaximum(100);
    opacityScale.setPageIncrement(10);
    opacityScale.setBounds(0, 0, 10, SWT.DEFAULT);
    opacityScale.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            opacityText.setText(String.valueOf(opacityScale.getSelection()) + "%"); // $NON-NLS-1$
            opacityText.pack(true);
          }
        });
    opacityScale.addSelectionListener(this);

    opacityText = new Text(borderOpacityArea, SWT.BORDER | SWT.READ_ONLY);
    opacityText.pack(true);

    return parent;
  }
Esempio n. 4
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);
          }
        });
  }
Esempio n. 5
0
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());
    Composite composite = new Composite(shell, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    RowLayout layout = new RowLayout(SWT.HORIZONTAL);
    layout.wrap = true;
    layout.fill = false;
    fTerminalModel = TerminalTextDataFactory.makeTerminalTextData();
    fHeight = 24;
    fWidth = 80;
    fTerminalModel.setDimensions(fHeight, fWidth);
    fTerminalModel.setMaxHeight(fHeight);
    ITerminalTextDataSnapshot snapshot = fTerminalModel.makeSnapshot();
    // TODO how to get the initial size correctly!
    snapshot.updateSnapshot(false);
    fgModel = new PollingTextCanvasModel(snapshot);
    fgTextCanvas =
        new TextCanvas(shell, fgModel, SWT.NONE, new TextLineRenderer(fgTextCanvas, fgModel));
    fgTextCanvas.setLayoutData(new GridData(GridData.FILL_BOTH));

    composite.setLayout(layout);
    addAutorevealCursorButton(composite);
    Text maxHeightText = addMaxHeightInput(composite);
    addHeightInput(composite, maxHeightText);
    addWidthText(composite);
    Text throttleText = addThrottleText(composite);

    IStatus status = new Status();
    DataReader reader =
        new DataReader("Line Count", fTerminalModel, new LineCountingDataSource(), status);
    addDataReader(composite, reader);
    reader = new DataReader("Fast", fTerminalModel, new FastDataSource(), status);
    addDataReader(composite, reader);
    reader = new DataReader("Random", fTerminalModel, new RandomDataSource(), status);
    addDataReader(composite, reader);
    for (int i = 0; i < args.length; i++) {
      File file = new File(args[i]);
      reader = new DataReader(file.getName(), fTerminalModel, new VT100DataSource(args[i]), status);
      addDataReader(composite, reader);
    }
    addStopAllButton(composite, reader);

    fStatusLabel = new Label(shell, SWT.NONE);
    fStatusLabel.setLayoutData(new GridData(250, 15));
    throttleText.setText("100");
    setThrottleForAll(100);

    if (args.length == 0) addLabel(composite, "[Files can be added via commandline]");
    shell.setSize(600, 300);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Esempio n. 6
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();
  }
Esempio n. 7
0
  private static void createFramesHolder(Composite parent, EmoticonImage icon) {
    Label label = new Label(parent, SWT.NONE);
    label.setText("Frame:");

    icon.emoticon.frames = new Composite(parent, SWT.NONE);
    icon.emoticon.frames.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
    rowLayout.wrap = true;
    icon.emoticon.frames.setLayout(rowLayout);

    fillFramesHolder(icon, true);
  }
    public OrCondition(
        final FilterAdvancedComposite filterAdvancedComposite, final CTabFolder tabFolder) {
      // fields
      this.filterAdvancedComposite = filterAdvancedComposite;
      this.tabItem = new CTabItem(tabFolder, SWT.NULL);
      this.tabItem.setText(Messages.a_condition);
      this.tabContent = new Composite(tabFolder, SWT.NONE);
      this.tabItem.setControl(this.tabContent);

      // widgets
      this.addAssertionComposite = new AddAssertionComposite(this, this.tabContent);
      this.assertionScrolledComposite =
          new ScrolledComposite(this.tabContent, SWT.V_SCROLL | SWT.NONE);
      this.assertionComposite = new Composite(this.assertionScrolledComposite, SWT.NONE);
      this.assertionScrolledComposite.setContent(this.assertionComposite);

      // layout
      final GridLayout layout = new GridLayout();
      layout.marginLeft = 6;
      layout.marginRight = 6;
      layout.marginTop = 6;
      layout.marginBottom = 6;
      layout.verticalSpacing = 12;
      this.tabContent.setLayout(layout);

      final GridData addAssertionCompositeLayoutData = new GridData();
      addAssertionCompositeLayoutData.grabExcessHorizontalSpace = true;
      addAssertionCompositeLayoutData.horizontalAlignment = GridData.FILL;
      this.addAssertionComposite.setLayoutData(addAssertionCompositeLayoutData);

      final GridData assertionCompositeLayoutData = new GridData();
      assertionCompositeLayoutData.grabExcessHorizontalSpace = true;
      assertionCompositeLayoutData.horizontalAlignment = GridData.FILL;
      assertionCompositeLayoutData.grabExcessVerticalSpace = true;
      assertionCompositeLayoutData.verticalAlignment = GridData.FILL;
      this.assertionScrolledComposite.setLayoutData(assertionCompositeLayoutData);
      this.assertionScrolledComposite.setExpandHorizontal(true);

      final RowLayout innerlayout = new RowLayout(SWT.VERTICAL);
      innerlayout.wrap = false;
      this.assertionComposite.setLayout(innerlayout);
      this.assertionComposite.addListener(
          SWT.Resize,
          new Listener() {
            public void handleEvent(final org.eclipse.swt.widgets.Event event) {
              final Point s =
                  OrCondition.this.assertionComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
              OrCondition.this.assertionComposite.setSize(s.x, s.y);
              refreshGUI();
            }
          });
    }
  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;
  }
Esempio n. 11
0
  public LoginPanel(Shell page, Composite parent) {
    super(parent, SWT.NONE);
    this.shell = page;

    setLayout(new GridLayout());
    // ´´½¨µÇ¼ÇøÓòµÄÓû§±êÇ© Óû§ÃûÊäÈë¿ò ÃÜÂë±êÇ© ÃÜÂëÊäÈë¿ò µÇ¼°´Å¥
    Composite panelTop = new Composite(this, SWT.NONE);
    panelTop.setBackgroundMode(SWT.INHERIT_DEFAULT);

    RowLayout layout = new RowLayout();
    layout.spacing = 40;
    layout.marginBottom = 0;
    layout.marginRight = 10;
    layout.marginTop = 0;
    layout.wrap = false;
    layout.pack = true;
    layout.center = true;

    panelTop.setLayout(layout);

    userText = new Text(panelTop, SWT.BORDER);
    RowData rd = new RowData();
    rd.width = 240;
    userText.setMessage("Õʺš¢Óû§Ãû»òÕßemail");
    userText.setLayoutData(rd);
    userText.setData(RWT.CUSTOM_VARIANT, "loginInput");
    userText.setFocus();

    passwordText = new Text(panelTop, SWT.BORDER | SWT.PASSWORD);
    rd = new RowData();
    rd.width = 220;
    passwordText.setMessage("ÊäÈëµÇ¼ÃÜÂë");
    passwordText.setLayoutData(rd);
    passwordText.setData(RWT.CUSTOM_VARIANT, "loginInput");

    okButton = new Button(panelTop, SWT.PUSH);
    okButton.setData(RWT.CUSTOM_VARIANT, "loginInput");
    rd = new RowData();
    rd.width = 50;
    rd.height = 50;
    okButton.setLayoutData(rd);
    page.setDefaultButton(okButton);
    okButton.addSelectionListener(
        new SelectionAdapter() {

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

    // ´´½¨±£´æÃÜÂë¹´Ñ¡¿òºÍ±£´æÓû§Ãû¹´Ñ¡¿ò
    Composite panelBottom = new Composite(this, SWT.NONE);

    layout = new RowLayout();
    layout.spacing = 4;
    layout.marginBottom = 0;
    layout.marginRight = 10;
    layout.marginTop = 0;
    layout.wrap = false;
    layout.pack = true;

    panelBottom.setLayout(layout);

    saveIdButton = new Button(panelBottom, SWT.CHECK);
    saveIdButton.setText("±£´æµÇ¼ÕʺÅ");
    saveIdButton.setData(RWT.CUSTOM_VARIANT, "loginCheck");

    savePassButton = new Button(panelBottom, SWT.CHECK);
    savePassButton.setText("±£´æµÇ¼ÃÜÂë");
    savePassButton.setData(RWT.CUSTOM_VARIANT, "loginCheck");

    // cookie save
    String uid = RWT.getSettingStore().getAttribute(COOKIE_UI_USERID);
    if (uid != null && uid.length() > 0) {
      userText.setText(uid);
      saveIdButton.setSelection(true);
    }
    // cookie save
    String psd = RWT.getSettingStore().getAttribute(COOKIE_UI_PASSWORD);
    if (psd != null && psd.length() > 0) {
      passwordText.setText(psd);
      savePassButton.setSelection(true);
    }

    panelTop.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
    panelBottom.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));

    createTooltips();
  }
 /**
  * @param parent
  * @param style
  */
 public CustomItemList(Composite parent, int style) {
   super(parent, style);
   RowLayout layout = new RowLayout();
   layout.wrap = true;
   setLayout(layout);
 }
Esempio n. 13
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);
  }
Esempio n. 14
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);
    }
  }
Esempio n. 15
0
  /**
   * Create contents of the wizard.
   *
   * @param parent the parent widget
   */
  @Override
  @SuppressWarnings("unused") // Don't warn about unassigned "new Label(.)": has side-effect
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);

    setControl(container);
    GridLayout glContainer = new GridLayout(2, false);
    glContainer.marginWidth = 0;
    glContainer.horizontalSpacing = 0;
    glContainer.marginHeight = 0;
    glContainer.verticalSpacing = 0;
    container.setLayout(glContainer);

    ScrolledComposite configurationScrollArea = new ScrolledComposite(container, SWT.V_SCROLL);
    configurationScrollArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
    configurationScrollArea.setExpandHorizontal(true);
    configurationScrollArea.setExpandVertical(true);

    mConfigurationArea = new Composite(configurationScrollArea, SWT.NONE);
    GridLayout glConfigurationArea = new GridLayout(3, false);
    glConfigurationArea.horizontalSpacing = 0;
    glConfigurationArea.marginRight = 15;
    glConfigurationArea.marginWidth = 0;
    glConfigurationArea.marginHeight = 0;
    mConfigurationArea.setLayout(glConfigurationArea);

    Label foregroundLabel = new Label(mConfigurationArea, SWT.NONE);
    foregroundLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    foregroundLabel.setText("Foreground:");

    Composite foregroundComposite = new Composite(mConfigurationArea, SWT.NONE);
    foregroundComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
    GridLayout glForegroundComposite = new GridLayout(5, false);
    glForegroundComposite.horizontalSpacing = 0;
    foregroundComposite.setLayout(glForegroundComposite);

    mImageRadio = new Button(foregroundComposite, SWT.FLAT | SWT.TOGGLE);
    mImageRadio.setSelection(false);
    mImageRadio.addSelectionListener(this);
    mImageRadio.setText("Image");

    mClipartRadio = new Button(foregroundComposite, SWT.FLAT | SWT.TOGGLE);
    mClipartRadio.setText("Clipart");
    mClipartRadio.addSelectionListener(this);

    mTextRadio = new Button(foregroundComposite, SWT.FLAT | SWT.TOGGLE);
    mTextRadio.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
    mTextRadio.setText("Text");
    mTextRadio.addSelectionListener(this);
    new Label(mConfigurationArea, SWT.NONE);

    mForegroundArea = new Composite(mConfigurationArea, SWT.NONE);
    mForegroundArea.setLayout(new StackLayout());
    mForegroundArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));

    mImageForm = new Composite(mForegroundArea, SWT.NONE);
    mImageForm.setLayout(new GridLayout(3, false));

    Label fileLabel = new Label(mImageForm, SWT.NONE);
    fileLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    fileLabel.setText("Image File:");

    mImagePathText = new Text(mImageForm, SWT.BORDER);
    GridData pathLayoutData = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    pathLayoutData.widthHint = 200;
    mImagePathText.setLayoutData(pathLayoutData);
    mImagePathText.addSelectionListener(this);
    mImagePathText.addModifyListener(this);

    mPickImageButton = new Button(mImageForm, SWT.FLAT);
    mPickImageButton.setText("Browse...");
    mPickImageButton.addSelectionListener(this);

    mClipartForm = new Composite(mForegroundArea, SWT.NONE);
    mClipartForm.setLayout(new GridLayout(2, false));

    mChooseClipart = new Button(mClipartForm, SWT.FLAT);
    mChooseClipart.setText("Choose...");
    mChooseClipart.addSelectionListener(this);

    mClipartPreviewPanel = new Composite(mClipartForm, SWT.NONE);
    RowLayout rlClipartPreviewPanel = new RowLayout(SWT.HORIZONTAL);
    rlClipartPreviewPanel.marginBottom = 0;
    rlClipartPreviewPanel.marginTop = 0;
    rlClipartPreviewPanel.center = true;
    mClipartPreviewPanel.setLayout(rlClipartPreviewPanel);
    mClipartPreviewPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    mTextForm = new Composite(mForegroundArea, SWT.NONE);
    mTextForm.setLayout(new GridLayout(2, false));

    Label textLabel = new Label(mTextForm, SWT.NONE);
    textLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    textLabel.setText("Text:");

    mText = new Text(mTextForm, SWT.BORDER);
    mText.setText("Aa");
    mText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    mText.addModifyListener(this);

    Label fontLabel = new Label(mTextForm, SWT.NONE);
    fontLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    fontLabel.setText("Font:");

    mFontButton = new Button(mTextForm, SWT.FLAT);
    mFontButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
    mFontButton.addSelectionListener(this);
    mFontButton.setText("Choose Font...");
    new Label(mConfigurationArea, SWT.NONE);

    mTrimCheckBox = new Button(mConfigurationArea, SWT.CHECK);
    mTrimCheckBox.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    mTrimCheckBox.setSelection(false);
    mTrimCheckBox.setText("Trim Surrounding Blank Space");
    mTrimCheckBox.addSelectionListener(this);
    new Label(mConfigurationArea, SWT.NONE);

    Label paddingLabel = new Label(mConfigurationArea, SWT.NONE);
    paddingLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    paddingLabel.setText("Additional Padding:");
    new Label(mConfigurationArea, SWT.NONE);

    mPaddingSlider = new Slider(mConfigurationArea, SWT.NONE);
    mPaddingSlider.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    // This doesn't work right -- not sure why. For now just use a plain slider
    // and subtract 10 from it to get the real range.
    // mPaddingSlider.setValues(0, -10, 50, 0, 1, 10);
    mPaddingSlider.setSelection(10 + 15);
    mPaddingSlider.addSelectionListener(this);

    mPercentLabel = new Label(mConfigurationArea, SWT.NONE);
    mPercentLabel.setText("  15%"); // Enough available space for -10%

    mScalingLabel = new Label(mConfigurationArea, SWT.NONE);
    mScalingLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    mScalingLabel.setText("Foreground Scaling:");

    mScalingComposite = new Composite(mConfigurationArea, SWT.NONE);
    mScalingComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
    GridLayout gl_mScalingComposite = new GridLayout(5, false);
    gl_mScalingComposite.horizontalSpacing = 0;
    mScalingComposite.setLayout(gl_mScalingComposite);

    mCropRadio = new Button(mScalingComposite, SWT.FLAT | SWT.TOGGLE);
    mCropRadio.setSelection(true);
    mCropRadio.setText("Crop");
    mCropRadio.addSelectionListener(this);

    mCenterRadio = new Button(mScalingComposite, SWT.FLAT | SWT.TOGGLE);
    mCenterRadio.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
    mCenterRadio.setText("Center");
    mCenterRadio.addSelectionListener(this);

    mShapeLabel = new Label(mConfigurationArea, SWT.NONE);
    mShapeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    mShapeLabel.setText("Shape");

    mShapeComposite = new Composite(mConfigurationArea, SWT.NONE);
    mShapeComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
    GridLayout gl_mShapeComposite = new GridLayout(5, false);
    gl_mShapeComposite.horizontalSpacing = 0;
    mShapeComposite.setLayout(gl_mShapeComposite);

    mSquareRadio = new Button(mShapeComposite, SWT.FLAT | SWT.TOGGLE);
    mSquareRadio.setSelection(true);
    mSquareRadio.setText("Square");
    mSquareRadio.addSelectionListener(this);

    mCircleButton = new Button(mShapeComposite, SWT.FLAT | SWT.TOGGLE);
    mCircleButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
    mCircleButton.setText("Circle");
    mCircleButton.addSelectionListener(this);

    mThemeLabel = new Label(mConfigurationArea, SWT.NONE);
    mThemeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    mThemeLabel.setText("Theme");

    mThemeComposite = new Composite(mConfigurationArea, SWT.NONE);
    mThemeComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    GridLayout gl_mThemeComposite = new GridLayout(2, false);
    gl_mThemeComposite.horizontalSpacing = 0;
    mThemeComposite.setLayout(gl_mThemeComposite);

    mHoloLightRadio = new Button(mThemeComposite, SWT.FLAT | SWT.TOGGLE);
    mHoloLightRadio.setText("Holo Light");
    mHoloLightRadio.setSelection(true);
    mHoloLightRadio.addSelectionListener(this);

    mHoloDarkRadio = new Button(mThemeComposite, SWT.FLAT | SWT.TOGGLE);
    mHoloDarkRadio.setText("Holo Dark");
    mHoloDarkRadio.addSelectionListener(this);

    mBgColorLabel = new Label(mConfigurationArea, SWT.NONE);
    mBgColorLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    mBgColorLabel.setText("Background Color:");

    mBgButton = new Button(mConfigurationArea, SWT.FLAT);
    mBgButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    mBgButton.addSelectionListener(this);
    mBgButton.setAlignment(SWT.CENTER);

    mFgColorLabel = new Label(mConfigurationArea, SWT.NONE);
    mFgColorLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    mFgColorLabel.setText("Foreground Color:");

    mFgButton = new Button(mConfigurationArea, SWT.FLAT);
    mFgButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    mFgButton.setAlignment(SWT.CENTER);
    mFgButton.addSelectionListener(this);

    if (SUPPORT_LAUNCHER_ICON_TYPES) {
      mEffectsLabel = new Label(mConfigurationArea, SWT.NONE);
      mEffectsLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
      mEffectsLabel.setText("Foreground Effects:");

      mEffectsComposite = new Composite(mConfigurationArea, SWT.NONE);
      mEffectsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
      GridLayout gl_mEffectsComposite = new GridLayout(5, false);
      gl_mEffectsComposite.horizontalSpacing = 0;
      mEffectsComposite.setLayout(gl_mEffectsComposite);

      mSimpleRadio = new Button(mEffectsComposite, SWT.FLAT | SWT.TOGGLE);
      mSimpleRadio.setSelection(true);
      mSimpleRadio.setText("Simple");
      mSimpleRadio.addSelectionListener(this);

      mFancyRadio = new Button(mEffectsComposite, SWT.FLAT | SWT.TOGGLE);
      mFancyRadio.setText("Fancy");
      mFancyRadio.addSelectionListener(this);

      mGlossyRadio = new Button(mEffectsComposite, SWT.FLAT | SWT.TOGGLE);
      mGlossyRadio.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
      mGlossyRadio.setText("Glossy");
      mGlossyRadio.addSelectionListener(this);
    }

    configurationScrollArea.setContent(mConfigurationArea);
    configurationScrollArea.setMinSize(mConfigurationArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    Label previewLabel = new Label(container, SWT.NONE);
    previewLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
    previewLabel.setText("Preview:");

    mPreviewArea = new Composite(container, SWT.BORDER);

    RowLayout rlPreviewAreaPreviewArea = new RowLayout(SWT.HORIZONTAL);
    rlPreviewAreaPreviewArea.wrap = true;
    rlPreviewAreaPreviewArea.pack = true;
    rlPreviewAreaPreviewArea.center = true;
    rlPreviewAreaPreviewArea.spacing = 0;
    rlPreviewAreaPreviewArea.marginBottom = 0;
    rlPreviewAreaPreviewArea.marginTop = 0;
    rlPreviewAreaPreviewArea.marginRight = 0;
    rlPreviewAreaPreviewArea.marginLeft = 0;
    mPreviewArea.setLayout(rlPreviewAreaPreviewArea);
    GridData gdMPreviewArea = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
    gdMPreviewArea.widthHint = PREVIEW_AREA_WIDTH;
    mPreviewArea.setLayoutData(gdMPreviewArea);

    // Initial color
    Display display = parent.getDisplay();
    // updateColor(display, new RGB(0xa4, 0xc6, 0x39), true /*background*/);
    updateColor(display, new RGB(0xff, 0x00, 0x00), true /*background*/);
    updateColor(display, new RGB(0x00, 0x00, 0x00), false /*background*/);

    // Start out showing the image form
    // mImageRadio.setSelection(true);
    // chooseForegroundTab(mImageRadio, mImageForm);
    // No, start out showing the text, since the user doesn't have to enter anything
    // initially and we still get images
    mTextRadio.setSelection(true);
    chooseForegroundTab(mTextRadio, mTextForm);
    new Label(mConfigurationArea, SWT.NONE);
    new Label(mConfigurationArea, SWT.NONE);
    new Label(mConfigurationArea, SWT.NONE);

    validatePage();
  }