类org.eclipse.jface.dialogs.MessageDialog源码实例Demo

下面列出了怎么用org.eclipse.jface.dialogs.MessageDialog的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: tmxeditor8   文件: EquivalentPage.java
/**
 * 验证用户输入的加权系数的正确性
 * @param equiTxt
 */
private void validEquiTxt(final Text equiTxt){
	final String defaultStr = "0.50";
	equiTxt.setText(defaultStr);
	equiTxt.addFocusListener(new FocusAdapter() {
		@Override
		public void focusLost(FocusEvent e) {
			String textStr = equiTxt.getText().trim();
			if (textStr == null || textStr.trim().length() == 0) {
				equiTxt.setText(defaultStr);
			}else {
				String regular = "1\\.(0){0,2}|0\\.\\d{0,2}";
				if (!textStr.matches(regular)) {
					MessageDialog.openInformation(getShell(), Messages.getString("preference.EquivalentPage.msgTitle"), 
						Messages.getString("preference.EquivalentPage.msg5"));
					equiTxt.setText(defaultStr);
				}
			}
		}
	});
}
 
源代码2 项目: tmxeditor8   文件: ShowNextFuzzyHandler.java
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.getNextFuzzySegmentIndex(lastSelectedRow);
	if (row != -1) {
		xliffEditor.jumpToRow(row);
	} else {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		MessageDialog.openWarning(window.getShell(), "", "不存在下一模糊匹配文本段。");
	}

	return null;
}
 
源代码3 项目: civicrm-data-integration   文件: CiviDialog.java
protected void getEntities() {
    try {
        if (civiCrmEntityList != null && civiCrmEntityList.size() > 0) {
            MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
            boolean goOn = MessageDialog.openConfirm(shell, BaseMessages.getString(PKG, "CiviCrmDialog.DoMapping.ReplaceFields.Title"),
                    BaseMessages.getString(PKG, "CiviCrmDialog.DoMapping.ReplaceFields.Msg"));
            if (!goOn) {
                return;
            }
        }

        String restUrl = variables.environmentSubstitute(wCiviCrmRestUrl.getText());
        String apiKey = variables.environmentSubstitute(wCiviCrmApiKey.getText());
        String siteKey = variables.environmentSubstitute(wCiviCrmSiteKey.getText());
        // String entity = wCiviCrmEntity.getText());

        CiviRestService crUtil = new CiviRestService(restUrl, apiKey, siteKey, "getfields", wCiviCrmEntity.getText());

        civiCrmEntityList = crUtil.getEntityList();
        String[] eArray = (String[]) civiCrmEntityList.toArray(new String[0]);
        wCiviCrmEntity.setItems(eArray);
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "CiviCrmStep.Error.EntityListError"), e.toString().split(":")[0], e);
        logBasic(BaseMessages.getString(PKG, "CiviCrmStep.Error.APIExecError", e.toString()));
    }
}
 
static public void launch() {
    // Check there's an open project
    if (ToolbarAction.project != null) {
        // Check that the Server details are configured
        if (BluemixUtil.isServerConfigured()) {
            // Check is the manifest open
            ManifestMultiPageEditor editor = BluemixUtil.getManifestEditor(ToolbarAction.project);
            if (editor != null) {
                MessageDialog.openWarning(null, _WIZARD_TITLE, 
                        "The Manifest for this application is open. You must close the Manifest before running the Configuration Wizard."); // $NLX-ConfigBluemixWizard.TheManifestforthisapplicat-1$ 
            } else {
                // Launch the Bluemix Config Wizard
                ConfigBluemixWizard wiz = new ConfigBluemixWizard();
                WizardDialog dialog = new WizardDialog(null, wiz);        
                dialog.addPageChangingListener(wiz);
                dialog.open();
            }
        }
        else {
            BluemixUtil.displayConfigureServerDialog();
        }
    } else {
        MessageDialog.openError(null, _WIZARD_TITLE, "No application has been selected or the selected application is not open.");  // $NLX-ConfigBluemixWizard.Noapplicationhasbeenselectedorthe-1$
    }
}
 
