Java Code Examples for org.eclipse.swt.widgets.Display.getDefault()

The following are Jave code examples for showing how to use getDefault() of the org.eclipse.swt.widgets.Display class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: tap17-muggl-javaee   File: LogWindow.java   View Source Code Vote up 6 votes
/**
 * Build and show the Windows, dispose it after is is not longer needed.
 *
 * @throws IllegalStateException If the parent shell is unusable (null or disposed).
 */
public void show() {
	try {
		this.display = Display.getDefault();
		createShell();
		this.shell.open();

		while (!this.shell.isDisposed()) {
			if (!this.display.readAndDispatch())
				this.display.sleep();
			}
	} catch (Throwable t) {
		if (this.parentShell != null && !this.parentShell.isDisposed()) {
			StaticGuiSupport.processGuiError(t, "log", this.parentShell);
		}
	} finally {
		doExit();
	}
}
 
Example 2
Project: BiglyBT   File: BuddyPluginView.java   View Source Code Vote up 5 votes
@Override
public void
openChat(
	final ChatInstance chat )
{
	final Display display = Display.getDefault();

	if ( display.isDisposed()){

		return;
	}

	display.asyncExec(
		new Runnable()
		{
			@Override
			public void
			run()
			{
				if ( display.isDisposed()){

					return;
				}

				BuddyPluginViewBetaChat.createChatWindow( BuddyPluginView.this, plugin, chat );
			}
		});
}
 
Example 3
Project: convertigo-eclipse   File: ExecuteMobileBuilderClassAction.java   View Source Code Vote up 5 votes
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();
   			if (treeObject instanceof MobileComponentTreeObject) {
   				if (treeObject instanceof MobileApplicationComponentTreeObject) {
   					MobileApplicationComponentTreeObject mpcto = (MobileApplicationComponentTreeObject) treeObject;
   					ApplicationComponentEditor editor = mpcto.activeEditor(false);
   					editor.launchBuilder(forceInstall, forceClean);
   				}
   			}
   		}
       }
       catch (Throwable e) {
       	ConvertigoPlugin.logException(e, "Unable to open the mobile builder!");
       }
       finally {
		shell.setCursor(null);
		waitCursor.dispose();
       }
}
 
Example 4
Project: convertigo-eclipse   File: TransactionExecuteSelectedAction.java   View Source Code Vote up 5 votes
@Override
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();
   			if ((treeObject != null) && (treeObject instanceof TransactionTreeObject)) {
   				TransactionTreeObject transactionTreeObject = (TransactionTreeObject)treeObject;
   				
   				Transaction transaction = transactionTreeObject.getObject();
   				transactionTreeObject.getConnectorTreeObject().openConnectorEditor();
   				
   				Connector connector = (Connector)transaction.getParent();
   				ProjectTreeObject projectTreeObject = transactionTreeObject.getProjectTreeObject();
   				ConnectorEditor connectorEditor = projectTreeObject.getConnectorEditor(connector);
   				if (connectorEditor != null) {
   					getActivePage().activate(connectorEditor);
   					connectorEditor.getDocument(transaction.getName(), isStubRequested());
   				}
   			}
   		}
       }
       catch (Throwable e) {
       	ConvertigoPlugin.logException(e, "Unable to execute the selected transaction!");
       }
       finally {
		shell.setCursor(null);
		waitCursor.dispose();
       }
}
 
Example 5
Project: convertigo-eclipse   File: EnableListenerAction.java   View Source Code Vote up 5 votes
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) {
   			DatabaseObjectTreeObject treeObject = null;
   			Listener listener = null;
   			
   			TreeObject[] treeObjects = explorerView.getSelectedTreeObjects();
			for (int i = treeObjects.length-1 ; i>=0  ; i--) {
				treeObject = (DatabaseObjectTreeObject) treeObjects[i];
				if (treeObject instanceof ListenerTreeObject) {
					ListenerTreeObject listenerTreeObject = (ListenerTreeObject)treeObject;
					listener = (Listener)listenerTreeObject.getObject();
					listener.setEnabled(true);
					
					listenerTreeObject.setEnabled(true);
					listenerTreeObject.hasBeenModified(true);
					
	                // Updating the tree
	                explorerView.refreshTreeObject(listenerTreeObject);
				}
			}
   		}
       }
       catch (Throwable e) {
       	ConvertigoPlugin.logException(e, "Unable to enable listener!");
       }
       finally {
		shell.setCursor(null);
		waitCursor.dispose();
       }
}
 
