本文整理汇总了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>();
}
示例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);
}
}
});
}
示例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);
}
}
});
}
示例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;
}
示例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) {
}
}
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
}
示例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;
}
}
示例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);
}
}
示例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();
}