源代码5 项目: gwt-eclipse-plugin   文件: ExtractJob.java
protected Action getViewStatusAction(IStatus jobStatus) {
  final String statusTitle = "Extracted " + archive.getName();

  final String statusMessage = "Extracted: "
      + archive.getAbsolutePath()
      + "\n"
      + "into directory: "
      + targetDir.getAbsolutePath()
      + (jobStatus == Status.OK_STATUS ? "" : "\n" + "Status: "
          + jobStatus.getMessage());

  return new Action("view extract status") {
    @Override
    public void run() {
      MessageDialog.openInformation(
          PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
          statusTitle, statusMessage);
    }
  };
}
 
源代码6 项目: bonita-studio   文件: CheckBoxExpressionViewer.java
protected void switchEditorType() {
    if (!control.isVisible()) {
        switchToExpressionMode();
        bindExpression();
    } else {
        if (MessageDialog.openQuestion(mc.getShell(), Messages.eraseExpressionTitle, Messages.eraseExpressionMsg)) {
            switchToCheckBoxMode();
            //Reset checkbox to false
            final Expression falseExp = ExpressionFactory.eINSTANCE.createExpression();
            falseExp.setName(Boolean.FALSE.toString());
            falseExp.setContent(Boolean.FALSE.toString());
            falseExp.setReturnType(Boolean.class.getName());
            falseExp.setType(ExpressionConstants.CONSTANT_TYPE);
            updateSelection(null, falseExp);
            bindExpression();
        }
    }
    mc.layout(true, true);
}
 
private int promptForTraceOverwrite(TracePackageTraceElement packageElement) {
    String name = packageElement.getDestinationElementPath();
    final MessageDialog dialog = new MessageDialog(getContainer().getShell(),
            Messages.ImportTracePackageWizardPage_AlreadyExistsTitle,
            null,
            MessageFormat.format(Messages.ImportTracePackageWizardPage_TraceAlreadyExists, name),
            MessageDialog.QUESTION, new String[] {
                    IDialogConstants.NO_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL,
                    IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.YES_LABEL },
            3) {
        @Override
        protected int getShellStyle() {
            return super.getShellStyle() | SWT.SHEET;
        }
    };
    return dialog.open();
}
 
源代码8 项目: slr-toolkit   文件: SplitTermHandler.java
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection == null || !(selection instanceof IStructuredSelection)) {
		return null;
	}
	IStructuredSelection currentSelection = (IStructuredSelection) selection;
	if (currentSelection.size() == 1) {
		Term termToSplit = (Term) currentSelection.getFirstElement();
		if (selectionValid(termToSplit)) {
			SplitTermDialog dialog = new SplitTermDialog(null, termToSplit.getName());
			if (dialog.open() == MessageDialog.OK && dialog.getReturnCode() == MessageDialog.OK) {
				TermSplitter.split(termToSplit, dialog.getDefaultTermName(), dialog.getFurtherTermNames());
			}
		} else {
			ErrorDialog.openError(null, "Error", null, new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Invalid selection. The selected term must not have children.", null));
		}
	}
	return null;
}
 
/**
 * hide open dashboards
 */
private void hideDashboards() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    try {
        IWorkbenchPage page = window.getActivePage();
        List<IEditorReference> openEditors = new ArrayList<IEditorReference>();
        IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
                .getEditorReferences();
        for (IEditorReference iEditorReference : editorReferences) {
            if (DASHBOARD_VIEW_ID.equals(iEditorReference.getId())) {
                openEditors.add(iEditorReference);
            }
        }
        if (openEditors.size() > 0) {
            page.closeEditors(openEditors.toArray(new IEditorReference[] {}), false);
        }
    } catch (Exception e) {
        MessageDialog.openError(window.getShell(), "Could not hide dashboards for perspective", e.getMessage());
    }
}
 
