Skip to content
Browse files

1. Implement Help View (displaying the help text).

2. Add org.apache.commons.io dependency to product files
3. Replace cassandra's FileUtils class on apache classes.
  • Loading branch information...
1 parent 049f221 commit 6132596096b3dd9684e99ae089b590b73749ad6e @semanticsoft committed Jan 6, 2013
View
1 org.semanticsoft.vaaclipse.demo.contacts/org.semanticsoft.vaaclipse.demo.contacts.product
@@ -34,6 +34,7 @@
<plugin id="org.apache.batik.css"/>
<plugin id="org.apache.batik.util"/>
<plugin id="org.apache.batik.util.gui"/>
+ <plugin id="org.apache.commons.io"/>
<plugin id="org.apache.commons.logging"/>
<plugin id="org.eclipse.core.commands"/>
<plugin id="org.eclipse.core.contenttype"/>
View
4 org.semanticsoft.vaaclipsedemo.cassandra.app/Application.e4xmi
@@ -75,7 +75,7 @@
<sharedElements xsi:type="basic:Part" xmi:id="_R6SHoOsOEeGrI5NvCZeHUA" elementId="org.semanticsoft.vaaclipsedemo.cassandra.app.part.variables" label="Variables" iconURI="platform:/plugin/org.semanticsoft.vaaclipsedemo.cassandra.app/img/variables.png" tooltip="Variables" closeable="true"/>
<sharedElements xsi:type="basic:Part" xmi:id="_VNAcoOsOEeGrI5NvCZeHUA" elementId="org.semanticsoft.vaaclipsedemo.cassandra.app.part.breakpoints" label="Breakpoints" iconURI="platform:/plugin/org.semanticsoft.vaaclipsedemo.cassandra.app/img/breakpoints.png" tooltip="Breakpoints" closeable="true"/>
<sharedElements xsi:type="basic:Part" xmi:id="_ZQfgMOsOEeGrI5NvCZeHUA" elementId="org.semanticsoft.vaaclipsedemo.cassandra.app.part.display" label="Display" iconURI="platform:/plugin/org.semanticsoft.vaaclipsedemo.cassandra.app/img/display.png" tooltip="Display" closeable="true"/>
- <sharedElements xsi:type="basic:Part" xmi:id="_MjCfsOsaEeGrI5NvCZeHUA" elementId="org.semanticsoft.vaaclipsedemo.cassandra.app.part.help" label="Help" iconURI="platform:/plugin/org.semanticsoft.vaaclipsedemo.cassandra.app/img/help.png" tooltip="Help" closeable="true"/>
+ <sharedElements xsi:type="basic:Part" xmi:id="_MjCfsOsaEeGrI5NvCZeHUA" elementId="org.semanticsoft.vaaclipsedemo.cassandra.app.part.help" contributionURI="bundleclass://org.semanticsoft.vaaclipsedemo.cassandra.app/org.semanticsoft.vaaclipsedemo.cassandra.app.views.Help" label="Help" iconURI="platform:/plugin/org.semanticsoft.vaaclipsedemo.cassandra.app/img/help.png" tooltip="Help" closeable="true"/>
<sharedElements xsi:type="basic:Part" xmi:id="_QyaqMOsaEeGrI5NvCZeHUA" elementId="org.semanticsoft.vaaclipsedemo.cassandra.app.part.javadoc" label="Javadoc" iconURI="platform:/plugin/org.semanticsoft.vaaclipsedemo.cassandra.app/img/javadoc.png" tooltip="Javadoc" closeable="true"/>
<sharedElements xsi:type="basic:Part" xmi:id="_YVR-sOsaEeGrI5NvCZeHUA" elementId="org.semanticsoft.vaaclipsedemo.cassandra.app.part.junit" label="JUnit" iconURI="platform:/plugin/org.semanticsoft.vaaclipsedemo.cassandra.app/img/junit.png" tooltip="JUnit" closeable="true"/>
<trimBars xmi:id="_SeXUAu8EEd6FC9cDb6iV7g" elementId="org.semanticsoft.vaaclipsedemo.cassandra.toptrimbar">
@@ -141,7 +141,7 @@
<tags>View</tags>
<tags>categoryTag:Debug</tags>
</descriptors>
- <descriptors xmi:id="_5RF1MFdGEeKUIKT1CIcS7g" elementId="org.semanticsoft.vaaclipsedemo.cassandra.app.part.help" label="Help" iconURI="platform:/plugin/org.semanticsoft.vaaclipsedemo.cassandra.app/img/help.png" tooltip="Help">
+ <descriptors xmi:id="_5RF1MFdGEeKUIKT1CIcS7g" elementId="org.semanticsoft.vaaclipsedemo.cassandra.app.part.help" label="Help" iconURI="platform:/plugin/org.semanticsoft.vaaclipsedemo.cassandra.app/img/help.png" tooltip="Help" contributionURI="bundleclass://org.semanticsoft.vaaclipsedemo.cassandra.app/org.semanticsoft.vaaclipsedemo.cassandra.app.views.Help">
<tags>View</tags>
<tags>categoryTag:Help</tags>
</descriptors>
View
3 org.semanticsoft.vaaclipsedemo.cassandra.app/META-INF/MANIFEST.MF
@@ -27,7 +27,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.e4.ui.di;bundle-version="0.10.1",
org.semanticsoft.vaaclipse.theme;bundle-version="1.0.0",
org.semanticsoft.vaaclipse.publicapi;bundle-version="1.0.0",
- org.semanticsoft.vaaclipse.additions;bundle-version="1.0.0"
+ org.semanticsoft.vaaclipse.additions;bundle-version="1.0.0",
+ org.apache.commons.io;bundle-version="2.4.0"
Import-Package: javax.annotation;version="1.0.0"
Bundle-ActivationPolicy: lazy
Bundle-Vendor: Rushan R. Gilmullin
View
1 org.semanticsoft.vaaclipsedemo.cassandra.app/cassandra.product
@@ -34,6 +34,7 @@
<plugin id="javax.inject"/>
<plugin id="javax.servlet"/>
<plugin id="javax.xml"/>
+ <plugin id="org.apache.commons.io"/>
<plugin id="org.eclipse.core.commands"/>
<plugin id="org.eclipse.core.contenttype"/>
<plugin id="org.eclipse.core.databinding"/>
View
40 org.semanticsoft.vaaclipsedemo.cassandra.app/data/Help.html
@@ -0,0 +1,40 @@
+<p><strong>Cassandra</strong> is the IDE-like demo environment allowing you to browse and learn its own code and demonstrating some <em>Vaaclipse</em> features. You can obtain <strong>Cassandra</strong> sources from <a href="https://github.com/semanticsoft/vaaclipse">Vaaclipse repository</a>.</p>
+
+<h3>Bundles</h3>
+
+<ul>
+<li>
+<em>org.semanticsoft.vaaclipsedemo.cassandra.app</em> - application bundle providing product, demo implementation, resources and compiled widgetset.</li>
+<li>
+<em>org.semanticsoft.vaaclipsedemo.cassandra.vaadinaddons</em> - provides the vaadin addon binaires used in this demo.</li>
+</ul><h3>Product configuration</h3>
+
+<p>Open file <em>plugin.xml</em>. The extension point <em>org.eclipse.core.runtime.products</em> contains the product configuration. Read about product configuration in <a href="https://github.com/semanticsoft/vaaclipse/wiki/Project-configuration">Project configuration guid</a>.</p>
+
+<ul>
+<li>
+<em>applicationXMI</em> - this file contains the application model. You can browse it using reach UI in <em>Eclipse Model Editor</em>.</li>
+<li>
+<em>applicationWidgetset</em> - the location of application widgetset. As you can see this application uses widgetset is located in <em>widgetset/cassandra.widgetset.CassandraWidgetset</em>.</li>
+<li>
+<em>cssTheme</em> - the identifier of theme used by application. <strong>Cassandra</strong> uses the <em>reindeer</em> theme.</li>
+<li>
+<em>applicationHeaderIcon</em> - you can see this icon in the browser window title.</li>
+</ul><h3>Theme configuration</h3>
+
+<p>Open file <em>plugin.xml</em>. The extension point <em>org.semanticsoft.vaaclipse.theme</em> contains the theme configuration. This extension point introduces the theme contribution <em>org.semanticsoft.vaaclipsedemo.cassandra.app.maincontrib</em> that extends the <em>reindeer</em> theme with stylesheet <em>"css/default.css"</em> and resources in <em>"img/"</em>. The another contribution <em>org.semanticsoft.vaaclipse.resources</em> contains stylesheet used by Vaaclipse. Read about themes and theme contributions in <a href="https://github.com/semanticsoft/vaaclipse/wiki/Resource-system">Resource system guide</a>. Shortly, theme contribution extends the given themes with resources and styles. Theme contributions help us to build modular applications. Contributions are counterparts to theme inheritance (that has more limited use). For example, we can create the new theme with our resources and styles and inherit it from <em>reindeer</em> theme or use the <em>reindeer</em> theme itself extending with our resources and styles. The second way is more preferable (see <em>Contribution vs inheritance</em> section of <a href="https://github.com/semanticsoft/vaaclipse/wiki/Resource-system">Resource system guide</a>).</p>
+
+<h3>Java code</h3>
+
+<p>Package <em>org.semanticsoft.vaaclipsedemo.cassandra.app</em></p>
+
+<ul>
+<li>
+<em>.views</em> contains the contribution classes for parts. For example, <em>PackageExplorer</em> class contains the contribution for part with elementId = <em>org.semanticsoft.vaaclipsedemo.cassandra.app.part.packageexplorer</em>.</li>
+<li>
+<em>.editors</em> contains the contribution classes for editors. The editors in this demo don't allow editing source code, but you can familiarize with editors infrastructure on this sample.</li>
+<li>
+<em>.toolitems</em> contains the contributions for <em>Tool Items</em>.</li>
+<li>
+<em>.handlers</em> contains the contributions classes for handlers. For example, <em>CollapseAll</em> class contains the contribution for Direct Tool Item with elementId = <em>org.semanticsoft.vaaclipsedemo.cassandra.app.directtoolitem.collapseall</em>.</li>
+</ul>
View
36 ...emo.cassandra.app/src/org/semanticsoft/vaaclipsedemo/cassandra/app/editors/FileUtils.java
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Rushan R. Gilmullin 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:
- * Rushan R. Gilmullin - initial API and implementation
- *******************************************************************************/
-
-package org.semanticsoft.vaaclipsedemo.cassandra.app.editors;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-/**
- *
- * @author rushan
- *
- */
-public class FileUtils
-{
- public static String readFile(File file, String encoding) throws IOException
- {
- FileInputStream input = new FileInputStream(file);
-
- byte[] fileData = new byte[input.available()];
-
- input.read(fileData);
- input.close();
- return new String(fileData, encoding);
- }
-}
-
View
11 ...mo.cassandra.app/src/org/semanticsoft/vaaclipsedemo/cassandra/app/editors/TextEditor.java
@@ -11,6 +11,10 @@
package org.semanticsoft.vaaclipsedemo.cassandra.app.editors;
+import org.apache.commons.io.IOUtils;
+
+import java.io.FileInputStream;
+
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout;
@@ -57,7 +61,12 @@ protected String readContent()
{
try
{
- content = FileUtils.readFile(getFile(), "UTF-8");
+ FileInputStream inputStream = new FileInputStream(getFile());
+ try {
+ content = IOUtils.toString(inputStream);
+ } finally {
+ inputStream.close();
+ }
}
catch (IOException e)
{
View
68 ...clipsedemo.cassandra.app/src/org/semanticsoft/vaaclipsedemo/cassandra/app/views/Help.java
@@ -0,0 +1,68 @@
+/**
+ *
+ */
+package org.semanticsoft.vaaclipsedemo.cassandra.app.views;
+
+import java.io.FileInputStream;
+import org.apache.commons.io.IOUtils;
+
+import java.util.Scanner;
+
+import java.io.IOException;
+
+import java.io.InputStream;
+
+import java.net.URL;
+
+import java.net.URI;
+
+import javax.annotation.PostConstruct;
+
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+import javax.inject.Inject;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+
+/**
+ * @author rushan
+ *
+ */
+public class Help
+{
+ private Panel panel;
+ private Label content;
+
+ @Inject
+ public void Help(VerticalLayout parent, IEclipseContext context)
+ {
+ panel = new Panel();
+ panel.setSizeFull();
+ panel.setScrollable(true);
+ parent.addComponent(panel);
+ }
+
+ @PostConstruct
+ public void loadHelpText()
+ {
+ String helpPath = "platform:/plugin/org.semanticsoft.vaaclipsedemo.cassandra.app/data/Help.html";
+ try {
+ URL cssUrl = new URL(helpPath);
+ InputStream is = cssUrl.openStream();
+
+ try {
+ String contentString = IOUtils.toString(is);
+ content = new Label(contentString, Label.CONTENT_XHTML);
+ } finally {
+ IOUtils.closeQuietly(is);
+ }
+ }
+ catch (IOException ex)
+ {
+ ex.printStackTrace();
+ content = new Label("Can not open file " + helpPath);
+ }
+
+ panel.addComponent(content);
+ }
+}
View
14 ...psedemo.cassandra.app/src/org/semanticsoft/vaaclipsedemo/cassandra/app/views/Outline.java
@@ -16,7 +16,7 @@
import com.vaadin.ui.Panel;
import com.vaadin.ui.Tree;
import com.vaadin.ui.VerticalLayout;
-import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
@@ -26,6 +26,7 @@
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
+import org.apache.commons.io.IOUtils;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.di.extensions.EventTopic;
@@ -38,7 +39,6 @@
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
import org.semanticsoft.vaaclipse.publicapi.resources.BundleResource;
-import org.semanticsoft.vaaclipsedemo.cassandra.app.editors.FileUtils;
import org.semanticsoft.vaaclipsedemo.cassandra.app.editors.JavaEditor;
public class Outline
@@ -96,11 +96,17 @@ public void handleEvent(Event event) {
if (part instanceof MInputPart && part.getObject() instanceof JavaEditor)
{
MInputPart inputPart = (MInputPart) part;
- File file = new File(inputPart.getInputURI());
+
String content;
try
{
- content = FileUtils.readFile(file, "UTF-8");
+ FileInputStream is = new FileInputStream(inputPart.getInputURI());
+ try {
+ content = IOUtils.toString(is);
+ } finally {
+ is.close();
+ }
+
refreshTree(content);
}
catch (IOException e)
View
1 ...nticsoft.vaaclipsedemo.contributions/org.semanticsoft.vaaclipsedemo.contributions.product
@@ -30,6 +30,7 @@
<plugin id="javax.inject"/>
<plugin id="javax.servlet"/>
<plugin id="javax.xml"/>
+ <plugin id="org.apache.commons.io"/>
<plugin id="org.eclipse.core.commands"/>
<plugin id="org.eclipse.core.contenttype"/>
<plugin id="org.eclipse.core.databinding"/>
View
1 ...semanticsoft.vaaclipsedemo.mediaplayer/org.semanticsoft.vaaclipsedemo.mediaplayer.product
@@ -30,6 +30,7 @@
<plugin id="javax.inject"/>
<plugin id="javax.servlet"/>
<plugin id="javax.xml"/>
+ <plugin id="org.apache.commons.io"/>
<plugin id="org.eclipse.core.commands"/>
<plugin id="org.eclipse.core.contenttype"/>
<plugin id="org.eclipse.core.databinding"/>
View
1 org.semanticsoft.vaaclipsedemo.mini/org.semanticsoft.vaaclipsedemo.mini.product
@@ -30,6 +30,7 @@
<plugin id="javax.inject"/>
<plugin id="javax.servlet"/>
<plugin id="javax.xml"/>
+ <plugin id="org.apache.commons.io"/>
<plugin id="org.eclipse.core.commands"/>
<plugin id="org.eclipse.core.contenttype"/>
<plugin id="org.eclipse.core.databinding"/>

0 comments on commit 6132596

Please sign in to comment.
Something went wrong with that request. Please try again.