Pages

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

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/