源代码10 项目: bonita-studio   文件: AbstractDataSection.java
@SuppressWarnings("unchecked")
protected void moveData(final IStructuredSelection structuredSelection) {
    final MoveDataWizard moveDataWizard = new MoveDataWizard((DataAware) getEObject());
    if (new WizardDialog(Display.getDefault().getActiveShell(), moveDataWizard).open() == Dialog.OK) {
        final DataAware dataAware = moveDataWizard.getSelectedDataAwareElement();
        try {
            final MoveDataCommand cmd = new MoveDataCommand(getEditingDomain(), (DataAware) getEObject(), structuredSelection.toList(), dataAware);
            OperationHistoryFactory.getOperationHistory().execute(cmd, null, null);

            if (!(cmd.getCommandResult().getStatus().getSeverity() == Status.OK)) {
                final List<Object> data = (List<Object>) cmd.getCommandResult().getReturnValue();
                String dataNames = "";
                for (final Object d : data) {
                    dataNames = dataNames + ((Element) d).getName() + ",";
                }
                dataNames = dataNames.substring(0, dataNames.length() - 1);
                MessageDialog.openWarning(Display.getDefault().getActiveShell(), Messages.PromoteDataWarningTitle,
                        Messages.bind(Messages.PromoteDataWarningMessage, dataNames));
            }

        } catch (final ExecutionException e1) {
            BonitaStudioLog.error(e1);
        }
        refresh();
    }
}
 
public void partClosed(IWorkbenchPartReference partRef) {
	IWorkbenchPart part = partRef.getPart(false);
	if (part instanceof CompareEditor) {
		CompareEditor editor = (CompareEditor)part;
		IEditorInput input = editor.getEditorInput();
		String name = input.getName();
		if (name != null && name.startsWith(compareName)) {
			targetPart.getSite().getPage().removePartListener(this);
			if (MessageDialog.openQuestion(getShell(), Messages.ResolveTreeConflictWizard_editorClosed, Messages.ResolveTreeConflictWizard_promptToReolve + treeConflict.getResource().getName() + "?")) { //$NON-NLS-1$
				ResolveTreeConflictWizard wizard = new ResolveTreeConflictWizard(treeConflict, targetPart);
				WizardDialog dialog = new SizePersistedWizardDialog(Display.getDefault().getActiveShell(), wizard, "ResolveTreeConflict"); //$NON-NLS-1$
				dialog.open();
			}
		}
	}
}
 
源代码12 项目: tmxeditor8   文件: UpdatePolicy.java
@Override
public boolean continueWorkingWithOperation(ProfileChangeOperation operation, Shell shell) {

	Assert.isTrue(operation.getResolutionResult() != null);
	IStatus status = operation.getResolutionResult();
	// user cancelled
	if (status.getSeverity() == IStatus.CANCEL)
		return false;

	// Special case those statuses where we would never want to open a wizard
	if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
		MessageDialog.openInformation(shell, P2UpdateUtil.CHECK_UPDATE_JOB_NAME, P2UpdateUtil.UPDATE_PROMPT_INFO_NO_UPDATE);
		return false;
	}

	// there is no plan, so we can't continue. Report any reason found
	if (operation.getProvisioningPlan() == null && !status.isOK()) {
		StatusManager.getManager().handle(status, StatusManager.LOG | StatusManager.SHOW);
		return false;
	}

	// Allow the wizard to open otherwise.
	return true;
}
 
源代码13 项目: gama   文件: ShowLocalHistory.java
protected IFileState[] getLocalHistory() {
	final IFile file = ResourceManager.getFile(getSelection().getFirstElement());
	IFileState states[] = null;
	try {
		if (file != null) {
			states = file.getHistory(null);
		}
	} catch (final CoreException ex) {
		MessageDialog.openError(WorkbenchHelper.getShell(), getPromptTitle(), ex.getMessage());
		return null;
	}

	if (states == null || states.length <= 0) {
		MessageDialog.openInformation(WorkbenchHelper.getShell(), getPromptTitle(),
				TeamUIMessages.ShowLocalHistory_0);
		return states;
	}
	return states;
}
 
