Author: snjeza
Date: 2011-10-15 17:25:01 -0400 (Sat, 15 Oct 2011)
New Revision: 35687
Added:
trunk/central/plugins/org.jboss.tools.central/icons/blogs.gif
trunk/central/plugins/org.jboss.tools.central/icons/feedsLink.gif
trunk/central/plugins/org.jboss.tools.central/icons/news.png
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossBlogsHandler.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/RefreshJBossBlogsHandler.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/FeedsToolTip.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/model/FeedsEntry.java
Removed:
trunk/central/plugins/org.jboss.tools.central/icons/news.gif
trunk/central/plugins/org.jboss.tools.central/icons/news.png
trunk/central/plugins/org.jboss.tools.central/icons/newsLink.gif
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/editors/NewsToolTip.java
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/model/NewsEntry.java
Modified:
trunk/central/plugins/org.jboss.tools.central/plugin.xml
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java
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/JBossCentralEditor.java
Log:
JBIDE-9653 Add RSS feed(s) in to JBoss Central
Copied: trunk/central/plugins/org.jboss.tools.central/icons/blogs.gif (from rev 35631,
trunk/central/plugins/org.jboss.tools.central/icons/news.gif)
===================================================================
(Binary files differ)
Copied: trunk/central/plugins/org.jboss.tools.central/icons/feedsLink.gif (from rev 35631,
trunk/central/plugins/org.jboss.tools.central/icons/newsLink.gif)
===================================================================
(Binary files differ)
Deleted: trunk/central/plugins/org.jboss.tools.central/icons/news.gif
===================================================================
(Binary files differ)
Deleted: trunk/central/plugins/org.jboss.tools.central/icons/news.png
===================================================================
(Binary files differ)
Added: trunk/central/plugins/org.jboss.tools.central/icons/news.png
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/icons/news.png
(rev 0)
+++ trunk/central/plugins/org.jboss.tools.central/icons/news.png 2011-10-15 21:25:01 UTC
(rev 35687)
@@ -0,0 +1,9 @@
+�PNG
+
+
+�c�m��K���mv.�&�$N&{ț���_�qO}���X0Hf�3���$����v�l���0�c/�w�����wNP��:�����C�B�ҧ
\ No newline at end of file
Deleted: trunk/central/plugins/org.jboss.tools.central/icons/newsLink.gif
===================================================================
(Binary files differ)
Modified: trunk/central/plugins/org.jboss.tools.central/plugin.xml
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/plugin.xml 2011-10-15 20:40:57 UTC (rev
35686)
+++ trunk/central/plugins/org.jboss.tools.central/plugin.xml 2011-10-15 21:25:01 UTC (rev
35687)
@@ -57,9 +57,9 @@
</command>
<command
- defaultHandler="org.jboss.tools.central.actions.OpenJBossNewsHandler"
- name="News"
- id="org.jboss.tools.central.openJBossNews">
+ defaultHandler="org.jboss.tools.central.actions.OpenJBossBlogsHandler"
+ name="Blogs"
+ id="org.jboss.tools.central.openJBossBlogs">
</command>
<command
@@ -68,9 +68,9 @@
id="org.jboss.tools.central.refreshJBossTutorials">
</command>
<command
-
defaultHandler="org.jboss.tools.central.actions.RefreshJBossNewsHandler"
+
defaultHandler="org.jboss.tools.central.actions.RefreshJBossBlogsHandler"
name="Refresh"
- id="org.jboss.tools.central.refreshJBossNews">
+ id="org.jboss.tools.central.refreshJBossBlogs">
</command>
<command
defaultHandler="org.jboss.tools.central.actions.RefreshDiscoveryHandler"
@@ -131,11 +131,11 @@
icon="icons/jbosstools_icon16.png">
</image>
<image
- commandId="org.jboss.tools.central.openJBossNews"
- icon="icons/news.gif">
+ commandId="org.jboss.tools.central.openJBossBlogs"
+ icon="icons/blogs.gif">
</image>
<image
- commandId="org.jboss.tools.central.refreshJBossNews"
+ commandId="org.jboss.tools.central.refreshJBossBlogs"
icon="icons/refresh.gif">
</image>
<image
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java 2011-10-15
20:40:57 UTC (rev 35686)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java 2011-10-15
21:25:01 UTC (rev 35687)
@@ -103,10 +103,14 @@
public static final String NEW_PROJECT_EXAMPLES_WIZARD_ID =
"org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard";
- public static final String NEWS_URL = "http://planet.jboss.org/feeds/blogs";
+ public static final String BLOG_URL = "http://planet.jboss.org/feeds/blogs";
- public static final String NEWS_ATOM_URL =
"http://planet.jboss.org/feeds/blogs";
+ public static final String BLOGS_ATOM_URL =
"http://planet.jboss.org/feeds/blogs";
+
+ public static final String NEWS_URL =
"http://pipes.yahoo.com/pipes/pipe.run?_id=660682be8ddf4b5db0cce318826f8a53";
+ public static final String NEWS_ATOM_URL =
"http://pipes.yahoo.com/pipes/pipe.run?_id=660682be8ddf4b5db0cce318826f8a53&_render=rss";
+
public static final String FORM_END_TAG = "</p></form>";
public static final String FORM_START_TAG = "<form><p>";
public static final String CANCELED = FORM_START_TAG + "<span
color=\"header\" font=\"header\">Canceled.</span>" +
FORM_END_TAG;
Copied:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossBlogsHandler.java
(from rev 35631,
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/OpenJBossBlogsHandler.java
(rev 0)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossBlogsHandler.java 2011-10-15
21:25:01 UTC (rev 35687)
@@ -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 OpenJBossBlogsHandler extends OpenWithBrowserHandler {
+
+ @Override
+ public String getLocation() {
+ return JBossCentralActivator.BLOG_URL;
+ }
+
+}
Deleted:
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 2011-10-15
20:40:57 UTC (rev 35686)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossNewsHandler.java 2011-10-15
21:25:01 UTC (rev 35687)
@@ -1,28 +0,0 @@
-/*************************************************************************************
- * 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;
- }
-
-}
Copied:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/RefreshJBossBlogsHandler.java
(from rev 35631,
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/RefreshJBossBlogsHandler.java
(rev 0)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/RefreshJBossBlogsHandler.java 2011-10-15
21:25:01 UTC (rev 35687)
@@ -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 RefreshJBossBlogsHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ if (RefreshBlogsJob.INSTANCE.getState() == Job.NONE) {
+ RefreshBlogsJob.INSTANCE.schedule();
+ }
+ return null;
+ }
+
+}
Deleted:
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 2011-10-15
20:40:57 UTC (rev 35686)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/RefreshJBossNewsHandler.java 2011-10-15
21:25:01 UTC (rev 35687)
@@ -1,35 +0,0 @@
-/*************************************************************************************
- * 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.RefreshNewsJob;
-
-/**
- *
- * @author snjeza
- *
- */
-public class RefreshJBossNewsHandler extends AbstractHandler {
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- if (RefreshNewsJob.INSTANCE.getState() == Job.NONE) {
- RefreshNewsJob.INSTANCE.schedule();
- }
- return null;
- }
-
-}
Copied:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/FeedsToolTip.java
(from rev 35658,
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/NewsToolTip.java)
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/FeedsToolTip.java
(rev 0)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/FeedsToolTip.java 2011-10-15
21:25:01 UTC (rev 35687)
@@ -0,0 +1,212 @@
+/*************************************************************************************
+ * 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.editors;
+
+import org.eclipse.jface.window.ToolTip;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.OpenWindowListener;
+import org.eclipse.swt.browser.WindowEvent;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.forms.widgets.FormText;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public class FeedsToolTip extends ToolTip {
+
+ private String toolText;
+ private static Shell CURRENT_TOOLTIP;
+ private Label hintLabel;
+ private FormText formText;
+ private int x;
+ private int y;
+ private boolean focused = false;
+
+// private Listener deactivateListener = new Listener() {
+//
+// @Override
+// public void handleEvent(Event event) {
+// if (focused) {
+// if (CURRENT_TOOLTIP != null) {
+// CURRENT_TOOLTIP.dispose();
+// CURRENT_TOOLTIP = null;
+// }
+// activate();
+// hide();
+// focused = false;
+// }
+// }
+// };
+
+ private MouseMoveListener mouseMoveListener = new MouseMoveListener() {
+ public void mouseMove(MouseEvent e) {
+ x = e.x;
+ y = e.y;
+ }
+ };
+ private Listener keyListener = new Listener() {
+
+ @Override
+ public void handleEvent(Event e) {
+ if (e == null)
+ return;
+ if (e.keyCode == SWT.ESC) {
+ if (CURRENT_TOOLTIP != null) {
+ CURRENT_TOOLTIP.dispose();
+ CURRENT_TOOLTIP = null;
+ }
+ activate();
+ focused = false;
+ }
+ if (e.keyCode == SWT.F2) {
+ if (CURRENT_TOOLTIP == null) {
+ deactivate();
+ hide();
+ }
+ focused = true;
+ createFocusedTooltip(FeedsToolTip.this.formText);
+ }
+ }
+ };
+
+ public FeedsToolTip(FormText formText, String toolText) {
+ super(formText);
+ this.toolText = "<html>" +
+ "<head>" +
+ "<title>JBoss</title>" +
+ "<style>" +
+ "html, body { font-size: 12px;font-family: Arial, Helvetica, sans-serif; }"
+
+ "h1, h2, h3, h4, h5, h6 { font-size: 14px;font-weight:bold;font-family: Arial,
Helvetica, sans-serif; }" +
+ "</style>" +
+ "</head>" +
+ "<body>" +
+ toolText +
+ "</body>" +
+ "</html>";
+ this.formText = formText;
+ setShift(new Point(0, 15));
+ setPopupDelay(400);
+ setHideOnMouseDown(true);
+ }
+
+ public void createFocusedTooltip(final Control control) {
+ final Shell stickyTooltip = new Shell(control.getShell(), SWT.ON_TOP | SWT.TOOL
+ | SWT.NO_FOCUS);
+ stickyTooltip.setLayout(new GridLayout());
+ //stickyTooltip.setBackground(stickyTooltip.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+
+ control.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ Event event = new Event();
+ event.x = x;
+ event.y = y;
+ event.widget = control;
+
+ createToolTipContentArea(event, stickyTooltip);
+ stickyTooltip.pack();
+
+ stickyTooltip.setLocation(stickyTooltip.getDisplay().getCursorLocation());
+ hintLabel.setText("Press 'ESC' to Hide.");
+ stickyTooltip.setVisible(true);
+ }
+ });
+ CURRENT_TOOLTIP = stickyTooltip;
+ }
+
+ @Override
+ protected Composite createToolTipContentArea(Event event, Composite parent) {
+ if (!focused) {
+ formText.setFocus();
+ }
+// if (formText.getShell() != null) {
+// formText.getShell().addListener(SWT.Deactivate, deactivateListener);
+// }
+ formText.addMouseMoveListener(mouseMoveListener);
+ formText.addListener(SWT.KeyDown, keyListener);
+
+ parent.addDisposeListener(new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ if (formText != null && !formText.isDisposed()) {
+ formText.removeMouseMoveListener(mouseMoveListener);
+ formText.removeListener(SWT.KeyDown, keyListener);
+// if (formText.getShell() != null && !formText.getShell().isDisposed()) {
+// formText.getShell().removeListener(SWT.Deactivate, deactivateListener);
+// }
+ }
+ }
+ });
+
+
+ parent.setLayout(new GridLayout());
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ parent.setLayoutData(gd);
+
+ Browser browser = new Browser(parent, SWT.NONE);
+ browser.setJavascriptEnabled(false);
+ browser.addOpenWindowListener(new OpenWindowListener() {
+ public void open(WindowEvent event) {
+ event.required= true;
+ }
+ });
+ gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.heightHint = 150;
+ gd.widthHint = 400;
+ browser.setLayoutData(gd);
+ browser.setText(toolText);
+
+ hintLabel = new Label(parent, SWT.NONE);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ hintLabel.setLayoutData(gd);
+ hintLabel.setAlignment(SWT.RIGHT);
+ hintLabel.setBackground(parent.getDisplay().getSystemColor(
+ SWT.COLOR_INFO_BACKGROUND));
+ hintLabel.setText("Press 'F2' for Focus.");
+ hintLabel.setForeground(parent.getDisplay().getSystemColor(
+ SWT.COLOR_DARK_GRAY));
+
+ final Font font;
+ Display display = parent.getDisplay();
+ FontData[] fd = parent.getFont().getFontData();
+ int size2 = fd.length;
+ for (int i = 0; i < size2; i++)
+ fd[i].setHeight(7);
+ font = new Font(display, fd);
+ parent.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ font.dispose();
+ }
+ });
+ hintLabel.setFont(font);
+ return parent;
+ }
+
+}
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-15
20:40:57 UTC (rev 35686)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java 2011-10-15
21:25:01 UTC (rev 35687)
@@ -45,7 +45,6 @@
import org.eclipse.jface.window.ToolTip;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ControlAdapter;
@@ -89,9 +88,9 @@
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.jboss.tools.central.JBossCentralActivator;
import org.jboss.tools.central.dialogs.ProjectExamplesDialog;
-import org.jboss.tools.central.jobs.RefreshNewsJob;
+import org.jboss.tools.central.jobs.RefreshBlogsJob;
import org.jboss.tools.central.jobs.RefreshTutorialsJob;
-import org.jboss.tools.central.model.NewsEntry;
+import org.jboss.tools.central.model.FeedsEntry;
import org.jboss.tools.central.model.Tutorial;
import org.jboss.tools.central.model.TutorialCategory;
import org.jboss.tools.project.examples.ProjectExamplesActivator;
@@ -112,22 +111,22 @@
protected static final long TIME_DELAY = 2000L;
private IWorkbenchAction newWizardDropDownAction;
private ScrolledForm form;
- private PageBook newsPageBook;
+ private PageBook blogsPageBook;
private ScrolledComposite scrollComposite;
- private RefreshNewsJobChangeListener refreshNewsJobChangeListener;
- private FormText newsNoteText;
+ private RefreshBlogsJobChangeListener refreshBlogsJobChangeListener;
+ private FormText blogsNoteText;
private FormText tutorialsNoteText;
- private Composite newsLoadingComposite;
+ private Composite blogsLoadingComposite;
private Composite tutorialsLoadingComposite;
- private FormText newsExceptionText;
+ private FormText blogsExceptionText;
private FormText tutorialsExceptionText;
- private Composite newsComposite;
+ private Composite blogsComposite;
private Composite tutorialsComposite;
private FormToolkit toolkit;
private ScrolledComposite tutorialScrollComposite;
private PageBook tutorialPageBook;
private RefreshTutorialsJobChangeListener refreshTutorialsJobChangeListener;
- private Section newsSection;
+ private Section blogsSection;
private Section tutorialsSection;
private Section documentationSection;
private Section projectsSection;
@@ -161,7 +160,7 @@
toolkit.paintBordersFor(left);
Composite right = createComposite(toolkit, body);
- createNewsSection(toolkit, right);
+ createBlogsSection(toolkit, right);
toolkit.paintBordersFor(right);
final ControlAdapter controlAdapter = new ControlAdapter() {
@@ -186,49 +185,43 @@
}
- private void createNewsSection(FormToolkit toolkit, Composite parent) {
- newsSection = createSection(toolkit, parent, "News",
ExpandableComposite.TITLE_BAR|ExpandableComposite.EXPANDED);
+ 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);
//gd.widthHint = 350;
//gd.heightHint = 100;
- newsSection.setLayoutData(gd);
- createNewsToolbar(toolkit, newsSection);
+ blogsSection.setLayoutData(gd);
+ createBlogsToolbar(toolkit, blogsSection);
- scrollComposite = new ScrolledComposite(newsSection, SWT.V_SCROLL);
+ scrollComposite = new ScrolledComposite(blogsSection, SWT.V_SCROLL);
gd =new GridData(SWT.FILL, SWT.FILL, true, false);
scrollComposite.setLayoutData(gd);
scrollComposite.setLayout(new GridLayout());
- newsPageBook = new PageBook(scrollComposite, SWT.WRAP);
+ blogsPageBook = new PageBook(scrollComposite, SWT.WRAP);
gd =new GridData(SWT.FILL, SWT.FILL, true, false);
- newsPageBook.setLayoutData(gd);
+ blogsPageBook.setLayoutData(gd);
- scrollComposite.setContent(newsPageBook);
+ scrollComposite.setContent(blogsPageBook);
scrollComposite.setExpandVertical(true);
scrollComposite.setExpandHorizontal(true);
scrollComposite.setAlwaysShowScrollBars(false);
-// scrollComposite.addControlListener(new ControlAdapter() {
-// public void controlResized(ControlEvent e) {
-// recomputeScrollComposite(scrollComposite, newsPageBook);
-// }
-// });
- newsNoteText = createNoteText(toolkit, newsPageBook);
- newsLoadingComposite = createLoadingComposite(toolkit, newsPageBook);
- newsExceptionText = createExceptionText(toolkit, newsPageBook);
+ blogsNoteText = createNoteText(toolkit, blogsPageBook);
+ blogsLoadingComposite = createLoadingComposite(toolkit, blogsPageBook);
+ blogsExceptionText = createExceptionText(toolkit, blogsPageBook);
- newsComposite = toolkit.createComposite(newsPageBook, SWT.NONE);
- newsComposite.setLayout(new TableWrapLayout());
- GridDataFactory.fillDefaults().grab(true, false).applyTo(newsComposite);
- //newsComposite.setLayoutData(gd);
+ blogsComposite = toolkit.createComposite(blogsPageBook, SWT.NONE);
+ blogsComposite.setLayout(new TableWrapLayout());
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(blogsComposite);
- newsSection.setClient(scrollComposite);
- showLoading(newsPageBook, newsLoadingComposite, scrollComposite);
- newsPageBook.pack(true);
- RefreshNewsJob refreshNewsJob = RefreshNewsJob.INSTANCE;
- refreshNewsJobChangeListener = new RefreshNewsJobChangeListener();
- refreshNewsJob.addJobChangeListener(refreshNewsJobChangeListener);
- refreshNewsJob.schedule();
+ blogsSection.setClient(scrollComposite);
+ showLoading(blogsPageBook, blogsLoadingComposite, scrollComposite);
+ blogsPageBook.pack(true);
+ RefreshBlogsJob refreshBlogsJob = RefreshBlogsJob.INSTANCE;
+ refreshBlogsJobChangeListener = new RefreshBlogsJobChangeListener();
+ refreshBlogsJob.addJobChangeListener(refreshBlogsJobChangeListener);
+ refreshBlogsJob.schedule();
}
private FormText createExceptionText(FormToolkit toolkit, Composite parent) {
@@ -268,7 +261,7 @@
return formText;
}
- private void createNewsToolbar(FormToolkit toolkit, Section section) {
+ private void createBlogsToolbar(FormToolkit toolkit, Section section) {
Composite headerComposite = toolkit.createComposite(section, SWT.NONE);
RowLayout rowLayout = new RowLayout();
rowLayout.marginTop = 0;
@@ -279,10 +272,10 @@
ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
toolBarManager.createControl(headerComposite);
- CommandContributionItem item = JBossCentralActivator.createContributionItem(getSite(),
"org.jboss.tools.central.openJBossNews");
+ CommandContributionItem item = JBossCentralActivator.createContributionItem(getSite(),
"org.jboss.tools.central.openJBossBlogs");
toolBarManager.add(item);
- item = JBossCentralActivator.createContributionItem(getSite(),
"org.jboss.tools.central.refreshJBossNews");
+ item = JBossCentralActivator.createContributionItem(getSite(),
"org.jboss.tools.central.refreshJBossBlogs");
toolBarManager.add(item);
toolBarManager.update(true);
@@ -571,9 +564,9 @@
public void dispose() {
newWizardDropDownAction.dispose();
newWizardDropDownAction = null;
- if (refreshNewsJobChangeListener != null) {
- RefreshNewsJob.INSTANCE.removeJobChangeListener(refreshNewsJobChangeListener);
- refreshNewsJobChangeListener = null;
+ if (refreshBlogsJobChangeListener != null) {
+ RefreshBlogsJob.INSTANCE.removeJobChangeListener(refreshBlogsJobChangeListener);
+ refreshBlogsJobChangeListener = null;
}
if (refreshTutorialsJobChangeListener != null) {
RefreshTutorialsJob.INSTANCE.removeJobChangeListener(refreshTutorialsJobChangeListener);
@@ -601,8 +594,8 @@
return true;
}
- private Image getNewsImage() {
- return JBossCentralActivator.getDefault().getImage("/icons/newsLink.gif");
+ private Image getFeedsImage() {
+ return JBossCentralActivator.getDefault().getImage("/icons/feedsLink.gif");
}
private void recomputeScrollComposite(ScrolledComposite composite, PageBook pageBook) {
@@ -640,20 +633,20 @@
pageBook.showPage(exceptionText);
}
- public void refreshNews() {
- RefreshNewsJob job = RefreshNewsJob.INSTANCE;
+ public void refreshBlogs() {
+ RefreshBlogsJob job = RefreshBlogsJob.INSTANCE;
if (job.getState() == Job.NONE) {
if (job.getException() != null) {
- showException(newsPageBook, newsExceptionText,
+ showException(blogsPageBook, blogsExceptionText,
job.getException());
return;
}
- List<NewsEntry> entries = job.getEntries();
+ List<FeedsEntry> entries = job.getEntries();
if (entries == null || entries.size() == 0) {
- showNote(newsPageBook, newsNoteText, scrollComposite);
+ showNote(blogsPageBook, blogsNoteText, scrollComposite);
return;
}
- showNews(entries);
+ showBlogs(entries);
}
}
@@ -793,19 +786,19 @@
}
}
- private void showNews(List<NewsEntry> entries) {
+ private void showBlogs(List<FeedsEntry> entries) {
int i = 0;
- disposeChildren(newsComposite);
+ disposeChildren(blogsComposite);
- for (final NewsEntry entry:entries) {
+ for (final FeedsEntry entry:entries) {
if (i++ > JBossCentralActivator.MAX_FEEDS) {
return;
}
String text = entry.getFormString();
- final FormText formText = toolkit.createFormText(newsComposite, true);
+ final FormText formText = toolkit.createFormText(blogsComposite, true);
TableWrapData td = new TableWrapData();
td.indent = 2;
- Point size = newsComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ Point size = blogsComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
td.maxWidth = size.x - 2;
try {
// to avoid illegal argumentexception on formtext fields.
@@ -827,9 +820,9 @@
//Font boldFont = getAuthorFont(display);
//formText.setFont("author", boldFont);
formText.setColor("author", JFaceColors.getHyperlinkText(getDisplay()));
- formText.setImage("image", getNewsImage());
+ formText.setImage("image", getFeedsImage());
if (entry.getDescription() != null && !entry.getDescription().isEmpty()) {
- ToolTip toolTip = new NewsToolTip(formText, entry.getDate() + " " +
entry.getDescription());
+ ToolTip toolTip = new FeedsToolTip(formText, entry.getDate() + " " +
entry.getDescription());
toolTip.activate();
}
formText.addHyperlinkListener(new HyperlinkAdapter() {
@@ -845,10 +838,10 @@
});
}
- newsPageBook.showPage(newsComposite);
+ blogsPageBook.showPage(blogsComposite);
form.reflow(true);
form.redraw();
- recomputeScrollComposite(scrollComposite, newsPageBook);
+ recomputeScrollComposite(scrollComposite, blogsPageBook);
}
protected void resize() {
@@ -856,12 +849,12 @@
GridData gd;
int widthHint = size.x/2 - 40;
- gd = (GridData) newsSection.getLayoutData();
+ gd = (GridData) blogsSection.getLayoutData();
gd.heightHint = size.y - 40;
gd.widthHint = widthHint;
gd.grabExcessVerticalSpace = false;
- Point computedSize = newsSection.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- newsSection.setSize(widthHint, computedSize.y);
+ Point computedSize = blogsSection.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ blogsSection.setSize(widthHint, computedSize.y);
gd = (GridData) tutorialsSection.getLayoutData();
//gridData.heightHint = size.y - 40;
@@ -895,11 +888,11 @@
y = 200;
}
tutorialScrollComposite.setMinSize(widthHint, y);
- refreshNews();
+ refreshBlogs();
form.layout(true, true);
}
- private class RefreshNewsJobChangeListener implements IJobChangeListener {
+ private class RefreshBlogsJobChangeListener implements IJobChangeListener {
@Override
public void aboutToRun(IJobChangeEvent event) {
@@ -917,7 +910,7 @@
@Override
public void run() {
- refreshNews();
+ refreshBlogs();
}
});
@@ -930,8 +923,8 @@
@Override
public void scheduled(IJobChangeEvent event) {
- RefreshNewsJob.INSTANCE.setException(null);
- showLoading(newsPageBook, newsLoadingComposite, scrollComposite);
+ RefreshBlogsJob.INSTANCE.setException(null);
+ showLoading(blogsPageBook, blogsLoadingComposite, scrollComposite);
}
@Override
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditor.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditor.java 2011-10-15
20:40:57 UTC (rev 35686)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditor.java 2011-10-15
21:25:01 UTC (rev 35687)
@@ -39,9 +39,9 @@
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.menus.CommandContributionItem;
import org.jboss.tools.central.JBossCentralActivator;
-import org.jboss.tools.central.actions.OpenJBossNewsHandler;
+import org.jboss.tools.central.actions.OpenJBossBlogsHandler;
import org.jboss.tools.central.editors.xpl.TextSearchControl;
-import org.jboss.tools.central.jobs.RefreshNewsJob;
+import org.jboss.tools.central.jobs.RefreshBlogsJob;
/**
*
@@ -83,7 +83,7 @@
softwareImage.dispose();
softwareImage = null;
}
- RefreshNewsJob.INSTANCE.cancel();
+ RefreshBlogsJob.INSTANCE.cancel();
super.dispose();
}
@@ -217,7 +217,7 @@
url.append(URLEncoder.encode(searchControl.getText(), UTF_8_ENCODING));
}
final String location = url.toString();
- AbstractHandler handler = new OpenJBossNewsHandler() {
+ AbstractHandler handler = new OpenJBossBlogsHandler() {
@Override
public String getLocation() {
Deleted:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/NewsToolTip.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/NewsToolTip.java 2011-10-15
20:40:57 UTC (rev 35686)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/NewsToolTip.java 2011-10-15
21:25:01 UTC (rev 35687)
@@ -1,212 +0,0 @@
-/*************************************************************************************
- * 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.editors;
-
-import org.eclipse.jface.window.ToolTip;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.browser.Browser;
-import org.eclipse.swt.browser.OpenWindowListener;
-import org.eclipse.swt.browser.WindowEvent;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.forms.widgets.FormText;
-
-/**
- *
- * @author snjeza
- *
- */
-public class NewsToolTip extends ToolTip {
-
- private String toolText;
- private static Shell CURRENT_TOOLTIP;
- private Label hintLabel;
- private FormText formText;
- private int x;
- private int y;
- private boolean focused = false;
-
-// private Listener deactivateListener = new Listener() {
-//
-// @Override
-// public void handleEvent(Event event) {
-// if (focused) {
-// if (CURRENT_TOOLTIP != null) {
-// CURRENT_TOOLTIP.dispose();
-// CURRENT_TOOLTIP = null;
-// }
-// activate();
-// hide();
-// focused = false;
-// }
-// }
-// };
-
- private MouseMoveListener mouseMoveListener = new MouseMoveListener() {
- public void mouseMove(MouseEvent e) {
- x = e.x;
- y = e.y;
- }
- };
- private Listener keyListener = new Listener() {
-
- @Override
- public void handleEvent(Event e) {
- if (e == null)
- return;
- if (e.keyCode == SWT.ESC) {
- if (CURRENT_TOOLTIP != null) {
- CURRENT_TOOLTIP.dispose();
- CURRENT_TOOLTIP = null;
- }
- activate();
- focused = false;
- }
- if (e.keyCode == SWT.F2) {
- if (CURRENT_TOOLTIP == null) {
- deactivate();
- hide();
- }
- focused = true;
- createFocusedTooltip(NewsToolTip.this.formText);
- }
- }
- };
-
- public NewsToolTip(FormText formText, String toolText) {
- super(formText);
- this.toolText = "<html>" +
- "<head>" +
- "<title>JBoss</title>" +
- "<style>" +
- "html, body { font-size: 12px;font-family: Arial, Helvetica, sans-serif; }"
+
- "h1, h2, h3, h4, h5, h6 { font-size: 14px;font-weight:bold;font-family: Arial,
Helvetica, sans-serif; }" +
- "</style>" +
- "</head>" +
- "<body>" +
- toolText +
- "</body>" +
- "</html>";
- this.formText = formText;
- setShift(new Point(0, 15));
- setPopupDelay(400);
- setHideOnMouseDown(true);
- }
-
- public void createFocusedTooltip(final Control control) {
- final Shell stickyTooltip = new Shell(control.getShell(), SWT.ON_TOP | SWT.TOOL
- | SWT.NO_FOCUS);
- stickyTooltip.setLayout(new GridLayout());
- //stickyTooltip.setBackground(stickyTooltip.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
-
- control.getDisplay().asyncExec(new Runnable() {
- public void run() {
- Event event = new Event();
- event.x = x;
- event.y = y;
- event.widget = control;
-
- createToolTipContentArea(event, stickyTooltip);
- stickyTooltip.pack();
-
- stickyTooltip.setLocation(stickyTooltip.getDisplay().getCursorLocation());
- hintLabel.setText("Press 'ESC' to Hide.");
- stickyTooltip.setVisible(true);
- }
- });
- CURRENT_TOOLTIP = stickyTooltip;
- }
-
- @Override
- protected Composite createToolTipContentArea(Event event, Composite parent) {
- if (!focused) {
- formText.setFocus();
- }
-// if (formText.getShell() != null) {
-// formText.getShell().addListener(SWT.Deactivate, deactivateListener);
-// }
- formText.addMouseMoveListener(mouseMoveListener);
- formText.addListener(SWT.KeyDown, keyListener);
-
- parent.addDisposeListener(new DisposeListener() {
-
- @Override
- public void widgetDisposed(DisposeEvent e) {
- if (formText != null && !formText.isDisposed()) {
- formText.removeMouseMoveListener(mouseMoveListener);
- formText.removeListener(SWT.KeyDown, keyListener);
-// if (formText.getShell() != null && !formText.getShell().isDisposed()) {
-// formText.getShell().removeListener(SWT.Deactivate, deactivateListener);
-// }
- }
- }
- });
-
-
- parent.setLayout(new GridLayout());
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- parent.setLayoutData(gd);
-
- Browser browser = new Browser(parent, SWT.NONE);
- browser.setJavascriptEnabled(false);
- browser.addOpenWindowListener(new OpenWindowListener() {
- public void open(WindowEvent event) {
- event.required= true;
- }
- });
- gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- gd.heightHint = 150;
- gd.widthHint = 400;
- browser.setLayoutData(gd);
- browser.setText(toolText);
-
- hintLabel = new Label(parent, SWT.NONE);
- gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- hintLabel.setLayoutData(gd);
- hintLabel.setAlignment(SWT.RIGHT);
- hintLabel.setBackground(parent.getDisplay().getSystemColor(
- SWT.COLOR_INFO_BACKGROUND));
- hintLabel.setText("Press 'F2' for Focus.");
- hintLabel.setForeground(parent.getDisplay().getSystemColor(
- SWT.COLOR_DARK_GRAY));
-
- final Font font;
- Display display = parent.getDisplay();
- FontData[] fd = parent.getFont().getFontData();
- int size2 = fd.length;
- for (int i = 0; i < size2; i++)
- fd[i].setHeight(7);
- font = new Font(display, fd);
- parent.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- font.dispose();
- }
- });
- hintLabel.setFont(font);
- return parent;
- }
-
-}
Copied:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshBlogsJob.java
(from rev 35631,
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/RefreshBlogsJob.java
(rev 0)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshBlogsJob.java 2011-10-15
21:25:01 UTC (rev 35687)
@@ -0,0 +1,144 @@
+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;
+
+public class RefreshBlogsJob extends Job {
+
+ private List<FeedsEntry> entries = new ArrayList<FeedsEntry>();
+ private Exception exception;
+ public static RefreshBlogsJob INSTANCE = new
RefreshBlogsJob(JBossCentralActivator.BLOGS_ATOM_URL);
+
+ private String blogsurl;
+
+ private RefreshBlogsJob(String blogsurl) {
+ super("Refreshing JBoss Blogs...");
+ setPriority(LONG);
+ this.blogsurl=blogsurl;
+ }
+
+ @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(blogsurl);
+ } 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;
+ }
+}
Deleted:
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 2011-10-15
20:40:57 UTC (rev 35686)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshNewsJob.java 2011-10-15
21:25:01 UTC (rev 35687)
@@ -1,144 +0,0 @@
-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.NewsEntry;
-
-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;
-
-public class RefreshNewsJob extends Job {
-
- private List<NewsEntry> entries = new ArrayList<NewsEntry>();
- private Exception exception;
- public static RefreshNewsJob INSTANCE = new
RefreshNewsJob(JBossCentralActivator.NEWS_ATOM_URL);
-
- private String newsurl;
-
- private RefreshNewsJob(String newsurl) {
- super("Refreshing JBoss News...");
- 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) {
- NewsEntry 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 NewsEntry 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 NewsEntry(title, link, description, entry.getAuthor(), date);
- }
-
- public Exception getException() {
- return exception;
- }
-
- public void setException(Exception exception) {
- this.exception = exception;
- }
-
- public List<NewsEntry> getEntries() {
- return entries;
- }
-}
Copied:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/FeedsEntry.java
(from rev 35676,
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/NewsEntry.java)
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/FeedsEntry.java
(rev 0)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/FeedsEntry.java 2011-10-15
21:25:01 UTC (rev 35687)
@@ -0,0 +1,173 @@
+package org.jboss.tools.central.model;
+
+import java.util.Date;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+import org.jboss.tools.central.JBossCentralActivator;
+
+import com.ocpsoft.pretty.time.PrettyTime;
+
+public class FeedsEntry {
+ private String title;
+ private String link;
+ private String description;
+ private String author;
+ private Date date;
+
+ public FeedsEntry() {
+ }
+
+ public FeedsEntry(String title, String link, String description,
+ String author, Date date) {
+ this.title = title;
+ this.link = link;
+ this.description = description;
+ this.author = author;
+ this.date = date;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getLink() {
+ return link;
+ }
+
+ public void setLink(String link) {
+ this.link = link;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ public String getFormString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(JBossCentralActivator.FORM_START_TAG);
+ buffer.append("<img href=\"image\"/> ");
+ if (link != null && !link.isEmpty()) {
+ buffer.append("<a href=\"");
+ buffer.append(link);
+ buffer.append("\">");
+ buffer.append(StringEscapeUtils.unescapeXml(title));
+ buffer.append("</a>");
+ } else {
+ buffer.append(title);
+ }
+ //buffer.append("<br/>");
+ boolean cr = false;
+ if (date != null) {
+ /*buffer.append("<span font=\"default\">");
+ buffer.append("posted ");
+ buffer.append("</span>");*/
+ buffer.append("<b>");
+ PrettyTime prettyTime = new PrettyTime(new Date());
+ buffer.append(" " + prettyTime.format(date));
+ buffer.append("</b>");
+ cr = true;
+ }
+ if (author != null && !author.isEmpty() && !"(author
unknown)".equalsIgnoreCase(author)) {
+ buffer.append(" ");
+ buffer.append("<span font=\"default\">");
+ buffer.append(" by");
+ buffer.append("</span>");
+ buffer.append(" ");
+ buffer.append("<span color=\"author\"
font=\"author\">");
+ buffer.append(author);
+ buffer.append("</span>");
+ cr = true;
+ }
+
+ if (cr) {
+ buffer.append("<br/>");
+ }
+ String shortDescription = getShortDescription();
+ cr = false;
+ if (shortDescription != null && !shortDescription.isEmpty()) {
+ buffer.append("<span font=\"description\">");
+ buffer.append(shortDescription);
+ buffer.append("</span>");
+ cr = true;
+ }
+ if (cr) {
+ buffer.append("<br/><br/>");
+ }
+ buffer.append(JBossCentralActivator.FORM_END_TAG);
+ return buffer.toString();
+ }
+
+ public String getShortDescription() {
+ if (description == null) {
+ return null;
+ }
+ boolean tagStarted = false;
+ StringBuffer buffer = new StringBuffer();
+ for (char c:description.toCharArray()) {
+ if (c == '<') {
+ tagStarted = true;
+ }
+ if (c == '>') {
+ tagStarted = false;
+ } else {
+ if (!tagStarted) {
+ buffer.append(c);
+ }
+ }
+ }
+ char[] chars = StringEscapeUtils.unescapeHtml(buffer.toString().trim()).toCharArray();
+ buffer = new StringBuffer();
+ int i = 0;
+ for (char c:chars) {
+ if (i++ < 140) {
+ buffer.append(c);
+ } else {
+ if ( (c == '_') ||
+ (c >= 'a' && c <= 'z') ||
+ (c >= 'a' && c <= 'Z') ||
+ (c >= '0' && c <= '9') ) {
+ buffer.append(c);
+ } else {
+ break;
+ }
+ }
+ }
+ if (buffer.length() > 0) {
+ buffer.append("...");
+ }
+ return buffer.toString();
+ }
+
+ @Override
+ public String toString() {
+ return "FeedsEntry [title=" + title + ", link=" + link
+ + ", description=" + description + ", author=" + author
+ + ", date=" + date + "]";
+ }
+
+}
Deleted:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/NewsEntry.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/NewsEntry.java 2011-10-15
20:40:57 UTC (rev 35686)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/NewsEntry.java 2011-10-15
21:25:01 UTC (rev 35687)
@@ -1,173 +0,0 @@
-package org.jboss.tools.central.model;
-
-import java.util.Date;
-
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
-import org.jboss.tools.central.JBossCentralActivator;
-
-import com.ocpsoft.pretty.time.PrettyTime;
-
-public class NewsEntry {
- private String title;
- private String link;
- private String description;
- private String author;
- private Date date;
-
- public NewsEntry() {
- }
-
- public NewsEntry(String title, String link, String description,
- String author, Date date) {
- this.title = title;
- this.link = link;
- this.description = description;
- this.author = author;
- this.date = date;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getLink() {
- return link;
- }
-
- public void setLink(String link) {
- this.link = link;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getAuthor() {
- return author;
- }
-
- public void setAuthor(String author) {
- this.author = author;
- }
-
- public Date getDate() {
- return date;
- }
-
- public void setDate(Date date) {
- this.date = date;
- }
-
- public String getFormString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append(JBossCentralActivator.FORM_START_TAG);
- buffer.append("<img href=\"image\"/> ");
- if (link != null && !link.isEmpty()) {
- buffer.append("<a href=\"");
- buffer.append(link);
- buffer.append("\">");
- buffer.append(StringEscapeUtils.unescapeXml(title));
- buffer.append("</a>");
- } else {
- buffer.append(title);
- }
- //buffer.append("<br/>");
- boolean cr = false;
- if (date != null) {
- /*buffer.append("<span font=\"default\">");
- buffer.append("posted ");
- buffer.append("</span>");*/
- buffer.append("<b>");
- PrettyTime prettyTime = new PrettyTime(new Date());
- buffer.append(" " + prettyTime.format(date));
- buffer.append("</b>");
- cr = true;
- }
- if (author != null && !author.isEmpty() && !"(author
unknown)".equalsIgnoreCase(author)) {
- buffer.append(" ");
- buffer.append("<span font=\"default\">");
- buffer.append(" by");
- buffer.append("</span>");
- buffer.append(" ");
- buffer.append("<span color=\"author\"
font=\"author\">");
- buffer.append(author);
- buffer.append("</span>");
- cr = true;
- }
-
- if (cr) {
- buffer.append("<br/>");
- }
- String shortDescription = getShortDescription();
- cr = false;
- if (shortDescription != null && !shortDescription.isEmpty()) {
- buffer.append("<span font=\"description\">");
- buffer.append(shortDescription);
- buffer.append("</span>");
- cr = true;
- }
- if (cr) {
- buffer.append("<br/><br/>");
- }
- buffer.append(JBossCentralActivator.FORM_END_TAG);
- return buffer.toString();
- }
-
- public String getShortDescription() {
- if (description == null) {
- return null;
- }
- boolean tagStarted = false;
- StringBuffer buffer = new StringBuffer();
- for (char c:description.toCharArray()) {
- if (c == '<') {
- tagStarted = true;
- }
- if (c == '>') {
- tagStarted = false;
- } else {
- if (!tagStarted) {
- buffer.append(c);
- }
- }
- }
- char[] chars = StringEscapeUtils.unescapeHtml(buffer.toString().trim()).toCharArray();
- buffer = new StringBuffer();
- int i = 0;
- for (char c:chars) {
- if (i++ < 140) {
- buffer.append(c);
- } else {
- if ( (c == '_') ||
- (c >= 'a' && c <= 'z') ||
- (c >= 'a' && c <= 'Z') ||
- (c >= '0' && c <= '9') ) {
- buffer.append(c);
- } else {
- break;
- }
- }
- }
- if (buffer.length() > 0) {
- buffer.append("...");
- }
- return buffer.toString();
- }
-
- @Override
- public String toString() {
- return "NewsEntry [title=" + title + ", link=" + link
- + ", description=" + description + ", author=" + author
- + ", date=" + date + "]";
- }
-
-}