Java Code Examples for org.eclipse.jface.viewers.IStructuredSelection

The following examples show how to use org.eclipse.jface.viewers.IStructuredSelection. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: eip-designer   Author: lbroudoux   File: InvocableEndpointPropertiesEditionPartImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 
 */
protected void addToChannels() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(toChannels.getInput(), toChannelsFilters, toChannelsBusinessFilters,
	"toChannels", propertiesEditionComponent.getEditingContext().getAdapterFactory(), current.eResource()) {
		@Override
		public void process(IStructuredSelection selection) {
			for (Iterator<?> iter = selection.iterator(); iter.hasNext();) {
				EObject elem = (EObject) iter.next();
				propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(InvocableEndpointPropertiesEditionPartImpl.this, EipViewsRepository.InvocableEndpoint.Properties.toChannels,
					PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			toChannels.refresh();
		}
	};
	dialog.open();
}
 
Example #2
Source Project: eip-designer   Author: lbroudoux   File: ContentFilterPropertiesEditionPartForm.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 
 */
protected void addToChannels() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(toChannels.getInput(), toChannelsFilters, toChannelsBusinessFilters,
	"toChannels", propertiesEditionComponent.getEditingContext().getAdapterFactory(), current.eResource()) {
		@Override
		public void process(IStructuredSelection selection) {
			for (Iterator<?> iter = selection.iterator(); iter.hasNext();) {
				EObject elem = (EObject) iter.next();
				propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ContentFilterPropertiesEditionPartForm.this, EipViewsRepository.ContentFilter.Properties.toChannels,
					PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			toChannels.refresh();
		}
	};
	dialog.open();
}
 
Example #3
Source Project: eclipse-cs   Author: checkstyle   File: CheckConfigurationConfigureDialog.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Opens the module editor for the current selection.
 *
 * @param selection
 *          the selection
 */
private void openModule(ISelection selection) {

  Module m = (Module) ((IStructuredSelection) selection).getFirstElement();
  if (m != null) {

    Module workingCopy = m.clone();

    RuleConfigurationEditDialog dialog = new RuleConfigurationEditDialog(getShell(),
            workingCopy, !mConfigurable,
            Messages.CheckConfigurationConfigureDialog_titleModuleConfigEditor);
    if (Window.OK == dialog.open() && mConfigurable) {
      mModules.set(mModules.indexOf(m), workingCopy);
      mIsDirty = true;
      mTableViewer.refresh(true);
      refreshTableViewerState();
    }
  }
}
 
Example #4
Source Project: xtext-eclipse   Author: eclipse   File: OutlineTreeState.java    License: Eclipse Public License 2.0 6 votes vote down vote up
protected Set<IOutlineNode> getSelectedNodes(final TreeViewer treeViewer) {
	DisplayRunHelper.runSyncInDisplayThread(new Runnable() {
		@Override
		public void run() {
			selectedNodes = Sets.newHashSet();
			ISelection selection = treeViewer.getSelection();
			if (selection instanceof IStructuredSelection) {
				for (Iterator<?> selectionIter = ((IStructuredSelection) selection).iterator(); selectionIter
						.hasNext();) {
					Object selectedElement = selectionIter.next();
					if (!(selectedElement instanceof IOutlineNode))
						LOG.error("Content outline contains illegal node " + selectedElement);
					else
						selectedNodes.add((IOutlineNode) selectedElement);
				}
			}
		}
	});
	return selectedNodes;
}
 
Example #5
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: FatJarPackageWizard.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @return all java projects which contain the selected elements in the active workbench window
 */
protected IStructuredSelection getSelectedJavaProjects() {
	ISelection currentSelection= JavaPlugin.getActiveWorkbenchWindow().getSelectionService().getSelection();
	if (currentSelection instanceof IStructuredSelection) {
		IStructuredSelection structuredSelection= (IStructuredSelection) currentSelection;
		HashSet<IJavaProject> selectedElements= new HashSet<IJavaProject>();
		Iterator<?> iter= structuredSelection.iterator();
		while (iter.hasNext()) {
			Object selectedElement= iter.next();
			if (selectedElement instanceof IJavaElement) {
				IJavaProject javaProject= ((IJavaElement) selectedElement).getJavaProject();
				if (javaProject != null)
					selectedElements.add(javaProject);
			}
		}
		return new StructuredSelection(selectedElements);
	} else
		return StructuredSelection.EMPTY;
}
 
Example #6
Source Project: translationstudio8   Author: heartsome   File: XmlConvertManagerDialog.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 编辑选中的元素 ;
 */
protected void editElement() {
	ISelection selection = tableViewer.getSelection();
	if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
		IStructuredSelection structuredSelection = (IStructuredSelection) selection;
		@SuppressWarnings("unchecked")
		Iterator<ElementBean> iter = structuredSelection.iterator();
		ElementBean bean = iter.next();

		AddOrEditElementOfXmlConvertDialog dialog = new AddOrEditElementOfXmlConvertDialog(getShell(), false,
				elementsList);
		dialog.create();
		dialog.setInitEditData(bean);
		int result = dialog.open();
		if (result == IDialogConstants.OK_ID) {
			refreshTable(dialog.getCurrentElement());
		}
	} else {
		MessageDialog.openInformation(getShell(), Messages.getString("dialogs.XmlConvertManagerDialog.msgTitle2"),
				Messages.getString("dialogs.XmlConvertManagerDialog.msg3"));
	}
}
 