private void startEditLocal(Object object, ILocalDocumentService service, Shell parentShell){
	Optional<File> file = service.add(object, new IConflictHandler() {
		@Override
		public Result getResult(){
			if (MessageDialog.openQuestion(parentShell,
				Messages.StartEditLocalDocumentHandler_conflicttitle,
				Messages.StartEditLocalDocumentHandler_conflictmessage)) {
				return Result.KEEP;
			} else {
				return Result.OVERWRITE;
			}
		}
	});
	if (file.isPresent()) {
		Program.launch(file.get().getAbsolutePath());
	} else {
		MessageDialog.openError(parentShell, Messages.StartEditLocalDocumentHandler_errortitle,
			Messages.StartEditLocalDocumentHandler_errormessage);
	}
}
 
源代码15 项目: gemfirexd-oss   文件: StartAction.java
public void run(IAction action) {
	try {
		if(currentJavaProject!=null){
			currentProject=currentJavaProject.getProject();
		}
		DerbyServerUtils.getDefault().startDerbyServer(currentProject);
		
	}
	catch (CoreException e) {
		Shell shell = new Shell();
		MessageDialog.openInformation(
			shell,
			CommonNames.PLUGIN_NAME,
			Messages.D_NS_START_ERROR +
			com.pivotal.gemfirexd.internal.ui.util.SelectionUtil.getStatusMessages(e));
	}
}
 
/**
 * Check if the supplied resource is read only or null. If it is then ask
 * the user if they want to continue. Return true if the resource is not
 * read only or if the user has given permission.
 * 
 * @return boolean
 */
private boolean checkReadOnlyAndNull(IResource currentResource) {
	// Do a quick read only and null check
	if (currentResource == null) {
		return false;
	}

	// Do a quick read only check
	final ResourceAttributes attributes = currentResource
			.getResourceAttributes();
	if (attributes != null && attributes.isReadOnly()) {
		return MessageDialog.openQuestion(shellProvider.getShell(), CHECK_RENAME_TITLE,
				MessageFormat.format(CHECK_RENAME_MESSAGE,
						new Object[] { currentResource.getName() }));
	}

	return true;
}
 
源代码17 项目: gama   文件: PickWorkspaceDialog.java
protected void cloneCurrentWorkspace() {
	final String currentLocation = WorkspacePreferences.getLastSetWorkspaceDirectory();
	if ( currentLocation == null || currentLocation.isEmpty() ) {
		MessageDialog.openError(Display.getDefault().getActiveShell(), "Error",
			"No current workspace exists. Can only clone from an existing workspace");
		return;
	}
	final String newLocation = workspacePathCombo.getText();
	// Fixes Issue #2848
	if ( newLocation.startsWith(currentLocation) ) {
		MessageDialog.openError(Display.getDefault().getActiveShell(), "Error",
			"The path entered is either that of the current wokspace or of a subdirectory of it. Neither can be used as a destination.");
		return;
	}
	cloning = true;
	try {
		okPressed();
	} finally {
		cloning = false;
	}
}
 
源代码18 项目: tracecompass   文件: ManageCustomParsersDialog.java
private boolean checkNameConflict(CustomTraceDefinition def) {
    for (TraceTypeHelper helper : TmfTraceType.getTraceTypeHelpers()) {
        if (def.categoryName.equals(helper.getCategoryName()) &&
                def.definitionName.equals(helper.getName())) {
            String newName = findAvailableName(def);
            MessageDialog dialog = new MessageDialog(
                    getShell(),
                    null,
                    null,
                    NLS.bind(Messages.ManageCustomParsersDialog_ConflictMessage,
                            new Object[] { def.categoryName, def.definitionName, newName}),
                    MessageDialog.QUESTION,
                    new String[] { Messages.ManageCustomParsersDialog_ConflictRenameButtonLabel,
                        Messages.ManageCustomParsersDialog_ConflictSkipButtonLabel },
                    0);
            int result = dialog.open();
            if (result == 0) {
                def.definitionName = newName;
                return true;
            }
            return false;
        }
    }
    return true;
}
 
