Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.ColorDialog


    public void widgetDefaultSelected( SelectionEvent e ) {
        widgetSelected(e);
    }

    public void widgetSelected( SelectionEvent e ) {
        ColorDialog dialog = new ColorDialog(e.display.getActiveShell());
        Color currentColor = (Color) e.widget.getData();
        RGB currentRGB = new RGB(currentColor.getRed(), currentColor.getGreen(), currentColor.getBlue());
        dialog.setRGB(currentRGB);
        dialog.open();
       
        RGB rgb = dialog.getRGB();
       
        e.widget.setData(new Color(rgb.red, rgb.green, rgb.blue));
       
        configurator.updateColorButton();
        Event event = new Event();
View Full Code Here


  }
 
  @Override
  public void run() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    ColorDialog dialog = new ColorDialog(window.getShell());
    RGB color = dialog.open();
    if(color!=null){
      IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
      ITextSelection sel = (ITextSelection)editor.getSelectionProvider().getSelection();
      try {
        doc.replace(sel.getOffset(), 0, HTMLUtil.toHex(color));
View Full Code Here

        this.selectedColor = originalColor;
        setImage(getColorImage(originalColor));
        addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                ColorDialog dialog = new ColorDialog(new Shell(
                        Display.getDefault(), SWT.SHELL_TRIM));
                dialog.setRGB(selectedColor.getRGB());
                RGB selected = dialog.open();
                if (selected != null) {
                    update(selected);
                }
            }
        });