Example 6
Project: convertigo-eclipse   File: DisableMobilePageComponentAction.java   View Source Code Vote up 5 votes
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) {
   			DatabaseObjectTreeObject treeObject = null;
   			PageComponent component = null;
   			
   			TreeObject[] treeObjects = explorerView.getSelectedTreeObjects();
			for (int i = treeObjects.length-1 ; i>=0  ; i--) {
				treeObject = (DatabaseObjectTreeObject) treeObjects[i];
				if (treeObject instanceof MobilePageComponentTreeObject) {
					MobilePageComponentTreeObject componentTreeObject = (MobilePageComponentTreeObject)treeObject;
					component = (PageComponent)componentTreeObject.getObject();
					component.setEnabled(false);
					
					componentTreeObject.setEnabled(false);
					componentTreeObject.hasBeenModified(true);
	                
	                TreeObjectEvent treeObjectEvent = new TreeObjectEvent(componentTreeObject, "isEnabled", true, false);
	                explorerView.fireTreeObjectPropertyChanged(treeObjectEvent);
				}
			}
			
			explorerView.refreshSelectedTreeObjects();
   		}
       }
       catch (Throwable e) {
       	ConvertigoPlugin.logException(e, "Unable to disable page!");
       }
       finally {
		shell.setCursor(null);
		waitCursor.dispose();
       }
}
 
Example 7
Project: Hydrograph   File: PaletteContainerListener.java   View Source Code Vote up 5 votes
/**
 * 
 * Show tooltip
 * 
 * @param toolTipMessage - text message to be display on tooltip
 */
private void showPaletteToolTip(String toolTipMessage) {
	paletteToolTip = new PaletteToolTip(Display.getDefault());
	java.awt.Point mouseLocation = MouseInfo.getPointerInfo().getLocation();
	paletteToolTip.setLocation(mouseLocation.x + 11 , mouseLocation.y +7);
	paletteToolTip.setToolTipText(toolTipMessage);
	paletteToolTip.setVisible(true);
}
 
Example 8
Project: convertigo-eclipse   File: CustomStatisticsAction.java   View Source Code Vote up 5 votes
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) {
   			ProjectTreeObject projectTreeObject = (ProjectTreeObject)explorerView.getFirstSelectedTreeObject();
   			if (projectTreeObject != null) {
   				StatisticsDialog stats = new StatisticsDialog(shell, 
   						projectTreeObject.getName(), projectTreeObject.getObject().getComment(), 
   						projectTreeObject.getObject().getVersion());
   			
   				stats.open();
   			}
   		}
       }
       catch (Throwable e) {
       	ConvertigoPlugin.logException(e, "Unable to compute statistics!");
       }
       finally {
		shell.setCursor(null);
		waitCursor.dispose();
       }
}
 
Example 9
Project: convertigo-eclipse   File: OpenProjectTestPlatformAction.java   View Source Code Vote up 5 votes
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 Project)) {
   				Project project = (Project)treeObject.getObject();
   				Program.launch(
   						EnginePropertiesManager.PropertyName.APPLICATION_SERVER_CONVERTIGO_URL.getDefaultValue()+"/projects/" + project.getName());
   			}
   		}
       	
       }
       catch (Throwable e) {
       	ConvertigoPlugin.logException(e, "Unable to open the selected project!");
       }
       finally {
		shell.setCursor(null);
		waitCursor.dispose();
       }
}
 
