當前位置: 首頁>>代碼示例>>Java>>正文


Java ColorDialog.setText方法代碼示例

本文整理匯總了Java中org.eclipse.swt.widgets.ColorDialog.setText方法的典型用法代碼示例。如果您正苦於以下問題:Java ColorDialog.setText方法的具體用法?Java ColorDialog.setText怎麽用?Java ColorDialog.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.swt.widgets.ColorDialog的用法示例。


在下文中一共展示了ColorDialog.setText方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: editColor

import org.eclipse.swt.widgets.ColorDialog; //導入方法依賴的package包/類
/**
 * Opens a dialog to change the color.
 *
 * @param color
 *          the color to change
 * @return the changed color
 */
public static String editColor(Diagram diagram, String colorStr) {
  Color color = null;
  if (colorStr == null) {
    color = Graphiti.getGaService().manageColor(diagram, IColorConstant.BLACK);
  } else {
    color = EditorUtils.buildColorFromString(diagram, colorStr);
  }
  ColorDialog colorDialog = new ColorDialog(Display.getDefault().getActiveShell());
  colorDialog.setText("Choose color");
  colorDialog.setRGB(new RGB(color.getRed(), color.getGreen(), color.getBlue()));

  RGB retRgb = colorDialog.open();
  if (retRgb == null) {
    return colorStr;
  } else {
    return EditorUtils.toString(retRgb);
  }
}
 
開發者ID:eclipse,項目名稱:triquetrum,代碼行數:26,代碼來源:EditorUtils.java

示例2: editColor

import org.eclipse.swt.widgets.ColorDialog; //導入方法依賴的package包/類
/**
 * Opens a dialog to change the color.
 * 
 * @param color
 *            the color to change
 * @return the changed color
 */
public static Color editColor(Color color) {
	if (color != null && color.eContainer() instanceof Diagram) {
		Shell shell = getShell();
		ColorDialog colorDialog = new ColorDialog(shell);
		colorDialog.setText("Choose Color");
		colorDialog.setRGB(new RGB(color.getRed(), color.getGreen(), color.getBlue()));

		RGB retRgb = colorDialog.open();
		if (retRgb == null) {
			return null;
		}

		Diagram diagram = (Diagram) color.eContainer();
		Color newColor = Graphiti.getGaService().manageColor(diagram, retRgb.red, retRgb.green, retRgb.blue);
		return newColor;

	}

	return null;
}
 
開發者ID:logicalhacking,項目名稱:SecureBPMN,代碼行數:28,代碼來源:SampleUtil.java

示例3: selectColor

import org.eclipse.swt.widgets.ColorDialog; //導入方法依賴的package包/類
/**
 * Open up a widget color wheel with the specified title.
 * Should be platform specific.
 * the specified integer should be in the following format.
 * lowest order 8 bits red
 * middle order 8 bits green
 * highest order 8 bits blue
 * ie: xxxxxxxx xxxxxxxx  xxxxxxxx
 *     BLUE     GREEN     RED
 */
public Integer selectColor(int oldColor, String dialogTitle)
{
    RGB old = GraphicsUtil.getRGBFromColor(oldColor);

    // Open the platform specific color chooser
    ColorDialog dialog = new ColorDialog(window);
    dialog.setRGB(old);
    if (dialogTitle != null)
    {
        dialog.setText(dialogTitle);
    }
    RGB newColor = dialog.open();

    if (newColor != null) {
        return new Integer(GraphicsUtil.getColorFromRGB(newColor));
    }

    return null;
}
 
開發者ID:cogtool,項目名稱:cogtool,代碼行數:30,代碼來源:DefaultInteraction.java

示例4: changeBackgroundColor