源代码19 项目: bonita-studio   文件: SmartImportBdmHandler.java
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell activeShell, RepositoryAccessor repositoryAccessor) {
    SmartImportBdmPage page = new SmartImportBdmPage(repositoryAccessor);
    Optional<BusinessDataModelEditor> openedEditor = retrieveBdmFileStore(repositoryAccessor)
            .map(BusinessObjectModelFileStore::getOpenedEditor);
    manageDirtyEditor(activeShell, openedEditor);
    Optional<IStatus> status = createWizard(newWizard(), page, repositoryAccessor).open(activeShell,
            Messages.importButtonLabel);
    if (status.isPresent()) {
        IStatus s = status.get();
        if (s.isOK()) {
            MessageDialog.openInformation(activeShell, Messages.bdmImportedTitle, Messages.bdmImported);
            updateWorkingCopy(openedEditor, repositoryAccessor);
        } else {
            MessageDialog.openError(activeShell, Messages.ImportError, s.getMessage());
        }
    }
}
 
源代码20 项目: tmxeditor8   文件: PluginConfigManage.java
public void sendDocument(PluginConfigBean bean, IFile curXliff) {
	String curXliffLocation = curXliff.getLocation().toOSString();
	File f = new File(curXliffLocation);
	if (!f.exists()) {
		MessageDialog.openInformation(shell, Messages.getString("plugin.PluginConfigManage.msgTitle"),
				MessageFormat.format(Messages.getString("plugin.PluginConfigManage.msg9"), curXliff.getFullPath()
						.toOSString()));
		return;
	}

	String commandLine = bean.getCommandLine();

	String[] cmdArray = { commandLine, curXliffLocation };
	try {
		Process pluginProcess = Runtime.getRuntime().exec(cmdArray);
		if (bean.getInput().equals(PluginConstants.EXCHANGEFILE)) {
			pluginProcess.waitFor();
		}
	} catch (Exception e) {
		LOGGER.error("", e);
	}
}
 
@Override
public void run(ITextSelection selection) {
	if (!ActionUtil.isEditable(fEditor))
		return;

	ITypeRoot typeRoot= SelectionConverter.getInput(fEditor);
	if (typeRoot == null)
		return;

	CompilationUnit node= RefactoringASTParser.parseWithASTProvider(typeRoot, true, null);

	if (typeRoot instanceof ICompilationUnit) {
		ICompilationUnit cu= (ICompilationUnit) typeRoot;
		if (fInlineTemp.isEnabled() && fInlineTemp.tryInlineTemp(cu, node, selection, getShell()))
			return;

		if (fInlineConstant.isEnabled() && fInlineConstant.tryInlineConstant(cu, node, selection, getShell()))
			return;
	}
	//InlineMethod is last (also tries enclosing element):
	if (fInlineMethod.isEnabled() && fInlineMethod.tryInlineMethod(typeRoot, node, selection, getShell()))
		return;

	MessageDialog.openInformation(getShell(), RefactoringMessages.InlineAction_dialog_title, RefactoringMessages.InlineAction_select);
}
 
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.getPreviousUntranslatedSegmentIndex(firstSelectedRow);
	if (row != -1) {
		xliffEditor.jumpToRow(row);
	} else {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		MessageDialog.openWarning(window.getShell(), "", "不存在上一未翻译文本段。");
	}

	return null;
}
 
