當前位置: 首頁>>代碼示例>>Java>>正文


Java HandlerUtil.getActiveShell方法代碼示例

本文整理匯總了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;
	}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:25,代碼來源:ConvertToHandler.java

示例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;
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:19,代碼來源:UpdateDdl.java

示例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;
}
 
開發者ID:eclipse,項目名稱:eclemma,代碼行數:20,代碼來源:DumpExecutionDataHandler.java

示例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;
}
 
開發者ID:SAP,項目名稱:hybris-commerce-eclipse-plugin,代碼行數:21,代碼來源:DetachSourcesHandler.java

示例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;
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:27,代碼來源:ImageViewSaveAsHandler.java

示例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;
}
 
開發者ID:cchabanois,項目名稱:mesfavoris,代碼行數:21,代碼來源:DeleteBookmarkHandler.java

示例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;
}
 
開發者ID:cchabanois,項目名稱:mesfavoris,代碼行數:27,代碼來源:NewBookmarkFolderHandler.java

示例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;

}
 
開發者ID:cchabanois,項目名稱:mesfavoris,代碼行數:19,代碼來源:RenameBookmarkHandler.java

示例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;
}
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:24,代碼來源:TLAOpenElementSelectionDialogHandler.java

示例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;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:10,代碼來源:OpenExternalLibraryPreferencePageHandler.java

示例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;
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:13,代碼來源:Diff.java

示例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;
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:8,代碼來源:FeedBack.java

示例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;
}
 
開發者ID:de-jcup,項目名稱:egradle,代碼行數:15,代碼來源:ReimportGradleProjectHandler.java

示例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;
}
 
開發者ID:de-jcup,項目名稱:egradle,代碼行數:12,代碼來源:NewGradleProjectHandler.java

示例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;
}
 
開發者ID:ObeoNetwork,項目名稱:M2Doc,代碼行數:33,代碼來源:AbstractGenerationHandler.java


注:本文中的org.eclipse.ui.handlers.HandlerUtil.getActiveShell方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。