Example #7
Source Project: xtext-eclipse   Author: eclipse   File: XbaseBreakpointDetailPaneFactory.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Set<String> getDetailPaneTypes(IStructuredSelection selection) {
	prioritizer.prioritizeXbaseOverJdt();
	if (selection.size() == 1) {
		Object selectedElement = selection.getFirstElement();
		if (selectedElement instanceof IBreakpoint) {
			IBreakpoint b = (IBreakpoint) selectedElement;
			try {
				Object sourceUri = b.getMarker().getAttribute(StratumBreakpointAdapterFactory.ORG_ECLIPSE_XTEXT_XBASE_SOURCE_URI);
				if (sourceUri != null) {
					return Collections.singleton(XBASE_DETAIL_PANE);
				}
			} catch (CoreException e) {}
		}
	}
	return Collections.emptySet();
}
 
Example #8
Source Project: eip-designer   Author: lbroudoux   File: RecipientListRouterPropertiesEditionPartImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 
 */
protected void addFromChannels() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(fromChannels.getInput(), fromChannelsFilters, fromChannelsBusinessFilters,
	"fromChannels", propertiesEditionComponent.getEditingContext().getAdapterFactory(), current.eResource()) {
		@Override
		public void process(IStructuredSelection selection) {
			for (Iterator<?> iter = selection.iterator(); iter.hasNext();) {
				EObject elem = (EObject) iter.next();
				propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(RecipientListRouterPropertiesEditionPartImpl.this, EipViewsRepository.RecipientListRouter.Properties.fromChannels,
					PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			fromChannels.refresh();
		}
	};
	dialog.open();
}
 
Example #9
Source Project: tmxeditor8   Author: heartsome   File: PropertiesView.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
	if (part == null || selection == null) {
		return;
	}
	if (!(part instanceof TmxEditorViewer)) {
		return;
	}
	if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) {
		return;
	}
	// tgtLangcodeInTmxEditor = TmxEditorViewer.getInstance().getTmxEditor().getTgtLang();
	StructuredSelection struct = (StructuredSelection) selection;
	Object obj = struct.getFirstElement();
	if (obj instanceof TmxEditorSelection) {
		currentSelected = (TmxEditorSelection) obj;
		tableViewerManager.get(TU_ATTRS).setInput(new TableViewerInput(TU_ATTRS, currentSelected));
		tableViewerManager.get(TUV_ATTRS).setInput(new TableViewerInput(TUV_ATTRS, currentSelected));
		tableViewerManager.get(TU_NODE_NOTE).setInput(null);
		tableViewerManager.get(TU_NODE_NOTE).setInput(new TableViewerInput(TU_NODE_NOTE, currentSelected));
		tableViewerManager.get(TU_NODE_PROPS).setInput(new TableViewerInput(TU_NODE_PROPS, currentSelected));
		compostie.layout();
		scrolledComposite.setMinSize(compostie.computeSize(SWT.DEFAULT, SWT.DEFAULT));
	}
}
 
Example #10
Source Project: tmxeditor8   Author: heartsome   File: TmDbManagerDialog.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 当使用该对话框作为数据库选择时 ;
 */
