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

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

Introduction

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

Prototype

long getLong(String name);

Source Link

Document

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

Usage

From source file:ca.uvic.chisel.logging.eclipse.internal.PluginStarter.java

License:Open Source License

public void earlyStartup() {
    if (!WorkbenchLoggingPlugin.isEnabled())
        return;/*from  ww w  .j a v a  2  s.  c o  m*/
    PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
        public void run() {
            // check if a new upload needs to be done.
            IPreferenceStore store = WorkbenchLoggingPlugin.getDefault().getPreferenceStore();
            long lastUpload = store.getLong(UploadJob.LAST_UPLOAD_KEY);
            long interval = store.getLong(UploadJob.UPLOAD_INTERVAL_KEY);
            if (interval <= 0) {
                store.setValue(UploadJob.UPLOAD_INTERVAL_KEY, UploadJob.UPLOAD_INTERVAL_WEEKLY);
                interval = UploadJob.UPLOAD_INTERVAL_WEEKLY;
            }
            if (lastUpload != 0) {
                long today = UploadJob.today();
                //see if there is anything to upload.
                boolean stale = false;
                for (ILoggingCategory category : WorkbenchLoggingPlugin.getDefault().getCategoryManager()
                        .getCategories()) {
                    if (((LoggingCategory) category).isStale()) {
                        stale = true;
                        break;
                    }
                }
                if (stale) {
                    if (today - lastUpload >= interval) {
                        WizardDialog dialog = new WizardDialog(
                                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                                new UploadWizard());
                        dialog.open();
                    }
                }
            } else {
                store.setValue(UploadJob.UPLOAD_INTERVAL_KEY, UploadJob.UPLOAD_INTERVAL_WEEKLY);
                store.setValue(UploadJob.LAST_UPLOAD_KEY, UploadJob.today());
            }
            IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
            for (IWorkbenchWindow window : windows) {
                windowListener.windowOpened(window);
            }
            windowListener.initialize(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
            ICommandService commandService = (ICommandService) PlatformUI.getWorkbench()
                    .getService(ICommandService.class);
            if (commandService != null) {
                commandService.addExecutionListener(commandLogger);
            }
        }

    });
}

From source file:ccw.preferences.OverlayPreferenceStore.java

License:Open Source License

