Author: snjeza
Date: 2011-10-16 17:10:06 -0400 (Sun, 16 Oct 2011)
New Revision: 35692
Added:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossNewsHandler.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/RefreshJBossNewsHandler.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshNewsJob.java
Modified:
trunk/central/plugins/org.jboss.tools.central/plugin.xml
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshBlogsJob.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshDiscoveryJob.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshTutorialsJob.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/FeedsEntry.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/Tutorial.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/TutorialCategory.java
Log:
JBIDE-9368 Dashboard(s) for easy news aggregation, twitter and easy additional/3rd party
plugin installation and project template/creation
Modified: trunk/central/plugins/org.jboss.tools.central/plugin.xml
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/plugin.xml 2011-10-16 21:09:55 UTC (rev
35691)
+++ trunk/central/plugins/org.jboss.tools.central/plugin.xml 2011-10-16 21:10:06 UTC (rev
35692)
@@ -63,6 +63,12 @@
</command>
<command
+ defaultHandler="org.jboss.tools.central.actions.OpenJBossNewsHandler"
+ name="News"
+ id="org.jboss.tools.central.openJBossNews">
+ </command>
+
+ <command
defaultHandler="org.jboss.tools.central.actions.RefreshJBossTutorialsHandler"
name="Refresh"
id="org.jboss.tools.central.refreshJBossTutorials">
@@ -73,6 +79,11 @@
id="org.jboss.tools.central.refreshJBossBlogs">
</command>
<command
+
defaultHandler="org.jboss.tools.central.actions.RefreshJBossNewsHandler"
+ name="Refresh"
+ id="org.jboss.tools.central.refreshJBossNews">
+ </command>
+ <command
defaultHandler="org.jboss.tools.central.actions.RefreshDiscoveryHandler"
name="Refresh"
id="org.jboss.tools.central.refreshDiscovery">
@@ -135,10 +146,18 @@
icon="icons/blogs.gif">
</image>
<image
+ commandId="org.jboss.tools.central.openJBossNews"
+ icon="icons/news.png">
+ </image>
+ <image
commandId="org.jboss.tools.central.refreshJBossBlogs"
icon="icons/refresh.gif">
</image>
<image
+ commandId="org.jboss.tools.central.refreshJBossNews"
+ icon="icons/refresh.gif">
+ </image>
+ <image
commandId="org.jboss.tools.central.refreshJBossTutorials"
icon="icons/refresh.gif">
</image>
Added:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossNewsHandler.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossNewsHandler.java
(rev 0)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossNewsHandler.java 2011-10-16
21:10:06 UTC (rev 35692)
@@ -0,0 +1,28 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+
+package org.jboss.tools.central.actions;
+
+import org.jboss.tools.central.JBossCentralActivator;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public class OpenJBossNewsHandler extends OpenWithBrowserHandler {
+
+ @Override
+ public String getLocation() {
+ return JBossCentralActivator.NEWS_URL;
+ }
+
+}
Added:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/RefreshJBossNewsHandler.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/RefreshJBossNewsHandler.java
(rev 0)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/RefreshJBossNewsHandler.java 2011-10-16
21:10:06 UTC (rev 35692)
@@ -0,0 +1,35 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+
+package org.jboss.tools.central.actions;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.jobs.Job;
+import org.jboss.tools.central.jobs.RefreshBlogsJob;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public class RefreshJBossNewsHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ if (RefreshBlogsJob.INSTANCE.getState() == Job.NONE) {
+ RefreshBlogsJob.INSTANCE.schedule();
+ }
+ return null;
+ }
+
+}
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java 2011-10-16
21:09:55 UTC (rev 35691)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java 2011-10-16
21:10:06 UTC (rev 35692)
@@ -89,6 +89,7 @@
import org.jboss.tools.central.JBossCentralActivator;
import org.jboss.tools.central.dialogs.ProjectExamplesDialog;
import org.jboss.tools.central.jobs.RefreshBlogsJob;
+import org.jboss.tools.central.jobs.RefreshNewsJob;
import org.jboss.tools.central.jobs.RefreshTutorialsJob;
import org.jboss.tools.central.model.FeedsEntry;
import org.jboss.tools.central.model.Tutorial;
@@ -112,7 +113,7 @@
private IWorkbenchAction newWizardDropDownAction;
private ScrolledForm form;
private PageBook blogsPageBook;
- private ScrolledComposite scrollComposite;
+ private ScrolledComposite blogsScrollComposite;
private RefreshBlogsJobChangeListener refreshBlogsJobChangeListener;
private FormText blogsNoteText;
private FormText tutorialsNoteText;
@@ -134,6 +135,14 @@
private Composite documentationComposite;
private Set<TutorialCategory> expandedCategories = new
HashSet<TutorialCategory>();
+ private Section newsSection;
+ private ScrolledComposite newsScrollComposite;
+ private PageBook newsPageBook;
+ private FormText newsNoteText;
+ private Composite newsLoadingComposite;
+ private FormText newsExceptionText;
+ private Composite newsComposite;
+ private RefreshNewsJobChangeListener refreshNewsJobChangeListener;
public GettingStartedPage(FormEditor editor) {
super(editor, ID, "Getting Started");
@@ -160,7 +169,8 @@
toolkit.paintBordersFor(left);
Composite right = createComposite(toolkit, body);
- createBlogsSection(toolkit, right);
+ createNewsSection(toolkit, right);
+ createBlogsSection(toolkit, right);
toolkit.paintBordersFor(right);
final ControlAdapter controlAdapter = new ControlAdapter() {
@@ -186,26 +196,26 @@
}
private void createBlogsSection(FormToolkit toolkit, Composite parent) {
- blogsSection = createSection(toolkit, parent, "Blogs",
ExpandableComposite.TITLE_BAR|ExpandableComposite.EXPANDED);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ blogsSection = createSection(toolkit, parent, "Blogs",
ExpandableComposite.TITLE_BAR|ExpandableComposite.EXPANDED|ExpandableComposite.TWISTIE);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
//gd.widthHint = 350;
//gd.heightHint = 100;
blogsSection.setLayoutData(gd);
createBlogsToolbar(toolkit, blogsSection);
- scrollComposite = new ScrolledComposite(blogsSection, SWT.V_SCROLL);
+ blogsScrollComposite = new ScrolledComposite(blogsSection, SWT.V_SCROLL);
gd =new GridData(SWT.FILL, SWT.FILL, true, false);
- scrollComposite.setLayoutData(gd);
- scrollComposite.setLayout(new GridLayout());
+ blogsScrollComposite.setLayoutData(gd);
+ blogsScrollComposite.setLayout(new GridLayout());
- blogsPageBook = new PageBook(scrollComposite, SWT.WRAP);
+ blogsPageBook = new PageBook(blogsScrollComposite, SWT.WRAP);
gd =new GridData(SWT.FILL, SWT.FILL, true, false);
blogsPageBook.setLayoutData(gd);
- scrollComposite.setContent(blogsPageBook);
- scrollComposite.setExpandVertical(true);
- scrollComposite.setExpandHorizontal(true);
- scrollComposite.setAlwaysShowScrollBars(false);
+ blogsScrollComposite.setContent(blogsPageBook);
+ blogsScrollComposite.setExpandVertical(true);
+ blogsScrollComposite.setExpandHorizontal(true);
+ blogsScrollComposite.setAlwaysShowScrollBars(false);
blogsNoteText = createNoteText(toolkit, blogsPageBook);
blogsLoadingComposite = createLoadingComposite(toolkit, blogsPageBook);
@@ -215,15 +225,71 @@
blogsComposite.setLayout(new TableWrapLayout());
GridDataFactory.fillDefaults().grab(true, false).applyTo(blogsComposite);
- blogsSection.setClient(scrollComposite);
- showLoading(blogsPageBook, blogsLoadingComposite, scrollComposite);
+ blogsSection.setClient(blogsScrollComposite);
+ blogsSection.addExpansionListener(new ExpansionAdapter() {
+
+ @Override
+ public void expansionStateChanged(ExpansionEvent e) {
+ resize();
+ }
+
+ });
+ showLoading(blogsPageBook, blogsLoadingComposite, blogsScrollComposite);
blogsPageBook.pack(true);
RefreshBlogsJob refreshBlogsJob = RefreshBlogsJob.INSTANCE;
refreshBlogsJobChangeListener = new RefreshBlogsJobChangeListener();
refreshBlogsJob.addJobChangeListener(refreshBlogsJobChangeListener);
refreshBlogsJob.schedule();
}
+
+ private void createNewsSection(FormToolkit toolkit, Composite parent) {
+ newsSection = createSection(toolkit, parent, "News",
ExpandableComposite.TITLE_BAR|ExpandableComposite.EXPANDED|ExpandableComposite.TWISTIE);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ //gd.widthHint = 350;
+ //gd.heightHint = 100;
+ newsSection.setLayoutData(gd);
+ createNewsToolbar(toolkit, newsSection);
+
+ newsScrollComposite = new ScrolledComposite(newsSection, SWT.V_SCROLL);
+ gd =new GridData(SWT.FILL, SWT.FILL, true, false);
+ newsScrollComposite.setLayoutData(gd);
+ newsScrollComposite.setLayout(new GridLayout());
+
+ newsPageBook = new PageBook(newsScrollComposite, SWT.WRAP);
+ gd =new GridData(SWT.FILL, SWT.FILL, true, false);
+ newsPageBook.setLayoutData(gd);
+
+ newsScrollComposite.setContent(newsPageBook);
+ newsScrollComposite.setExpandVertical(true);
+ newsScrollComposite.setExpandHorizontal(true);
+ newsScrollComposite.setAlwaysShowScrollBars(false);
+ newsNoteText = createNoteText(toolkit, newsPageBook);
+ newsLoadingComposite = createLoadingComposite(toolkit, newsPageBook);
+ newsExceptionText = createExceptionText(toolkit, newsPageBook);
+
+ newsComposite = toolkit.createComposite(newsPageBook, SWT.NONE);
+ newsComposite.setLayout(new TableWrapLayout());
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(newsComposite);
+
+ newsSection.setClient(newsScrollComposite);
+ newsSection.addExpansionListener(new ExpansionAdapter() {
+
+ @Override
+ public void expansionStateChanged(ExpansionEvent e) {
+ resize();
+ }
+
+ });
+ showLoading(newsPageBook, newsLoadingComposite, newsScrollComposite);
+ newsPageBook.pack(true);
+ RefreshNewsJob refreshNewsJob = RefreshNewsJob.INSTANCE;
+ refreshNewsJobChangeListener = new RefreshNewsJobChangeListener();
+ refreshNewsJob.addJobChangeListener(refreshNewsJobChangeListener);
+ refreshNewsJob.schedule();
+ }
+
+
private FormText createExceptionText(FormToolkit toolkit, Composite parent) {
FormText formText = toolkit.createFormText(parent, true);
GridData gd = new GridData(GridData.FILL, GridData.FILL, false, false);
@@ -283,6 +349,29 @@
section.setTextClient(headerComposite);
}
+ private void createNewsToolbar(FormToolkit toolkit, Section section) {
+ Composite headerComposite = toolkit.createComposite(section, SWT.NONE);
+ RowLayout rowLayout = new RowLayout();
+ rowLayout.marginTop = 0;
+ rowLayout.marginBottom = 0;
+ headerComposite.setLayout(rowLayout);
+ headerComposite.setBackground(null);
+
+ ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
+ toolBarManager.createControl(headerComposite);
+
+ CommandContributionItem item = JBossCentralActivator.createContributionItem(getSite(),
"org.jboss.tools.central.openJBossNews");
+ toolBarManager.add(item);
+
+ item = JBossCentralActivator.createContributionItem(getSite(),
"org.jboss.tools.central.refreshJBossNews");
+ toolBarManager.add(item);
+
+ toolBarManager.update(true);
+
+ section.setTextClient(headerComposite);
+ }
+
+
private void createTutorialsSection(FormToolkit toolkit, Composite parent) {
tutorialsSection = createSection(toolkit, parent, "Project Examples",
ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
@@ -568,6 +657,10 @@
RefreshBlogsJob.INSTANCE.removeJobChangeListener(refreshBlogsJobChangeListener);
refreshBlogsJobChangeListener = null;
}
+ if (refreshNewsJobChangeListener != null) {
+ RefreshNewsJob.INSTANCE.removeJobChangeListener(refreshNewsJobChangeListener);
+ refreshNewsJobChangeListener = null;
+ }
if (refreshTutorialsJobChangeListener != null) {
RefreshTutorialsJob.INSTANCE.removeJobChangeListener(refreshTutorialsJobChangeListener);
refreshTutorialsJobChangeListener = null;
@@ -643,13 +736,30 @@
}
List<FeedsEntry> entries = job.getEntries();
if (entries == null || entries.size() == 0) {
- showNote(blogsPageBook, blogsNoteText, scrollComposite);
+ showNote(blogsPageBook, blogsNoteText, blogsScrollComposite);
return;
}
- showBlogs(entries);
+ showEntries(entries, blogsComposite, blogsPageBook, blogsScrollComposite);
}
}
+ public void refreshNews() {
+ RefreshNewsJob job = RefreshNewsJob.INSTANCE;
+ if (job.getState() == Job.NONE) {
+ if (job.getException() != null) {
+ showException(newsPageBook, newsExceptionText,
+ job.getException());
+ return;
+ }
+ List<FeedsEntry> entries = job.getEntries();
+ if (entries == null || entries.size() == 0) {
+ showNote(newsPageBook, newsNoteText, newsScrollComposite);
+ return;
+ }
+ showEntries(entries, newsComposite, newsPageBook, newsScrollComposite);
+ }
+ }
+
public void refreshTutorials() {
RefreshTutorialsJob job = RefreshTutorialsJob.INSTANCE;
if (job.getException() != null) {
@@ -786,19 +896,19 @@
}
}
- private void showBlogs(List<FeedsEntry> entries) {
+ private void showEntries(List<FeedsEntry> entries, Composite composite, PageBook
pageBook, ScrolledComposite scrollable) {
int i = 0;
- disposeChildren(blogsComposite);
+ disposeChildren(composite);
for (final FeedsEntry entry:entries) {
if (i++ > JBossCentralActivator.MAX_FEEDS) {
return;
}
String text = entry.getFormString();
- final FormText formText = toolkit.createFormText(blogsComposite, true);
+ final FormText formText = toolkit.createFormText(composite, true);
TableWrapData td = new TableWrapData();
td.indent = 2;
- Point size = blogsComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
td.maxWidth = size.x - 2;
try {
// to avoid illegal argumentexception on formtext fields.
@@ -838,22 +948,49 @@
});
}
- blogsPageBook.showPage(blogsComposite);
+ pageBook.showPage(composite);
form.reflow(true);
form.redraw();
- recomputeScrollComposite(scrollComposite, blogsPageBook);
+ recomputeScrollComposite(scrollable, pageBook);
}
protected void resize() {
- Point size = form.getSize();
+ Point size = form.getBody().getSize();
GridData gd;
+ Point computedSize;
int widthHint = size.x/2 - 40;
+ gd = (GridData) newsSection.getLayoutData();
+ if (newsSection.isExpanded()) {
+ if (blogsSection.isExpanded()) {
+ gd.heightHint = size.y/2 - 20;
+ } else {
+ gd.heightHint = size.y - 40;
+ }
+ } else {
+ computedSize = newsSection.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ gd.heightHint = computedSize.y;
+ }
+ gd.widthHint = widthHint;
+ gd.grabExcessVerticalSpace = false;
+ computedSize = newsSection.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ newsSection.setSize(widthHint, computedSize.y);
+
gd = (GridData) blogsSection.getLayoutData();
- gd.heightHint = size.y - 40;
+ if (blogsSection.isExpanded()) {
+ if (newsSection.isExpanded()) {
+ gd.heightHint = size.y/2 - 20;
+ } else {
+ gd.heightHint = size.y - 40;
+ }
+ } else {
+ computedSize = blogsSection.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ gd.heightHint = computedSize.y;
+ }
+
gd.widthHint = widthHint;
gd.grabExcessVerticalSpace = false;
- Point computedSize = blogsSection.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ computedSize = blogsSection.computeSize(SWT.DEFAULT, SWT.DEFAULT);
blogsSection.setSize(widthHint, computedSize.y);
gd = (GridData) tutorialsSection.getLayoutData();
@@ -880,7 +1017,8 @@
form.reflow(true);
form.redraw();
- scrollComposite.setMinSize(widthHint, size.y - 55);
+ blogsScrollComposite.setMinSize(widthHint, size.y - 55);
+ newsScrollComposite.setMinSize(widthHint, size.y - 55);
computedSize = tutorialPageBook.computeSize(SWT.DEFAULT, SWT.DEFAULT);
int y = computedSize.y;
@@ -888,7 +1026,9 @@
y = 200;
}
tutorialScrollComposite.setMinSize(widthHint, y);
+ refreshNews();
refreshBlogs();
+
form.layout(true, true);
}
@@ -924,7 +1064,7 @@
@Override
public void scheduled(IJobChangeEvent event) {
RefreshBlogsJob.INSTANCE.setException(null);
- showLoading(blogsPageBook, blogsLoadingComposite, scrollComposite);
+ showLoading(blogsPageBook, blogsLoadingComposite, blogsScrollComposite);
}
@Override
@@ -976,4 +1116,46 @@
}
+ private class RefreshNewsJobChangeListener implements IJobChangeListener {
+
+ @Override
+ public void aboutToRun(IJobChangeEvent event) {
+
+ }
+
+ @Override
+ public void awake(IJobChangeEvent event) {
+
+ }
+
+ @Override
+ public void done(IJobChangeEvent event) {
+ Display.getDefault().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ refreshNews();
+ }
+ });
+
+ }
+
+ @Override
+ public void running(IJobChangeEvent event) {
+
+ }
+
+ @Override
+ public void scheduled(IJobChangeEvent event) {
+ RefreshNewsJob.INSTANCE.setException(null);
+ showLoading(newsPageBook, newsLoadingComposite, newsScrollComposite);
+ }
+
+ @Override
+ public void sleeping(IJobChangeEvent event) {
+
+ }
+
+ }
+
}
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshBlogsJob.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshBlogsJob.java 2011-10-16
21:09:55 UTC (rev 35691)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshBlogsJob.java 2011-10-16
21:10:06 UTC (rev 35692)
@@ -1,3 +1,13 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
package org.jboss.tools.central.jobs;
import java.net.MalformedURLException;
@@ -20,6 +30,11 @@
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;
+/**
+ *
+ * @author snjeza
+ *
+ */
public class RefreshBlogsJob extends Job {
private List<FeedsEntry> entries = new ArrayList<FeedsEntry>();
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshDiscoveryJob.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshDiscoveryJob.java 2011-10-16
21:09:55 UTC (rev 35691)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshDiscoveryJob.java 2011-10-16
21:10:06 UTC (rev 35692)
@@ -1,3 +1,13 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
package org.jboss.tools.central.jobs;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -8,6 +18,11 @@
import org.jboss.tools.central.JBossCentralActivator;
import org.jboss.tools.central.editors.JBossCentralEditor;
+/**
+ *
+ * @author snjeza
+ *
+ */
public class RefreshDiscoveryJob extends Job {
public static RefreshDiscoveryJob INSTANCE = new RefreshDiscoveryJob();
Added:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshNewsJob.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshNewsJob.java
(rev 0)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshNewsJob.java 2011-10-16
21:10:06 UTC (rev 35692)
@@ -0,0 +1,159 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.central.jobs;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.jboss.tools.central.JBossCentralActivator;
+import org.jboss.tools.central.model.FeedsEntry;
+
+import com.sun.syndication.feed.synd.SyndContent;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.io.SyndFeedInput;
+import com.sun.syndication.io.XmlReader;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public class RefreshNewsJob extends Job {
+
+ private List<FeedsEntry> entries = new ArrayList<FeedsEntry>();
+ private Exception exception;
+ public static RefreshNewsJob INSTANCE = new
RefreshNewsJob(JBossCentralActivator.NEWS_ATOM_URL);
+
+ private String newsurl;
+
+ private RefreshNewsJob(String newsurl) {
+ super("Refreshing JBoss Blogs...");
+ setPriority(LONG);
+ this.newsurl=newsurl;
+ }
+
+ @Override
+ public IStatus run(IProgressMonitor monitor) {
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ }
+ entries.clear();
+ SyndFeedInput input = new SyndFeedInput();
+ URL url;
+ try {
+ url = new URL(newsurl);
+ } catch (MalformedURLException e) {
+ exception = e;
+ return Status.CANCEL_STATUS;
+ }
+ try {
+ SyndFeed syndFeed = input.build(new XmlReader(url));
+ List<SyndEntry> feeds = syndFeed.getEntries();
+ if (feeds == null || feeds.size() == 0) {
+ return Status.OK_STATUS;
+ }
+ int i = 0;
+
+ for (SyndEntry feed:feeds) {
+ FeedsEntry entry = adaptEntry(feed);
+ if (entry == null) {
+ continue;
+ }
+ if (i++ > JBossCentralActivator.MAX_FEEDS) {
+ break;
+ }
+ entries.add(entry);
+ }
+ } catch (Exception e) {
+ exception = e;
+ return Status.CANCEL_STATUS;
+ }
+ return Status.OK_STATUS;
+ }
+
+
+ private FeedsEntry adaptEntry(SyndEntry entry) {
+ if (entry == null) {
+ return null;
+ }
+ String title = null;
+ if (entry.getTitle() != null) {
+ title = entry.getTitle();
+ } else {
+ SyndContent titleEx = entry.getTitleEx();
+ if (titleEx != null && !titleEx.getValue().isEmpty()) {
+ title = titleEx.getValue();
+ }
+ }
+ if (title == null) {
+ return null;
+ }
+ title = StringEscapeUtils.escapeHtml(title);
+ String link;
+ if (entry.getLink() != null) {
+ link = entry.getLink();
+ } else {
+ link = entry.getUri();
+ }
+ String description = null;
+ if (entry.getDescription() != null) {
+ SyndContent desc = entry.getDescription();
+ if (desc != null && !desc.getValue().isEmpty()) {
+ description = desc.getValue();
+ }
+ }
+ if (description == null) {
+ List<SyndContent> contents = entry.getContents();
+ if (contents != null && contents.size() > 0) {
+ SyndContent desc = contents.get(0);
+ if (desc != null && !desc.getValue().isEmpty()) {
+ description = desc.getValue();
+ }
+ }
+ }
+
+
+ Date date;
+ if (entry.getUpdatedDate() != null) {
+ date = entry.getUpdatedDate();
+ } else {
+ date = entry.getPublishedDate();
+ }
+ String author = entry.getAuthor();
+ if (author != null) {
+ author = StringEscapeUtils.escapeHtml(author);
+ }
+
+ //description = " " + description;
+ return new FeedsEntry(title, link, description, entry.getAuthor(), date);
+ }
+
+ public Exception getException() {
+ return exception;
+ }
+
+ public void setException(Exception exception) {
+ this.exception = exception;
+ }
+
+ public List<FeedsEntry> getEntries() {
+ return entries;
+ }
+}
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshTutorialsJob.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshTutorialsJob.java 2011-10-16
21:09:55 UTC (rev 35691)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshTutorialsJob.java 2011-10-16
21:10:06 UTC (rev 35692)
@@ -1,3 +1,13 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
package org.jboss.tools.central.jobs;
import java.util.ArrayList;
@@ -19,6 +29,11 @@
import org.jboss.tools.project.examples.model.ProjectFix;
import org.jboss.tools.project.examples.model.ProjectUtil;
+/**
+ *
+ * @author snjeza
+ *
+ */
public class RefreshTutorialsJob extends Job {
private Exception exception;
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/FeedsEntry.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/FeedsEntry.java 2011-10-16
21:09:55 UTC (rev 35691)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/FeedsEntry.java 2011-10-16
21:10:06 UTC (rev 35692)
@@ -1,3 +1,13 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
package org.jboss.tools.central.model;
import java.util.Date;
@@ -3,9 +13,13 @@
import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
import org.jboss.tools.central.JBossCentralActivator;
import com.ocpsoft.pretty.time.PrettyTime;
+/**
+ *
+ * @author snjeza
+ *
+ */
public class FeedsEntry {
private String title;
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/Tutorial.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/Tutorial.java 2011-10-16
21:09:55 UTC (rev 35691)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/Tutorial.java 2011-10-16
21:10:06 UTC (rev 35692)
@@ -1,3 +1,13 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
package org.jboss.tools.central.model;
import org.jboss.tools.project.examples.model.Project;
@@ -2,2 +12,7 @@
+/**
+ *
+ * @author snjeza
+ *
+ */
public class Tutorial implements Comparable<Tutorial> {
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/TutorialCategory.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/TutorialCategory.java 2011-10-16
21:09:55 UTC (rev 35691)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/TutorialCategory.java 2011-10-16
21:10:06 UTC (rev 35692)
@@ -1,3 +1,13 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
package org.jboss.tools.central.model;
import java.util.Set;
@@ -3,4 +13,9 @@
import java.util.TreeSet;
+/**
+ *
+ * @author snjeza
+ *
+ */
public class TutorialCategory implements Comparable<TutorialCategory> {