private void executeSelectDatabase() {
	ISelection selection = getDbTableViewer().getSelection();
	if (selection.isEmpty()) {
		return;
	}
	hasSelected = new HashMap<DatabaseModelBean, String>();
	IStructuredSelection structuredSelection = (IStructuredSelection) selection;

	Iterator<?> it = structuredSelection.iterator();
	while (it.hasNext()) {
		DatabaseManagerDbListBean dbBean = (DatabaseManagerDbListBean) it.next();
		DatabaseModelBean dbModelBean = new DatabaseModelBean();
		currServer.copyToOtherIntance(dbModelBean);
		dbModelBean.setDbName(dbBean.getDbName());
		hasSelected.put(dbModelBean, dbBean.getLangs());
	}
}
 
Example #11
Source Project: neoscada   Author: eclipse   File: AbstractItemHandler.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Get all items from the selection
 *
 * @return a data of all selected items
 */
protected Collection<Item> getItems ()
{
    final Collection<Item> result = new LinkedList<Item> ();

    final IStructuredSelection sel = getSelection ();

    if ( sel != null && !sel.isEmpty () )
    {
        for ( final Iterator<?> i = sel.iterator (); i.hasNext (); )
        {
            final Object o = i.next ();

            final Item holder = AdapterHelper.adapt ( o, Item.class );
            if ( holder != null )
            {
                result.add ( holder );
            }
        }
    }

    return result;
}
 
Example #12
Source Project: APICloud-Studio   Author: apicloudcom   File: MergeFileAssociationPreferencePage.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void removeFileType() {
	associationsUpdated = true;
	ArrayList associationsList = new ArrayList();
	for (int i = 0; i < mergeFileAssociations.length; i++) associationsList.add(mergeFileAssociations[i]);
	IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
	Iterator iter = selection.iterator();
	while (iter.hasNext()) {
		associationsList.remove(iter.next());
	}
	mergeFileAssociations = new MergeFileAssociation[associationsList.size()];
	associationsList.toArray(mergeFileAssociations);
	viewer.refresh();
	builtInMergeRadioButton.setSelection(false);
	externalMergeRadioButton.setSelection(false);
	customMergeRadioButton.setSelection(false);
	customProgramLocationCombo.setText(""); //$NON-NLS-1$
	customProgramParametersText.setText(""); //$NON-NLS-1$
}
 
Example #13
Source Project: tmxeditor8   Author: heartsome   File: LanguageCodesPreferencePage.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 根据当前选择的语言,更新数字、货币等的显示示例
 * @param selection
 *            ;
 */
protected void refreshFormatControls(IStructuredSelection selection) {
	Object firstSelected = selection.getFirstElement();
	if (firstSelected instanceof Language) {
		Language language = (Language) firstSelected;
		digitalValue.setText(language.getName());
		digitalValue.setToolTipText(language.getName());

		currencyValue.setText(language.getName());
		currencyValue.setToolTipText(language.getName());

		timeValue.setText(language.getName());
		timeValue.setToolTipText(language.getName());

		shortDateValue.setText(language.getName());
		shortDateValue.setToolTipText(language.getName());

		longDateValue.setText(language.getName());
		longDateValue.setToolTipText(language.getName());
	}
}
 
Example #14
Source Project: APICloud-Studio   Author: apicloudcom   File: TeamAction.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void selectionChanged(IAction action, ISelection sel) {
	if (sel instanceof IStructuredSelection) {
		this.selection = (IStructuredSelection) sel;
		if (action != null) {
			setActionEnablement(action);
		}
	}
	if (sel instanceof ITextSelection){
			IEditorPart part = getTargetPage().getActiveEditor();
			if (part != null) {
				IEditorInput input = part.getEditorInput();
				IResource r = (IResource) input.getAdapter(IResource.class);
				if (r != null) {
					switch(r.getType()){
						case IResource.FILE:
							this.selection = new StructuredSelection(r);
							if (action != null) {
								setActionEnablement(action);
							}
						break;
					}
				}	//	set selection to current editor file;
			}
	}
}
 
Example #15
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: JavaCompareAction.java    License: Eclipse Public License 1.0 6 votes vote down vote up
protected boolean isEnabled(ISelection selection) {
	if (selection instanceof IStructuredSelection) {
		Object[] sel= ((IStructuredSelection) selection).toArray();
		if (sel.length == 2) {
			for (int i= 0; i < 2; i++) {
				Object o= sel[i];
				if (!(o instanceof ISourceReference))
					return false;
			}
			fLeft= (ISourceReference) sel[0];
			fRight= (ISourceReference) sel[1];
			return true;
		}
	}
	return false;
}
 
