Java Code Examples for org.eclipse.jface.dialogs.MessageDialog#openWarning()

The following examples show how to use org.eclipse.jface.dialogs.MessageDialog#openWarning() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShowPreviousFuzzyHandler.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
		return null;
	}
	XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
	int[] selectedRows = xliffEditor.getSelectedRows();
	if (selectedRows.length < 1) {
		return null;
	}
	Arrays.sort(selectedRows);
	int firstSelectedRow = selectedRows[0];
	XLFHandler handler = xliffEditor.getXLFHandler();

	int row = handler.getPreviousFuzzySegmentIndex(firstSelectedRow);
	if (row != -1) {
		xliffEditor.jumpToRow(row);
	} else {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		MessageDialog.openWarning(window.getShell(), "", "不存在上一模糊匹配文本段。");
	}

	return null;
}
 
Example 2
Source File: N4JSGracefulActivator.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Opens a message dialog showing the status with given title. If you do not have a title, just call
 * {@link #statusDialog(IStatus)}.
 */
public static void statusDialog(String title, IStatus status) {
	Shell shell = getActiveWorkbenchShell();
	if (shell != null) {
		switch (status.getSeverity()) {
		case IStatus.ERROR:
			ErrorDialog.openError(shell, title, null, status);
			break;
		case IStatus.WARNING:
			MessageDialog.openWarning(shell, title, status.getMessage());
			break;
		case IStatus.INFO:
			MessageDialog.openInformation(shell, title, status.getMessage());
			break;
		}
	}
}
 
Example 3
Source File: DataSetParametersPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void handleLinkedMultipleValuesReportParam( OdaDataSetParameter dsParam )
{
	if ( dsParam.getParamName( ) == null )
		return;
	ScalarParameterHandle paramHandle = ParameterPageUtil.getScalarParameter( dsParam.getParamName( ),
			true );
	if ( paramHandle != null )
	{
		if ( DesignChoiceConstants.SCALAR_PARAM_TYPE_MULTI_VALUE.equals( paramHandle.getParamType( ) ) )
		{
			MessageDialog.openWarning( Workbench.getInstance( )
					.getDisplay( )
					.getActiveShell( ),
					Messages.getString( "DataSetParameterPage.warningLinkedMultipleValuesParams.title" ),
					getWarning( dsParam ) );

		}
	}

}
 
Example 4
Source File: ShowNextUnapprovedHandler.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
		return null;
	}
	XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
	int[] selectedRows = xliffEditor.getSelectedRows();
	if (selectedRows.length < 1) {
		return null;
	}
	Arrays.sort(selectedRows);
	int lastSelectedRow = selectedRows[selectedRows.length - 1];
	XLFHandler handler = xliffEditor.getXLFHandler();

	int row = handler.getNextUnapprovedSegmentIndex(lastSelectedRow);
	if (row != -1) {
		xliffEditor.jumpToRow(row);
	} else {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		MessageDialog.openWarning(window.getShell(), "", "不存在下一个未批准文本段。");
	}

	return null;
}
 
Example 5
Source File: QAPage.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 当选中 缩短按钮时,进行的提示信息
 * @param isNumericRegex
 */
private boolean validMinValue(String isNumericRegex){
	if (minBtn.getSelection()) {
		String minNumer = minTxt.getText();
		if ("".equals(minNumer)) {
			minTxt.setFocus();
			minBtn.setSelection(false);
			MessageDialog.openWarning(getShell(),
					Messages.getString("dialog.TargetLengthSettingDialog.msgTitle"),
					Messages.getString("preference.QAPage.msg1"));
			return false;
		} else if (!minNumer.matches(isNumericRegex)) {
			minTxt.setFocus();
			minBtn.setSelection(false);
			MessageDialog.openWarning(getShell(),
					Messages.getString("dialog.TargetLengthSettingDialog.msgTitle"),
					Messages.getString("preference.QAPage.msg2"));
			return false;
		}
	}
	return true;
}
 
