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


Java TreeSelection類代碼示例

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


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

示例1: createControl

import org.eclipse.jface.viewers.TreeSelection; //導入依賴的package包/類
/**
 * @wbp.parser.entryPoint
 */
@Override
public void createControl(Composite parent) {
	fRootControl = new Composite(parent, SWT.NULL);
	fRootControl.setLayout(new FillLayout(SWT.HORIZONTAL));

	 
	viewer = new TreeViewer(fRootControl, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
	viewer.setContentProvider(new ViewContentProvider());
	viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new ViewLabelProvider(createImageDescriptor())));
	viewer.addDoubleClickListener(new IDoubleClickListener () {

		@Override
		public void doubleClick(DoubleClickEvent evt) {
			TreeSelection sel = (TreeSelection) evt.getSelection();
			IFile file = (IFile) sel.getFirstElement();
			if (isModelFile(file)) {
				JDTManager.openEditor(file, "org.gw4e.eclipse.studio.editor.GW4EEditor", null);	
				return;
			}
			JDTManager.openEditor(file, null); 
		}
		
	});
	files = new ArrayList<IFile>();
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:29,代碼來源:ModelSearchResultPage.java

示例2: createControl

import org.eclipse.jface.viewers.TreeSelection; //導入依賴的package包/類
@Override
public void createControl(Composite parent) {
  Composite container = new Composite(parent, SWT.NONE);
  setControl(container);
  container.setLayout(new FillLayout(SWT.HORIZONTAL));

  treeViewer = new TreeViewer(container, SWT.BORDER);
  treeViewer.setUseHashlookup(true);
  treeViewer.setLabelProvider(new SigTypeLabelProvider());
  treeViewer.setContentProvider(new SigTypeContentProvider());
  treeViewer.setInput(ResourcesPlugin.getWorkspace().getRoot().getProjects());

  treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

    @Override
    public void selectionChanged(SelectionChangedEvent event) {
      if (((TreeSelection) event.getSelection()).getFirstElement() instanceof IMarker) {
        selection = event.getSelection();
        ContainerSelectionPage.this.setPageComplete(true);
      } else {
        ContainerSelectionPage.this.setPageComplete(false);
      }
    }
  });
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:26,代碼來源:ContainerSelectionPage.java

示例3: createControl

import org.eclipse.jface.viewers.TreeSelection; //導入依賴的package包/類
@Override
public void createControl(Composite parent) {
  Composite container = new Composite(parent, SWT.NONE);
  this.setControl(container);
  container.setLayout(new FillLayout(SWT.HORIZONTAL));

  TreeViewer treeViewer = new TreeViewer(container, SWT.BORDER);
  treeViewer.setUseHashlookup(true);
  treeViewer.setLabelProvider(new CreatingAtomWizardLabelProvider());
  treeViewer.setContentProvider(new CreatingAtomWizardContentProvider());
  treeViewer.setInput(ResourcesPlugin.getWorkspace().getRoot().getProjects());
  treeViewer.setFilters(new ViewerFilter[] {new CreatingAtomWizardFilter()});

  treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

    @Override
    public void selectionChanged(SelectionChangedEvent event) {
      if (((TreeSelection) event.getSelection()).getFirstElement() instanceof IMarker) {
        UntypedMarkerPage.this.selection = event.getSelection();
        UntypedMarkerPage.this.setPageComplete(true);
      } else {
        UntypedMarkerPage.this.setPageComplete(false);
      }
    }
  });
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:27,代碼來源:UntypedMarkerPage.java

示例4: 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

示例5: selectionChanged