private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) {

    if (orgin.isDefault(key.fKey)) {
        if (!target.isDefault(key.fKey))
            target.setToDefault(key.fKey);
        return;/*from  ww w.ja  va 2s.c  o  m*/
    }

    TypeDescriptor d = key.fDescriptor;
    if (BOOLEAN == d) {

        boolean originValue = orgin.getBoolean(key.fKey);
        boolean targetValue = target.getBoolean(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (DOUBLE == d) {

        double originValue = orgin.getDouble(key.fKey);
        double targetValue = target.getDouble(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (FLOAT == d) {

        float originValue = orgin.getFloat(key.fKey);
        float targetValue = target.getFloat(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (INT == d) {

        int originValue = orgin.getInt(key.fKey);
        int targetValue = target.getInt(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (LONG == d) {

        long originValue = orgin.getLong(key.fKey);
        long targetValue = target.getLong(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (STRING == d) {

        String originValue = orgin.getString(key.fKey);
        String targetValue = target.getString(key.fKey);
        if (targetValue != null && originValue != null && !targetValue.equals(originValue))
            target.setValue(key.fKey, originValue);

    }
}

From source file:ccw.preferences.OverlayPreferenceStore.java

License:Open Source License

private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target,
        boolean forceInitialization) {
    TypeDescriptor d = key.fDescriptor;/*from  ww  w  .j  a  va2 s.  c  om*/
    if (BOOLEAN == d) {

        if (forceInitialization)
            target.setValue(key.fKey, true);
        target.setValue(key.fKey, orgin.getBoolean(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey));

    } else if (DOUBLE == d) {

        if (forceInitialization)
            target.setValue(key.fKey, 1.0D);
        target.setValue(key.fKey, orgin.getDouble(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey));

    } else if (FLOAT == d) {

        if (forceInitialization)
            target.setValue(key.fKey, 1.0F);
        target.setValue(key.fKey, orgin.getFloat(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey));

    } else if (INT == d) {

        if (forceInitialization)
            target.setValue(key.fKey, 1);
        target.setValue(key.fKey, orgin.getInt(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey));

    } else if (LONG == d) {

        if (forceInitialization)
            target.setValue(key.fKey, 1L);
        target.setValue(key.fKey, orgin.getLong(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey));

    } else if (STRING == d) {

        if (forceInitialization)
            target.setValue(key.fKey, "1"); //$NON-NLS-1$
        target.setValue(key.fKey, orgin.getString(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultString(key.fKey));

    }
}

From source file:com.aptana.ide.update.ui.SchedulerStartup.java

License:Open Source License

private void scheduleCheckForReleaseMessage() {
    // Escape mechanism
    boolean doNotCheckForReleaseMessage = Boolean.getBoolean("DO_NOT_CHECK_FOR_RELEASE_MESSAGE"); //$NON-NLS-1$
    if (doNotCheckForReleaseMessage) {
        return;//from ww w.j av a 2 s  . c  o m
    }

    final IPreferenceStore prefs = UpdateUIActivator.getDefault().getPreferenceStore();
    final String releaseMessageURLPrefix = prefs.getString(IPreferenceConstants.RELEASE_MESSAGE_URL_PREFIX);
    Job job = new Job("Check for new release message") { //$NON-NLS-1$
        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                final URL releaseMessageURL = new URL(
                        System.getProperty("RELEASE_MESSAGE_URL_OVERRIDE", releaseMessageURLPrefix //$NON-NLS-1$
                                + getCoreUIVersion() + "/message.html")); //$NON-NLS-1$
                URLConnection urlConnection = null;
                try {
                    urlConnection = releaseMessageURL.openConnection();
                } catch (IOException ioe) {
                    logError(ioe);
                }

                if (urlConnection instanceof HttpURLConnection) {
                    HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;
                    try {
                        httpURLConnection.setConnectTimeout(1000);
                        httpURLConnection.setUseCaches(false);
                        httpURLConnection.addRequestProperty("Cache-Control", "no-cache"); //$NON-NLS-1$ //$NON-NLS-2$
                        httpURLConnection.setRequestMethod("HEAD"); //$NON-NLS-1$
                        if (httpURLConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {

                            boolean showMessage = true;
                            // Check for lastModified?
                            long lastModified = httpURLConnection.getLastModified();
                            if (lastModified == 0) {
                                // unknown
                            } else {
                                long lastLastModified = prefs.getLong(releaseMessageURL.toString());
                                if (lastLastModified >= lastModified) {
                                    showMessage = false;
                                }
                            }
                            prefs.setValue(releaseMessageURL.toString(), lastModified);

                            if (showMessage) {
                                CoreUIUtils.getDisplay().asyncExec(new Runnable() {

                                    public void run() {
                                        IWorkbenchPage page = CoreUIPlugin.getActivePage();
                                        if (page != null) {
                                            try {
                                                page.openEditor(
                                                        new WebBrowserEditorInput(releaseMessageURL,
                                                                IWorkbenchBrowserSupport.PERSISTENT),
                                                        ExternalWebBrowserEditor.ID, false);
                                            } catch (PartInitException e) {
                                                // Show the message in
                                                // external browser
                                                CoreUIUtils.openBrowserURL(releaseMessageURL.toExternalForm());
                                            }
                                        }

                                    }
                                });
                            }
                        }
                    } catch (IOException e) {
                        logError(e);
                    } finally {
                        // cleanup
                        httpURLConnection.disconnect();
                    }
                }
            } catch (MalformedURLException e) {
                logError(e);
            }

            return Status.OK_STATUS;
        }
    };
    job.setSystem(true);
    job.schedule();
}

From source file:com.aptana.ide.update.ui.SchedulerStartup.java

License:Open Source License

private void scheduleCheckForNewsMessage() {
    // Escape mechanism
    boolean doNotCheckForReleaseMessage = Boolean.getBoolean("DO_NOT_CHECK_FOR_NEWS_MESSAGE"); //$NON-NLS-1$
    if (doNotCheckForReleaseMessage) {
        return;/*from  w w  w  .  j a  v a  2  s  . c  o m*/
    }

    final IPreferenceStore prefs = UpdateUIActivator.getDefault().getPreferenceStore();
    String newsMessageURLPrefix = prefs.getString(IPreferenceConstants.NEWS_MESSAGE_URL_PREFIX);
    // For the news we want to pass the version of studio and
    final String newsMessageBaseURL = System.getProperty("NEWS_MESSAGE_URL_OVERRIDE", //$NON-NLS-1$
            newsMessageURLPrefix + "news.php"); //$NON-NLS-1$
    Job job = new Job("Check for new news message") { //$NON-NLS-1$
        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                final URL newsMessageURL = new URL(newsMessageBaseURL + getParamsString());
                URLConnection urlConnection = null;
                try {
                    urlConnection = newsMessageURL.openConnection();
                } catch (IOException ioe) {
                    logError(ioe);
                }

                if (urlConnection instanceof HttpURLConnection) {
                    HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;
                    try {
                        httpURLConnection.setConnectTimeout(1000);
                        httpURLConnection.setUseCaches(false);
                        httpURLConnection.addRequestProperty("Cache-Control", "no-cache"); //$NON-NLS-1$ //$NON-NLS-2$
                        httpURLConnection.setRequestMethod("HEAD"); //$NON-NLS-1$
                        if (httpURLConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
                            // Check for lastModified?
                            boolean showMessage = true;
                            long lastModified = httpURLConnection.getLastModified();
                            if (lastModified == 0) {
                                // unknown
                            } else {
                                long lastLastModified = prefs.getLong(newsMessageBaseURL);
                                if (lastLastModified >= lastModified) {
                                    showMessage = false;
                                }
                            }
                            prefs.setValue(newsMessageBaseURL, lastModified);

                            if (showMessage) {
                                CoreUIUtils.getDisplay().asyncExec(new Runnable() {

                                    public void run() {
                                        IWorkbenchPage page = CoreUIPlugin.getActivePage();
                                        if (page != null) {
                                            try {
                                                page.openEditor(
                                                        new WebBrowserEditorInput(newsMessageURL,
                                                                IWorkbenchBrowserSupport.PERSISTENT),
                                                        ExternalWebBrowserEditor.ID, false);
                                            } catch (PartInitException e) {
                                                // Show the message in
                                                // external browser
                                                CoreUIUtils.openBrowserURL(newsMessageURL.toExternalForm());
                                            }
                                        }

                                    }
                                });
                            }
                        }
                    } catch (IOException e) {
                        logError(e);
                    } finally {
                        // cleanup
                        httpURLConnection.disconnect();
                    }
                }
            } catch (MalformedURLException e) {
                logError(e);
            }

            return Status.OK_STATUS;
        }
    };
    job.setSystem(true);
    job.schedule();
}

From source file:com.aptana.ide.update.ui.SchedulerStartup.java

License:Open Source License

private void scheduleCheckForAnnouncements() {
    // Escape mechanism
    boolean doNotCheckForReleaseMessage = Boolean.getBoolean("DO_NOT_CHECK_FOR_NEWS_MESSAGE"); //$NON-NLS-1$
    if (doNotCheckForReleaseMessage) {
        return;/*from w w  w. j  a  va 2s. co  m*/
    }
    final IPreferenceStore prefs = UpdateUIActivator.getDefault().getPreferenceStore();
    boolean b_neverShow = prefs.getBoolean(IPreferenceConstants.NEVER_SHOW_ANNOUNCEMENTS);
    if (b_neverShow) {
        return;
    }

    String announcementURLPrefix = prefs.getString(IPreferenceConstants.ANNOUNCEMENT_URL_PREFIX);
    final String announceBaseURL = System.getProperty("ANNOUNCEMENT_URL_OVERRIDE", //$NON-NLS-1$
            announcementURLPrefix + "announce.php"); //$NON-NLS-1$
    Job job = new Job("Check for new announcement") { //$NON-NLS-1$

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                // For the announcements we want to pass the version of
                // studio and
                getAnnouncement(new URL(announceBaseURL + getParamsString()));
            } catch (MalformedURLException e) {
                logError(e);
            }

            return Status.OK_STATUS;
        }

        private void getAnnouncement(final URL url) {
            URLConnection urlConnection = null;
            try {
                urlConnection = url.openConnection();
            } catch (IOException ioe) {
                logError(ioe);
            }
            if (urlConnection instanceof HttpURLConnection) {
                HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;
                try {
                    httpURLConnection.setConnectTimeout(1000);
                    httpURLConnection.setUseCaches(false);
                    httpURLConnection.addRequestProperty("Cache-Control", "no-cache"); //$NON-NLS-1$ //$NON-NLS-2$
                    httpURLConnection.setRequestMethod("HEAD"); //$NON-NLS-1$

                    if (httpURLConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
                        // Check for lastModified?
                        boolean showMessage = true;
                        long lastModified = httpURLConnection.getLastModified();
                        if (lastModified == 0) {
                            // unknown
                        } else {
                            boolean neverShowThisAgain = prefs
                                    .getBoolean(IPreferenceConstants.NEVER_SHOW_THIS_ANNOUNCEMENT);
                            if (neverShowThisAgain) {
                                long lastLastModified = prefs.getLong(
                                        IPreferenceConstants.NEVER_SHOW_THIS_ANNOUNCEMENT_LAST_LAST_MODIFIED);
                                if (lastModified <= lastLastModified) {
                                    showMessage = false;
                                }
                            }
                        }
                        prefs.setValue(IPreferenceConstants.NEVER_SHOW_THIS_ANNOUNCEMENT_LAST_LAST_MODIFIED,
                                lastModified);

                        String strHeight = httpURLConnection.getHeaderField(HEADER_HEIGHT);
                        String strWidth = httpURLConnection.getHeaderField(HEADER_WIDTH);

                        final int height = (strHeight != null) ? Integer.parseInt(strHeight) : 300;
                        final int width = (strWidth != null) ? Integer.parseInt(strWidth) : 300;

                        if (showMessage) {
                            UIJob uiJob = new UIJob("Show Aptana Announcement") { //$NON-NLS-1$
                                @Override
                                public IStatus runInUIThread(IProgressMonitor monitor) {
                                    IWorkbenchPage page = CoreUIPlugin.getActivePage();
                                    if (page != null) {
                                        BrowserDialog dialog = new BrowserDialog(CoreUIUtils.getActiveShell(),
                                                url.toString(), height, width);
                                        dialog.open();
                                    }

                                    return Status.OK_STATUS;
                                }
                            };
                            uiJob.setSystem(true);
                            uiJob.setRule(MutexJobRule.getInstance());
                            uiJob.schedule();
                        }
                    }
                } catch (IOException e) {
                    logError(e);
                } finally {
                    // cleanup
                    httpURLConnection.disconnect();
                }
            }
        }
    };
    job.setSystem(true);
    job.schedule();
}

From source file:com.axmor.eclipse.typescript.editor.preferences.OverlayPreferenceStore.java

License:Open Source License

private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) {
    if (orgin.isDefault(key.fKey)) {
        if (!target.isDefault(key.fKey))
            target.setToDefault(key.fKey);
        return;//from  w  w  w .j  a v  a2s . c  o m
    }
    TypeDescriptor d = key.fDescriptor;
    if (BOOLEAN == d) {
        boolean originValue = orgin.getBoolean(key.fKey);
        boolean targetValue = target.getBoolean(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);
    } else if (DOUBLE == d) {
        double originValue = orgin.getDouble(key.fKey);
        double targetValue = target.getDouble(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);
    } else if (FLOAT == d) {
        float originValue = orgin.getFloat(key.fKey);
        float targetValue = target.getFloat(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);
    } else if (INT == d) {
        int originValue = orgin.getInt(key.fKey);
        int targetValue = target.getInt(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);
    } else if (LONG == d) {
        long originValue = orgin.getLong(key.fKey);
        long targetValue = target.getLong(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);
    } else if (STRING == d) {
        String originValue = orgin.getString(key.fKey);
        String targetValue = target.getString(key.fKey);
        if (targetValue != null && originValue != null && !targetValue.equals(originValue))
            target.setValue(key.fKey, originValue);
    }
}

From source file:com.axmor.eclipse.typescript.editor.preferences.OverlayPreferenceStore.java

License:Open Source License

private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target,
        boolean forceInitialization) {
    TypeDescriptor d = key.fDescriptor;/* w  w w.j ava  2 s  . co m*/
    if (BOOLEAN == d) {
        if (forceInitialization)
            target.setValue(key.fKey, true);
        target.setValue(key.fKey, orgin.getBoolean(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey));
    } else if (DOUBLE == d) {
        if (forceInitialization)
            target.setValue(key.fKey, 1.0D);
        target.setValue(key.fKey, orgin.getDouble(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey));
    } else if (FLOAT == d) {
        if (forceInitialization)
            target.setValue(key.fKey, 1.0F);
        target.setValue(key.fKey, orgin.getFloat(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey));
    } else if (INT == d) {
        if (forceInitialization)
            target.setValue(key.fKey, 1);
        target.setValue(key.fKey, orgin.getInt(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey));
    } else if (LONG == d) {
        if (forceInitialization)
            target.setValue(key.fKey, 1L);
        target.setValue(key.fKey, orgin.getLong(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey));
    } else if (STRING == d) {
        if (forceInitialization)
            target.setValue(key.fKey, "1"); //$NON-NLS-1$
        target.setValue(key.fKey, orgin.getString(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultString(key.fKey));
    }
}

From source file:com.cisco.yangide.ui.preferences.OverlayPreferenceStore.java

License:Open Source License

private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) {

    if (orgin.isDefault(key.fKey)) {
        if (!target.isDefault(key.fKey)) {
            target.setToDefault(key.fKey);
        }//w  ww.  j ava2  s.  co m
        return;
    }

    TypeDescriptor d = key.fDescriptor;
    if (BOOLEAN == d) {

        boolean originValue = orgin.getBoolean(key.fKey);
        boolean targetValue = target.getBoolean(key.fKey);
        if (targetValue != originValue) {
            target.setValue(key.fKey, originValue);
        }

    } else if (DOUBLE == d) {

        double originValue = orgin.getDouble(key.fKey);
        double targetValue = target.getDouble(key.fKey);
        if (targetValue != originValue) {
            target.setValue(key.fKey, originValue);
        }

    } else if (FLOAT == d) {

        float originValue = orgin.getFloat(key.fKey);
        float targetValue = target.getFloat(key.fKey);
        if (targetValue != originValue) {
            target.setValue(key.fKey, originValue);
        }

    } else if (INT == d) {

        int originValue = orgin.getInt(key.fKey);
        int targetValue = target.getInt(key.fKey);
        if (targetValue != originValue) {
            target.setValue(key.fKey, originValue);
        }

    } else if (LONG == d) {

        long originValue = orgin.getLong(key.fKey);
        long targetValue = target.getLong(key.fKey);
        if (targetValue != originValue) {
            target.setValue(key.fKey, originValue);
        }

    } else if (STRING == d) {

        String originValue = orgin.getString(key.fKey);
        String targetValue = target.getString(key.fKey);
        if (targetValue != null && originValue != null && !targetValue.equals(originValue)) {
            target.setValue(key.fKey, originValue);
        }

    }
}

From source file:com.cisco.yangide.ui.preferences.OverlayPreferenceStore.java

License:Open Source License

private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target,
        boolean forceInitialization) {
    TypeDescriptor d = key.fDescriptor;//from  w w  w. j a  v a2s.  c om
    if (BOOLEAN == d) {

        if (forceInitialization) {
            target.setValue(key.fKey, true);
        }
        target.setValue(key.fKey, orgin.getBoolean(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey));

    } else if (DOUBLE == d) {

        if (forceInitialization) {
            target.setValue(key.fKey, 1.0D);
        }
        target.setValue(key.fKey, orgin.getDouble(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey));

    } else if (FLOAT == d) {

        if (forceInitialization) {
            target.setValue(key.fKey, 1.0F);
        }
        target.setValue(key.fKey, orgin.getFloat(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey));

    } else if (INT == d) {

        if (forceInitialization) {
            target.setValue(key.fKey, 1);
        }
        target.setValue(key.fKey, orgin.getInt(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey));

    } else if (LONG == d) {

        if (forceInitialization) {
            target.setValue(key.fKey, 1L);
        }
        target.setValue(key.fKey, orgin.getLong(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey));

    } else if (STRING == d) {

        if (forceInitialization) {
            target.setValue(key.fKey, "1"); //$NON-NLS-1$
        }
        target.setValue(key.fKey, orgin.getString(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultString(key.fKey));

    }
}