@Override
protected void okPressed(){
	ProgressMonitorDialog progress = new ProgressMonitorDialog(getShell());
	QueryProposalRunnable runnable = new QueryProposalRunnable();
	try {
		progress.run(true, true, runnable);
		if (runnable.isCanceled()) {
			return;
		} else {
			proposal = runnable.getProposal();
		}
	} catch (InvocationTargetException | InterruptedException e) {
		LoggerFactory.getLogger(BillingProposalWizardDialog.class)
			.error("Error running proposal query", e);
		MessageDialog.openError(getShell(), "Fehler",
			"Fehler beim Ausführen des Rechnungs-Vorschlags.");
		return;
	}
	
	super.okPressed();
}
 
源代码24 项目: tmxeditor8   文件: TermDbManagerDialog.java
/**
 * 执行查询
 * @param sysDbOp
 *            ;
 */
private void executeSearch(final SystemDBOperator sysDbOp) {
	BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
		public void run() {
			// 连接检查
			if (!sysDbOp.checkDbConnection()) {
				MessageDialog.openInformation(getShell(),
						Messages.getString("dialog.TermDbManagerDialog.msgTitle"),
						Messages.getString("dialog.TermDbManagerDialog.msg1"));
				setLastSelectedServer(null);
				return;
			}

			// 获取数据库信息,包括名称和语言
			List<DatabaseManagerDbListBean> temp = searchCurrServerDatabase(sysDbOp, currServer);

			currServerdbListInput.clear();
			if (temp != null) {
				currServerdbListInput.addAll(temp);
				if (temp.size() > 0) {
					getDbTableViewer().setSelection(new StructuredSelection(temp.get(0)));
				}
				setLastSelectedServer(currServer.getId());
			}
		}
	});
}
 
public void runWithEvent(Event event) {
	if (viewer != null && !viewer.getTextWidget().isDisposed()) {
		StyledTextCellEditor editor = HsMultiActiveCellEditor.getFocusCellEditor();
		boolean isSrc = false;
		if (editor != null && editor.getCellType().equals(NatTableConstant.SOURCE)) {
			isSrc = true;
		}
		StyledText styledText = viewer.getTextWidget();
		String text = styledText.getText();
		String selectionText = styledText.getSelectionText();
		// 当选择源文时,要判断是否是删除所有源文
		if (isSrc) {
			if (selectionText != null && text != null && text.equals(selectionText)) {
				MessageDialog.openInformation(viewer.getTextWidget().getShell(),
						Messages.getString("editor.XLIFFEditorActionHandler.msgTitle"),
						Messages.getString("editor.XLIFFEditorActionHandler.msg"));
				return;
			}
		}
		viewer.doOperation(ITextOperationTarget.DELETE);
		updateActionsEnableState();
		return;
	}
	if (deleteAction != null) {
		deleteAction.runWithEvent(event);
		return;
	}
}
 
源代码26 项目: APICloud-Studio   文件: SVNHistoryPage.java
/**
 * Ask the user to confirm the overwrite of the file if the file has been
 * modified since last commit
 */
private boolean confirmOverwrite() {
   IFile file = (IFile) resource;
   if(file != null && file.exists()) {
     ISVNLocalFile svnFile = SVNWorkspaceRoot.getSVNFileFor(file);
     try {
       if(svnFile.isDirty()) {
         String title = Policy.bind("HistoryView.overwriteTitle"); //$NON-NLS-1$
         String msg = Policy.bind("HistoryView.overwriteMsg"); //$NON-NLS-1$
         final MessageDialog dialog = new MessageDialog(getSite().getShell(), title, null, msg,
             MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL}, 0);
         final int[] result = new int[ 1];
         getSite().getShell().getDisplay().syncExec(new Runnable() {
           public void run() {
             result[ 0] = dialog.open();
           }
         });
         if(result[ 0] != 0) {
           // cancel
           return false;
         }
       }
     } catch(SVNException e) {
       SVNUIPlugin.log(e.getStatus());
     }
   }
   return true;
 }
 