Example 6
Source File: DefaultImportStatusDialogHandler.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public int open(final Shell parentShell) {
    if (importStatus.getSeverity() == IStatus.WARNING
            && (importStatus.getChildren() == null || importStatus.getChildren().length == 0)) {
        MessageDialog.openWarning(parentShell, org.bonitasoft.studio.importer.i18n.Messages.importResultTitle,
                importStatus.getMessage());
        return IDialogConstants.CLOSE_ID;
    } else {
        switch (importStatus.getSeverity()) {
            case IStatus.OK:
                return openImportStatus(parentShell, customSuccessMessage.orElse(org.bonitasoft.studio.importer.i18n.Messages.importSucessfulMessage));
            case IStatus.INFO:
                return openImportStatus(parentShell, customSuccessMessage
                        .orElse(org.bonitasoft.studio.importer.i18n.Messages.importSucessfulMessage));
            default:
                return openImportStatus(parentShell,
                        customErrorMessage.orElse(org.bonitasoft.studio.importer.i18n.Messages.importStatusMsg));
        }
    }
}
 
Example 7
Source File: ShowPreviousUntranslatableHandler.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
		return null;
	}
	XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
	int[] selectedRows = xliffEditor.getSelectedRows();
	if (selectedRows.length < 1) {
		return null;
	}
	Arrays.sort(selectedRows);
	int firstSelectedRow = selectedRows[0];
	XLFHandler handler = xliffEditor.getXLFHandler();

	int row = handler.getPreviousUntranslatableSegmentIndex(firstSelectedRow);
	if (row != -1) {
		xliffEditor.jumpToRow(row);
	} else {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		MessageDialog.openWarning(window.getShell(), "", "不存在上一不可翻译文本段。");
	}

	return null;
}
 
Example 8
Source File: SQBDataSetWizardPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private static boolean openInvalidInputMessageBox( Shell parentShell, boolean askUser )
{
    String userMessage = Messages.sqbWizPage_invalidSqbStateMsg;
    if( askUser )
    {
        userMessage += NEWLINE_CHAR
                        + Messages.sqbWizPage_inputFailOnOpenAskUserMessage;
        return MessageDialog.openQuestion( parentShell,
                    Messages.sqbWizPage_invalidSqbStateTitle, userMessage );
    }
    
    // not an user option, raise warning and continue
    MessageDialog.openWarning( parentShell,
                    Messages.sqbWizPage_invalidSqbStateTitle, userMessage );
    return true; // continue
}
 
Example 9
Source File: BestellView.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Find the default supplier. Shows a warning if supplier is null or inexisting
 * 
 * @param cfgSupplier
 *            value delivered from the plugins configured supplier field
 * @param selDialogTitle
 *            title of the dialog
 * @return the supplier or null if none could be resolved.
 */
public static Kontakt resolveDefaultSupplier(String cfgSupplier, String selDialogTitle){
	Kontakt supplier = null;
	if (cfgSupplier != null && !cfgSupplier.isEmpty()) {
		supplier = Kontakt.load(cfgSupplier);
	}
	
	//warn that there is no supplier
	if (supplier == null || !supplier.exists()) {
		MessageDialog.openWarning(UiDesk.getTopShell(), selDialogTitle,
			Messages.BestellView_CantOrderNoSupplier);
	}
	return supplier;
}
 
Example 10
Source File: CreateESBAction.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
@Override
public void run(IIntroSite site, Properties params) {
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    if (factory.isUserReadOnlyOnCurrentProject()) {
        MessageDialog.openWarning(null, "User Authority", "Can't create Service! Current user is read-only on this project!");
    } else {
        PlatformUI.getWorkbench().getIntroManager().closeIntro(PlatformUI.getWorkbench().getIntroManager().getIntro());
        selectRootObject(params);
        doRun();
    }
}
 
Example 11
Source File: LocalWSDLEditor.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
@Override
public void doSave(IProgressMonitor monitor) {
    if (isEditorInputReadOnly()) {
        MessageDialog.openWarning(getSite().getShell(), Messages.WSDLFileIsReadOnly_Title,
                Messages.WSDLFileIsReadOnly_Message);
        return;
    }
    super.doSave(monitor);
    if (null != serviceItem && null != repositoryNode) {
        // save();

        try {
            String name = "Save Service"; //$NON-NLS-1$
            RepositoryWorkUnit<Object> repositoryWorkUnit = new RepositoryWorkUnit<Object>(name, this) {

                @Override
                protected void run() throws LoginException, PersistenceException {
                    save();
                }
            };
            repositoryWorkUnit.setAvoidSvnUpdate(true);
            repositoryWorkUnit.setAvoidUnloadResources(true);
            ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(repositoryWorkUnit);
            repositoryWorkUnit.throwPersistenceExceptionIfAny();
        } catch (Exception e) {
            e.printStackTrace();
            ExceptionHandler.process(e);
        }
    }
}
 
