List of usage examples for org.eclipse.jface.dialogs MessageDialog openQuestion
public static boolean openQuestion(Shell parent, String title, String message)
From source file:com.generalrobotix.ui.item.GrxProjectItem.java
License:Open Source License
public void save(File f) { if (f.exists()) { if (!f.isFile()) return; }//from w ww .jav a 2s .co m String mode = manager_.getCurrentModeName(); storeMode(mode); setName(f.getName().split("[.]")[0]); //$NON-NLS-1$ setURL(f.getAbsolutePath()); if (MessageDialog.openQuestion(null, MessageBundle.get("GrxProjectItem.dialog.savewindow.title"), MessageBundle.get("GrxProjectItem.dialog.savewindow.message"))) { //$NON-NLS-1$ Element element = _getModeNodeInfo(mode).root; Element windowConfigElement = storePerspectiveConf(element); setWindowConfigElement(mode, windowConfigElement); } if (f == null) f = new File(getDefaultDir().getAbsolutePath() + "/" + getName() + ".xml"); //$NON-NLS-1$ //$NON-NLS-2$ if (!f.getAbsolutePath().endsWith(".xml")) //$NON-NLS-1$ f = new File(f.getAbsolutePath() + ".xml"); //$NON-NLS-1$ try { DOMSource src = new DOMSource(); src.setNode(doc_); StreamResult target = new StreamResult(); target.setOutputStream(new FileOutputStream(f)); transformer_.transform(src, target); return; } catch (TransformerConfigurationException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace(); } MessageDialog.openError(null, MessageBundle.get("GrxProjectItem.dialog.saveError.title"), MessageBundle.get("GrxProjectItem.dialog.saveError.message")); }
From source file:com.generalrobotix.ui.item.GrxShapeItem.java
License:Open Source License
protected void initialize(Transform3D t3d) { Vector3d trans = new Vector3d(); Matrix3d rotat = new Matrix3d(); t3d.get(rotat, trans);// w w w. ja va 2s .c om double[] pos = new double[3]; trans.get(pos); translation(pos); AxisAngle4d a4d = new AxisAngle4d(); rotat.normalize(); a4d.setMatrix(rotat); double[] rot = new double[4]; a4d.get(rot); rotation(rot); resizeBoundingBox(); getMenu().clear(); Action item; // rename item = new Action() { public String getText() { return MessageBundle.get("GrxShapeItem.menu.rename"); //$NON-NLS-1$ } public void run() { InputDialog dialog = new InputDialog(null, getText(), MessageBundle.get("GrxShapeItem.dialog.message.newName"), getName(), null); //$NON-NLS-1$ if (dialog.open() == InputDialog.OK && dialog.getValue() != null) rename(dialog.getValue()); } }; setMenuItem(item); // delete item = new Action() { public String getText() { return MessageBundle.get("GrxShapeItem.menu.delete"); //$NON-NLS-1$ } public void run() { String mes = MessageBundle.get("GrxShapeItem.dialog.message.delete"); //$NON-NLS-1$ mes = NLS.bind(mes, new String[] { getName() }); if (MessageDialog.openQuestion(null, MessageBundle.get("GrxShapeItem.dialog.title.delete"), //$NON-NLS-1$ mes)) { delete(); } } }; setMenuItem(item); /* disable copy and paste menus until they are implemented // menu item : copy item = new Action(){ public String getText(){ return "copy"; } public void run(){ GrxDebugUtil.println("GrxModelItem.GrxShapeItem copy Action"); manager_.setSelectedGrxBaseItemList(); } }; setMenuItem(item); // menu item : paste item = new Action(){ public String getText(){ return "paste"; } public void run(){ } }; setMenuItem(item); */ setIcon("segment.png"); //$NON-NLS-1$ }
From source file:com.generalrobotix.ui.item.GrxSimulationItem.java
License:Open Source License
private boolean extendTime() { if (!isInteractive_) return false; boolean state = MessageDialog.openQuestion(GrxUIPerspectiveFactory.getCurrentShell(), MessageBundle.get("GrxOpenHRPView.dialog.title.timeUp"), //$NON-NLS-1$ MessageBundle.get("GrxOpenHRPView.dialog.message.TimeUp")); //$NON-NLS-1$ if (state == true) return false; String str = null;/*w w w. j a va 2 s .co m*/ while (true) { InputDialog dialog = new InputDialog(GrxUIPerspectiveFactory.getCurrentShell(), MessageBundle.get("GrxOpenHRPView.dialog.title.ExtendTime"), //$NON-NLS-1$ MessageBundle.get("GrxOpenHRPView.dialog.message.extendTime"), "5.0", null); //$NON-NLS-1$ //$NON-NLS-2$ int result = dialog.open(); str = dialog.getValue(); if (result == InputDialog.CANCEL) return false; try { double d = Double.parseDouble(str); if (d > 0) { //simParamPane_.setTotalTime(simParamPane_.getTotalTime() + d); totalTime_ = totalTime_ + d; setDbl("totalTime", totalTime_); currentWorld_.extendTime(totalTime_); break; } } catch (NumberFormatException e) { } } return true; }
From source file:com.generalrobotix.ui.view.graph.GraphPanel.java
License:Open Source License
public GraphPanel(GrxPluginManager manager, TrendGraphModel trendGraphMgr, Composite comp) { super(comp, SWT.NONE); manager_ = manager;//from w w w. j a v a2s . co m trendGraphMgr_ = trendGraphMgr; setLayout(new GridLayout(1, true)); graphScrollPane_ = new ScrolledComposite(this, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); graphScrollPane_.setExpandHorizontal(true); graphScrollPane_.setExpandVertical(true); GridData gridData0 = new GridData(); gridData0.horizontalAlignment = GridData.FILL; gridData0.grabExcessHorizontalSpace = true; gridData0.verticalAlignment = GridData.FILL; gridData0.grabExcessVerticalSpace = true; graphScrollPane_.setLayoutData(gridData0); Composite graphControlPanel = new Composite(this, SWT.NONE); GridData gridData1 = new GridData(); gridData1.horizontalAlignment = GridData.FILL; gridData1.grabExcessHorizontalSpace = true; graphControlPanel.setLayoutData(gridData1); graphControlPanel.setLayout(new RowLayout()); graphElementBase_ = new SashForm(graphScrollPane_, SWT.VERTICAL); graphElementBase_.SASH_WIDTH = 6; graphScrollPane_.setContent(graphElementBase_); numGraph_ = trendGraphMgr_.getNumGraph(); graphElement_ = new GraphElement[numGraph_]; for (int i = 0; i < numGraph_; i++) { graphElement_[i] = new GraphElement(this, graphElementBase_, trendGraphMgr_.getTrendGraph(i)); } graphScrollPane_.setMinSize(graphElementBase_.computeSize(SWT.DEFAULT, SWT.DEFAULT)); currentGraph_ = graphElement_[0]; graphElement_[0].setBorderColor(focusedColor_); hRangeButton_ = new Button(graphControlPanel, SWT.PUSH); hRangeButton_.setText(MessageBundle.get("GraphPanel.button.hrange")); //$NON-NLS-1$ hRangeDialog_ = new HRangeDialog(graphControlPanel.getShell()); hRangeButton_.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { GrxGraphItem graphItem = manager_.<GrxGraphItem>getSelectedItem(GrxGraphItem.class, null); if (graphItem == null) return; hRangeDialog_.setMaxHRange(trendGraphMgr_.getTotalTime()); hRangeDialog_.setMinHRange(trendGraphMgr_.getStepTime() * 10); double range = trendGraphMgr_.getTimeRange(); double pos = trendGraphMgr_.getMarkerPos(); hRangeDialog_.setHRange(range); hRangeDialog_.setMarkerPos(pos); if (hRangeDialog_.open() == IDialogConstants.OK_ID) { int flag = hRangeDialog_.getUpdateFlag(); if (flag != 0) { TrendGraph tg = currentGraph_.getTrendGraph(); double hRange = hRangeDialog_.getHRange(); double mpos = hRangeDialog_.getMarkerPos(); if ((flag & HRangeDialog.RANGE_UPDATED) != 0 || (flag & HRangeDialog.POS_UPDATED) != 0) { tg.setTimeRangeAndPos(hRange, mpos); } graphItem.setDblAry("timeRange", new double[] { hRange, mpos }); //$NON-NLS-1$ trendGraphMgr_.updateGraph(); } } } }); vRangeButton_ = new Button(graphControlPanel, SWT.PUSH); vRangeButton_.setText(MessageBundle.get("GraphPanel.button.vrange")); //$NON-NLS-1$ vRangeDialog_ = new VRangeDialog(graphControlPanel.getShell()); vRangeButton_.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { TrendGraph tg = currentGraph_.getTrendGraph(); vRangeDialog_.setUnit(tg.getUnitLabel()); vRangeDialog_.setBase(tg.getBase()); vRangeDialog_.setExtent(tg.getExtent()); if (vRangeDialog_.open() == IDialogConstants.OK_ID) { double base = vRangeDialog_.getBase(); double extent = vRangeDialog_.getExtent(); tg.setRange(base, extent); GrxGraphItem graphItem = manager_.<GrxGraphItem>getSelectedItem(GrxGraphItem.class, null); if (graphItem == null) return; graphItem.setDblAry(currentGraph_.getTrendGraph().getNodeName() + ".vRange", //$NON-NLS-1$ new double[] { base, extent }); redraw(getLocation().x, getLocation().y, getSize().x, getSize().y, true); } } }); seriesButton_ = new Button(graphControlPanel, SWT.PUSH); seriesButton_.setText(MessageBundle.get("GraphPanel.button.series")); //$NON-NLS-1$ seriesDialog_ = new SeriesDialog(currentGraph_, graphControlPanel.getShell()); seriesButton_.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { GrxGraphItem graphItem = manager_.<GrxGraphItem>getSelectedItem(GrxGraphItem.class, null); if (graphItem == null) { if (MessageDialog.openQuestion(null, MessageBundle.get("GraphPanel.dialog.creategraph.title"), MessageBundle.get("GraphPanel.dialog.creategraph.message"))) { graphItem = (GrxGraphItem) manager_.createItem(GrxGraphItem.class, null); manager_.itemChange(graphItem, GrxPluginManager.ADD_ITEM); manager_.setSelectedItem(graphItem, true); } else return; } TrendGraph tg = currentGraph_.getTrendGraph(); seriesDialog_.setModelList(currentModels_); seriesDialog_.setDataItemInfoList(tg.getDataItemInfoList()); if (seriesDialog_.open() == IDialogConstants.OK_ID) { DataItemInfo[] dii = seriesDialog_.getDataItemInfoList(); for (int i = 0; i < dii.length; i++) { tg.setDataItemInfo(dii[i]); } dii = seriesDialog_.getRemovedList(); for (int i = 0; i < dii.length; i++) { tg.removeDataItem(dii[i]); } addedArray_ = seriesDialog_.getAddedList(); for (int i = 0; i < addedArray_.length; i++) { tg.addDataItem(addedArray_[i]); } String graphName = tg.getNodeName(); Enumeration<?> enume = graphItem.propertyNames(); while (enume.hasMoreElements()) { String key = (String) enume.nextElement(); if (key.startsWith(graphName)) graphItem.remove(key); } String dataItems = ""; //$NON-NLS-1$ DataItemInfo[] list = tg.getDataItemInfoList(); for (int i = 0; i < list.length; i++) { DataItem di = list[i].dataItem; String header = tg._getDataItemNodeName(di); if (i > 0) dataItems += ","; //$NON-NLS-1$ dataItems += graphName + "_" + di.object + "_" + di.node + "_" + di.attribute; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (di.index >= 0) dataItems += "_" + di.index; //$NON-NLS-1$ graphItem.setProperty(header + ".object", di.object); //$NON-NLS-1$ graphItem.setProperty(header + ".node", di.node); //$NON-NLS-1$ graphItem.setProperty(header + ".attr", di.attribute); //$NON-NLS-1$ graphItem.setProperty(header + ".index", String.valueOf(di.index)); //$NON-NLS-1$ graphItem.setProperty(header + ".legend", list[i].legend); //$NON-NLS-1$ graphItem.setProperty(header + ".color", StringConverter.asString(list[i].color)); //$NON-NLS-1$ } graphItem.setProperty(graphName + ".dataItems", dataItems); //$NON-NLS-1$ updateButtons(); trendGraphMgr_.updateGraph(); } } }); /* epsButton_ = new Button(graphControlPanel, SWT.PUSH); epsButton_.setText(MessageBundle.get("graph.eps")); epsDialog_ = new EPSDialog(owner_); epsButton_.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { epsDialog_.setColorOutput(true); epsDialog_.setGraphOutput(true); epsDialog_.setLegendOutput(true); epsDialog_.setLocationRelativeTo(GraphPanel.this); epsDialog_.setVisible(true); if (epsDialog_.isUpdated()) { String path = epsDialog_.getPath(); boolean cout = epsDialog_.isColorOutput(); boolean gout = epsDialog_.isGraphOutput(); boolean lout = epsDialog_.isLegendOutput(); FileWriter fw = null; if (path.equals("")) { new MessageDialog( owner_, MessageBundle.get("message.filenameempty"), MessageBundle.get("messege.inputfilename") ).showModalDialog(); return; } try { fw = new FileWriter(path); } catch (IOException ex) { //ex.printStackTrace(); //System.exit(0); new MessageDialog( owner_, MessageBundle.get("messege.fileioerror"), MessageBundle.get("messege.fileioerror") ).showModalDialog(); return; } BufferedWriter bw = new BufferedWriter(fw); DroppableXYGraph graph = (DroppableXYGraph)currentGraph_.getGraph(); DroppableXYGraph.LegendPanel legend = (DroppableXYGraph.LegendPanel)graph.getLegendPanel(); Dimension gsize = graph.getSize(); //Dimension lsize = legend.getSize(); Dimension lsize = legend.getMinimalSize(); int width = 0; int height = 0; int lyofs = 0; if (gout && lout) { width = gsize.width + lsize.width - GRAPH_RIGHT_MARGIN + 10; if (gsize.height > lsize.height) { height = gsize.height; lyofs = (gsize.height - lsize.height) / 2; } else { height = lsize.height; } } else if (gout) { width = gsize.width; height = gsize.height; } else if (lout) { width = lsize.width; height = lsize.height; } EPSGraphics eg = new EPSGraphics(bw, 0, 0, width, height, cout); int xofs = 0; if (gout) { graph.setEPSMode(true); graph.paint(eg); graph.setEPSMode(false); xofs += gsize.width - GRAPH_RIGHT_MARGIN + 10; } if (lout) { eg.setXOffset(xofs); eg.setYOffset(lyofs); legend.paint(eg); } eg.finishOutput(); } } } ); */ setEnabledRangeButton(false); }
From source file:com.generalrobotix.ui.view.GrxServerManagerView.java
License:Open Source License
private void updateNameServerBtn() { StringBuffer refHost = new StringBuffer(""); StringBuffer refPort = new StringBuffer(""); boolean ret = MessageDialog.openQuestion(composite_.getShell(), MessageBundle.get("GrxServerManagerView.dialog.infomation.tittle.updateNameServer"), MessageBundle.get("GrxServerManagerView.dialog.infomation.message.updateNameServer")); if (ret) {/* w ww . j ava 2 s . c o m*/ String message = serverManager_.setNewHostPort(textNsHost_.getText(), textNsPort_.getText(), refHost, refPort); // TODO if (message.isEmpty()) { updateNameServerBtn_.setEnabled(false); restartServers(); } else { MessageDialog.openError(composite_.getShell(), MessageBundle.get("GrxServerManagerView.dialog.error.tittle.updateNameServer"), message); if (refHost.length() != 0) { textNsHost_.setText(refHost.toString()); } if (refPort.length() != 0) { textNsPort_.setText(refPort.toString()); } } } }
From source file:com.generalrobotix.ui.view.GrxTextEditorView.java
License:Open Source License
public GrxTextEditorView(String name, GrxPluginManager manager_, GrxBaseViewPart vp, Composite parent) { super(name, manager_, vp, parent); GridLayout layout = new GridLayout(1, true); layout.marginHeight = 0;/*from w w w .ja v a2s . c o m*/ layout.marginWidth = 0; layout.horizontalSpacing = 0; layout.verticalSpacing = 0; composite_.setLayout(layout); area_ = new StyledText(composite_, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); area_.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (currentItem_ != null) currentItem_.setValue(area_.getText()); } }); area_.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { if (currentItem_ == null) return; if (currentItem_.isModifiedExternally()) { boolean state = MessageDialog.openQuestion(getParent().getShell(), MessageBundle.get("GrxTextEditorView.dialog.title.reload"), //$NON-NLS-1$ MessageBundle.get("GrxTextEditorView.dialog.message.reload")); //$NON-NLS-1$ if (state) { currentItem_.reload(); area_.setText(currentItem_.getValue()); } } } public void focusLost(FocusEvent e) { } }); area_.addListener(SWT.Paint, new Listener() { public void handleEvent(Event event) { setPositionLabel(); } }); area_.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event event) { setPositionLabel(); } }); area_.addListener(SWT.KeyDown, new Listener() { public void handleEvent(Event event) { setPositionLabel(); } }); status_ = new Label(composite_, SWT.BORDER); GridData textData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); area_.setLayoutData(textData); GridData statusData = new GridData(GridData.FILL_HORIZONTAL); statusData.verticalAlignment = SWT.END; status_.setLayoutData(statusData); IToolBarManager toolbar = vp.getViewSite().getActionBars().getToolBarManager(); save_ = new Action() { public void run() { if (currentItem_ != null) { currentItem_.setValue(area_.getText()); currentItem_.save(); //save_.setEnabled(false); } } }; save_.setToolTipText(MessageBundle.get("GrxTextEditorView.text.save")); //$NON-NLS-1$ save_.setImageDescriptor(Activator.getDefault().getDescriptor("save_edit.png")); //$NON-NLS-1$ toolbar.add(save_); saveAs_ = new Action() { public void run() { if (currentItem_ != null) { currentItem_.setValue(area_.getText()); currentItem_.saveAs(); } } }; saveAs_.setToolTipText(MessageBundle.get("GrxTextEditorView.text.saveAs")); //$NON-NLS-1$ saveAs_.setImageDescriptor(Activator.getDefault().getDescriptor("saveas_edit.png")); //$NON-NLS-1$ toolbar.add(saveAs_); setScrollMinSize(SWT.DEFAULT, SWT.DEFAULT); setUp(); manager_.registerItemChangeListener(this, GrxPythonScriptItem.class); updateEditerFont(); }
From source file:com.generalrobotix.ui.view.simulation.CollisionPairPanel.java
License:Open Source License
private boolean _checkDialog(String msg) { boolean overwrite = MessageDialog.openQuestion(getShell(), MessageBundle.get("dialog.overwrite"), msg); //$NON-NLS-1$ return overwrite; }
From source file:com.genuitec.eclipse.gerrit.tools.internal.fbranches.commands.DeleteFeatureBranchCommand.java
License:Open Source License
@Override protected void execute(ExecutionEvent event, final List<Repository> repositories, String branchRef) throws ExecutionException { final Shell shell = HandlerUtil.getActiveShell(event); if (!MessageDialog.openQuestion(shell, "Delete branch", "Delete feature branch: " + branchRef + " ?")) { //user cancelled return;/* w w w. j a va 2 s. co m*/ } for (Repository repo : repositories) { try { if (//local repo.getRef(branchRef) != null || //or remote repo.getRef("refs/remotes/origin/" + branchRef.substring("refs/heads/".length())) != null) { execute(shell, repo, branchRef); } } catch (IOException e) { throw new ExecutionException(e.getLocalizedMessage(), e); } } }
From source file:com.github.sdbg.debug.ui.internal.DefaultDebugUIHelper.java
License:Open Source License
@Override public void showDevtoolsDisconnectError(final String _title, final ISDBGDebugTarget target) { final Display display = Display.getDefault(); Display.getDefault().asyncExec(new Runnable() { @Override//from w ww. j a va 2 s .c o m public void run() { if (display.isDisposed()) { return; } String title = _title; String message = "The debugger connection has been closed by DevTools.\n\n" + "DevTools only supports one connected debugger (e.g. Editor or Chrome DevTools) at a " + "time. Do you want to re-connect? (DevTools must be closed first)"; Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); while (MessageDialog.openQuestion(shell, title, message)) { try { target.reconnect(); return; } catch (IOException e) { title = "Error Re-connecting"; message = "Unable to reconnect - DevTools must first be closed in the browser." + " Try to reconnect again?\n\n" + "(" + e.toString() + ")"; } } } }); }
From source file:com.google.appengine.eclipse.core.deploy.ui.DeployProjectHandler.java
License:Open Source License
private boolean shouldDeploy(GaeProject gaeProject) { IStatus status = gaeProject.getDeployableStatus(); if (status.getSeverity() == IStatus.ERROR) { MessageDialog.openError(Display.getDefault().getActiveShell(), "Google App Engine", status.getMessage());//from w w w .j a va 2s . com return false; } else if (status.getSeverity() == IStatus.WARNING) { String message = status.getMessage() + "\n\nDo you want to continue and deploy anyway?"; return MessageDialog.openQuestion(Display.getDefault().getActiveShell(), "Google App Engine", message); } return true; }