Example usage for org.eclipse.jface.preference IPreferenceStore getString

List of usage examples for org.eclipse.jface.preference IPreferenceStore getString

Introduction

In this page you can find the example usage for org.eclipse.jface.preference IPreferenceStore getString.

Prototype

String getString(String name);

Source Link

Document

Returns the current value of the string-valued preference with the given name.

Usage

From source file:com.android.ide.eclipse.adt.internal.launch.AndroidLaunchController.java

License:Open Source License

/**
 * Sent when an existing client information changed.
 * <p/>/*  w ww.ja  v  a 2s  . c o m*/
 * This is sent from a non UI thread.
 * @param client the updated client.
 * @param changeMask the bit mask describing the changed properties. It can contain
 * any of the following values: {@link Client#CHANGE_INFO}, {@link Client#CHANGE_NAME}
 * {@link Client#CHANGE_DEBUGGER_STATUS}, {@link Client#CHANGE_THREAD_MODE},
 * {@link Client#CHANGE_THREAD_DATA}, {@link Client#CHANGE_HEAP_MODE},
 * {@link Client#CHANGE_HEAP_DATA}, {@link Client#CHANGE_NATIVE_HEAP_DATA}
 *
 * @see IClientChangeListener#clientChanged(Client, int)
 */
@Override
public void clientChanged(final Client client, int changeMask) {
    boolean connectDebugger = false;
    if ((changeMask & Client.CHANGE_NAME) == Client.CHANGE_NAME) {
        String applicationName = client.getClientData().getClientDescription();
        if (applicationName != null) {
            IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
            String home = store.getString(AdtPrefs.PREFS_HOME_PACKAGE);

            if (home.equals(applicationName)) {

                // looks like home is up, get its device
                IDevice device = client.getDevice();

                // look for application waiting for home
                synchronized (sListLock) {
                    for (int i = 0; i < mWaitingForReadyEmulatorList.size();) {
                        DelayedLaunchInfo launchInfo = mWaitingForReadyEmulatorList.get(i);
                        if (launchInfo.getDevice() == device) {
                            // it's match, remove from the list
                            mWaitingForReadyEmulatorList.remove(i);

                            // We couldn't check earlier the API level of the device
                            // (it's asynchronous when the device boot, and usually
                            // deviceConnected is called before it's queried for its build info)
                            // so we check now
                            if (checkBuildInfo(launchInfo, device) == false) {
                                // device is not the proper API!
                                AdtPlugin.printErrorToConsole(launchInfo.getProject(), "Launch canceled!");
                                stopLaunch(launchInfo);
                                return;
                            }

                            AdtPlugin.printToConsole(launchInfo.getProject(),
                                    String.format("HOME is up on device '%1$s'", device.getSerialNumber()));

                            // attempt to sync the new package onto the device.
                            if (syncApp(launchInfo, device)) {
                                // application package is sync'ed, lets attempt to launch it.
                                launchApp(launchInfo, device);
                            } else {
                                // failure! Cancel and return
                                AdtPlugin.printErrorToConsole(launchInfo.getProject(), "Launch canceled!");
                                stopLaunch(launchInfo);
                            }

                            break;
                        } else {
                            i++;
                        }
                    }
                }
            }

            // check if it's already waiting for a debugger, and if so we connect to it.
            if (client.getClientData().getDebuggerConnectionStatus() == DebuggerStatus.WAITING) {
                // search for this client in the list;
                synchronized (sListLock) {
                    int index = mUnknownClientsWaitingForDebugger.indexOf(client);
                    if (index != -1) {
                        connectDebugger = true;
                        mUnknownClientsWaitingForDebugger.remove(client);
                    }
                }
            }
        }
    }

    // if it's not home, it could be an app that is now in debugger mode that we're waiting for
    // lets check it

    if ((changeMask & Client.CHANGE_DEBUGGER_STATUS) == Client.CHANGE_DEBUGGER_STATUS) {
        ClientData clientData = client.getClientData();
        String applicationName = client.getClientData().getClientDescription();
        if (clientData.getDebuggerConnectionStatus() == DebuggerStatus.WAITING) {
            // Get the application name, and make sure its valid.
            if (applicationName == null) {
                // looks like we don't have the client yet, so we keep it around for when its
                // name becomes available.
                synchronized (sListLock) {
                    mUnknownClientsWaitingForDebugger.add(client);
                }
                return;
            } else {
                connectDebugger = true;
            }
        }
    }

    if (connectDebugger) {
        Log.d("adt", "Debugging " + client);
        // now check it against the apps waiting for a debugger
        String applicationName = client.getClientData().getClientDescription();
        Log.d("adt", "App Name: " + applicationName);
        synchronized (sListLock) {
            for (int i = 0; i < mWaitingForDebuggerApplications.size();) {
                final DelayedLaunchInfo launchInfo = mWaitingForDebuggerApplications.get(i);
                if (client.getDevice() == launchInfo.getDevice()
                        && applicationName.equals(launchInfo.getDebugPackageName())) {
                    // this is a match. We remove the launch info from the list
                    mWaitingForDebuggerApplications.remove(i);

                    // and connect the debugger.
                    String msg = String.format("Attempting to connect debugger to '%1$s' on port %2$d",
                            launchInfo.getDebugPackageName(), client.getDebuggerListenPort());
                    AdtPlugin.printToConsole(launchInfo.getProject(), msg);

                    new Thread("Debugger Connection") { //$NON-NLS-1$
                        @Override
                        public void run() {
                            try {
                                if (connectRemoteDebugger(client.getDebuggerListenPort(),
                                        launchInfo.getLaunch(), launchInfo.getMonitor()) == false) {
                                    return;
                                }
                            } catch (CoreException e) {
                                // well something went wrong.
                                AdtPlugin.printErrorToConsole(launchInfo.getProject(),
                                        String.format("Launch error: %s", e.getMessage()));
                                // stop the launch
                                stopLaunch(launchInfo);
                            }

                            launchInfo.getMonitor().done();
                        }
                    }.start();

                    // we're done processing this client.
                    return;

                } else {
                    i++;
                }
            }
        }

        // if we get here, we haven't found an app that we were launching, so we look
        // for opened android projects that contains the app asking for a debugger.
        // If we find one, we automatically connect to it.
        IProject project = ProjectHelper.findAndroidProjectByAppName(applicationName);

        if (project != null) {
            debugRunningApp(project, client.getDebuggerListenPort());
        }
    }
}

From source file:com.android.ide.eclipse.adt.internal.launch.EmulatorConfigTab.java

License:Open Source License

@Override
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
    configuration.setAttribute(LaunchConfigDelegate.ATTR_TARGET_MODE,
            LaunchConfigDelegate.DEFAULT_TARGET_MODE.toString());
    configuration.setAttribute(LaunchConfigDelegate.ATTR_SPEED, LaunchConfigDelegate.DEFAULT_SPEED);
    configuration.setAttribute(LaunchConfigDelegate.ATTR_DELAY, LaunchConfigDelegate.DEFAULT_DELAY);
    configuration.setAttribute(LaunchConfigDelegate.ATTR_WIPE_DATA, LaunchConfigDelegate.DEFAULT_WIPE_DATA);
    configuration.setAttribute(LaunchConfigDelegate.ATTR_NO_BOOT_ANIM,
            LaunchConfigDelegate.DEFAULT_NO_BOOT_ANIM);

    IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
    String emuOptions = store.getString(AdtPrefs.PREFS_EMU_OPTIONS);
    configuration.setAttribute(LaunchConfigDelegate.ATTR_COMMANDLINE, emuOptions);
}

From source file:com.android.ide.eclipse.adt.internal.lint.GlobalLintConfiguration.java

License:Open Source License

@Override
public Severity getSeverity(@NonNull Issue issue) {
    if (mSeverities == null) {
        IssueRegistry registry = EclipseLintClient.getRegistry();
        mSeverities = new HashMap<Issue, Severity>();
        IPreferenceStore store = getStore();
        String assignments = store.getString(AdtPrefs.PREFS_LINT_SEVERITIES);
        if (assignments != null && assignments.length() > 0) {
            for (String assignment : assignments.split(",")) { //$NON-NLS-1$
                String[] s = assignment.split("="); //$NON-NLS-1$
                if (s.length == 2) {
                    Issue d = registry.getIssue(s[0]);
                    if (d != null) {
                        Severity severity = Severity.valueOf(s[1]);
                        if (severity != null) {
                            mSeverities.put(d, severity);
                        }/*  w w  w .j  a  v a  2  s  .  c o m*/
                    }
                }
            }
        }
    }

    Severity severity = mSeverities.get(issue);
    if (severity != null) {
        return severity;
    }

    if (!issue.isEnabledByDefault()) {
        return Severity.IGNORE;
    }

    return issue.getDefaultSeverity();
}

From source file:com.android.ide.eclipse.adt.internal.lint.GlobalLintConfiguration.java

License:Open Source License

/**
 * Sets the custom severities for the given issues, in bulk.
 *
 * @param severities a map from detector to severity to use from now on
 * @return true if something changed from the current settings
 *///from ww  w. j  a v  a2  s  .c o  m
private boolean setSeverities(Map<Issue, Severity> severities) {
    mSeverities = severities;

    String value = "";
    if (severities.size() > 0) {
        List<Issue> sortedKeys = new ArrayList<Issue>(severities.keySet());
        Collections.sort(sortedKeys);

        StringBuilder sb = new StringBuilder(severities.size() * 20);
        for (Issue issue : sortedKeys) {
            Severity severity = severities.get(issue);
            if (severity != issue.getDefaultSeverity()) {
                if (sb.length() > 0) {
                    sb.append(',');
                }
                sb.append(issue.getId());
                sb.append('=');
                sb.append(severity.name());
            }
        }

        value = sb.toString();
    }

    IPreferenceStore store = getStore();
    String previous = store.getString(AdtPrefs.PREFS_LINT_SEVERITIES);
    boolean changed = !value.equals(previous);
    if (changed) {
        if (value.length() == 0) {
            store.setToDefault(AdtPrefs.PREFS_LINT_SEVERITIES);
        } else {
            store.setValue(AdtPrefs.PREFS_LINT_SEVERITIES, value);
        }
    }

    return changed;
}

From source file:com.android.ide.eclipse.adt.internal.lint.LintEclipseContext.java

License:Open Source License

public boolean isEnabled(Issue issue) {
    IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
    String idList = store.getString(AdtPrefs.PREFS_DISABLED_ISSUES);
    if (idList == null) {
        idList = ""; //$NON-NLS-1$
    }/*from w w w.  j  av  a 2 s. c  o m*/
    if (mDisabledIds == null || !mDisabledIdsList.equals(idList)) {
        mDisabledIdsList = idList;
        if (idList.length() > 0) {
            String[] ids = idList.split(","); //$NON-NLS-1$
            mDisabledIds = new HashSet<String>(ids.length);
            for (String s : ids) {
                mDisabledIds.add(s);
            }
        } else {
            mDisabledIds = Collections.emptySet();
        }
    }

    return !mDisabledIds.contains(issue.getId());
}

From source file:com.android.ide.eclipse.adt.internal.lint.LintEclipseContext.java

License:Open Source License

public Severity getSeverity(Issue issue) {
    if (mSeverities == null) {
        mSeverities = new HashMap<Issue, Severity>();
        IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
        String assignments = store.getString(AdtPrefs.PREFS_LINT_SEVERITIES);
        if (assignments != null && assignments.length() > 0) {
            for (String assignment : assignments.split(",")) { //$NON-NLS-1$
                String[] s = assignment.split("="); //$NON-NLS-1$
                if (s.length == 2) {
                    Issue d = mRegistry.getIssue(s[0]);
                    if (d != null) {
                        Severity severity = Severity.valueOf(s[1]);
                        if (severity != null) {
                            mSeverities.put(d, severity);
                        }/*from   ww w .j  a  v a2 s.  co m*/
                    }
                }
            }
        }
    }

    Severity severity = mSeverities.get(issue);
    if (severity != null) {
        return severity;
    }

    return issue.getDefaultSeverity();
}

From source file:com.android.ide.eclipse.adt.launch.AndroidLaunchController.java

License:Open Source License

/**
 * Returns an {@link ILaunchConfiguration} for the specified {@link IProject}.
 * @param project the project//w  w w  .j  av  a2  s.  c  om
 * @return a new or already existing <code>ILaunchConfiguration</code> or null if there was
 * an error when creating a new one.
 */
public static ILaunchConfiguration getLaunchConfig(IProject project) {
    // get the launch manager
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();

    // now get the config type for our particular android type.
    ILaunchConfigurationType configType = manager
            .getLaunchConfigurationType(LaunchConfigDelegate.ANDROID_LAUNCH_TYPE_ID);

    String name = project.getName();

    // search for an existing launch configuration
    ILaunchConfiguration config = findConfig(manager, configType, name);

    // test if we found one or not
    if (config == null) {
        // Didn't find a matching config, so we make one.
        // It'll be made in the "working copy" object first.
        ILaunchConfigurationWorkingCopy wc = null;

        try {
            // make the working copy object
            wc = configType.newInstance(null, manager.generateUniqueLaunchConfigurationNameFrom(name));

            // set the project name
            wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);

            // set the launch mode to default.
            wc.setAttribute(LaunchConfigDelegate.ATTR_LAUNCH_ACTION,
                    LaunchConfigDelegate.DEFAULT_LAUNCH_ACTION);

            // set default target mode
            wc.setAttribute(LaunchConfigDelegate.ATTR_TARGET_MODE,
                    LaunchConfigDelegate.DEFAULT_TARGET_MODE.getValue());

            // default AVD: None
            wc.setAttribute(LaunchConfigDelegate.ATTR_AVD_NAME, (String) null);

            // set the default network speed
            wc.setAttribute(LaunchConfigDelegate.ATTR_SPEED, LaunchConfigDelegate.DEFAULT_SPEED);

            // and delay
            wc.setAttribute(LaunchConfigDelegate.ATTR_DELAY, LaunchConfigDelegate.DEFAULT_DELAY);

            // default wipe data mode
            wc.setAttribute(LaunchConfigDelegate.ATTR_WIPE_DATA, LaunchConfigDelegate.DEFAULT_WIPE_DATA);

            // default disable boot animation option
            wc.setAttribute(LaunchConfigDelegate.ATTR_NO_BOOT_ANIM, LaunchConfigDelegate.DEFAULT_NO_BOOT_ANIM);

            // set default emulator options
            IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
            String emuOptions = store.getString(AdtPlugin.PREFS_EMU_OPTIONS);
            wc.setAttribute(LaunchConfigDelegate.ATTR_COMMANDLINE, emuOptions);

            // map the config and the project
            wc.setMappedResources(getResourcesToMap(project));

            // save the working copy to get the launch config object which we return.
            return wc.doSave();

        } catch (CoreException e) {
            String msg = String.format("Failed to create a Launch config for project '%1$s': %2$s",
                    project.getName(), e.getMessage());
            AdtPlugin.printErrorToConsole(project, msg);

            // no launch!
            return null;
        }
    }

    return config;
}

From source file:com.android.ide.eclipse.adt.launch.AndroidLaunchController.java

License:Open Source License

/**
 * Sent when an existing client information changed.
 * <p/>/* ww w . j  av a2s.  c om*/
 * This is sent from a non UI thread.
 * @param client the updated client.
 * @param changeMask the bit mask describing the changed properties. It can contain
 * any of the following values: {@link Client#CHANGE_INFO}, {@link Client#CHANGE_NAME}
 * {@link Client#CHANGE_DEBUGGER_INTEREST}, {@link Client#CHANGE_THREAD_MODE},
 * {@link Client#CHANGE_THREAD_DATA}, {@link Client#CHANGE_HEAP_MODE},
 * {@link Client#CHANGE_HEAP_DATA}, {@link Client#CHANGE_NATIVE_HEAP_DATA} 
 * 
 * @see IClientChangeListener#clientChanged(Client, int)
 */
public void clientChanged(final Client client, int changeMask) {
    boolean connectDebugger = false;
    if ((changeMask & Client.CHANGE_NAME) == Client.CHANGE_NAME) {
        String applicationName = client.getClientData().getClientDescription();
        if (applicationName != null) {
            IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
            String home = store.getString(AdtPlugin.PREFS_HOME_PACKAGE);

            if (home.equals(applicationName)) {

                // looks like home is up, get its device
                IDevice device = client.getDevice();

                // look for application waiting for home
                synchronized (sListLock) {
                    for (int i = 0; i < mWaitingForReadyEmulatorList.size();) {
                        DelayedLaunchInfo launchInfo = mWaitingForReadyEmulatorList.get(i);
                        if (launchInfo.getDevice() == device) {
                            // it's match, remove from the list
                            mWaitingForReadyEmulatorList.remove(i);

                            // We couldn't check earlier the API level of the device
                            // (it's asynchronous when the device boot, and usually
                            // deviceConnected is called before it's queried for its build info)
                            // so we check now
                            if (checkBuildInfo(launchInfo, device) == false) {
                                // device is not the proper API!
                                AdtPlugin.printErrorToConsole(launchInfo.getProject(), "Launch canceled!");
                                stopLaunch(launchInfo);
                                return;
                            }

                            AdtPlugin.printToConsole(launchInfo.getProject(),
                                    String.format("HOME is up on device '%1$s'", device.getSerialNumber()));

                            // attempt to sync the new package onto the device.
                            if (syncApp(launchInfo, device)) {
                                // application package is sync'ed, lets attempt to launch it.
                                launchApp(launchInfo, device);
                            } else {
                                // failure! Cancel and return
                                AdtPlugin.printErrorToConsole(launchInfo.getProject(), "Launch canceled!");
                                stopLaunch(launchInfo);
                            }

                            break;
                        } else {
                            i++;
                        }
                    }
                }
            }

            // check if it's already waiting for a debugger, and if so we connect to it.
            if (client.getClientData().getDebuggerConnectionStatus() == ClientData.DEBUGGER_WAITING) {
                // search for this client in the list;
                synchronized (sListLock) {
                    int index = mUnknownClientsWaitingForDebugger.indexOf(client);
                    if (index != -1) {
                        connectDebugger = true;
                        mUnknownClientsWaitingForDebugger.remove(client);
                    }
                }
            }
        }
    }

    // if it's not home, it could be an app that is now in debugger mode that we're waiting for
    // lets check it

    if ((changeMask & Client.CHANGE_DEBUGGER_INTEREST) == Client.CHANGE_DEBUGGER_INTEREST) {
        ClientData clientData = client.getClientData();
        String applicationName = client.getClientData().getClientDescription();
        if (clientData.getDebuggerConnectionStatus() == ClientData.DEBUGGER_WAITING) {
            // Get the application name, and make sure its valid.
            if (applicationName == null) {
                // looks like we don't have the client yet, so we keep it around for when its
                // name becomes available.
                synchronized (sListLock) {
                    mUnknownClientsWaitingForDebugger.add(client);
                }
                return;
            } else {
                connectDebugger = true;
            }
        }
    }

    if (connectDebugger) {
        Log.d("adt", "Debugging " + client);
        // now check it against the apps waiting for a debugger
        String applicationName = client.getClientData().getClientDescription();
        Log.d("adt", "App Name: " + applicationName);
        synchronized (sListLock) {
            for (int i = 0; i < mWaitingForDebuggerApplications.size();) {
                final DelayedLaunchInfo launchInfo = mWaitingForDebuggerApplications.get(i);
                if (client.getDevice() == launchInfo.getDevice()
                        && applicationName.equals(launchInfo.getDebugPackageName())) {
                    // this is a match. We remove the launch info from the list
                    mWaitingForDebuggerApplications.remove(i);

                    // and connect the debugger.
                    String msg = String.format("Attempting to connect debugger to '%1$s' on port %2$d",
                            launchInfo.getDebugPackageName(), client.getDebuggerListenPort());
                    AdtPlugin.printToConsole(launchInfo.getProject(), msg);

                    new Thread("Debugger Connection") { //$NON-NLS-1$
                        @Override
                        public void run() {
                            try {
                                if (connectRemoteDebugger(client.getDebuggerListenPort(),
                                        launchInfo.getLaunch(), launchInfo.getMonitor()) == false) {
                                    return;
                                }
                            } catch (CoreException e) {
                                // well something went wrong.
                                AdtPlugin.printErrorToConsole(launchInfo.getProject(),
                                        String.format("Launch error: %s", e.getMessage()));
                                // stop the launch
                                stopLaunch(launchInfo);
                            }

                            launchInfo.getMonitor().done();
                        }
                    }.start();

                    // we're done processing this client.
                    return;

                } else {
                    i++;
                }
            }
        }

        // if we get here, we haven't found an app that we were launching, so we look
        // for opened android projects that contains the app asking for a debugger.
        // If we find one, we automatically connect to it.
        IProject project = ProjectHelper.findAndroidProjectByAppName(applicationName);

        if (project != null) {
            debugRunningApp(project, client.getDebuggerListenPort());
        }
    }
}

From source file:com.android.ide.eclipse.adt.launch.EmulatorConfigTab.java

License:Open Source License

public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
    configuration.setAttribute(LaunchConfigDelegate.ATTR_TARGET_MODE,
            LaunchConfigDelegate.DEFAULT_TARGET_MODE.getValue());
    configuration.setAttribute(LaunchConfigDelegate.ATTR_SPEED, LaunchConfigDelegate.DEFAULT_SPEED);
    configuration.setAttribute(LaunchConfigDelegate.ATTR_DELAY, LaunchConfigDelegate.DEFAULT_DELAY);
    configuration.setAttribute(LaunchConfigDelegate.ATTR_WIPE_DATA, LaunchConfigDelegate.DEFAULT_WIPE_DATA);
    configuration.setAttribute(LaunchConfigDelegate.ATTR_NO_BOOT_ANIM,
            LaunchConfigDelegate.DEFAULT_NO_BOOT_ANIM);

    IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
    String emuOptions = store.getString(AdtPlugin.PREFS_EMU_OPTIONS);
    configuration.setAttribute(LaunchConfigDelegate.ATTR_COMMANDLINE, emuOptions);
}

From source file:com.android.ide.eclipse.ddms.DdmsPlugin.java

License:Apache License

@Override
public void start(BundleContext context) throws Exception {
    super.start(context);

    final Display display = getDisplay();

    // get the eclipse store
    final IPreferenceStore eclipseStore = getPreferenceStore();

    AndroidDebugBridge.addDeviceChangeListener(this);

    DdmUiPreferences.setStore(eclipseStore);

    //DdmUiPreferences.displayCharts();

    // set the consoles.
    mDdmsConsole = new MessageConsole("DDMS", null); //$NON-NLS-1$
    ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { mDdmsConsole });

    final MessageConsoleStream consoleStream = mDdmsConsole.newMessageStream();
    final MessageConsoleStream errorConsoleStream = mDdmsConsole.newMessageStream();
    mRed = new Color(display, 0xFF, 0x00, 0x00);

    // because this can be run, in some cases, by a non UI thread, and because
    // changing the console properties update the UI, we need to make this change
    // in the UI thread.
    display.asyncExec(new Runnable() {
        @Override//w w w.  j  a  v  a  2 s  .c  o  m
        public void run() {
            errorConsoleStream.setColor(mRed);
        }
    });

    // set up the ddms log to use the ddms console.
    Log.setLogOutput(new ILogOutput() {
        @Override
        public void printLog(LogLevel logLevel, String tag, String message) {
            if (logLevel.getPriority() >= LogLevel.ERROR.getPriority()) {
                printToStream(errorConsoleStream, tag, message);
                showConsoleView(mDdmsConsole);
            } else {
                printToStream(consoleStream, tag, message);
            }
        }

        @Override
        public void printAndPromptLog(final LogLevel logLevel, final String tag, final String message) {
            printLog(logLevel, tag, message);
            // dialog box only run in UI thread..
            display.asyncExec(new Runnable() {
                @Override
                public void run() {
                    Shell shell = display.getActiveShell();
                    if (logLevel == LogLevel.ERROR) {
                        MessageDialog.openError(shell, tag, message);
                    } else {
                        MessageDialog.openWarning(shell, tag, message);
                    }
                }
            });
        }

    });

    // set up the ddms console to use this objects
    DdmConsole.setConsole(new IDdmConsole() {
        @Override
        public void printErrorToConsole(String message) {
            printToStream(errorConsoleStream, null, message);
            showConsoleView(mDdmsConsole);
        }

        @Override
        public void printErrorToConsole(String[] messages) {
            for (String m : messages) {
                printToStream(errorConsoleStream, null, m);
            }
            showConsoleView(mDdmsConsole);
        }

        @Override
        public void printToConsole(String message) {
            printToStream(consoleStream, null, message);
        }

        @Override
        public void printToConsole(String[] messages) {
            for (String m : messages) {
                printToStream(consoleStream, null, m);
            }
        }
    });

    // set the listener for the preference change
    eclipseStore.addPropertyChangeListener(new IPropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            // get the name of the property that changed.
            String property = event.getProperty();

            if (PreferenceInitializer.ATTR_DEBUG_PORT_BASE.equals(property)) {
                DdmPreferences
                        .setDebugPortBase(eclipseStore.getInt(PreferenceInitializer.ATTR_DEBUG_PORT_BASE));
            } else if (PreferenceInitializer.ATTR_SELECTED_DEBUG_PORT.equals(property)) {
                DdmPreferences.setSelectedDebugPort(
                        eclipseStore.getInt(PreferenceInitializer.ATTR_SELECTED_DEBUG_PORT));
            } else if (PreferenceInitializer.ATTR_THREAD_INTERVAL.equals(property)) {
                DdmUiPreferences.setThreadRefreshInterval(
                        eclipseStore.getInt(PreferenceInitializer.ATTR_THREAD_INTERVAL));
            } else if (PreferenceInitializer.ATTR_LOG_LEVEL.equals(property)) {
                DdmPreferences.setLogLevel(eclipseStore.getString(PreferenceInitializer.ATTR_LOG_LEVEL));
            } else if (PreferenceInitializer.ATTR_TIME_OUT.equals(property)) {
                DdmPreferences.setTimeOut(eclipseStore.getInt(PreferenceInitializer.ATTR_TIME_OUT));
            } else if (PreferenceInitializer.ATTR_USE_ADBHOST.equals(property)) {
                DdmPreferences.setUseAdbHost(eclipseStore.getBoolean(PreferenceInitializer.ATTR_USE_ADBHOST));
            } else if (PreferenceInitializer.ATTR_ADBHOST_VALUE.equals(property)) {
                DdmPreferences
                        .setAdbHostValue(eclipseStore.getString(PreferenceInitializer.ATTR_ADBHOST_VALUE));
            }
        }
    });

    // do some last initializations

    // set the preferences.
    PreferenceInitializer.setupPreferences();

    // this class is set as the main source revealer and will look at all the implementations
    // of the extension point. see #reveal(String, String, int)
    StackTracePanel.setSourceRevealer(this);

    /*
     * Load the extension point implementations.
     * The first step is to load the IConfigurationElement representing the implementations.
     * The 2nd step is to use these objects to instantiate the implementation classes.
     *
     * Because the 2nd step will trigger loading the plug-ins providing the implementations,
     * and those plug-ins could access DDMS classes (like ADT), this 2nd step should be done
     * in a Job to ensure that DDMS is loaded, so that the other plug-ins can load.
     *
     * Both steps could be done in the 2nd step but some of DDMS UI rely on knowing if there
     * is an implementation or not (DeviceView), so we do the first steps in start() and, in
     * some case, record it.
     *
     */

    // get the IConfigurationElement for the debuggerConnector right away.
    final IConfigurationElement[] dcce = findConfigElements("com.android.ide.eclipse.ddms.debuggerConnector"); //$NON-NLS-1$
    mHasDebuggerConnectors = dcce.length > 0;

    // get the other configElements and instantiante them in a Job.
    new Job(Messages.DdmsPlugin_DDMS_Post_Create_Init) {
        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                // init the lib
                AndroidDebugBridge.init(true /* debugger support */);

                // get the available adb locators
                IConfigurationElement[] elements = findConfigElements(
                        "com.android.ide.eclipse.ddms.toolsLocator"); //$NON-NLS-1$

                IToolsLocator[] locators = instantiateToolsLocators(elements);

                for (IToolsLocator locator : locators) {
                    try {
                        String adbLocation = locator.getAdbLocation();
                        String traceviewLocation = locator.getTraceViewLocation();
                        String hprofConvLocation = locator.getHprofConvLocation();
                        if (adbLocation != null && traceviewLocation != null && hprofConvLocation != null) {
                            // checks if the location is valid.
                            if (setToolsLocation(adbLocation, hprofConvLocation, traceviewLocation)) {

                                AndroidDebugBridge.createBridge(sAdbLocation, true /* forceNewBridge */);

                                // no need to look at the other locators.
                                break;
                            }
                        }
                    } catch (Throwable t) {
                        // ignore, we'll just not use this implementation.
                    }
                }

                // get the available debugger connectors
                mDebuggerConnectors = instantiateDebuggerConnectors(dcce);

                // get the available Traceview Launchers.
                elements = findConfigElements("com.android.ide.eclipse.ddms.traceviewLauncher"); //$NON-NLS-1$
                mTraceviewLaunchers = instantiateTraceviewLauncher(elements);

                return Status.OK_STATUS;
            } catch (CoreException e) {
                return e.getStatus();
            }
        }
    }.schedule();
}