use of net.heartsome.cat.ts.ui.dialog.NewFolderDialogOfHs in project translationstudio8 by heartsome.
the class NewFolderHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = HandlerUtil.getActiveShell(event);
String partId = HandlerUtil.getActivePartId(event);
if (partId.equals("net.heartsome.cat.common.ui.navigator.view")) {
// 导航视图处于激活状态
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart viewPart = page.findView("net.heartsome.cat.common.ui.navigator.view");
StructuredSelection selection = (StructuredSelection) viewPart.getSite().getSelectionProvider().getSelection();
if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
List<?> lstObj = ((IStructuredSelection) selection).toList();
if (lstObj == null || lstObj.size() != 1) {
MessageDialog.openInformation(shell, Messages.getString("handlers.NewFolderHandler.msgTitle"), Messages.getString("handlers.NewFolderHandler.msg1"));
return null;
}
IContainer container = null;
for (Object obj : lstObj) {
if (obj instanceof IFile) {
IFile file = (IFile) obj;
container = file.getParent();
} else if (obj instanceof IFolder) {
container = (IFolder) obj;
} else if (obj instanceof IProject) {
container = (IProject) obj;
}
}
ResourcesPlugin.getPlugin().getPluginPreferences().setValue(ResourcesPlugin.PREF_DISABLE_LINKING, true);
NewFolderDialogOfHs dialog = new NewFolderDialogOfHs(shell, container);
dialog.open();
} else {
MessageDialog.openInformation(shell, Messages.getString("handlers.NewFolderHandler.msgTitle"), Messages.getString("handlers.NewFolderHandler.msg2"));
return null;
}
} else {
MessageDialog.openInformation(shell, Messages.getString("handlers.NewFolderHandler.msgTitle"), Messages.getString("handlers.NewFolderHandler.msg2"));
return null;
}
return null;
}
Aggregations