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

The following are top voted examples for showing how to use org.eclipse.jface.viewers.IStructuredSelection. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: neoscada   File: AbstractQueryHandler.java   View source code 6 votes vote down vote up
protected Collection<QueryBean> getQueryList ()
{
    final IStructuredSelection sel = getSelection ();

    if ( sel == null )
    {
        return Collections.emptyList ();

    }

    final Collection<QueryBean> result = new LinkedList<QueryBean> ();
    final Iterator<?> i = sel.iterator ();
    while ( i.hasNext () )
    {
        final Object o = i.next ();
        if ( o instanceof QueryBean )
        {
            result.add ( (QueryBean)o );
        }
    }

    return result;
}
 
Example 2
Project: time4sys   File: OtherPropertiesEditionPartImpl.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addRServices() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(rServices.getInput(), rServicesFilters, rServicesBusinessFilters,
	"rServices", 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(OtherPropertiesEditionPartImpl.this, LibraryViewsRepository.Other.Properties.rServices,
					PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			rServices.refresh();
		}
	};
	dialog.open();
}
 
Example 3
Project: time4sys   File: OtherPropertiesEditionPartForm.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addExitServices() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(exitServices.getInput(),
			exitServicesFilters, exitServicesBusinessFilters, "exitServices",
			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(
						OtherPropertiesEditionPartForm.this, SrmViewsRepository.Other.Properties.exitServices,
						PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			exitServices.refresh();
		}
	};
	dialog.open();
}
 
Example 4
Project: time4sys   File: OtherPropertiesEditionPartImpl.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addDelayServices() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(delayServices.getInput(),
			delayServicesFilters, delayServicesBusinessFilters, "delayServices",
			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(
						OtherPropertiesEditionPartImpl.this, SrmViewsRepository.Other.Properties.delayServices,
						PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			delayServices.refresh();
		}
	};
	dialog.open();
}
 
Example 5
Project: time4sys   File: OtherPropertiesEditionPartImpl.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addRServices() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(rServices.getInput(), rServicesFilters, rServicesBusinessFilters,
	"rServices", 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(OtherPropertiesEditionPartImpl.this, GrmViewsRepository.Other.OtherProperties.rServices,
					PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			rServices.refresh();
		}
	};
	dialog.open();
}
 
Example 6
Project: time4sys   File: OtherPropertiesEditionPartImpl.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addReceiveServices() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(receiveServices.getInput(),
			receiveServicesFilters, receiveServicesBusinessFilters, "receiveServices",
			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(
						OtherPropertiesEditionPartImpl.this, SrmViewsRepository.Other.Properties.receiveServices,
						PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			receiveServices.refresh();
		}
	};
	dialog.open();
}
 
Example 7
Project: time4sys   File: TimingPropertiesEditionPartForm.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addMutualExclusionResources() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(mutualExclusionResources.getInput(),
			mutualExclusionResourcesFilters, mutualExclusionResourcesBusinessFilters, "mutualExclusionResources",
			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(TimingPropertiesEditionPartForm.this,
								SrmViewsRepository.Timing.Properties.mutualExclusionResources,
								PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			mutualExclusionResources.refresh();
		}
	};
	dialog.open();
}
 
Example 8
Project: neoscada   File: AbstractChartManagePart.java   View source code 6 votes vote down vote up
protected void handleSelectionChanged ( final ISelection sel )
{
    if ( sel == null || sel.isEmpty () )
    {
        return;
    }
    if ( ! ( sel instanceof IStructuredSelection ) )
    {
        return;
    }

    final Object o = ( (IStructuredSelection)sel ).getFirstElement ();
    if ( ! ( o instanceof ChartViewer ) )
    {
        return;
    }

    setChartViewer ( (ChartViewer)o );
}
 
Example 9
Project: time4sys   File: OtherPropertiesEditionPartForm.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addClearServices() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(clearServices.getInput(),
			clearServicesFilters, clearServicesBusinessFilters, "clearServices",
			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(
						OtherPropertiesEditionPartForm.this, SrmViewsRepository.Other.Properties.clearServices,
						PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			clearServices.refresh();
		}
	};
	dialog.open();
}
 