View Full Code Here

       
        try
        {
            shell.setBounds( x, y, 0, 0 );
           
            final ColorDialog dialog = new ColorDialog( shell );
           
            dialog.setText( property.definition().getLabel( false, CapitalizationType.TITLE_STYLE, false ) );
            dialog.setRGB( convert( (Color) ( (Value<?>) property ).content() ) );
           
            final RGB pickedColor = dialog.open();
           
            if( pickedColor != null )
            {
                return convert( pickedColor ).toString();
            }
View Full Code Here

        break;
      case SWT.Selection:
        Display display = event.display;
        MenuItem item = (MenuItem) event.widget;
        if (customColorMI == item) {
          ColorDialog dialog = new ColorDialog(parent.getShell());
          if (customColor != null && !customColor.isDisposed())
            dialog.setRGB(customColor.getRGB());
          RGB rgb = dialog.open();
          if (rgb == null)
            return;
          if (customColor != null)
            customColor.dispose();
          customColor = new Color(display, rgb);
          if (customPatternMI != null)
            customPatternMI.setImage(null);
          if (customGradientMI != null)
            customGradientMI.setImage(null);
          if (customImage != null)
            customImage.dispose();
          customImage = GraphicsExample.createImage(display, customColor);
          GraphicsBackground gb = new GraphicsBackground();
          gb.setBgImage(customImage);
          gb.setThumbNail(customImage);
          gb.setBgColor1(customColor);
          item.setData(gb);
          item.setImage(customImage);
          resources.add(customColor);
          resources.add(customImage);
        } else if (customPatternMI == item) {
          FileDialog dialog = new FileDialog(parent.getShell());
          dialog.setFilterExtensions(new String[] { "*.jpg", "*.gif", "*.*" });
          String name = dialog.open();
          if (name == null)
            return;
          if (customColorMI != null)
            customColorMI.setImage(null);
          if (customGradientMI != null)
            customGradientMI.setImage(null);
          if (customColor != null)
            customColor.dispose();
          if (customImage != null)
            customImage.dispose();
          if (customImageThumb != null)
            customImageThumb.dispose();
          customImage = new Image(display, name);
          customImageThumb = GraphicsExample.createThumbnail(display, name);
          GraphicsBackground gb = new GraphicsBackground();
          gb.setBgImage(customImage);
          gb.setThumbNail(customImageThumb);
          item.setData(gb);
          item.setImage(customImageThumb);
          resources.add(customImageThumb);
        } else if (customGradientMI == item) {
          GradientDialog dialog = new GradientDialog(parent.getShell());
          if (background != null) {
            if (background.getBgColor1() != null)
              dialog.setFirstRGB(background.getBgColor1().getRGB());
            if (background.getBgColor2() != null)
              dialog.setSecondRGB(background.getBgColor2().getRGB());
          }
          if (dialog.open() != SWT.OK)
            return;
          Color colorA = new Color(display, dialog.getFirstRGB());
          Color colorB = new Color(display, dialog.getSecondRGB());
          if (colorA == null || colorB == null)
            return;
          if (customColorMI != null)
            customColorMI.setImage(null);
          if (customPatternMI != null)
View Full Code Here

    Button defaultsButton = new Button(colorGroup, SWT.PUSH);
    defaultsButton.setText(ControlExample.getResourceString("Defaults"));
    defaultsButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

    /* Add listeners to set/reset colors and fonts. */
    colorDialog = new ColorDialog(shell);
    fontDialog = new FontDialog(shell);
    colorAndFontTable.addSelectionListener(new SelectionAdapter() {
      public void widgetDefaultSelected(SelectionEvent event) {
        changeFontOrColor(colorAndFontTable.getSelectionIndex());
      }
View Full Code Here

    /* Open the appropriate dialog type */
    String name = dialogCombo.getText();

    if (name.equals(ControlExample.getResourceString("ColorDialog"))) {
      ColorDialog dialog = new ColorDialog(shell, style);
      dialog.setRGB(new RGB(100, 100, 100));
      dialog.setText(ControlExample.getResourceString("Title"));
      RGB result = dialog.open();
      textWidget.append(ControlExample.getResourceString("ColorDialog") + Text.DELIMITER);
      textWidget.append(ControlExample.getResourceString("Result", new String[] { "" + result }) + Text.DELIMITER
          + Text.DELIMITER);
      return;
    }

    if (name.equals(ControlExample.getResourceString("DirectoryDialog"))) {
      DirectoryDialog dialog = new DirectoryDialog(shell, style);
      dialog.setMessage(ControlExample.getResourceString("Example_string"));
      dialog.setText(ControlExample.getResourceString("Title"));
      String result = dialog.open();
      textWidget.append(ControlExample.getResourceString("DirectoryDialog") + Text.DELIMITER);
      textWidget.append(ControlExample.getResourceString("Result", new String[] { "" + result }) + Text.DELIMITER
          + Text.DELIMITER);
      return;
    }

    if (name.equals(ControlExample.getResourceString("FileDialog"))) {
      FileDialog dialog = new FileDialog(shell, style);
      dialog.setFileName(ControlExample.getResourceString("readme_txt"));
      dialog.setFilterNames(DialogTab.FilterNames);
      dialog.setFilterExtensions(DialogTab.FilterExtensions);
      dialog.setText(ControlExample.getResourceString("Title"));
      String result = dialog.open();
      textWidget.append(ControlExample.getResourceString("FileDialog") + Text.DELIMITER);
      textWidget
          .append(ControlExample.getResourceString("Result", new String[] { "" + result }) + Text.DELIMITER);
      if ((dialog.getStyle() & SWT.MULTI) != 0) {
        String[] files = dialog.getFileNames();
        for (int i = 0; i < files.length; i++)
          textWidget.append("\t" + files[i] + Text.DELIMITER);
      }
      textWidget.append(Text.DELIMITER);
      return;
    }

    if (name.equals(ControlExample.getResourceString("FontDialog"))) {
      FontDialog dialog = new FontDialog(shell, style);
      dialog.setText(ControlExample.getResourceString("Title"));
      FontData result = dialog.open();
      textWidget.append(ControlExample.getResourceString("FontDialog") + Text.DELIMITER);
      textWidget.append(ControlExample.getResourceString("Result", new String[] { "" + result }) + Text.DELIMITER
          + Text.DELIMITER);
      return;
    }

    if (name.equals(ControlExample.getResourceString("PrintDialog"))) {
      PrintDialog dialog = new PrintDialog(shell, style);
      dialog.setText(ControlExample.getResourceString("Title"));
      PrinterData result = dialog.open();
      textWidget.append(ControlExample.getResourceString("PrintDialog") + Text.DELIMITER);
      textWidget.append(ControlExample.getResourceString("Result", new String[] { "" + result }) + Text.DELIMITER
          + Text.DELIMITER);
      return;
    }

    if (name.equals(ControlExample.getResourceString("MessageBox"))) {
      MessageBox dialog = new MessageBox(shell, style);
      dialog.setMessage(ControlExample.getResourceString("Example_string"));
      dialog.setText(ControlExample.getResourceString("Title"));
      int result = dialog.open();
      textWidget.append(ControlExample.getResourceString("MessageBox") + Text.DELIMITER);
      /*
       * The resulting integer depends on the original dialog style. Decode the result and display it.
       */
      switch (result) {
View Full Code Here

        gc.dispose();

        fButton.setImage(fImage);
        fButton.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent event) {
                ColorDialog colorDialog = new ColorDialog(fButton.getShell());
                colorDialog.setRGB(fColorValue);
                RGB newColor = colorDialog.open();
                if (newColor != null) {
                    fColorValue = newColor;
                    updateColorImage();
                }
            }
View Full Code Here

    return img;
  }

  private void onSelectOtherColor() {
    ColorDialog dialog = new ColorDialog(fParent.getShell());
    dialog.setRGB(fSelectedColor);
    RGB color = dialog.open();
    if (color != null)
      onColorSelected(color);
  }
View Full Code Here

    fButton.setImage(fImage);
    fButton.addSelectionListener(new SelectionAdapter() {

      public void widgetSelected(SelectionEvent event)
      {
        ColorDialog colorDialog = new ColorDialog(fButton.getShell());
        colorDialog.setRGB(fColorValue);
        RGB newColor = colorDialog.open();
        if(newColor != null)
        {
          fColorValue = newColor;
          updateColorImage();
        }
View Full Code Here

TOP

Related Classes of org.eclipse.swt.widgets.ColorDialog

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.