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

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

Introduction

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

Prototype

public static ImageDescriptor createFromFile(Class<?> location, String filename) 

Source Link

Document

Creates and returns a new image descriptor from a file.

Usage

From source file:edu.buffalo.cse.green.relationships.RelationshipGroup.java

License:Open Source License

/**
 * Note: the image file must be the name of the relationship (returned in
 * getName()) concatenated with .gif/*from  w  ww . j a va  2 s  .  co m*/
 * 
 * For example, if getName() returns the value "Association", then the image
 * file must be "Association.gif"
 */
public ImageDescriptor getImageDescriptor() {
    return ImageDescriptor.createFromFile(getPartClass(), getName() + ".gif");
}

From source file:edu.harvard.i2b2.eclipse.plugins.admin.utilities.views.PatientCountView.java

License:Open Source License

private void addHelpButtonToToolBar() {
    final IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
    Action helpAction = new Action() {
        public void run() {
            helpSystem//from w w w.  j a v  a2s  .  c o  m
                    .displayHelpResource("/edu.harvard.i2b2.eclipse.plugins.adminTool/html/i2b2_mt_index.html");
        }
    };
    helpAction.setImageDescriptor(ImageDescriptor.createFromFile(PatientCountView.class, "/icons/help.png"));

    getViewSite().getActionBars().getToolBarManager().add(helpAction);
}

From source file:edu.harvard.i2b2.eclipse.plugins.adminTool.views.AdminToolView.java

License:Open Source License

private void addHelpButtonToToolBar() {
    final IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
    Action helpAction = new Action() {
        public void run() {
            helpSystem//from w  ww .ja va 2 s .com
                    .displayHelpResource("/edu.harvard.i2b2.eclipse.plugins.adminTool/html/i2b2_mt_index.html");
        }
    };
    helpAction.setImageDescriptor(ImageDescriptor.createFromFile(AdminToolView.class, "/icons/help.png"));

    getViewSite().getActionBars().getToolBarManager().add(helpAction);
}

From source file:edu.harvard.i2b2.eclipse.plugins.analysis.views.AnalysisView.java

License:Open Source License

private void addHelpButtonToToolBar() {
    final IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
    Action helpAction = new Action() {
        public void run() {
            helpSystem.displayHelpResource(
                    "/edu.harvard.i2b2.eclipse.plugins.analysis/html/i2b2_analysis_index.htm");
        }//from w w  w. ja v  a  2s. c o  m
    };
    helpAction.setImageDescriptor(ImageDescriptor.createFromFile(AnalysisView.class, "/icons/help.png"));

    getViewSite().getActionBars().getToolBarManager().add(helpAction);
}

From source file:edu.harvard.i2b2.eclipse.plugins.explorer.views.ExplorerView.java

License:Open Source License

private void addHelpButtonToToolBar() {
    final IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
    Action helpAction = new Action() {
        public void run() {
            helpSystem.displayHelpResource(
                    "/edu.harvard.i2b2.eclipse.plugins.explorer/html/i2b2_timeline_index.htm");
        }/* ww  w.  j  ava2s  . c  o  m*/
    };
    helpAction.setImageDescriptor(ImageDescriptor.createFromFile(ExplorerView.class, "/icons/help.png"));

    getViewSite().getActionBars().getToolBarManager().add(helpAction);
}

From source file:edu.harvard.i2b2.eclipse.plugins.ontology.views.edit.ContainerWizard.java

License:Open Source License

public Thread addChild() {
    final Display theDisplay = Display.getCurrent();
    return new Thread() {
        @Override//w  w w.  j  av  a2  s. co m
        public void run() {
            try {
                add(theDisplay);
            } catch (Exception e) {
                log.error("Add child error");
            }
            theDisplay.syncExec(new Runnable() {
                public void run() {
                    MetadataRecord.getInstance().getBrowser().update();
                    MetadataRecord.getInstance().getSyncAction().setImageDescriptor(
                            ImageDescriptor.createFromFile(EditView.class, "/icons/red_database_refresh.png"));
                }
            });
        }
    };
}