Example 12
Source File: ServerPreferencePage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void updatePortConfiguration(final Integer newPort) {
    if (SocketUtil.isPortInUse(newPort)) {
        MessageDialog.openWarning(getShell(), Messages.portAlreadyUseTitle,
                Messages.bind(Messages.portAlreadyUseMsg, newPort));
        return;
    }
    getPreferenceStore().setValue(BonitaPreferenceConstants.CONSOLE_PORT, newPort);
    restartServer();
}
 
Example 13
Source File: LoadXmlAction.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void run(final IAction action) {
    if (!(selection instanceof IStructuredSelection) || selection.isEmpty()) {
        return;
    }
    IStructuredSelection structuredSelection = (IStructuredSelection) selection;

    IProject project = getProject(structuredSelection);
    if (project == null) {
        return;
    }

    // Get the file name from a file dialog
    FileDialog dialog = createFileDialog(project);
    boolean validFileName = false;
    do {
        String fileName = openFileDialog(dialog);
        if (fileName == null) {
            // user cancel
            return;
        }
        validFileName = validateSelectedFileName(fileName);
        if (!validFileName) {
            MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Warning", fileName
                    + " is not a file or is not readable!");
            continue;
        }
        getDialogSettings().put(LOAD_XML_PATH_KEY, fileName);
        work(project, fileName);
    } while (!validFileName);
}
 
Example 14
Source File: DFSPath.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
/**
 * Does a recursive delete of the remote directory tree at this node.
 */
public void delete() {
  try {
    getDFS().delete(this.path, true);

  } catch (IOException e) {
    e.printStackTrace();
    MessageDialog.openWarning(null, "Delete file",
        "Unable to delete file \"" + this.path + "\"\n" + e);
  }
}
 
Example 15
Source File: MergeNextHandler.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
		IEditorPart editor = HandlerUtil.getActiveEditor(event);
		if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
			return null;
		}
		XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
		List<String> selectedRowIds = xliffEditor.getSelectedRowIds();
		if (selectedRowIds.size() < 1) {
			return null;
		}
		String rowId = selectedRowIds.get(selectedRowIds.size() - 1);
		XLFHandler handler = xliffEditor.getXLFHandler();

		int rowIndex = handler.getRowIndex(rowId);

		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		if (rowIndex == handler.countEditableTransUnit() - 1) { // 是最后一行
			MessageDialog.openWarning(window.getShell(), "", "不存在下一文本段,不能合并。");
			return null;
		}
		String rowId2 = handler.getRowId(rowIndex + 1);
		if (handler.isApproved(rowId) || handler.isApproved(rowId2)) {
			MessageDialog.openWarning(window.getShell(), "", "已批准文本段,不能合并。");
			return null;
		}

		String fileName1 = RowIdUtil.getFileNameByRowId(rowId);
		String fileName2 = RowIdUtil.getFileNameByRowId(rowId2);
		if (fileName1 == null || fileName2 == null || !fileName1.equals(fileName2)) {
			MessageDialog.openWarning(window.getShell(), "", "文本段不在同一个文件内,不能合并。");
			return null;
		}

//		IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
//		try {
//			operationHistory.execute(new MergeSegmentOperation("Merge Segment", xliffEditor, handler,
//					rowIndex), null, null);
//		} catch (ExecutionException e) {
//			e.printStackTrace();
//		}

		return null;
	}
 
Example 16
Source File: StandardDialogs.java    From jbt with Apache License 2.0 4 votes vote down vote up
public static void warningDialog(String title, String warningMessage) {
	MessageDialog.openWarning(null, title, warningMessage);
}
 
Example 17
Source File: OpenEngineLogCommand.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected void showWarningMessage(final File localFile) {
    MessageDialog.openWarning(Display.getDefault().getActiveShell(), Messages.failedToOpenLogTitle,
            Messages.bind(Messages.failedToOpenLogMessage, localFile.getAbsolutePath(),
                    org.bonitasoft.studio.common.Messages.bonitaStudioModuleName));
}
 
