Chethan Sharma

Ranch Hand
+ Follow
since Mar 22, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chethan Sharma

Hi,

I have a requirement to parse the timestamp and get the timezone from it:

timestamp is in the format of 'Thu Mar 11 18:25:14 GMT-08:00 2010'.

From this string, I need to get the timezone (as PST in above example).

I am using the SimpleDateFormat as 'EEE MMM dd HH:mm:ss z yyyy' for parsing but the timezone is showing as IST.

following is the code i have tried :
/**
SimpleDateFormat SDF = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
String testdate = "Thu Mar 11 18:25:14 GMT-08:00 2010";
SDF.parse(testdate);
System.out.println("SDF.getTimeZone().getDisplayName());
**/

Output:
==========
India Standard Time.

if I rewrite 'testdate' with "Thu Mar 11 18:25:14 PST 2010", output is coming correctly as 'PST'.

Please let me know how to retireve the correct timezone in the above code ?

Also, I have tried taking timezone substring from the testdate as 'GMT-08:00' and pass it to TimeZone class like :
/**
System.out.println(TimeZone.getTimeZone("GMT-08:00").getID());
**/
But the output is shown as 'GMT-08:00' but not the 'PST'.

Please help me to achieve the desired output.
14 years ago
Thanks Sagar.

I didn't get the expected output after changed the regular expression as
^([^\n]|\p{Print}|\p{Blank})*$
in xml file

Thanks & Regards,
C
15 years ago
"\n-" needs to allow for users on particular text box for enumeration purpose like bullets.
15 years ago
Thanks for the reply.

I was on leave for the last few days. So I didn�t get chance to reply back.

Currently I am reading regular expression pattern from an xml file.

So I have defined the regular expression in xml file as:

^(\p{Print}|\p{Blank}|\n-)*$

My actual requirement is mentioned below

a) If I type explicitly "\n" and "\t" in the text box of my struts application it moves to next page, which means they were regarded as normal printable characters, but they shouldn't be allowed.
This is not the expected output. Here I am expecting the error message with out forwarding to next page.

b) However, if I use enter key and tab key which interprets to "\r\n" and "\t", it doesn't allow to next page. Getting error message and this is the expected output.


Please let me know how to define regular expression in an xml file to meet the above two scenarios.


Where as in java program we have to give the same regular expression with double slashes as

^(\\p{Print}|\\p{Blank}|\\n-)*$


But if I give with double slashes in xml file, during runtime expression I am getting the below exception

Exception: java.util.regex.PatternSyntaxException: Illegal repetition near index 5 "^(\\p{Print}|\\p{Blank}|\\n-)*$" ^

In xml file I tried with different ways but I didn�t get the expected output.

- ^(\p{Print}|\p{Blank}|\n-)*$
- ^(\\p{Print}|\\p{Blank}|\\n-)*$
- ^(\p{Print}|\p{Blank}|\\n-)*$

Thanks
15 years ago
Hi,

The application need to allow only printable characters, blank characters and \n-.
For this purpose I have written the below regular expression.

^(\p{Print}|\p{Blank}|\n-)*$

//****
exam = "this is for testing purpose message \n only";
regexp ="^(\p{Print}|\p{Blank}|\n-)*$";

public static boolean matchRegExp(final String exam, final String regexp) {
Pattern p = Pattern.compile(regexp);
Matcher m = p.matcher(exam);
return m.find();
}
//****

I have written this api in a java file (Test. java) and when I run Test. java as individual program it is working fine and it doesn't allow \n. I am getting the expected output.

But When I am calling the same api in my struts application, it is not working. It allows \n which is not the expected output.

When I am debugging the code using MyEclipse, in Variable view the message appears as

"this is for testing purpose message \\n only" ; ( via struts application)

"this is for testing purpose message \n only"; (individual program)


I am not sure why individual program is working fine but thru application it's not working.

Please let me know how to handle this "\n". Otherwise do I need to make any change in regular expression?


Thanks,
15 years ago
Hi,

I am deploying the Eclipse RCP application using JWS.
During installation of my application, I will get an alert message as

"Would you like to create desktop and start menu shortcuts for MY Application?" With options "Yes / No / Configure..."

When the user selected "Yes" option both desktop and start menu shortcuts are created. But when the users selected "No" option both short cuts are not created and the application is launching. To launch the application next time there is no trigger to launch the application because the user selected "No" option.

Expecting:

By default the desktop and start menu shortcuts are created without this alert message "Would you like to create desktop and start menu shortcuts for MY Application?" With options "Yes / No / Configure...� during installation of my application.

Is there any property to set this alert message won't come during installation.

Please suggest me is there any alternative for this.

Thanks,
16 years ago
I am deploying Eclipse based application with Java Web Start. By default the installation of my application is doing in "C:" drive because I created the jnlp file as below

