SCViewer/com.minres.scviewer.ui/src/com/minres/scviewer/ui/adapter/ITransactionPropertySource....

92 lines
3.2 KiB
Java
Raw Normal View History

2012-06-17 20:34:50 +02:00
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
2012-06-17 20:34:50 +02:00
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
2012-06-17 20:34:50 +02:00
*******************************************************************************/
package com.minres.scviewer.ui.adapter;
2012-06-17 19:53:05 +02:00
import java.util.ArrayList;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;
2015-01-06 17:14:16 +01:00
import com.minres.scviewer.database.ITx;
2012-06-17 19:53:05 +02:00
2015-01-01 23:17:32 +01:00
public class ITransactionPropertySource implements IPropertySource {
2012-06-17 19:53:05 +02:00
2015-01-06 17:14:16 +01:00
private ITx iTransaction;
2012-06-17 19:53:05 +02:00
public final static String PROPERTY_ID = "ID";
public final static String PROPERTY_BEGINTIME = "BEGINTIME";
public final static String PROPERTY_ENDTIME = "ENDTIME";
2015-01-01 23:17:32 +01:00
public final static String PROPERTY_NAME = "NAME";
2012-06-17 19:53:05 +02:00
protected IPropertyDescriptor[] propertyDescriptors;
2015-01-06 17:14:16 +01:00
public ITransactionPropertySource(ITx iTransaction) {
2012-06-17 19:53:05 +02:00
this.iTransaction=iTransaction;
}
@Override
public Object getEditableValue() {
return null;
}
@Override
public IPropertyDescriptor[] getPropertyDescriptors() {
if (propertyDescriptors == null) {
2015-01-01 23:17:32 +01:00
ArrayList<IPropertyDescriptor> descriptor=new ArrayList<IPropertyDescriptor>();
2012-06-17 19:53:05 +02:00
// Create a descriptor and set a category
2015-01-01 23:17:32 +01:00
PropertyDescriptor idDescriptor = new PropertyDescriptor(PROPERTY_ID, "Id");
idDescriptor.setCategory("Attributes");
descriptor.add(idDescriptor);
2012-06-17 19:53:05 +02:00
PropertyDescriptor begTimeDescriptor = new PropertyDescriptor(PROPERTY_BEGINTIME, "Begin time");
begTimeDescriptor.setCategory("Attributes");
2015-01-01 23:17:32 +01:00
descriptor.add(begTimeDescriptor);
2012-06-17 19:53:05 +02:00
PropertyDescriptor endTimeDescriptor = new PropertyDescriptor(PROPERTY_ENDTIME, "End time");
endTimeDescriptor.setCategory("Attributes");
2015-01-01 23:17:32 +01:00
descriptor.add(endTimeDescriptor);
PropertyDescriptor nameDescriptor = new PropertyDescriptor(PROPERTY_NAME, "Name");
nameDescriptor.setCategory("Attributes");
descriptor.add(nameDescriptor);
propertyDescriptors = descriptor.toArray(new IPropertyDescriptor[descriptor.size()]);
2012-06-17 19:53:05 +02:00
}
return propertyDescriptors;
}
@Override
public Object getPropertyValue(Object id) {
if (id.equals(PROPERTY_ID)) {
return iTransaction.getId();
} else if(id.equals(PROPERTY_BEGINTIME)){
return iTransaction.getBeginTime();//.getValueNS();
} else if(id.equals(PROPERTY_ENDTIME)){
return iTransaction.getEndTime();//.getValueNS();
2015-01-01 23:17:32 +01:00
} else if(id.equals(PROPERTY_NAME)){
return iTransaction.getGenerator().getName();
2012-06-17 19:53:05 +02:00
}
return null;
}
@Override
public boolean isPropertySet(Object id) {
String curName = (String)getPropertyValue(id);
return curName!=null && curName.length()>0;
}
@Override
public void resetPropertyValue(Object id) {
}
@Override
public void setPropertyValue(Object id, Object value) {
}
}