Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
ikylin committed May 29, 2012
1 parent 2a02e24 commit 7e81377
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 0 deletions.
8 changes: 8 additions & 0 deletions hello.client.gui/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions hello.client.gui/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>hello.client.gui</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
</natures>
</projectDescription>
6 changes: 6 additions & 0 deletions hello.client.gui/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Tue May 29 10:20:53 CST 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5
8 changes: 8 additions & 0 deletions hello.client.gui/.settings/org.maven.ide.eclipse.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Tue May 29 10:20:52 CST 2012
activeProfiles=
eclipse.preferences.version=1
fullBuildGoals=process-test-resources
resolveWorkspaceProjects=true
resourceFilterGoals=process-resources resources\:testResources
skipCompilerPlugin=true
version=1
58 changes: 58 additions & 0 deletions hello.client.gui/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>iPOJOTutorial</groupId>
<artifactId>hello.client.gui</artifactId>
<version>1.0.0</version>
<packaging>bundle</packaging>

<name>hello.client.gui</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency> <!-- Compilation (i.e. class) dependency on the service interface -->
<groupId>iPOJOTutorial</groupId>
<artifactId>hello.service</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.3</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
<Private-Package>ipojo.example.hello.client.gui</Private-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-ipojo-plugin</artifactId>
<version>1.2.0</version>
<executions>
<execution>
<goals>
<goal>ipojo-bundle</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package ipojo.example.hello.client.gui;

import ipojo.example.hello.SpellChecker;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

/**
* A very simple Gui interacting with the CheckSpeller service
*/
public class SpellCheckerGui extends JFrame {
/**
* Swing component where the user write the passage to check.
*/
private JTextField m_passage = null;

/**
* Check button
*/
private JButton m_checkButton = null;

/**
* Area where the result is displayed.
*/
private JLabel m_result = null;
/**
* Service dependency on the SpellChecker.
*/
private SpellChecker m_checker;

/**
* Constructor. Initialize the GUI.
*/
public SpellCheckerGui() {
super();
initComponents();
this.setTitle("Spellchecker Gui");
}

/**
* Initialize the Swing Gui.
*/
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
m_checkButton = new javax.swing.JButton();
m_result = new javax.swing.JLabel();
m_passage = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); // Stop
// Felix
getContentPane().setLayout(new java.awt.GridBagLayout());
m_checkButton.setText("Check");
m_checkButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
check();
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
getContentPane().add(m_checkButton, gridBagConstraints);
m_result.setPreferredSize(new java.awt.Dimension(175, 20));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
getContentPane().add(m_result, gridBagConstraints);
m_passage.setPreferredSize(new java.awt.Dimension(175, 20));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
getContentPane().add(m_passage, gridBagConstraints);
pack();
}

/**
* Check Button action. Collects the user input and checks it.
*/
private void check() {
String[] result = m_checker.check(m_passage.getText());
if (result != null) {
m_result.setText(result.length + " word(s) are mispelled");
} else {
m_result.setText("All words are correct");
}
}

/**
* Start callback. This method will be called when the instance becomes
* valid. It set the Gui visibility to true.
*/
public void start() {
this.setVisible(true);
}

/**
* Stop callback. This method will be called when the instance becomes
* invalid or stops. It deletes the Gui.
*/
public void stop() {
this.dispose();
}
}
11 changes: 11 additions & 0 deletions hello.client.gui/src/main/resources/metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/CURRENT/core.xsd"
xmlns="org.apache.felix.ipojo">
<component classname="ipojo.example.hello.client.gui.SpellCheckerGui">
<requires field="m_checker" />
<callback transition="validate" method="start" />
<callback transition="invalidate" method="stop" />
</component>
<instance component="ipojo.example.hello.client.gui.SpellCheckerGui" />
</ipojo>
Binary file not shown.

0 comments on commit 7e81377

Please sign in to comment.