Search in sources :

Example 1 with IProduct

use of org.eclipse.core.runtime.IProduct in project dbeaver by serge-rider.

the class AboutBoxDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    //Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());
    parent.setBackground(background);
    Composite group = new Composite(parent, SWT.NONE);
    group.setBackground(background);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = 20;
    layout.marginWidth = 20;
    group.setLayout(layout);
    GridData gd;
    IProduct product = Platform.getProduct();
    {
        Label nameLabel = new Label(group, SWT.NONE);
        nameLabel.setBackground(background);
        nameLabel.setFont(NAME_FONT);
        nameLabel.setText(product.getName());
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalAlignment = GridData.CENTER;
        nameLabel.setLayoutData(gd);
    }
    Label titleLabel = new Label(group, SWT.NONE);
    titleLabel.setBackground(background);
    titleLabel.setFont(TITLE_FONT);
    titleLabel.setText(product.getProperty(PRODUCT_PROP_SUB_TITLE));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    titleLabel.setLayoutData(gd);
    titleLabel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {

                @Override
                public void run() {
                    // Do not create InstallationDialog directly
                    // but execute "org.eclipse.ui.help.installationDialog" command
                    IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                    IHandlerService service = workbenchWindow.getService(IHandlerService.class);
                    if (service != null) {
                        try {
                            //$NON-NLS-1$
                            service.executeCommand("org.eclipse.ui.help.installationDialog", null);
                        } catch (Exception e1) {
                        // just ignore error
                        }
                    }
                }
            });
        }
    });
    Label imageLabel = new Label(group, SWT.NONE);
    imageLabel.setBackground(background);
    gd = new GridData();
    gd.verticalAlignment = GridData.BEGINNING;
    gd.horizontalAlignment = GridData.CENTER;
    gd.grabExcessHorizontalSpace = true;
    imageLabel.setLayoutData(gd);
    imageLabel.setImage(ABOUT_IMAGE);
    Label versionLabel = new Label(group, SWT.NONE);
    versionLabel.setBackground(background);
    versionLabel.setText(CoreMessages.dialog_about_label_version + GeneralUtils.getProductVersion().toString());
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    versionLabel.setLayoutData(gd);
    Label releaseTimeLabel = new Label(group, SWT.NONE);
    releaseTimeLabel.setBackground(background);
    releaseTimeLabel.setText(DateFormat.getDateInstance(DateFormat.LONG).format(GeneralUtils.getProductReleaseDate()));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    releaseTimeLabel.setLayoutData(gd);
    Label authorLabel = new Label(group, SWT.NONE);
    authorLabel.setBackground(background);
    authorLabel.setText(product.getProperty(PRODUCT_PROP_COPYRIGHT));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    authorLabel.setLayoutData(gd);
    Link siteLink = UIUtils.createLink(group, UIUtils.makeAnchor(product.getProperty(PRODUCT_PROP_WEBSITE)), new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            UIUtils.launchProgram(e.text);
        }
    });
    siteLink.setBackground(background);
    gd = new GridData();
    gd.horizontalAlignment = GridData.CENTER;
    siteLink.setLayoutData(gd);
    return parent;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) MouseEvent(org.eclipse.swt.events.MouseEvent) Color(org.eclipse.swt.graphics.Color) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) IHandlerService(org.eclipse.ui.handlers.IHandlerService) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IProduct(org.eclipse.core.runtime.IProduct)

Example 2 with IProduct

use of org.eclipse.core.runtime.IProduct in project translationstudio8 by heartsome.

the class SelfBaseHelpSystem method getProductName.

/**
	 * Obtains name of the Eclipse product
	 * 
	 * @return String
	 */
public static String getProductName() {
    IProduct product = Platform.getProduct();
    if (product == null) {
        //$NON-NLS-1$
        return "";
    }
    String name = product.getName();
    //$NON-NLS-1$
    return name == null ? "" : name;
}
Also used : IProduct(org.eclipse.core.runtime.IProduct)

Example 3 with IProduct

use of org.eclipse.core.runtime.IProduct in project dbeaver by serge-rider.

the class UIUtils method updateMainWindowTitle.