import org.eclipse.swt.widgets.ColorDialog; //導入方法依賴的package包/類
public void changeBackgroundColor() {
	ColorDialog cd = new ColorDialog(getShell());
	cd.setRGB(text.getBackground().getRGB());
	cd.setText("Choose a color");

	RGB newColor = cd.open();
	if (newColor != null)
		Config.getInstance().setValue(Config.BACKGROUND_COLOR,
				new Color(Display.getCurrent(), newColor));
	updateFont();
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:12,代碼來源:EditingPane.java

示例5: changeFontColor

import org.eclipse.swt.widgets.ColorDialog; //導入方法依賴的package包/類
public void changeFontColor() {
	ColorDialog cd = new ColorDialog(getShell());
	cd.setRGB(text.getBackground().getRGB());
	cd.setText("Choose a color");

	RGB newColor = cd.open();
	if (newColor != null)
		Config.getInstance().setValue(Config.FONT_COLOR,
				new Color(Display.getCurrent(), newColor));
	updateFont();
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:12,代碼來源:EditingPane.java

示例6: updatePropertyFromWidget

import org.eclipse.swt.widgets.ColorDialog; //導入方法依賴的package包/類
private void updatePropertyFromWidget() {
	ColorDialog cd = new ColorDialog(Display.getCurrent().getActiveShell());
	cd.setText("Choose color");
	cd.setRGB(getValueOfProperty().getRGB());
	RGB newColor = cd.open();
	if (newColor == null)
		return;
			
	try {
		BeanUtils.setProperty(bean, property, Colors.createColor(newColor));
	} catch (IllegalAccessException | InvocationTargetException e) {
		throw new RuntimeException(e);
	}	
}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:15,代碼來源:BindColorToButtonListener.java

示例7: run

import org.eclipse.swt.widgets.ColorDialog; //導入方法依賴的package包/類
public void run() {
	if (window != null) {
		ColorDialog dlg = new ColorDialog(window.getShell());
		AgentObject agent = AgentModelThread.getInstance().getAgentObject(objHash);
		dlg.setRGB(agent.getColor().getRGB());
		dlg.setText("Choose a Color");
		RGB rgb = dlg.open();
		if (rgb != null) {
			Color color = AgentColorManager.getInstance().changeColor(objHash, rgb);
			//agent.setColor(color);
		}
	}
}
 
開發者ID:scouter-project,項目名稱:scouter,代碼行數:14,代碼來源:SetColorAction.java

示例8: mouseDoubleClick

import org.eclipse.swt.widgets.ColorDialog; //導入方法依賴的package包/類
@Override
public void mouseDoubleClick(MouseEvent e) {
    final TreeItem selection;
    if (tree.getSelectionCount() == 1 && (selection = tree.getSelection()[0]).getData() != null) {
        ColorDialog dlg = new ColorDialog(getShell());
        // Change the title bar text
        dlg.setText(selection.getText(0));
        dlg.setRGB(selection.getParent().getMapInv().get(selection).getBackground(1).getRGB());
        // Open the dialog and retrieve the selected color
        RGB rgb = dlg.open();
        if (rgb != null) {
            GColour refCol = new GColour(-1, rgb.red / 255f, rgb.green / 255f, rgb.blue / 255f, 1f);
            tree.getMapInv().get(selection).setBackground(1, SWTResourceManager.getColor(rgb));
            Object[] colourObj = (Object[]) selection.getData();
            ColourType type = (ColourType) colourObj[0];
            switch (type) {
            case OPENGL_COLOUR:
                ((float[]) ((Object[]) colourObj[1])[0])[0] = refCol.getR();
                ((float[]) ((Object[]) colourObj[1])[1])[0] = refCol.getG();
                ((float[]) ((Object[]) colourObj[1])[2])[0] = refCol.getB();
                break;
            case SWT_COLOUR:
                ((Color[]) colourObj[1])[0] = SWTResourceManager.getColor(rgb) ;
                break;
            default:
                break;
            }

            for (EditorTextWindow w : Project.getOpenTextWindows()) {
                for (CTabItem t : w.getTabFolder().getItems()) {
                    ((CompositeTab) t).updateColours();
                }
            }
            tree.build();
            tree.update();
        }
    }
}
 
開發者ID:nilsschmidt1337,項目名稱:ldparteditor,代碼行數:39,代碼來源:OptionsDesign.java

示例9: openView

import org.eclipse.swt.widgets.ColorDialog; //導入方法依賴的package包/類
public static void openView(final IColorRunnable runnable, final RGB initial) {
	final Shell shell = new Shell(WorkbenchHelper.getDisplay(), SWT.MODELESS);
	final ColorDialog dlg = new ColorDialog(shell, SWT.MODELESS);
	dlg.setText("Choose a custom color");
	dlg.setRGB(initial);
	final RGB rgb = dlg.open();
	// final int a = StringUtils.INDEX_NOT_FOUND;
	if (rgb != null) {
		if (runnable != null) {
			runnable.run(rgb.red, rgb.green, rgb.blue);
		}
	}
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:14,代碼來源:GamaColorMenu.java

示例10: open

import org.eclipse.swt.widgets.ColorDialog; //導入方法依賴的package包/類
/**
 * Activate the editor for this selector. This causes the color selection
 * dialog to appear and wait for user input.
 * 
 * @since 3.2
 */
public void open( )
{
	/*
	 * Bugzilla #269139 - Issue about color editor dialog in Highlight
	 * Editor dialog. (After the fixing of Bugizlla #223759, the change is
	 * not applicable on Linux and causes #269139. The workaround is to
	 * detect what type the OS is and only appply the change of #223759 on
	 * Windows.)
	 */
	Shell shell = null;
	Boolean isWin32 = Platform.getOS( ).equals( Platform.OS_WIN32 );
	if ( isWin32 )
	{
		shell = new Shell( Display.getCurrent( ), SWT.SHELL_TRIM );
		shell.setLocation( fButton.toDisplay( 0, 0 ).x
				+ fButton.getBounds( ).width,
				fButton.toDisplay( 0, 0 ).y - fButton.getBounds( ).height );
	}
	ColorDialog colorDialog = new ColorDialog( isWin32 ? shell
			: fButton.getShell( ), SWT.APPLICATION_MODAL );
	RGB[] rgbs = ReportPlugin.getDefault( ).getCustomColorsPreference( );
	if ( rgbs != null )
	{
		colorDialog.setRGBs( rgbs );
	}
	colorDialog.setRGB( fColorValue );
	colorDialog.setText( Messages.getString( "ColorSelector.ColorDialog.Title" ) ); //$NON-NLS-1$
	RGB newColor = colorDialog.open( );
	ReportPlugin.getDefault( )
			.setCustomColorsPreference( colorDialog.getRGBs( ) );
	if ( newColor != null )
	{
		RGB oldValue = fColorValue;
		fColorValue = newColor;
		final Object[] finalListeners = getListeners( );
		if ( finalListeners.length > 0 )
		{
			PropertyChangeEvent pEvent = new PropertyChangeEvent( this,
					PROP_COLORCHANGE,
					oldValue,
					newColor );
			for ( int i = 0; i < finalListeners.length; ++i )
			{
				IPropertyChangeListener listener = (IPropertyChangeListener) finalListeners[i];
				listener.propertyChange( pEvent );
			}
		}
		updateColorImage( );
	}
	if ( isWin32 )
	{
		shell.dispose( );
	}
}
 
開發者ID:eclipse,項目名稱:birt,代碼行數:61,代碼來源:ColorSelector.java


注:本文中的org.eclipse.swt.widgets.ColorDialog.setText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。