Pages

about my opensource eclipse java applications recently i'm studying GWT and Android

Friday, August 05, 2005

First Draw2D


You need draw2d.jar of GEF and swt.jar to run below program.


At first it's need to create FigureCanvas.
FigureCanvas connect Components and Figures.
Besides that there are LightweightSystem

FigureCanvas canvas = new FigureCanvas(shell);

Next ,it need to create Panel of Draw2D which is one of Figures. And set FlowLayout as Layout. On Draw2D figure is set as tree ,So it's need root Figure. And Method setContens() set root Figure .

Panel panel=new Panel(); panel.setLayoutManager(new FlowLayout(false)); canvas.setContents(panel);
Finally,it add labels of Draw2D. On Draw2D,there are no need to add a parent Figure argument,because it add a children figure to a parent Figure directly.

for(int i=0;i<3;i++){
Label label=new Label("draw2d "+i);
panel.add(label);


---
//all codes.

/*
* Created on 2005/07/28
* Author aki@www.xucker.jpn.org
* License Apache2.0 or Common Public License
*/
package example.draw2d;

import org.eclipse.draw2d.FigureCanvas;
import org.eclipse.draw2d.FlowLayout;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.Panel;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
*
*
*/
public class Draw2DLabel {


public Draw2DLabel(Shell shell) {

shell.setBounds(0,0,150,150);
shell.setLayout(new FillLayout(SWT.VERTICAL));

FigureCanvas canvas = new FigureCanvas(shell);
Panel panel=new Panel();
panel.setLayoutManager(new FlowLayout(false));
canvas.setContents(panel);

for(int i=0;i<3;i++){
Label label=new Label("draw2d "+i);
panel.add(label);
}
}

public static void main(String[] args) {
Display display=new Display();
Shell shell=new Shell(display);


Draw2DLabel app=new Draw2DLabel(shell);


shell.open();

while(!shell.isDisposed()){
if (!display.readAndDispatch ()){
display.sleep ();
}
}
display.dispose();
}

}
}

Tuesday, June 07, 2005

akj Speechtools 1.1

I release new verion akJ Speechtools 1.1
This is Eclipse RCP Application which can speech.
it can both speech both English & Japanese.
it use FreeTTS & Mbrola & Gtalk(Japanese Voice).

You can download from here.
https://sourceforge.jp/projects/akjrcp/files/?release_id=15055#15055

Wednesday, March 30, 2005

how to wrap on and off Text Widget

I don't know is this a best way .

simply rebuild text widget.
keep text and selection.
----
public void createPartControl(Composite parent) {

textArea = new Text(parent,SWT.MULTI|SWT.V_SCROLL|SWT.H_SCROLL);

}