import org.eclipse.jface.viewers.TreeSelection; //導入依賴的package包/類
@Override
public void selectionChanged(SelectionChangedEvent event) {
	ISelection selection = event.getSelection();
	if (selection instanceof IStructuredSelection) {
		IStructuredSelection structureSelection = (IStructuredSelection) selection;
		IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		IViewPart view = activePage.findView(IMAGEVIEW_BUNDLE_ID);
		Bundle dataBundle = Platform.getBundle(XWING_DATA_BUNDLE_ID);
		
		if (structureSelection.getFirstElement() instanceof PilotTreeNode) {
			PilotTreeNode pilot = (PilotTreeNode) structureSelection.getFirstElement();
			Pilot p = (Pilot) pilot.getValue();
			
			if (view != null) {
				loadPilotImage(view, dataBundle, p);
			}				
		} else if (structureSelection instanceof TreeSelection) {
			try {
				UpgradeTypeTreeNode upgradeNode = (UpgradeTypeTreeNode) structureSelection.getFirstElement();
				loadUpgradeImage(view, dataBundle, (Upgrade)upgradeNode.getValue());
			} catch (ClassCastException ex) {
			}
		}
	}
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:26,代碼來源:SquadSelectionChangeListener.java

示例6: 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

示例7: checkTreeSectionSource

import org.eclipse.jface.viewers.TreeSelection; //導入依賴的package包/類
/**
 * 트리에서 선택된 요소가 다이어그램에 놓을 수 있는 요소인지 검사한다.
 * 
 * 
 * @param selection
 * @return boolean
 */
protected boolean checkTreeSectionSource(TreeSelection selection) {
    DiagramType diagramType = diagramEditor.getDiagram().getType();
    if (DiagramType.CLASS_DIAGRAM.equals(diagramType)) {
        if (checkClassDiagram(selection)) {
            return true;
        }
    } else if (DiagramType.USE_CASE_DIAGRAM.equals(diagramType)) {
        if (checkUseCaseDiagram(selection)) {
            return true;
        }
    } else if (DiagramType.SEQUENCE_DIAGRAM.equals(diagramType)) {
        if (checkSequenceDiagram(selection)) {
            return true;
        }
    } else if (DiagramType.COMPONENT_DIAGRAM.equals(diagramType)) {
        if (checkComponentDiagram(selection)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:SK-HOLDINGS-CC,項目名稱:NEXCORE-UML-Modeler,代碼行數:29,代碼來源:DiagramDropTargetListener.java

示例8: checkTreeSectionSource

import org.eclipse.jface.viewers.TreeSelection; //導入依賴的package包/類
/**
 * 트리에서 선택된 요소가 다이어그램에 놓을 수 있는 요소인지 검사한다.
 * 
 * 
 * @param selection
 * @return boolean
 */
protected boolean checkTreeSectionSource(TreeSelection selection) {
    DiagramType diagramType = diagramEditor.getDiagram().getType();
    if (DiagramType.CLASS_DIAGRAM.equals(diagramType)) {
        if (checkClassDiagram(selection)) {
            return true;
        }
    } else if (DiagramType.USE_CASE_DIAGRAM.equals(diagramType)) {
        if (checkUseCaseDiagram(selection)) {
            return true;
        }
    } else if (DiagramType.SEQUENCE_DIAGRAM.equals(diagramType)) {
        if (checkSequenceDiagram(selection)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:SK-HOLDINGS-CC,項目名稱:NEXCORE-UML-Modeler,代碼行數:25,代碼來源:DiagramRegerate.java

示例9: hierarchyCheck

import org.eclipse.jface.viewers.TreeSelection; //導入依賴的package包/類
/**
 * hierarchyCheck
 *  
 * @return boolean
 */
protected boolean hierarchyCheck() {
    CommonViewer commonViewer = ViewerRegistry.getViewer();
    TreeSelection sel = (TreeSelection) commonViewer.getSelection();

    List<TreePath> pathList = Arrays.asList(sel.getPaths());

    for (TreePath path : pathList) {
        if (isContains(pathList, path.getParentPath())) {
            MessageDialog.openError(ProjectExplorerPlugin.getShell(),
                UMLMessage.LABEL_FILE_FRAGMENTATION,
                UMLMessage.MESSAGE_FRAGMENT_DEFRAGMENT_ERROR_MESSAGE/*"패키지 간 상하 관계가 포함된 경우 일괄 단편화/병합을 실행할 수 없습니다."*/);
            return false;
        }
    }

    return true;
}
 
開發者ID:SK-HOLDINGS-CC,項目名稱:NEXCORE-UML-Modeler,代碼行數:23,代碼來源:BaseMultiFragmentAction.java

示例10: 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

示例11: doubleClick

import org.eclipse.jface.viewers.TreeSelection; //導入依賴的package包/類
@Override
public void doubleClick(final DoubleClickEvent event) {
	// safety check first
	if (event == null || event.getSelection() == null || !(event.getSelection() instanceof TreeSelection)) {
		return;
	}
	final TreeSelection selection = (TreeSelection) event.getSelection();
	final TreePath[] paths = selection.getPaths();
	final TreePath treePath = paths[paths.length - 1];
	final Object segment = treePath.getLastSegment();

	final TreeItem[] items = viewer.getTree().getItems();
	final TreeItem item = getItem(items, segment);
	if (item != null) {
		item.setExpanded(!item.getExpanded());
		viewer.refresh();
	}
}
 
開發者ID:FI13,項目名稱:afbb-bibo,代碼行數:19,代碼來源:TreeCollapseExpandListener.java

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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