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


Java IStructuredSelection.getFirstElement方法代碼示例

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


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

示例1: execute

import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);

	IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
	try {
		view = (N4IDEXpectView) windows[0].getActivePage().showView(
				N4IDEXpectView.ID);
	} catch (PartInitException e) {
		N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
	}

	Description desc = (Description) selection.getFirstElement();
	if (desc.isTest() && view.testsExecutionStatus.hasFailed(desc)) {
		Throwable failureException = view.testsExecutionStatus.getFailure(desc).getException();

		if (failureException instanceof ComparisonFailure) {
			ComparisonFailure cf = (ComparisonFailure) failureException;
			// display comparison view
			displayComparisonView(cf, desc);
		}
	}
	return null;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:26,代碼來源:XpectCompareCommandHandler.java

示例2: activateEditor

import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
@Override
public void activateEditor(final IWorkbenchPage page, final IStructuredSelection selection) {
	if (null != selection && !selection.isEmpty()) {
		final Object firstElement = selection.getFirstElement();
		if (firstElement instanceof ResourceNode) {
			final File fileResource = ((ResourceNode) firstElement).getResource();
			if (fileResource.exists() && fileResource.isFile()) {
				final URI uri = URI.createFileURI(fileResource.getAbsolutePath());
				final IResource resource = externalLibraryWorkspace.getResource(uri);
				if (resource instanceof IFile) {
					final IEditorInput editorInput = EditorUtils.createEditorInput(new URIBasedStorage(uri));
					final IEditorPart editor = page.findEditor(editorInput);
					if (null != editor) {
						page.bringToTop(editor);
						return;
					}
				}
			}
		}
	}
	super.activateEditor(page, selection);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:23,代碼來源:N4JSResourceLinkHelper.java

示例3: dbBlocksJournalViewSelectionChanged

import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
private void dbBlocksJournalViewSelectionChanged(SelectionChangedEvent event) {
    ISelection selection = event.getSelection();
    if (selection.isEmpty()) {
        dbBlocksJournalProcessInfoView.hide();
    } else {
        DBProcess process;
        IStructuredSelection structuredSelection = (IStructuredSelection)selection;
        Object element = structuredSelection.getFirstElement();
        if (element instanceof DBBlocksJournalProcess) {
            DBBlocksJournalProcess blocksJournalProcess = (DBBlocksJournalProcess)element;
            process = blocksJournalProcess.getProcess();
        } else {
            process = (DBProcess)element;
        }
        dbBlocksJournalProcessInfoView.show(process);
    }
}
 
開發者ID:technology16,項目名稱:pgsqlblocks,代碼行數:18,代碼來源:ProcessesController.java

示例4: selectionChanged

import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
public void selectionChanged(IAction action, ISelection selection) {
	super.selectionChanged(action, selection);
	IStructuredSelection structuredSelection = (IStructuredSelection) selection;
	TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
	if (treeObject instanceof StepTreeObject) {
		Step step = ((StepTreeObject) treeObject).getObject();
		if (step instanceof AttributeStep || step instanceof XMLAttributeStep) {
			action.setText("Attribute always output true.");
			action.setEnabled(false);
		} else {
			output = !step.isOutput();
			String actionText = output ? "Output true":"Output false";
			actionText += recurse ? " recursively":"";
			action.setText(actionText);
		}
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:18,代碼來源:OutputStepAction.java

示例5: openSelectedTreeItemInEditor

import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
public void openSelectedTreeItemInEditor(ISelection selection, boolean grabFocus) {
	if (selection instanceof IStructuredSelection) {
		IStructuredSelection ss = (IStructuredSelection) selection;
		Object firstElement = ss.getFirstElement();
		if (firstElement instanceof Item) {
			Item item = (Item) firstElement;
			int offset = item.getOffset();
			int length = item.getLength();
			if (length == 0) {
				/* fall back */
				length = 1;
			}
			ignoreNextCaretMove = true;
			selectAndReveal(offset, length);
			if (grabFocus) {
				setFocus();
			}
		}
	}
}
 
開發者ID:de-jcup,項目名稱:eclipse-bash-editor,代碼行數:21,代碼來源:BashEditor.java

示例6: GeneratorChoiceComposite

import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
public GeneratorChoiceComposite(Composite parent, int style, IStructuredSelection selection, Listener listener) {
	super(parent, style);

	setLayout(new GridLayout(12, false));
	GridData gridData = new GridData();
	gridData.horizontalAlignment = GridData.FILL;
	gridData.grabExcessHorizontalSpace = true;
	setLayoutData(gridData);

	this.listener = listener;
	this.selection = selection;
	IFile file = (IFile) selection.getFirstElement();
	loadAncestor(file);
	findStartElement () ;
	Label explanationLabel = new Label(this, SWT.NONE);
	explanationLabel.setLayoutData(new GridData(SWT.FILL));
	explanationLabel.setText(MessageUtil.getString("three_modes_explanation"));

	skip(this);

	createAppendMode();
	createExtendMode();
	createNewMode();

}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:26,代碼來源:GeneratorChoiceComposite.java

示例7: execute

import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
@Override
protected Object execute(SchemaRegistryView registryView, AvroSchemaEditor editor, ExecutionEvent event) {
	
	IStructuredSelection selection = (IStructuredSelection) registryView.getSelection();
	
	if (!selection.isEmpty()) {
		Object element = selection.getFirstElement();
		if (element instanceof AvroNode) {
			AvroNode node = (AvroNode) element;
			SchemaViewer masterViewer = editor.getContentPart().getSchemaViewer(AvroContext.Kind.MASTER);
			masterViewer.setSelection(new StructuredSelection(node));
			masterViewer.reveal(node);
		}
	}
	
	return null;
}
 
開發者ID:Talend,項目名稱:avro-schema-editor,代碼行數:18,代碼來源:ShowInEditorHandler.java

示例8: selectionChanged

import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
public void selectionChanged(IAction action, ISelection selection) {
	try {
		boolean enable = true;
		super.selectionChanged(action, selection);
		IStructuredSelection structuredSelection = (IStructuredSelection) selection;
		TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
		if (treeObject instanceof ObjectsFolderTreeObject) {
			ObjectsFolderTreeObject ofto = (ObjectsFolderTreeObject)treeObject;
			enable = ofto.folderType == ObjectsFolderTreeObject.FOLDER_TYPE_VARIABLES;
			treeObject = ofto.getParent();
		}
		if (enable && treeObject instanceof DatabaseObjectTreeObject) {
			DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
			ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
			enable = actionModel.isEnabled;
		}
		action.setEnabled(enable);
	}
	catch (Exception e) {}
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:21,代碼來源:CreateVariableAction.java

示例9: selectionChanged

import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
public void selectionChanged(IAction action, ISelection selection) {
	super.selectionChanged(action, selection);
	IStructuredSelection structuredSelection = (IStructuredSelection) selection;
	TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
	if (treeObject instanceof DesignDocumentViewTreeObject) {
		DesignDocumentViewTreeObject ddvto = (DesignDocumentViewTreeObject)treeObject;
		action.setText(CouchKey.reduce.key() + " function");
		action.setEnabled(!ddvto.hasReduce());
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:11,代碼來源:CreateDesignDocumentViewReduceAction.java

示例10: getDetailPaneTypes

import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
@Override
public Set<String> getDetailPaneTypes(IStructuredSelection selection) {
	final Set<String> res = new HashSet<String>();

	final IBreakpoint breakpoint = (IBreakpoint) selection
			.getFirstElement();
	if (breakpoint instanceof DSLBreakpoint) {
		res.add(GemocBreakpointDetailPane.PANEL_TYPE);
	}

	return res;
}
 
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:13,代碼來源:BreakpointDetailPaneFactory.java

示例11: selectionChanged

import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
public void selectionChanged(IAction action, ISelection selection) {
	super.selectionChanged(action, selection);
	IStructuredSelection structuredSelection = (IStructuredSelection) selection;
	TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
	if (treeObject instanceof ConnectorTreeObject) {
		DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
		ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
		action.setChecked(actionModel.isChecked);
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:11,代碼來源:SetDefaultConnectorAction.java

示例12: selectionChanged

import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
public void selectionChanged(IAction action, ISelection selection) {
	super.selectionChanged(action, selection);
	IStructuredSelection structuredSelection = (IStructuredSelection) selection;
	TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
	if (treeObject instanceof MobilePageComponentTreeObject) {
		DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
		ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
		action.setChecked(actionModel.isChecked);
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:11,代碼來源:SetMobileRootPageAction.java

示例13: selectionChanged

import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
public void selectionChanged(IAction action, ISelection selection) {
	try {
		boolean enable = false;
		super.selectionChanged(action, selection);
		IStructuredSelection structuredSelection = (IStructuredSelection) selection;
		TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
		if (treeObject instanceof DatabaseObjectTreeObject) {
			DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
			ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
			enable = actionModel.isEnabled;
		}
		action.setEnabled(enable);
	}
	catch (Exception e) {}
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:16,代碼來源:ChangeToElementStepAction.java

示例14: run

import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
@Override
public void run() {
	super.run();
	IStructuredSelection currentSelectedComponent = (IStructuredSelection) getSelection();
	if (currentSelectedComponent.getFirstElement() instanceof ComponentEditPart) {
		ComponentEditPart componentEditPart = ((ComponentEditPart) currentSelectedComponent.getFirstElement());
		Object componentModel=componentEditPart.getCastedModel();
		ELTPropertyWindow eltPropertyWindow = new ELTPropertyWindow(componentModel);
		eltPropertyWindow.open(); 
		
		componentEditPart.updateComponentView(eltPropertyWindow);
	}
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:14,代碼來源:ComponentPropertiesAction.java

示例15: selectionChanged

import org.eclipse.jface.viewers.IStructuredSelection; //導入方法依賴的package包/類
public void selectionChanged(IAction action, ISelection selection) {
	super.selectionChanged(action, selection);
	IStructuredSelection structuredSelection = (IStructuredSelection) selection;
	TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
	if (treeObject instanceof DesignDocumentTreeObject) {
		action.setText(((DesignDocumentTreeObject)treeObject).getDefaultViewName());
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:9,代碼來源:CreateDesignDocumentViewAction.java


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