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


Java TreeSelection.getFirstElement方法代碼示例

本文整理匯總了Java中org.eclipse.jface.viewers.TreeSelection.getFirstElement方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeSelection.getFirstElement方法的具體用法?Java TreeSelection.getFirstElement怎麽用?Java TreeSelection.getFirstElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jface.viewers.TreeSelection的用法示例。


在下文中一共展示了TreeSelection.getFirstElement方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import org.eclipse.jface.viewers.TreeSelection; //導入方法依賴的package包/類
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	TreeSelection selection = (TreeSelection) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
	Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
	Object firstElement = selection.getFirstElement();
	
	if (firstElement instanceof IAdaptable)
       {
           IFile file = (IFile)((IAdaptable)firstElement).getAdapter(IFile.class);
           IPath path = file.getLocation();
           
           try {
           	//TODO fix
			SurveyGenerator.generateAll(path.toOSString(), path.toOSString());
			MessageDialog.openInformation(shell, "Success", "Code was generated successfully");
		} catch (Exception e) {
			//MessageDialog.openError(shell, "Error", e.getMessage());
			e.printStackTrace();
		}
       }
	return null;
}
 
開發者ID:TodorovicNikola,項目名稱:SurveyDSL,代碼行數:23,代碼來源:GenerateATLHandler.java

示例2: selectionChanged

import org.eclipse.jface.viewers.TreeSelection; //導入方法依賴的package包/類
public void selectionChanged(SelectionChangedEvent event) {
	Object firstElement = null;
	if (event.getSelection() instanceof TreeSelection) {
		TreeSelection treeSelection = (TreeSelection) event
				.getSelection();
		firstElement = treeSelection.getFirstElement();
	}

	if (firstElement instanceof ISourceImage) {
		Image image = ((ISourceImage) firstElement).getImage();
		imagesBrowseDialog
				.setSelectedResource((ISourceImage) firstElement);
		imagesBrowseDialog.showImage(image);
	} else {
		imagesBrowseDialog.setSelectedResource(null);
		imagesBrowseDialog.showImage(null);
	}
}
 
開發者ID:ShoukriKattan,項目名稱:ForgedUI-Eclipse,代碼行數:19,代碼來源:ImageBrowserDialog.java

示例3: fillContextMenu

import org.eclipse.jface.viewers.TreeSelection; //導入方法依賴的package包/類
/**
 * fillContextMenu
 * 
 * @param manager
 */