From source file:edu.harvard.i2b2.eclipse.plugins.ontology.views.edit.ContainerWizard.java

License:Open Source License

public void createControl(Composite parent) {
    Composite itemSettings = new Composite(parent, SWT.NONE);

    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;// www .j  a va 2 s  .  c  om
    gridLayout.horizontalSpacing = 1;
    gridLayout.verticalSpacing = 1;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;

    itemSettings.setLayout(gridLayout);

    new Label(itemSettings, SWT.NONE);
    new Label(itemSettings, SWT.NONE);

    ImageDescriptor imageDescriptorFolder = ImageDescriptor.createFromFile(getClass(),
            "icons/closedFolder.jpg");
    ImageDescriptor imageDescriptorContainer = ImageDescriptor.createFromFile(getClass(),
            "icons/closedCase.jpg");

    Image image = null;
    if (MetadataRecord.getInstance().getParentData().getVisualattributes().startsWith("F"))
        image = imageDescriptorFolder.createImage();

    else if (MetadataRecord.getInstance().getParentData().getVisualattributes().startsWith("C"))
        image = imageDescriptorContainer.createImage();

    new Label(itemSettings, SWT.NONE).setText("The parent will be: ");
    Composite parentInfo = new Composite(itemSettings, SWT.NONE);
    parentInfo.setLayout(gridLayout);

    new Label(parentInfo, SWT.NONE).setImage(image);
    new Label(parentInfo, SWT.NONE).setText(" " + MetadataRecord.getInstance().getParentData().getName());

    new Label(itemSettings, SWT.NONE).setText("The path will be: ");
    new Label(itemSettings, SWT.NONE)
            .setText(StringUtil.getPath(MetadataRecord.getInstance().getParentData().getFullName()));

    new Label(itemSettings, SWT.NONE);
    new Label(itemSettings, SWT.NONE);

    new Label(itemSettings, SWT.NONE).setText("*Container Name:");
    text1 = new Text(itemSettings, SWT.BORDER);
    text1.setToolTipText("The Container Name is the name that appears in the navigate tree.");

    GridData textData = new GridData();
    textData.widthHint = 250;
    textData.grabExcessHorizontalSpace = true;
    textData.horizontalAlignment = SWT.FILL;
    text1.setLayoutData(textData);

    // Page is not complete until a name has been added
    text1.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent event) {
            //  update tooltip and symbol name as name is entered

            String name = text1.getText();
            text5.setText(MetadataRecord.getInstance().getParentData().getTooltip() + " \\ " + name);

            if (name.length() > 33)
                name = name.substring(0, 33) + "~";
            text6.setText(name);

            // Page is not complete until a name and symbol name have been added
            if ((text1.getText().length() > 0) && (text6.getText().length() > 0))
                setPageComplete(true);
            else
                setPageComplete(false);

        }
    });
    text1.addVerifyListener(new VerifyListener() {
        public void verifyText(VerifyEvent e) {
            if ((e.character == '\b') || (e.character == '\u007F')) {
                e.doit = true;
                return;
            }
            // dont allow certain characters.
            if (invalid(e.character))
                e.doit = false;

            if (text1.getText().length() > 1999)
                e.doit = false;
        }
    });

    new Label(itemSettings, SWT.NONE).setText("Tooltip:");
    text5 = new Text(itemSettings, SWT.BORDER);
    text5.setToolTipText("The Tooltip is the tooltip that appears in the navigate tree.");
    text5.setLayoutData(textData);
    String tooltip = MetadataRecord.getInstance().getParentData().getTooltip();
    // Limit length of tool tip to 255 chars
    if (tooltip.length() > 254)
        tooltip = tooltip.substring(0, 254);
    text5.setText(tooltip);
    text5.addVerifyListener(new VerifyListener() {
        public void verifyText(VerifyEvent e) {
            if ((e.character == '\b') || (e.character == '\u007F')) {
                e.doit = true;
                return;
            }
            if (text5.getText().length() > 254)
                e.doit = false;
        }
    });

    Label conceptLabel = new Label(itemSettings, SWT.NONE);
    conceptLabel.setText("Base code:");
    conceptLabel.setEnabled(false);
    Composite conceptCodeComp = new Composite(itemSettings, SWT.NONE);
    GridLayout grid2 = new GridLayout();
    grid2.numColumns = 2;
    grid2.horizontalSpacing = 1;
    grid2.verticalSpacing = 1;
    grid2.marginHeight = 0;
    grid2.marginWidth = 0;
    conceptCodeComp.setLayout(grid2);
    GridData data = new GridData();
    data.horizontalSpan = 1;
    data.horizontalAlignment = SWT.FILL;
    conceptCodeComp.setLayoutData(data);

    final Combo schemesCombo = new Combo(conceptCodeComp, SWT.READ_ONLY);
    schemesCombo.setEnabled(false);
    List<ConceptType> schemes = SchemesUtil.getInstance().getSchemes();
    if (schemes != null) {
        Iterator<ConceptType> schemesIterator = schemes.iterator();
        while (schemesIterator.hasNext()) {
            ConceptType scheme = (ConceptType) schemesIterator.next();
            String name = scheme.getName();
            schemesCombo.add(name);
        }
    }

    text2 = new Text(conceptCodeComp, SWT.BORDER);
    text2.setEnabled(false);
    text2.setToolTipText("Base codes (concept codes, provider codes) identify terms for queries.");
    GridData data2 = new GridData();
    data2.widthHint = 135;
    data2.grabExcessHorizontalSpace = true;
    data2.horizontalAlignment = SWT.FILL;
    text2.setLayoutData(data2);

    text2.addVerifyListener(new VerifyListener() {
        public void verifyText(VerifyEvent e) {
            if ((e.character == '\b') || (e.character == '\u007F')) {
                e.doit = true;
                return;
            }
            if (schemesKey.length() + text2.getText().length() > 49)
                e.doit = false;
        }
    });

    schemesCombo.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            // Item in list has been selected
            if (schemesCombo.getSelectionIndex() == 0)
                schemesKey = "";
            else {
                ConceptType concept = (ConceptType) SchemesUtil.getInstance().getSchemes()
                        .get(schemesCombo.getSelectionIndex());
                schemesKey = concept.getKey();
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            // this is not an option (text cant be entered)
        }
    });

    new Label(itemSettings, SWT.NONE).setText("*Symbol Name:");
    text6 = new Text(itemSettings, SWT.BORDER);
    text6.setToolTipText("The symbol name is appended to the path to create the full path name");
    text6.setLayoutData(textData);
    text6.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent event) {
            // Page is not complete until a name, concept and symbol name have been added
            if ((text1.getText().length() > 0) && (text6.getText().length() > 0))
                setPageComplete(true);
            else
                setPageComplete(false);
        }
    });
    text6.addVerifyListener(new VerifyListener() {
        public void verifyText(VerifyEvent e) {
            if ((e.character == '\b') || (e.character == '\u007F')) {
                e.doit = true;
                return;
            }
            // dont allow certain characters.
            if (invalid(e.character))
                e.doit = false;
            if (text6.getText().length() > 33)
                e.doit = false;
        }
    });

    new Label(itemSettings, SWT.NONE).setText("Sourcesystem code:");
    text3 = new Text(itemSettings, SWT.BORDER);
    text3.setToolTipText("A Sourcesystem code describes the system the data was derived from.");
    text3.setLayoutData(textData);
    text3.setText(UserInfoBean.getInstance().getUserName() + "_manualentry");
    text3.addVerifyListener(new VerifyListener() {
        public void verifyText(VerifyEvent e) {
            if ((e.character == '\b') || (e.character == '\u007F')) {
                e.doit = true;
                return;
            }
            if (text3.getText().length() > 49)
                e.doit = false;
        }
    });

    new Label(itemSettings, SWT.NONE).setText("Comment:");
    text4 = new Text(itemSettings, SWT.BORDER);
    text4.setToolTipText("Miscellaneous (optional) comments may be entered here.");
    text4.setLayoutData(textData);
    text4.addVerifyListener(new VerifyListener() {
        public void verifyText(VerifyEvent e) {
            if ((e.character == '\b') || (e.character == '\u007F')) {
                e.doit = true;
                return;
            }
            if (text4.getText().length() > 1999)
                e.doit = false;
        }
    });

    new Label(itemSettings, SWT.NONE).setText("Semantic type:");
    Composite semanticComp = new Composite(itemSettings, SWT.NONE);
    GridLayout grid3 = new GridLayout();
    grid2.numColumns = 3;
    grid2.horizontalSpacing = 1;
    grid2.verticalSpacing = 1;
    grid2.marginHeight = 0;
    grid2.marginWidth = 0;
    semanticComp.setLayout(grid2);
    semanticComp.setLayoutData(data);
    valTypeCombo = new Combo(semanticComp, SWT.READ_ONLY);
    valTypeCombo.setToolTipText("'DOC'== a document or note; 'LAB' == lab results");
    valTypeCombo.add("");
    valTypeCombo.add("DOC");
    valTypeCombo.add("LAB");

    valTypeCombo.setText("");

    valTypeCombo.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            if (valTypeCombo.getText().equals("LAB")) {
                enterValues.setSelection(true);
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            // this is not an option (text cant be entered)
        }
    });

    new Label(semanticComp, SWT.NONE).setText("      ");

    enterValues = new Button(semanticComp, SWT.CHECK);
    enterValues.setText("Enter Value Information");

    new Label(itemSettings, SWT.NONE);
    new Label(itemSettings, SWT.NONE);
    new Label(itemSettings, SWT.NONE).setText("* denotes required field.");

    setControl(itemSettings);

}

