Example usage for org.eclipse.jface.resource ImageDescriptor createImage

List of usage examples for org.eclipse.jface.resource ImageDescriptor createImage

Introduction

In this page you can find the example usage for org.eclipse.jface.resource ImageDescriptor createImage.

Prototype

public Image createImage() 

Source Link

Document

Creates and returns a new SWT image for this image descriptor.

Usage

From source file:net.rim.ejde.internal.ui.views.BasicDebugView.java

License:Open Source License

/**
 * Creates the Image instance indicated by <code>imageId</code>.
 *
 * @param imageId/*from ww  w  . j a  v  a2 s  .com*/
 *            <code>int</code> number which indicates the image to be created.
 * @return Image instance or <code>null</code> if some exception occurs.
 */
static protected Image createImage(int imageId) {
    Image image = null;
    ImageDescriptor descriptor = null;
    switch (imageId) {
    case REFRESH_BUTTON: {
        descriptor = ContextManager.imageDescriptorFromPlugin(ContextManager.PLUGIN_ID,
                "icons/obj16/refresh_enabled.gif");
        break;
    }
    case SAVE_BUTTON: {
        descriptor = ContextManager.imageDescriptorFromPlugin(ContextManager.PLUGIN_ID,
                "icons/obj16/save_edit_enabled.gif");
        break;
    }
    case CLEAR_BUTTON: {
        descriptor = ContextManager.imageDescriptorFromPlugin(ContextManager.PLUGIN_ID,
                "icons/obj16/clear.gif");
        break;
    }
    case OPTIONS_BUTTON: {
        descriptor = ContextManager.imageDescriptorFromPlugin(ContextManager.PLUGIN_ID,
                "icons/obj16/options.gif");
        break;
    }
    case COMPARE_BUTTON: {
        descriptor = ContextManager.imageDescriptorFromPlugin(ContextManager.PLUGIN_ID,
                "icons/obj16/compare.gif");
        break;
    }
    case SNAPSHOT_BUTTON: {
        descriptor = ContextManager.imageDescriptorFromPlugin(ContextManager.PLUGIN_ID,
                "icons/obj16/snapshot.gif");
        break;
    }
    case GARBAGE_COLLECTION_BUTTON: {
        descriptor = ContextManager.imageDescriptorFromPlugin(ContextManager.PLUGIN_ID,
                "icons/obj16/recycle.gif");
        break;
    }
    case FILTER_BUTTON: {
        descriptor = ContextManager.imageDescriptorFromPlugin(ContextManager.PLUGIN_ID,
                "icons/obj16/filter.gif");
        break;
    }
    case FORWARD_BUTTON: {
        descriptor = ContextManager.imageDescriptorFromPlugin(ContextManager.PLUGIN_ID,
                "icons/obj16/forward_nav.gif");
        break;
    }
    case BACKWARD_BUTTON: {
        descriptor = ContextManager.imageDescriptorFromPlugin(ContextManager.PLUGIN_ID,
                "icons/obj16/backward_nav.gif");
        break;
    }
    case RETURN_TO_START_BUTTON: {
        descriptor = ContextManager.imageDescriptorFromPlugin(ContextManager.PLUGIN_ID,
                "icons/obj16/return_to_start.gif");
        break;
    }
    case RETURN_TO_END_BUTTON: {
        descriptor = ContextManager.imageDescriptorFromPlugin(ContextManager.PLUGIN_ID,
                "icons/obj16/return_to_end.gif");
        break;
    }
    case SAVE_TO_XML: {
        descriptor = ContextManager.imageDescriptorFromPlugin(ContextManager.PLUGIN_ID,
                "icons/obj16/save_edit_enabled.gif");
        break;
    }
    case SAVE_RAW_TO_XML: {
        descriptor = ContextManager.imageDescriptorFromPlugin(ContextManager.PLUGIN_ID,
                "icons/obj16/save_edit_enabled.gif");
        break;
    }
    case OPEN_PROFILEVIS: {
        descriptor = ContextManager.imageDescriptorFromPlugin(ContextManager.PLUGIN_ID,
                "icons/obj16/openfile.gif");
        break;
    }
    }
    if (descriptor != null) {
        image = descriptor.createImage();
    }
    return image;
}

