Java 类org.eclipse.core.runtime.dynamichelpers.IExtensionTracker 实例源码

项目:eclipsensis    文件:FileAssociationChecker.java   
public FileAssociationChecker()
{
    mEditorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
    mJobName = EclipseNSISStartup.getResourceString("job.name"); //$NON-NLS-1$
    mDialogTitleFormat = new MessageFormat(EclipseNSISStartup.getResourceString("dialog.title.format")); //$NON-NLS-1$
    mDialogMessageFormat = new MessageFormat(EclipseNSISStartup.getResourceString("dialog.message.format")); //$NON-NLS-1$
    mDialogToggleMessageFormat = new MessageFormat(EclipseNSISStartup.getResourceString("dialog.toggle.message.format")); //$NON-NLS-1$
    final IExtensionTracker tracker = PlatformUI.getWorkbench().getExtensionTracker();
    loadExtensions(tracker);
    tracker.registerHandler(this, ExtensionTracker.createExtensionPointFilter(getExtensionPointFilter()));
    final BundleContext bundleContext = EclipseNSISStartup.getDefault().getBundleContext();
    bundleContext.addBundleListener(new BundleListener() {
        public void bundleChanged(BundleEvent event)
        {
            if(event.getType() == BundleEvent.STOPPED ) {
                bundleContext.removeBundleListener(this);
            }
            tracker.unregisterHandler(FileAssociationChecker.this);
            Job.getJobManager().cancel(JOB_FAMILY);
        }
    });
}
项目:eclipsensis    文件:FileAssociationChecker.java   
private void loadExtensions(IExtensionTracker tracker)
{
    IExtensionPoint point = getExtensionPointFilter();
    if (point != null) {
        IExtension[] extensions = point.getExtensions();
        for (int i = 0; i < extensions.length; i++) {
            addExtension(tracker, extensions[i]);
        }
        EclipseNSISStartup.getDefault().savePreferences();
    }
}
项目:eclipsensis    文件:FileAssociationChecker.java   
public void addExtension(IExtensionTracker tracker, IExtension extension)
{
    IConfigurationElement[] associations = extension.getConfigurationElements();
    String bundleId = extension.getNamespaceIdentifier();
    for (int i = 0; i < associations.length; i++) {
        if (ELEM_ASSOCIATION.equals(associations[i].getName())) {
            List<String> fileTypesList = null;
            List<String> editorIdsList = null;
            String id = associations[i].getAttribute(ATTR_ID);
            String fileTypesName = ""; //$NON-NLS-1$
            String editorsName = ""; //$NON-NLS-1$
            IConfigurationElement[] children = associations[i].getChildren();
            boolean enablement = true;
            String enablementPref = null;
            for (int j = 0; j < children.length; j++) {
                String name = children[j].getName();
                if(fileTypesList == null && ELEM_FILETYPES.equals(name)) {
                    fileTypesName = children[j].getAttribute(ATTR_NAME);
                    fileTypesList = new ArrayList<String>();
                    IConfigurationElement[] fileTypes = children[j].getChildren();
                    for (int k = 0; k < fileTypes.length; k++) {
                        if(ELEM_FILETYPE.equals(fileTypes[k].getName())) {
                            fileTypesList.add(fileTypes[k].getAttribute(ATTR_NAME));
                        }
                    }
                }
                else if(editorIdsList == null && ELEM_EDITORS.equals(name)) {
                    editorsName = children[j].getAttribute(ATTR_NAME);
                    editorIdsList = new ArrayList<String>();
                    IConfigurationElement[] editors = children[j].getChildren();
                    for (int k = 0; k < editors.length; k++) {
                        if(ELEM_EDITOR.equals(editors[k].getName())) {
                            editorIdsList.add(editors[k].getAttribute(ATTR_ID));
                        }
                    }
                }
                else if(ELEM_ENABLEMENT.equals(name)) {
                    String value = children[j].getAttribute(ATTR_DEFAULT_VALUE);
                    if(value != null) {
                        enablement = Boolean.valueOf(value).booleanValue();
                    }
                    enablementPref = children[j].getAttribute(ATTR_INIT_PREFERENCE);
                }
            }
            if(fileTypesList != null && editorIdsList != null) {
                initializePreference(id, enablement, bundleId, enablementPref);
                mFileAssociationMap.put(id, new FileAssociationDef(id, fileTypesName, fileTypesList.toArray(new String[fileTypesList.size()]),
                        editorsName, editorIdsList.toArray(new String[editorIdsList.size()])));
            }
        }
    }
}
项目:eclipse-tapestry5-plugin    文件:NullWorkbenchWindow.java   
@Override public IExtensionTracker getExtensionTracker() { return null; }