Example 10
Project: n4js   File: N4JSResourceLinkHelper.java   View source code 6 votes vote down vote up
@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);
}
 
Example 11
Project: convertigo-eclipse   File: CreateDocumentAction.java   View source code 6 votes vote down vote up
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)
			enable = ((ObjectsFolderTreeObject)treeObject).folderType == ObjectsFolderTreeObject.FOLDER_TYPE_DOCUMENTS;
		else 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) {}
}
 
Example 12
Project: time4sys   File: OtherPropertiesEditionPartImpl.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addReleaseServices() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(releaseServices.getInput(),
			releaseServicesFilters, releaseServicesBusinessFilters, "releaseServices",
			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(
						OtherPropertiesEditionPartImpl.this, SrmViewsRepository.Other.Properties.releaseServices,
						PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			releaseServices.refresh();
		}
	};
	dialog.open();
}
 
Example 13
Project: time4sys   File: OtherPropertiesEditionPartImpl.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addRoutineConnectServices() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(routineConnectServices.getInput(),
			routineConnectServicesFilters, routineConnectServicesBusinessFilters, "routineConnectServices",
			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(OtherPropertiesEditionPartImpl.this,
								SrmViewsRepository.Other.Properties.routineConnectServices,
								PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			routineConnectServices.refresh();
		}
	};
	dialog.open();
}
 
Example 14
Project: time4sys   File: OtherPropertiesEditionPartForm.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addOpenServices() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(openServices.getInput(),
			openServicesFilters, openServicesBusinessFilters, "openServices",
			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(
						OtherPropertiesEditionPartForm.this, SrmViewsRepository.Other.Properties.openServices,
						PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			openServices.refresh();
		}
	};
	dialog.open();
}
 
Example 15
Project: avro-schema-editor   File: SchemaRegistryView.java   View source code 6 votes vote down vote up
protected void updateToolbarOnSelectionChanged(ISelection selection) {
	IStructuredSelection sel = (IStructuredSelection) selection;
	NSNode selectedNode = null;
	if (sel.isEmpty()) {
		selectedNode = schemaRegistry.getNameSpaceTree();
	} else {
		Object element = sel.getFirstElement();
		if (element instanceof NSNode) {
			selectedNode = (NSNode) element;
		}
	}		
	for (NameSpaceAction action : actions) {
		action.setNSNode(selectedNode);				
	}
	toolbarMgr.update(true);
}
 
Example 16
Project: eclipse-bash-editor   File: BashEditor.java   View source code 6 votes vote down vote up
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();
			}
		}
	}
}
 
Example 17
Project: time4sys   File: GeneralPropertiesEditionPartImpl.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addUsedResource() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(usedResource.getInput(),
			usedResourceFilters, usedResourceBusinessFilters, "usedResource",
			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(
						GeneralPropertiesEditionPartImpl.this, GrmViewsRepository.General.Properties.usedResource,
						PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			usedResource.refresh();
		}
	};
	dialog.open();
}
 
Example 18
Project: time4sys   File: TimingPropertiesEditionPartImpl.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addTimers() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(timers.getInput(), timersFilters,
			timersBusinessFilters, "timers", 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(
						TimingPropertiesEditionPartImpl.this, SrmViewsRepository.Timing.Properties.timers,
						PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			timers.refresh();
		}
	};
	dialog.open();
}
 
Example 19
Project: pgsqlblocks   File: ProcessesController.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 20
Project: neoscada   File: ItemDragSourceListener.java   View source code 6 votes vote down vote up
@Override
public void dragStart ( final DragSourceEvent event )
{
    event.doit = false;

    if ( ! ( this.viewer.getSelection () instanceof IStructuredSelection ) )
    {
        return;
    }

    final Collection<Item> items = ItemSelectionHelper.getSelection ( this.viewer.getSelection () );
    if ( !items.isEmpty () )
    {
        LocalSelectionTransfer.getTransfer ().setSelection ( this.viewer.getSelection () );
        event.doit = true;
    }

}
 
