/** * Initialize the toolbar with icons and selection listeners in the appropriate part of the window */ public void initToolbar() { Device dev = shell.getDisplay(); try { exitImg = new Image(dev, "img/exit.png"); // openImg = new Image(dev, "img/open.png"); playImg = new Image(dev, "img/play.png"); // pauseImg = new Image(dev, "img/pause.png"); } catch (Exception e) { System.out.println("Cannot load images"); System.out.println(e.getMessage()); System.exit(1); } ToolBar toolBar = new ToolBar(shell, SWT.BORDER); GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; toolBar.setLayoutData(gridData); ToolItem exit = new ToolItem(toolBar, SWT.PUSH); exit.setImage(exitImg); // ToolItem open = new ToolItem(toolBar, SWT.PUSH); // exit.setImage(openImg); ToolItem play = new ToolItem(toolBar, SWT.PUSH); play.setImage(playImg); // ToolItem pause = new ToolItem(toolBar, SWT.PUSH); // pause.setImage(pauseImg); toolBar.pack(); exit.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { System.exit(0); } }); // open.addSelectionListener(new SelectionAdapter() { // @Override // public void widgetSelected(SelectionEvent e) { // FileDialog dialog = new FileDialog(shell, SWT.NULL); // String path = dialog.open(); // } // }); play.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { controller.RunAnimation(); } }); }
public void openUrl(String url) { String os = System.getProperty("os.name"); Runtime runtime = Runtime.getRuntime(); try { // Block for Windows Platform if (os.startsWith("Windows")) { String cmd = "rundll32 url.dll,FileProtocolHandler " + url; Process p = runtime.exec(cmd); // Block for Mac OS } else if (os.startsWith("Mac OS")) { Class fileMgr = Class.forName("com.apple.eio.FileManager"); Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] {String.class}); openURL.invoke(null, new Object[] {url}); // Block for UNIX Platform } else { String[] browsers = {"firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape"}; String browser = null; for (int count = 0; count < browsers.length && browser == null; count++) if (runtime.exec(new String[] {"which", browsers[count]}).waitFor() == 0) browser = browsers[count]; if (browser == null) throw new Exception("Could not find web browser"); else runtime.exec(new String[] {browser, url}); } } catch (Exception x) { System.err.println("Exception occurd while invoking Browser!"); x.printStackTrace(); } }
/** Export the selected values from the table to a csv file */ private void export() { FileDialog dialog = new FileDialog(shell, SWT.SAVE); String[] filterNames = new String[] {"CSV Files", "All Files (*)"}; String[] filterExtensions = new String[] {"*.csv;", "*"}; String filterPath = "/"; String platform = SWT.getPlatform(); if (platform.equals("win32") || platform.equals("wpf")) { filterNames = new String[] {"CSV Files", "All Files (*.*)"}; filterExtensions = new String[] {"*.csv", "*.*"}; filterPath = "c:\\"; } dialog.setFilterNames(filterNames); dialog.setFilterExtensions(filterExtensions); dialog.setFilterPath(filterPath); try { dialog.setFileName(this.getCurrentKey() + ".csv"); } catch (Exception e) { dialog.setFileName("export.csv"); } String fileName = dialog.open(); FileOutputStream fos; OutputStreamWriter out; try { fos = new FileOutputStream(fileName); out = new OutputStreamWriter(fos, "UTF-8"); } catch (Exception e) { MessageBox messageBox = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR); messageBox.setMessage("Error creating export file " + fileName + " : " + e.getMessage()); messageBox.open(); return; } Vector<TableItem> sel = new Vector<TableItem>(this.dataTable.getSelection().length); sel.addAll(Arrays.asList(this.dataTable.getSelection())); Collections.reverse(sel); for (TableItem item : sel) { String date = item.getText(0); String value = item.getText(1); try { out.write(date + ";" + value + "\n"); } catch (IOException e) { continue; } } try { out.close(); fos.close(); } catch (IOException e) { MessageBox messageBox = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR); messageBox.setMessage("Error writing export file " + fileName + " : " + e.getMessage()); messageBox.open(); e.printStackTrace(); } }
/** * Launch the application. This is here for the SWT Designer * * @param args */ public static void main(String[] args) { try { UCEditor window = new UCEditor(null); window.open(); } catch (Exception e) { e.printStackTrace(); } }
public void updateView(String sourceFileLocation, Block block) { if (block == null) { return; } this.block = block; this.sourceFileLocation = sourceFileLocation; // this.label.setText(txt+ "Update "+ new Timestamp(new java.util.Date().getTime())); ConfigurableEPC result = null; for (EPClet e : block.getEpclets()) { // System.out.println(e.getPre().getValue() +"->"+e.getRole().getRoleId()+"."+e.getTask()+" -> // "+e.getPost().getValue()); try { String preep = null, postep = null, taskid = null, roleid = null; preep = (e.getPre() != null) ? e.getPre().getValue() : null; postep = (e.getPost() != null) ? e.getPost().getValue() : null; taskid = (e.getTask() != null) ? e.getTask() : null; roleid = (e.getRole() != null) ? e.getRole().getRoleId() : null; result = MergeBehavior.mergeEPC( result, PatternToEPC.convertToEPC(preep, taskid, postep, roleid, null, null)); } catch (Exception e1) { // TODO Auto-generated catch block this.errorLabel.setText(e1.getMessage()); e1.printStackTrace(); } } // SerendipEPCView serendipEPCView = new SerendipEPCView("test", result); this.epmlWriter = new EPMLWriter(result, true); ModelGraphPanel mgp = epmlWriter.getModelGraphPanel(); mgp.setScaleToFit(true); this.viewPanel.removeAll(); this.viewPanel.add(mgp, BorderLayout.CENTER); this.viewPanel.repaint(); // export the epml try { this.epmlWriter.writeToFile(sourceFileLocation + "." + block.getName().getName() + ".epml"); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } this.errorLabel.setText( "EPC graph " + block.getName().getName() + "constructed - " + new Timestamp(new java.util.Date().getTime())); this.setFocus(); }
void updateViewport() { baseEditor.lineCountEvent(text.getLineCount()); int start = 0; try { start = text.getTopIndex() - 1; } catch (Exception e) { e.printStackTrace(System.out); } if (start < 0) start = 0; int end = start + text.getClientArea().height / text.getLineHeight(); baseEditor.visibleTextEvent(start, end - start + 2); }
/** * Launch the application. * * @param args */ public static void main(String[] args) { try { SendMsgWindow window = new SendMsgWindow(null, null); Shell sendMsgWindowShell = window.open(); while (sendMsgWindowShell.isDisposed() != true) { if (Display.getCurrent().readAndDispatch() != true) { Display.getCurrent().sleep(); } } } catch (Exception e) { e.printStackTrace(); } }
private void updateCursor(final String selection) { Cursor cursor = null; Class swtClass = SWT.class; if (selection != null) { try { Field field = swtClass.getField(selection); int cursorStyle = field.getInt(swtClass); cursor = Display.getCurrent().getSystemCursor(cursorStyle); } catch (Exception e) { e.printStackTrace(); } } Iterator iter = controls.iterator(); while (iter.hasNext()) { Control control = (Control) iter.next(); control.setCursor(cursor); } }
private void showProgressDialog() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try { dialog.run( true, true, new IRunnableWithProgress() { public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Counting from one to 20...", 20); for (int i = 1; !monitor.isCanceled() && i <= 20; i++) { monitor.worked(1); Thread.sleep(1000); } monitor.done(); } }); } catch (Exception e) { MessageDialog.openError(getShell(), "Error", e.getMessage()); } }
public List getCategories() { List concepts = null; try { // GetReturnType request = new GetReturnType(); // request.setType("limited"); GetCategoriesType request = new GetCategoriesType(); request.setType("core"); request.setHiddens(false); request.setSynonyms(false); OntologyResponseMessage msg = new OntologyResponseMessage(); StatusType procStatus = null; while (procStatus == null || !procStatus.getType().equals("DONE")) { String response = OntServiceDriver.getCategories(request, "FIND"); procStatus = msg.processResult(response); // if other error codes // TABLE_ACCESS_DENIED and USER_INVALID, DATABASE ERROR if (procStatus.getType().equals("ERROR")) { System.setProperty("errorMessage", procStatus.getValue()); return concepts; } procStatus.setType("DONE"); } ConceptsType allConcepts = msg.doReadConcepts(); if (allConcepts != null) concepts = allConcepts.getConcept(); } catch (AxisFault e) { log.error(e.getMessage()); System.setProperty("errorMessage", "Ontology cell unavailable"); } catch (I2B2Exception e) { log.error(e.getMessage()); System.setProperty("errorMessage", e.getMessage()); } catch (Exception e) { log.error(e.getMessage()); System.setProperty("errorMessage", "Remote server unavailable"); } return concepts; }
public void updateParentFileCombo(FileObject selectedItem) { try { List<FileObject> parentChain = new ArrayList<FileObject>(); // are we a directory? try { if (selectedItem.getType() == FileType.FOLDER && selectedItem.getType().hasChildren()) { // we have real children.... parentChain.add(selectedItem); } } catch (Exception e) { // we are not a folder } FileObject parentFileObject; parentFileObject = selectedItem.getParent(); while (parentFileObject != null) { parentChain.add(parentFileObject); parentFileObject = parentFileObject.getParent(); } File roots[] = File.listRoots(); if (currentPanel != null) { for (int i = 0; i < roots.length; i++) { parentChain.add(currentPanel.resolveFile(roots[i].getAbsolutePath())); } } String items[] = new String[parentChain.size()]; int idx = 0; for (int i = parentChain.size() - 1; i >= 0; i--) { items[idx++] = ((FileObject) parentChain.get(i)).getName().getURI(); } openFileCombo.setItems(items); openFileCombo.select(items.length - 1); } catch (Exception e) { e.printStackTrace(); // then let's not update the GUI } }
/* * (non-Javadoc) * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { display = parent.getDisplay(); sashForm = new SashForm(parent, SWT.VERTICAL); FillLayout layout = new FillLayout(); sashForm.setLayout(layout); GridData data = new GridData(GridData.FILL_BOTH); sashForm.setLayoutData(data); initializeDialogUnits(sashForm); Composite composite = new Composite(sashForm, SWT.NONE); GridLayout gridLayout = new GridLayout(); gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; composite.setLayout(gridLayout); treeViewer = createTreeViewer(composite); data = new GridData(GridData.FILL_BOTH); data.heightHint = convertHeightInCharsToPixels(ILayoutConstants.DEFAULT_TABLE_HEIGHT); data.widthHint = convertWidthInCharsToPixels(ILayoutConstants.DEFAULT_TABLE_WIDTH); Tree tree = treeViewer.getTree(); tree.setLayoutData(data); tree.setHeaderVisible(true); activateCopy(tree); TreeViewerColumn nameColumn = new TreeViewerColumn(treeViewer, SWT.LEFT); nameColumn.getColumn().setText(ProvUIMessages.ProvUI_NameColumnTitle); nameColumn.getColumn().setWidth(400); nameColumn.getColumn().setMoveable(true); nameColumn.setLabelProvider( new ColumnLabelProvider() { public String getText(Object element) { IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class); String label = iu.getProperty(IInstallableUnit.PROP_NAME, null); if (label == null) label = iu.getId(); return label; } public Image getImage(Object element) { if (element instanceof ProvElement) return ((ProvElement) element).getImage(element); if (ProvUI.getAdapter(element, IInstallableUnit.class) != null) return ProvUIImages.getImage(ProvUIImages.IMG_IU); return null; } public String getToolTipText(Object element) { if (element instanceof AvailableIUElement && ((AvailableIUElement) element).getImageOverlayId(null) == ProvUIImages.IMG_INFO) return ProvUIMessages.RemedyElementNotHighestVersion; return super.getToolTipText(element); } }); TreeViewerColumn versionColumn = new TreeViewerColumn(treeViewer, SWT.LEFT); versionColumn.getColumn().setText(ProvUIMessages.ProvUI_VersionColumnTitle); versionColumn.getColumn().setWidth(200); versionColumn.setLabelProvider( new ColumnLabelProvider() { public String getText(Object element) { IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class); if (element instanceof IIUElement) { if (((IIUElement) element).shouldShowVersion()) return iu.getVersion().toString(); return ""; //$NON-NLS-1$ } return iu.getVersion().toString(); } }); TreeViewerColumn idColumn = new TreeViewerColumn(treeViewer, SWT.LEFT); idColumn.getColumn().setText(ProvUIMessages.ProvUI_IdColumnTitle); idColumn.getColumn().setWidth(200); idColumn.setLabelProvider( new ColumnLabelProvider() { public String getText(Object element) { IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class); return iu.getId(); } }); // Filters and sorters before establishing content, so we don't refresh unnecessarily. IUComparator comparator = new IUComparator(IUComparator.IU_NAME); comparator.useColumnConfig(getColumnConfig()); treeViewer.setComparator(comparator); treeViewer.setComparer(new ProvElementComparer()); ColumnViewerToolTipSupport.enableFor(treeViewer); contentProvider = new ProvElementContentProvider(); treeViewer.setContentProvider(contentProvider); // labelProvider = new IUDetailsLabelProvider(null, getColumnConfig(), getShell()); // treeViewer.setLabelProvider(labelProvider); // Optional area to show the size createSizingInfo(composite); // The text area shows a description of the selected IU, or error detail if applicable. iuDetailsGroup = new IUDetailsGroup( sashForm, treeViewer, convertWidthInCharsToPixels(ILayoutConstants.DEFAULT_TABLE_WIDTH), true); setControl(sashForm); sashForm.setWeights(getSashWeights()); Dialog.applyDialogFont(sashForm); // Controls for filtering/presentation/site selection Composite controlsComposite = new Composite(composite, SWT.NONE); gridLayout = new GridLayout(); gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; gridLayout.numColumns = 2; gridLayout.makeColumnsEqualWidth = true; gridLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); controlsComposite.setLayout(layout); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false); controlsComposite.setLayoutData(gd); final Runnable runnable = new Runnable() { public void run() { treeViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { setDetailText(resolvedOperation); } }); setDrilldownElements(input, resolvedOperation); treeViewer.setInput(input); } }; if (resolvedOperation != null && !resolvedOperation.hasResolved()) { try { getContainer() .run( true, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { resolvedOperation.resolveModal(monitor); display.asyncExec(runnable); } }); } catch (Exception e) { StatusManager.getManager() .handle(new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e)); } } else { runnable.run(); } }
private void openFile(String fileName, Table table) { String outStr; try { CSVReader reader = new CSVReader(new FileReader(fileName), ',', '"'); String[] strLineArr; // Open the file that is the first // command line parameter FileInputStream fstream = new FileInputStream(fileName); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; table.clearAll(); table.removeAll(); table.redraw(); int length = 0; boolean first = true; // Read File Line By Line while ((strLineArr = reader.readNext()) != null) { // while ((strLine = br.readLine()) != null) { // Print the content on the console // outStr = strLine; TableItem item = null; if (first) { length = strLineArr.length; } else { item = new TableItem(table, SWT.NONE); } int thisLen = strLineArr.length; if (thisLen <= length) { // String[] line = new String[length]; for (int i = 0; i < thisLen; i++) { // line[i] = st.nextToken(); // item.setText (i, st.nextToken()); if (first) { TableColumn column = new TableColumn(table, SWT.NONE); column.setText(strLineArr[i]); } else { // System.out.println("-- "+i+" -- " + strLineArr[i]); item.setText(i, strLineArr[i]); } } } first = false; } // System.out.println("Finisehd file"); for (int i = 0; i < length; i++) { table.getColumn(i).pack(); } // System.out.println("finished packing"); // Close the input stream in.close(); } catch (Exception e) { // Catch exception if any System.err.println("Error: " + e.getMessage()); e.printStackTrace(); } }
public void openResultsXML(String fileName) { String outStr; try { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = (Document) dBuilder.parse(fileName); doc.getDocumentElement().normalize(); if (doc.getElementsByTagName("wuid") != null) { wuid = doc.getElementsByTagName("wuid").item(0).getTextContent(); } if (doc.getElementsByTagName("jobname") != null) { jobname = doc.getElementsByTagName("jobname").item(0).getTextContent(); } if (doc.getElementsByTagName("serverAddress") != null) { serverAddress = doc.getElementsByTagName("serverAddress").item(0).getTextContent(); } // WUID // System.out.println(wuid); // lets create a tab for the wuid CTabItem wuidTab = new CTabItem(folder, SWT.NONE); wuidTab.setText(jobname + " " + wuid); folder.setSelection(folder.indexOf(wuidTab)); System.out.println("BUILDTAB--------" + folder.indexOf(wuidTab)); Composite tabHolder = new Composite(folder, SWT.NONE); tabHolder.setLayout(new GridLayout()); tabHolder.setLayoutData(new GridData(GridData.FILL_BOTH)); final String thisWuid = wuid; final String thisServerAddress = serverAddress; // add link here // Label link = new Label(); Link link = new Link(tabHolder, SWT.NONE); link.setText("<a>View Workunit in the Default Web Browser</a>"); link.addListener( SWT.Selection, new Listener() { public void handleEvent(Event event) { openUrl(thisServerAddress + "/WsWorkunits/WUInfo?Wuid=" + thisWuid); } }); CTabFolder subfolder = new CTabFolder(tabHolder, SWT.CLOSE); subfolder.setSimple(false); subfolder.setBorderVisible(true); subfolder.setLayoutData(new GridData(GridData.FILL_BOTH)); NodeList results = doc.getElementsByTagName("result"); for (int temp = 0; temp < results.getLength(); temp++) { Node result = results.item(temp); NamedNodeMap att = result.getAttributes(); // type String resType = att.getNamedItem("resulttype").getTextContent(); // System.out.println("resType: |" + resType + "|"); // filename String filePath = result.getTextContent(); // System.out.println(filePath); // CTabItem resultTab = new CTabItem(subfolder, SWT.NONE); // resultTab.setText(resType); // so here we use type and decide what tab to open and pass filename // buildTab(filePath,resType,subfolder); if (resType != null && filePath != null) { if (resType.equalsIgnoreCase("ClusterCounts")) { buildClusterCountsTab(filePath, resType, subfolder); } else if (resType.equalsIgnoreCase("SrcProfiles")) { buildSrcProfilesTab(filePath, resType, subfolder); } else if (resType.equalsIgnoreCase("Hygiene_ValidityErrors")) { buildHygieneValidityErrorsTab(filePath, resType, subfolder); } else if (resType.equalsIgnoreCase("ClusterSrc")) { buildClusterSrcTab(filePath, resType, subfolder); } else if (resType.equalsIgnoreCase("SrcOutliers")) { buildSrcOutliersTab(filePath, resType, subfolder); } else if (resType.equalsIgnoreCase("Dataprofiling_AllProfiles")) { buildProfileTab(filePath, resType, subfolder); } else if (resType.equalsIgnoreCase("Dataprofiling_SummaryReport")) { buildSummaryTab(filePath, resType, subfolder); } else if (resType.equalsIgnoreCase("Dataprofiling_OptimizedLayout")) { buildOptimizedLayoutTab(filePath, resType, subfolder); } else { // CleanedData buildTab(filePath, resType, subfolder); } } } wuidTab.setControl(tabHolder); } catch (Exception e) { // Catch exception if any System.err.println("Error: " + e.getMessage()); e.printStackTrace(); } }
/** Initializes the GUI. */ private void initGUI() { try { getShell() .addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent evt) { shellWidgetDisposed(evt); } }); getShell() .addControlListener( new ControlAdapter() { public void controlResized(ControlEvent evt) { shellControlResized(evt); } }); getShell() .addControlListener( new ControlAdapter() { public void controlMoved(ControlEvent evt) { shellControlMoved(evt); } }); GridLayout thisLayout = new GridLayout(); this.setLayout(thisLayout); { GridData toolBarLData = new GridData(); toolBarLData.grabExcessHorizontalSpace = true; toolBarLData.horizontalAlignment = GridData.FILL; toolBar = new ToolBar(this, SWT.FLAT); toolBar.setLayoutData(toolBarLData); toolBar.setBackgroundImage(SWTResourceManager.getImage("images/ToolbarBackground.gif")); { newToolItem = new ToolItem(toolBar, SWT.NONE); newToolItem.setImage(SWTResourceManager.getImage("images/new.gif")); newToolItem.setToolTipText("New"); } { openToolItem = new ToolItem(toolBar, SWT.NONE); openToolItem.setToolTipText("Open"); openToolItem.setImage(SWTResourceManager.getImage("images/open.gif")); openToolItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { openToolItemWidgetSelected(evt); } }); } { saveToolItem = new ToolItem(toolBar, SWT.NONE); saveToolItem.setToolTipText("Save"); saveToolItem.setImage(SWTResourceManager.getImage("images/save.gif")); } } { clientArea = new Composite(this, SWT.NONE); GridData clientAreaLData = new GridData(); clientAreaLData.grabExcessHorizontalSpace = true; clientAreaLData.grabExcessVerticalSpace = true; clientAreaLData.horizontalAlignment = GridData.FILL; clientAreaLData.verticalAlignment = GridData.FILL; clientArea.setLayoutData(clientAreaLData); clientArea.setLayout(null); } { statusArea = new Composite(this, SWT.NONE); GridLayout statusAreaLayout = new GridLayout(); statusAreaLayout.makeColumnsEqualWidth = true; statusAreaLayout.horizontalSpacing = 0; statusAreaLayout.marginHeight = 0; statusAreaLayout.marginWidth = 0; statusAreaLayout.verticalSpacing = 0; statusAreaLayout.marginLeft = 3; statusAreaLayout.marginRight = 3; statusAreaLayout.marginTop = 3; statusAreaLayout.marginBottom = 3; statusArea.setLayout(statusAreaLayout); GridData statusAreaLData = new GridData(); statusAreaLData.horizontalAlignment = GridData.FILL; statusAreaLData.grabExcessHorizontalSpace = true; statusArea.setLayoutData(statusAreaLData); statusArea.setBackground(SWTResourceManager.getColor(239, 237, 224)); { statusText = new Label(statusArea, SWT.BORDER); statusText.setText(" Ready"); GridData txtStatusLData = new GridData(); txtStatusLData.horizontalAlignment = GridData.FILL; txtStatusLData.grabExcessHorizontalSpace = true; txtStatusLData.verticalIndent = 3; statusText.setLayoutData(txtStatusLData); } } thisLayout.verticalSpacing = 0; thisLayout.marginWidth = 0; thisLayout.marginHeight = 0; thisLayout.horizontalSpacing = 0; thisLayout.marginTop = 3; this.setSize(474, 312); { menu1 = new Menu(getShell(), SWT.BAR); getShell().setMenuBar(menu1); { fileMenuItem = new MenuItem(menu1, SWT.CASCADE); fileMenuItem.setText("&File"); { fileMenu = new Menu(fileMenuItem); { newFileMenuItem = new MenuItem(fileMenu, SWT.PUSH); newFileMenuItem.setText("&New"); newFileMenuItem.setImage(SWTResourceManager.getImage("images/new.gif")); } { openFileMenuItem = new MenuItem(fileMenu, SWT.PUSH); openFileMenuItem.setText("&Open"); openFileMenuItem.setImage(SWTResourceManager.getImage("images/open.gif")); openFileMenuItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { openFileMenuItemWidgetSelected(evt); } }); } { closeFileMenuItem = new MenuItem(fileMenu, SWT.CASCADE); closeFileMenuItem.setText("Close"); } { fileMenuSep1 = new MenuItem(fileMenu, SWT.SEPARATOR); } { saveFileMenuItem = new MenuItem(fileMenu, SWT.PUSH); saveFileMenuItem.setText("&Save"); saveFileMenuItem.setImage(SWTResourceManager.getImage("images/save.gif")); saveFileMenuItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { saveFileMenuItemWidgetSelected(evt); } }); } { fileMenuSep2 = new MenuItem(fileMenu, SWT.SEPARATOR); } { exitMenuItem = new MenuItem(fileMenu, SWT.CASCADE); exitMenuItem.setText("E&xit"); exitMenuItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { exitMenuItemWidgetSelected(evt); } }); } fileMenuItem.setMenu(fileMenu); } } { helpMenuItem = new MenuItem(menu1, SWT.CASCADE); helpMenuItem.setText("&Help"); { helpMenu = new Menu(helpMenuItem); { aboutMenuItem = new MenuItem(helpMenu, SWT.CASCADE); aboutMenuItem.setText("&About"); aboutMenuItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { aboutMenuItemWidgetSelected(evt); } }); } helpMenuItem.setMenu(helpMenu); } } } } catch (Exception e) { e.printStackTrace(); } }