public static void updateMainWindowTitle(IWorkbenchWindow window) {
    if (window == null) {
        return;
    }
    Shell shell = window.getShell();
    if (shell == null) {
        return;
    }
    IProject activeProject = DBeaverCore.getInstance().getProjectRegistry().getActiveProject();
    IProduct product = Platform.getProduct();
    //$NON-NLS-1$
    String title = product == null ? "Unknown" : product.getName();
    if (activeProject != null) {
        //$NON-NLS-1$
        title += " - " + activeProject.getName();
    }
    IWorkbenchPage activePage = window.getActivePage();
    if (activePage != null) {
        IEditorPart activeEditor = activePage.getActiveEditor();
        if (activeEditor != null) {
            title += " - [ " + activeEditor.getTitle() + " ]";
        }
    }
    shell.setText(title);
}
Also used : IProduct(org.eclipse.core.runtime.IProduct) IProject(org.eclipse.core.resources.IProject)

Example 4 with IProduct

use of org.eclipse.core.runtime.IProduct in project dbeaver by serge-rider.

the class DBeaverSplashHandler method initVisualization.

private void initVisualization() {
    String progressRectString = null, messageRectString = null, foregroundColorString = null, versionCoordString = null, versionInfoSizeString = null, versionInfoColorString = null;
    final IProduct product = Platform.getProduct();
    if (product != null) {
        progressRectString = product.getProperty(IProductConstants.STARTUP_PROGRESS_RECT);
        messageRectString = product.getProperty(IProductConstants.STARTUP_MESSAGE_RECT);
        foregroundColorString = product.getProperty(IProductConstants.STARTUP_FOREGROUND_COLOR);
        versionCoordString = product.getProperty("versionInfoCoord");
        versionInfoSizeString = product.getProperty("versionInfoSize");
        versionInfoColorString = product.getProperty("versionInfoColor");
    }
    setProgressRect(StringConverter.asRectangle(progressRectString, new Rectangle(275, 300, 280, 10)));
    setMessageRect(StringConverter.asRectangle(messageRectString, new Rectangle(275, 275, 280, 25)));
    final Point versionCoord = StringConverter.asPoint(versionCoordString, new Point(485, 215));
    final int versionInfoSize = StringConverter.asInt(versionInfoSizeString, 22);
    final RGB versionInfoRGB = StringConverter.asRGB(versionInfoColorString, new RGB(255, 255, 255));
    int foregroundColorInteger = 0xD2D7FF;
    try {
        if (foregroundColorString != null) {
            foregroundColorInteger = Integer.parseInt(foregroundColorString, 16);
        }
    } catch (Exception ex) {
    // ignore
    }
    setForeground(new RGB((foregroundColorInteger & 0xFF0000) >> 16, (foregroundColorInteger & 0xFF00) >> 8, foregroundColorInteger & 0xFF));
    normalFont = getContent().getFont();
    //boldFont = UIUtils.makeBoldFont(normalFont);
    FontData[] fontData = normalFont.getFontData();
    fontData[0].setStyle(fontData[0].getStyle() | SWT.BOLD);
    fontData[0].setHeight(versionInfoSize);
    boldFont = new Font(normalFont.getDevice(), fontData[0]);
    final Color versionColor = new Color(getContent().getDisplay(), versionInfoRGB);
    getContent().addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            String productVersion = "";
            if (product != null) {
                productVersion = GeneralUtils.getProductVersion().toString();
            }
            //String osVersion = Platform.getOS() + " " + Platform.getOSArch();
            if (boldFont != null) {
                e.gc.setFont(boldFont);
            }
            e.gc.setForeground(versionColor);
            e.gc.drawText(productVersion, versionCoord.x, versionCoord.y, true);
            //e.gc.drawText(osVersion, 115, 200, true);
            e.gc.setFont(normalFont);
        }
    });
}
Also used : PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) IProduct(org.eclipse.core.runtime.IProduct)

Aggregations

IProduct (org.eclipse.core.runtime.IProduct)4 IProject (org.eclipse.core.resources.IProject)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 PaintEvent (org.eclipse.swt.events.PaintEvent)1 PaintListener (org.eclipse.swt.events.PaintListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Color (org.eclipse.swt.graphics.Color)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 IHandlerService (org.eclipse.ui.handlers.IHandlerService)1