1 20 package org.apache.directory.ldapstudio.schemas.view; 21 22 23 import org.eclipse.swt.SWT; 24 import org.eclipse.swt.graphics.Color; 25 import org.eclipse.swt.widgets.MessageBox; 26 import org.eclipse.ui.PlatformUI; 27 28 29 35 public class ViewUtils 36 { 37 38 public static final Color COLOR_BLACK = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() 39 .getDisplay().getSystemColor( SWT.COLOR_BLACK ); 40 41 42 public static final Color COLOR_RED = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay() 43 .getSystemColor( SWT.COLOR_RED ); 44 45 46 54 public static String concateAliases( String [] aliases ) 55 { 56 StringBuffer sb = new StringBuffer (); 57 if ( aliases.length > 0 ) 58 { 59 sb.append( aliases[0] ); 60 for ( int i = 1; i < aliases.length; i++ ) 61 { 62 sb.append( ", " ); sb.append( aliases[i] ); 64 } 65 } 66 67 return sb.toString(); 68 } 69 70 71 80 public static boolean verifyName( String name ) 81 { 82 return name.matches( "[a-zA-Z]+[a-zA-Z0-9;-]*" ); } 84 85 86 97 public static int displayErrorMessageBox( String title, String message ) 98 { 99 return displayMessageBox( SWT.OK | SWT.ICON_ERROR, title, message ); 100 } 101 102 103 114 public static int displayWarningMessageBox( String title, String message ) 115 { 116 return displayMessageBox( SWT.OK | SWT.ICON_WARNING, title, message ); 117 } 118 119 120 131 public static int displayInformationMessageBox( String title, String message ) 132 { 133 return displayMessageBox( SWT.OK | SWT.ICON_INFORMATION, title, message ); 134 } 135 136 137 150 public static int displayQuestionMessageBox( int buttonStyle, String title, String message ) 151 { 152 return displayMessageBox( SWT.ICON_QUESTION | buttonStyle, title, message ); 153 } 154 155 156 169 private static int displayMessageBox( int style, String title, String message ) 170 { 171 MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), style ); 172 messageBox.setText( title ); 173 messageBox.setMessage( message ); 174 return messageBox.open(); 175 } 176 177 } 178 | Popular Tags |