<property name="osgi.instance.area" value="C:/MyApplication/org.eclipse.osgi/bundles"/>
<property name="osgi.configuration.area" value="C:/MyApplication"/>
<property name="eclipse.product" value="My.product"/>
<property name="osgi.sharedConfiguration.area" value="C:/MyApplication"/>


But I need to allow the users to choose the location where they would like to install / deploy the application.

Please let me know a) how to get "Browse for folder" button.

b) I need to create a dynamic jnlp file based on the user's information. Whether "C:" or "D:" drive.

Any information on this is highly helpful for me.

Thanks,
16 years ago
Hi,

I am deploying Eclipse based application with Java Web Start. By default the installation of my application is doing in "C:" drive because I created the jnlp file as below

<property name="osgi.instance.area" value="C:/MyApplication/org.eclipse.osgi/bundles"/>
<property name="osgi.configuration.area" value="C:/MyApplication"/>
<property name="eclipse.product" value="My.product"/>
<property name="osgi.sharedConfiguration.area" value="C:/MyApplication"/>


But I need to allow the users to choose the location where they would like to install / deploy the application.

Please let me know a) how to get "Browse for folder" button.

b) I need to create a dynamic jnlp file based on the user's information. Whether "C:" or "D:" drive.

Any information on this is highly helpful for me.

Thanks,
16 years ago
Hi,

String finalOutput = "";
StringBuffer buffer = new StringBuffer();

StyledText outputArea = new StyledText(outputAreaGroup, SWT.MULTI
| SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.heightHint = 109;
gridData.widthHint = 755;
outputArea.setLayoutData(gridData);
outputArea.setEditable(false);

After performed some operation I will get large amount of data in a List (result).

List result = comd.getResult();
if (result != null && !result.isEmpty()) {
Iterator iter = result.iterator();
while (iter.hasNext()) {
buffer.append(iter.next());
}
finalOutput = buffer.toString();
}

//Up to here I have no problem.

But when I am trying to execute the outputArea.setText(finalOutput);
Here it takes so much time to set the data in a styled text.
The tool gets hanged for few mins and showing as Not responding in Task manager.

Please let me know how to handle this situation.

Thanks,
16 years ago
Hi,

Please let me know how to handle "Browse for folder" button in a jsp page.

For e.g. during installation of any software we will show browse button to choose where we would like to install the software / application.

Thanks,
16 years ago
JSP
Program:
-----------
public static void main(String[] args) {
{
List names = new ArrayList();
names.add("Rams");
names.add("Shanker");

List numbers = new ArrayList();
numbers.add(new Integer("1"));
numbers.add(new Integer("2"));

printDet(numbers,"mumbers");
printDet(names,"names");
}
public static void printDet(List list,String type){
Class myclass;
if(type.equals("numbers")){
myclass = Integer.class;
}
else if(type.equals("names")){
myclass = String.class;
}
for(int i=0;i<list.size();i++){
System.out.println((myclass)list.get(i));
}

}
output:
--------
Error: 'myclass' is not resolved to a type...

Can anybody explain why this is not working?
Is there anyother way of coding to compile this example successfully?

Thanks,
16 years ago
Hi,

The application is developing using swt.
this way I resolved this one. Thanks for your response.


=============================
private MenuManager createWindowMenu(IWorkbenchWindow window) {

....
.........
ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry();
IActionSetDescriptor[] actionSets = reg.getActionSets();
String actionSetId[] = {"org.eclipse.ui.edit.text.actionSet.navigation" };

for (int i = 0; i < actionSets.length; i++) {
if ((!actionSets[i].getId().equals(actionSetId[0]))
&& (!actionSets[i].getId().equals(actionSetId[1])))
continue;
IExtension ext = actionSets[i].getConfigurationElement().getDeclaringExtension();
reg.removeExtension(ext, new Object[] { actionSets[i] });
}

return menu;
}

Thanks,
16 years ago
Hi,

Thanks for the response.

Exactly I am developing RCP application using Eclipse3.2.2.
In my application I want to remove "Last Edit Location" tool bar item.

Thanks,
16 years ago
Hi,

Could you please let me know how to remove "Last Edit Location" tool bar item in my application.

In Eclipse We can disabled "Last Edit Location" from
Winodw >> Customize perspective and press commands tab -uncheck the Editor Navigation item from Available Command groups.
16 years ago
Hi,

I need to Highlight multiple lines in a text editor.

Eg:

IMPORTS
A,
B,
c;
IToken oid = new Token(new TextAttribute(color_oid, null, SWT.BOLD));
rules[i++] = new MultiLineRule("IMPORTS ", ";", oid);

By this way I am not able to highlight the multiple lines. But when I give one extra space before IMPORTS word, it is highlighting.


IMPORTS
A,
B,
c;

rules[i++] = new MultiLineRule(" IMPORTS",";", oid);

My requirement is no extra space before IMPORTS word.
Please let me know how to handle this one.

Thanks,
17 years ago