From source file:net.roboconf.eclipse.modeler.RoboconfModelerPlugin.java

License:Apache License

/**
 * Finds an image from a relative path.//from w  w w. j a v a  2  s .c  o m
 * @param filePath the relative file path
 * @return an image, or null if none was found
 */
public static Image findImage(String filePath) {

    ImageDescriptor desc = imageDescriptorFromPlugin(PLUGIN_ID, filePath);
    Image img = null;
    try {
        img = desc.createImage();

    } catch (Exception e) {
        log("Image " + filePath + " could not be found.", IStatus.ERROR);
    }

    return img;
}

From source file:net.sf.eclipsecs.ui.CheckstyleUIPluginImages.java

License:Open Source License

/**
 * Gets an image from a given descriptor.
 * //from w  ww .ja v a  2s.  com
 * @param descriptor the descriptor
 * @return the image
 */
public static Image getImage(ImageDescriptor descriptor) {

    Image image = CACHED_IMAGES.get(descriptor);
    if (image == null) {
        image = descriptor.createImage();
        CACHED_IMAGES.put(descriptor, image);
    }
    return image;
}

From source file:net.sf.eclipsensis.EclipseNSISPlugin.java

License:Open Source License

public void run(final boolean fork, final boolean cancelable, final IRunnableWithProgress runnable) {
    try {//  w w w .  j  a v a  2s .  c o  m
        if (Display.getCurrent() == null) {
            //fork and cancelable are meaningless here
            runnable.run(new NullProgressMonitor());
        } else {
            boolean useWorkbenchWindow = false;
            try {
                useWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()
                        .isVisible();
            } catch (Exception e) {
                useWorkbenchWindow = false;
            }
            if (!useWorkbenchWindow) {
                if (mBundleContext != null && mBundleContext.getBundle().getState() == Bundle.STARTING) {
                    //Startup in progress- overlay the splash screen
                    String splashFile = System.getProperty("org.eclipse.equinox.launcher.splash.location"); //$NON-NLS-1$
                    if (!Common.isEmpty(splashFile)) {
                        File file = new File(splashFile);
                        if (IOUtility.isValidFile(file)) {
                            ImageDescriptor desc = ImageDescriptor.createFromURL(file.toURI().toURL());
                            final Image image = desc.createImage();
                            Rectangle rect = image.getBounds();
                            String foregroundColor = null;
                            IProduct product = Platform.getProduct();
                            if (product != null) {
                                foregroundColor = product
                                        .getProperty(IProductConstants.STARTUP_FOREGROUND_COLOR);
                            }
                            RGB fgRGB;
                            try {
                                fgRGB = ColorManager.getRGB(Integer.parseInt(foregroundColor, 16));
                            } catch (Exception ex) {
                                fgRGB = ColorManager.getRGB(13817855); // D2D7FF=white
                            }
                            Monitor monitor = Display.getCurrent().getPrimaryMonitor();
                            Point pt = Geometry.centerPoint(monitor.getBounds());
                            MinimalProgressMonitorDialog dialog = new MinimalProgressMonitorDialog(
                                    Display.getCurrent().getActiveShell(), rect.width, rect.width);
                            dialog.setBGImage(image);
                            dialog.setForegroundRGB(fgRGB);
                            dialog.create();
                            Shell shell = dialog.getShell();
                            shell.setLocation(shell.getLocation().x, pt.y + rect.height / 2);
                            shell.addDisposeListener(new DisposeListener() {
                                public void widgetDisposed(DisposeEvent e) {
                                    image.dispose();
                                }
                            });
                            dialog.run(fork, cancelable, runnable);
                            return;
                        }
                    }
                }
                new MinimalProgressMonitorDialog(Display.getDefault().getActiveShell()).run(fork, cancelable,
                        runnable);
            } else {
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(fork, cancelable, runnable);
            }
        }
    } catch (Exception e) {
        log(e);
    }
}

