use of org.eclipse.swt.accessibility.AccessibleEvent in project epp.mpc by eclipse.
the class AbstractMarketplaceWizardDialog method createButtonsForButtonBar.
@Override
protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);
if (backButton != null || nextButton != null) {
AccessibleAdapter adapter = new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
final Button button = (Button) ((Accessible) e.getSource()).getControl();
final String text = button.getText();
e.result = text.replace('<', ' ').replace('>', ' ');
}
};
if (backButton != null) {
backButton.getAccessible().addAccessibleListener(adapter);
}
if (nextButton != null) {
nextButton.getAccessible().addAccessibleListener(adapter);
}
}
}
use of org.eclipse.swt.accessibility.AccessibleEvent in project mdw-designer by CenturyLinkCloud.
the class ImageCombo method initAccessible.
void initAccessible() {
AccessibleAdapter accessibleAdapter = new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
String name = null;
Label label = getAssociatedLabel();
if (label != null) {
name = stripMnemonic(label.getText());
}
e.result = name;
}
@Override
public void getKeyboardShortcut(AccessibleEvent e) {
String shortcut = null;
Label label = getAssociatedLabel();
if (label != null) {
String lText = label.getText();
if (lText != null) {
char mnemonic = getMnemonic(lText);
if (mnemonic != '\0') {
// $NON-NLS-1$
shortcut = "Alt+" + mnemonic;
}
}
}
e.result = shortcut;
}
@Override
public void getHelp(AccessibleEvent e) {
e.result = getToolTipText();
}
};
getAccessible().addAccessibleListener(accessibleAdapter);
text.getAccessible().addAccessibleListener(accessibleAdapter);
table.getAccessible().addAccessibleListener(accessibleAdapter);
arrow.getAccessible().addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
// $NON-NLS-1$ //$NON-NLS-2$
e.result = isDropped() ? SWT.getMessage("SWT_Close") : SWT.getMessage("SWT_Open");
}
@Override
public void getKeyboardShortcut(AccessibleEvent e) {
// $NON-NLS-1$
e.result = "Alt+Down Arrow";
}
@Override
public void getHelp(AccessibleEvent e) {
e.result = getToolTipText();
}
});
getAccessible().addAccessibleTextListener(new AccessibleTextAdapter() {
@Override
public void getCaretOffset(AccessibleTextEvent e) {
e.offset = text.getCaretPosition();
}
});
getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
@Override
public void getChildAtPoint(AccessibleControlEvent e) {
Point testPoint = toControl(e.x, e.y);
if (getBounds().contains(testPoint)) {
e.childID = ACC.CHILDID_SELF;
}
}
@Override
public void getLocation(AccessibleControlEvent e) {
Rectangle location = getBounds();
Point pt = toDisplay(location.x, location.y);
e.x = pt.x;
e.y = pt.y;
e.width = location.width;
e.height = location.height;
}
@Override
public void getChildCount(AccessibleControlEvent e) {
e.detail = 0;
}
@Override
public void getRole(AccessibleControlEvent e) {
e.detail = ACC.ROLE_COMBOBOX;
}
@Override
public void getState(AccessibleControlEvent e) {
e.detail = ACC.STATE_NORMAL;
}
@Override
public void getValue(AccessibleControlEvent e) {
e.result = getText();
}
});
text.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
@Override
public void getRole(AccessibleControlEvent e) {
e.detail = text.getEditable() ? ACC.ROLE_TEXT : ACC.ROLE_LABEL;
}
});
arrow.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
@Override
public void getDefaultAction(AccessibleControlEvent e) {
// $NON-NLS-1$ //$NON-NLS-2$
e.result = isDropped() ? SWT.getMessage("SWT_Close") : SWT.getMessage("SWT_Open");
}
});
}
use of org.eclipse.swt.accessibility.AccessibleEvent in project archi by archimatetool.
the class MultiLineLabel method addAccessibility.
private void addAccessibility() {
getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
@Override
public void getRole(AccessibleControlEvent e) {
e.detail = ACC.ROLE_LABEL;
}
@Override
public void getState(AccessibleControlEvent e) {
e.detail = ACC.STATE_READONLY;
}
});
getAccessible().addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
e.result = getText();
}
});
addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
Point p = getViewport().getViewLocation();
int dy = getFont().getFontData()[0].getHeight();
int dx = dy * 3 / 2;
boolean mirrored = (e.widget.getStyle() & SWT.MIRRORED) != 0;
if (e.keyCode == SWT.ARROW_DOWN) {
scrollToY(p.y + dy / 2);
scrollToY(p.y + dy);
scrollToY(p.y + dy * 3 / 2);
scrollToY(p.y + dy * 2);
} else if (e.keyCode == SWT.ARROW_UP) {
scrollToY(p.y - dy / 2);
scrollToY(p.y - dy);
scrollToY(p.y - dy * 3 / 2);
scrollToY(p.y - dy * 2);
} else if ((!mirrored && e.keyCode == SWT.ARROW_RIGHT) || (mirrored && e.keyCode == SWT.ARROW_LEFT)) {
scrollToX(p.x + dx);
scrollToX(p.x + dx * 2);
scrollToX(p.x + dx * 3);
} else if ((!mirrored && e.keyCode == SWT.ARROW_LEFT) || (mirrored && e.keyCode == SWT.ARROW_RIGHT)) {
scrollToX(p.x - dx);
scrollToX(p.x - dx * 2);
scrollToX(p.x - dx * 3);
}
}
});
}
use of org.eclipse.swt.accessibility.AccessibleEvent in project azure-tools-for-java by Microsoft.
the class SparkSubmissionExDialog method createContents.
@Override
protected Control createContents(Composite parent) {
final Composite root = new Composite(parent, SWT.NONE);
root.setLayout(new GridLayout(2, false));
root.setLayoutData(new GridDataBuilder().widthHint(600).build());
final Label clusterListLabel = new Label(root, SWT.LEFT);
clusterListLabel.setText("Cluster Name:");
clustersListComboBox = new Combo(root, SWT.READ_ONLY);
clustersListComboBox.setLayoutData(new GridDataBuilder().build());
clustersListComboBox.setToolTipText("The HDInsight Spark cluster you want to submit your application to. Only Linux cluster is supported.");
clustersListComboBox.addModifyListener(event -> {
IClusterDetail clusterDetail = getSelectedCluster(clustersListComboBox.getText());
if (clusterDetail != null && ClusterManagerEx.getInstance().isHdiReaderCluster(clusterDetail)) {
showHdiReaderErrors(true);
} else {
showHdiReaderErrors(false);
}
});
// Execute "select the first item" operation after the dialog opened
Display.getDefault().asyncExec(() -> {
for (IClusterDetail clusterDetail : cachedClusterDetails) {
clustersListComboBox.add(clusterDetail.getTitle());
clustersListComboBox.setData(clusterDetail.getTitle(), clusterDetail);
}
if (cachedClusterDetails.size() > 0) {
// Send SWT.Modify event after select the first item
clustersListComboBox.select(0);
}
});
// Add blank label as a placeholder
final Label placeholderLabel = new Label(root, SWT.LEFT);
placeholderLabel.setVisible(false);
final Composite warningWithLink = new Composite(root, SWT.NONE);
warningWithLink.setLayout(new GridLayout(2, false));
warningWithLink.setLayoutData(new GridDataBuilder().build());
// Add warning message and link cluster button composite
hdiReaderErrorMsgLabel = new Label(warningWithLink, SWT.LEFT);
hdiReaderErrorMsgLabel.setText("No Ambari permission to submit job to the selected cluster...");
hdiReaderErrorMsgLabel.setToolTipText("No Ambari permission to submit job to the selected cluster. Please ask the cluster owner or user " + "access administrator to upgrade your role to HDInsight Cluster Operator in the Azure Portal, or " + "link to the selected cluster.");
hdiReaderLink = new Link(warningWithLink, SWT.NONE);
hdiReaderLink.setText("<a href=\" \">Link this cluster</a>");
hdiReaderLink.addListener(SWT.Selection, e -> {
IClusterDetail selectedClusterDetail = getSelectedCluster(clustersListComboBox.getText());
if (selectedClusterDetail != null && ClusterManagerEx.getInstance().isHdiReaderCluster(selectedClusterDetail)) {
String defaultStorageRootPath = ((ClusterDetail) selectedClusterDetail).getDefaultStorageRootPath();
AddNewHDInsightReaderClusterForm linkClusterForm = new AddNewHDInsightReaderClusterForm(PluginUtil.getParentShell(), null, (ClusterDetail) selectedClusterDetail) {
protected void afterOkActionPerformed() {
showHdiReaderErrors(false);
HDInsightAdditionalClusterDetail linkedCluster = (HDInsightAdditionalClusterDetail) ClusterManagerEx.getInstance().findClusterDetail(clusterDetail -> getSelectedLinkedHdiCluster(clusterDetail, selectedClusterDetail.getName()), true);
if (linkedCluster != null) {
linkedCluster.setDefaultStorageRootPath(defaultStorageRootPath);
ClusterManagerEx.getInstance().updateHdiAdditionalClusterDetail(linkedCluster);
// Display the HDI reader cluster as linked cluster
Display.getDefault().asyncExec(() -> {
int selectedClusterIndex = clustersListComboBox.indexOf(selectedClusterDetail.getTitle());
clustersListComboBox.setItem(selectedClusterIndex, linkedCluster.getTitle());
clustersListComboBox.setData(linkedCluster.getTitle(), linkedCluster);
});
}
}
};
linkClusterForm.open();
}
});
// Hide HDInsight reader cluster error when dialog open at first time
showHdiReaderErrors(false);
// Radio button group for the artifact selection
final Group artifactSelectGroup = new Group(root, SWT.NONE);
artifactSelectGroup.setText("Select an Artifact to submit");
artifactSelectGroup.setLayout(new GridLayout(2, false));
artifactSelectGroup.setLayoutData(new GridDataBuilder().span(2, 2).build());
// Project artifacts Radio button
projectArtifactRadioButton = new Button(artifactSelectGroup, SWT.RADIO);
projectArtifactRadioButton.setText("Artifact from Eclipse project:");
projectArtifactRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ignored) {
switchToProjectArtifactSelection(true);
}
});
final String selectProjectArtifactTip = "The Artifact you want to use.";
projectArtifactSelectComboBox = new Combo(artifactSelectGroup, SWT.READ_ONLY);
projectArtifactSelectComboBox.setToolTipText(selectProjectArtifactTip);
projectArtifactSelectComboBox.setLayoutData(new GridDataBuilder().widthHint(400).build());
projectArtifactSelectComboBox.getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(AccessibleEvent event) {
event.result = projectArtifactRadioButton.getText();
}
});
final String[] projects = getProjects();
projectArtifactSelectComboBox.setItems(projects);
if (myProject != null) {
final String selectedProjectName = myProject.getName();
for (int i = 0; i < projects.length; ++i) {
if (projects[i].equalsIgnoreCase(selectedProjectName)) {
projectArtifactSelectComboBox.select(i);
}
}
} else if (projects.length > 0) {
projectArtifactSelectComboBox.select(0);
}
// Local artifact
localArtifactRadioButton = new Button(artifactSelectGroup, SWT.RADIO);
localArtifactRadioButton.setText("Artifact from hard disk:");
localArtifactRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ignored) {
switchToProjectArtifactSelection(false);
}
});
final Composite localArtifactSelection = new Composite(artifactSelectGroup, SWT.NONE);
localArtifactSelection.setLayout(new GridLayout(2, false));
localArtifactSelection.setLayoutData(new GridDataBuilder().build());
final String localArtifactInputTip = "Input the local artifact path.";
localArtifactInput = new Text(localArtifactSelection, SWT.LEFT | SWT.BORDER);
localArtifactInput.setToolTipText(localArtifactInputTip);
localArtifactInput.setLayoutData(new GridDataBuilder().build());
localArtifactInput.getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(AccessibleEvent event) {
event.result = localArtifactRadioButton.getText();
}
});
// Browser button to open file selection dialog
localArtifactBrowseButton = new Button(localArtifactSelection, SWT.PUSH);
localArtifactBrowseButton.setText("Browse");
localArtifactBrowseButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
FileDialog dialog = new FileDialog(SparkSubmissionExDialog.this.getShell());
String[] extensions = { "*.jar", "*.JAR" };
dialog.setFilterExtensions(extensions);
String file = dialog.open();
if (file != null) {
localArtifactInput.setText(file);
}
}
});
localArtifactBrowseButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(AccessibleEvent event) {
event.result = "Browse. Open System File dialog to select artifact";
}
});
// Default selection
projectArtifactRadioButton.setSelection(true);
switchToProjectArtifactSelection(true);
// Main class input
final Label sparkMainClassLabel = new Label(root, SWT.LEFT);
sparkMainClassLabel.setText("Main class name");
mainClassCombo = new Combo(root, SWT.DROP_DOWN);
mainClassCombo.setToolTipText("Application's java/spark main class");
mainClassCombo.setLayoutData(new GridDataBuilder().build());
try {
java.util.Set<String> classes = getClassesWithMainMethod();
String[] names = new String[classes.size()];
classes.toArray(names);
mainClassCombo.setItems(names);
mainClassCombo.select(0);
} catch (CoreException e1) {
Activator.getDefault().log("get main class list error", e1);
}
// Job configuration
final Label jobConfigurationLabel = new Label(root, SWT.LEFT);
jobConfigurationLabel.setText("Job configurations");
jobConfigurationLabel.setLayoutData(new GridDataBuilder().verticalAlignment(TOP).build());
jobConfigTableViewer = new TableViewer(root, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
jobConfigTableViewer.setUseHashlookup(true);
jobConfigTableViewer.setColumnProperties(COLUMN_NAMES);
final Table jobConfigurationTable = jobConfigTableViewer.getTable();
jobConfigurationTable.setHeaderVisible(true);
jobConfigurationTable.setLinesVisible(true);
jobConfigurationTable.setLayout(new GridLayout(1, false));
jobConfigurationTable.setLayoutData(new GridDataBuilder().heightHint(75).build());
final TableViewerColumn keyCol = new TableViewerColumn(jobConfigTableViewer, SWT.NONE);
keyCol.getColumn().setText(COLUMN_NAMES[0]);
keyCol.getColumn().setWidth(150);
final TableViewerColumn valueCol = new TableViewerColumn(jobConfigTableViewer, SWT.NONE);
valueCol.getColumn().setText(COLUMN_NAMES[1]);
valueCol.getColumn().setWidth(80);
final CellEditor[] editors = new CellEditor[] { new TextCellEditor(jobConfigurationTable), new TextCellEditor(jobConfigurationTable) };
jobConfigTableViewer.setCellEditors(editors);
jobConfigTableViewer.setContentProvider(new JobConfigurationContentProvider());
jobConfigTableViewer.setLabelProvider(new JobConfigurationLabelProvider());
jobConfigTableViewer.setCellModifier(new JobConfigurationCellModifier());
jobConfigurationTable.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.keyCode == SWT.SPACE) {
TableItem[] selection = ((Table) e.getSource()).getSelection();
if (selection.length > 0) {
jobConfigTableViewer.editElement(selection[0].getData(), 1);
}
}
}
});
ColumnViewerEditorActivationStrategy activationSupport = new ColumnViewerEditorActivationStrategy(jobConfigTableViewer) {
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
// Enable editor only with mouse double click or space key press
if (event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC || event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.character == SWT.SPACE) {
EventObject source = event.sourceEvent;
// Take double right click as invalid mouse event
return !(source instanceof MouseEvent && ((MouseEvent) source).button == 3);
}
return false;
}
};
TableViewerEditor.create(jobConfigTableViewer, activationSupport, ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
initializeTable();
// Make the table focus at the first cell when it get focus at the first time
jobConfigTableViewer.editElement(jobConfigurationTable.getItem(0).getData(), 0);
final Label label = new Label(root, SWT.LEFT);
label.setText("Command line arguments");
final String commandLineTip = "Command line arguments used in your main class; multiple arguments should be split by space.";
commandLineTextField = new Text(root, SWT.LEFT | SWT.BORDER);
commandLineTextField.setToolTipText(commandLineTip);
commandLineTextField.setLayoutData(new GridDataBuilder().build());
final String refJarsTip = "Files to be placed on the java classpath; The path needs to be a Azure Blob Storage Path (path started with wasb://); Multiple paths should be split by semicolon (;)";
final Label referencedJarsLabel = new Label(root, SWT.LEFT);
referencedJarsLabel.setText("Referenced Jars");
referencedJarsTextField = new Text(root, SWT.BORDER | SWT.LEFT);
referencedJarsTextField.setToolTipText(refJarsTip);
referencedJarsTextField.setLayoutData(new GridDataBuilder().build());
final Label referencedFilesLabel = new Label(root, SWT.LEFT);
referencedFilesLabel.setText("Referenced Files");
final String refFilesTip = "Files to be placed in executor working directory. The path needs to be a Azure Blob Storage Path (path started with wasb://); Multiple paths should be split by semicolon (;) ";
referencedFilesTextField = new Text(root, SWT.BORDER | SWT.LEFT);
referencedFilesTextField.setToolTipText(refFilesTip);
referencedFilesTextField.setLayoutData(new GridDataBuilder().build());
return super.createContents(parent);
}
use of org.eclipse.swt.accessibility.AccessibleEvent in project azure-tools-for-java by Microsoft.
the class SparkSubmissionToolWindowView method createPartControl.
@Override
public void createPartControl(Composite parent) {
GridLayout layout = new GridLayout();
layout.numColumns = 2;
parent.setLayout(layout);
Composite composite = new Composite(parent, SWT.NONE);
layout = new GridLayout();
composite.setLayout(layout);
GridData gridData = new GridData();
gridData.verticalAlignment = SWT.TOP;
composite.setLayoutData(gridData);
stopButton = new Button(composite, SWT.PUSH);
stopButton.setText("Stop");
stopButton.setToolTipText("Stop execution of current application");
stopButton.setImage(Activator.getImageDescriptor(CommonConst.StopIconPath).createImage());
stopButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent evt) {
DefaultLoader.getIdeHelper().executeOnPooledThread(new Runnable() {
@Override
public void run() {
if (!StringHelper.isNullOrWhiteSpace(connectionUrl)) {
AppInsightsClient.create(Messages.SparkSubmissionStopButtionClickEvent, null);
EventUtil.logEvent(EventType.info, HDINSIGHT, Messages.SparkSubmissionStopButtionClickEvent, null);
try {
HttpResponse deleteResponse = SparkBatchSubmission.getInstance().killBatchJob(connectionUrl + "/livy/batches", batchId);
if (deleteResponse.getCode() == 201 || deleteResponse.getCode() == 200) {
jobStatusManager.setJobKilled();
setInfo("========================Stop application successfully=======================");
} else {
setError(String.format("Error : Failed to stop spark application. error code : %d, reason : %s.", deleteResponse.getCode(), deleteResponse.getContent()));
}
} catch (IOException exception) {
setError("Error : Failed to stop spark application. exception : " + exception.toString());
}
}
}
});
}
});
stopButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(AccessibleEvent e) {
super.getName(e);
e.result = stopButton.getToolTipText();
}
});
openSparkUIButton = new Button(composite, SWT.PUSH);
openSparkUIButton.setText("Open Spark UI");
openSparkUIButton.setToolTipText("Open Spark UI");
openSparkUIButton.setImage(Activator.getImageDescriptor(CommonConst.OpenSparkUIIconPath).createImage());
openSparkUIButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
try {
if (jobStatusManager.isApplicationGenerated()) {
String sparkApplicationUrl = String.format(yarnRunningUIUrlFormat, connectionUrl, jobStatusManager.getApplicationId());
PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL(sparkApplicationUrl));
}
} catch (Exception browseException) {
DefaultLoader.getUIHelper().showError("Failed to browse spark application yarn url", "Spark Submission");
}
}
});
openSparkUIButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(AccessibleEvent e) {
super.getName(e);
e.result = openSparkUIButton.getToolTipText();
}
});
gridData = new GridData();
gridData.horizontalAlignment = SWT.FILL;
gridData.verticalAlignment = SWT.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.grabExcessHorizontalSpace = true;
outputPanel = new Browser(parent, SWT.BORDER);
outputPanel.setLayoutData(gridData);
PropertyChangeListener propertyChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent evt) {
// if (ApplicationManager.getApplication().isDispatchThread()) {
changeSupportHandler(evt);
// // } else {
// try {
// SwingUtilities.invokeAndWait(new Runnable() {
// @Override
// public void run() {
// changeSupportHandler(evt);
// }
// }
// );
// } catch (InterruptedException e) {
// e.printStackTrace();
// } catch (InvocationTargetException e) {
// e.printStackTrace();
// }
// }
}
private void changeSupportHandler(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("toolWindowText")) {
outputPanel.setText(evt.getNewValue().toString());
} else if (evt.getPropertyName().equals("isStopButtonEnable")) {
stopButton.setEnabled(Boolean.parseBoolean(evt.getNewValue().toString()));
} else if (evt.getPropertyName().equals("isBrowserButtonEnable")) {
openSparkUIButton.setEnabled(Boolean.parseBoolean(evt.getNewValue().toString()));
}
}
};
// outputPanel.addPropertyChangeListener(propertyChangeListener);
changeSupport = new PropertyChangeSupport(outputPanel);
changeSupport.addPropertyChangeListener(propertyChangeListener);
}
Aggregations