Example 18
Source File: MergePreviousHandler.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
		IEditorPart editor = HandlerUtil.getActiveEditor(event);
		if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
			return null;
		}
		XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
		List<String> selectedRowIds = xliffEditor.getSelectedRowIds();
		if (selectedRowIds.size() < 1) {
			return null;
		}
		String rowId = selectedRowIds.get(0);
		XLFHandler handler = xliffEditor.getXLFHandler();

		int rowIndex = handler.getRowIndex(rowId);

		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		if (rowIndex == 0) { // 是第一行
			MessageDialog.openWarning(window.getShell(), "", "不存在上一文本段,不能合并。");
			return null;
		}
		String rowId2 = handler.getRowId(rowIndex - 1);
		if (handler.isApproved(rowId) || handler.isApproved(rowId2)) {
			MessageDialog.openWarning(window.getShell(), "", "已批准文本段,不能合并。");
			return null;
		}

		String fileName1 = RowIdUtil.getFileNameByRowId(rowId);
		String fileName2 = RowIdUtil.getFileNameByRowId(rowId2);
		if (fileName1 == null || fileName2 == null || !fileName1.equals(fileName2)) {
			MessageDialog.openWarning(window.getShell(), "", "文本段不在同一个文件内,不能合并。");
			return null;
		}

//		IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
//		try {
//			operationHistory.execute(new MergeSegmentOperation("Merge Segment", xliffEditor, handler,
//					rowIndex - 1), null, null);
//		} catch (ExecutionException e) {
//			e.printStackTrace();
//		}

		// 选中上一行
		SelectionLayer selectionLayer = LayerUtil.getLayer(xliffEditor.getTable(), SelectionLayer.class);
		selectionLayer.selectRow(0, rowIndex - 1, false, false);

		return null;
	}
 
Example 19
Source File: MergeNextHandler.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
		IEditorPart editor = HandlerUtil.getActiveEditor(event);
		if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
			return null;
		}
		XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
		List<String> selectedRowIds = xliffEditor.getSelectedRowIds();
		if (selectedRowIds.size() < 1) {
			return null;
		}
		String rowId = selectedRowIds.get(selectedRowIds.size() - 1);
		XLFHandler handler = xliffEditor.getXLFHandler();

		int rowIndex = handler.getRowIndex(rowId);

		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		if (rowIndex == handler.countEditableTransUnit() - 1) { // 是最后一行
			MessageDialog.openWarning(window.getShell(), "", "不存在下一文本段,不能合并。");
			return null;
		}
		String rowId2 = handler.getRowId(rowIndex + 1);
		if (handler.isApproved(rowId) || handler.isApproved(rowId2)) {
			MessageDialog.openWarning(window.getShell(), "", "已批准文本段,不能合并。");
			return null;
		}

		String fileName1 = RowIdUtil.getFileNameByRowId(rowId);
		String fileName2 = RowIdUtil.getFileNameByRowId(rowId2);
		if (fileName1 == null || fileName2 == null || !fileName1.equals(fileName2)) {
			MessageDialog.openWarning(window.getShell(), "", "文本段不在同一个文件内,不能合并。");
			return null;
		}

//		IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
//		try {
//			operationHistory.execute(new MergeSegmentOperation("Merge Segment", xliffEditor, handler,
//					rowIndex), null, null);
//		} catch (ExecutionException e) {
//			e.printStackTrace();
//		}

		return null;
	}
 
Example 20
Source File: LifeCycleManager.java    From offspring with MIT License 4 votes vote down vote up
@PostContextCreate
void postContextCreate(IApplicationContext context, Display display,
    final IEventBroker broker, final INxtService nxt, IWallet wallet,
    UISynchronize sync, IUserService userService, IDataProviderPool pool) {

  logger.info("LifeCycleManager.postContextCreate");

  String appId = "com.dgex.offspring.application.lifecycle.LifeCycleManager";
  boolean alreadyRunning;
  try {
    JUnique.acquireLock(appId);
    alreadyRunning = false;
  }
  catch (AlreadyLockedException e) {
    alreadyRunning = true;
  }
  if (alreadyRunning) {
    File home = new File(System.getProperty("user.home") + File.separator
        + ".junique");

    MessageDialog
        .openWarning(
            display.getActiveShell(),
            "Offspring Already Running",
            "Offspring is already running.\n\n"
                + "If you keep seeing this dialog close Offspring with your taskmanager.\n\n"
                + "Cannot find Offspring in your taskmanager?\n"
                + "Then delete this folder " + home.getAbsolutePath());
    System.exit(0);
    return;
  }

  context.applicationRunning();

  final LoginDialog loginDialog = new LoginDialog(Display.getCurrent()
      .getActiveShell(), wallet);
  loginDialog.setBlockOnOpen(true);

  if (loginDialog.open() != Window.OK)
    System.exit(0);

  /* Must re-initialize if user selected to use test net (write new config) */
  if (Config.nxtIsTestNet) {
    Config.initialize();
  }
}