From source file:net.sf.fjep.fatjar.wizard.FJExportWizardConfigPage.java

License:Open Source License

/**
 * @see IDialogPage#createControl(Composite)
 *//* www.j a v a2s . c om*/
public void createControl(Composite parent) {
    justCreated = true;

    controlParent = parent;

    GridData gd;
    Label label;

    Composite comp = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    comp.setLayout(layout);
    layout.numColumns = 3;
    layout.verticalSpacing = 9;

    // The following comment indicates a new row on the grid
    // ----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setText("&Jar-Name:");

    jarnameText = new Text(comp, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = layout.numColumns - 1;
    jarnameText.setLayoutData(gd);
    jarnameText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });

    //      browseJarnameButton = new Button(comp, SWT.PUSH);
    //      browseJarnameButton.setText("Browse...");
    //      browseJarnameButton.addSelectionListener(new SelectionAdapter() {
    //         public void widgetSelected(SelectionEvent e) {
    //            handleJarnameBrowse();
    //         }
    //      });
    //      browseJarnameButton.setVisible(false);

    // ----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setVisible(false);
    //
    jarnameIsExternCheckbox = new Button(comp, SWT.CHECK);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    jarnameIsExternCheckbox.setLayoutData(gd);
    jarnameIsExternCheckbox.setText("use extern Jar-Name");
    jarnameIsExternCheckbox.setToolTipText(
            "path for Jar-Name is absolute if checked or relative to project root folder when unchecked");
    jarnameIsExternCheckbox.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            boolean jarnameIsExtern = jarnameIsExternCheckbox.getSelection();
            String jarname = jarnameText.getText();
            if (jarnameIsExtern) {
                jarname = BuildFatJar.getProjectDir(jproject) + File.separator + jarname;
            } else {
                String projectDir = BuildFatJar.getProjectDir(jproject) + File.separator;
                if (jarname.startsWith(projectDir)) {
                    jarname = jarname.substring(projectDir.length());
                } else {
                    jarname = File.separatorChar + jarname;
                    jarname = jarname.substring(jarname.lastIndexOf(File.separatorChar) + 1);
                }
            }
            jarnameText.setText(jarname);
        }
    });
    jarnameIsExternCheckbox.setVisible(false);
    //
    label = new Label(comp, SWT.NULL);
    label.setVisible(false);
    // ----------------------------------------------------------
    //      label = new Label(comp, SWT.SEPARATOR | SWT.HORIZONTAL);
    //      gd = new GridData(GridData.FILL_HORIZONTAL);
    //      gd.horizontalSpan = 3;
    //      label.setLayoutData(gd);
    // ----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setVisible(false);
    //
    useManifestFileCheckbox = new Button(comp, SWT.CHECK);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    useManifestFileCheckbox.setLayoutData(gd);
    useManifestFileCheckbox.setText("select Manifest file");
    useManifestFileCheckbox.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            boolean useManifestFile = useManifestFileCheckbox.getSelection();
            manifestfileText.setEnabled(useManifestFile);
            browseManifestfileButton.setEnabled(useManifestFile);
            manifestmainclassText.setEnabled(!useManifestFile);
            manifestclasspathText.setEnabled(!useManifestFile);
        }
    });
    useManifestFileCheckbox.setVisible(false);
    //
    label = new Label(comp, SWT.NULL);
    label.setVisible(false);

    // ----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setText("&Manifest:");
    label.setVisible(false);
    //
    manifestfileText = new Text(comp, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    manifestfileText.setLayoutData(gd);
    manifestfileText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });
    manifestfileText.setVisible(false);
    //
    browseManifestfileButton = new Button(comp, SWT.PUSH);
    browseManifestfileButton.setText("Browse...");
    browseManifestfileButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            handleManifestfileBrowse();
        }
    });
    browseManifestfileButton.setVisible(false);
    // ----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setText("&Main-Class:");
    label.setVisible(false);
    //
    manifestmainclassText = new Text(comp, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    manifestmainclassText.setLayoutData(gd);
    manifestmainclassText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });
    manifestmainclassText.setText(AguiConstants.SDK_MAIN_CLASS_NAME);
    manifestmainclassText.setVisible(false);
    //
    browseManifestmainclassButton = new Button(comp, SWT.PUSH);
    browseManifestmainclassButton.setText("Browse...");
    browseManifestmainclassButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            handleManifestmainclassBrowse();
        }
    });
    browseManifestmainclassButton.setVisible(false);
    // ----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setText("&Class-Path:");
    label.setVisible(false);
    //
    manifestclasspathText = new Text(comp, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    manifestclasspathText.setLayoutData(gd);
    manifestclasspathText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });
    manifestclasspathText.setVisible(false);
    // ----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setVisible(false);
    //
    manifestmergeallCheckbox = new Button(comp, SWT.CHECK);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    manifestmergeallCheckbox.setLayoutData(gd);
    manifestmergeallCheckbox.setText("merge individual-sections of all MANIFEST.MF files");
    manifestmergeallCheckbox.setEnabled(true);
    manifestmergeallCheckbox.setVisible(false);
    //
    label = new Label(comp, SWT.NULL);
    label.setVisible(false);
    // ----------------------------------------------------------
    //      label = new Label(comp, SWT.SEPARATOR | SWT.HORIZONTAL);
    //      gd = new GridData(GridData.FILL_HORIZONTAL);
    //      gd.horizontalSpan = 3;
    //      label.setLayoutData(gd);
    // ----------------------------------------------------------
    // Add a help icon for One-JAR, and a checkbox to enable
    // One-JAR support.
    Label help = new Label(comp, SWT.NONE);
    ImageDescriptor desc = ImageDescriptor
            .createFromURL(AguiPlugin.getDefault().getBundle().getEntry("icons/help.gif"));
    gd = new GridData();
    gd.horizontalAlignment = GridData.END;
    help.setLayoutData(gd);
    help.setImage(desc.createImage());
    help.setToolTipText("One-JAR Help");
    help.addMouseListener(new MouseListener() {
        public void mouseDoubleClick(MouseEvent e) {
        }

        public void mouseDown(MouseEvent e) {
        }

        public void mouseUp(MouseEvent e) {
            showOneJARHelp();
        }
    });
    help.setVisible(false);
    oneJarButton = new Button(comp, SWT.CHECK);
    oneJarButton.setText("One-JAR");
    oneJarButton.setToolTipText("Build a One-JAR executable (preserves supporting Jar files)");
    oneJarButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            boolean oneJar = oneJarButton.getSelection();
            if (oneJarLicenseRequired) {
                int code = showOneJARLicense();
                if (code == 1) {
                    // Didn't agree, reset the selection.
                    oneJarButton.setSelection(false);
                    return;
                }
                oneJarLicenseRequired = false;
            }
            manifestmergeallCheckbox.setEnabled(!oneJar);
            oneJarExpandLabel.setEnabled(oneJar);
            oneJarExpandText.setEnabled(oneJar);
            dialogChanged();
        }
    });
    oneJarButton.setVisible(false);
    //
    label = new Label(comp, SWT.LEFT);
    label.setVisible(false);
    // ----------------------------------------------------------
    oneJarExpandLabel = new Label(comp, SWT.NULL);
    oneJarExpandLabel.setText("&One-Jar-Expand:");
    oneJarExpandLabel.setVisible(false);
    //
    oneJarExpandText = new Text(comp, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    oneJarExpandText.setLayoutData(gd);
    oneJarExpandText
            .setToolTipText("Comma separated list of directories/files to expand at runtime (optional)");
    oneJarExpandText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });
    oneJarExpandText.setVisible(false);
    //
    label = new Label(comp, SWT.LEFT);
    label.setVisible(true);

    if (jproject != null) {
        initialize();
        dialogChanged();
    }
    setControl(comp);
}