Example 21
Project: time4sys   File: OtherPropertiesEditionPartForm.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addReleaseServices() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(releaseServices.getInput(),
			releaseServicesFilters, releaseServicesBusinessFilters, "releaseServices",
			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(
						OtherPropertiesEditionPartForm.this, SrmViewsRepository.Other.Properties.releaseServices,
						PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			releaseServices.refresh();
		}
	};
	dialog.open();
}
 
Example 22
Project: time4sys   File: OtherPropertiesEditionPartForm.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addUnmapServices() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(unmapServices.getInput(),
			unmapServicesFilters, unmapServicesBusinessFilters, "unmapServices",
			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(
						OtherPropertiesEditionPartForm.this, SrmViewsRepository.Other.Properties.unmapServices,
						PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			unmapServices.refresh();
		}
	};
	dialog.open();
}
 
Example 23
Project: SimQRI   File: ConveyorBeltPropertiesEditionPartForm.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addStorageOutputFlow() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(storageOutputFlow.getInput(), storageOutputFlowFilters, storageOutputFlowBusinessFilters,
	"storageOutputFlow", 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(ConveyorBeltPropertiesEditionPartForm.this, MetamodelViewsRepository.ConveyorBelt.Properties.storageOutputFlow,
					PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			storageOutputFlow.refresh();
		}
	};
	dialog.open();
}
 
Example 24
Project: SimQRI   File: BatchProcessPropertiesEditionPartForm.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addStorageOutputFlow() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(storageOutputFlow.getInput(), storageOutputFlowFilters, storageOutputFlowBusinessFilters,
	"storageOutputFlow", 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(BatchProcessPropertiesEditionPartForm.this, MetamodelViewsRepository.BatchProcess.Properties.storageOutputFlow,
					PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			storageOutputFlow.refresh();
		}
	};
	dialog.open();
}
 
Example 25
Project: neoscada   File: ItemDragSourceListener.java   View source code 6 votes vote down vote up
@Override
public void dragSetData ( final DragSourceEvent event )
{
    try
    {
        if ( ItemTransfer.getInstance ().isSupportedType ( event.dataType ) )
        {
            final IStructuredSelection selection = (IStructuredSelection)LocalSelectionTransfer.getTransfer ().getSelection ();
            final Collection<Item> items = ItemSelectionHelper.getSelection ( selection );
            event.data = items.toArray ( new Item[items.size ()] );
            event.doit = true;
        }
    }
    catch ( final Exception e )
    {
        logger.warn ( "Failed to set drag data", e );
        event.doit = false;
    }

}
 
Example 26
Project: SimQRI   File: SupplierPropertiesEditionPartImpl.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addRefillPolicy() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(refillPolicy.getInput(), refillPolicyFilters, refillPolicyBusinessFilters,
	"refillPolicy", 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(SupplierPropertiesEditionPartImpl.this, MetamodelViewsRepository.Supplier.Properties.refillPolicy,
					PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			refillPolicy.refresh();
		}
	};
	dialog.open();
}
 
Example 27
Project: convertigo-eclipse   File: DeleteDesignDocumentFunctionAction.java   View source code 6 votes vote down vote up
public void selectionChanged(IAction action, ISelection selection) {
	super.selectionChanged(action, selection);
	IStructuredSelection structuredSelection = (IStructuredSelection) selection;
	TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
	if (treeObject instanceof DesignDocumentFunctionTreeObject) {
		DesignDocumentFunctionTreeObject ddfto = (DesignDocumentFunctionTreeObject)treeObject;
		// filter function
		if (treeObject instanceof DesignDocumentFilterTreeObject) {
			action.setEnabled(true);
		}
		// update function
		else if (treeObject instanceof DesignDocumentUpdateTreeObject) {
			action.setEnabled(true);
		}
		// view function
		else {
			action.setEnabled(ddfto.getName().equals(CouchKey.reduce.key()));
		}
	}
}
 
Example 28
Project: time4sys   File: TimingPropertiesEditionPartForm.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addAccessTokenElements() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(accessTokenElements.getInput(),
			accessTokenElementsFilters, accessTokenElementsBusinessFilters, "accessTokenElements",
			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(TimingPropertiesEditionPartForm.this,
								SrmViewsRepository.Timing.Properties.accessTokenElements,
								PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			accessTokenElements.refresh();
		}
	};
	dialog.open();
}
 