From source file:edu.harvard.i2b2.eclipse.plugins.ontology.views.edit.EditModifierWizard.java

License:Open Source License

public Thread modifyChild(final boolean inclSynonyms) {
    final Display theDisplay = Display.getCurrent();
    return new Thread() {
        @Override/*from   w  ww .  j  av a  2 s  .c om*/
        public void run() {
            try {
                modify(theDisplay, inclSynonyms);
            } catch (Exception e) {
                log.error("Edit child error");
            }
            theDisplay.syncExec(new Runnable() {
                public void run() {
                    ModifierComposite.getInstance().refreshNode();
                    if (MetadataRecord.getInstance().isUpdateSyncIconFlag()) {
                        MetadataRecord.getInstance().getSyncAction().setImageDescriptor(ImageDescriptor
                                .createFromFile(EditView.class, "/icons/red_database_refresh.png"));
                    }
                    return;
                }
            });
        }
    };
}

From source file:edu.harvard.i2b2.eclipse.plugins.ontology.views.edit.EditModifierWizard.java

License:Open Source License

public Thread rebuildChild() {
    final Display theDisplay = Display.getCurrent();
    return new Thread() {
        @Override/*from   w w  w . j a  v a 2 s.c o  m*/
        public void run() {
            try {
                rebuild(theDisplay);
            } catch (Exception e) {
                log.error("Edit child error on synonym rebuild");
            }
            theDisplay.syncExec(new Runnable() {
                public void run() {
                    MetadataRecord.getInstance().getBrowser().parentUpdate();
                    if (MetadataRecord.getInstance().isUpdateSyncIconFlag()) {
                        MetadataRecord.getInstance().getSyncAction().setImageDescriptor(ImageDescriptor
                                .createFromFile(EditView.class, "/icons/red_database_refresh.png"));
                    }
                }
            });
        }
    };
}

From source file:edu.harvard.i2b2.eclipse.plugins.ontology.views.edit.EditView.java

License:Open Source License

private void addHelpButtonToToolBar() {
    final IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
    Action helpAction = new Action() {
        @Override//  w  w w. j ava 2 s . co m
        public void run() {
            helpSystem.displayHelpResource(
                    "/edu.harvard.i2b2.eclipse.plugins.ontology/html/i2b2_edit_terms_index.htm");
        }
    };
    helpAction.setImageDescriptor(ImageDescriptor.createFromFile(EditView.class, "/icons/help.png"));
    getViewSite().getActionBars().getToolBarManager().add(helpAction);

}