private void fillContextMenu(IMenuManager manager)
{
	ISelection selection = treeViewer.getSelection();

	if (selection instanceof TreeSelection)
	{
		TreeSelection treeSelection = (TreeSelection) selection;
		Object item = treeSelection.getFirstElement();

		if (item != null)
		{
			IAction[] actions = actionProvider.getActions(this, item);

			if (actions != null)
			{
				for (IAction action : actions)
				{
					manager.add(action);
				}
			}
		}
	}
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:29,代碼來源:IndexView.java

示例4: getModelHandle

import org.eclipse.jface.viewers.TreeSelection; //導入方法依賴的package包/類
private ModelHandle getModelHandle() {
  ModelHandle handle = null;
  ISelection selection = viewer.getSelection();
  if (selection instanceof TreeSelection) {
    TreeSelection treeSelection = (TreeSelection) selection;
    if (treeSelection.size() == 1) {
      Object selObj = treeSelection.getFirstElement();
      if(selObj instanceof ModelCodeTreeNode) {
        ModelCodeTreeNode modelCodeNode = (ModelCodeTreeNode)selObj;
        try {
          handle = modelCodeNode.getActiveModelHandle();
        } catch (EntryNotFoundException e) {
          // ignore and just interpret as non-drag-able...
        }
      }
    }
  }
  return handle;
}
 
開發者ID:eclipse,項目名稱:triquetrum,代碼行數:20,代碼來源:WorkflowRepositoryView.java

示例5: getFirstSelectedElement

import org.eclipse.jface.viewers.TreeSelection; //導入方法依賴的package包/類
/**
    * @param selection
    * @return first element of the selection
    */
   public static Object getFirstSelectedElement(ISelection selection) {
if (selection instanceof TreeSelection) {
    TreeSelection treeSelection = (TreeSelection) selection;
    return treeSelection.getFirstElement();
} else if (selection instanceof StructuredSelection) {
    StructuredSelection structuredSelection = (StructuredSelection) selection;
    return structuredSelection.getFirstElement();
} else if (selection instanceof IFileEditorInput) {
    IFileEditorInput editorInput = (FileEditorInput) selection;
    return editorInput.getFile();
} else if (selection instanceof TextSelection) {
    return null;
} else {
    throw new RuntimeException(
	    Messages.GeneratorUtils_SelectionNotSupported);
}
   }
 
開發者ID:junit-tools-team,項目名稱:junit-tools,代碼行數:22,代碼來源:EclipseUIUtils.java

示例6: open

import org.eclipse.jface.viewers.TreeSelection; //導入方法依賴的package包/類
/***********************************************************************
 * Open event on double click
 **********************************************************************/
@Override
public void open(OpenEvent event)
{
	TreeSelection sel = (TreeSelection) event.getSelection();
	try
	{
		ProcedureNode item = (ProcedureNode) sel.getFirstElement();
		// Open procedures only, ignore categories
		String category = item.getProcID();
		if (category == null || category.equals("") || category.equals("CATEGORY"))
		{
			return;
		}
		CommandHelper.execute(OpenProcedure.ID);
	}
	catch (Exception e)
	{
		return;
	}
}
 
開發者ID:Spacecraft-Code,項目名稱:SPELL,代碼行數:24,代碼來源:NavigationView.java

示例7: selectionChanged

import org.eclipse.jface.viewers.TreeSelection; //導入方法依賴的package包/類
/***********************************************************************
 * Selection changed on the tree
 **********************************************************************/
@Override
public void selectionChanged(SelectionChangedEvent event)
{
	TreeSelection sel = (TreeSelection) event.getSelection();
	IRuntimeSettings runtime = (IRuntimeSettings) ServiceManager.get(IRuntimeSettings.class);
	try
	{
		ProcedureNode item = (ProcedureNode) sel.getFirstElement();
		runtime.setRuntimeProperty(RuntimeProperty.ID_NAVIGATION_VIEW_SELECTION, item.getProcID());
	}
	catch (Exception ex)
	{
		runtime.setRuntimeProperty(RuntimeProperty.ID_NAVIGATION_VIEW_SELECTION, null);
	}
}
 
開發者ID:Spacecraft-Code,項目名稱:SPELL,代碼行數:19,代碼來源:NavigationView.java

示例8: doubleClick

import org.eclipse.jface.viewers.TreeSelection; //導入方法依賴的package包/類
public void doubleClick(TreeViewer treeViewer) {
	TreeSelection ts = (TreeSelection) treeViewer.getSelection();
	Object el = ts.getFirstElement();
	if (el instanceof MFolder) {
		if (treeViewer.getExpandedState(el))
			treeViewer.collapseToLevel(el, 1);
		else {
			if (refreshAction.isEnabled())
				refreshAction.run();
			treeViewer.expandToLevel(el, 1);
		}
	}
	if (el instanceof MInputControl && editAction.isEnabled()) {
		editAction.run();
		return;
	}
	if (editServerAction.isEnabled())
		editServerAction.run();
	// if (runReportUnitAction.isEnabled())
	// runReportUnitAction.run();
	else if (openInEditorAction.isEnabled())
		openInEditorAction.run();
	else if (runReportUnitAction.isEnabled())
		runReportUnitAction.run();
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:26,代碼來源:ServerProvider.java

示例9: fillContextMenu

import org.eclipse.jface.viewers.TreeSelection; //導入方法依賴的package包/類
/**
 * fillContextMenu
 * 
 * @param manager
 */
private void fillContextMenu(IMenuManager manager)
{
	ISelection selection = treeViewer.getSelection();

	if (selection instanceof TreeSelection)
	{
		TreeSelection treeSelection = (TreeSelection) selection;
		Object item = treeSelection.getFirstElement();

		if (item instanceof BaseNode)
		{
			BaseNode<?> node = (BaseNode<?>) item;
			Action[] actions = node.getActions();

			if (actions != null)
			{
				for (Action action : actions)
				{
					manager.add(action);
				}
			}
		}
	}
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:30,代碼來源:BundleView.java

示例10: doFindResource

import org.eclipse.jface.viewers.TreeSelection; //導入方法依賴的package包/類
public static void doFindResource(ServerProvider sp, TreeViewer treeViewer) {
	TreeSelection ts = (TreeSelection) treeViewer.getSelection();
	Object el = ts.getFirstElement();
	MServerProfile msp = null;
	if (el instanceof MServerProfile)
		msp = (MServerProfile) el;
	else if (el instanceof MResource) {
		INode n = ((MResource) el).getRoot();
		if (n != null && n instanceof MServerProfile)
			msp = (MServerProfile) n;
	}
	if (msp != null) {
		FindResourceWizard wizard = new FindResourceWizard(msp);
		WizardDialog dialog = new FindWizardDialog(UIUtils.getShell(), wizard);
		dialog.setHelpAvailable(false);
		dialog.create();
		if (dialog.open() == Dialog.OK) {
			ResourceDescriptor rd = wizard.getValue();
			if (rd != null)
				selectResource(sp, msp, rd, treeViewer);
		}
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:24,代碼來源:FindResourceJob.java

示例11: run

import org.eclipse.jface.viewers.TreeSelection; //導入方法依賴的package包/類
@Override
public void run() {
	IConnection conn = null;

	TreeSelection selection = (TreeSelection) treeViewer.getSelection();
	Object firstElement = selection.getFirstElement();
	if (firstElement != null) {
		if (firstElement instanceof MServerProfile)
			conn = ((MServerProfile) firstElement).getWsClient();
		else if (firstElement instanceof MResource)
			conn = ((MResource) firstElement).getWsClient();
	}
	if (conn != null) {
		ImportMetadataWizard wizard = new ImportMetadataWizard(conn);
		WizardDialog dialog = new WizardDialog(UIUtils.getShell(), wizard);
		dialog.create();
		if (dialog.open() == Dialog.OK) {
		}
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:21,代碼來源:ImportMetadataAction.java

示例12: setupNewFileName

import org.eclipse.jface.viewers.TreeSelection; //導入方法依賴的package包/類
public void setupNewFileName() {
	String filename = NEW_FILENAME;
	if (selection != null) {
		if (selection instanceof TreeSelection) {
			TreeSelection s = (TreeSelection) selection;
			if (s.getFirstElement() instanceof IFile) {
				IFile file = (IFile) s.getFirstElement();

				String f = file.getProjectRelativePath().removeLastSegments(1).toOSString() + "/" + filename;//$NON-NLS-1$

				int i = 1;
				while (file.getProject().getFile(f).exists()) {
					filename = NEW_NAME + i + NEW_EXT;
					f = file.getProjectRelativePath().removeLastSegments(1).toOSString() + "/" + filename;//$NON-NLS-1$
					i++;
				}
			}
		}
		step1.setFileName(filename);
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:22,代碼來源:ChartThemeNewWizard.java

示例13: setupNewFileName

import org.eclipse.jface.viewers.TreeSelection; //導入方法依賴的package包/類
public void setupNewFileName() {
	String filename = NEW_DATAADAPTER_XML;
	if (selection != null) {
		if (selection instanceof TreeSelection) {
			TreeSelection s = (TreeSelection) selection;
			if (s.getFirstElement() instanceof IFile) {
				IFile file = (IFile) s.getFirstElement();

				String f = file.getProjectRelativePath().removeLastSegments(1).toOSString() + "/" + filename; //$NON-NLS-1$

				int i = 1;
				while (file.getProject().getFile(f).exists()) {
					filename = "NEW_DATAADAPTER" + i + ".xml"; //$NON-NLS-1$ //$NON-NLS-2$
					f = file.getProjectRelativePath().removeLastSegments(1).toOSString() + "/" + filename; //$NON-NLS-1$
					i++;
				}
			}
		}
		step1.setFileName(filename);
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:22,代碼來源:NewFileDataAdapterWizard.java

示例14: setupNewFileName

import org.eclipse.jface.viewers.TreeSelection; //導入方法依賴的package包/類
public void setupNewFileName() {
	String filename = NEW_STYLE_JRTX;
	if (selection != null) {
		if (selection instanceof TreeSelection) {
			TreeSelection s = (TreeSelection) selection;
			if (s.getFirstElement() instanceof IFile) {
				IFile file = (IFile) s.getFirstElement();

				String f = file.getProjectRelativePath().removeLastSegments(1).toOSString() + "/" + filename;//$NON-NLS-1$

				int i = 1;
				while (file.getProject().getFile(f).exists()) {
					filename = NEW_STYLE_NAME + i + NEW_STYLE_EXT;
					f = file.getProjectRelativePath().removeLastSegments(1).toOSString() + "/" + filename;//$NON-NLS-1$
					i++;
				}
			}
		}
		step1.setFileName(filename);
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:22,代碼來源:StyleTemplateNewWizard.java

示例15: doubleClick

import org.eclipse.jface.viewers.TreeSelection; //導入方法依賴的package包/類
/**
 * The callback function for the double click listener. Finds what was 
 * clicked on, if its a rule show it in the editor (or focus on the already
 * open editor).
 */
/* Override */
public void doubleClick( DoubleClickEvent event )
{
    if( event.getSelection() instanceof TreeSelection ) {
       TreeSelection selected = (TreeSelection) event.getSelection();
       if( selected.getFirstElement() != null ) {
          switch( ((ModelElement) selected.getFirstElement()).getModelType() ) {
             
             case RULE:
                TrafficScriptEditor.openEditorForRule( (Rule) selected.getFirstElement() );
             break;
             
          }
       }
    }
}
 
開發者ID:brocade,項目名稱:vTM-eclipse,代碼行數:22,代碼來源:ZXTMViewInputManager.java


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