From c71f87cb49ea34f431f7f7e753cd91ccca0b0e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arvi=CC=84ds=20Grabovskis?= Date: Thu, 21 Jun 2018 11:10:40 +0300 Subject: [PATCH 1/4] Remove plugin update check --- instasearch/.project | 2 +- instasearch/icons/update.gif | Bin 336 -> 0 bytes instasearch/plugin.xml | 9 - .../actions/CheckUpdatesActionDelegate.java | 34 --- .../indexing/WorkspaceIndexerJDT.java | 4 +- .../instasearch/jobs/CheckUpdatesJob.java | 246 ------------------ .../instasearch/jobs/UpdatePluginJob.java | 80 ------ .../prefs/InstaSearchPreferencePage.java | 4 - .../prefs/PreferenceConstants.java | 4 - .../prefs/PreferenceInitializer.java | 2 - .../unibz/instasearch/ui/InstaSearchView.java | 67 +---- .../instasearch/ui/MatchHighlightJob.java | 2 +- .../instasearch/indexing/TestStorage.java | 4 +- 13 files changed, 7 insertions(+), 451 deletions(-) delete mode 100755 instasearch/icons/update.gif delete mode 100755 instasearch/src/it/unibz/instasearch/actions/CheckUpdatesActionDelegate.java delete mode 100755 instasearch/src/it/unibz/instasearch/jobs/CheckUpdatesJob.java delete mode 100755 instasearch/src/it/unibz/instasearch/jobs/UpdatePluginJob.java diff --git a/instasearch/.project b/instasearch/.project index 4a7655c..7c683fb 100755 --- a/instasearch/.project +++ b/instasearch/.project @@ -34,7 +34,7 @@ root_pom.xml 1 - /Users/ajermakovics/Workspace/eclipse-instasearch/pom.xml + UP/pom.xml diff --git a/instasearch/icons/update.gif b/instasearch/icons/update.gif deleted file mode 100755 index 1b724a6784910f0fb632fdf4df6b46a144555ad2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 336 zcmZ?wbhEHb6krfwxXQr55IT)Fb|!D^4EglA3K?_dGv=CK0qT>Sf9>(8_Cdt1adlnL#q6WLrPyt`3!SEK0m zI?>&YVk`3mR^$n+DHL3hC%BBnnIz~g+PYz|NsAi&cp>2f3h$#FqkpufE0lI z#K4y8FgqYZi?`q7(Xkmen}SxJb-OAu&tZRT}eifdF;41SfF@krG-*ZXoxN^o#XigWm~3yMt<6%}OnWfKq<5fb8OD`Vm1V`gP- SG-KjoT; - - T getAdapter(Class adapter) { return classFile.getAdapter(adapter); } diff --git a/instasearch/src/it/unibz/instasearch/jobs/CheckUpdatesJob.java b/instasearch/src/it/unibz/instasearch/jobs/CheckUpdatesJob.java deleted file mode 100755 index d745ef5..0000000 --- a/instasearch/src/it/unibz/instasearch/jobs/CheckUpdatesJob.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (c) 2009 Andrejs Jermakovics. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andrejs Jermakovics - initial implementation - */ -package it.unibz.instasearch.jobs; - -import it.unibz.instasearch.InstaSearchPlugin; -import it.unibz.instasearch.actions.ShowExceptionAction; -import it.unibz.instasearch.ui.InstaSearchUI; - -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; - -import org.apache.commons.httpclient.Credentials; -import org.apache.commons.httpclient.HostConfiguration; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpException; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.UsernamePasswordCredentials; -import org.apache.commons.httpclient.auth.AuthScope; -import org.apache.commons.httpclient.methods.GetMethod; -import org.eclipse.core.net.proxy.IProxyData; -import org.eclipse.core.net.proxy.IProxyService; -import org.eclipse.core.resources.WorkspaceJob; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.progress.IProgressConstants; - -/** - * A job that checks for new updates of the plugin - * - */ -public class CheckUpdatesJob extends WorkspaceJob -{ - // return code constants - public static final int UPDATE_AVAILABLE_CODE = 1; - public static final int NO_UPDATE_AVAILABLE_CODE = 2; - - private boolean updateAvailable; - - public CheckUpdatesJob() - { - super("InstaSearch Update Check"); - - setPriority(DECORATE); - - setProperty(IProgressConstants.ICON_PROPERTY, - InstaSearchPlugin.getImageDescriptor("update")); - - setProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, Boolean.TRUE); - setProperty(IProgressConstants.KEEPONE_PROPERTY, Boolean.TRUE); - } - - @Override - public IStatus runInWorkspace(IProgressMonitor monitor) - throws CoreException - { - try - { - checkForUpdates(monitor); - - if( ! isSystem() ) - PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { - public void run() { - IAction action; - - if( isUpdateAvailable() ) - action = createUpdateNotificationAction(); - else - action = createNoUpdateNotificationAction(); - - action.run(); - } - }); - - //setProperty(IProgressConstants.ACTION_PROPERTY, action); - - } catch (Exception e) { - IAction action = new ShowExceptionAction(e, "Error Checking Updates"); - setProperty(IProgressConstants.ACTION_PROPERTY, action); - - if (!isSystem()) - setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE); - - if( ! isSystem() ) { - InstaSearchPlugin.log(e); - return new Status(IStatus.ERROR, InstaSearchPlugin.getPluginId(), 0, action.getText(), e); - } - } - - int returnCode = isUpdateAvailable() ? UPDATE_AVAILABLE_CODE : NO_UPDATE_AVAILABLE_CODE; - return new Status(IStatus.OK, InstaSearchPlugin.getPluginId(), returnCode, "Done", null); - } - - private boolean checkForUpdates(IProgressMonitor monitor) throws HttpException, IOException, URISyntaxException - - { - updateAvailable = false; - - String versionCheckUrl = InstaSearchPlugin.getUpdateLocation(); - String v = InstaSearchPlugin.getVersion(); - - HttpClient httpClient = new HttpClient(); - configureProxy(httpClient, versionCheckUrl); - - GetMethod getMethod = new GetMethod(versionCheckUrl + "?v="+v); - - int statusCode = httpClient.executeMethod(getMethod); - - if (statusCode != HttpStatus.SC_OK) - return updateAvailable; - - String response = getMethod.getResponseBodyAsString(); - getMethod.releaseConnection(); - - if( "y".equals(response) ) - updateAvailable = true; - - return updateAvailable; - } - - /** - * @param httpClient - * @param versionCheckUrl - * @throws URISyntaxException - */ - private void configureProxy(HttpClient httpClient, String versionCheckUrl) throws URISyntaxException - { - IProxyService proxyService = InstaSearchPlugin.getDefault().getProxyService(); - - if (proxyService != null && proxyService.isProxiesEnabled()) { - URI uri = new URI(versionCheckUrl); - final IProxyData[] proxiesData = proxyService.select(uri); - - IProxyData proxy = null; - for(IProxyData proxyData: proxiesData) - { - if( proxyData.getType().equals(IProxyData.HTTP_PROXY_TYPE) ) - { - proxy = proxyData; - break; - } - } - - if( proxy == null ) - return; - - HostConfiguration config = httpClient.getHostConfiguration(); - config.setProxy(proxy.getHost(), proxy.getPort()); - - if( proxy.isRequiresAuthentication() ) - { - Credentials credentials = new UsernamePasswordCredentials(proxy.getUserId(), proxy.getPassword()); - AuthScope authScope = new AuthScope(proxy.getHost(), proxy.getPort()); - httpClient.getState().setProxyCredentials(authScope, credentials); - } - } - } - - private IAction createNoUpdateNotificationAction() - { - String text = "No Update Available"; - - IAction notificationAction = new Action(text) - { - public void run() - { - InstaSearchUI.showMessage("You have the latest version (" + InstaSearchPlugin.getVersion() + ")"); - setEnabled(false); - } - }; - notificationAction.setDescription(text); - notificationAction.setToolTipText(text); - - return notificationAction; - } - - /** - * Creates an action that offers to update the plugin - * @return IAction - */ - public static IAction createUpdateNotificationAction() - { - String text = "New Version Available"; - - IAction notificationAction = new Action("Update") - { - public void run() - { - /* - MessageDialogWithToggle.openYesNoQuestion(shell, "Update", - "There is a new version of InstaSearch available. Update?", - "Update automatically", true, - InstaSearchPlugin.getDefault().getPreferenceStore(), "AUTO_UPDATE"); - */ - boolean update = MessageDialog.openQuestion( - InstaSearchUI.getActiveShell(), - getDescription(), - "There is a new version available. Update?"); - - if( update ) - { - UpdatePluginJob updateJob = new UpdatePluginJob(); - updateJob.schedule(); - } - - } - }; - notificationAction.setDescription(text); - notificationAction.setToolTipText(text); - - return notificationAction; - } - - /** - * Is there an update available for this plugin - * The value is set after the job has finished - * @return UpdateAvailable - */ - public boolean isUpdateAvailable() - { - return updateAvailable; - } - - @Override - public boolean belongsTo(Object family) - { - return family == CheckUpdatesJob.class; - } - - -} \ No newline at end of file diff --git a/instasearch/src/it/unibz/instasearch/jobs/UpdatePluginJob.java b/instasearch/src/it/unibz/instasearch/jobs/UpdatePluginJob.java deleted file mode 100755 index 5ab0e0d..0000000 --- a/instasearch/src/it/unibz/instasearch/jobs/UpdatePluginJob.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2009 Andrejs Jermakovics. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andrejs Jermakovics - initial implementation - */ -package it.unibz.instasearch.jobs; - -import it.unibz.instasearch.InstaSearchPlugin; -import it.unibz.instasearch.actions.ShowExceptionAction; - -import org.eclipse.core.resources.WorkspaceJob; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.handlers.IHandlerService; -import org.eclipse.ui.progress.IProgressConstants; - -/** - * Workspace Job that updates the plugin - */ -public class UpdatePluginJob extends WorkspaceJob -{ - - /** - * - */ - private static final String UPDATE_MANAGER_COMMAND = "org.eclipse.equinox.p2.ui.sdk.update"; - - public UpdatePluginJob() - { - super("InstaSearch Update"); - - setPriority(DECORATE); - - setProperty(IProgressConstants.ICON_PROPERTY, InstaSearchPlugin.getImageDescriptor("update")); - setProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, Boolean.TRUE); - } - - @Override - public IStatus runInWorkspace(IProgressMonitor monitor) - throws CoreException - { - if( !isSystem() ) - setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE); - - showUpdateManager(); - - return new Status(IStatus.OK, InstaSearchPlugin.getPluginId(), 0, "Update Manager Launched", null); - } - - private void showUpdateManager() - { - PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { - - public void run() - { - IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class); - - if( handlerService != null ) { - try { - handlerService.executeCommand(UPDATE_MANAGER_COMMAND, new Event()); // show software updates dialog - } catch(Exception e) { - InstaSearchPlugin.log(e); - setProperty(IProgressConstants.ACTION_PROPERTY, new ShowExceptionAction(e, "Error Launching Update Manager")); - } - } - } - }); - } - -} diff --git a/instasearch/src/it/unibz/instasearch/prefs/InstaSearchPreferencePage.java b/instasearch/src/it/unibz/instasearch/prefs/InstaSearchPreferencePage.java index ac205f0..7f704cc 100755 --- a/instasearch/src/it/unibz/instasearch/prefs/InstaSearchPreferencePage.java +++ b/instasearch/src/it/unibz/instasearch/prefs/InstaSearchPreferencePage.java @@ -97,10 +97,6 @@ public void createFieldEditors() { addBoolField(PreferenceConstants.P_FUZZY_SEARCH_AUTO, "Find similar matches when no exact matches found"); - String version = InstaSearchPlugin.getVersion(); - addBoolField(PreferenceConstants.P_CHECK_UPDATES, "Notify about updates (ver. " + version + ")"); - - periodicReindexEnabled = addBoolField(PreferenceConstants.P_INDEX_UPDATE_ENABLED, "Enable Automatic-Reindex"); periodicReindexInterval = new IntegerFieldEditor(PreferenceConstants.P_INDEX_UPDATE_INTERVAL, "Automatic Reindex interval (ms)", getFieldEditorParent()); diff --git a/instasearch/src/it/unibz/instasearch/prefs/PreferenceConstants.java b/instasearch/src/it/unibz/instasearch/prefs/PreferenceConstants.java index 5a0d900..140e8e8 100755 --- a/instasearch/src/it/unibz/instasearch/prefs/PreferenceConstants.java +++ b/instasearch/src/it/unibz/instasearch/prefs/PreferenceConstants.java @@ -35,11 +35,7 @@ public class PreferenceConstants public static final String P_SHOWN_LINES_COUNT = "shownLineCount"; public static final String P_DIALOG_ON_SHORTCUT = "dialogOnShortcut"; - // General - public static final String P_CHECK_UPDATES = "checkUpdates"; - // Internal - public static final String P_UPDATE_CHECK_DELAY = "updateCheckDelay"; public static final String P_TYPING_SEARCH_DELAY = "typingSearchDelay"; public static final String P_INDEX_UPDATE_INTERVAL = "indexUpdateInterval"; public static final String P_INDEX_UPDATE_ENABLED = "indexUpdateEnabled"; diff --git a/instasearch/src/it/unibz/instasearch/prefs/PreferenceInitializer.java b/instasearch/src/it/unibz/instasearch/prefs/PreferenceInitializer.java index e67dab7..c696fd8 100755 --- a/instasearch/src/it/unibz/instasearch/prefs/PreferenceInitializer.java +++ b/instasearch/src/it/unibz/instasearch/prefs/PreferenceInitializer.java @@ -40,7 +40,6 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer { public void initializeDefaultPreferences() { IPreferenceStore store = InstaSearchPlugin.getDefault().getPreferenceStore(); - store.setDefault(PreferenceConstants.P_CHECK_UPDATES, true); store.setDefault(PreferenceConstants.P_SHOW_MATCH_COUNT, true); store.setDefault(PreferenceConstants.P_INDEX_ARCHIVES, false); store.setDefault(PreferenceConstants.P_INDEX_EMPTY_EXTENSION, false); @@ -52,7 +51,6 @@ public void initializeDefaultPreferences() store.setDefault(PreferenceConstants.P_SHOWN_FILES_COUNT, 25); store.setDefault(PreferenceConstants.P_SHOWN_LINES_COUNT, 4); - store.setDefault(PreferenceConstants.P_UPDATE_CHECK_DELAY, 10000); store.setDefault(PreferenceConstants.P_TYPING_SEARCH_DELAY, 200); store.setDefault(PreferenceConstants.P_INDEX_UPDATE_INTERVAL, 60000); store.setDefault(PreferenceConstants.P_INDEX_UPDATE_ENABLED, true); diff --git a/instasearch/src/it/unibz/instasearch/ui/InstaSearchView.java b/instasearch/src/it/unibz/instasearch/ui/InstaSearchView.java index 8a3c53a..631c1e3 100755 --- a/instasearch/src/it/unibz/instasearch/ui/InstaSearchView.java +++ b/instasearch/src/it/unibz/instasearch/ui/InstaSearchView.java @@ -12,12 +12,10 @@ package it.unibz.instasearch.ui; import it.unibz.instasearch.InstaSearchPlugin; -import it.unibz.instasearch.actions.CheckUpdatesActionDelegate; import it.unibz.instasearch.actions.ShowExceptionAction; import it.unibz.instasearch.indexing.Field; import it.unibz.instasearch.indexing.SearchQuery; import it.unibz.instasearch.indexing.SearchResultDoc; -import it.unibz.instasearch.jobs.CheckUpdatesJob; import it.unibz.instasearch.prefs.PreferenceConstants; import it.unibz.instasearch.ui.ResultContentProvider.MatchLine; @@ -39,7 +37,6 @@ import org.eclipse.jface.action.IContributionItem; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.text.IFindReplaceTarget; import org.eclipse.jface.util.IPropertyChangeListener; @@ -110,8 +107,6 @@ public void init(IViewSite site) throws PartInitException { super.init(site); - scheduleUpdateCheck(); // schedule update check if view is opened - InstaSearchPlugin.getDefault().getLog().addLogListener(this); // listen for exceptions initPrefs(); @@ -261,7 +256,7 @@ private void configureResultViewer(ResultContentProvider contentProvider, IBaseL resultViewer.setContentProvider(contentProvider); resultViewer.setLabelProvider(decoratedLabelProvider); - resultViewer.setSorter(null); + resultViewer.setComparator(null); getViewSite().setSelectionProvider(resultViewer); resultViewer.addTreeListener(this); @@ -494,19 +489,6 @@ public void run() { }; } - private void scheduleUpdateCheck() - { - boolean checkUpdates = InstaSearchPlugin.getBoolPref(PreferenceConstants.P_CHECK_UPDATES); - if( !checkUpdates ) - return; - - CheckUpdatesJob checkUpdatesJob = new CheckUpdatesJob(); - checkUpdatesJob.setSystem(true); - checkUpdatesJob.addJobChangeListener(new UpdateJobChangeListener()); - checkUpdatesJob.schedule(InstaSearchPlugin.getIntPref(PreferenceConstants.P_UPDATE_CHECK_DELAY)); - } - - /** * Logging an error in the plugin * Create an action that allows reporting it @@ -557,53 +539,6 @@ public void propertyChange(PropertyChangeEvent event) incrementalSearchEnabled = InstaSearchPlugin.getBoolPref(PreferenceConstants.P_INCREMENTAL_SEARCH); } - /** - * Waits for {@link CheckUpdatesJob} to finish and notifies if update is available - * by placing an Update button in the view's toolbar - */ - private class UpdateJobChangeListener extends JobChangeAdapter { - - public void done(IJobChangeEvent event) - { - IStatus status = event.getResult(); - - if( status.getSeverity() == IStatus.OK ) - { - boolean updateAvailable = (status.getCode() == CheckUpdatesJob.UPDATE_AVAILABLE_CODE); - if( updateAvailable ) - { - getViewSite().getShell().getDisplay().asyncExec(new Runnable() { - public void run() - { - addUpdateAction(); - setTitleToolTip("New version available"); - getViewSite().getActionBars().getStatusLineManager().setMessage(getTitleImage(), "New version available"); - } - }); - } - - - } - } - - private void addUpdateAction() { - IAction updateAction = CheckUpdatesJob.createUpdateNotificationAction(); - updateAction.setImageDescriptor( InstaSearchPlugin.getImageDescriptor("lightbulb") ); - - IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager(); - mgr.add(updateAction); - mgr.update(true); - - IMenuManager menuMgr = getViewSite().getActionBars().getMenuManager(); - - menuMgr.add(updateAction); - - IContributionItem checkUpdatesItem = mgr.find(CheckUpdatesActionDelegate.ID); - if( checkUpdatesItem != null ) - checkUpdatesItem.setVisible(false); // hide Check for Updates action - } - } - /** * Background job that expands/collapses all entries */ diff --git a/instasearch/src/it/unibz/instasearch/ui/MatchHighlightJob.java b/instasearch/src/it/unibz/instasearch/ui/MatchHighlightJob.java index 1c89605..58bcb8f 100755 --- a/instasearch/src/it/unibz/instasearch/ui/MatchHighlightJob.java +++ b/instasearch/src/it/unibz/instasearch/ui/MatchHighlightJob.java @@ -71,7 +71,7 @@ public MatchHighlightJob(SearchResultDoc doc, MatchLine selectedLineMatches, Res this.workbenchPage = workbenchPage; IEditorInput input = contentProvider.getEditorInput(doc); - IEditorDescriptor editorDesc = IDE.getEditorDescriptor(doc.getFileName()); + IEditorDescriptor editorDesc = IDE.getEditorDescriptor(doc.getFileName(), true, true); IEditorPart editorPart = IDE.openEditor(workbenchPage, input, editorDesc.getId()); this.editor = getTextEditor(input, editorPart); diff --git a/instasearch/test/it/unibz/instasearch/indexing/TestStorage.java b/instasearch/test/it/unibz/instasearch/indexing/TestStorage.java index 7f91498..8d10e66 100755 --- a/instasearch/test/it/unibz/instasearch/indexing/TestStorage.java +++ b/instasearch/test/it/unibz/instasearch/indexing/TestStorage.java @@ -53,8 +53,8 @@ public boolean isReadOnly() { return false; } - @SuppressWarnings("rawtypes") - public Object getAdapter(Class adapter) { + @Override + public T getAdapter(Class adapter) { return null; } } \ No newline at end of file From 9c0578bb75a872f5fe0f7b47008c1ae376eb44ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arvi=CC=84ds=20Grabovskis?= Date: Tue, 26 Jun 2018 11:20:25 +0300 Subject: [PATCH 2/4] Replace error report dialog with standard error dialog --- instasearch.feature/feature.xml | 1 - instasearch/META-INF/MANIFEST.MF | 3 - .../unibz/instasearch/InstaSearchPlugin.java | 17 -- .../unibz/instasearch/ui/InstaSearchUI.java | 6 +- .../instasearch/ui/ReportErrorDialog.java | 215 ------------------ 5 files changed, 2 insertions(+), 240 deletions(-) delete mode 100755 instasearch/src/it/unibz/instasearch/ui/ReportErrorDialog.java diff --git a/instasearch.feature/feature.xml b/instasearch.feature/feature.xml index cffce5a..b3257f3 100755 --- a/instasearch.feature/feature.xml +++ b/instasearch.feature/feature.xml @@ -39,7 +39,6 @@ http://www.eclipse.org/org/documents/epl-v10.html - diff --git a/instasearch/META-INF/MANIFEST.MF b/instasearch/META-INF/MANIFEST.MF index 5e89564..3fd0d2d 100755 --- a/instasearch/META-INF/MANIFEST.MF +++ b/instasearch/META-INF/MANIFEST.MF @@ -6,16 +6,13 @@ Bundle-Version: 1.5.7.qualifier Bundle-Activator: it.unibz.instasearch.InstaSearchPlugin Bundle-DocURL: https://github.com/ajermakovics/eclipse-instasearch Bundle-UpdateLocation: http://code.inf.unibz.it/instasearch/downloads/ver.php -ErrorReportURL: http://code.inf.unibz.it/instasearch/downloads/contact/send.php Require-Bundle: org.eclipse.ui;bundle-version="3.7.0", org.apache.lucene;bundle-version="[2.9.1,2.9.2]", org.apache.lucene.analysis;bundle-version="[2.9.1,2.9.2)", - org.apache.commons.httpclient, org.apache.commons.lang, org.eclipse.ui.ide, org.eclipse.ui.editors, org.eclipse.ui.workbench.texteditor, - org.eclipse.core.net, org.eclipse.core.runtime, org.eclipse.core.resources, org.eclipse.search, diff --git a/instasearch/src/it/unibz/instasearch/InstaSearchPlugin.java b/instasearch/src/it/unibz/instasearch/InstaSearchPlugin.java index 87e999e..2676d24 100755 --- a/instasearch/src/it/unibz/instasearch/InstaSearchPlugin.java +++ b/instasearch/src/it/unibz/instasearch/InstaSearchPlugin.java @@ -17,7 +17,6 @@ import java.util.List; import org.apache.commons.lang.StringUtils; -import org.eclipse.core.net.proxy.IProxyService; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; @@ -32,7 +31,6 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; -import org.osgi.util.tracker.ServiceTracker; /** * The activator class controls the plug-in life cycle @@ -48,7 +46,6 @@ public final class InstaSearchPlugin extends AbstractUIPlugin { private String indexDirLocation; private InstaSearch instaSearch; - private ServiceTracker proxyServiceTracker; private boolean debug = false; /** @@ -320,20 +317,6 @@ public static void removePreferenceChangeListener(IPropertyChangeListener listen plugin.getPreferenceStore().removePropertyChangeListener(listener); } - public IProxyService getProxyService() { - try { - if (proxyServiceTracker == null) { - proxyServiceTracker = new ServiceTracker(getBundle().getBundleContext(), IProxyService.class, null); - proxyServiceTracker.open(); - } - return proxyServiceTracker.getService(); - } catch (Exception e) { - InstaSearchPlugin.log(e); - } - - return null; - } - private void configureDebug() { try { diff --git a/instasearch/src/it/unibz/instasearch/ui/InstaSearchUI.java b/instasearch/src/it/unibz/instasearch/ui/InstaSearchUI.java index a72bfd4..ad4879a 100755 --- a/instasearch/src/it/unibz/instasearch/ui/InstaSearchUI.java +++ b/instasearch/src/it/unibz/instasearch/ui/InstaSearchUI.java @@ -21,6 +21,7 @@ import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Shell; @@ -68,10 +69,7 @@ public static void showError(Throwable exception, String message) { } public static void showError(IStatus status, String message) { - - //status.getException().printStackTrace(); - - ReportErrorDialog.openReportError(getActiveShell(), InstaSearchPlugin.getPluginName(), message, status); + ErrorDialog.openError(getActiveShell(), InstaSearchPlugin.getPluginName(), message, status); InstaSearchPlugin.log(status); } diff --git a/instasearch/src/it/unibz/instasearch/ui/ReportErrorDialog.java b/instasearch/src/it/unibz/instasearch/ui/ReportErrorDialog.java deleted file mode 100755 index a4fdc19..0000000 --- a/instasearch/src/it/unibz/instasearch/ui/ReportErrorDialog.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (c) 2009 Andrejs Jermakovics. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andrejs Jermakovics - initial implementation - */ -package it.unibz.instasearch.ui; - -import it.unibz.instasearch.InstaSearchPlugin; - -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; - -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpException; -import org.apache.commons.httpclient.methods.PostMethod; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Link; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.osgi.framework.Constants; - -public class ReportErrorDialog extends ErrorDialog -{ - private static final int REPORT_BUTTON_ID = IDialogConstants.CLIENT_ID + 1; - private IStatus status; - private Link newTicketLink; - - /** - * @param parentShell - * @param dialogTitle - * @param message - * @param status - * @param displayMask - */ - public ReportErrorDialog(Shell parentShell, String dialogTitle, - String message, IStatus status, int displayMask) - { - super(parentShell, dialogTitle, message, status, displayMask); - - this.status = status; - } - - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.ErrorDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) - */ - @Override - protected void createButtonsForButtonBar(Composite parent) - { - super.createButtonsForButtonBar(parent); - - createButton(parent, REPORT_BUTTON_ID, "Report", true); - } - - @Override - protected List createDropDownList(Composite parent) - { - List list = super.createDropDownList(parent); - - if( newTicketLink == null ) { - newTicketLink = new Link(parent, SWT.NONE); - newTicketLink.setText("You can also open a new ticket"); - newTicketLink.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) - { - try - { - InstaSearchUI.showHomePage(); - } catch (Exception ex) - { - InstaSearchPlugin.log(ex); - newTicketLink.setEnabled(false); - } - } - }); - - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL - | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL - | GridData.GRAB_VERTICAL ); // - data.horizontalSpan = 2; - newTicketLink.setLayoutData( data ); - } - - list.addDisposeListener(new DisposeListener(){ - public void widgetDisposed(DisposeEvent e) - { - newTicketLink.dispose(); - newTicketLink = null; - } - }); - - return list; - } - - public static void openReportError(Shell parentShell, String title, - String message, IStatus status) { - - int displayMask = IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR; - final ReportErrorDialog dialog = new ReportErrorDialog(parentShell, title, message, status, displayMask); - - Display display = PlatformUI.getWorkbench().getDisplay(); - if(display == null || display.isDisposed() ) - return; - - display.asyncExec(new Runnable() { - public void run() - { - dialog.open(); - } - }); - - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.ErrorDialog#buttonPressed(int) - */ - @Override - protected void buttonPressed(int id) - { - if( id == REPORT_BUTTON_ID ) { - try { - reportError(); - close(); - } catch (Exception e) { - e.printStackTrace(); - InstaSearchPlugin.log(e); - InstaSearchUI.showMessage("Unable to send. Please open a ticket in project's site"); - } - } else - super.buttonPressed(id); - } - - - /** - * @throws IOException - * @throws HttpException - * - */ - private void reportError() throws HttpException, IOException - { - HttpClient httpClient = new HttpClient(); - PostMethod postMethod = new PostMethod(InstaSearchPlugin.getErrorReportURL()); - - postMethod.addParameter("subj", message); - postMethod.addParameter("attn", "Exception"); - postMethod.addParameter("notes", getStatusContent(status)); - postMethod.addParameter("visitor", "InstaSearch Plugin " + InstaSearchPlugin.getVersion()); - - httpClient.executeMethod(postMethod); - - postMethod.releaseConnection(); - } - - private String getStatusContent(IStatus status) { - - StringWriter stringWriter = new StringWriter(); - PrintWriter printWriter = new PrintWriter(stringWriter); - - addProperty(printWriter, "version", InstaSearchPlugin.getVersion()); - - addSystemProperty(printWriter, "osgi.framework.version"); - addSystemProperty(printWriter, "eclipse.buildId"); - addSystemProperty(printWriter, "java.version"); - - addBundleProperty(printWriter, Constants.FRAMEWORK_VERSION); - addBundleProperty(printWriter, Constants.FRAMEWORK_OS_NAME); - addBundleProperty(printWriter, Constants.FRAMEWORK_OS_VERSION); - - addStatusContent(printWriter, status); - - for(IStatus st: status.getChildren()) - addStatusContent(printWriter, st); - - return stringWriter.toString(); - } - - private void addBundleProperty(PrintWriter b, String prop) { - addProperty(b, prop, InstaSearchPlugin.getDefault().getBundle().getBundleContext().getProperty(prop)); - } - - private void addSystemProperty(PrintWriter b, String prop) { - addProperty(b, prop, System.getProperty(prop)); - } - - private void addProperty(PrintWriter b, String prop, String val) { - b.print(prop); - b.print(": "); - b.println(val); - } - - private void addStatusContent(PrintWriter b, IStatus status) { - b.print("Status: "); - b.println(status.getMessage()); - status.getException().printStackTrace(b); - b.println(); - } -} From 3b3f5432c8ac84f2e836686c84d827a9d6d46283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arvi=CC=84ds=20Grabovskis?= Date: Mon, 23 Jul 2018 12:33:25 +0300 Subject: [PATCH 3/4] Fix API compatibility with Eclipse Indigo --- instasearch/META-INF/MANIFEST.MF | 2 +- .../src/it/unibz/instasearch/InstaSearchPlugin.java | 11 +---------- .../instasearch/indexing/WorkspaceIndexerJDT.java | 4 ++-- .../it/unibz/instasearch/ui/MatchHighlightJob.java | 2 +- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/instasearch/META-INF/MANIFEST.MF b/instasearch/META-INF/MANIFEST.MF index 3fd0d2d..7da9a69 100755 --- a/instasearch/META-INF/MANIFEST.MF +++ b/instasearch/META-INF/MANIFEST.MF @@ -5,7 +5,7 @@ Bundle-SymbolicName: it.unibz.instasearch;singleton:=true Bundle-Version: 1.5.7.qualifier Bundle-Activator: it.unibz.instasearch.InstaSearchPlugin Bundle-DocURL: https://github.com/ajermakovics/eclipse-instasearch -Bundle-UpdateLocation: http://code.inf.unibz.it/instasearch/downloads/ver.php +Bundle-UpdateLocation: http://dl.bintray.com/ajermakovics/InstaSearch/ Require-Bundle: org.eclipse.ui;bundle-version="3.7.0", org.apache.lucene;bundle-version="[2.9.1,2.9.2]", org.apache.lucene.analysis;bundle-version="[2.9.1,2.9.2)", diff --git a/instasearch/src/it/unibz/instasearch/InstaSearchPlugin.java b/instasearch/src/it/unibz/instasearch/InstaSearchPlugin.java index 2676d24..59de6ff 100755 --- a/instasearch/src/it/unibz/instasearch/InstaSearchPlugin.java +++ b/instasearch/src/it/unibz/instasearch/InstaSearchPlugin.java @@ -213,15 +213,6 @@ public static String getHomePageLocation() { return getBundleHeader(Constants.BUNDLE_DOCURL); } - public static String getUpdateLocation() { - - return getBundleHeader(Constants.BUNDLE_UPDATELOCATION); - } - - public static String getErrorReportURL() { - return getBundleHeader("ErrorReportURL"); - } - public static String getPluginName() { return getBundleHeader(Constants.BUNDLE_NAME); } @@ -229,7 +220,7 @@ public static String getPluginName() { public static String getPluginId() { return PLUGIN_ID; } - + public static String getVersion() { return getBundleHeader(Constants.BUNDLE_VERSION); } diff --git a/instasearch/src/it/unibz/instasearch/indexing/WorkspaceIndexerJDT.java b/instasearch/src/it/unibz/instasearch/indexing/WorkspaceIndexerJDT.java index 58f4b60..55d3afa 100755 --- a/instasearch/src/it/unibz/instasearch/indexing/WorkspaceIndexerJDT.java +++ b/instasearch/src/it/unibz/instasearch/indexing/WorkspaceIndexerJDT.java @@ -462,8 +462,8 @@ public boolean isReadOnly() { return true; } - @Override - public T getAdapter(Class adapter) { + @SuppressWarnings("rawtypes") + public Object getAdapter(Class adapter) { return classFile.getAdapter(adapter); } diff --git a/instasearch/src/it/unibz/instasearch/ui/MatchHighlightJob.java b/instasearch/src/it/unibz/instasearch/ui/MatchHighlightJob.java index 58bcb8f..1c89605 100755 --- a/instasearch/src/it/unibz/instasearch/ui/MatchHighlightJob.java +++ b/instasearch/src/it/unibz/instasearch/ui/MatchHighlightJob.java @@ -71,7 +71,7 @@ public MatchHighlightJob(SearchResultDoc doc, MatchLine selectedLineMatches, Res this.workbenchPage = workbenchPage; IEditorInput input = contentProvider.getEditorInput(doc); - IEditorDescriptor editorDesc = IDE.getEditorDescriptor(doc.getFileName(), true, true); + IEditorDescriptor editorDesc = IDE.getEditorDescriptor(doc.getFileName()); IEditorPart editorPart = IDE.openEditor(workbenchPage, input, editorDesc.getId()); this.editor = getTextEditor(input, editorPart); From 1d7ea249f1f6bf990626c1685063fbaecee123f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arvi=CC=84ds=20Grabovskis?= Date: Mon, 23 Jul 2018 12:47:12 +0300 Subject: [PATCH 4/4] Fix API compatibility with Eclipse Indigo (cont.) --- .../test/it/unibz/instasearch/indexing/TestStorage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instasearch/test/it/unibz/instasearch/indexing/TestStorage.java b/instasearch/test/it/unibz/instasearch/indexing/TestStorage.java index 8d10e66..7f91498 100755 --- a/instasearch/test/it/unibz/instasearch/indexing/TestStorage.java +++ b/instasearch/test/it/unibz/instasearch/indexing/TestStorage.java @@ -53,8 +53,8 @@ public boolean isReadOnly() { return false; } - @Override - public T getAdapter(Class adapter) { + @SuppressWarnings("rawtypes") + public Object getAdapter(Class adapter) { return null; } } \ No newline at end of file