Example 29
Project: eZooKeeper   File: BaseAction.java   View source code 6 votes vote down vote up
public boolean canRun() {

        InputType inputType = getInputType();

        if (inputType.isStructuredSelection()) {
            IStructuredSelection structuredSelection = getCurrentStructuredSelection();
            if (canRunWithStructuredSelection(structuredSelection)) {
                return true;
            }
        }
        else if (inputType.isEditorInput()) {

            IEditorPart editor = getActiveEditor();
            IEditorInput editorInput = (editor != null) ? editor.getEditorInput() : null;

            if (canRunWithEditorInput(editorInput)) {
                return true;
            }
        }
        else if (canRunWithNothing()) {
            return true;
        }

        return false;

    }
 
Example 30
Project: time4sys   File: GeneralPropertiesEditionPartForm.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addEndToEndStimuli() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(endToEndStimuli.getInput(),
			endToEndStimuliFilters, endToEndStimuliBusinessFilters, "endToEndStimuli",
			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(GeneralPropertiesEditionPartForm.this,
								GqamViewsRepository.General.Properties.endToEndStimuli,
								PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			endToEndStimuli.refresh();
		}
	};
	dialog.open();
}
 
Example 31
Project: bdf2   File: SelectClassPage.java   View source code 6 votes vote down vote up
/**
 * 当用户通过右键菜单启动向导时,初始化类选择列表
 * @param selection 当前选择项
 */
public void init(IStructuredSelection selection) {
	IJavaProject jProject = ProjectHelper.getCurrentJavaProject();
	if (jProject == null) {
		alertAndClose();
		return;
	}
	
	Map<String, List<String>> packageClassMap = new HashMap<String, List<String>>();
	setPackageClassMap(selection, packageClassMap);
	
	for(String packageName : packageClassMap.keySet()){
		List<String> classes = packageClassMap.get(packageName);
		if(classes.isEmpty()){
			nodeListManager.addNodesFromPackage(jProject, packageName, getFile(jProject, packageName).list());
		}else{
			nodeListManager.addNodesFromPackage(jProject, packageName, classes.toArray(new String[classes.size()]));
		}
	}
}
 
Example 32
Project: time4sys   File: OtherPropertiesEditionPartImpl.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addForkServices() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(forkServices.getInput(),
			forkServicesFilters, forkServicesBusinessFilters, "forkServices",
			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(
						OtherPropertiesEditionPartImpl.this, SrmViewsRepository.Other.Properties.forkServices,
						PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			forkServices.refresh();
		}
	};
	dialog.open();
}
 
Example 33
Project: gemoc-studio-modeldebugging   File: GemocToggleBreakpointHandler.java   View source code 6 votes vote down vote up
@Override
public boolean isEnabled() {
	final boolean res;
	
	ISelectionService service = (ISelectionService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(ISelectionService.class);
	if (service != null) {
		final ISelection selection = service.getSelection();
		if (selection instanceof IStructuredSelection) {
			boolean allValidMSE = true;
			final Iterator<?> it = ((IStructuredSelection) selection).iterator();
			while (allValidMSE && it.hasNext()) {
				Object current = it.next();
				allValidMSE = current instanceof MSE /*&& ((MSE) current).getAction() != null*/;
			}
			res = allValidMSE;
		} else {
			res = false;
		}
	} else {
		res = false;
	}
	
	return res;
}
 
Example 34
Project: time4sys   File: GeneralPropertiesEditionPartImpl.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addCause() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(cause.getInput(), causeFilters,
			causeBusinessFilters, "cause", 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(
						GeneralPropertiesEditionPartImpl.this, GqamViewsRepository.General.Properties.cause,
						PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			cause.refresh();
		}
	};
	dialog.open();
}
 
Example 35
Project: time4sys   File: GeneralPropertiesEditionPartForm.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addSchedulableResource() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(schedulableResource.getInput(),
			schedulableResourceFilters, schedulableResourceBusinessFilters, "schedulableResource",
			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(GeneralPropertiesEditionPartForm.this,
								GrmViewsRepository.General.Properties.schedulableResource,
								PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			schedulableResource.refresh();
		}
	};
	dialog.open();
}
 