From source file:net.sf.fjep.fatjar.wizards.export.ConfigPage.java

License:Open Source License

/**
 * @see IDialogPage#createControl(Composite)
 *//*from  ww  w.ja  v a 2 s  .  c o  m*/
public void createControl(Composite parent) {

    justCreated = true;

    controlParent = parent;

    GridData gd;
    Label label;

    Composite comp = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    comp.setLayout(layout);
    layout.numColumns = 3;
    layout.verticalSpacing = 9;

    // The following comment indicates a new row on the grid
    //----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setText("Launch-Config:");

    launchConfigText = new Text(comp, SWT.READ_ONLY);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    launchConfigText.setLayoutData(gd);

    //----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setText("Change to:");

    changeLaunchConfigCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    changeLaunchConfigCombo.setLayoutData(gd);
    changeLaunchConfigCombo.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });

    changeLaunchConfigButton = new Button(comp, SWT.PUSH);
    changeLaunchConfigButton.setText("Change...");
    changeLaunchConfigButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            handleUseLaunchConfigButton();
        }
    });

    //----------------------------------------------------------
    label = new Label(comp, SWT.SEPARATOR | SWT.HORIZONTAL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 3;
    label.setLayoutData(gd);

    //----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setText("NEW-&Jar-Name:");

    jarnameText = new Text(comp, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    jarnameText.setLayoutData(gd);
    jarnameText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });

    browseJarnameButton = new Button(comp, SWT.PUSH);
    browseJarnameButton.setText("Browse...");
    browseJarnameButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            handleJarnameBrowse();
        }
    });

    //----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setVisible(false);
    //
    jarnameIsExternCheckbox = new Button(comp, SWT.CHECK);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    jarnameIsExternCheckbox.setLayoutData(gd);
    jarnameIsExternCheckbox.setText("use extern Jar-Name");
    jarnameIsExternCheckbox.setToolTipText(
            "path for Jar-Name is absolute if checked or relative to project root folder when unchecked");
    jarnameIsExternCheckbox.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            boolean jarnameIsExtern = jarnameIsExternCheckbox.getSelection();
            String jarname = jarnameText.getText();
            if (jarnameIsExtern) {
                jarname = jproject.getAbsProjectDir() + File.separator + jarname;
            } else {
                String projectDir = jproject.getAbsProjectDir() + File.separator;
                if (jarname.startsWith(projectDir)) {
                    jarname = jarname.substring(projectDir.length());
                } else {
                    jarname = File.separatorChar + jarname;
                    jarname = jarname.substring(jarname.lastIndexOf(File.separatorChar) + 1);
                }
            }
            jarnameText.setText(jarname);
        }
    });
    //
    label = new Label(comp, SWT.NULL);
    label.setVisible(false);

    //----------------------------------------------------------
    label = new Label(comp, SWT.SEPARATOR | SWT.HORIZONTAL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 3;
    label.setLayoutData(gd);

    //----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setVisible(false);
    //
    useManifestFileCheckbox = new Button(comp, SWT.CHECK);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    useManifestFileCheckbox.setLayoutData(gd);
    useManifestFileCheckbox.setText("select Manifest file");
    useManifestFileCheckbox.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            boolean useManifestFile = useManifestFileCheckbox.getSelection();
            manifestfileText.setEnabled(useManifestFile);
            browseManifestfileButton.setEnabled(useManifestFile);
            manifestmainclassText.setEnabled(!useManifestFile);
            manifestclasspathText.setEnabled(!useManifestFile);
            manifestargumentsText.setEnabled(!useManifestFile);
            manifestvmargumentsText.setEnabled(!useManifestFile);
        }
    });
    //
    label = new Label(comp, SWT.NULL);
    label.setVisible(false);

    //----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setText("&Manifest:");
    //
    manifestfileText = new Text(comp, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    manifestfileText.setLayoutData(gd);
    manifestfileText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });
    //
    browseManifestfileButton = new Button(comp, SWT.PUSH);
    browseManifestfileButton.setText("Browse...");
    browseManifestfileButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            handleManifestfileBrowse();
        }
    });

    //----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setText("&Main-Class:");
    //
    manifestmainclassText = new Text(comp, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    manifestmainclassText.setLayoutData(gd);
    manifestmainclassText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
            FJExpWizard fjew = (FJExpWizard) getWizard();
            if (fjew.autoJarPage != null) {
                fjew.autoJarPage.dialogChanged();
            }
        }
    });
    //
    browseManifestmainclassButton = new Button(comp, SWT.PUSH);
    browseManifestmainclassButton.setText("Browse...");
    browseManifestmainclassButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            handleManifestmainclassBrowse();
        }
    });

    //----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setText("&Class-Path:");
    //
    manifestclasspathText = new Text(comp, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    manifestclasspathText.setLayoutData(gd);
    manifestclasspathText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });

    //----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setText("Arguments:");
    //
    manifestargumentsText = new Text(comp, SWT.BORDER | SWT.SINGLE);
    manifestargumentsText.setToolTipText(
            "if not empty: causes a boot-class to be added and started before original main-class");
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    manifestargumentsText.setLayoutData(gd);
    manifestargumentsText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });

    //----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setText("Defines:");
    //
    manifestvmargumentsText = new Text(comp, SWT.BORDER | SWT.SINGLE);
    manifestvmargumentsText.setToolTipText(
            "multiple \"-D<propname>=<value>\" allowed. If not empty: causes a boot-class to be added and started before original main-class");
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    manifestvmargumentsText.setLayoutData(gd);
    manifestvmargumentsText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });

    //----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setVisible(false);
    //
    manifestmergeallCheckbox = new Button(comp, SWT.CHECK);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    manifestmergeallCheckbox.setLayoutData(gd);
    manifestmergeallCheckbox.setText("merge individual-sections of all MANIFEST.MF files");
    manifestmergeallCheckbox.setEnabled(true);
    //
    label = new Label(comp, SWT.NULL);
    label.setVisible(false);

    //----------------------------------------------------------
    label = new Label(comp, SWT.NULL);
    label.setVisible(false);
    //
    manifestremovesignersCheckbox = new Button(comp, SWT.CHECK);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    manifestremovesignersCheckbox.setLayoutData(gd);
    manifestremovesignersCheckbox.setText("remove signer files (*.SF) in META-INF");
    manifestremovesignersCheckbox.setEnabled(true);

    //----------------------------------------------------------
    label = new Label(comp, SWT.SEPARATOR | SWT.HORIZONTAL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 3;
    label.setLayoutData(gd);

    //----------------------------------------------------------
    // Add a help icon for One-JAR, and a checkbox to enable
    // One-JAR support.
    Label help = new Label(comp, SWT.NONE);
    ImageDescriptor desc = ImageDescriptor
            .createFromURL(AguiPlugin.getDefault().getBundle().getEntry("icons/help.gif"));
    gd = new GridData();
    gd.horizontalAlignment = GridData.END;
    help.setLayoutData(gd);
    help.setImage(desc.createImage());
    help.setToolTipText("One-JAR Help");

    help.addMouseListener(new MouseListener() {
        public void mouseDoubleClick(MouseEvent e) {
        }

        public void mouseDown(MouseEvent e) {
        }

        public void mouseUp(MouseEvent e) {
            showOneJARHelp();
        }
    });

    oneJarButton = new Button(comp, SWT.CHECK);
    oneJarButton.setText("One-JAR");
    oneJarButton.setToolTipText("Build a One-JAR executable (preserves supporting Jar files)");

    oneJarButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            boolean oneJar = oneJarButton.getSelection();
            if (oneJarLicenseRequired) {
                int code = showOneJARLicense();
                if (code == 1) {
                    // Didn't agree, reset the selection.
                    oneJarButton.setSelection(false);
                    return;
                }
                oneJarLicenseRequired = false;
            }
            manifestmergeallCheckbox.setEnabled(!oneJar);
            manifestremovesignersCheckbox.setEnabled(!oneJar);
            oneJarExpandLabel.setEnabled(oneJar);
            oneJarExpandText.setEnabled(oneJar);
            dialogChanged();
        }
    });

    label = new Label(comp, SWT.LEFT);
    label.setVisible(true);

    //----------------------------------------------------------
    oneJarExpandLabel = new Label(comp, SWT.NULL);
    oneJarExpandLabel.setText("&One-Jar-Expand:");
    //
    oneJarExpandText = new Text(comp, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    oneJarExpandText.setLayoutData(gd);
    oneJarExpandText
            .setToolTipText("Comma separated list of directories/files to expand at runtime (optional)");
    oneJarExpandText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });

    //
    label = new Label(comp, SWT.LEFT);
    label.setVisible(true);

    if (jproject != null) {
        initialize();
        dialogChanged();
    }
    setControl(comp);
}

