FlowEntryValueDialog.java from PovClipse at Krugle
Show FlowEntryValueDialog.java syntax highlighted
/* PovClipse - Eclipse plugin for editing and rendering Povray sceene files.
* Copyright (C) 2006-2007 Wolfgang Moestl wmoestl@web.de
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package com.wm.povclipse.dialogs.flow;
import java.text.NumberFormat;
import java.text.ParseException;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.swt.widgets.Display;
import com.wm.povclipse.PovClipseEditorPlugin;
import com.wm.povclipse.i18n.I18nFlowEditor;
import com.wm.povclipse.validator.FloatValidator;
/**
* Dialog used by a <code>FlowWidget</code> to let the user edit the <code>value</code>
* of a <code>FlowEntry</code>.
*
* @author Wolfgang Möstl
*/
public class FlowEntryValueDialog {
/**
* Opens a Dialog for entering a float number.
* @param value The initial value to be shown
* @return The edited value or <code>NULL</code> if the user did not
* close the dialog using the "Set" button
*/
public static Float showValueDialog(float value, NumberFormat floatFormatter) {
InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(),
I18nFlowEditor.bind(I18nFlowEditor.value_dialog_title, floatFormatter.format(value)),
I18nFlowEditor.value_dialog_lable,
floatFormatter.format(value),
new FloatValidator());
dialog.create();
dialog.getShell().setImage(PovClipseEditorPlugin.getDefault().getImageRegistry().get(PovClipseEditorPlugin.IMAGE_LOGO_POVRAY));
if (Dialog.OK == dialog.open()) {
try {
Number num = floatFormatter.parse(dialog.getValue());
return new Float(num.floatValue());
} catch (ParseException e) {
return null;
}
} else {
return null;
}
}
}
See more files for this project here