Skip to content

Commit 4b9f591

Browse files
committed
Refactor plugins - Create Core and UI plugins for base and LSP functionality. Fixes fabric8-analytics#143
Signed-off-by: Rastislav Wagner <[email protected]>
1 parent 6fb8ca3 commit 4b9f591

File tree

83 files changed

+1167
-428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1167
-428
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %Bundle-Name
4-
Bundle-SymbolicName: com.redhat.fabric8analytics.lsp.eclipse.core;singleton:=true
4+
Bundle-SymbolicName: com.redhat.fabric8analytics.eclipse.core;singleton:=true
55
Bundle-Version: 0.0.1.qualifier
66
Bundle-Vendor: %Bundle-Vendor
77
Bundle-Localization: plugin
88
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
9-
Require-Bundle: org.eclipse.lsp4e;bundle-version="0.3.0",
10-
org.eclipse.core.runtime,
9+
Require-Bundle: org.eclipse.core.runtime,
1110
org.eclipse.core.resources;bundle-version="3.12.0",
1211
org.apache.httpcomponents.httpclient;bundle-version="4.5.2",
1312
org.apache.httpcomponents.httpcore;bundle-version="4.4.6",
@@ -18,13 +17,13 @@ Require-Bundle: org.eclipse.lsp4e;bundle-version="0.3.0",
1817
org.eclipse.m2e.core,
1918
org.eclipse.m2e.maven.runtime,
2019
org.jboss.tools.openshift.io.core
21-
Eclipse-BundleShape: dir
22-
Bundle-Activator: com.redhat.fabric8analytics.lsp.eclipse.core.Fabric8AnalysisLSCoreActivator
20+
Bundle-Activator: com.redhat.fabric8analytics.eclipse.core.Fabric8AnalysisCoreActivator
2321
Bundle-ActivationPolicy: lazy
2422
Bundle-ClassPath: .
25-
Export-Package: com.redhat.fabric8analytics.lsp.eclipse.core,
26-
com.redhat.fabric8analytics.lsp.eclipse.core.job,
27-
com.redhat.fabric8analytics.lsp.eclipse.core.data,
28-
com.redhat.fabric8analytics.lsp.eclipse.core.internal;x-friends:=com.redhat.fabric8analytics.lsp.eclipse.ui
23+
Export-Package: com.redhat.fabric8analytics.eclipse.core,
24+
com.redhat.fabric8analytics.eclipse.core.data,
25+
com.redhat.fabric8analytics.eclipse.core.internal;x-friends:="com.redhat.fabric8analytics.eclipse.lsp.core, com.redhat.fabric8analytics.eclipse.ui, com.redhat.fabric8analytics.eclipse.lsp.ui",
26+
com.redhat.fabric8analytics.eclipse.core.job,
27+
com.redhat.fabric8analytics.eclipse.core.api
2928

3029

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Bundle-Name=Fabric8Analytics Core Plugin
2+
Bundle-Vendor=JBoss by Red Hat

plugins/com.redhat.fabric8analytics.lsp.eclipse.core/pom.xml renamed to plugins/com.redhat.fabric8analytics.eclipse.core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<version>0.0.1-SNAPSHOT</version>
77
</parent>
88

9-
<artifactId>com.redhat.fabric8analytics.lsp.eclipse.core</artifactId>
9+
<artifactId>com.redhat.fabric8analytics.eclipse.core</artifactId>
1010
<packaging>eclipse-plugin</packaging>
1111

1212
</project>
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Red Hat Incorporated - initial API and implementation
1010
*******************************************************************************/
1111

12-
package com.redhat.fabric8analytics.lsp.eclipse.core;
12+
package com.redhat.fabric8analytics.eclipse.core;
1313