From source file:net.sf.jmoney.entrytable.OtherEntriesButton.java

License:Open Source License

@Override
public IPropertyControl<EntryData> createCellControl(Composite parent, final RowControl rowControl,
        final EntryRowControl coordinator) {
    if (downArrowImage == null) {
        ImageDescriptor descriptor = JMoneyPlugin.createImageDescriptor("comboArrow.gif"); //$NON-NLS-1$
        downArrowImage = descriptor.createImage();
    }/* w ww  .j a  v a 2  s .c o m*/

    return new ButtonCellControl(rowControl, coordinator, downArrowImage,
            Messages.OtherEntriesButton_ToolTipText) {
        @Override
        protected void run(EntryRowControl rowControl) {
            final OtherEntriesShell shell = new OtherEntriesShell(rowControl.getShell(), SWT.ON_TOP,
                    coordinator.getUncommittedEntryData(), otherEntriesRootBlock, false);
            Display display = rowControl.getDisplay();
            Rectangle rect = display.map(rowControl, null, this.getControl().getBounds());
            shell.open(rect);
        }
    };
}

From source file:net.sf.jmoney.fields.DateControl.java

License:Open Source License

/**
 * @param parent//from  www . j  av  a2s .c  om
 * @param style
 */
public DateControl(final Composite parent) {
    super(parent, SWT.NULL);

    setBackgroundMode(SWT.INHERIT_FORCE);

    setLayout(new DialogCellLayout());

    textControl = new Text(this, SWT.LEFT);

    textControl.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            // CTRL + and CTRL - increment and decrement the date respectively.
            // It would be even easier for the user the CTRL did not have to be
            // pressed, but then it would not be possible to have a date format
            // that contains '-'.
            if (e.stateMask == SWT.CONTROL && (e.character == '+' || e.character == '-')) {

                Calendar calendar = Calendar.getInstance();
                calendar.setTime(fDateFormat.parse(textControl.getText()));

                if (e.character == '+') {
                    calendar.add(Calendar.DAY_OF_MONTH, 1);
                } else {
                    calendar.add(Calendar.DAY_OF_MONTH, -1);
                }

                textControl.setText(fDateFormat.format(calendar.getTime()));

                e.doit = false;
            }
        }
    });

    button = new Button(this, SWT.DOWN);
    if (threeDotsImage == null) {
        ImageDescriptor descriptor = JMoneyPlugin.createImageDescriptor("dots_button.gif"); //$NON-NLS-1$
        threeDotsImage = descriptor.createImage();
    }
    button.setImage(threeDotsImage);

    button.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            final Shell shell = new Shell(parent.getShell(), SWT.ON_TOP);
            shell.setLayout(new RowLayout());
            swtcal = new DateTime(shell, SWT.CALENDAR);

            // Set the currently set date into the calendar control
            // (If the parse method returned null then the text control did not
            // contain a valid date.  In this case no date is set into the
            // date picker).
            try {
                String t = textControl.getText();
                Date date = fDateFormat.parse(t);
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(date);
                swtcal.setYear(calendar.get(Calendar.YEAR));
                swtcal.setMonth(calendar.get(Calendar.MONTH));
                swtcal.setDay(calendar.get(Calendar.DAY_OF_MONTH));
            } catch (IllegalArgumentException e) {
                // The date format was invalid.
                // Ignore this error (the calendar control
                // does not require a date to be set).
            }

            swtcal.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    Calendar cal = Calendar.getInstance();

                    /*
                    * First reset all fields. Otherwise differences in the time
                    * part, even if the difference is only milliseconds, will cause
                    * the date comparisons to fail.
                    * 
                    * Note also it is critical that whatever is done here is exactly the
                    * same as that done in VerySimpleDateFormat, otherwise dates will not
                    * match.  For example, if you replace clear() here with setTimeInMillis(0)
                    * then we get a different object (because data other than the date and time
                    * such as time zone information will be different).
                    */
                    cal.clear();

                    cal.set(swtcal.getYear(), swtcal.getMonth(), swtcal.getDay());
                    Date date = cal.getTime();
                    textControl.setText(fDateFormat.format(date));
                }
            });

            shell.pack();

            // Position the calendar shell below the date control,
            // unless the date control is so near the bottom of the display that
            // the calendar control would go off the bottom of the display,
            // in which case position the calendar shell above the date control.
            Display display = getDisplay();
            Rectangle rect = display.map(parent, null, getBounds());
            int calendarShellHeight = shell.getSize().y;
            if (rect.y + rect.height + calendarShellHeight <= display.getBounds().height) {
                shell.setLocation(rect.x, rect.y + rect.height);
            } else {
                shell.setLocation(rect.x, rect.y - calendarShellHeight);
            }

            shell.open();

            shell.addShellListener(new ShellAdapter() {
                @Override
                public void shellDeactivated(ShellEvent e) {
                    shell.close();
                    swtcal = null;
                }
            });
        }
    });
}