public void setWrap(boolean bool){
Composite parent=textArea.getParent();
String text=textArea.getText();
Point pt=textArea.getSelection();
textArea.dispose();
int style=SWT.H_SCROLL;
if(bool){
style=SWT.WRAP;
}
textArea = new Text(parent,SWT.MULTI|SWT.V_SCROLL|style);
textArea.setText(text);
textArea.setSelection(pt);

parent.layout();

on windows these character cant' use

on windows these character cant' use
public static char[] NON_FILENAME={'\\','/',':','*','?','<','>','|'};
and sample codes.
/*
* Created on 2005/03/31
* Author aki@www.xucker.jpn.org
* License Apache2.0 or Common Public License
*/
package org.jpn.xucker.rcp.speech.wizards;

import java.util.HashMap;

import java.io.IOException;

/**
*
*
*/
public class FileNameUtils {
public static char[] NON_FILENAME={'\\','/',':','*','?','<','>','|'};
public static String replaceNonFileName(String base,String replaceText,int maxlength){
StringBuffer result=new StringBuffer();
for(int i=0;i if(isNonFileNameChar(base.charAt(i))){
result.append(replaceText);
}else{
result.append(base.charAt(i));
}
}
return result.toString();
}
public static boolean isNonFileNameChar(char ch){
for (int i = 0; i < NON_FILENAME.length; i++) {
if(NON_FILENAME[i]==ch){
return true;
}
}
return false;
}

public static String[] avoidSameName(String filenames[],String[] otherNames) throws IOException{
int max=999999;
String result[]=new String[filenames.length];
HashMap map=new HashMap();
if(otherNames!=null){
for (int i = 0; i < otherNames.length; i++) {
map.put(otherNames[i],"");
}
}
for (int i = 0; i < result.length; i++) {

String newname=filenames[i];
int last=filenames[i].lastIndexOf(".");
String head=null;
String foot=null;
if(last!=-1){
head=filenames[i].substring(0,last);
foot=filenames[i].substring(last);
}else{
head=filenames[i];
foot="";
}

int sx=1;
while(map.get(newname)!=null){
newname=head+"_"+sx+foot;
sx++;
if(sx>max){
throw new IOException("can't filename renamed");
}
}
result[i]=newname;
map.put(newname,"");

}
return result;
}


}

Sunday, March 13, 2005

akj speechtools

today i upload my eclipse rcp speech tools.
http://sourceforge.jp/projects/akjrcp/files/?release_id=13713#13713

this is simply wrapped freetts & mbrola.

try it!

Saturday, March 12, 2005

create account in sourceforge.jp

If it was possible i'd like to create project at sourceforge.net.
but my project was rejected.and becouse of my poor enligh skills, i can't explain my projects.

any way.
check my site http://sourceforge.jp/projects/akjrcp/

Friday, March 11, 2005

how to change your eclipse rcp application's title and icon

if you hurry anyway,you can do that.

public class OptipngWrapperWorkbenchAdvisor extends WorkbenchAdvisor{

public void postWindowOpen(IWorkbenchWindowConfigurer configurer) {
configurer.setTitle(Messages.getString("optipng_title"));
Image logoImage=ImageDescriptor.createFromURL(OptipngWrapperPlugin.getDefault().find(new Path("icons/akj_eclipse.png"))).createImage(); //$NON-NLS-1$
configurer.getWindow().getShell().setImage(logoImage);
}

}

but this approach has problem. selected icon isn't deliverd to other shell (Help or Updates)
that's not so important thing.

but I recomend you use product extension point.
more detail see
http://eclipse.org/articles/Article-Branding/branding-your-application.html
<extension
id="product"
point="org.eclipse.core.runtime.products">
<product name="akJ Speech Tools"
application="org.jpn.xucker.rcp.speech.SpeechApplication"
>
<property name="windowImage" value="icons/akj.png"/>
</product>
</extension>

Thursday, March 10, 2005

How to IAction Disable or Enable

when you something action.you hope disable other action.
at first i didn't found them. finally i found that.
I don't know ,is that right?
but i use that code.
you call this method from view,or change 'this'.
on id-String .use Action ID.
private void setEnabled(boolean bool,String id){
IContributionItem ic=this.getViewSite().getActionBars().getToolBarManager().find(id);
if(ic!=null && ic instanceof ActionContributionItem){
IAction iaction=((ActionContributionItem)ic).getAction();
iaction.setEnabled(bool);
}
}

Wednesday, March 09, 2005

Open Editor on Eclipse RCP

see that samples.
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-text-home/development/rcp/examples/index.html

that's difficult.
even in open text files,i should create some classes.
and now I'dont know how to use other editor plugin.
when i open file.
it coused that error
org.eclipse.ui.PartInitException: Text editor does not have a document provider

maybe on 3.1,that become more easy.

give up handle moving view.

on Eclipse 3.01 Windows XP

I don't know how to handle movable views,and
I give up using them.

I choose 2 rules.
Rule 1.Never use folder.
Rule 2.Use setFixed(true) when use setEditorAreaVisible(false)

why folder is movable.
and folder can't back window.

when use setEditorAreaVisible(false) and all views go out,
view didn't come back alone.
maybe everyuser panic that.

Tuesday, March 08, 2005

Today I try to add preferences my application.
that is something easy.

if you wish use preferences. call that.

PreferenceManager m=PlatformUI.getWorkbench().getPreferenceManager();

PreferenceDialog dialog=new PreferenceDialog(window.getShell(),m);

dialog.open();

off course you should create preference extentions(org.eclipse.ui.preferencePages).


Saturday, March 05, 2005

try Eclipse UpdateManager

Today I try to implement UpdateManager.
I see the Update Sites of Eclipse Help.
and I create Feature Project and Update Site Project.
I confused version and other,but finnlay I succede.

but there are problem.if i use UpdateManagerUI.openInstaller(),
include too many other plugins. and my application became really fat size.

so i'd like to release my application as zip archive files.

my first eclipse rcp application (ak Optipng wrapper)

hello
this is my first eclipse rcp applicaltion.
http://www.xucker.jpn.org/product/akjoptipngwrapper.zip

this optimize png file size by calling the optipng which is command-line application.
soon i'd like to show source code,please wait finish to refactoring.

JSmooth example for Eclipse RCP

if you don't know how to use NSIS like me and you know how to use JSmooth,
maybe it's is userful for you.
You msut change applicationclass and exe-name.
---------



registry
javahome
jrepath
jdkpath
exepath
jview
-application org.jpn.xucker.rcp.optipngwrapper.OptipngWrapperApplication %*
startup.jar
.
false
akjoptipngwrapper.exe
icon.png
-1
org.eclipse.core.launcher.Main
-1


Windowed Wrapper

Message
Need Install Java


URL
http://www.java.com/


SingleProcess
0


Debug
0

how to get plugin dir on Eclipse RCP?

finally i choose that aproach.i don't that is best way.

public File toPluginDir(Plugin plugin){
return new File(Platform.getInstallLocation().getURL().getPath(),
"plugins/"
+plugin.getBundle().getSymbolicName()
+"_"
+plugin.getBundle().getHeaders().get("Bundle-Version"));
}

it's too difficult for me handle the Bundle Class.
it's sample of bundle.getHeaders() values.

Bundle-ClassPath='rcp_optipngwrapper.jar'
Bundle-Name='akJ OptipngWrapper Plug-in'
Bundle-Version='1.0.2'
Bundle-Localization='plugin'
Generated-from='1110021669453;type=2'
Bundle-SymbolicName='org.jpn.xucker.rcp.optipngwrapper; singleton=true'
Require-Bundle='org.jpn.xucker.commons,
org.eclipse.ui,
org.eclipse.core.runtime'
Bundle-Activator='org.jpn.xucker.rcp.optipngwrapper.OptipngWrapperPlugin'
Eclipse-AutoStart='true'
Bundle-Vendor='www.xucker.jpn.org'
Manifest-Version='1.0'
Provide-Package='org.jpn.xucker.rcp.optipngwrapper,
org.jpn.xucker.optipngwrapper'

Tuesday, March 01, 2005

Free Culture Srt-Sub File

Today I created srt-sub file from Free Culture Audio book.

now it's only 1 files.
but one day i'd like to create all file and post there

sample
-----
1
00:00:01,560 --> 00:00:03,670
At the end of his review of my first book

2
00:00:03,710 --> 00:00:05,690
Code: And Other Laws of Cyberspace
----

download from here
this works licensed under
Attribution-NonCommercial 2.0 Japan
http://creativecommons.org/licenses/by-nc/2.0/jp/

Monday, February 21, 2005

Test tritunus MP3Encocer


Today I test tritunus MP3Encocer,
http://www.tritonus.org/plugins.html (tritonus-mp3enc-2001-04-25.zip)
becouse i'd like to make converting wav to mp3 program.

it's successed.
if you carefull to dont't forget to contain lame_enc.dll and lametritonus.dll in classpath,
it is an easy work.

of cource i think calling lame.exe from commandline is simple way. You dont't think? :)
but maybe i think implementing some lame-args is hard work.
it's easy to use Tritunus MP3Encoder.

either using lame.exe or lame_enc.dll.
the users must install Lame munually.
We should create a manual which contain how to download Lame. Posted by Hello

my code

Hello ,I'm Aki.
Today I start my java log.

my codes are uploaded here.

Currently I create SWT-based applications.but I'd like to change them to Eclipse-RCP based applications.


one of my favorite sweet. Posted by Hello