本文整理汇总了Java中org.eclipse.ui.handlers.HandlerUtil.getActiveShell方法的典型用法代码示例。如果您正苦于以下问题:Java HandlerUtil.getActiveShell方法的具体用法?Java HandlerUtil.getActiveShell怎么用?Java HandlerUtil.getActiveShell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.handlers.HandlerUtil
的用法示例。
在下文中一共展示了HandlerUtil.getActiveShell方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection sel = HandlerUtil.getCurrentSelection(event);
if (sel.isEmpty())
return null;
if (!(sel instanceof IStructuredSelection))
return null;
Object obj = ((IStructuredSelection) sel).getFirstElement();
if (!(obj instanceof IFile))
return null;
try {
ConvertToFileCreationWizard wizard = new ConvertToFileCreationWizard( );
wizard.init(PlatformUI.getWorkbench(), (IStructuredSelection)sel);
Shell activeShell = HandlerUtil.getActiveShell(event);
if (activeShell==null) return null;
WizardDialog dialog = new WizardDialog(activeShell,wizard);
dialog.open();
} catch (Exception e) {
ResourceManager.logException(e);
}
return null;
}
示例2: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) {
IWorkbenchPart part = HandlerUtil.getActiveEditor(event);
if (part instanceof SQLEditor){
SQLEditor sqlEditor = (SQLEditor) part;
if (sqlEditor.getCurrentDb() != null) {
sqlEditor.updateDdl();
} else {
MessageBox mb = new MessageBox(HandlerUtil.getActiveShell(event), SWT.ICON_INFORMATION);
mb.setText(Messages.UpdateDdl_select_source);
mb.setMessage(Messages.UpdateDdl_select_source_msg);
mb.open();
}
}
return null;
}
示例3: openDialog
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
private ICoverageLaunch openDialog(ExecutionEvent event,
List<ICoverageLaunch> launches) {
final ListDialog dialog = new ListDialog(HandlerUtil.getActiveShell(event)) {
@Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
ContextHelp.setHelp(shell, ContextHelp.DUMP_EXECUTION_DATA);
}
};
dialog.setTitle(UIMessages.DumpExecutionDataDialog_title);
dialog.setMessage(UIMessages.DumpExecutionDataDialog_message);
dialog.setContentProvider(ArrayContentProvider.getInstance());
dialog.setLabelProvider(new LaunchLabelProvider());
dialog.setInput(launches);
if (dialog.open() == Dialog.OK && dialog.getResult().length == 1) {
return (ICoverageLaunch) dialog.getResult()[0];
}
return null;
}
示例4: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException
{
Shell activeShell = HandlerUtil.getActiveShell(event);
IRunnableWithProgress runner = ProjectSourceUtil.getRunner();
try
{
new ProgressMonitorDialog( activeShell ).run( true, false, runner );
}
catch( InvocationTargetException | InterruptedException e )
{
Throwable t = (e instanceof InvocationTargetException) ? e.getCause() : e;
MessageDialog.openError( activeShell, "Error detaching sources", t.toString() );
}
return null;
}
示例5: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
ImageView imageView = (ImageView) activePart;
SWTImageCanvas imageCanvas = imageView.imageCanvas;
if (imageCanvas == null) {
return null;
}
Shell shell = HandlerUtil.getActiveShell(event);
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
dialog.setFilterExtensions(new String[] { "*.png", "*.*" });
dialog.setFilterNames(new String[] { "PNG Files", "All Files" });
String fileSelected = dialog.open();
if (fileSelected != null) {
ImageLoader imageLoader = new ImageLoader();
imageLoader.data = new ImageData[] { imageCanvas.getImageData() };
System.out.println("Selected file: " + fileSelected);
imageLoader.save(fileSelected, SWT.IMAGE_PNG);
}
return null;
}
示例6: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
if (selection.isEmpty()) {
return null;
}
List<Bookmark> bookmarks = new ArrayList<>(
getBookmarksToDelete(bookmarkDatabase.getBookmarksTree(), selection));
ConfirmDeleteDialog dialog = new ConfirmDeleteDialog(HandlerUtil.getActiveShell(event), bookmarks);
if (dialog.open() != Window.OK) {
return null;
}
try {
bookmarksService.deleteBookmarks(getAsBookmarkIds(selection), true);
} catch (BookmarksException e) {
throw new ExecutionException("Could not delete bookmark", e);
}
return null;
}
示例7: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
BookmarkFolder parent = null;
if (selection.isEmpty()) {
parent = bookmarksService.getBookmarksTree().getRootFolder();
} else {
Bookmark bookmark = (Bookmark) selection.getFirstElement();
if (!(bookmark instanceof BookmarkFolder)) {
return null;
}
parent = (BookmarkFolder) bookmark;
}
Shell shell = HandlerUtil.getActiveShell(event);
String folderName = askBookmarkFolderName(shell);
if (folderName == null) {
return null;
}
try {
bookmarksService.addBookmarkFolder(parent.getId(), folderName);
} catch (BookmarksException e) {
throw new ExecutionException("Could not add bookmark folder", e);
}
return null;
}
示例8: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
Bookmark bookmark = getSelectedBookmark(selection);
Shell shell = HandlerUtil.getActiveShell(event);
String newName = askBookmarkName(shell, bookmark.getPropertyValue(Bookmark.PROPERTY_NAME));
if (newName == null) {
return null;
}
try {
bookmarksService.renameBookmark(bookmark.getId(), newName);
} catch (BookmarksException e) {
throw new ExecutionException("Could not rename bookmark", e);
}
return null;
}
示例9: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
public Object execute(final ExecutionEvent event) throws ExecutionException {
final FilteredItemsSelectionDialog dialog = new TLAFilteredItemsSelectionDialog(HandlerUtil.getActiveShell(event));
dialog.open();
final Object[] result = dialog.getResult();
if (result != null && result.length == 1) {
final Map<String, String> parameters = new HashMap<String, String>();
if (result[0] instanceof Module && ((Module) result[0]).isRoot()) {
parameters.put(OpenSpecHandler.PARAM_SPEC, ((Module) result[0]).getModuleName());
UIHelper.runCommand(OpenSpecHandler.COMMAND_ID, parameters);
} else if (result[0] instanceof Module) {
parameters.put(OpenModuleHandler.PARAM_MODULE, ((Module) result[0]).getModuleName());
UIHelper.runCommand(OpenModuleHandler.COMMAND_ID, parameters);
} else if (result[0] instanceof Model) {
parameters.put(OpenModelHandler.PARAM_MODEL_NAME, ((Model) result[0]).getName());
UIHelper.runCommand(OpenModelHandler.COMMAND_ID, parameters);
} else if (result[0] instanceof Spec) {
parameters.put(OpenSpecHandler.PARAM_SPEC, ((Spec) result[0]).getName());
UIHelper.runCommand(OpenSpecHandler.COMMAND_ID, parameters);
}
}
return null;
}
示例10: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = HandlerUtil.getActiveShell(event);
PreferenceDialog dialog = createPreferenceDialogOn(shell, ExternalLibraryPreferencePage.ID, FILTER_IDS, null);
if (null != dialog) {
dialog.open();
}
return null;
}
示例11: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) {
PgDbProject proj = OpenProjectUtils.getProject(event);
Shell shell = HandlerUtil.getActiveShell(event);
IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
Log.log(Log.LOG_DEBUG, "Diff wizard about to show"); //$NON-NLS-1$
WizardDialog dialog = new WizardDialog(
shell, new DiffWizard(proj, prefStore));
dialog.open();
return null;
}
示例12: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = HandlerUtil.getActiveShell(event);
FeedBackDialog dialog = new FeedBackDialog(shell);
dialog.open();
return null;
}
示例13: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell activeShell = HandlerUtil.getActiveShell(event);
EGradleRootProjectImportWizard wizard = new EGradleRootProjectImportWizard();
wizard.setImportMode(RootProjectConfigMode.REIMPORT_PROJECTS);
wizard.setWindowTitle("Reimport project(s)");
WizardDialog dialog = new WizardDialog(activeShell, wizard);
dialog.open();
return null;
}
示例14: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell activeShell = HandlerUtil.getActiveShell(event);
IWizard wizard = new EGradleNewProjectWizard();
WizardDialog dialog = new WizardDialog(activeShell, wizard);
dialog.open();
return null;
}
示例15: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
final Shell shell = HandlerUtil.getActiveShell(event);
if (selection instanceof IStructuredSelection) {
Iterator<?> it = ((IStructuredSelection) selection).iterator();
while (it.hasNext()) {
final Object selected = it.next();
final Generation generation;
if (selected instanceof IFile && "genconf".equals(((IFile) selected).getFileExtension())) {
URI genconfURI = URI.createPlatformResourceURI(((IFile) selected).getFullPath().toString(), true);
generation = getGeneration(genconfURI);
} else if (selected instanceof Generation) {
generation = (Generation) selected;
} else {
generation = null;
}
if (generation != null) {
execute(event, generation);
} else {
MessageDialog.openError(shell, "Bad selection",
"Document generation action can only be triggered on Generation object or a .genconf file.");
}
}
} else {
MessageDialog.openError(shell, "Bad selection",
"Document generation action can only be triggered on Generation object or a .genconf file.");
}
return null;
}