package tool.editors.serviceobject;
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.editor.FormPage;
import org.eclipse.ui.forms.widgets.FormToolkit;
import tool.ToolEditorActivator;
import tool.commands.findtype.TypeSelectionDialog;
import tool.model.ToolClass;
import tool.model.ToolServiceObject;
import tool.model.ToolType;
public class ServiceObjectPage extends FormPage {//implements PropertyChangeListener{
private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
private ToolServiceObject so;
private Text soNameText;
private Text soClassText;
private Combo visabilityCombo;
private Combo dialogDurationCombo;
private Text UUIDText;
private Button btnLoadBalanced;
private Text searchPathText;
private Text resourceNameText;
private Text userNameText;
private Text userPasswordText;
private Text managerText;
private Label lblSuperClass;
private Button lookupButton;
private Label lblResourceManager;
private Label lblUserName;
private Label lblUserPassword;
private Label lblManager;
public ServiceObjectPage(){
super("tool,editors.ServiceObjectForm", "Service Object");
}
@Override
public void createPartControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout gl_composite = new GridLayout(3, false);
gl_composite.horizontalSpacing = 8;
composite.setLayout(gl_composite);
Label lblName = new Label(composite, SWT.NONE);
lblName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblName.setText("Name");
soNameText = new Text(composite, SWT.BORDER);
GridData gd_classNameText = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
gd_classNameText.widthHint = 224;
soNameText.setLayoutData(gd_classNameText);
toolkit.adapt(soNameText, true, true);
new Label(composite, SWT.NONE);
lblSuperClass = new Label(composite, SWT.NONE);
lblSuperClass.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblSuperClass.setText("Class");
soClassText = new Text(composite, SWT.BORDER);
GridData gd_superClassText = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
gd_superClassText.widthHint = 226;
soClassText.setLayoutData(gd_superClassText);
toolkit.adapt(soClassText, true, true);
lookupButton = new Button(composite, SWT.NONE);
lookupButton.setImage(ToolEditorActivator.getImage("icons/look_up.gif"));
lookupButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ToolType typeClass = ToolClass.fetch(so.getProject(), so.getType());
TypeSelectionDialog dialog = new TypeSelectionDialog(getSite().getWorkbenchWindow().getShell(), true);
dialog.setInitialPattern(soClassText.getText());
dialog.setBlockOnOpen(true);
if (dialog.open() == Dialog.OK){
// find the resource and edit it
Object[] result = dialog.getResult();
if (result.length > 0){
IFile file = (IFile) result[0];
so.setType(file.getName().substring(0, file.getName().lastIndexOf('.')));
}
}
}
});
lookupButton.setToolTipText("Class lookup");
toolkit.adapt(lookupButton, true, true);
Label lblVisability = new Label(composite, SWT.NONE);
lblVisability.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblVisability.setText("Visability");
visabilityCombo = new Combo(composite, SWT.READ_ONLY);
visabilityCombo.setItems(new String[] {"ENVIRONMENT", "USER"});
visabilityCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
toolkit.adapt(visabilityCombo);
toolkit.paintBordersFor(visabilityCombo);
new Label(composite, SWT.NONE);
Label lblDialogDuration = new Label(composite, SWT.NONE);
lblDialogDuration.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblDialogDuration.setText("Dialog Duration");
dialogDurationCombo = new Combo(composite, SWT.READ_ONLY);
dialogDurationCombo.setItems(new String[] {"MESSAGE", "TRANSACTION", "SESSION"});
dialogDurationCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
toolkit.adapt(dialogDurationCombo);
toolkit.paintBordersFor(dialogDurationCombo);
new Label(composite, SWT.NONE);
new Label(composite, SWT.NONE);
btnLoadBalanced = new Button(composite, SWT.CHECK);
btnLoadBalanced.setText("Load Balance");
new Label(composite, SWT.NONE);
new Label(composite, SWT.NONE);
Button btnFailOver = new Button(composite, SWT.CHECK);
btnFailOver.setText("Fail Over");
new Label(composite, SWT.NONE);
Label lblUuid = new Label(composite, SWT.NONE);
lblUuid.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblUuid.setText("UUID");
UUIDText = new Text(composite, SWT.BORDER | SWT.READ_ONLY);
GridData gd_UUIDText = new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1);
gd_UUIDText.widthHint = 262;
UUIDText.setLayoutData(gd_UUIDText);
toolkit.adapt(UUIDText, true, true);
new Label(composite, SWT.NONE);
Label lblNewLabel = new Label(composite, SWT.NONE);
lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblNewLabel .setText("Search Path");
searchPathText = new Text(composite, SWT.BORDER);
searchPathText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
toolkit.adapt(searchPathText, true, true);
new Label(composite, SWT.NONE);
lblManager = new Label(composite, SWT.NONE);
lblManager.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblManager.setText("Manager");
managerText = new Text(composite, SWT.BORDER);
managerText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
toolkit.adapt(managerText, true, true);
new Label(composite, SWT.NONE);
lblResourceManager = new Label(composite, SWT.NONE);
lblResourceManager.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblResourceManager.setText("Resource");
resourceNameText = new Text(composite, SWT.BORDER);
resourceNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
toolkit.adapt(resourceNameText, true, true);
new Label(composite, SWT.NONE);
lblUserName = new Label(composite, SWT.NONE);
lblUserName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblUserName.setText("User Name");
userNameText = new Text(composite, SWT.BORDER);
userNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
toolkit.adapt(userNameText, true, true);
new Label(composite, SWT.NONE);
lblUserPassword = new Label(composite, SWT.NONE);
lblUserPassword.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
toolkit.adapt(lblUserPassword, true, true);
lblUserPassword.setText("User Password");
userPasswordText = new Text(composite, SWT.BORDER);
userPasswordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
toolkit.adapt(userPasswordText, true, true);
new Label(composite, SWT.NONE);
// if (so != null)
// m_bindingContext = initDataBindings();
}
public ToolServiceObject getSo() {
return so;
}
public void setSo(ToolServiceObject so) {
// if (m_bindingContext != null){
// m_bindingContext.dispose();
// m_bindingContext = null;
// }
this.so = so;
this.so.setDirty(false);
// this.so.addPropertyChangeListener("dirty", this);
if (this.so != null && this.soNameText != null){
// m_bindingContext = initDataBindings();
}
}
// @Override
// public void propertyChange(PropertyChangeEvent event) {
// if (event.getPropertyName().equalsIgnoreCase("dirty")){
// firePropertyChange(IWorkbenchPartConstants.PROP_DIRTY);
// }
// }
}