Example 36
Project: time4sys   File: OtherPropertiesEditionPartImpl.java   View source code 6 votes vote down vote up
/**
 * 
 */
protected void addUnlockServices() {
	TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(unlockServices.getInput(),
			unlockServicesFilters, unlockServicesBusinessFilters, "unlockServices",
			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(
						OtherPropertiesEditionPartImpl.this, SrmViewsRepository.Other.Properties.unlockServices,
						PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
			}
			unlockServices.refresh();
		}
	};
	dialog.open();
}
 
Example 37
Project: n4js   File: LaunchXpectShortcut.java   View source code 5 votes vote down vote up
@Override
public void launch(ISelection selection, String mode) {
	try {
		Object selectObj = ((IStructuredSelection) selection).getFirstElement();
		if (selectObj instanceof IFile) {
			launchFile((IFile) selectObj, mode);
		} else {
			showDialogNotImplemented(selection.getClass().getName());
		}
	} catch (CoreException e) {
		System.out.println(e.getLocalizedMessage() + "\n");
	}
}
 
Example 38
Project: neoscada   File: SecurityModelWizard.java   View source code 5 votes vote down vote up
/**
 * This just records the information.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void init ( IWorkbench workbench, IStructuredSelection selection )
{
    this.workbench = workbench;
    this.selection = selection;
    setWindowTitle ( SecurityEditorPlugin.INSTANCE.getString ( "_UI_Wizard_label" ) ); //$NON-NLS-1$
    setDefaultPageImageDescriptor ( ExtendedImageRegistry.INSTANCE.getImageDescriptor ( SecurityEditorPlugin.INSTANCE.getImage ( "full/wizban/NewSecurity" ) ) ); //$NON-NLS-1$
}
 
Example 39
Project: n4js   File: OpenGeneratedSourceInEditorHandler.java   View source code 5 votes vote down vote up
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {

	final ISelection selection = getCurrentSelection(event);
	if (null == selection) {
		return null;
	}

	if (selection.isEmpty()) {
		return null;
	}

	final AtomicReference<IFile> fileRef = new AtomicReference<>();

	if (selection instanceof IStructuredSelection) {
		final Object element = ((IStructuredSelection) selection).getFirstElement();
		if (element instanceof IFile) {
			fileRef.set((IFile) element);
		}
	} else if (selection instanceof ITextSelection) {
		final IEditorPart editorPart = getActiveEditor(event);
		if (null != editorPart) {
			final IEditorInput input = editorPart.getEditorInput();
			if (input instanceof IFileEditorInput) {
				fileRef.set(((IFileEditorInput) input).getFile());
			}
		}
	}

	if (null != fileRef.get()) {
		final Optional<IFile> generatedSource = fileLocator.tryGetGeneratedSourceForN4jsFile(fileRef.get());
		if (generatedSource.isPresent()) {
			tryOpenFileInEditor(fileRef.get(), generatedSource.get());
		}
	}

	return null;
}
 
Example 40
Project: neoscada   File: RecipeEditor.java   View source code 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setStatusLineManager ( ISelection selection )
{
    IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ? contentOutlineStatusLineManager : getActionBars ().getStatusLineManager ();

    if ( statusLineManager != null )
    {
        if ( selection instanceof IStructuredSelection )
        {
            Collection<?> collection = ( (IStructuredSelection)selection ).toList ();
            switch ( collection.size () )
            {
                case 0:
                {
                    statusLineManager.setMessage ( getString ( "_UI_NoObjectSelected" ) ); //$NON-NLS-1$
                    break;
                }
                case 1:
                {
                    String text = new AdapterFactoryItemDelegator ( adapterFactory ).getText ( collection.iterator ().next () );
                    statusLineManager.setMessage ( getString ( "_UI_SingleObjectSelected", text ) ); //$NON-NLS-1$
                    break;
                }
                default:
                {
                    statusLineManager.setMessage ( getString ( "_UI_MultiObjectSelected", Integer.toString ( collection.size () ) ) ); //$NON-NLS-1$
                    break;
                }
            }
        }
        else
        {
            statusLineManager.setMessage ( "" ); //$NON-NLS-1$
        }
    }
}