List of usage examples for org.eclipse.jface.resource ImageDescriptor createFromImage
public static ImageDescriptor createFromImage(Image img)
From source file:pt.iscte.dcti.visual_tracer.view.InstanceDetailView.java
License:Open Source License
public void defineActions() { _actionViewJoinpoint = new Action("View Joinpoint that generate the selected snapshot", ImageDescriptor.createFromImage(ImageUtils.getImage(ImageUtils.ImageName.Eye.name()))) { public void run() { if (_treeSnaposhots.getSelectionCount() == 1) { TreeItem itemSelected = _treeSnaposhots.getSelection()[0]; Snapshot snapshot = (Snapshot) itemSelected.getData(TreeSnapshotDataKeys.Snapshot.name()); getController().showJoinPoint(snapshot.getAbstractJoinPoint()); } else { MessageBox message = new MessageBox(getShell()); message.setMessage("Item unselected"); message.setText("Please select one snapshot of the list"); message.open();// w w w.jav a 2s . c o m } } }; }
From source file:pt.iscte.dcti.visual_tracer.view.PrincipalView.java
License:Open Source License
private void defineActions() { _actionExit = new Action("&Exit", ImageDescriptor.createFromImage(ImageUtils.getImage(ImageUtils.ImageName.DoorOut.name()))) { public void run() { MessageBox messagebox = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO); messagebox.setMessage("Are you sure?"); messagebox.setText("Exit apllication"); int option = messagebox.open(); if (option == SWT.YES) { //when the user shutdown the UI, the program that was inspected keep going normally getController().setStatus(Status.UserExit); getShell().dispose();/*from w w w . j ava 2 s . c om*/ } } }; _actionPlay = new Action("&Play@Ctrl+P", ImageDescriptor.createFromImage(ImageUtils.getImage(ImageUtils.ImageName.ControlPlay.name()))) { public void run() { getController().setStatus(IModel.Status.Playing); } }; _actionPause = new Action("&Pause", ImageDescriptor.createFromImage(ImageUtils.getImage(ImageUtils.ImageName.ControlPause.name()))) { public void run() { getController().setStatus(IModel.Status.Paused); } }; _actionHelpContent = new Action("&Help Content", ImageDescriptor.createFromImage(ImageUtils.getImage(ImageUtils.ImageName.Help.name()))) { public void run() { File currentDir = new File(""); try { Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + currentDir.getAbsolutePath() + "\\Files\\ManualUtilizacao.pdf"); } catch (IOException e) { System.out.println(e.getMessage()); } } }; _actionDeveloperHelpContent = new Action("&Developer Help Content", ImageDescriptor.createFromImage(ImageUtils.getImage(ImageUtils.ImageName.Help.name()))) { public void run() { File currentDir = new File(""); try { Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + currentDir.getAbsolutePath() + "\\Files\\Visual Tracer javadoc\\index.html"); } catch (IOException e) { System.out.println(e.getMessage()); } } }; _actionAbout = new Action("&About", ImageDescriptor.createFromImage(ImageUtils.getImage(ImageUtils.ImageName.Group.name()))) { public void run() { new AboutView(_shell, SWT.NULL); } }; _actionViewGPL = new Action("&GNU General Public License", ImageDescriptor.createFromImage(ImageUtils.getImage(ImageUtils.ImageName.Gnu.name()))) { public void run() { new GnuView(_shell, SWT.NULL); } }; }
From source file:scouter.client.group.view.XLogLoadTimeGroupView.java
License:Apache License
public void createPartControl(final Composite parent) { display = Display.getCurrent();/*from w ww . ja v a 2 s. c o m*/ shell = new Shell(display); this.setPartName(grpName + " - XLog"); IToolBarManager man = getViewSite().getActionBars().getToolBarManager(); create(parent, man); man.add(new Action("zoom in", ImageUtil.getImageDescriptor(Images.zoomin)) { public void run() { TimeRangeDialog dialog = new TimeRangeDialog(display, XLogLoadTimeGroupView.this, DateUtil.yyyymmdd(stime)); dialog.show(stime, etime); } }); man.add(new Action("zoom out", ImageUtil.getImageDescriptor(Images.zoomout)) { public void run() { if (viewPainter.isZoomMode()) { viewPainter.endZoom(); } else { viewPainter.keyPressed(16777261); viewPainter.build(); } canvas.redraw(); } }); man.add(new Separator()); createContextMenu(parent, new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { if (viewPainter.isZoomMode() == false) { manager.add(new Action("Load") { public void run() { CalendarDialog dialog = new CalendarDialog(display, XLogLoadTimeGroupView.this); dialog.showWithEndTime(); } }); manager.add(new Action("Zoom In", ImageDescriptor.createFromImage(Images.zoomin)) { public void run() { TimeRangeDialog dialog = new TimeRangeDialog(display, XLogLoadTimeGroupView.this, DateUtil.yyyymmdd(stime)); dialog.show(stime, etime); } }); } } }); canvas.addControlListener(new ControlListener() { public void controlResized(ControlEvent e) { viewPainter.set(canvas.getClientArea()); viewPainter.build(); } public void controlMoved(ControlEvent e) { } }); setObjType(objType); }
From source file:scouter.client.host.views.DiskUsageView.java
License:Apache License
private void createTableContextMenu() { MenuManager manager = new MenuManager(); viewer.getControl().setMenu(manager.createContextMenu(viewer.getControl())); manager.add(new Action("&Copy", ImageDescriptor.createFromImage(Images.copy)) { public void run() { selectionCopyToClipboard();//from ww w . ja va2 s. c o m } }); viewer.getTable().addListener(SWT.KeyDown, new Listener() { public void handleEvent(Event e) { if (e.keyCode == SWT.CTRL) { ctrlPressed = true; } else if (e.keyCode == 'c' || e.keyCode == 'C') { if (ctrlPressed) { selectionCopyToClipboard(); } } } }); viewer.getTable().addListener(SWT.KeyUp, new Listener() { public void handleEvent(Event e) { if (e.keyCode == SWT.CTRL) { ctrlPressed = false; } } }); }
From source file:scouter.client.util.ImageUtil.java
License:Apache License
public static ImageDescriptor getImageDescriptor(Image image) { return ImageDescriptor.createFromImage(image); }
From source file:scouter.client.views.ClientEnvView.java
License:Apache License
private void createTableContextMenu() { MenuManager manager = new MenuManager(); viewer.getControl().setMenu(manager.createContextMenu(viewer.getControl())); manager.add(new Action("&Copy", ImageDescriptor.createFromImage(Images.copy)) { public void run() { selectionCopyToClipboard();/* w w w . j av a 2s .c o m*/ } }); viewer.getTable().addListener(SWT.KeyDown, new Listener() { public void handleEvent(Event e) { if (e.stateMask == SWT.CTRL) { if (e.keyCode == 'c' || e.keyCode == 'C') { selectionCopyToClipboard(); } } } }); viewer.getTable().addMouseListener(new MouseAdapter() { public void mouseDoubleClick(MouseEvent e) { TableItem[] items = viewer.getTable().getSelection(); if (items != null && items.length > 0) { VariableData data = (VariableData) items[0].getData(); new EditableMessageDialog().show(data.name, data.value); } } }); }
From source file:scouter.client.views.ObjectClassListView.java
License:Apache License
private void createTableContextMenu() { MenuManager manager = new MenuManager(); tableViewer.getControl().setMenu(manager.createContextMenu(tableViewer.getControl())); manager.add(new Action("&Copy", ImageDescriptor.createFromImage(Images.copy)) { public void run() { selectionCopyToClipboard();/* ww w . j av a 2 s. com*/ } }); Server server = ServerManager.getInstance().getServer(serverId); if (server.isAllowAction(GroupPolicyConstants.ALLOW_EXPORTCLASS)) { manager.add(new Action("&Export Class") { public void run() { StructuredSelection selection = (StructuredSelection) tableViewer.getSelection(); ClassData data = (ClassData) selection.getFirstElement(); final String className = data.name; if (StringUtil.isEmpty(className)) { return; } ExUtil.asyncRun(new Runnable() { public void run() { TcpProxy tcp = TcpProxy.getTcpProxy(serverId); MapPack p = null; try { MapPack param = new MapPack(); param.put("objHash", objHash); param.put("class", className); p = (MapPack) tcp.getSingle(RequestCmd.OBJECT_LOAD_CLASS_BY_STREAM, param); } catch (Exception e) { ConsoleProxy.errorSafe(e.getMessage()); } finally { TcpProxy.putTcpProxy(tcp); } if (p != null) { String error = CastUtil.cString(p.get("error")); if (StringUtil.isNotEmpty(error)) { ConsoleProxy.errorSafe(error); } Value v = p.get("class"); if (v != null) { final BlobValue bv = (BlobValue) v; ExUtil.exec(tableViewer.getTable(), new Runnable() { public void run() { saveClassFile(className, bv); } }); } } } }); } }); manager.add(new Action("&Export Jar") { public void run() { StructuredSelection selection = (StructuredSelection) tableViewer.getSelection(); final ClassData data = (ClassData) selection.getFirstElement(); final String resource = data.resources; if (StringUtil.isEmpty(resource)) { return; } ExUtil.asyncRun(new Runnable() { public void run() { TcpProxy tcp = TcpProxy.getTcpProxy(serverId); MapPack p = null; try { MapPack param = new MapPack(); param.put("objHash", objHash); param.put("resource", resource); p = (MapPack) tcp.getSingle(RequestCmd.OBJECT_CHECK_RESOURCE_FILE, param); } catch (Exception e) { ConsoleProxy.errorSafe(e.getMessage()); } finally { TcpProxy.putTcpProxy(tcp); } if (p != null) { String error = p.getText("error"); if (StringUtil.isNotEmpty(error)) { ConsoleProxy.errorSafe(error); } else { final String name = p.getText("name"); final long size = p.getLong("size"); ExUtil.exec(tableViewer.getTable(), new Runnable() { public void run() { if (MessageDialog.openQuestion(tableViewer.getTable().getShell(), data.name, name + "(" + ScouterUtil.humanReadableByteCount(size, true) + ") will be downloaded.\nContinue?")) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getShell(); FileDialog dialog = new FileDialog(shell, SWT.SAVE); dialog.setOverwrite(true); dialog.setFileName(name); dialog.setFilterExtensions(new String[] { "*.jar", "*.*" }); dialog.setFilterNames( new String[] { "Jar File(*.jar)", "All Files" }); String fileSelected = dialog.open(); if (fileSelected != null) { new DownloadJarFileJob(name, resource, fileSelected).schedule(); } } } }); } } } }); } }); } manager.add(new Action("&Description") { public void run() { openDescription(); } }); manager.add(new Separator()); if (server.isAllowAction(GroupPolicyConstants.ALLOW_REDEFINECLASS)) { manager.add(new Action("&Redefine class") { public void run() { StructuredSelection selection = (StructuredSelection) tableViewer.getSelection(); final ListValue classLv = new ListValue(); Object[] datas = selection.toArray(); for (int i = 0; i < datas.length; i++) { ClassData data = (ClassData) datas[i]; classLv.add(data.name); } if (MessageDialog.openQuestion(tableViewer.getTable().getShell(), classLv.size() + " class(es) selected", "Redefine class may affect this server.\nContinue?")) { new RedefineClassJob(classLv).schedule(); } } }); } tableViewer.getTable().addListener(SWT.KeyDown, new Listener() { public void handleEvent(Event e) { if (e.stateMask == SWT.CTRL) { if (e.keyCode == 'c' || e.keyCode == 'C') { selectionCopyToClipboard(); } } } }); }
From source file:scouter.client.views.ObjectFileSocketView.java
License:Apache License
private void createTableContextMenu() { MenuManager manager = new MenuManager(); viewer.getControl().setMenu(manager.createContextMenu(viewer.getControl())); manager.add(new Action("&Stack Trace", ImageDescriptor.createFromImage(Images.pin)) { public void run() { try { StructuredSelection sel = (StructuredSelection) viewer.getSelection(); SocketObject socketObj = (SocketObject) sel.getFirstElement(); if (socketObj != null) { load(socketObj.key); }/*from www . j a v a2s . c o m*/ } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:scouter.client.xlog.dialog.XLogSummaryAbstractDialog.java
License:Apache License
private void createTableContextMenu() { MenuManager manager = new MenuManager(); viewer.getControl().setMenu(manager.createContextMenu(viewer.getControl())); manager.add(new Action("&Copy", ImageDescriptor.createFromImage(Images.copy)) { public void run() { TableItem[] items = viewer.getTable().getSelection(); if (items == null || items.length < 1) { return; }//from www .j a v a2 s .c om copyToClipboard(items); } }); }
From source file:se.aceone.mediatek.linkit.ui.NewLinkit10ProjectWizard.java
License:Open Source License
@Override /**/*from ww w . j a va2 s. c o m*/ * adds pages to the wizard. We are using the standard project wizard of Eclipse */ public void addPages() { // // We assume everything is OK as it is tested in the handler // create each page and fill in the title and description // first page to fill in the project name // mWizardPage = new WizardNewProjectCreationPage("New LinkIt SDK 1.0 Tool Chain Project"); mWizardPage.setDescription("Create a new LinkItIt SDK 1.0 Tool Chain Project."); mWizardPage.setTitle("New LinkItIt SDK 1.0 Tool Chain Project"); AbstractUIPlugin plugin = Activator.getDefault(); ImageRegistry imageRegistry = plugin.getImageRegistry(); Image myImage = imageRegistry.get(Activator.CPU_64PX); ImageDescriptor image = ImageDescriptor.createFromImage(myImage); mWizardPage.setImageDescriptor(image); // // / addPage(mWizardPage); configPage = new ConfigureLinkIt10ProjectWizardPage(); addPage(configPage); }