1414
import org.eclipse.core.runtime.IStatus;
1515
import org.eclipse.core.runtime.Plugin;
@@ -19,17 +19,17 @@
1919
/**
2020
* The activator class controls the plug-in life cycle
2121
*/
22-
public class Fabric8AnalysisLSCoreActivator extends Plugin {
22+
public class Fabric8AnalysisCoreActivator extends Plugin {
2323

24-
public static final String PLUGIN_ID = "com.redhat.fabric8analytics.lsp.eclipse.core";
24+
public static final String PLUGIN_ID = "com.redhat.fabric8analytics.eclipse.core";
2525

2626
// The shared instance
27-
private static Fabric8AnalysisLSCoreActivator plugin;
27+
private static Fabric8AnalysisCoreActivator plugin;
2828

2929
/**
3030
* The constructor
3131
*/
32-
public Fabric8AnalysisLSCoreActivator() {
32+
public Fabric8AnalysisCoreActivator() {
3333
}
3434

3535
@Override
@@ -49,7 +49,7 @@ public void stop(BundleContext context) throws Exception {
4949
*
5050
* @return the shared instance
5151
*/
52-
public static Fabric8AnalysisLSCoreActivator getDefault() {
52+
public static Fabric8AnalysisCoreActivator getDefault() {
5353
return plugin;
5454
}
5555

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@
88
* Contributors:
99
* Red Hat Incorporated - initial API and implementation
1010
*******************************************************************************/
11-
package com.redhat.fabric8analytics.lsp.eclipse.core;
11+
package com.redhat.fabric8analytics.eclipse.core;
1212

1313
import org.eclipse.core.runtime.preferences.InstanceScope;
1414
import org.eclipse.equinox.security.storage.ISecurePreferences;
1515
import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
1616
import org.eclipse.equinox.security.storage.StorageException;
1717

18-
import com.redhat.fabric8analytics.lsp.eclipse.core.data.ThreeScaleData;
18+
import com.redhat.fabric8analytics.eclipse.core.data.ThreeScaleData;
1919

2020
public class Fabric8AnalysisPreferences {
2121

22-
public static final String LSP_SERVER_ENABLED = "fabric8AnalysisPreferences.LSP_ENABLED";
2322
public static final String PROD_URL = "fabric8AnalysisPreferences.PROD_URL";
2423
public static final String STAGE_URL = "fabric8AnalysisPreferences.STAGE_URL";
2524
public static final String USER_KEY = "fabric8AnalysisPreferences.USER_KEY";
@@ -39,28 +38,20 @@ public static Fabric8AnalysisPreferences getInstance() {
3938
return instance;
4039
}
4140

42-
public boolean isLSPServerEnabled() {
43-
return InstanceScope.INSTANCE.getNode(Fabric8AnalysisLSCoreActivator.PLUGIN_ID).getBoolean(LSP_SERVER_ENABLED, false);
44-
}
45-
46-
public void setLSPServerEnabled(boolean enabled) {
47-
InstanceScope.INSTANCE.getNode(Fabric8AnalysisLSCoreActivator.PLUGIN_ID).putBoolean(LSP_SERVER_ENABLED, enabled);
48-
}
49-
5041
public String getProdURL() {
51-
return InstanceScope.INSTANCE.getNode(Fabric8AnalysisLSCoreActivator.PLUGIN_ID).get(PROD_URL, null);
42+
return InstanceScope.INSTANCE.getNode(Fabric8AnalysisCoreActivator.PLUGIN_ID).get(PROD_URL, null);
5243
}
5344

5445
public void setProdURL(String prodURL) {
55-
InstanceScope.INSTANCE.getNode(Fabric8AnalysisLSCoreActivator.PLUGIN_ID).put(PROD_URL, prodURL);
46+
InstanceScope.INSTANCE.getNode(Fabric8AnalysisCoreActivator.PLUGIN_ID).put(PROD_URL, prodURL);
5647
}
5748

5849
public String getStageURL() {
59-
return InstanceScope.INSTANCE.getNode(Fabric8AnalysisLSCoreActivator.PLUGIN_ID).get(STAGE_URL, null);
50+
return InstanceScope.INSTANCE.getNode(Fabric8AnalysisCoreActivator.PLUGIN_ID).get(STAGE_URL, null);
6051
}
6152

6253
public void setStageURL(String stageURL) {
63-
InstanceScope.INSTANCE.getNode(Fabric8AnalysisLSCoreActivator.PLUGIN_ID).put(STAGE_URL, stageURL);
54+
InstanceScope.INSTANCE.getNode(Fabric8AnalysisCoreActivator.PLUGIN_ID).put(STAGE_URL, stageURL);
6455
}
6556

6657
public String getUserKey() throws StorageException {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Red Hat Incorporated - initial API and implementation
1010
*******************************************************************************/
1111

12-
package com.redhat.fabric8analytics.lsp.eclipse.core;
12+
package com.redhat.fabric8analytics.eclipse.core.api;
1313

1414
import org.json.JSONObject;
1515

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Red Hat Incorporated - initial API and implementation
1010
*******************************************************************************/
1111

12-
package com.redhat.fabric8analytics.lsp.eclipse.core;
12+
package com.redhat.fabric8analytics.eclipse.core.api;
1313

1414

1515
import java.io.File;
@@ -31,8 +31,9 @@
3131
import org.json.JSONException;
3232
import org.json.JSONObject;
3333

34-
import com.redhat.fabric8analytics.lsp.eclipse.core.data.AnalyticsAuthData;
35-
import com.redhat.fabric8analytics.lsp.eclipse.core.internal.PomContentBody;
34+
import com.redhat.fabric8analytics.eclipse.core.Fabric8AnalysisCoreActivator;
35+
import com.redhat.fabric8analytics.eclipse.core.data.AnalyticsAuthData;
36+
import com.redhat.fabric8analytics.eclipse.core.internal.PomContentBody;
3637

3738
/**
3839
* Provides access to Recommender API server
@@ -132,7 +133,7 @@ public boolean analysesFinished(String jobId) throws RecommenderAPIException {
132133
int responseCode = response.getStatusLine().getStatusCode();
133134

134135
// TODO - for debug purposes - should be removed later
135-
Fabric8AnalysisLSCoreActivator.getDefault().logInfo("F8 server response code: " + responseCode);
136+
Fabric8AnalysisCoreActivator.getDefault().logInfo("F8 server response code: " + responseCode);
136137

137138
if (responseCode == HttpStatus.SC_OK) {
138139
return true;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Red Hat Incorporated - initial API and implementation
1010
*******************************************************************************/
1111

12-
package com.redhat.fabric8analytics.lsp.eclipse.core;
12+
package com.redhat.fabric8analytics.eclipse.core.api;
1313

1414
import org.json.JSONObject;
1515

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Red Hat Incorporated - initial API and implementation
1010
*******************************************************************************/
1111

12-
package com.redhat.fabric8analytics.lsp.eclipse.core;
12+
package com.redhat.fabric8analytics.eclipse.core.api;
1313

1414
import java.io.IOException;
1515

@@ -22,7 +22,7 @@
2222
import org.json.JSONException;
2323
import org.json.JSONObject;
2424

25-
import com.redhat.fabric8analytics.lsp.eclipse.core.data.ThreeScaleData;
25+
import com.redhat.fabric8analytics.eclipse.core.data.ThreeScaleData;
2626

2727
/**
2828
* Provides access to 3scale service
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Contributors:
99
* Red Hat Incorporated - initial API and implementation
1010
*******************************************************************************/
11-
package com.redhat.fabric8analytics.lsp.eclipse.core.data;
11+
package com.redhat.fabric8analytics.eclipse.core.data;
1212

1313
public class AnalyticsAuthData {
1414

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.redhat.fabric8analytics.lsp.eclipse.core.data;
1+
package com.redhat.fabric8analytics.eclipse.core.data;
22

33
/**
44
* Stores 3scale data.
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Red Hat Incorporated - initial API and implementation
1010
*******************************************************************************/
1111

12-
package com.redhat.fabric8analytics.lsp.eclipse.core.internal;
12+
package com.redhat.fabric8analytics.eclipse.core.internal;
1313

1414
import java.util.List;
1515

@@ -21,12 +21,12 @@
2121
import org.jboss.tools.openshift.io.core.AccountStatus;
2222
import org.jboss.tools.openshift.io.core.model.IAccount;
2323

24-
import com.redhat.fabric8analytics.lsp.eclipse.core.Fabric8AnalysisLSCoreActivator;
25-
import com.redhat.fabric8analytics.lsp.eclipse.core.Fabric8AnalysisPreferences;
26-
import com.redhat.fabric8analytics.lsp.eclipse.core.ThreeScaleAPIException;
27-
import com.redhat.fabric8analytics.lsp.eclipse.core.ThreeScaleAPIProvider;
28-
import com.redhat.fabric8analytics.lsp.eclipse.core.data.AnalyticsAuthData;
29-
import com.redhat.fabric8analytics.lsp.eclipse.core.data.ThreeScaleData;
24+
import com.redhat.fabric8analytics.eclipse.core.Fabric8AnalysisCoreActivator;
25+
import com.redhat.fabric8analytics.eclipse.core.Fabric8AnalysisPreferences;
26+
import com.redhat.fabric8analytics.eclipse.core.api.ThreeScaleAPIException;
27+
import com.redhat.fabric8analytics.eclipse.core.api.ThreeScaleAPIProvider;
28+
import com.redhat.fabric8analytics.eclipse.core.data.AnalyticsAuthData;
29+
import com.redhat.fabric8analytics.eclipse.core.data.ThreeScaleData;
3030

3131
public class AnalyticsAuthService {
3232

@@ -78,7 +78,7 @@ public AnalyticsAuthData getAnalyticsAuthData(IProgressMonitor progressMonitor)
7878
try {
7979
threeScaleData = registerThreeScale(monitor, token);
8080
} catch (ThreeScaleAPIException e) {
81-
Fabric8AnalysisLSCoreActivator.getDefault().logError("Unable to get data from 3scale", e);
81+
Fabric8AnalysisCoreActivator.getDefault().logError("Unable to get data from 3scale", e);
8282
return null;
8383
}
8484
}
@@ -101,7 +101,7 @@ public AnalyticsAuthData login(IProgressMonitor progressMonitor) throws StorageE
101101
try {
102102
threeScaleData = registerThreeScale(monitor, token);
103103
} catch (ThreeScaleAPIException e) {
104-
Fabric8AnalysisLSCoreActivator.getDefault().logError("Unable to get data from 3scale", e);
104+
Fabric8AnalysisCoreActivator.getDefault().logError("Unable to get data from 3scale", e);
105105
return null;
106106
}
107107
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Contributors:
99
* Red Hat Incorporated - initial API and implementation
1010
*******************************************************************************/
11-
package com.redhat.fabric8analytics.lsp.eclipse.core.internal;
11+
package com.redhat.fabric8analytics.eclipse.core.internal;
1212

1313
import java.io.IOException;
1414
import java.io.OutputStream;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2018 Red Hat Inc..
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Red Hat Incorporated - initial API and implementation
10+
*******************************************************************************/
11+
package com.redhat.fabric8analytics.eclipse.core.job;
12+
13+
import org.eclipse.core.runtime.IProgressMonitor;
14+
import org.eclipse.core.runtime.IStatus;
15+
import org.eclipse.core.runtime.Status;
16+
import org.eclipse.core.runtime.jobs.Job;
17+
import org.eclipse.equinox.security.storage.StorageException;
18+
19+
import com.redhat.fabric8analytics.eclipse.core.Fabric8AnalysisCoreActivator;
20+
import com.redhat.fabric8analytics.eclipse.core.data.AnalyticsAuthData;
21+
import com.redhat.fabric8analytics.eclipse.core.internal.AnalyticsAuthService;
22+
23+
public class LoginToOSIOJob extends Job {
24+
25+
private AnalyticsAuthData analyticsAuthData;
26+
27+
public LoginToOSIOJob() {
28+
super("Login to Openshift.io");
29+
}
30+
31+
@Override
32+
protected IStatus run(IProgressMonitor progressMonitor) {
33+
try {
34+
analyticsAuthData = AnalyticsAuthService.getInstance().login(progressMonitor);
35+
} catch (StorageException e) {
36+
return new Status(IStatus.ERROR, Fabric8AnalysisCoreActivator.PLUGIN_ID, "Error occured while storing Fabric8Analytics data", e);
37+
}
38+
return Status.OK_STATUS;
39+
}
40+
41+
public AnalyticsAuthData getAnalyticsAuthData() {
42+
return analyticsAuthData;
43+
}
44+
45+
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
* Contributors:
99
* Red Hat Incorporated - initial API and implementation
1010
*******************************************************************************/
11-
package com.redhat.fabric8analytics.lsp.eclipse.core.job;
11+
package com.redhat.fabric8analytics.eclipse.core.job;
1212

1313
import org.eclipse.core.runtime.IProgressMonitor;
1414
import org.eclipse.core.runtime.IStatus;
1515
import org.eclipse.core.runtime.Status;
1616
import org.eclipse.core.runtime.jobs.Job;
1717

18-
import com.redhat.fabric8analytics.lsp.eclipse.core.Fabric8AnalysisLSCoreActivator;
19-
import com.redhat.fabric8analytics.lsp.eclipse.core.RecommenderAPIException;
20-
import com.redhat.fabric8analytics.lsp.eclipse.core.RecommenderAPIProvider;
18+
import com.redhat.fabric8analytics.eclipse.core.Fabric8AnalysisCoreActivator;
19+
import com.redhat.fabric8analytics.eclipse.core.api.RecommenderAPIException;
20+
import com.redhat.fabric8analytics.eclipse.core.api.RecommenderAPIProvider;
2121

2222
public class RetrieveResultsJob extends Job {
2323

@@ -35,10 +35,10 @@ public RetrieveResultsJob(RecommenderAPIProvider provider, String jobID) {
3535
protected IStatus run(IProgressMonitor monitor) {
3636
try {
3737
if (!provider.analysesFinished(jobID)) {
38-
return new Status(IStatus.INFO, Fabric8AnalysisLSCoreActivator.PLUGIN_ID, "Analysis is not ready yet");
38+
return new Status(IStatus.INFO, Fabric8AnalysisCoreActivator.PLUGIN_ID, "Analysis is not ready yet");
3939
}
4040
} catch (RecommenderAPIException e) {
41-
return new Status(IStatus.ERROR, Fabric8AnalysisLSCoreActivator.PLUGIN_ID,
41+
return new Status(IStatus.ERROR, Fabric8AnalysisCoreActivator.PLUGIN_ID,
4242
"Error during communication with analytics server", e);
4343
}
4444

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Contributors:
99
* Red Hat Incorporated - initial API and implementation
1010
*******************************************************************************/
11-
package com.redhat.fabric8analytics.lsp.eclipse.core.job;
11+
package com.redhat.fabric8analytics.eclipse.core.job;
1212

1313
import java.io.StringWriter;
1414
import java.util.HashMap;
@@ -26,8 +26,8 @@
2626
import org.eclipse.m2e.core.project.IMavenProjectFacade;
2727
import org.eclipse.m2e.core.project.IMavenProjectRegistry;
2828

29-
import com.redhat.fabric8analytics.lsp.eclipse.core.Fabric8AnalysisLSCoreActivator;
30-
import com.redhat.fabric8analytics.lsp.eclipse.core.RecommenderAPIProvider;
29+
import com.redhat.fabric8analytics.eclipse.core.Fabric8AnalysisCoreActivator;
30+
import com.redhat.fabric8analytics.eclipse.core.api.RecommenderAPIProvider;
3131

3232
public class SendToFabric8AnalysisJob extends Job {
3333

@@ -61,7 +61,7 @@ protected IStatus run(IProgressMonitor monitor) {
6161

6262
jobID = provider.requestAnalyses(effectivePomFiles, license);
6363
} catch (Exception e) {
64-
return new Status(Status.ERROR, Fabric8AnalysisLSCoreActivator.PLUGIN_ID, "Error during communication with server", e);
64+
return new Status(Status.ERROR, Fabric8AnalysisCoreActivator.PLUGIN_ID, "Error during communication with server", e);
6565
}
6666
return Status.OK_STATUS;
6767
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/bin/
2+
/.settings/
3+
/.project
4+
/.classpath
5+
target/
6+
server*
7+
**/.DS_Store

0 commit comments

Comments
 (0)