use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.
the class AttributeInputDialog method createDialogArea.
/**
* @see Dialog#createDialogArea(Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
// create composite
Composite composite = (Composite) super.createDialogArea(parent);
// create message
if (message != null) {
Label label = new Label(composite, SWT.WRAP);
label.setText(message);
GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
label.setLayoutData(data);
label.setFont(parent.getFont());
}
// create editor
AttributeEditorFactory aef = PlatformUI.getWorkbench().getService(AttributeEditorFactory.class);
editor = aef.createEditor(composite, definition, entity, false);
editor.setVariableReplacer(replacer);
editor.getControl().setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
editor.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(AttributeEditor.IS_VALID))
getButton(IDialogConstants.OK_ID).setEnabled((Boolean) event.getNewValue());
}
});
applyDialogFont(composite);
return composite;
}
use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.
the class WFSTarget method createControls.
@Override
public void createControls(Composite parent) {
getPage().setMessage("Please specify the WFS Transaction URL");
GridLayout layout = new GridLayout(3, false);
parent.setLayout(layout);
// target URL field
targetURL = new URIFieldEditor("targetURL", "Transaction URL", parent) {
// the following methods are overridden so the capabilities button
// may appear on the same line
@Override
public int getNumberOfControls() {
return super.getNumberOfControls() + 1;
}
@Override
protected void doFillIntoGrid(Composite parent, int numColumns) {
super.doFillIntoGrid(parent, numColumns - 1);
}
};
targetURL.setPage(getPage());
targetURL.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(FieldEditor.IS_VALID)) {
getPage().setMessage(null);
updateState();
} else if (event.getProperty().equals(FieldEditor.VALUE)) {
getPage().setMessage(null);
updateState();
}
}
});
// button to determine from capabilities
Button capButton = new Button(parent, SWT.PUSH);
capButton.setText("...");
capButton.setToolTipText("Determine based on WFS Capabilities");
capButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
WFSTransactionConfig config = new WFSTransactionConfig();
ISelection versionSel = selectVersion.getSelection();
if (!versionSel.isEmpty() && versionSel instanceof IStructuredSelection) {
WFSVersion version = (WFSVersion) ((IStructuredSelection) versionSel).getFirstElement();
config.setVersion(version);
}
WFSTransactionWizard wizard = new WFSTransactionWizard(config);
HaleWizardDialog dialog = new HaleWizardDialog(Display.getCurrent().getActiveShell(), wizard);
if (dialog.open() == WizardDialog.OK) {
WFSTransactionConfig result = wizard.getConfiguration();
// apply result
targetURL.setStringValue(result.getTransactionUri().toString());
if (result.getVersion() != null) {
selectVersion.setSelection(new StructuredSelection(result.getVersion()));
} else {
selectVersion.setSelection(new StructuredSelection());
}
}
}
});
// select version
Label versionLabel = new Label(parent, SWT.NONE);
versionLabel.setText("WFS Version");
selectVersion = new ComboViewer(parent);
GridDataFactory.swtDefaults().span(1, 1).grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(selectVersion.getControl());
selectVersion.setContentProvider(EnumContentProvider.getInstance());
selectVersion.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof WFSVersion) {
return ((WFSVersion) element).versionString;
}
return super.getText(element);
}
});
selectVersion.setInput(WFSVersion.class);
selectVersion.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
updateState();
}
});
// fixed content type
setContentType(HalePlatform.getContentTypeManager().getContentType(CONTENT_TYPE_ID_WFST));
// initial state update
updateState();
}
use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.
the class SourceViewerPage method createContent.
@Override
protected void createContent(Composite page) {
// init editor
IVerticalRuler ruler = createVerticalRuler();
IOverviewRuler overviewRuler = createOverviewRuler();
SourceViewerPanel<C> panel = new SourceViewerPanel<C>(page, ruler, overviewRuler, new SourceValidator() {
@Override
public boolean validate(String content) {
return SourceViewerPage.this.validate(content);
}
}, compiler);
viewer = panel.getViewer();
viewer.getTextWidget().setFont(JFaceResources.getTextFont());
viewer.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (ValidatingSourceViewer.PROPERTY_VALID.equals(event.getProperty())) {
getShell().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
setPageComplete((Boolean) event.getNewValue());
}
});
} else if (ValidatingSourceViewer.PROPERTY_VALIDATION_ENABLED.equals(event.getProperty())) {
if (!((Boolean) event.getNewValue())) {
// if validation is disabled, automatically set the page
// to be complete
setPageComplete(true);
}
}
}
});
configure(viewer);
SourceViewerKeyBindings.installDefault(viewer);
viewer.getDocument().set(initialValue);
addActions(panel.getToolbar(), viewer);
}
use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.
the class HaleConnectTarget method createControls.
@Override
public void createControls(Composite parent) {
getPage().setDescription("Please select a destination file for the export");
parent.setLayout(new GridLayout(4, false));
Composite loginGroup = new Composite(parent, SWT.BORDER);
loginGroup.setLayout(new GridLayout(4, false));
GridData loginGroupLayout = new GridData(SWT.LEAD, SWT.LEAD, false, false, 4, 1);
loginGroupLayout.widthHint = 550;
loginGroup.setLayoutData(loginGroupLayout);
/*
* Login status label
*/
loginStatusLabel = new Label(loginGroup, SWT.NONE);
loginStatusLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
loginButton = new Button(loginGroup, SWT.PUSH);
loginButton.setText("Login");
loginButton.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false, 1, 1));
loginButton.addSelectionListener(new SelectionAdapter() {
/**
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
HaleConnectLoginDialog loginDialog = HaleConnectLoginHandler.createLoginDialog(Display.getCurrent().getActiveShell());
if (loginDialog != null && loginDialog.open() == Dialog.OK) {
HaleConnectLoginHandler.performLogin(loginDialog);
updateLoginStatus();
updateState();
prefillTargetProject();
}
}
});
updateOrNewGroup = new Group(parent, SWT.NONE);
updateOrNewGroup.setText("Please choose whether you would like to...");
updateOrNewGroup.setLayout(new GridLayout(4, false));
updateOrNewGroup.setLayoutData(new GridData(SWT.LEAD, SWT.LEAD, false, false, 4, 1));
newProject = new Button(updateOrNewGroup, SWT.RADIO);
newProject.setText("create a new project on hale connect");
newProject.setSelection(true);
newProject.addSelectionListener(new SelectionAdapter() {
/**
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
updateState();
}
});
updateProject = new Button(updateOrNewGroup, SWT.RADIO);
updateProject.setText("update an existing project");
updateProject.addSelectionListener(new SelectionAdapter() {
/**
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
updateState();
}
});
controlsStackLayout = new StackLayout();
controlsStack = new Composite(parent, SWT.NONE);
controlsStack.setLayout(controlsStackLayout);
newProjectControls = new Composite(controlsStack, SWT.NONE);
newProjectControls.setLayout(new GridLayout(4, true));
GridData grid = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1);
newProjectControls.setLayoutData(grid);
ownershipGroup = new Composite(newProjectControls, SWT.NONE);
ownershipGroup.setLayout(new GridLayout(4, false));
ownershipGroup.setLayoutData(new GridData(SWT.LEAD, SWT.LEAD, false, false, 4, 1));
Label ownerLabel = new Label(ownershipGroup, SWT.NONE);
ownerLabel.setText("Who should own the uploaded project?");
ownerUser = new Button(ownershipGroup, SWT.RADIO);
ownerUser.setText("You");
ownerOrg = new Button(ownershipGroup, SWT.RADIO);
ownerOrg.setText("Your organisation");
orgSelector = new ComboViewer(ownershipGroup);
GridData orgSelectorGrid = new GridData(SWT.LEAD, SWT.LEAD, false, false);
orgSelectorGrid.widthHint = 175;
orgSelector.getCombo().setLayoutData(orgSelectorGrid);
orgSelector.setContentProvider(ArrayContentProvider.getInstance());
orgSelector.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof HaleConnectOrganisationInfo) {
return ((HaleConnectOrganisationInfo) element).getName();
}
return super.getText(element);
}
});
Composite bucketOptions = new Composite(parent, SWT.NONE);
bucketOptions.setLayout(new RowLayout());
bucketOptions.setLayoutData(new GridData(SWT.LEAD, SWT.LEAD, true, true, 4, 1));
enableVersioning = new Button(bucketOptions, SWT.CHECK);
enableVersioning.setText("Enable versioning?");
publicAccess = new Button(bucketOptions, SWT.CHECK);
publicAccess.setText("Allow public access?");
updateProjectControls = new Composite(controlsStack, SWT.NONE);
updateProjectControls.setVisible(false);
updateProjectControls.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
/*
* Project name text field
*/
projectName = new StringFieldEditor("project", "Project to update", updateProjectControls) {
// the following methods are overridden so the button
// may appear on the same line
@Override
public int getNumberOfControls() {
return super.getNumberOfControls() + 1;
}
@Override
protected void doFillIntoGrid(Composite parent, int numColumns) {
super.doFillIntoGrid(parent, numColumns - 1);
}
};
projectName.setEmptyStringAllowed(false);
projectName.setErrorMessage("Please select a project before continuing.");
projectName.setPage(getPage());
projectName.getTextControl(updateProjectControls).setEditable(false);
projectName.getTextControl(updateProjectControls).addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
selectProject();
}
});
projectName.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(FieldEditor.IS_VALID)) {
getPage().setMessage(null);
updateState();
} else if (event.getProperty().equals(FieldEditor.VALUE)) {
getPage().setMessage(null);
updateState();
}
}
});
/*
* Select project button
*/
selectProjectButton = new Button(updateProjectControls, SWT.PUSH);
selectProjectButton.setText("Select");
selectProjectButton.setToolTipText("Select project");
selectProjectButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
selectProjectButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectProject();
}
});
FontData currentFont = loginStatusLabel.getFont().getFontData()[0];
upstreamModifiedWarning = new Label(updateProjectControls, SWT.WRAP);
upstreamModifiedWarning.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false, 4, 1));
upstreamModifiedWarning.setFont(new Font(upstreamModifiedWarning.getDisplay(), new FontData(currentFont.getName(), currentFont.getHeight(), SWT.BOLD)));
upstreamModifiedWarning.setVisible(false);
Composite writerOptions = new Composite(parent, SWT.NONE);
writerOptions.setLayout(new RowLayout());
writerOptions.setLayoutData(new GridData(SWT.LEAD, SWT.LEAD, true, true, 4, 2));
includeWebResources = new Button(writerOptions, SWT.CHECK);
includeWebResources.setText("Include web resources?");
excludeData = new Button(writerOptions, SWT.CHECK);
excludeData.setText("Exclude source data?");
excludeData.setSelection(true);
excludeCachedResources = new Button(writerOptions, SWT.CHECK);
excludeCachedResources.setText("Use cached internal schema representation (required for big schema files)?");
excludeCachedResources.setSelection(true);
prefillTargetProject();
updateState();
}
use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.
the class DefaultSchemaTypePage method update.
/**
* Update all fields (should be called if page is initialized or the
* selection of input (file or table) has been changed
*/
protected void update() {
int length = 0;
// the header is not valid so clear all content
if (header == null || header.length == 0) {
// clear properties
clearPage();
return;
}
if (secondRow == null || secondRow.length == 0) {
secondRow = header;
}
if (header.length != 0) {
length = header.length;
}
// dispose all property names if the read configuration has been changed
if (lastSecondRow != null && !Arrays.equals(header, lastSecondRow)) {
for (TypeNameField properties : fields) {
properties.dispose();
properties.getTextControl(group).dispose();
properties.getLabelControl(group).dispose();
}
for (ComboViewer combViewer : comboFields) {
combViewer.getCombo().dispose();
}
fields.clear();
comboFields.clear();
}
if (!Arrays.equals(header, lastSecondRow)) {
for (int i = 0; i < length; i++) {
final TypeNameField propField;
final ComboViewer cv;
validSel.add(true);
propField = new TypeNameField("properties", Integer.toString(i + 1), group);
fields.add(propField);
propField.setEmptyStringAllowed(false);
propField.setErrorMessage("Please enter a valid Property Name");
propField.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
HashSet<String> hs = new HashSet<String>();
if (event.getProperty().equals(StringFieldEditor.VALUE)) {
for (TypeNameField field : fields) {
if (!hs.add(field.getStringValue())) {
valid = false;
break;
} else {
valid = true;
}
}
}
if (event.getProperty().equals(StringFieldEditor.IS_VALID)) {
isValid = (Boolean) event.getNewValue();
}
setPageComplete(isValid());
}
});
propField.setStringValue(header[i].replace(" ", ""));
cv = new ComboViewer(group);
comboFields.add(cv);
cv.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
int i = comboFields.indexOf(event.getSource());
PropertyTypeFactory actualSelection = ((PropertyTypeFactory) ((IStructuredSelection) cv.getSelection()).getFirstElement());
try {
actualSelection.createExtensionObject().convertFromField(secondRow[i]);
validSel.set(i, true);
} catch (Exception e) {
validSel.set(i, false);
}
if (validSel.contains(false)) {
int j = validSel.indexOf(false) + 1;
setMessage("Your selection in field # " + j + " is not valid!", WARNING);
} else {
setMessage(null);
}
}
});
cv.setContentProvider(ArrayContentProvider.getInstance());
cv.setLabelProvider(new LabelProvider() {
/**
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
@Override
public String getText(Object element) {
if (element instanceof PropertyTypeFactory) {
return ((PropertyTypeFactory) element).getDisplayName();
}
return super.getText(element);
}
});
Collection<PropertyTypeFactory> elements = PropertyTypeExtension.getInstance().getFactories();
cv.setInput(elements);
PropertyTypeFactory defaultSelection = PropertyTypeExtension.getInstance().getFactory("java.lang.String");
if (defaultSelection != null) {
cv.setSelection(new StructuredSelection(defaultSelection));
} else if (!elements.isEmpty()) {
cv.setSelection(new StructuredSelection(elements.iterator().next()));
}
}
}
group.setLayout(new GridLayout(3, false));
lastSecondRow = header;
group.layout();
sc.layout();
// setPageComplete(sfe.isValid() && isValid && valid);
}
Aggregations