Example #16
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: JavaBrowsingPart.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private void saveSelectionState(IMemento memento) {
	Object elements[]= ((IStructuredSelection) fViewer.getSelection()).toArray();
	if (elements.length > 0) {
		IMemento selectionMem= memento.createChild(TAG_SELECTED_ELEMENTS);
		for (int i= 0; i < elements.length; i++) {
			IMemento elementMem= selectionMem.createChild(TAG_SELECTED_ELEMENT);
			Object o= elements[i];
			if (o instanceof IJavaElement)
				elementMem.putString(TAG_SELECTED_ELEMENT_PATH, ((IJavaElement) elements[i]).getHandleIdentifier());
			else if (o instanceof LogicalPackage) {
				IPackageFragment[] packages=((LogicalPackage)o).getFragments();
				for (int j= 0; j < packages.length; j++) {
					IMemento packageMem= elementMem.createChild(TAG_LOGICAL_PACKAGE);
					packageMem.putString(TAG_SELECTED_ELEMENT_PATH, packages[j].getHandleIdentifier());
				}
			}
		}
	}
}
 
Example #17
Source Project: eip-designer   Author: lbroudoux   File: GatewayPropertiesEditionPartForm.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 
 */
protected void addFromChannels() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(fromChannels.getInput(), fromChannelsFilters, fromChannelsBusinessFilters,
	"fromChannels", propertiesEditionComponent.getEditingContext().getAdapterFactory(), current.eResource()) {
		@Override
		public void process(IStructuredSelection selection) {
			for (Iterator<?> iter = selection.iterator(); iter.hasNext();) {
				EObject elem = (EObject) iter.next();
				propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(GatewayPropertiesEditionPartForm.this, EipViewsRepository.Gateway.Properties.fromChannels,
					PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			fromChannels.refresh();
		}
	};
	dialog.open();
}
 
Example #18
Source Project: gama   Author: gama-platform   File: RevealInWorkspace.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
	final IStructuredSelection sel = HandlerUtil.getCurrentStructuredSelection(event);
	if (sel.isEmpty()) { return null; }
	final IWorkbenchPart part = HandlerUtil.getActivePart(event);
	if (!(part instanceof GamaNavigator)) { return null; }
	final GamaNavigator nav = (GamaNavigator) part;
	final List<Object> selection = sel.toList();
	final List<WrappedFile> newSelection = new ArrayList<>();
	for (final Object o : selection) {
		if (o instanceof LinkedFile) {
			newSelection.add(((LinkedFile) o).getTarget());
		}
	}
	if (newSelection.isEmpty()) { return null; }
	nav.selectReveal(new StructuredSelection(newSelection));
	return this;
}
 
Example #19
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: InferTypeArgumentsAction.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run(IStructuredSelection selection) {
	IJavaElement[] elements= getSelectedElements(selection);
	try {
		if (! ActionUtil.areProcessable(getShell(), elements))
			return;

		if (RefactoringAvailabilityTester.isInferTypeArgumentsAvailable(elements)) {
			RefactoringExecutionStarter.startInferTypeArgumentsRefactoring(elements, getShell());
		} else {
			MessageDialog.openInformation(getShell(), RefactoringMessages.OpenRefactoringWizardAction_unavailable, RefactoringMessages.InferTypeArgumentsAction_unavailable);
		}
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
	}
}
 
Example #20
public static boolean isPullUpAvailable(final IStructuredSelection selection) throws JavaModelException {
	if (!selection.isEmpty()) {
		if (selection.size() == 1) {
			if (selection.getFirstElement() instanceof ICompilationUnit)
				return true; // Do not force opening
			final IType type= getSingleSelectedType(selection);
			if (type != null)
				return Checks.isAvailable(type) && isPullUpAvailable(new IType[] { type});
		}
		for (final Iterator<?> iterator= selection.iterator(); iterator.hasNext();) {
			if (!(iterator.next() instanceof IMember))
				return false;
		}
		final Set<IMember> members= new HashSet<IMember>();
		@SuppressWarnings("unchecked")
		List<IMember> selectionList= (List<IMember>) (List<?>) Arrays.asList(selection.toArray());
		members.addAll(selectionList);
		return isPullUpAvailable(members.toArray(new IMember[members.size()]));
	}
	return false;
}
 
Example #21
Source Project: tlaplus   Author: tlaplus   File: ToolboxExplorer.java    License: MIT License 6 votes vote down vote up
/**
 * Open on double-click
 */
