/** * Starting point for the demonstration application. * * @param args ignored. */ public static void main( String[] args ) { JFreeChart chart = createChart(createDataset()); Display display = new Display(); Shell shell = new Shell(display); shell.setSize(600, 400); shell.setLayout(new FillLayout()); shell.setText("Test for jfreechart running with SWT"); final ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true); //frame.setDisplayToolTips(false); frame.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
@Override protected void onDoubleClick() { HivePartitionKeyValueDialog fieldDialog=new HivePartitionKeyValueDialog(Display.getCurrent().getActiveShell(), propertyDialogButtonBar); fieldDialog.setComponentName(gridConfig.getComponentName()); if (getProperties().get(propertyName) == null) { InputHivePartitionKeyValues inputHivePartitionKeyValues = new InputHivePartitionKeyValues(); List<String> keys= new ArrayList<>(); List<InputHivePartitionColumn> keyValues = new ArrayList<>(); inputHivePartitionKeyValues.setKey(keys); inputHivePartitionKeyValues.setKeyValues(keyValues); setProperties(propertyName, (InputHivePartitionKeyValues)inputHivePartitionKeyValues); } fieldDialog.setRuntimePropertySet(hivePartitionKeyValues); fieldDialog.setSourceFieldsFromPropagatedSchema(getPropagatedSchema()); fieldDialog.open(); setProperties(propertyName,fieldDialog.getRuntimePropertySet()); }
public void init(IEditorSite site, IEditorInput input) throws PartInitException { super.init(site, input); setSite(site); setPartName(input.getName()); setInputWithNotify(input); site.setSelectionProvider(this); if (getEditorInput() instanceof FileEditorInput) { FileEditorInput fei = (FileEditorInput) getEditorInput(); IFile file = fei.getFile(); gWGraph = ResourceManager.load(file); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { gWGraph.initialize(getGraphicalViewer().getEditPartRegistry()); if (!ResourceManager.isEditable(file)) { gWGraph.setReadOnly(true); getGraphicalViewer().getControl().setEnabled(false); String title = MessageUtil.getString("conversion"); String message = MessageUtil.getString("not_formatted_as_json_convert_it"); DialogManager.displayWarning(title, message); } } }); } }
/** * Build and show the Window, dispose it after is is not longer needed. * @param parent The parent ShellWindow. * @param arrayModificationHandler The ArrayModificationHandler the holds the represented array. * @param myDimension The dimension of a probably multidimensional array this Window represents. * @param dimensionsIndexes Dimension indexes of the higher-level dimensions the array represented might be a part of. */ public void show(ShellWindow parent, ArrayModificationHandler arrayModificationHandler, int myDimension, int[] dimensionsIndexes) { try { // Initialize. this.parent = parent; this.display = Display.getDefault(); createShell(arrayModificationHandler, myDimension, dimensionsIndexes); this.shell.open(); // Keep the window active as long as it is needed. while (!this.shell.isDisposed()) { if (!this.display.readAndDispatch()) this.display.sleep(); } } catch (Throwable t) { arrayModificationHandler.doNotReturnThisArray(); StaticGuiSupport.processGuiError(t, "Array entries", parent.getShell()); } finally { doExit(); } }
/** * Called when an atomic test has finished, whether the test succeeds or fails. * * @param description * the description of the test that just ran */ @Override public void testFinished(Description description) throws Exception { Display.getDefault().syncExec(new Runnable() { @Override public void run() { IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows(); try { N4IDEXpectView view = (N4IDEXpectView) windows[0].getActivePage().showView( N4IDEXpectView.ID); view.notifyFinishedExecutionOf(description); } catch (PartInitException e) { N4IDEXpectUIPlugin.logError("cannot refresh test view window", e); } } }); }
/** * Called when an atomic test flags that it assumes a condition that is false * * describes the test that failed and the {@link AssumptionViolatedException} that was thrown */ @Override public void testAssumptionFailure(Failure failure) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows(); try { N4IDEXpectView view = (N4IDEXpectView) windows[0].getActivePage().showView( N4IDEXpectView.ID); view.notifyFailedExecutionOf(failure); } catch (PartInitException e) { N4IDEXpectUIPlugin.logError("cannot refresh test view window", e); } } }); }
/** * Build and show the Windows, dispose it after is is not longer needed. * @param parentShell The parent windows' Shell. * @param classLoader The system MugglClassLoader. * @param classFile The classFile the initial Method belongs to. * @param method The initial Method. */ public void show(Shell parentShell, MugglClassLoader classLoader, ClassFile classFile, Method method) { try { this.display = Display.getDefault(); if (createShell(parentShell, classLoader, classFile, method)) this.shell.open(); // Now make the parent shell invisible. parentShell.setVisible(false); // Keep the window alive. while (!this.shell.isDisposed()) { if (!this.display.readAndDispatch()) this.display.sleep(); } } catch (Throwable t) { StaticGuiSupport.processGuiError(t, "Step by step execution", parentShell); } finally { //Make the parent shell visible. parentShell.setVisible(true); // Make sure execution is aborted. Otherwise the Thread would not be stopped and the memory released after this window is closed. if (this.stepByStepExecutionComposite != null) this.stepByStepExecutionComposite.abortExecution(false); doExit(); } }
@Override public void update ( final ViewerCell cell ) { final ConfigurationDescriptor cfg = (ConfigurationDescriptor)cell.getElement (); switch ( cell.getColumnIndex () ) { case 0: cell.setText ( cfg.getConfigurationInformation ().getId () ); break; case 1: cell.setText ( "" + cfg.getConfigurationInformation ().getState () ); break; } if ( cfg.getConfigurationInformation ().getErrorInformation () != null ) { cell.setBackground ( Display.getCurrent ().getSystemColor ( SWT.COLOR_RED ) ); } else { cell.setBackground ( null ); } super.update ( cell ); }
/** * create the main avoCADo shell and display it * @param display */ public MainAvoCADoShell(Display display){ shell = new Shell(display); setupShell(); // place components in the main avoCADo shell shell.setText("avoCADo"); shell.setSize(800, 600); //TODO: set intial size to last known size shell.setMinimumSize(640, 480); Rectangle b = display.getBounds(); int xPos = Math.max(0, (b.width-800)/2); int yPos = Math.max(0, (b.height-600)/2); shell.setLocation(xPos, yPos); shell.setImage(ImageUtils.getIcon("./avoCADo.png", 32, 32)); shell.open(); AvoGlobal.intializeNewAvoCADoProject(); // initialize app to starting model/view. StartupSplashShell.closeSplash(); // handle events while the shell is not disposed while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
public static void focusMarker(final IMarker marker) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { try { IDE.openEditor( MarkerActivator.getDefault().getWorkbench().getWorkbenchWindows()[0].getActivePage(), marker); } catch (final PartInitException e1) { e1.printStackTrace(); } } }); }
/** * Create instance. */ public TestProgressBar(Composite parent, int style) { super(parent, style); // damn you, SWT color management // Color sample is form: http://www.colorpicker.com/c6f2b1 colorSkipped = new Color(Display.getCurrent(), 230, 232, 235); colorPassed = new Color(Display.getCurrent(), 198, 242, 177); colorFailed = new Color(Display.getCurrent(), 242, 188, 177); colorError = new Color(Display.getCurrent(), 242, 188, 177); colorFixme = new Color(Display.getCurrent(), 177, 231, 242); addPaintListener((ev) -> { onPaint(ev.gc); }); addDisposeListener((ev) -> { onDispose(); }); }
public List<GridRow> getSchemaFromXSD(String XSDFile,String loopXPathQuery) throws ParserConfigurationException, SAXException, IOException, JAXBException{ SchemaParser parser = new SchemaParser(); try{ Schema schema=parser.parse(XSDFile); Element element = getRowTagElement(schema); if(element==null){ return null; } return parseElementsOfRowTag(element,loopXPathQuery); } catch(Exception e){ createMessageBox(INVALID_XSD_FILE+e.getMessage(), Constants.ERROR, SWT.ERROR,Display.getCurrent().getActiveShell()); } return null; }
/** * Creates a new CommentBoxFigure with a MarginBorder that is the given size and a FlowPage containing a TextFlow * with the style WORD_WRAP_SOFT. * * @param borderSize * the size of the MarginBorder */ public CommentBoxFigure(int borderSize) { setBorder(new MarginBorder(5)); FlowPage flowPage = new FlowPage(); textFlow = new TextFlow(); textFlow.setLayoutManager(new ParagraphTextLayout(textFlow, ParagraphTextLayout.WORD_WRAP_SOFT)); flowPage.add(textFlow); setLayoutManager(new StackLayout()); add(flowPage); font = new Font(Display.getDefault(), "Arial", 9, SWT.NORMAL); setFont(font); setForegroundColor(ColorConstants.black); setOpaque(false); }
@Override public Object start ( final IApplicationContext context ) throws Exception { Display display = PlatformUI.createDisplay (); try { int returnCode = PlatformUI.createAndRunWorkbench ( display, new ApplicationWorkbenchAdvisor () ); if ( returnCode == PlatformUI.RETURN_RESTART ) { return IApplication.EXIT_RESTART; } else { return IApplication.EXIT_OK; } } finally { display.dispose (); } }
/** * create the startup splash shell and display it * @param display */ public AboutAvoCADoGPLShell(Display display){ shell = new Shell(display, SWT.PRIMARY_MODAL); setupShell(); // place components in the avoCADo license shell shell.setText("avoCADo GPLv2"); shell.setSize(583, 350); //TODO: set initial size to last known size Rectangle b = display.getBounds(); int xPos = Math.max(0, (b.width-583)/2); int yPos = Math.max(0, (b.height-350)/2); shell.setLocation(xPos, yPos); shell.open(); // handle events while the shell is not disposed while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
public void loadProperties(TableViewer tv) { if (fieldNameList != null && !fieldNameList.isEmpty()) { for (String key : fieldNameList) { FilterProperties filter = new FilterProperties(); if (validateBeforeLoad(key)) { filter.setPropertyname(key); propertyList.add(filter); tv.refresh(); if(!sourceFieldsList.contains(filter.getPropertyname())){ tv.getTable().getItem(propertyList.size()-1).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); }else{ tv.getTable().getItem(propertyList.size()-1).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); } } } tv.refresh(); } else { logger.debug("LodProperties :: Empty Map"); } }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWizardDescriptor descriptor = PlatformUI.getWorkbench().getNewWizardRegistry().findWizard(ID); if (descriptor == null) { descriptor = PlatformUI.getWorkbench().getImportWizardRegistry().findWizard(ID); } if (descriptor == null) { descriptor = PlatformUI.getWorkbench().getExportWizardRegistry().findWizard(ID); } try { if (descriptor != null) { IWizard wizard = descriptor.createWizard(); WizardDialog wd = new WizardDialog(Display.getDefault().getActiveShell(), wizard); wd.setTitle(wizard.getWindowTitle()); wd.open(); } } catch (CoreException e) { e.printStackTrace(); } return null; }
void initializeColors() { Display display = Display.getDefault(); colors = new Color[] { new Color(display, new RGB(0, 0, 0)), // black new Color(display, new RGB(128, 0, 0)), // red new Color(display, new RGB(0, 128, 0)), // green new Color(display, new RGB(0, 0, 128)) // blue }; tokenColors = new int[MAXIMUM_TOKEN]; tokenColors[OTHER] = 0; tokenColors[NUMBER] = 0; tokenColors[WORD] = 0; tokenColors[WHITE] = 0; tokenColors[COMMENT] = 1; tokenColors[STRING] = 2; tokenColors[KEY] = 3; }
private void runEventLoop(Shell loopShell) { Display display; if (getShell() == null) { display = Display.getCurrent(); } else { display = loopShell.getDisplay(); } while (loopShell != null && !loopShell.isDisposed()) { try { if (!display.readAndDispatch()) { display.sleep(); } } catch (Throwable e) { EclipseUtil.logError("UI problems on dispatch",e); } } if (!display.isDisposed()) { display.update(); } }
@Override protected Shell createShell(Display display) throws Exception { this.controlTree = getControlTree("control_tree.xml"); this.viewer = new ControlTreeViewer(controlTree, Services.getConnector()); viewer.setUseFilteredTree(false); Shell shell = new Shell(display); shell.setText("Control Tree"); shell.setLayout(new GridLayout(1, false)); viewer.createPartControl(shell, controlTree); shell.pack(); shell.setSize(500, 500); shell.open(); return shell; }
public static void drawShadowImage(GC gc, Image image, int x, int y, int alpha) { Display display = Display.getCurrent(); Point imageSize = new Point(image.getBounds().width, image.getBounds().height); // ImageData imgData = new ImageData(imageSize.x, imageSize.y, 24, new PaletteData(255, 255, 255)); imgData.alpha = alpha; Image img = new Image(display, imgData); GC imgGC = new GC(img); imgGC.drawImage(image, 0, 0); gc.drawImage(img, x, y); imgGC.dispose(); img.dispose(); }
@Override public void initialReconcile() { if (this.document == null) { return; } Display.getDefault().syncExec(new Runnable() { @Override public void run() { try { RelationModelReconcilingStrategy.this.manager = new SynchronizationManager(RelationModelReconcilingStrategy.this.document); } catch (final BadLocationException e) { e.printStackTrace(); } } }); }
private static void paintLine(int line, int y, int lineHeight, GC gc, Display display, LineNumberChangeRulerColumn l) { try { Method m = LineNumberRulerColumn.class .getDeclaredMethod("paintLine", new Class[] { int.class, int.class, int.class, GC.class, Display.class }); m.setAccessible(true); m.invoke(l, line, y, lineHeight, gc, display); } catch (Exception e) { e.printStackTrace(); } }
public void animateBackwards(long mSecDuration){ goingFwd = false; timeBegin = System.currentTimeMillis(); duration = mSecDuration; timeBegin -= (long)((1.0f-lastPercentComplete)*(float)duration); if(duration <= 0){ animatorTransition(0.0f); lastPercentComplete = 0.0f; return; } new Runnable() { public void run() { if(!goingFwd){ float percentComplete = (float)(System.currentTimeMillis()-timeBegin) / (float)duration; if(percentComplete <= 1.0){ animatorTransition(1.0f - percentComplete); lastPercentComplete = (1.0f - percentComplete); Display.getCurrent().timerExec(mSec,this); }else{ animatorTransition(0.0f); lastPercentComplete = 0.0f; } } } }.run(); }
public void preferences() { try { Config.getInstance().showConfigurationDialog(shell); } catch (PmTransException e) { MessageBox diag = new MessageBox(Display.getCurrent().getActiveShell(), SWT.APPLICATION_MODAL | SWT.ICON_ERROR | SWT.OK); diag.setMessage("Unable to save preferences"); diag.open(); } }
@Override protected void createInitialModel(Resource resource) { Configuration rootObject = OCCIFactory.eINSTANCE.createConfiguration(); resource.getContents().add(rootObject); try { Importer.importFromOcciServer(rootObject, occiServerUrl); rootObject.setLocation(occiServerUrl); } catch (Throwable throwable) { Shell shell = Display.getCurrent().getActiveShell(); Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, null, throwable); ErrorDialog.openError(shell, null, throwable.getMessage(), status); throwable.printStackTrace(System.err); return; } }
/** * Get {@link IWorkbenchPage} of currently running workbench. Returned value is wrapped in Optional, thus it is * never null. */ public static final Optional<IWorkbenchPage> getActivePage() { AtomicReference<IWorkbenchPage> wrappedPage = new AtomicReference<>(); Display.getDefault().syncExec(() -> wrappedPage.set(unsafeGetWorkbenchPage())); IWorkbenchPage page = wrappedPage.get(); if (page == null) logger.warn("Cannot obtain IWorkbenchPage, will return empty Optional"); return Optional.ofNullable(page); }
@Override public void numberOfPossibleStepsAtChanged(final int branch, final int index, final int numberOfPossibleStep) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { deepRefresh(); } }); }
/** If {@link IWorkbenchPage} is available, will try to force close (without save) provided editor. */ public static final void forceCloseEditor(IEditorPart editor) { Display.getDefault().syncExec(() -> { IWorkbenchPage page = unsafeGetWorkbenchPage(); if (page != null) { boolean allClosed = page.closeEditor(editor, false); logger.info("Editor closed: " + allClosed); } else { logger.info(" Closing all editors: No active page."); } }); }
public DialogFuture ( final Display display, final Callback[] callbacks, final List<CallbackWidgetFactory> factories ) { this.parentShell = null; this.display = display; this.callbacks = callbacks; this.factories = factories; }
protected void flush(IEclipsePreferences node) { try { node.flush(); } catch (BackingStoreException e) { MessageDialog.openError(Display.getDefault().getActiveShell(), "Error saving preference", "Error saving preference value for node " + node.name() + " . Check error log for details"); PrefEditorPlugin.log(e); } }
public void run() { Display display = Display.getDefault(); Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT); Shell shell = getParentShell(); shell.setCursor(waitCursor); try { ProjectExplorerView explorerView = getProjectExplorerView(); if (explorerView != null) { TreeObject treeObject = explorerView.getFirstSelectedTreeObject(); Object databaseObject = treeObject.getObject(); if ((databaseObject != null) && (databaseObject instanceof TestCase)) { TestCase testCase = (TestCase)databaseObject; testCase.importRequestableVariables((RequestableObject)testCase.getParent()); if (testCase.hasChanged) { explorerView.reloadTreeObject(treeObject); StructuredSelection structuredSelection = new StructuredSelection(treeObject); ConvertigoPlugin.getDefault().getPropertiesView().selectionChanged((IWorkbenchPart)explorerView, structuredSelection); } } } } catch (Throwable e) { ConvertigoPlugin.logException(e, "Unable to add requestable variables to test case!"); } finally { shell.setCursor(null); waitCursor.dispose(); } }
@Override public Color getForeground(Object ofield) { Color ret = super.getForeground(ofield); if (ret!=null) return ret; if (ofield instanceof FieldValue && viewer.isValidationError((FieldValue)ofield)) { return Display.getDefault().getSystemColor(SWT.COLOR_RED); } else { return null; } }
public void setWeight(SWTBotGefEditPart part, double value) { selectPart(part); selectTab(part, PROPERTIES); final SWTBotText text = botView.bot().textWithId(WIDGET_ID,WIDGET_TEXT_WEIGHT); text.setText(value+""); Display.getDefault().asyncExec(new Runnable () { @Override public void run() { //SWTBotText text = botView.bot().textWithId(WIDGET_ID,WIDGET_TEXT_WEIGHT); text.widget.notifyListeners(SWT.FocusOut, createFocusEvent((Control)text.widget)); } }); }
public LongRunningOperation(Display display, ProgressBar progressBar, Button button) { this.display = display; this.progressBar = progressBar; this.parentShell = progressBar.getShell(); this.button = button; }
@Override protected void okPressed() { configProperty.setLookupKey(lookupKey); configProperty.setDriverKey(driverKey); if(!oldConfigProperty.equals(configProperty)){ propertyDialogButtonBar.enableApplyButton(true); MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.INFORMATION, Messages.LOOKUP_PORT_CHANGE); } super.okPressed(); }
/** * Open the dialog. * * @return the result */ public boolean open() { createContents(); shell.open(); shell.layout(); Display display = getParent().getDisplay(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return flag; }
/** */ public void write(String msg) { if (msg == null) { return; } // messageConsole.activate(); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { messageConsole.newMessageStream().print(msg); // messageConsole.clearConsole(); } }); }
/** * Instantiates a new external schema selection dialog including validator for schema extension * * @param title the title * @param message the message * @param type the type * @param filterOperationClassUtility the filter operation class utility */ public ExternalSchemaFileSelectionDialog(String title, String message, String[] type,FilterOperationClassUtility filterOperationClassUtility) { this(Display.getDefault().getActiveShell(), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(), contentProvider); this.extensions = type; setTitle(title); setMessage(message); setInput(computeInput()); setValidator(validator); this.filterOperationClassUtility=filterOperationClassUtility; }
public void sugiyamaLayout() { Display.getDefault().syncExec(new Runnable() { @Override public void run() { resetEdgesRouteLayout(); gWGraph.setLayout(new Rectangle(0, 0, getDimension().width, getDimension().height)); LayoutAlgoritmManager.sugiyamaLayout(gWGraph, getDimension()); } }); }