@Override public IPropertySource getPropertySource ( final Object object ) { // this one has priority in super class if ( object instanceof IPropertySource ) { return (IPropertySource)object; } // allow the object to adapt to IPropertySource if ( object instanceof EObject && ( (EObject)object ).eClass () != null ) { final IPropertySource propertySource = (IPropertySource)this.adapterFactory.adapt ( object, IPropertySource.class ); if ( propertySource != null ) { return propertySource; } } // fall back to default behavior return super.getPropertySource ( object ); }
@Override public Object getAdapter(Class key) { if (key == SnapToHelper.class) { List<SnapToHelper> helpers = new ArrayList<SnapToHelper>(); if (Boolean.TRUE.equals(getViewer().getProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED))) { helpers.add(new SnapToGeometry(this)); } if (Boolean.TRUE.equals(getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ENABLED))) { helpers.add(new SnapToGrid(this)); } if(helpers.size()==0) { return null; } else { return new CompoundSnapToHelper(helpers.toArray(new SnapToHelper[0])); } } if (key == IPropertySource.class) { return new GW4EGraphEditPartProperties(this); } return null; }
public void handleEvent(Event e) { if (!notification) return; EdgeGW4EEditPartProperties properties = (EdgeGW4EEditPartProperties) node .getAdapter(IPropertySource.class); textWeightDecorator.hide(); String value = textWeight.getText(); if (value != null && value.trim().length() > 0) { try { double d = Double.parseDouble(value.trim()); if (d<0 || d>1) { throw new NumberFormatException(); } properties.setPropertyValue(ModelProperties.PROPERTY_EDGE_WEIGHT, value.trim()); } catch (NumberFormatException ex) { textWeightDecorator.show(); } } }
public void handleEvent(Event e) { if (!notification) return; EdgeGW4EEditPartProperties properties = (EdgeGW4EEditPartProperties) node .getAdapter(IPropertySource.class); textDependencyDecorator.hide(); String value = textDependency.getText(); if (value != null && value.trim().length() > 0) { try { Integer d = Integer.parseInt(value.trim()); if (d<0 || d>100) { throw new NumberFormatException(); } properties.setPropertyValue(ModelProperties.PROPERTY_EDGE_DEPENDENCY, value.trim()); } catch (NumberFormatException ex) { textDependencyDecorator.show(); } } }
@Override public void focusLost(FocusEvent e) { if (!notification) return; GW4EVertexEditPartProperties properties = (GW4EVertexEditPartProperties) sectionProvider .getAdapter(IPropertySource.class); txtSharedNameDecorator.hide(); String value = textSharedName.getText(); if (value == null || value.trim().length() == 0) { txtSharedNameDecorator.show(); return; } properties.setPropertyValue(ModelProperties.PROPERTY_VERTEX_SHAREDNAME,value); }
public void setInput(IWorkbenchPart part, ISelection selection) { super.setInput(part, selection); txtNameDecorator.hide(); txtSharedNameDecorator.hide(); Object input = ((IStructuredSelection) selection).getFirstElement(); this.sectionProvider = (SectionProvider) input; AbstractGW4EEditPartProperties properties = (AbstractGW4EEditPartProperties) sectionProvider .getAdapter(IPropertySource.class); textName.setEnabled(properties.isUpdatable(ModelProperties.PROPERTY_NAME)); btnCheckShrd.setEnabled(properties.isUpdatable(ModelProperties.PROPERTY_VERTEX_SHARED)); btnCheckBlocked.setEnabled(properties.isUpdatable(ModelProperties.PROPERTY_BLOCKED)); textDescription.setEnabled(properties.isUpdatable(ModelProperties.PROPERTY_DESCRIPTION)); textRequirements.setEnabled(properties.isUpdatable(ModelProperties.PROPERTY_VERTEX_REQUIREMENTS)); textSharedName.setEnabled(properties.isUpdatable(ModelProperties.PROPERTY_VERTEX_SHAREDNAME)); ((GWNode) this.sectionProvider.getModel()).removePropertyChangeListener(this); ((GWNode) this.sectionProvider.getModel()).addPropertyChangeListener(this); }
public void refresh() { notification = false; try { GW4EGraphEditPartProperties properties = (GW4EGraphEditPartProperties) node .getAdapter(IPropertySource.class); textName.setText(properties.getName()); Set<GWNode> elements = properties.getGraph().getLinks(); Set<GWNode> vertices = properties.getGraph().getVertices(); elements.addAll(vertices); GWNode[] items = new GWNode[elements.size()]; elements.toArray(items); viewer.setInput(items); GWNode startElement = properties.getGraph().getStartElement(); if (startElement != null) { viewer.setSelection(new StructuredSelection(startElement), true); } textDescription.setText(properties.getDescription()); textComponent.setText(properties.getComponent()); } finally { notification = true; } }
public IPropertySheetPage getPropertySheetPage() { if (propertySheetPage == null) { propertySheetPage = new de.darwinspl.preferences.resource.dwprofile.ui.DwprofilePropertySheetPage(); // add a slightly modified adapter factory that does not return any editors for // properties. this way, a model can never be modified through the properties view. AdapterFactory adapterFactory = new de.darwinspl.preferences.resource.dwprofile.ui.DwprofileAdapterFactoryProvider().getAdapterFactory(); propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory) { protected IPropertySource createPropertySource(Object object, IItemPropertySource itemPropertySource) { return new PropertySource(object, itemPropertySource) { protected IPropertyDescriptor createPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) { return new PropertyDescriptor(object, itemPropertyDescriptor) { public CellEditor createPropertyEditor(Composite composite) { return null; } }; } }; } }); highlighting.addSelectionChangedListener(propertySheetPage); } return propertySheetPage; }
public IPropertySheetPage getPropertySheetPage() { if (propertySheetPage == null) { propertySheetPage = new eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionPropertySheetPage(); // add a slightly modified adapter factory that does not return any editors for // properties. this way, a model can never be modified through the properties view. AdapterFactory adapterFactory = new eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionAdapterFactoryProvider().getAdapterFactory(); propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory) { protected IPropertySource createPropertySource(Object object, IItemPropertySource itemPropertySource) { return new PropertySource(object, itemPropertySource) { protected IPropertyDescriptor createPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) { return new PropertyDescriptor(object, itemPropertyDescriptor) { public CellEditor createPropertyEditor(Composite composite) { return null; } }; } }; } }); highlighting.addSelectionChangedListener(propertySheetPage); } return propertySheetPage; }
public IPropertySheetPage getPropertySheetPage() { if (propertySheetPage == null) { propertySheetPage = new eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaPropertySheetPage(); // add a slightly modified adapter factory that does not return any editors for // properties. this way, a model can never be modified through the properties view. AdapterFactory adapterFactory = new eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaAdapterFactoryProvider().getAdapterFactory(); propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory) { protected IPropertySource createPropertySource(Object object, IItemPropertySource itemPropertySource) { return new PropertySource(object, itemPropertySource) { protected IPropertyDescriptor createPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) { return new PropertyDescriptor(object, itemPropertyDescriptor) { public CellEditor createPropertyEditor(Composite composite) { return null; } }; } }; } }); highlighting.addSelectionChangedListener(propertySheetPage); } return propertySheetPage; }
public IPropertySheetPage getPropertySheetPage() { if (propertySheetPage == null) { propertySheetPage = new eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavaluePropertySheetPage(); // add a slightly modified adapter factory that does not return any editors for // properties. this way, a model can never be modified through the properties view. AdapterFactory adapterFactory = new eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueAdapterFactoryProvider().getAdapterFactory(); propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory) { protected IPropertySource createPropertySource(Object object, IItemPropertySource itemPropertySource) { return new PropertySource(object, itemPropertySource) { protected IPropertyDescriptor createPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) { return new PropertyDescriptor(object, itemPropertyDescriptor) { public CellEditor createPropertyEditor(Composite composite) { return null; } }; } }; } }); highlighting.addSelectionChangedListener(propertySheetPage); } return propertySheetPage; }
public IPropertySheetPage getPropertySheetPage() { if (propertySheetPage == null) { propertySheetPage = new eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingPropertySheetPage(); // add a slightly modified adapter factory that does not return any editors for // properties. this way, a model can never be modified through the properties view. AdapterFactory adapterFactory = new eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingAdapterFactoryProvider().getAdapterFactory(); propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory) { protected IPropertySource createPropertySource(Object object, IItemPropertySource itemPropertySource) { return new PropertySource(object, itemPropertySource) { protected IPropertyDescriptor createPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) { return new PropertyDescriptor(object, itemPropertyDescriptor) { public CellEditor createPropertyEditor(Composite composite) { return null; } }; } }; } }); highlighting.addSelectionChangedListener(propertySheetPage); } return propertySheetPage; }
public IPropertySheetPage getPropertySheetPage() { if (propertySheetPage == null) { propertySheetPage = new eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsPropertySheetPage(); // add a slightly modified adapter factory that does not return any editors for // properties. this way, a model can never be modified through the properties view. AdapterFactory adapterFactory = new eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsAdapterFactoryProvider().getAdapterFactory(); propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory) { protected IPropertySource createPropertySource(Object object, IItemPropertySource itemPropertySource) { return new PropertySource(object, itemPropertySource) { protected IPropertyDescriptor createPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) { return new PropertyDescriptor(object, itemPropertyDescriptor) { public CellEditor createPropertyEditor(Composite composite) { return null; } }; } }; } }); highlighting.addSelectionChangedListener(propertySheetPage); } return propertySheetPage; }
public IPropertySheetPage getPropertySheetPage() { if (propertySheetPage == null) { propertySheetPage = new eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestPropertySheetPage(); // add a slightly modified adapter factory that does not return any editors for // properties. this way, a model can never be modified through the properties view. AdapterFactory adapterFactory = new eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestAdapterFactoryProvider().getAdapterFactory(); propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory) { protected IPropertySource createPropertySource(Object object, IItemPropertySource itemPropertySource) { return new PropertySource(object, itemPropertySource) { protected IPropertyDescriptor createPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) { return new PropertyDescriptor(object, itemPropertyDescriptor) { public CellEditor createPropertyEditor(Composite composite) { return null; } }; } }; } }); highlighting.addSelectionChangedListener(propertySheetPage); } return propertySheetPage; }
@Override public Object getAdapter(final Object adaptableObject, final Class adapterType) { if (adaptableObject instanceof ChangeItem) { final ChangeItem changeItem = (ChangeItem) adaptableObject; if (adapterType == IPropertySource.class) { if (changeItem.getType() == ChangeItemType.CHANGESET) { return new ChangePropertySource(changeItem.getChange()); } else { return new PendingChangePropertySource( changeItem.getPendingChange(), changeItem.getPropertyValues()); } } if (adapterType == IWorkbenchAdapter.class) { return ChangeItemWorkbenchAdapter.INSTANCE; } } return null; }
/** * Method declared on IAdapterFactory. * Get the given adapter for the given object */ public Object getAdapter(Object adaptableObject, Class adapterType) { if (IWorkbenchAdapter.class == adapterType) { return getWorkbenchAdapter(adaptableObject); } if(IDeferredWorkbenchAdapter.class == adapterType) { Object o = getWorkbenchAdapter(adaptableObject); if(o != null && o instanceof IDeferredWorkbenchAdapter) { return o; } return null; } if (IPropertySource.class == adapterType) { return getPropertySource(adaptableObject); } if(IHistoryPageSource.class == adapterType) { return pageHistoryParticipant; } return null; }
@Test public void testPropertyWithPropertyNeedingUpdate() throws Exception { // Given addBookmark(new BookmarkId("rootFolder"), bookmark("bookmark1").withProperty(PROP_LINE_NUMBER, "10").build()); bookmarkProblemsDatabase.add(new BookmarkProblem(new BookmarkId("bookmark1"), BookmarkProblem.TYPE_PROPERTIES_NEED_UPDATE, ImmutableMap.of(PROP_LINE_NUMBER, "120"))); // When IPropertyDescriptor[] propertyDescriptors = bookmarkPropertySource.getPropertyDescriptors(); IPropertyDescriptor propertyDescriptor = getPropertyDescriptor(propertyDescriptors, PROP_LINE_NUMBER); Object propertyValue = bookmarkPropertySource.getPropertyValue(PROP_LINE_NUMBER); // Then assertThat(propertyDescriptor.getDisplayName()).isEqualTo(PROP_LINE_NUMBER); assertThat(propertyValue).isInstanceOf(IPropertySource.class); IPropertySource valuePropertySource = (IPropertySource) propertyValue; IPropertyDescriptor updatePropertyDescriptor = getPropertyDescriptor( valuePropertySource.getPropertyDescriptors(), PROP_LINE_NUMBER); assertThat(valuePropertySource.getPropertyValue(PROP_LINE_NUMBER)).isEqualTo(new UpdatedPropertyValue("120")); assertThat(updatePropertyDescriptor.getDisplayName()).isEqualTo("Updated value"); }
@Test public void testPropertyWithPropertyMayUpdate() throws Exception { // Given addBookmark(new BookmarkId("rootFolder"), bookmark("bookmark1").withProperty(PROP_LINE_NUMBER, "10").build()); bookmarkProblemsDatabase.add(new BookmarkProblem(new BookmarkId("bookmark1"), BookmarkProblem.TYPE_PROPERTIES_MAY_UPDATE, ImmutableMap.of(PROP_LINE_NUMBER, "11"))); // When IPropertyDescriptor[] propertyDescriptors = bookmarkPropertySource.getPropertyDescriptors(); IPropertyDescriptor propertyDescriptor = getPropertyDescriptor(propertyDescriptors, PROP_LINE_NUMBER); Object propertyValue = bookmarkPropertySource.getPropertyValue(PROP_LINE_NUMBER); // Then assertThat(propertyDescriptor.getDisplayName()).isEqualTo(PROP_LINE_NUMBER); assertThat(propertyValue).isInstanceOf(IPropertySource.class); IPropertySource valuePropertySource = (IPropertySource) propertyValue; IPropertyDescriptor updatePropertyDescriptor = getPropertyDescriptor( valuePropertySource.getPropertyDescriptors(), PROP_LINE_NUMBER); assertThat(valuePropertySource.getPropertyValue(PROP_LINE_NUMBER)).isEqualTo(new UpdatedPropertyValue("11")); assertThat(updatePropertyDescriptor.getDisplayName()).isEqualTo("Updated value"); }
public Object getAdapter(Object adaptableObject, Class adapterType) { if (adaptableObject instanceof org.xtext.example.statemachine.statemachine.diagram.navigator.StatemachineDomainNavigatorItem) { org.xtext.example.statemachine.statemachine.diagram.navigator.StatemachineDomainNavigatorItem domainNavigatorItem = (org.xtext.example.statemachine.statemachine.diagram.navigator.StatemachineDomainNavigatorItem) adaptableObject; EObject eObject = domainNavigatorItem.getEObject(); if (adapterType == EObject.class) { return eObject; } if (adapterType == IPropertySource.class) { return domainNavigatorItem .getPropertySourceProvider() .getPropertySource(eObject); } } return null; }
@Override public void performRequest(Request req) { if (RequestConstants.REQ_OPEN.equals(req.getType())) { if(!ExpressionEditorSupportUtil.isExpressionEditorDialogOpen()) { JRExpressionEditor wizard = new JRExpressionEditor(); MHtml m = (MHtml) getModel(); wizard.setValue((JRDesignExpression) m .getPropertyValue(HtmlComponent.PROPERTY_HTMLCONTENT_EXPRESSION)); ExpressionContext ec=ModelUtils.getElementExpressionContext((JRDesignElement)m.getValue(), m); wizard.setExpressionContext(ec); WizardDialog dialog = ExpressionEditorSupportUtil.getExpressionEditorWizardDialog(Display.getDefault() .getActiveShell(), wizard); if (dialog.open() == Dialog.OK) { SetValueCommand cmd = new SetValueCommand(); cmd.setTarget((IPropertySource) getModel()); cmd.setPropertyId(HtmlComponent.PROPERTY_HTMLCONTENT_EXPRESSION); cmd.setPropertyValue(wizard.getValue()); getViewer().getEditDomain().getCommandStack().execute(cmd); } } } else super.performRequest(req); }
/** * Sets the model. * * @param model * the new model */ public void setModel(ANode model) { if (listener != null && this.model != null) this.model.getPropertyChangeSupport().removePropertyChangeListener(listener); if (model != null) { if (listener == null) { listener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getSource() instanceof IPropertySource) JRPropertySheetEntry.this.setValues(new Object[] { evt.getSource() }); } }; } model.getPropertyChangeSupport().addPropertyChangeListener(listener); } this.model = model; }
@Override public void setValues(Object[] objects) { if (objects.length > 0) { // TODO WORK WITH COLLECTION if (objects[0] instanceof EditPart) { if (((EditPart) objects[0]).getModel() instanceof ANode) setModel((ANode) ((EditPart) objects[0]).getModel()); } } else setModel(null); if (objects.length == 0) { editValue = null; } else { // set the first value object as the entry's value Object newValue = objects[0]; // see if we should convert the value to an editable value IPropertySource source = getPropertySource(newValue); if (source != null) { newValue = source.getEditableValue(); } editValue = newValue; } super.setValues(objects); }
/** * Get a list of all the datasets used by every element, and if one or more of this are references to the dataset * with the changed name ask if the user want to refactor the name inside the project */ @Override public Command postSetValue(IPropertySource target, Object prop, Object newValue, Object oldValue) { JSSCompoundCommand c = new JSSCompoundCommand(null); c.setReferenceNodeIfNull(target); //Check if the updated element is a dataset and the updated property is the name if (target instanceof MDataset && prop.equals(JRDesignDataset.PROPERTY_NAME)) { //Get all the references to this dataset List<IDatasetContainer> references = DeleteDatasetCommand.getDatasetUsage(((MDataset)target).getRoot().getChildren(), oldValue.toString()); if (references.size()>0){ boolean selectedYes = UIUtils.showConfirmation(Messages.PostSetDatasetName_title, Messages.PostSetDatasetName_message); if (selectedYes){ for(IDatasetContainer datasetRun : references){ List<MDatasetRun> datasetList = datasetRun.getDatasetRunList(); for (MDatasetRun actualDataset : datasetList){ if (actualDataset != null && oldValue.toString().equals(actualDataset.getPropertyValue(JRDesignDatasetRun.PROPERTY_DATASET_NAME))) c.add(new SetDatasetRunName(actualDataset, oldValue.toString(), newValue.toString())); } } } } } return c; }
/** * Get a list of all the datasets run used by every element, and if one or more of this are references to the dataset * with the changed parameter search create a command that search inside them the reference to the parameter and if * found rename it */ @Override public Command postSetValue(IPropertySource target, Object prop, Object newValue, Object oldValue) { JSSCompoundCommand c = new JSSCompoundCommand(null); // Check if the updated element is a dataset and the updated property is the name if (target instanceof MParameter && prop.equals(JRDesignParameter.PROPERTY_NAME)) { MParameter mprm = (MParameter) target; if (mprm.getParent() != null && mprm.getParent().getParent() != null) { // Get all the references to this dataset ANode parentElement = mprm.getParent().getParent(); c.setReferenceNodeIfNull(parentElement); if (parentElement instanceof MDataset) { MDataset parentDataset = (MDataset) parentElement; List<IDatasetContainer> references = DeleteDatasetCommand.getDatasetUsage(parentDataset.getRoot() .getChildren(), parentDataset.getPropertyActualValue(JRDesignDataset.PROPERTY_NAME).toString()); for (IDatasetContainer datasetRun : references) { List<MDatasetRun> datasetList = datasetRun.getDatasetRunList(); for (MDatasetRun actualDataset : datasetList) { c.add(new SetParameterName(actualDataset, oldValue.toString(), newValue.toString())); } } } } } return c; }
@SuppressWarnings("rawtypes") @Override public Object getAdapter(Class type) { if (type == IPropertySource.class) return getPropertySheetPage(); if (type == IPropertySheetPage.class) return getPropertySheetPage(); if (type == ZoomManager.class) return getGraphicalViewer().getProperty(ZoomManager.class.toString()); if (type == IContentOutlinePage.class) { return getOutlineView(); } if (type == EditorContributor.class) { if (editorContributor == null) editorContributor = new EditorContributor(getEditDomain()); return editorContributor; } return super.getAdapter(type); }
@Override public Object getAdapter(@SuppressWarnings("rawtypes") final Class adapter) { if (adapter == IPropertySource.class) { return new ReflectivePropertySource(_document); } else if (adapter == IStoreItem.class) { return _document; } else if (adapter == IDocument.class) { return _document; } return null; }
/** * @see org.eclipse.ui.views.properties.IPropertySheetEntry#resetPropertyValue() */ public void resetPropertyValue() { CompoundCommand cc = new CompoundCommand(); if (getParent() == null) // root does not have a default value return; // Use our parent's values to reset our values. boolean change = false; Object[] objects = getParent().getValues(); for (int i = 0; i < objects.length; i++) { IPropertySource source = getPropertySource(objects[i]); if (source.isPropertySet(getDescriptor().getId())) { SetPropertyValueCommand restoreCmd = new SetPropertyValueCommand( getDescriptor().getDisplayName(), source, getDescriptor().getId(), SetPropertyValueCommand.DEFAULT_VALUE); cc.add(restoreCmd); change = true; } } if (change) { getCommandStack().execute(cc); refreshFromRoot(); } }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public Object getAdapter(Object adaptableObject, Class adapterType) { if(!(adaptableObject instanceof HybridPluginFolder)) return null; HybridPluginFolder pluginFolder = (HybridPluginFolder)adaptableObject; if(IPropertySource.class.equals(adapterType)){ return new CordovaPluginProperties(pluginFolder); } if(IWorkbenchAdapter.class.equals(adapterType)){ return new CordovaPluginWorkbenchAdapter(); } if(IResource.class.equals(adapterType)){ return pluginFolder.getFolder(); } return null; }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public Object getAdapter(Object adaptableObject, Class adapterType) { if(!(adaptableObject instanceof HybridPlatformFolder)) return null; HybridPlatformFolder platform = (HybridPlatformFolder)adaptableObject; if(IPropertySource.class.equals(adapterType)){ return new CordovaPlatformProperties(platform); } if(IWorkbenchAdapter.class.equals(adapterType)){ return new CordovaPlatformWorkbenchAdapter(); } if(IResource.class.equals(adapterType)){ return platform.getFolder(); } return null; }
/** * @generated */ public IPropertySource getPropertySource(Object object) { if (object instanceof IPropertySource) { return (IPropertySource) object; } AdapterFactory af = getAdapterFactory(object); if (af != null) { IItemPropertySource ips = (IItemPropertySource) af.adapt(object, IItemPropertySource.class); if (ips != null) { return new PropertySource(object, ips); } } if (object instanceof IAdaptable) { return (IPropertySource) ((IAdaptable) object) .getAdapter(IPropertySource.class); } return null; }
public Object getAdapter(Object adaptableObject, Class adapterType) { if (adaptableObject instanceof au.edu.swin.ict.road.designer.smc.diagram.navigator.SmcDomainNavigatorItem) { au.edu.swin.ict.road.designer.smc.diagram.navigator.SmcDomainNavigatorItem domainNavigatorItem = (au.edu.swin.ict.road.designer.smc.diagram.navigator.SmcDomainNavigatorItem) adaptableObject; EObject eObject = domainNavigatorItem.getEObject(); if (adapterType == EObject.class) { return eObject; } if (adapterType == IPropertySource.class) { return domainNavigatorItem .getPropertySourceProvider() .getPropertySource(eObject); } } return null; }
public NTFigure(IPropertySource propertySource) { super(); setOpaque(true); setLayoutManager(new XYLayout()); mHScrollBar = new ScrollBar(); mHScrollBar.setHorizontal(true); mHScrollBar.setVisible(false); add(mHScrollBar); mVScrollBar = new ScrollBar(); mVScrollBar.setHorizontal(false); add(mVScrollBar); mGlassPanel = new Label(); mGlassPanel.setOpaque(false); add(mGlassPanel); createChildFigures(); init(propertySource); }
@Override public void execute() { boolean wasPropertySet = getTarget().isPropertySet(mPropertyName); mUndoValue = getTarget().getPropertyValue(mPropertyName); if (mUndoValue instanceof IPropertySource) { mUndoValue = ((IPropertySource)mUndoValue).getEditableValue(); } if (mPropertyValue instanceof IPropertySource) { mPropertyValue = ((IPropertySource)mPropertyValue).getEditableValue(); } getTarget().setPropertyValue(mPropertyName, mPropertyValue); mResetOnUndo = wasPropertySet != getTarget().isPropertySet(mPropertyName); if (mResetOnUndo) { mUndoValue = null; } }
public void resetPropertyValue(String id, IPropertySource[] sources) { CompoundCommand cc = new CompoundCommand(); ResetValueCommand restoreCmd; for (int i = 0; i < sources.length; i++) { IPropertySource source = sources[i]; if (source.isPropertySet(id)) { //source.resetPropertyValue(getDescriptor()getId()); restoreCmd = new ResetValueCommand(); restoreCmd.setTarget(source); restoreCmd.setPropertyId(id); cc.add(restoreCmd); } } if (cc.size() > 0) { mStack.execute(cc); refresh(); } }
public void valueChanged(String propertyId, String name, IPropertySource[] targets, Object[] newValues, CompoundCommand command) { CompoundCommand cc = new CompoundCommand(); command.add(cc); for (int i = 0; i < targets.length; i++) { IPropertySource target = targets[i]; Object oldValue = target.getPropertyValue(propertyId); Object newValue = (newValues.length > i?newValues[i]:null); if(!Common.objectsAreEqual(oldValue, newValue)) { if(InstallOptionsModel.PROPERTY_TYPE.equals(propertyId)) { cc.add(createChangeTypeCommand(target, name, propertyId, newValue)); } else { cc.add(createSetValueCommand(target, name, propertyId, newValue)); } } } }
/** * */ public ComboboxFigure(Composite parent, final IPropertySource propertySource) { super(); Combo cb = new Combo(parent,SWT.DROP_DOWN); cb.setVisible(false); cb.setBounds(-100,-100,10,10); Point p = cb.computeSize(SWT.DEFAULT,SWT.DEFAULT); cb.dispose(); mComboHeight = p.y; setLayoutManager(new XYLayout()); Rectangle[] bounds = calculateBounds((Rectangle)propertySource.getPropertyValue(InstallOptionsWidget.PROPERTY_BOUNDS)); mComboFigure = new ComboFigure(parent, new CustomPropertySourceWrapper(propertySource, bounds[0])); mListFigure = new ListFigure(parent, new CustomPropertySourceWrapper(propertySource, bounds[1]), SWT.SINGLE); mListFigure.setBorder(new LineBorder(ColorManager.getColor(ColorManager.BLACK))); mListFigure.setVisible(mShowDropdown); add(mComboFigure); add(mListFigure); }
public SWTControlFigure(Composite parent, IPropertySource propertySource, int style) { super(); mStyle = style; setLayoutManager(new XYLayout()); mParent = parent; if(mParent != null) { mParent.addDisposeListener(new DisposeListener(){ public void widgetDisposed(DisposeEvent e) { if(mImage != null && !mImage.isDisposed()) { mImage.dispose(); } } }); } init(propertySource); }
@SuppressWarnings("rawtypes") @Override public Object getAdapter(Class key) { if (IPropertySource.class == key) { return getPropertySource(); } if (key == SnapToHelper.class) { List<SnapToHelper> helpers = new ArrayList<SnapToHelper>(); if (Boolean.TRUE.equals(getViewer().getProperty( SnapToGeometry.PROPERTY_SNAP_ENABLED))) { helpers.add(new SnapToGeometry(this)); } if (Boolean.TRUE.equals(getViewer().getProperty( SnapToGrid.PROPERTY_GRID_ENABLED))) { helpers.add(new SnapToGrid(this)); } if (helpers.size() == 0) { return null; } else { return new CompoundSnapToHelper( helpers.toArray(new SnapToHelper[0])); } } return super.getAdapter(key); }
@SuppressWarnings("rawtypes") public Object getAdapter(Object adaptableObject, Class adapterType) { if (adapterType == IPropertySheetPage.class) { if (adaptableObject instanceof BugExplorerView || adaptableObject instanceof JavaEditor || adaptableObject instanceof AbstractFindbugsView) { return new BugPropertySheetPage(); } } if (adapterType == IPropertySource.class) { if (adaptableObject instanceof BugPattern || adaptableObject instanceof BugInstance || adaptableObject instanceof DetectorFactory || adaptableObject instanceof Plugin || adaptableObject instanceof BugInstance.XmlProps || adaptableObject instanceof BugGroup || adaptableObject instanceof BugAnnotation) { return new PropertySource(adaptableObject); } IMarker marker = Util.getAdapter(IMarker.class, adaptableObject); if (!MarkerUtil.isFindBugsMarker(marker)) { return null; } return new MarkerPropertySource(marker); } return null; }