本文整理匯總了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();
}