Example 10
Project: tap17-muggl-javaee   File: ExecutionWindow.java   View Source Code Vote up 5 votes
/**
 * 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.parentShell = parentShell;
		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.
		if (!parentShell.isDisposed())
			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.executionComposite != null) this.executionComposite.abortExecution();
		doExit();
	}
}
 
Example 11
Project: convertigo-eclipse   File: CreateDesignDocumentViewAction.java   View Source Code Vote up 5 votes
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) {
   			DesignDocumentTreeObject ddto = (DesignDocumentTreeObject)explorerView.getFirstSelectedTreeObject();
   			DesignDocumentViewTreeObject ddvto = ddto.addNewView();
   			if (ddto.hasChanged()) {
				TreeParent treeParent = ddto.getParent();
				if (treeParent instanceof FolderTreeObject)
					treeParent = treeParent.getParent();
				explorerView.objectChanged(new CompositeEvent(treeParent.getObject(),ddvto.getPath()));
   			}
   		}
       }
       catch (Throwable e) {
       	ConvertigoPlugin.logException(e, "Unable to create a new view!");
       }
       finally {
		shell.setCursor(null);
		waitCursor.dispose();
       }
}
 
Example 12
Project: convertigo-eclipse   File: DisableMobileRouteActionComponentAction.java   View Source Code Vote up 5 votes
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) {
   			DatabaseObjectTreeObject treeObject = null;
   			RouteActionComponent component = null;
   			
   			TreeObject[] treeObjects = explorerView.getSelectedTreeObjects();
			for (int i = treeObjects.length-1 ; i>=0  ; i--) {
				treeObject = (DatabaseObjectTreeObject) treeObjects[i];
				if (treeObject instanceof MobileRouteActionComponentTreeObject) {
					MobileRouteActionComponentTreeObject componentTreeObject = (MobileRouteActionComponentTreeObject)treeObject;
					component = (RouteActionComponent)componentTreeObject.getObject();
					component.setEnabled(false);
					
					componentTreeObject.setEnabled(false);
					componentTreeObject.hasBeenModified(true);
	                
	                TreeObjectEvent treeObjectEvent = new TreeObjectEvent(componentTreeObject, "isEnabled", true, false);
	                explorerView.fireTreeObjectPropertyChanged(treeObjectEvent);
				}
			}
			
			explorerView.refreshSelectedTreeObjects();
   		}
       }
       catch (Throwable e) {
       	ConvertigoPlugin.logException(e, "Unable to disable action!");
       }
       finally {
		shell.setCursor(null);
		waitCursor.dispose();
       }
}
 
Example 13
Project: convertigo-eclipse   File: DisableMobileRouteComponentAction.java   View Source Code Vote up 5 votes
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) {
   			DatabaseObjectTreeObject treeObject = null;
   			RouteComponent component = null;
   			
   			TreeObject[] treeObjects = explorerView.getSelectedTreeObjects();
			for (int i = treeObjects.length-1 ; i>=0  ; i--) {
				treeObject = (DatabaseObjectTreeObject) treeObjects[i];
				if (treeObject instanceof MobileRouteComponentTreeObject) {
					MobileRouteComponentTreeObject componentTreeObject = (MobileRouteComponentTreeObject)treeObject;
					component = (RouteComponent)componentTreeObject.getObject();
					component.setEnabled(false);
					
					componentTreeObject.setEnabled(false);
					componentTreeObject.hasBeenModified(true);
	                
	                TreeObjectEvent treeObjectEvent = new TreeObjectEvent(componentTreeObject, "isEnabled", true, false);
	                explorerView.fireTreeObjectPropertyChanged(treeObjectEvent);
				}
			}
			
			explorerView.refreshSelectedTreeObjects();
   		}
       }
       catch (Throwable e) {
       	ConvertigoPlugin.logException(e, "Unable to disable route!");
       }
       finally {
		shell.setCursor(null);
		waitCursor.dispose();
       }
}
 
Example 14
Project: convertigo-eclipse   File: LaunchMobileApplicationProjectAction.java   View Source Code Vote up 5 votes
@Override
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 MobileApplication)) {
   				MobileApplication mobileApplication = (MobileApplication) databaseObject;
   				
   				// Test plateform
   				Program.launch(
   						EnginePropertiesManager.PropertyName.APPLICATION_SERVER_CONVERTIGO_URL.getDefaultValue()+"/project.html#" 
   								+ mobileApplication.getProject() + "?launch=webapp");
   			}
   		}
       	
       }
       catch (Throwable e) {
       	ConvertigoPlugin.logException(e, "Unable to launch the mobile device selected project!");
       }
       finally {
		shell.setCursor(null);
		waitCursor.dispose();
       }
}
 
Example 15
Project: convertigo-eclipse   File: ChangeToIfXpathExistsStatementAction.java   View Source Code Vote up 4 votes
@Override
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) {
   			DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) explorerView.getFirstSelectedTreeObject();
   			DatabaseObject databaseObject = treeObject.getObject();
   			if ((databaseObject != null) && (databaseObject instanceof IfXpathExistsThenElseStatement)) {
   				IfXpathExistsThenElseStatement ifThenElseStatement = (IfXpathExistsThenElseStatement) databaseObject;
   				// IfXpathExistsThenElse statement
   				if (ifThenElseStatement.hasThenElseStatements()) {
					DatabaseObjectTreeObject parentTreeObject = treeObject.getOwnerDatabaseObjectTreeObject();
					
	        		if (parentTreeObject != null) {
   						// New IfXpathExistsStatement statement
	        			IfXpathExistsStatement ifStatement  = new IfXpathExistsStatement();
   						ifStatement.bNew = true;
   						ifStatement.hasChanged = true;
   						
   						// Add new If statement to parent
   						StatementWithExpressions parentDbo = (StatementWithExpressions) ifThenElseStatement.getParent();
   						parentDbo.addStatementAfter(ifStatement, ifThenElseStatement); 
   						
       					for (Statement statement: ifThenElseStatement.getThenStatement().getStatements()) {
       						ifStatement.addStatement(statement);
       					}
   						
   						// Set properties
   						ifStatement.setCondition(ifThenElseStatement.getCondition());
   						ifStatement.setComment(ifThenElseStatement.getComment());
   						ifStatement.setEnabled(ifThenElseStatement.isEnabled());
   						ifStatement.setVersion(ifThenElseStatement.getVersion());
   						
   						String name = ifThenElseStatement.getName();
   						
   		   				// Delete IfThenElse statement
   						ifThenElseStatement.delete();
   						
   						ifStatement.setName(name);
   						
	        			parentTreeObject.hasBeenModified(true);
		                explorerView.reloadTreeObject(parentTreeObject);
		                explorerView.setSelectedTreeObject(parentTreeObject.findTreeObjectByUserObject(ifStatement));
	        		}
   				}
   			}
   		}
       	
       }
       catch (Throwable e) {
       	ConvertigoPlugin.logException(e, "Unable to change statement to If statement!");
       }
       finally {
		shell.setCursor(null);
		waitCursor.dispose();
       }
}
 
Example 16
Project: pandionj   File: FrameView.java   View Source Code Vote up 4 votes
void copyToClipBoard() {
	Composite item = viewer;
	Point p = viewer.computeSize(SWT.DEFAULT, SWT.DEFAULT);

	Rectangle size = item.getClientArea();

	System.out.println(p +  "    " + size);
	//			compositeViewer.setBackground(Constants.HIGHLIGHT_COLOR);
	GC gc = new GC(item);
	//			Rectangle clipping2 = gc.getClipping();
	//			Image img = new Image(Display.getDefault(), size.width, size.height);
	//			gc.copyArea(img, 0, 0);
	//			ImageData imageData = img.getImageData();

	RGB[] rgb = new RGB[256];
	// build grey scale palette: 256 different grey values are generated. 
	for (int i = 0; i < 256; i++) {
		rgb[i] = new RGB(i, i, i);
	}

	// Construct a new indexed palette given an array of RGB values.
	PaletteData palette = new PaletteData(rgb);
	Image img2 = new Image(Display.getDefault(), new ImageData(size.width, size.height, 8, palette));
	//			gc.setClipping(0, 0, p.x, p.y);
	gc.copyArea(img2, 0, 0);
	Shell popup = new Shell(Display.getDefault());
	popup.setText("Image");
	popup.setBounds(50, 50, 200, 200);
	Canvas canvas = new Canvas(popup, SWT.NONE);
	canvas.setBounds(img2.getBounds());
	canvas.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent e) {
			e.gc.drawImage(img2, 0, 0);
		}
	});
	popup.open();
	Clipboard clipboard = new Clipboard(Display.getDefault());
	clipboard.setContents(new Object[]{img2.getImageData()}, new Transfer[]{ ImageTransfer.getInstance()}); 
	img2.dispose();
	gc.dispose();
}
 
Example 17
Project: convertigo-eclipse   File: SequenceImportFromXsdAction.java   View Source Code Vote up 4 votes
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) {
   			DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject)explorerView.getFirstSelectedTreeObject();
   			DatabaseObject databaseObject = databaseObjectTreeObject.getObject();
   			SequenceTreeObject sequenceTreeObject = (SequenceTreeObject) ((databaseObject instanceof Sequence) ? databaseObjectTreeObject:databaseObjectTreeObject.getParentDatabaseObjectTreeObject());
   			Sequence sequence = (databaseObject instanceof Sequence) ? (Sequence)databaseObject:((StepWithExpressions)databaseObject).getSequence();
   			
           	FileDialog fileDialog = new FileDialog(shell, SWT.PRIMARY_MODAL | SWT.SAVE);
           	fileDialog.setText("Import schema file");
           	fileDialog.setFilterExtensions(new String[]{"*.xsd"});
           	fileDialog.setFilterNames(new String[]{"Schema files"});
           	fileDialog.setFilterPath(Engine.PROJECTS_PATH);
           	
           	String filePath = fileDialog.open();
           	if (filePath != null) {
           		filePath = filePath.replaceAll("\\\\", "/");
           		
           		XmlSchemaCollection collection = new XmlSchemaCollection();
           		collection.setBaseUri(filePath);
           		XmlSchema xmlSchema = SchemaUtils.loadSchema(new File(filePath), collection);
           		SchemaMeta.setCollection(xmlSchema, collection);
           		
           		SchemaObjectsDialog dlg = new SchemaObjectsDialog(shell, sequence, xmlSchema);
				if (dlg.open() == Window.OK) {
					if (dlg.result instanceof Throwable) {
						throw (Throwable)dlg.result;
					}
					else {
						Step step = (Step)dlg.result;
						if (step != null) {
							if (databaseObject instanceof Sequence) {
								sequence.addStep(step);
								sequence.hasChanged = true;
							}
							else {
								StepWithExpressions swe = (StepWithExpressions)databaseObject;
								swe.addStep(step);
								swe.hasChanged = true;
							}
							
							sequence.hasChanged = true;
							
							// Reload sequence in tree without updating its schema for faster reload
							ConvertigoPlugin.logDebug("Reload sequence: start");
							explorerView.reloadTreeObject(sequenceTreeObject);
							ConvertigoPlugin.logDebug("Reload sequence: end");
							
							// Select target dbo in tree
							explorerView.objectSelected(new CompositeEvent(databaseObject));
						}
					}
	        	}
           	}
   		}
       }
       catch (Throwable e) {
       	ConvertigoPlugin.logException(e, "Unable to import step from xsd!");
       }
       finally {
		shell.setCursor(null);
		waitCursor.dispose();
       }
}
 
Example 18
Project: convertigo-eclipse   File: EnableExtractionRuleAction.java   View Source Code Vote up 4 votes
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) {
   			DatabaseObjectTreeObject treeObject = null;
   			ExtractionRule extractionRule = null;
   			
   			TreeObject[] treeObjects = explorerView.getSelectedTreeObjects();
   			
   			Set<TreeObject> parents = new HashSet<TreeObject>();
   			
			for (int i = treeObjects.length-1 ; i>=0  ; i--) {
				treeObject = (DatabaseObjectTreeObject) treeObjects[i];
				if (treeObject instanceof ExtractionRuleTreeObject) {
					ExtractionRuleTreeObject extractionRuleTreeObject = (ExtractionRuleTreeObject)treeObject;
					extractionRule = (ExtractionRule)extractionRuleTreeObject.getObject();
	    			extractionRule.setEnabled(true);
	    			
	    			extractionRuleTreeObject.setEnabled(true);
	    			extractionRuleTreeObject.hasBeenModified(true);
	    			
	    			parents.add(extractionRuleTreeObject.getParentDatabaseObjectTreeObject());
				}
			}
			// Updating the tree
			for (TreeObject parent : parents) {
				explorerView.refreshTreeObject(parent,true);
			}
   		}
       }
       catch (Throwable e) {
       	ConvertigoPlugin.logException(e, "Unable to enable extraction rule!");
       }
       finally {
		shell.setCursor(null);
		waitCursor.dispose();
       }
}
 
Example 19
Project: com.onpositive.prefeditor   File: PreferenceView.java   View Source Code Vote up 4 votes
protected void textToClipboard(String text) {
	Clipboard clipboard = new Clipboard(Display.getDefault());
	TextTransfer textTransfer = TextTransfer.getInstance();
	clipboard.setContents(new String[]{text}, new Transfer[]{textTransfer});
	clipboard.dispose();
}
 
Example 20
Project: convertigo-eclipse   File: DatabaseObjectIncreasePriorityAction.java   View Source Code Vote up 4 votes
public void run() {
	Display display = Display.getDefault();
	Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);		
	
	Shell shell = getParentShell();
	shell.setCursor(waitCursor);
	
       try {
       	treeNodesToUpdate = new ArrayList<TreeParent>();
       	
   		ProjectExplorerView explorerView = getProjectExplorerView();
   		if (explorerView != null) {
   			TreeObject[] treeObjects = explorerView.getSelectedTreeObjects();
   			String[] selectedPaths = new String[treeObjects.length];
   			if (treeObjects != null) {
   				// Increase priority
   				TreeObject treeObject = null;
   				for (int i = 0 ; i < treeObjects.length ; i++) {
   					treeObject = treeObjects[i];
   					selectedPaths[i] = treeObject.getPath();
  						increasePriority(treeObject);
   				}
   				
   				// Updating the tree and the properties panel
   				Enumeration<TreeParent> enumeration = Collections.enumeration(treeNodesToUpdate);
   				TreeParent parentTreeObject = null;
   				while (enumeration.hasMoreElements()) {
   					parentTreeObject = enumeration.nextElement();
   					explorerView.reloadTreeObject(parentTreeObject);
   				}
   				
   				// Restore selection
   	    		TreeObjectEvent treeObjectEvent;
   	        	for (int i=0; i<selectedPaths.length; i++) {
   	        		String previousPath = selectedPaths[i];
   	        		treeObject = explorerView.findTreeObjectByPath(parentTreeObject, previousPath);
   	        		if (treeObject != null) {
   	        			treeObjects[i] = treeObject;
   		                treeObjectEvent = new TreeObjectEvent(treeObject);
   		                explorerView.fireTreeObjectPropertyChanged(treeObjectEvent);
   	        		}
   	        	}
   				explorerView.setSelectedTreeObjects(treeObjects);
   			}
   		}
       }
       catch (Throwable e) {
       	ConvertigoPlugin.logException(e, "Unable to increase priority!");
       }
       finally {
		shell.setCursor(null);
		waitCursor.dispose();
       }
}