protected void handleDoubleClick(DoubleClickEvent anEvent)
{
    super.handleDoubleClick(anEvent);
    // open the model
    if (anEvent.getSelection() instanceof IStructuredSelection) {
    	IStructuredSelection iss = (IStructuredSelection) anEvent.getSelection();
    	Object firstElement = iss.getFirstElement();
    	if (firstElement instanceof Module) {
    		final Map<String, String> parameters = new HashMap<String, String>();
    		parameters.put(OpenModuleHandler.PARAM_MODULE, ((Module) firstElement).getModuleName());
UIHelper.runCommand(OpenModuleHandler.COMMAND_ID, parameters);
    	} else if (firstElement instanceof IGroup) {
    		// No-Op
    	} else if (firstElement instanceof Spec && ((Spec) firstElement).isCurrentSpec()) {
    		// No-op, do not re-open an open spec again.
    	} else {
    		UIHelper.runCommand(ToolboxExplorer.COMMAND_ID, new HashMap<String, String>());
    	}
    }
}
 
Example #22
Source Project: n4js   Author: eclipse   File: N4JSProjectActionGroup.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private void performSelectionChanged(final IStructuredSelection structuredSelection) {
	final Object[] array = structuredSelection.toArray();
	final ArrayList<IProject> openProjects = new ArrayList<>();
	final int selectionStatus = evaluateSelection(array, openProjects);
	final StructuredSelection sel = new StructuredSelection(openProjects);

	// If only projects are selected, disable this action group, as all of
	// the project-related contributions will be provided by default action providers
	enableContribution = (selectionStatus & NON_PROJECT_SELECTED) != 0;

	openAction.setEnabled(hasClosedProjectsInWorkspace());
	enableOpenInContextMenu = (selectionStatus & CLOSED_PROJECTS_SELECTED) != 0
			|| (selectionStatus == 0 && array.length == 0 && hasClosedProjectsInWorkspace());
	closeAction.selectionChanged(sel);
	closeUnrelatedAction.selectionChanged(sel);
}
 
Example #23
Source Project: birt   Author: eclipse   File: CutAction.java    License: Eclipse Public License 1.0 6 votes vote down vote up
protected DeleteAction createDeleteAction( final Object objects )
{
	return new DeleteAction( objects ) {

		/*
		 * (non-Javadoc)
		 * 
		 * @see org.eclipse.birt.report.designer.internal.ui.views.actions.DeleteAction#getTransactionLabel()
		 */
		protected String getTransactionLabel( )
		{
			if ( objects instanceof IStructuredSelection )
			{
				return Messages.getString( "CutAction.trans" ); //$NON-NLS-1$
			}
			return DEFAULT_TEXT + " " + DEUtil.getDisplayLabel( objects ); //$NON-NLS-1$
		}
	};
}
 
Example #24
protected void editCurrentElement() {
	IStructuredSelection selection= (IStructuredSelection) fTreeViewer.getSelection();
	if ( (selection != null) && isSimilarElement(selection.getFirstElement())) {
		IJavaElement element= (IJavaElement) selection.getFirstElement();
		String newName= fSimilarElementsToNewName.get(element);
		if (newName == null)
			return;
		EditElementDialog dialog= new EditElementDialog(getShell(), element, newName);
		if (dialog.open() == Window.OK) {
			String changedName= dialog.getNewName();
			if (!changedName.equals(newName)) {
				fSimilarElementsToNewName.put(element, changedName);
				fTreeViewer.update(element, null);
			}
		}
	}
}
 
Example #25
Source Project: M2Doc   Author: ObeoNetwork   File: GenconfEditorLauncher.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void open(IPath file) {
    final IWorkbench workbench = PlatformUI.getWorkbench();
    final Shell shell = workbench.getActiveWorkbenchWindow().getShell();
    final ISelection selection = workbench.getActiveWorkbenchWindow().getSelectionService().getSelection();

    if (selection instanceof IStructuredSelection) {
        openNewGenerationWizard(workbench, shell, (IStructuredSelection) selection);
    }
}
 
