List of usage examples for org.eclipse.jface.dialogs IMessageProvider NONE
int NONE
To view the source code for org.eclipse.jface.dialogs IMessageProvider NONE.
Click Source Link
From source file:com.observability.monitoring.server.ModelHandler.java
License:Open Source License
/** * Get the descriptor files from the central server and store them in the * project directory.// w w w .j ava2s .com * @param dirPath the absolute path of the project root * @throws Exception generic exception to catch any error */ public void getDescriptorFiles(Path dirPath) throws Exception { if (dirPath == null) { throw new NullPointerException(Messages.ModelHandler_MSG_ERROR_INVALID_DIRECTORY); } // get the ip and port where the model handler service is running. String[] ipPort = uiInstance.getServerDetails(IMessageProvider.NONE, ""); if (ipPort.length == 0) { return; } else { ip = ipPort[0]; port = ipPort[1]; } // connect to the RMI connectRMI(ip, port); // create descriptor directory path in the project Path descDirPath = dirPath.resolve(EclipseResourceDelegate.PROBE_DESCRIPTOR_DIR_PATH); // create descriptor directory if (!IModelHandlerServer.FileOperationHelper.createDirectory(descDirPath.toString())) { // Unable to create directory. Abort throw new RuntimeException(Messages.ModelHandler_MSG_ERROR_NO_PERMISSIONS); } ; // create descriptor file File descFile = descDirPath.resolve(DESCRIPTOR_FILE_NAME).toFile(); // get the details of the descriptor file from the server int nrOfBlocks = svr.getDescFileNrOfBlocks(); // get MD5 hash of the descriptor file from the server String serverMd5 = svr.getDescFileMd5(); // Get the file from the server in blocks FileOutputStream fOut = null; try { for (int i = 1; i <= nrOfBlocks; i++) { byte[] bytes; bytes = svr.getDescriptorFiles(i); if (bytes.length > 0) { fOut = new FileOutputStream(descFile, true); fOut.write(bytes); fOut.close(); } } } catch (IOException e) { if (fOut != null) { fOut.close(); } throw e; } // get the MD5 of the received file and compare it with the MD5 received from server String actualMd5 = IModelHandlerServer.FileOperationHelper.getFileMD5(descFile.toString()); if (!serverMd5.equals(actualMd5)) { // MD5 do not match. Abort IModelHandlerServer.FileOperationHelper.deleteFile(descFile); throw new RuntimeException(Messages.ModelHandler_MSG_ERROR_GET_DESCRIPTOR); } // unzip the file and delete the zip. int result = IModelHandlerServer.FileOperationHelper.unzipFile(descFile.toString(), descDirPath.toString()); if (result <= 0) { // Error in unzipping. Abort IModelHandlerServer.FileOperationHelper.deleteFile(descFile); throw new RuntimeException(Messages.ModelHandler_MSG_ERROR_DESCRIPTOR_UNZIP); } ; // If the code reaches here, success. Delete the zip IModelHandlerServer.FileOperationHelper.deleteFile(descFile); }
From source file:com.observability.monitoring.server.ModelHandler.java
License:Open Source License
/** * Deploy the generated file to the server * @param target the absolute path of the file which is to be transferred * @param fileName the name of the file, without the extension. * @return integer containing the number of files deployed by the server * @throws Exception generic exception to catch any error. *//* ww w.j a v a2 s . c o m*/ public int deployFile(String target, String fileName) throws Exception { if (ip == null || port == null) { // get the ip and port where the model handler service is running. String[] ipPort = uiInstance.getServerDetails(IMessageProvider.NONE, ""); if (ipPort.length == 0) { return -1; } else { ip = ipPort[0]; port = ipPort[1]; } } // connect to the Model Handler connectRMI(ip, port); // get the md5 hash of the file String md5 = IModelHandlerServer.FileOperationHelper.getFileMD5(target); if (svr.beginFileUpload(fileName)) { // start uploading the files in blocks of maxBlockSize byte File file = new File(target); long size = file.length(); int noOfBlocks = 1; if (size > MAX_BLOCK_SIZE) { noOfBlocks = (int) Math.ceil((double) size / MAX_BLOCK_SIZE); } int skipBytes = 0; int bufferSize = MAX_BLOCK_SIZE; FileInputStream fIn = null; try { for (int i = 1; i <= noOfBlocks; i++) { // skip blocksize bytes if more than one block is to be sent if (i != 1) { skipBytes += MAX_BLOCK_SIZE; } // if it is the last block, get the size of the block if (i == noOfBlocks) { // bufferSize should decrease if the last block is less than maxBlockSize bufferSize = (int) (size % MAX_BLOCK_SIZE); bufferSize = bufferSize != 0 ? bufferSize : MAX_BLOCK_SIZE; } fIn = new FileInputStream(target); fIn.skip(skipBytes); byte[] bytes = new byte[bufferSize]; fIn.read(bytes); // No more bytes to read. Write file to the server svr.uploadFileChunk(bytes); fIn.close(); } } catch (IOException e) { fIn.close(); throw e; } // End the upload process. int uploadStatus = svr.endFileUpload(md5); if (uploadStatus < 0) { throw new RuntimeException(Messages.ModelHandler_MSG_ERROR_UPLOAD); } } else { throw new RuntimeException(Messages.ModelHandler_MSG_ERROR_UPLOAD_NOT_STARTED); } return 0; }
From source file:com.opera.widgets.ui.editor.validation.AbstractControlValidation.java
License:Open Source License
public static int getMessageType(IStatus status) { int severity = status.getSeverity(); if (severity == IStatus.OK) { return IMessageProvider.NONE; } else if (severity == IStatus.ERROR) { return IMessageProvider.ERROR; } else if (severity == IStatus.WARNING) { return IMessageProvider.WARNING; } else if (severity == IStatus.INFO) { return IMessageProvider.INFORMATION; }// w ww .ja va 2 s.c o m return IMessageProvider.NONE; }
From source file:com.rcpcompany.uibindings.bindingMessages.ValidationLabelDecorator.java
License:Open Source License
/** * Returns the max severity for the specified element. * <p>/*from www . j a v a 2s .c o m*/ * Includes the severity of any popagated severity * * @param element the element to test * @return the severity */ public int getElementSeverity(Object element) { final Integer severity = myObjectSeverities.get(element); if (severity == null) return IMessageProvider.NONE; return severity; }
From source file:com.rcpcompany.uibindings.bindingMessages.ValidationLabelDecorator.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { final Integer severity = myObjectSeverities.get(element); if (severity == null) return;//from w w w . j ava2 s . com if (Activator.getDefault() != null && Activator.getDefault().TRACE_LABEL_DECORATOR) { LogUtils.debug(this, hashCode() + ": " + element + ": severity: " + severity); //$NON-NLS-1$ //$NON-NLS-2$ } switch (severity) { case IMessageProvider.NONE: break; case IMessageProvider.INFORMATION: break; case IMessageProvider.WARNING: decoration.addOverlay(WARNING_IMAGE); break; case IMessageProvider.ERROR: decoration.addOverlay(ERROR_IMAGE); break; default: break; } }
From source file:com.rcpcompany.uibindings.bindingMessages.ValidationLabelDecorator.java
License:Open Source License
/** * Calculates the severities for all the affected objects covered by this decorator. *//*from w w w . ja va2 s.c o m*/ protected void calculateSeverities() { // Calculate the new severities for all objects with a message final Map<Object, Integer> newSeverities = new HashMap<Object, Integer>(); for (final EObject o : myValidatorManager.getCurrentObjects()) { final int severity = myValidatorManager.getObjectSeverity(o); if (severity == IMessageProvider.NONE) { continue; } updateSeverity(newSeverities, o, severity); } // Update myObjectSeverities and changedObjects final Set<Object> changedObjects = new HashSet<Object>(); final Set<Object> deletedObjects = new HashSet<Object>(); for (final Map.Entry<Object, Integer> e : newSeverities.entrySet()) { final Object o = e.getKey(); if (BasicUtils.equals(myObjectSeverities.get(o), e.getValue())) { continue; } if (Activator.getDefault().TRACE_LABEL_DECORATOR) { LogUtils.debug(this, hashCode() + ": " + o + ": NEW severity: " + e.getValue()); //$NON-NLS-1$ //$NON-NLS-2$ } myObjectSeverities.put(o, e.getValue()); changedObjects.add(o); } for (final Map.Entry<Object, Integer> e : myObjectSeverities.entrySet()) { final Object o = e.getKey(); if (newSeverities.get(o) != null) { continue; } deletedObjects.add(o); changedObjects.add(o); } for (final Object o : deletedObjects) { myObjectSeverities.remove(o); } if (changedObjects.size() == 0) return; final Object[] array = changedObjects.toArray(); final LabelProviderChangedEvent event = new LabelProviderChangedEvent(ValidationLabelDecorator.this, array); if (Activator.getDefault().TRACE_LABEL_DECORATOR) { LogUtils.debug(this, hashCode() + ": " + Arrays.toString(array)); //$NON-NLS-1$ } for (final ILabelProviderListener l : myListeners) { try { l.labelProviderChanged(event); } catch (final Exception ex) { LogUtils.error(l, ex); } } }
From source file:com.rcpcompany.uibindings.bindingMessages.ValidationLabelDecorator.java
License:Open Source License
/** * Updates the specified map with the specified severity for the specified object if the new * severity is more grave than any old severity stored for the same object. * <p>//w ww . ja v a 2 s. c om * If the map is updated and a propagation adapter is defined, the parent object is also * updated. * * @param map the map with severities * @param o the object to update * @param severity the new severity */ private void updateSeverity(Map<Object, Integer> map, Object o, int severity) { final Integer oldSeverity = map.get(o); if (oldSeverity != null && oldSeverity >= severity) return; if (oldSeverity == null) { int oSeverity = IMessageProvider.NONE; if (o instanceof EObject) { oSeverity = myValidatorManager.getObjectSeverity((EObject) o); } if (severity < oSeverity) { severity = oSeverity; } } if (Activator.getDefault().TRACE_LABEL_DECORATOR) { LogUtils.debug(this, hashCode() + ": update " + severity + ": " + o); //$NON-NLS-1$ //$NON-NLS-2$ } map.put(o, SEVERITY_OBJECTS[severity]); if (myPropagationAdapter == null) return; final Object parent = myPropagationAdapter.getParent(o); if (parent != null) { updateSeverity(map, parent, severity); } }
From source file:com.rcpcompany.uibindings.contextAdapters.ScrolledFormContextMessageDecoratorAdapter.java
License:Open Source License
@Override public void update(List<IBindingMessage> messages, boolean inError, int maxType) { // LogUtils.debug(this, "\n" + messages + "\nerror: " + inError + " type: " + maxType); if (myForm.getForm().getHead().isDisposed()) return;//from w ww. j av a 2s .com if (myForm.getForm().getHead().getBounds().height == 0 || messages.isEmpty()) { myForm.setMessage(null, IMessageProvider.NONE); return; } myCurrentMessages = messages; String messageText = null; if (myCurrentMessages.size() == 1) { // a single message final IBindingMessage message = messages.get(0); messageText = AbstractBindingMessage.getFullMessage(message); myForm.setMessage(messageText, maxType); } else { // show a summary message for the message and list of errors for the details messageText = NLS.bind(MULTIPLE_MESSAGE_SUMMARY_KEYS[maxType], new String[] { messages.size() + "" }); //$NON-NLS-1$ myForm.setMessage(messageText, maxType); } }
From source file:com.rcpcompany.uibindings.contextAdapters.TitleAreaDialogContextMessageDecoratorAdapter.java
License:Open Source License
@Override public void update(List<IBindingMessage> messages, boolean inError, int maxType) { if (maxType == IMessageProvider.NONE) { myDialog.setMessage(null, IMessageProvider.NONE); } else if (messages.size() == 1) { final String m = AbstractBindingMessage.getFullMessage(messages.get(0)); myDialog.setMessage(m, maxType); } else {/*from w w w . j av a2 s .c om*/ final String m = messages.size() + " messages"; // TODO NLS myDialog.setMessage(m, maxType); } /* * We assume that the button bar is a standard bar as created by Dialog.createButtonBar... * * See Dialog.createButton(...) */ if (myOKButton == null) { if (myDialog.buttonBar instanceof Composite) { final Composite buttonBarComposite = (Composite) myDialog.buttonBar; for (final Control c : buttonBarComposite.getChildren()) { if (!(c instanceof Button)) { continue; } final Button b = (Button) c; final Object data = b.getData(); if (!(data instanceof Integer)) { continue; } final Integer i = (Integer) data; if (i.intValue() == IDialogConstants.OK_ID) { myOKButton = b; break; } } } } if (myOKButton != null) { myOKButton.setEnabled(!inError); } }
From source file:com.rcpcompany.uibindings.contextAdapters.WizardPageContextMessageDecoratorAdapter.java
License:Open Source License
@Override public void update(List<IBindingMessage> messages, boolean inError, int maxType) { if (maxType == IMessageProvider.NONE) { myPage.setMessage(null, IMessageProvider.NONE); } else if (messages.size() == 1) { final String m = AbstractBindingMessage.getFullMessage(messages.get(0)); myPage.setMessage(m, maxType);//from www . j a v a 2 s. c o m } else { final String m = messages.size() + " messages"; // TODO NLS myPage.setMessage(m, maxType); } myPage.setPageComplete(!inError); }