use of org.eclipse.swt.events.KeyListener in project janrufmonitor by tbrandt77.
the class GosPage method createControl.
public void createControl(Composite c) {
Composite co = new Composite(c, SWT.NONE);
co.setLayout(new GridLayout(2, false));
co.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
int operations = DND.DROP_MOVE;
Transfer[] types = new Transfer[] { FileTransfer.getInstance() };
DropTarget target = new DropTarget(co, operations);
target.setTransfer(types);
target.addDropListener(new DropTargetAdapter() {
public void drop(DropTargetEvent event) {
// A drop has occurred, copy over the data
if (event.data == null) {
event.detail = DND.DROP_NONE;
return;
}
File f = new File(((String[]) event.data)[0]);
m_logger.info("Detected drag action with file: " + f.getAbsolutePath());
if (f.exists() && f.getName().toLowerCase().endsWith(".jam.zip")) {
ZipArchive zip = new ZipArchive(f, false);
try {
zip.open();
List files = zip.list(new FilenameFilter() {
public boolean accept(File f, String name) {
return name.toLowerCase().startsWith("install/repository.") && name.toLowerCase().endsWith(".inf");
}
});
if (files.size() == 1) {
m_logger.info("Found a valid generic online module.");
Properties inf = new Properties();
inf.load(zip.get((String) files.get(0)));
String ns = ((String) files.get(0)).substring("install/repository.".length(), ((String) files.get(0)).length() - 4);
name.setText(ns);
url.setText(inf.getProperty("repository." + ns + ":url:value", ""));
offset.setText(inf.getProperty("repository." + ns + ":skipbytes:value", "0"));
lastname.setText(inf.getProperty("repository." + ns + ":regexp.lastname:value", ""));
firstname.setText(inf.getProperty("repository." + ns + ":regexp.firstname:value", ""));
street.setText(inf.getProperty("repository." + ns + ":regexp.street:value", ""));
streetno.setText(inf.getProperty("repository." + ns + ":regexp.streetno:value", ""));
postal.setText(inf.getProperty("repository." + ns + ":regexp.pcode:value", ""));
city.setText(inf.getProperty("repository." + ns + ":regexp.city:value", ""));
area.setText(inf.getProperty("repository." + ns + ":regexp.areacode:value", ""));
number.setText(inf.getProperty("repository." + ns + ":regexp.phone:value", ""));
intarea.setText(inf.getProperty("repository." + ns + ":intareacode:value", ""));
}
zip.close();
} catch (ZipArchiveException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (IOException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
}
}
});
Label l = new Label(co, SWT.LEFT);
l.setText(this.m_i18n.getString(this.getNamespace(), "name", "label", this.m_language));
GridData gd = new GridData();
gd.widthHint = 150;
name = new Text(co, SWT.BORDER);
name.setLayoutData(gd);
name.setText("");
name.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setPageComplete(isComplete());
}
});
l = new Label(co, SWT.LEFT);
l.setText(this.m_i18n.getString(this.getNamespace(), "version", "label", this.m_language));
gd = new GridData();
gd.widthHint = 50;
version = new Text(co, SWT.BORDER);
version.setLayoutData(gd);
version.setText("1.0.0");
version.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setPageComplete(isComplete());
}
});
l = new Label(co, SWT.LEFT);
l.setText(this.m_i18n.getString(this.getNamespace(), "url", "label", this.m_language));
url = new Text(co, SWT.BORDER);
gd.widthHint = 300;
url.setLayoutData(gd);
url.setText("");
url.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setPageComplete(isComplete());
}
});
l = new Label(co, SWT.LEFT);
l.setText(this.m_i18n.getString(this.getNamespace(), "offset", "label", this.m_language));
offset = new Text(co, SWT.BORDER);
offset.setText("");
offset.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setPageComplete(isComplete());
}
});
l = new Label(co, SWT.LEFT);
l.setText(this.m_i18n.getString(this.getNamespace(), "lastname", "label", this.m_language));
lastname = new Text(co, SWT.BORDER);
lastname.setLayoutData(gd);
lastname.setText("");
lastname.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setPageComplete(isComplete());
lastname.setForeground(new Color(lastname.getDisplay(), 0, 0, 0));
}
});
l = new Label(co, SWT.LEFT);
l.setText(this.m_i18n.getString(this.getNamespace(), "firstname", "label", this.m_language));
firstname = new Text(co, SWT.BORDER);
firstname.setText("");
firstname.setLayoutData(gd);
firstname.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setPageComplete(isComplete());
firstname.setForeground(new Color(firstname.getDisplay(), 0, 0, 0));
}
});
l = new Label(co, SWT.LEFT);
l.setText(this.m_i18n.getString(this.getNamespace(), "street", "label", this.m_language));
street = new Text(co, SWT.BORDER);
street.setLayoutData(gd);
street.setText("");
street.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setPageComplete(isComplete());
street.setForeground(new Color(street.getDisplay(), 0, 0, 0));
}
});
l = new Label(co, SWT.LEFT);
l.setText(this.m_i18n.getString(this.getNamespace(), "streetno", "label", this.m_language));
streetno = new Text(co, SWT.BORDER);
streetno.setLayoutData(gd);
streetno.setText("");
streetno.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setPageComplete(isComplete());
streetno.setForeground(new Color(streetno.getDisplay(), 0, 0, 0));
}
});
l = new Label(co, SWT.LEFT);
l.setText(this.m_i18n.getString(this.getNamespace(), "postal", "label", this.m_language));
postal = new Text(co, SWT.BORDER);
postal.setLayoutData(gd);
postal.setText("");
postal.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setPageComplete(isComplete());
postal.setForeground(new Color(postal.getDisplay(), 0, 0, 0));
}
});
l = new Label(co, SWT.LEFT);
l.setText(this.m_i18n.getString(this.getNamespace(), "city", "label", this.m_language));
city = new Text(co, SWT.BORDER);
city.setLayoutData(gd);
city.setText("");
city.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setPageComplete(isComplete());
city.setForeground(new Color(city.getDisplay(), 0, 0, 0));
}
});
l = new Label(co, SWT.LEFT);
l.setText(this.m_i18n.getString(this.getNamespace(), "area", "label", this.m_language));
area = new Text(co, SWT.BORDER);
area.setLayoutData(gd);
area.setText("");
area.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setPageComplete(isComplete());
area.setForeground(new Color(area.getDisplay(), 0, 0, 0));
}
});
l = new Label(co, SWT.LEFT);
l.setText(this.m_i18n.getString(this.getNamespace(), "number", "label", this.m_language));
number = new Text(co, SWT.BORDER);
number.setLayoutData(gd);
number.setText("");
number.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setPageComplete(isComplete());
number.setForeground(new Color(number.getDisplay(), 0, 0, 0));
}
});
l = new Label(co, SWT.LEFT);
l.setText(this.m_i18n.getString(this.getNamespace(), "intarea", "label", this.m_language));
intarea = new Text(co, SWT.BORDER);
intarea.setText("49");
intarea.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setPageComplete(isComplete());
}
});
l = new Label(co, SWT.LEFT);
l.setText(this.m_i18n.getString(this.getNamespace(), "locale", "label", this.m_language));
Locale[] locales = Locale.getAvailableLocales();
List localeList = new ArrayList(locales.length);
Locale lo = null;
for (int i = 0; i < locales.length; i++) {
lo = locales[i];
if (lo.toString().indexOf("_") > 0)
localeList.add(lo);
}
Collections.sort(localeList, new Comparator() {
public int compare(Object l1, Object l2) {
if (l1 instanceof Locale && l2 instanceof Locale) {
return ((Locale) l1).getDisplayCountry().compareTo(((Locale) l2).getDisplayCountry());
}
return 0;
}
});
String[] countryNames = new String[localeList.size()];
for (int i = 0; i < localeList.size(); i++) {
countryNames[i] = ((Locale) localeList.get(i)).getDisplayCountry() + " (" + ((Locale) localeList.get(i)).getDisplayLanguage() + ")";
}
locale = new Combo(co, SWT.READ_ONLY);
locale.setItems(countryNames);
for (int i = 0; i < countryNames.length; i++) {
locale.setData(countryNames[i], localeList.get(i));
}
locale.select(0);
locale.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setPageComplete(isComplete());
}
});
l = new Label(co, SWT.LEFT);
l.setText(this.m_i18n.getString(this.getNamespace(), "encoding", "label", this.m_language));
String[] encodings = new String[] { "ISO-8859-1", "UTF-8", "UTF-16" };
encoding = new Combo(co, SWT.READ_ONLY);
encoding.setItems(encodings);
for (int i = 0; i < encodings.length; i++) {
encoding.setData(encodings[i], encodings[i]);
}
encoding.select(0);
locale.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setPageComplete(isComplete());
}
});
Composite dco2 = new Composite(co, SWT.NONE);
dco2.setLayout(new GridLayout(1, false));
gd = new GridData();
gd.horizontalSpan = 2;
dco2.setLayoutData(gd);
ffe = new FileFieldEditor(this.m_i18n.getString(this.getNamespace(), "fname", "label", this.m_language), this.m_i18n.getString(this.getNamespace(), "flabel", "label", this.m_language), dco2);
ffe.setFileExtensions(new String[] { "*.png" });
l = new Label(co, SWT.LEFT);
l = new Label(co, SWT.LEFT);
Composite dco = new Composite(co, SWT.NONE);
dco.setLayout(new GridLayout(1, false));
gd = new GridData();
gd.horizontalSpan = 2;
dco.setLayoutData(gd);
dfe = new DirectoryFieldEditor(this.m_i18n.getString(this.getNamespace(), "dname", "label", this.m_language), this.m_i18n.getString(this.getNamespace(), "dlabel", "label", this.m_language), this.m_i18n.getString(this.getNamespace(), "dmessage", "label", this.m_language), dco);
dfe.setStringValue(PathResolver.getInstance().getTempDirectory());
Group c2 = new Group(co, SWT.SHADOW_ETCHED_IN);
c2.setLayout(new GridLayout(2, false));
gd = new GridData();
gd.horizontalSpan = 2;
gd.horizontalAlignment = GridData.FILL_HORIZONTAL;
c2.setLayoutData(gd);
l = new Label(c2, SWT.LEFT);
l.setText(this.m_i18n.getString(this.getNamespace(), "testnumber", "label", this.m_language));
l = new Label(c2, SWT.LEFT);
final Text testnum = new Text(c2, SWT.BORDER);
testnum.setText("");
gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 400;
// gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
testnum.setLayoutData(gd);
final Button test = new Button(c2, SWT.PUSH);
test.setEnabled(false);
test.setText(this.m_i18n.getString(this.getNamespace(), "test", "label", this.m_language));
test.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IPhonenumber pn = getRuntime().getCallerFactory().createPhonenumber(testnum.getText().startsWith("0") ? testnum.getText().substring(1) : testnum.getText());
pn.setIntAreaCode(intarea.getText());
Properties config = new Properties();
config.setProperty("version", version.getText());
config.setProperty("skipbytes", offset.getText());
config.setProperty("url", url.getText());
config.setProperty("regexp.lastname", lastname.getText());
config.setProperty("regexp.firstname", firstname.getText());
config.setProperty("regexp.street", street.getText());
config.setProperty("regexp.streetno", streetno.getText());
config.setProperty("regexp.pcode", postal.getText());
config.setProperty("regexp.city", city.getText());
config.setProperty("regexp.areacode", area.getText());
config.setProperty("regexp.phone", number.getText());
config.setProperty("intareacode", intarea.getText());
config.setProperty("locale", ((Locale) locale.getData(locale.getText())).toString());
config.setProperty("encoding", encoding.getText());
config.setProperty("icon", ffe.getStringValue());
TestWebCallerManager twcm = new TestWebCallerManager(config);
try {
ICaller c = twcm.getCaller(pn);
IService dialog = getRuntime().getServiceFactory().getService("DefaultCallDialogService");
if (dialog != null) {
ICall call = getRuntime().getCallFactory().createCall(c, getRuntime().getMsnManager().createMsn("12345"), getRuntime().getCipManager().createCip("1"));
if (dialog instanceof AbstractReceiverConfigurableService) {
((AbstractReceiverConfigurableService) dialog).receivedValidRule(call);
}
lastname.setForeground(new Color(lastname.getDisplay(), 0, 0, 0));
firstname.setForeground(new Color(firstname.getDisplay(), 0, 0, 0));
street.setForeground(new Color(street.getDisplay(), 0, 0, 0));
streetno.setForeground(new Color(streetno.getDisplay(), 0, 0, 0));
postal.setForeground(new Color(postal.getDisplay(), 0, 0, 0));
city.setForeground(new Color(city.getDisplay(), 0, 0, 0));
area.setForeground(new Color(area.getDisplay(), 0, 0, 0));
number.setForeground(new Color(number.getDisplay(), 0, 0, 0));
}
} catch (CallerNotFoundException ex) {
PropagationFactory.getInstance().fire(new Message(Message.INFO, getNamespace(), "notidentified", new String[] { pn.getTelephoneNumber() }, ex));
// first CallerNotFoundException
Throwable cause = ex.getCause();
if (cause != null && !(cause instanceof RegExpURLRequesterException)) {
cause = cause.getCause();
}
if (cause != null && cause instanceof RegExpURLRequesterException) {
List failure = ((RegExpURLRequesterException) cause).getFailures();
String c = null;
for (int i = 0; i < failure.size(); i++) {
c = (String) failure.get(i);
if (c.equalsIgnoreCase("regexp.lastname")) {
lastname.setForeground(new Color(lastname.getDisplay(), 255, 0, 0));
}
if (c.equalsIgnoreCase("regexp.firstname")) {
firstname.setForeground(new Color(firstname.getDisplay(), 255, 0, 0));
}
if (c.equalsIgnoreCase("regexp.street")) {
street.setForeground(new Color(street.getDisplay(), 255, 0, 0));
}
if (c.equalsIgnoreCase("regexp.streetno")) {
streetno.setForeground(new Color(streetno.getDisplay(), 255, 0, 0));
}
if (c.equalsIgnoreCase("regexp.pcode")) {
postal.setForeground(new Color(postal.getDisplay(), 255, 0, 0));
}
if (c.equalsIgnoreCase("regexp.city")) {
city.setForeground(new Color(city.getDisplay(), 255, 0, 0));
}
if (c.equalsIgnoreCase("regexp.areacode")) {
area.setForeground(new Color(area.getDisplay(), 255, 0, 0));
}
if (c.equalsIgnoreCase("regexp.phone")) {
number.setForeground(new Color(number.getDisplay(), 255, 0, 0));
}
}
}
} finally {
twcm = null;
}
}
});
testnum.addKeyListener(new KeyListener() {
public void keyPressed(org.eclipse.swt.events.KeyEvent e) {
if (testnum.getText().length() > 0 && url.getText().length() > 0 && number.getText().length() > 0)
test.setEnabled(true);
else
test.setEnabled(false);
}
public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
}
});
this.setPageComplete(isComplete());
this.setControl(co);
}
use of org.eclipse.swt.events.KeyListener in project tdq-studio-se by Talend.
the class DQRespositoryView method createPartControl.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.navigator.CommonNavigator#createPartControl(org.eclipse .swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new BorderLayout());
Composite topComp = new Composite(parent, SWT.NONE);
topComp.setFont(parent.getFont());
topComp.setLayoutData(BorderLayout.NORTH);
Composite bottomComp = new Composite(parent, SWT.NONE);
bottomComp.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
bottomComp.setFont(parent.getFont());
bottomComp.setLayoutData(BorderLayout.CENTER);
topComp.setLayout(new BorderLayout());
FillLayout bottomLayout = new FillLayout(SWT.VERTICAL);
bottomComp.setLayout(bottomLayout);
createTreeFilter(topComp);
super.createPartControl(bottomComp);
// For removing the popup menu of DQRepositoryView.
// $NON-NLS-1$
MenuManager menuMgr = new MenuManager("org.talend.dataprofiler.core.ui.views.DQRespositoryView");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager menuManager) {
ISelection selection = getCommonViewer().getSelection();
getNavigatorActionService().setContext(new ActionContext(selection));
getNavigatorActionService().fillContextMenu(menuManager);
}
});
Menu menu = menuMgr.createContextMenu(getCommonViewer().getTree());
getCommonViewer().getTree().setMenu(menu);
this.addViewerFilter(EMFObjFilter.FILTER_ID);
this.addViewerFilter(ReportingFilter.FILTER_ID);
this.addViewerFilter(FolderObjFilter.FILTER_ID);
adjustFilter();
activateContext();
getCommonViewer().setSorter(null);
getCommonViewer().getTree().addTreeListener(new TreeAdapter() {
@Override
public void treeExpanded(TreeEvent e) {
TreeItem item = (TreeItem) e.item;
if (!item.getText().endsWith(")")) {
// $NON-NLS-1$
Object obj = item.getData();
if (obj instanceof TableFolderNode || obj instanceof ViewFolderNode || obj instanceof ColumnFolderNode) {
// $NON-NLS-1$ //$NON-NLS-2$
item.setText(item.getText() + "(" + item.getItemCount() + ")");
}
}
super.treeExpanded(e);
}
});
getCommonViewer().getTree().addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
boolean superDoubleClick = true;
Tree tree = (Tree) e.getSource();
Point point = new Point(e.x, e.y);
final TreeItem item = tree.getItem(point);
if (item != null) {
Object obj = item.getData();
if (obj instanceof AbstractFolderNode) {
AbstractFolderNode node = (AbstractFolderNode) obj;
node.loadChildren();
Object[] children = node.getChildren();
if (children != null) {
if (item.getText().indexOf("(") > 0) {
// $NON-NLS-1$
item.setText(// $NON-NLS-1$ //$NON-NLS-2$
item.getText().substring(0, item.getText().indexOf("(")) + "(" + children.length + // $NON-NLS-1$
")");
} else {
// $NON-NLS-1$ //$NON-NLS-2$
item.setText(item.getText() + "(" + children.length + ")");
}
}
}
if (obj instanceof IndicatorDefinition) {
IndicatorDefinition indicatorDefinition = (IndicatorDefinition) obj;
// reload object
indicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition(indicatorDefinition.getLabel());
IndicatorEditorInput input = new IndicatorEditorInput(indicatorDefinition);
try {
CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, IndicatorEditor.class.getName());
} catch (PartInitException e1) {
log.error(e1, e1);
}
}
if (obj instanceof DQRepositoryNode) {
if (obj instanceof ReportFileRepNode) {
new OpenItemEditorAction(new IRepositoryNode[] { (IRepositoryNode) obj }).run();
} else if (obj instanceof DFConnectionRepNode) {
new EditFileDelimitedAction((IRepositoryNode) obj).run();
} else if (obj instanceof HadoopClusterConnectionRepNode && HadoopClusterUtils.getDefault().isServiceInstalled()) {
new EditHadoopClusterAction((IRepositoryNode) obj).run();
} else if (obj instanceof HDFSOfHCConnectionNode && HadoopClusterUtils.getDefault().isServiceInstalled()) {
new EditHDFSConnectionAction((IRepositoryNode) obj).run();
} else if (obj instanceof DFTableRepNode) {
new EditDFTableAction((IRepositoryNode) obj).run();
} else if (obj instanceof ContextRepNode) {
new DQEditContextAction((ContextRepNode) obj, false).run();
} else {
DQRepositoryNode repoNode = (DQRepositoryNode) obj;
if (RepositoryNodeHelper.canOpenEditor(repoNode)) {
OpenItemEditorAction openItemEditorAction = new OpenItemEditorAction(new IRepositoryNode[] { repoNode });
openItemEditorAction.run();
}
if (repoNode instanceof AnalysisRepNode || repoNode instanceof ReportRepNode || repoNode instanceof SysIndicatorDefinitionRepNode || repoNode instanceof PatternRepNode || repoNode instanceof RuleRepNode) {
superDoubleClick = false;
}
}
}
}
if (superDoubleClick) {
super.mouseDoubleClick(e);
}
}
});
getCommonViewer().getTree().addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
Tree tree = (Tree) e.getSource();
TreeItem[] selection = tree.getSelection();
for (TreeItem item : selection) {
Object data = item.getData();
DQRepositoryNode repoNode = (DQRepositoryNode) data;
if (RepositoryNodeHelper.canOpenEditor(repoNode)) {
OpenItemEditorAction openItemEditorAction = new OpenItemEditorAction(new IRepositoryNode[] { repoNode });
openItemEditorAction.run();
}
}
}
}
public void keyReleased(KeyEvent e) {
// do nothing here until now
}
});
// ~ADD mzhao for feature 6233 Load columns when selecting a table (or
// view) in DQ Repository view
getCommonViewer().addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
TreeSelection selection = (TreeSelection) event.getSelection();
Iterator<?> iterator = selection.iterator();
while (iterator.hasNext()) {
Object selectedElement = iterator.next();
if (selectedElement instanceof DBTableRepNode || selectedElement instanceof DBViewRepNode) {
((RepositoryNode) selectedElement).getChildren().get(0).getChildren();
}
}
}
});
// MOD mzhao 2011-03-10 bug 19147: filter MDM entries.
getCommonViewer().addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IProject) {
return false;
}
return true;
}
});
// ~
}
use of org.eclipse.swt.events.KeyListener in project tdq-studio-se by Talend.
the class AbstractExportOptionsDlg method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
comp.setLayout(new FillLayout(SWT.VERTICAL));
comp.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
String columnSeparator = SQLExplorerPlugin.getDefault().getPreferenceStore().getString(IConstants.CLIP_EXPORT_SEPARATOR);
boolean hdr = SQLExplorerPlugin.getDefault().getPreferenceStore().getBoolean(IConstants.CLIP_EXPORT_COLUMNS);
Label l = null;
int flags = getFlags();
addContentChooseRadio(comp);
if ((flags & FMT_CHARSET) != 0 || (flags & FMT_DELIM) != 0 || (flags & FMT_NULL) != 0) {
Group fmtGroup = new Group(comp, SWT.SHADOW_ETCHED_IN);
fmtGroup.setText(Messages.getString("ExportDialog.group.format"));
fmtGroup.setLayout(new GridLayout(2, false));
int i = 0, def = 0;
if ((flags & FMT_CHARSET) != 0) {
l = new Label(fmtGroup, SWT.NONE);
l.setText(Messages.getString("ExportDialog.format.cs"));
uiCharset = new Combo(fmtGroup, SWT.READ_ONLY);
SortedMap m = Charset.availableCharsets();
for (Iterator it = m.keySet().iterator(); it.hasNext(); i++) {
Charset cs = (Charset) m.get(it.next());
uiCharset.add(cs.displayName());
if (cs.displayName().toLowerCase().equals("utf-8")) {
def = i;
}
}
uiCharset.select(def);
}
if ((flags & FMT_DELIM) != 0) {
l = new Label(fmtGroup, SWT.NONE);
l.setText(Messages.getString("ExportDialog.format.delim"));
uiDelim = new Combo(fmtGroup, SWT.NONE);
for (i = 0, def = 0; i < DELIMS.length; i++) {
uiDelim.add(DELIMS[i]);
if (DELIMS[i].toLowerCase().equals(columnSeparator)) {
def = i;
}
}
uiDelim.select(def);
}
if ((flags & FMT_NULL) != 0) {
l = new Label(fmtGroup, SWT.NONE);
l.setText(Messages.getString("ExportDialog.format.null"));
uiNullValue = new Text(fmtGroup, SWT.SINGLE | SWT.BORDER | SWT.FILL);
uiNullValue.setText("<null>");
uiNullValue.setLayoutData(new GridData(50, SWT.DEFAULT));
}
}
if ((flags & OPT_HDR) != 0 || (flags & OPT_QUOTE) != 0 || (flags & OPT_RTRIM) != 0) {
Group optionsGroup = new Group(comp, SWT.SHADOW_ETCHED_IN);
optionsGroup.setText(Messages.getString("ExportDialog.group.options"));
optionsGroup.setLayout(new GridLayout(1, true));
if ((flags & OPT_HDR) != 0) {
uiIncHeaders = new Button(optionsGroup, SWT.CHECK);
uiIncHeaders.setText(Messages.getString("ExportDialog.options.hdr"));
uiIncHeaders.setSelection(hdr);
}
if ((flags & OPT_QUOTE) != 0) {
uiQuoteText = new Button(optionsGroup, SWT.CHECK);
uiQuoteText.setText(Messages.getString("ExportDialog.options.quote"));
}
if ((flags & OPT_RTRIM) != 0) {
uiRtrim = new Button(optionsGroup, SWT.CHECK);
uiRtrim.setText(Messages.getString("ExportDialog.options.rtrim"));
}
}
Group fileGroup = new Group(comp, SWT.SHADOW_ETCHED_IN);
fileGroup.setText(Messages.getString("ExportDialog.group.file"));
fileGroup.setLayout(new GridLayout(2, false));
uiFile = new Text(fileGroup, SWT.BORDER | SWT.FILL | SWT.SINGLE);
uiFile.setLayoutData(new GridData(300, SWT.DEFAULT));
uiFile.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
sync();
}
public void keyReleased(KeyEvent e) {
sync();
}
});
Button choose = new Button(fileGroup, SWT.NONE);
choose.setText(Messages.getString("ExportDialog.file.choose"));
choose.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
chooseFilename();
}
});
comp.pack();
sync();
return comp;
}
use of org.eclipse.swt.events.KeyListener in project tdq-studio-se by Talend.
the class FileLabelProvider method createDialogArea.
protected Control createDialogArea(Composite parent) {
// top level composite
Composite parentComposite = (Composite) super.createDialogArea(parent);
// create a composite with standard margins and spacing
Composite composite = new Composite(parentComposite, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setFont(parentComposite.getFont());
Composite nameGroup = new Composite(composite, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 3;
layout.marginWidth = 10;
nameGroup.setLayout(layout);
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
nameGroup.setLayoutData(data);
Composite topComposite = new Composite(nameGroup, SWT.NONE);
data = new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL);
data.horizontalSpan = 3;
topComposite.setLayoutData(data);
topComposite.setLayout(new GridLayout());
Group topGroup = new Group(topComposite, SWT.NULL);
topGroup.setText(Messages.getString("Driver_14"));
data = new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL);
data.horizontalSpan = 3;
data.widthHint = SIZING_TEXT_FIELD_WIDTH;
topGroup.setLayoutData(data);
layout = new GridLayout();
layout.numColumns = 3;
layout.marginWidth = 5;
topGroup.setLayout(layout);
Label label = new Label(topGroup, SWT.WRAP);
label.setText(Messages.getString("Name_15"));
nameField = new Text(topGroup, SWT.BORDER);
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
data.horizontalSpan = 2;
data.widthHint = SIZING_TEXT_FIELD_WIDTH;
nameField.setLayoutData(data);
nameField.addKeyListener(new KeyListener() {
public void keyPressed(org.eclipse.swt.events.KeyEvent e) {
CreateDriverDlg.this.validate();
}
public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
CreateDriverDlg.this.validate();
}
});
Label label5 = new Label(topGroup, SWT.WRAP);
label5.setText(Messages.getString("Example_URL_16"));
exampleUrlField = new Text(topGroup, SWT.BORDER);
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
data.widthHint = SIZING_TEXT_FIELD_WIDTH;
data.horizontalSpan = 2;
exampleUrlField.setLayoutData(data);
exampleUrlField.addKeyListener(new KeyListener() {
public void keyPressed(org.eclipse.swt.events.KeyEvent e) {
CreateDriverDlg.this.validate();
}
public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
CreateDriverDlg.this.validate();
}
});
Composite centralComposite = new Composite(nameGroup, SWT.NONE);
data = new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL);
data.horizontalSpan = 3;
data.verticalSpan = 4;
data.heightHint = 200;
centralComposite.setLayoutData(data);
centralComposite.setLayout(new FillLayout());
TabFolder tabFolder = new TabFolder(centralComposite, SWT.NULL);
TabItem item1 = new TabItem(tabFolder, SWT.NULL);
item1.setText(Messages.getString("Java_Class_Path_17"));
TabItem item2 = new TabItem(tabFolder, SWT.NULL);
item2.setText(Messages.getString("Extra_Class_Path_18"));
createJavaClassPathPanel(tabFolder, item1);
createExtraClassPathPanel(tabFolder, item2);
Label label4 = new Label(nameGroup, SWT.WRAP);
label4.setText(Messages.getString("Driver_Class_Name_19"));
combo = new Combo(nameGroup, SWT.BORDER | SWT.DROP_DOWN);
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
data.widthHint = SIZING_TEXT_FIELD_WIDTH;
data.horizontalSpan = 2;
combo.setLayoutData(data);
combo.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
CreateDriverDlg.this.validate();
}
});
combo.addKeyListener(new KeyListener() {
public void keyPressed(org.eclipse.swt.events.KeyEvent e) {
CreateDriverDlg.this.validate();
}
public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
CreateDriverDlg.this.validate();
}
});
nameGroup.layout();
loadData();
return parentComposite;
}
use of org.eclipse.swt.events.KeyListener in project rap by entirej.
the class EJRWTListItemRenderer method createComponent.
@Override
public void createComponent(Composite composite) {
_actionControl = new EJRWTAbstractActionList(composite) {
private static final long serialVersionUID = 2592484612013403481L;
@Override
protected boolean hasFilter() {
return _rendererProps.getBooleanProperty(FILTER, false);
}
@Override
public void refreshData() {
refreshList();
}
@Override
public org.eclipse.swt.widgets.List createList(Composite parent) {
String alignmentProperty = _rendererProps.getStringProperty(EJRWTTextItemRendererDefinitionProperties.PROPERTY_ALIGNMENT);
if (alignmentProperty == null) {
alignmentProperty = _rendererProps.getStringProperty("ALLIGNMENT");
}
String hint = _screenItemProperties.getHint();
int style = SWT.READ_ONLY | SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL;
style = getComponentStyle(alignmentProperty, style);
_listField = new org.eclipse.swt.widgets.List(parent, style);
_listField.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_LIST);
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
String imageItem = _rendererProps.getStringProperty(COLUMN_IMAGE_ITEM);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
_listField.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
if (imageItem != null && imageItem.trim().length() > 0) {
_listField.setData(EJ_RWT.MARKUP_ENABLED, true);
}
if (hint != null && hint.trim().length() > 0) {
_listField.setToolTipText(hint);
}
_listField.setData(_item.getReferencedItemProperties().getName());
_listField.addFocusListener(EJRWTListItemRenderer.this);
_listField.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (isValid()) {
Object old = _baseValue;
ListBoxValue value = getListBoxValue();
if (value != null && _activeEvent) {
value.populateReturnItems(_item.getBlock().getBlockController(), _item.getScreenType());
}
if (_activeEvent) {
_item.itemValueChaged(value.getItemValue());
}
setMandatoryBorder(_mandatory);
} else {
_isValid = true;
}
if (_activeEvent) {
_item.executeActionCommand();
}
}
});
return _listField;
}
@Override
public Control createActionLabel(Composite parent) {
Label label = new Label(parent, SWT.NONE);
label.setImage(EJRWTImageRetriever.get(EJRWTImageRetriever.IMG_FIND_LOV));
label.addFocusListener(EJRWTListItemRenderer.this);
label.addMouseListener(new MouseListener() {
@Override
public void mouseUp(MouseEvent arg0) {
_item.getItemLovController().displayLov(EJLovDisplayReason.LOV);
}
@Override
public void mouseDown(MouseEvent arg0) {
}
@Override
public void mouseDoubleClick(MouseEvent arg0) {
}
});
final EJFrameworkExtensionProperties rendererProp = EJCoreProperties.getInstance().getApplicationDefinedProperties();
final EJFrameworkExtensionProperties propertyGroup = rendererProp.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ACTION_GROUP);
String lovKey = "SHIFT+ARROW_DOWN";
if (propertyGroup != null) {
lovKey = propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_LOV_KEY);
}
if (lovKey == null) {
lovKey = "SHIFT+ARROW_DOWN";
}
label.setData(EJ_RWT.ACTIVE_KEYS, new String[] { lovKey });
getListControl().setData(EJ_RWT.ACTIVE_KEYS, new String[] { lovKey });
addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent arg0) {
if ((arg0.stateMask & SWT.SHIFT) != 0 && arg0.keyCode == SWT.ARROW_DOWN && isLovActivated()) {
_item.getItemLovController().displayLov(EJLovDisplayReason.LOV);
}
}
@Override
public void keyPressed(KeyEvent arg0) {
}
});
return label;
}
};
_visualContext = new EJRWTItemRendererVisualContext(_listField.getBackground(), _listField.getForeground(), _listField.getFont());
_mandatoryDecoration = new ControlDecoration(_actionControl, SWT.TOP | SWT.LEFT);
_errorDecoration = new ControlDecoration(_actionControl, SWT.TOP | SWT.LEFT);
_errorDecoration.setImage(getDecorationImage(FieldDecorationRegistry.DEC_ERROR));
_mandatoryDecoration.setImage(getDecorationImage(FieldDecorationRegistry.DEC_REQUIRED));
_mandatoryDecoration.setShowHover(true);
_mandatoryDecoration.setDescriptionText(_screenItemProperties.getLabel() == null || _screenItemProperties.getLabel().isEmpty() ? "Required Item" : String.format("%s is required", _screenItemProperties.getLabel()));
if (_isValid) {
_errorDecoration.hide();
}
if (message != null) {
setMessage(message);
}
_mandatoryDecoration.hide();
refreshList();
setInitialValue(_baseValue);
}
Aggregations