Example #26
Source Project: eclipse-cs   Author: checkstyle   File: SimpleFileSetsEditor.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void selectionChanged(SelectionChangedEvent event) {
  IStructuredSelection selection = (IStructuredSelection) event.getSelection();
  ICheckConfiguration config = (ICheckConfiguration) selection.getFirstElement();

  if (config != null) {
    mDefaultFileSet.setCheckConfig(config);
    mTxtConfigDescription
            .setText(config.getDescription() != null ? config.getDescription() : ""); //$NON-NLS-1$
  } else {
    mComboViewer.setSelection(new StructuredSelection(mComboViewer.getElementAt(0)));
  }

  mPropertyPage.getContainer().updateButtons();
}
 
Example #27
private IField[] getSelectedFields(IStructuredSelection selection) {
	List<?> elements= selection.toList();
	if (elements.size() > 0) {
		IField[] fields= new IField[elements.size()];
		ICompilationUnit unit= null;
		for (int index= 0; index < elements.size(); index++) {
			if (elements.get(index) instanceof IField) {
				IField field= (IField) elements.get(index);
				if (index == 0) {
					// remember the CU of the first element
					unit= field.getCompilationUnit();
					if (unit == null) {
						return null;
					}
				} else if (!unit.equals(field.getCompilationUnit())) {
					// all fields must be in the same CU
					return null;
				}
				try {
					final IType declaringType= field.getDeclaringType();
					if (declaringType.isInterface() || declaringType.isAnnotation() || declaringType.isAnonymous())
						return null;
				} catch (JavaModelException exception) {
					JavaPlugin.log(exception);
					return null;
				}
				fields[index]= field;
			} else {
				return null;
			}
		}
		return fields;
	}
	return null;
}
 
Example #28
Source Project: tmxeditor8   Author: heartsome   File: TermDbManagerDialog.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 初始化树右键菜单 ;
 */
private void initTreePopMenu() {
	MenuManager menuManager = new MenuManager("");
	menuManager.add(new Action(Messages.getString("dialog.TermDbManagerDialog.deleteAction")) {
		@Override
		public void run() {
			ISelection selection = getTreeViewer().getSelection();
			if (selection.isEmpty()) {
				return;
			}
			IStructuredSelection structuredSelection = (IStructuredSelection) selection;
			Object obj = structuredSelection.getFirstElement();
			if (obj instanceof DatabaseModelBean) {
				List<DatabaseModelBean> currDbTypeServers = treeInputMap.get(currDbType);
				configer.deleteServerById(((DatabaseModelBean) obj).getId());
				int i = currDbTypeServers.indexOf(obj);
				currDbTypeServers.remove(i);
				getTreeViewer().refresh();
				// selectSaveItem();
				// setLastSelectedServer(null);

				if (currDbTypeServers.size() != 0) {
					if (i > currDbTypeServers.size() - 1) {
						setLastSelectedServer(currDbTypeServers.get(i - 1).getId());
					} else {
						setLastSelectedServer(currDbTypeServers.get(i).getId());
					}
					initUI(false);
				} else {
					setLastSelectedServer(null);
					initUI(true);
				}
				selectSaveItem();

			}
		}
	});
	Tree tree = treeViewer.getTree();
	this.treePopMenu = menuManager.createContextMenu(tree);
}
 
Example #29
Source Project: tesb-studio-se   Author: Talend   File: ServicesButtonPart.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void buttonSelected(SelectionEvent e) {
    RepositoryReviewDialog dialog = new RepositoryReviewDialog(getShell(), ERepositoryObjectType.METADATA,
            "SERVICES:OPERATION") {

        @Override
        protected boolean isSelectionValid(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection.size() == 1) {
                return true;
            }
            return false;
        }

        @Override
        protected Control createDialogArea(Composite parent) {
            return createDialogArea(parent, "org.talend.rcp.perspective");
        }
    };

    int open = dialog.open();
    if (open == Dialog.OK) {
        RepositoryNode result = dialog.getResult();
        if (result != null) {
            listener.serviceNodeSelected(result);
        }
    }
}
 
Example #30
Source Project: neoscada   Author: eclipse   File: VisualInterfaceModelWizard.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This just records the information.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public void init ( final IWorkbench workbench, final IStructuredSelection selection )
{
    this.workbench = workbench;
    this.selection = selection;
    setWindowTitle ( VisualInterfaceEditorPlugin.INSTANCE.getString ( "_UI_Wizard_label" ) ); //$NON-NLS-1$
    setDefaultPageImageDescriptor ( ExtendedImageRegistry.INSTANCE.getImageDescriptor ( VisualInterfaceEditorPlugin.INSTANCE.getImage ( "full/wizban/NewVisualInterface.png" ) ) ); //$NON-NLS-1$
}