protected boolean includeMoveDownOperation() { if ((getMergeViewer().getLeftViewer() == this && !getMergeViewer().isLeftEditable()) || (getMergeViewer().getRightViewer() == this && !getMergeViewer().isRightEditable())) { return false; } IStructuredSelection selection = (IStructuredSelection) getSelection(); if (selection.size() == 1) { Object element = selection.getFirstElement(); Object realElement = ((ComparableTreeObject) element).getRealElement(); if (MetadataSortingManager.isOrderedElement(realElement)) { try { Method method = realElement .getClass() .getMethod( "Actionfilter", new Class[] {String.class, String.class}); // $NON-NLS-1$ Boolean bool = (Boolean) method.invoke( realElement, new Object[] {"can", "move down"}); // $NON-NLS-1$ $NON-NLS-2$ return bool; } catch (SecurityException e) { CorePlugin.logError("Unable to test for ordering ability.", e); } catch (NoSuchMethodException e) { CorePlugin.logError("Unable to test for ordering ability.", e); } catch (IllegalArgumentException e) { CorePlugin.logError("Unable to test for ordering ability.", e); } catch (IllegalAccessException e) { CorePlugin.logError("Unable to test for ordering ability.", e); } catch (InvocationTargetException e) { CorePlugin.logError("Unable to test for ordering ability.", e); } } } return false; }
public class ForkJoinsA_FJPropertySource implements IPropertySource { private ForkJoinNode_c m_inst; private PropertyDescriptor[] m_propertyDescriptors; MetadataSortingManager sorter = MetadataSortingManager.createDefault(); public ForkJoinsA_FJPropertySource(ForkJoinNode_c inst) { m_inst = inst; } /* (non-Javadoc) * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue() */ public Object getEditableValue() { return this; } /* (non-Javadoc) * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object) */ public boolean isPropertySet(Object id) { return false; } /* (non-Javadoc) * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object) */ public void resetPropertyValue(Object id) { // do nothing } public String toString() { return m_inst.Get_name(); } /* (non-Javadoc) * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors() */ public IPropertyDescriptor[] getPropertyDescriptors() { if (m_inst == null || m_inst.isOrphaned()) return new IPropertyDescriptor[0]; if (m_propertyDescriptors == null || 2 != m_propertyDescriptors.length) { m_propertyDescriptors = new PropertyDescriptor[2]; boolean readonly = false; m_propertyDescriptors[0] = new DescriptionPropertyDescriptor("Descrip", "Fork Join Description", m_inst); m_propertyDescriptors[0].setCategory(BridgepointPropertySheetPage.basicCategoryName); m_propertyDescriptors[1] = new TextPropertyDescriptor("GuardCondition", "Guard Condition"); m_propertyDescriptors[1].setCategory(BridgepointPropertySheetPage.basicCategoryName); } return m_propertyDescriptors; } /* (non-Javadoc) * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object) */ public Object getPropertyValue(Object id) { if (m_inst.isOrphaned()) { return ""; } if (id.equals("Descrip")) { return m_inst.getDescrip().replace('\n', '/'); } else if (id.equals("GuardCondition")) { return m_inst.getGuardcondition(); } return null; } /* (non-Javadoc) * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object) */ public void setPropertyValue(Object id, Object value) { boolean value_changed = false; String trans_name = ""; Transaction tr = null; Ooaofooa modelRoot = (Ooaofooa) m_inst.getModelRoot(); TransactionManager tm = TransactionManager.getSingleton(); try { if (id.equals("Descrip")) { if (!value.toString().equals(m_inst.getDescrip())) { trans_name = "Change in property: 'Descrip' of Fork Join Node"; // $NON-NLS-1$ tr = tm.startTransaction(trans_name, Ooaofooa.getDefaultInstance()); value_changed = true; m_inst.setDescrip(value.toString()); } } else if (id.equals("GuardCondition")) { if (!value.toString().equals(m_inst.getGuardcondition())) { trans_name = "Change in property: 'GuardCondition' of Fork Join Node"; // $NON-NLS-1$ tr = tm.startTransaction(trans_name, Ooaofooa.getDefaultInstance()); value_changed = true; m_inst.setGuardcondition(value.toString()); } } // catch all exceptions and cancel the transaction } catch (Exception e) { // this can be null if there was // an exception starting the // transaction if (tr != null) { tm.cancelTransaction(tr, e); tr = null; } CorePlugin.logError("Transaction: " + trans_name + " could not complete", e); } if (tr != null) { if (value_changed) tm.endTransaction(tr); else tm.cancelTransaction(tr); } } }