use of org.eclipse.jface.dialogs.InputDialog in project meclipse by flaper87.
the class Collection method makeActions.
private void makeActions() {
insert = new Action(getCaption("collection.insertDoc")) {
@Override
public void run() {
FileDialog dialog = new FileDialog(view.getSite().getShell(), SWT.OPEN);
dialog.setFilterExtensions(new String[] { "*.json" });
String result = dialog.open();
if (result != null) {
try {
String jsonText = IOUtils.readFile(new File(result));
JSONObject jsonObj = new JSONObject(jsonText);
col.insert(JSONUtils.toDBObject(jsonObj));
} catch (Exception ex) {
UIUtils.openErrorDialog(view.getSite().getShell(), ex.toString());
}
}
}
};
rename = new Action(getCaption("collection.renameColl")) {
@Override
public void run() {
InputDialog dialog = new InputDialog(view.getSite().getShell(), getCaption("collection.renameColl"), getCaption("collection.msg.newCollName"), col.getName(), new RequiredInputValidator(getCaption("collection.msg.inputCollName")));
if (dialog.open() == InputDialog.OK) {
try {
col.rename(dialog.getValue());
} catch (MongoException ex) {
UIUtils.openErrorDialog(view.getSite().getShell(), ex.toString());
}
view.getViewer().refresh(getParent());
}
}
};
delete = new Action(getCaption("collection.deleteColl")) {
@Override
public void run() {
if (MessageDialog.openConfirm(view.getSite().getShell(), getCaption("confirm"), String.format(getCaption("collection.msg.reallyDeleteColl"), col.getName()))) {
col.drop();
view.getViewer().refresh(getParent());
}
}
};
}
use of org.eclipse.jface.dialogs.InputDialog in project translationstudio8 by heartsome.
the class MergeXliff method getTargetFilePath.
/**
* 获取合并后的文件的路径
* @param srcXlfPath
* 被分割的第一个文件
*/
private void getTargetFilePath(final Vector<String> srcFilesPath) {
String originalFileName = xlfhandler.getSplitOriginalName(srcFilesPath.get(0));
if (originalFileName == null) {
targetFilePath = null;
Display.getDefault().asyncExec(new Runnable() {
public void run() {
MessageDialog.openInformation(shell, Messages.getString("splitAndMergeXliff.MergeXliff.msgTitle2"), Messages.getString("splitAndMergeXliff.MergeXliff.msg9"));
}
});
} else {
String srcXlfLC = null;
int leastLength = -1;
// 循环遍历每一个文件,找出其中深度最低的文件,之后再取其父目录做为合并文件的位置
for (String fileLC : srcFilesPath) {
IFile iFile = ResourceUtils.fileToIFile(fileLC);
String fullStr = iFile.getFullPath().toOSString();
String separator = "\\".equals(System.getProperty("file.separator")) ? "\\\\" : "/";
String[] array = fullStr.split(separator);
if (leastLength == -1) {
leastLength = array.length;
srcXlfLC = fileLC;
} else {
if (array.length < leastLength) {
srcXlfLC = fileLC;
}
}
}
if (srcXlfLC == null || "".equals(srcXlfLC)) {
return;
}
final String fileExtension = originalFileName.substring(originalFileName.lastIndexOf("."), originalFileName.length());
originalFileName = originalFileName.substring(0, originalFileName.lastIndexOf(fileExtension)) + "_merged" + fileExtension;
// 下面判断这个层次最高的文件,它的父的父是不是"XLIFF" 文件夹,如果是的话
IFile srcXlfIFile = ResourceUtils.fileToIFile(srcXlfLC);
IPath mergeFileParentIPath = null;
if ("XLIFF".equals(srcXlfIFile.getParent().getParent().getName())) {
mergeFileParentIPath = srcXlfIFile.getParent().getLocation();
} else {
mergeFileParentIPath = srcXlfIFile.getParent().getParent().getLocation();
}
targetFilePath = mergeFileParentIPath.append(originalFileName).toOSString();
if (new File(targetFilePath).exists()) {
final String initValue = "Copy of " + originalFileName;
final String message = MessageFormat.format(Messages.getString("splitAndMergeXliff.MergeXliff.msg10"), originalFileName);
final IPath curPath = mergeFileParentIPath;
Display.getDefault().syncExec(new Runnable() {
public void run() {
InputDialog dialog = new InputDialog(shell, Messages.getString("splitAndMergeXliff.MergeXliff.dialogTitle"), message, initValue, null);
dialog.open();
if (dialog.getReturnCode() == Window.CANCEL) {
targetFilePath = null;
} else {
String newFileName = dialog.getValue();
if (!fileExtension.equals(newFileName.substring(newFileName.lastIndexOf("."), newFileName.length()))) {
newFileName = newFileName + fileExtension;
}
targetFilePath = curPath.append(newFileName).toOSString();
}
}
});
}
}
}
use of org.eclipse.jface.dialogs.InputDialog in project translationstudio8 by heartsome.
the class RenameResourceAndCloseEditorAction method queryNewResourceName.
/**
* Return the new name to be given to the target resource.
*
* @return java.lang.String
* @param resource
* the resource to query status on
*/
protected String queryNewResourceName(final IResource resource) {
final IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
final IPath prefix = resource.getFullPath().removeLastSegments(1);
IInputValidator validator = new IInputValidator() {
public String isValid(String string) {
if (resource.getName().equals(string)) {
return IDEWorkbenchMessages.RenameResourceAction_nameMustBeDifferent;
}
IStatus status = workspace.validateName(string, resource.getType());
if (!status.isOK()) {
return status.getMessage();
}
if (workspace.getRoot().exists(prefix.append(string))) {
return IDEWorkbenchMessages.RenameResourceAction_nameExists;
}
return null;
}
};
InputDialog dialog = new InputDialog(shellProvider.getShell(), IDEWorkbenchMessages.RenameResourceAction_inputDialogTitle, IDEWorkbenchMessages.RenameResourceAction_inputDialogMessage, resource.getName(), validator);
dialog.setBlockOnOpen(true);
int result = dialog.open();
if (result == Window.OK)
return dialog.getValue();
return null;
}
use of org.eclipse.jface.dialogs.InputDialog in project tdi-studio-se by Talend.
the class GenericHiddenTextController method createButtonCommand.
protected Command createButtonCommand(final Button button) {
if (button.getData(NAME).equals(HIDDEN_TEXT)) {
InputDialog dlg = new InputDialog(button.getShell(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Messages.getString("GenericHiddenTextController.NewPassword"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Messages.getString("GenericHiddenTextController.NoteConvention"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"\"\"", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
null) {
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.InputDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Control control = super.createDialogArea(parent);
String paramName = (String) button.getData(PARAMETER_NAME);
getText().setData(PARAMETER_NAME, paramName);
// editionControlHelper.register(paramName, getText());
return control;
}
};
if (dlg.open() == Window.OK) {
String paramName = (String) button.getData(PARAMETER_NAME);
elem.setPropertyValue(EParameterName.UPDATE_COMPONENTS.getName(), new Boolean(true));
return new PropertyChangeCommand(elem, paramName, dlg.getValue());
}
}
return null;
}
use of org.eclipse.jface.dialogs.InputDialog in project tdi-studio-se by Talend.
the class PasswordController method createButtonCommand.
protected Command createButtonCommand(final Button button) {
if (button.getData(NAME).equals(PASSWORD)) {
String paramName = (String) button.getData(PARAMETER_NAME);
IElementParameter param = elem.getElementParameter(paramName);
//$NON-NLS-1$
String initValue = "\"\"";
if (param.getValue() != null && ContextParameterUtils.containContextVariables(param.getValue().toString())) {
initValue = param.getValue().toString();
}
InputDialog dlg = new InputDialog(button.getShell(), //$NON-NLS-1$ //$NON-NLS-2$
Messages.getString("PasswordController.NewPassword"), //$NON-NLS-1$ //$NON-NLS-2$
Messages.getString("PasswordController.NoteConvention"), initValue, null) {
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.InputDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Control control = super.createDialogArea(parent);
String paramName = (String) button.getData(PARAMETER_NAME);
getText().setData(PARAMETER_NAME, paramName);
editionControlHelper.register(paramName, getText());
return control;
}
};
if (dlg.open() == Window.OK) {
elem.setPropertyValue(EParameterName.UPDATE_COMPONENTS.getName(), new Boolean(true));
return new PropertyChangeCommand(elem, paramName, dlg.getValue());
}
}
return null;
}
Aggregations