private BillingProposalView getOpenView(ExecutionEvent event){
	try {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
		IWorkbenchPage page = window.getActivePage();
		return (BillingProposalView) page.showView(BillingProposalView.ID);
	} catch (PartInitException e) {
		MessageDialog.openError(HandlerUtil.getActiveShell(event), "Fehler",
			"Konnte Rechnungs-Vorschlag View nicht öffnen");
	}
	return null;
}
 
源代码28 项目: gama   文件: WorkspaceModelsManager.java
IFile createUnclassifiedModelsProjectAndAdd(final IPath location) {
	IFile iFile = null;
	try {
		final IFolder modelFolder = createUnclassifiedModelsProject(location);
		iFile = modelFolder.getFile(location.lastSegment());
		if ( iFile.exists() ) {
			if ( iFile.isLinked() ) {
				final IPath path = iFile.getLocation();
				if ( path.equals(location) ) {
					// First case, this is a linked resource to the same location. In that case, we simply return
					// its name.
					return iFile;
				} else {
					// Second case, this resource is a link to another location. We create a filename that is
					// guaranteed not to exist and change iFile accordingly.
					iFile = createUniqueFileFrom(iFile, modelFolder);
				}
			} else {
				// Third case, this resource is local and we do not want to overwrite it. We create a filename that
				// is guaranteed not to exist and change iFile accordingly.
				iFile = createUniqueFileFrom(iFile, modelFolder);
			}
		}
		iFile.createLink(location, IResource.NONE, null);
		// RefreshHandler.run();
		return iFile;
	} catch (final CoreException e) {
		e.printStackTrace();
		MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Error in creation",
			"The file " + (iFile == null ? location.lastSegment() : iFile.getFullPath().lastSegment()) +
				" cannot be created because of the following exception " + e.getMessage());
		return null;
	}
}
 
源代码29 项目: slr-toolkit   文件: ExportHandler.java
/**
 * Tries to load a project and all corresponding files in ModelRegistry and metainformation plugin. If more than one projects are in the workspace, a dialog will be opened and the user
 * input determines, which project is to be loaded.
 * @param event Execution Event
 * @return false, if no project can be loaded; true, if a project could be loaded
 */
private boolean tryLoadingProjectFiles(ExecutionEvent event) {
	initializeEditingDomain();
	
	IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
	
	List<IProject> openProjects = new ArrayList<>();
	for(IProject project : projects)
	{
	    if(project.isOpen())
	        openProjects.add(project);
	}
	
	if(openProjects.size() == 0) {
		String errorMessage = "There are no projects to export in your workspace.";
		MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error",
				errorMessage);
		return false;
	}
	
	else if(openProjects.size() == 1) {
		setProjectForExport(openProjects.get(0));
		return true;
	}
	
	else{
		int projectSelection = getProjectSelection(openProjects);
		
		if(projectSelection == this.SELECTIONEVENT_CANCEL) {
			return false;
		}
		else {
			setProjectForExport(openProjects.get(projectSelection));
			return true;
		}
	}
}
 
@Override
public void fill(final ToolBar toolbar, final int style) {
    toolItem = new ToolItem(toolbar, SWT.LEFT | SWT.PUSH | SWT.NO_FOCUS);
    toolItem.setEnabled(false);
    toolItem.setToolTipText(Messages.newFormTooltipForPool);
    toolItem.setImage(Pics.getImage("new_form.png", UIDesignerPlugin.getDefault()));
    toolItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (shoudCreateNewForm()) {
                if (!isEditable()) {
                    createNewForm();
                } else {
                    editForm();
                }
            }
        }

        /**
         * @param canCreateOrEdit
         * @return
         */
        protected boolean shoudCreateNewForm() {
            if (!isInternalForm()) {
                return MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), Messages.switchTypeOfFormQuestionTitle,
                        Messages.bind(Messages.switchTypeOfFormQuestion, getFormMappingTypeName()));
            }
            return true;
        }
    });
}