From source file:net.sf.simpletest.eclipse.SimpletestPlugin.java

License:Open Source License

public static Image createImage(String path) {

    ImageDescriptor id = createImageDescriptor(path);
    return id.createImage();

}

From source file:net.sf.smbt.ui.dmx.utils.DMXGraphicsUtil.java

License:LGPL

public Image createDMXGroupImage(String groupID) {
    if (groupID == null)
        return null;
    ChannelKind cKind = ChannelKind.get(groupID);
    String path = "icons/";
    if (cKind != null) {
        switch (cKind) {
        case BEAM: // i5
            path += "i5.gif";
            break;
        case COLOUR: // i3
            path += "i3.gif";
            break;
        case FX: // i12
            path += "i12.gif";
            break;
        case GOBO: // i4
            path += "i4.gif";
            break;
        case INTENSITY: // i2
            path += "i2.gif";
            break;
        case MAINTENANCE: // i16
            path += "i16.gif";
            break;
        case PAN: // i8
            path += "i8.gif";
            break;
        case PRISM: // i7
            path += "i7.gif";
            break;
        case SHUTTER: // i1
            path += "i1.gif";
            break;
        case SPEED: // i10
            path += "i10.gif";
            break;
        case TILT: // i9
            path += "i9.gif";
            break;
        case NOTHING:
        default:// w w w .  j a va  2  s.  com
            break;
        }
    }
    if ("icons/".equals(path)) {
        return null;
    }
    ImageDescriptor desc = Activator.imageDescriptorFromPlugin("net.sf.smbt.ui.dmx", path);
    if (desc == null) {
        return null;
    }
    return desc.createImage();
}