Exemplo n.º 1
0
    public void run() {
      String msg =
          name
              + "数据被外部程序改变,是否重载?\n"
              + "注:如果选择是,所有已打开的编辑窗口将被关闭,数据不会保存;如果选择否,"
              + "那么在你继续编辑并保存数据时,将有可能覆盖别人的修改!";
      if (MessageDialog.openConfirm(getSite().getShell(), "警告", msg) == false) {
        return;
      }
      try {
        // 重载
        CrossGateEditor.getReloadManager().reload();

        // 刷新列表
        for (TreeViewer tv : dataTreeViewers) {
          tv.refresh();
        }

        // 关闭所有编辑器
        IEditorReference[] refs =
            getSite().getWorkbenchWindow().getActivePage().getEditorReferences();
        for (IEditorReference ref : refs) {
          IEditorPart editor = ref.getEditor(false);
          if (editor != null) {
            getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
          }
        }
      } catch (Exception e) {
        CrossGateEditor.getLog().error(getClass().getName(), e);
        //            	CrossGateEditor.catchException(e, false);
        MessageDialog.openError(getSite().getShell(), "错误", e.toString());
      }
    }
Exemplo n.º 2
0
  protected void addSelection() {
    String key = keyText.getText();
    String val = valueText.getText();
    if (key != null && key.trim().length() > 0) {
      boolean isContained = false;
      for (int i = 0; i < globalLinkedProperties.size(); i++) {
        GlobalProperty property = (GlobalProperty) globalLinkedProperties.get(i);
        if (key.equals(property.key) && !property.isDeleted) {
          property.value = val;
          isContained = true;
          break;
        }
      }

      if (!isContained) {
        // if the file is read-only then change is not allowed.
        if (propFileName[0] == null) {
          return;
        } else {
          File f = new File(propFileName[0]);
          if (!(f.exists() && f.isFile())) {
            MessageDialog.openError(
                getShell(),
                Messages.getString("ResourceEditDialog.NotFile.Title"), // $NON-NLS-1$
                Messages.getFormattedString(
                    "ResourceEditDialog.NotFile.Message", //$NON-NLS-1$
                    new Object[] {propFileName}));
            return;
          } else if (!f.canWrite()) {
            MessageDialog.openError(
                getShell(),
                Messages.getString("ResourceEditDialog.ReadOnlyEncounter.Title"), // $NON-NLS-1$
                Messages.getFormattedString(
                    "ResourceEditDialog.ReadOnlyEncounter.Message", //$NON-NLS-1$
                    new Object[] {propFileName}));
            return;
          }

          GlobalProperty property = new GlobalProperty();
          property.key = key;
          property.value = val;
          property.holder = contents[0];
          property.isDeleted = false;
          property.holderFile = propFileName[0];

          globalLinkedProperties.add(property);
        }
      }

      viewer.refresh();
      listChanged = true;
      updateSelection();

    } else {
      MessageDialog.openWarning(
          getShell(),
          Messages.getString("ResourceEditDialog.text.AddWarningTitle"), // $NON-NLS-1$
          Messages.getString("ResourceEditDialog.text.AddWarningMsg")); // $NON-NLS-1$
    }
  }
Exemplo n.º 3
0
 private boolean shouldVerify() {
   if (VerifyJob.isRunning()) {
     new MessageDialog(
             getShell(),
             "Program being verified.",
             null,
             "Only one program can be verified at a time.",
             MessageDialog.ERROR,
             new String[] {"OK"},
             0)
         .open();
     return false;
   }
   if (!editor.isDirty()) return true;
   MessageDialog dialog =
       new MessageDialog(
           getShell(),
           "Save Changes?",
           null,
           "Before the program can be verified changes made to the configuration must first be saved.",
           MessageDialog.ERROR,
           new String[] {
             "&Save New Properties and Verify", "&Revert to Old Properties and Verify", "&Cancel"
           },
           2);
   int option = dialog.open();
   if (option == 0) editor.saveProperties();
   else if (option == 1) editor.revertProperties();
   else return false;
   return true;
 }
Exemplo n.º 4
0
 private void loadLdapUser() {
   try {
     LoadLdapUser loadLdapUser = new LoadLdapUser(getParameter());
     loadLdapUser = ServiceFactory.lookupCommandService().executeCommand(loadLdapUser);
     personSet.clear();
     List<PersonInfo> personList = loadLdapUser.getPersonList();
     if (personList != null) {
       List<PersonInfo> accountList = new ArrayList<PersonInfo>(personList);
       personSet.addAll(accountList);
     }
     // Get the content for the viewer, setInput will call getElements in the
     // contentProvider
     refreshTable();
   } catch (SizeLimitExceededException sizeLimitExceededException) {
     log.warn("To many results ehen searching for LDAP users."); // $NON-NLS-1$
     if (log.isDebugEnabled()) {
       log.debug("stacktrace: ", sizeLimitExceededException); // $NON-NLS-1$
     }
     personSet.clear();
     refreshTable();
     MessageDialog.openInformation(
         getShell(), Messages.LdapImportDialog_6, Messages.LdapImportDialog_7);
   } catch (Throwable t) {
     log.error("Error while setting table data", t); // $NON-NLS-1$
     personSet.clear();
     refreshTable();
     MessageDialog.openError(
         getShell(), Messages.LdapImportDialog_45, Messages.LdapImportDialog_1);
   }
 }
  /**
   * Determine if the supplied IFile has any outstanding problem markers. If markers are found,
   * dialogs are displayed.
   *
   * @param mxdFile the file containing the extension definition
   * @return <code>true</code> if problems were found
   */
  private static boolean checkProblemMarkers(IFile mxdFile) {
    IMarker[] markers = null;
    boolean errorOccurred = false;

    try {
      markers =
          mxdFile.findMarkers(
              UiConstants.ExtensionIds.PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
    } catch (CoreException ex) {
      Util.log(ex);
      errorOccurred = true;
    }

    // Notify user if error getting markers
    if (errorOccurred) {
      MessageDialog.openError(
          getShell(),
          Messages.checkMedProblemMarkersErrorTitle,
          Messages.checkMedProblemMarkersErrorMsg);
      return true;
    }

    if (markers.length > 0) {
      MessageDialog.openError(
          getShell(),
          Messages.checkMedProblemMarkersHasErrorsTitle,
          Messages.checkMedProblemMarkersHasErrorsMsg);
      return true;
    }

    return false;
  }
  /*
   * @return <code>true</code> if compare result is OK to show, <code>false</code> otherwise
   */
  public boolean compareResultOK(CompareEditorInput input, IRunnableContext context) {
    final Shell shell = getShell();
    try {

      // run operation in separate thread and make it cancelable
      if (context == null) context = PlatformUI.getWorkbench().getProgressService();
      context.run(true, true, input);

      String message = input.getMessage();
      if (message != null) {
        MessageDialog.openError(
            shell, Utilities.getString("CompareUIPlugin.compareFailed"), message); // $NON-NLS-1$
        return false;
      }

      if (input.getCompareResult() == null) {
        MessageDialog.openInformation(
            shell,
            Utilities.getString("CompareUIPlugin.dialogTitle"),
            Utilities.getString("CompareUIPlugin.noDifferences")); // $NON-NLS-2$ //$NON-NLS-1$
        return false;
      }

      return true;

    } catch (InterruptedException x) {
      // canceled by user
    } catch (InvocationTargetException x) {
      MessageDialog.openError(
          shell,
          Utilities.getString("CompareUIPlugin.compareFailed"),
          x.getTargetException().getMessage()); // $NON-NLS-1$
    }
    return false;
  }
Exemplo n.º 7
0
  public void save_Event() {
    FileDialog fd = new FileDialog(ZestDebuggerView.this.getSite().getShell(), SWT.SAVE);
    fd.setText("Save");
    fd.setFilterPath("C:/");
    String[] filterExt = {"*.jpg"};
    fd.setFilterExtensions(filterExt);
    String selected = fd.open();
    System.out.println(selected);

    if (selected != null) {
      GC gc = new GC(viewer.getControl());
      org.eclipse.swt.graphics.Rectangle bounds = viewer.getControl().getBounds();

      Image image = new Image(viewer.getControl().getDisplay(), bounds);
      try {
        gc.copyArea(image, 0, 0);
        ImageLoader imageLoader = new ImageLoader();
        imageLoader.data = new ImageData[] {image.getImageData()};
        imageLoader.save(selected, SWT.IMAGE_JPEG);
        MessageDialog.openInformation(
            ZestDebuggerView.this.getSite().getShell(),
            "Success",
            "The image has been saved successfully");
      } catch (Exception e) {
        e.printStackTrace();
        MessageDialog.openError(
            ZestDebuggerView.this.getSite().getShell(), "Failure", "The image can't be saved");
      } finally {
        image.dispose();
        gc.dispose();
      }
    }
  }
  public static boolean renameParameter(
      IContextModelManager manager,
      final String oldParamName,
      String sourceId,
      final String newParamName,
      boolean reposFlag) {
    if (!manager.getContextManager().checkValidParameterName(oldParamName, newParamName)) {
      MessageDialog.openError(
          new Shell(),
          Messages.getString("ContextProcessSection.errorTitle"),
          Messages.getString(
              "ContextProcessSection.ParameterNameIsNotValid")); //$NON-NLS-1$ //$NON-NLS-2$
      return false;
    }
    // fix 0017942: It is unlimited for total characters of context variable name
    if (null != newParamName && !"".equals(newParamName)) { // $NON-NLS-1$
      if (newParamName.length() > 255) {
        MessageDialog.openError(
            new Shell(),
            Messages.getString("ContextProcessSection.errorTitle"),
            Messages.getString(
                "ContextTemplateComposite.ParamterLengthInvilid")); //$NON-NLS-1$ //$NON-NLS-2$
        return false;
      }
    }

    manager.onContextRenameParameter(
        manager.getContextManager(), sourceId, oldParamName, newParamName);
    manager.refresh();
    return true;
  }
Exemplo n.º 9
0
  @Override
  public void run(IAction action) {
    if (project == null) {
      return;
    }
    // 不是初始化的项目不能删除
    DBObject projectData = project.getData();
    if (!DataUtil.isInactive(projectData) && !DataUtil.isInactive(projectData)) {
      MessageDialog.openWarning(
          window.getShell(),
          UIConstants.TEXT_REMOVE_PROJECT,
          UIConstants.MESSAGE_CANNOT_DELETE_PROJECT_NOT_INIT_OR_READY);
      return;
    }

    // 项目管理员和项目创建者可以删除
    if (!DataUtil.isProjectCreator(projectData) && !DataUtil.isProjectAdmin(projectData)) {
      MessageDialog.openWarning(
          window.getShell(),
          UIConstants.TEXT_REMOVE_PROJECT,
          UIConstants.MESSAGE_CANNOT_DELETE_PROJECT_NOT_AUTH);
      return;
    }

    boolean ok =
        MessageDialog.openQuestion(
            window.getShell(),
            UIConstants.TEXT_REMOVE_PROJECT,
            ""
                + project.getText(IDBConstants.FIELD_DESC)
                + UIConstants.MESSAGE_QUESTION_REMOVE_PROJECT);
    if (!ok) return;
    removeUserInformation();
    project.remove();
  }
Exemplo n.º 10
0
 private void handleSetDefaultButton() {
   try {
     CustomizeData custData = getCustTableSelection();
     if (custData.getName().equals(CustomizeManager.TABLE_DEFAULT_LABEL)
         || custData.getName().equals(CustomizeManager.CURRENT_LABEL)) {
       XViewerLib.popup("ERROR", XViewerText.get("error.set_default"));
       return;
     }
     if (xViewerToCustomize.getCustomizeMgr().isCustomizationUserDefault(custData)) {
       if (MessageDialog.openConfirm(
           Display.getCurrent().getActiveShell(),
           XViewerText.get("button.remove_default"),
           MessageFormat.format(
               XViewerText.get("XViewerCustomizeDialog.prompt.remove_default"),
               custData.getName()))) {
         xViewerToCustomize.getCustomizeMgr().setUserDefaultCustData(custData, false);
       }
     } else if (MessageDialog.openConfirm(
         Display.getCurrent().getActiveShell(),
         XViewerText.get("button.set_default"),
         MessageFormat.format(
             XViewerText.get("XViewerCustomizeDialog.prompt.set_default"), custData.getName()))) {
       xViewerToCustomize.getCustomizeMgr().setUserDefaultCustData(custData, true);
     }
     loadCustomizeTable();
   } catch (Exception ex) {
     XViewerLog.logAndPopup(Activator.class, Level.SEVERE, ex);
   }
 }
  private void compileLoader(String id) {
    String param = "";
    param = "appId=" + id + "&" + "loader=1";
    String message = NetWorkService.getInstance().addUnpack(id, param, ip);
    JSONObject json;
    try {
      json = new JSONObject(message);
      String status = json.getString("status");
      if (status.equals("0")) {
        MessageDialog.openError(
            Display.getDefault().getActiveShell(), Messages.ERROR, Messages.SERVICEBUSY);
      } else if (status.equals("error")) {
        MessageDialog.openError(
            Display.getDefault().getActiveShell(), Messages.ERROR, Messages.COMPILEERROR);

      } else {
        String body;
        body = json.getString("body");
        JSONObject result = new JSONObject(body);
        pkgId = result.getString("pkgId");
        System.err.println(pkgId);
        compileAndDownloadAppLoader(id);
      }
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
 /** @generated */
 private static boolean openEditor(IWorkbench workbench, URI fileURI) {
   IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
   IWorkbenchPage page = workbenchWindow.getActivePage();
   IEditorDescriptor editorDescriptor =
       workbench.getEditorRegistry().getDefaultEditor(fileURI.toFileString());
   if (editorDescriptor == null) {
     MessageDialog.openError(
         workbenchWindow.getShell(),
         Messages.DiagramEditorActionBarAdvisor_DefaultFileEditorTitle,
         NLS.bind(
             Messages.DiagramEditorActionBarAdvisor_DefaultFileEditorMessage,
             fileURI.toFileString()));
     return false;
   } else {
     try {
       page.openEditor(new URIEditorInput(fileURI), editorDescriptor.getId());
     } catch (PartInitException exception) {
       MessageDialog.openError(
           workbenchWindow.getShell(),
           Messages.DiagramEditorActionBarAdvisor_DefaultEditorOpenErrorTitle,
           exception.getMessage());
       return false;
     }
   }
   return true;
 }
Exemplo n.º 13
0
	/**
	 * @author rafaeldurelli
	 *  @param SQLMODEL.sqlmodel.DataBase used to instantiate the DataBase metaClasse
	 * */
	public static void createModel(DataBase dataBase) {
		
		
		Database dataBaseModel = factory.createDatabase();
		
		//set the name of the DataBase
		dataBaseModel.setName(dataBase.getDataBaseName());
		
		addTables(dataBaseModel, dataBase.getDataBaseTables());
		
		Registry reg = Registry.INSTANCE;
		
		Map<String, Object> m = reg.getExtensionToFactoryMap();
		m.put("sqlmodel", new XMIResourceFactoryImpl());
		
		ResourceSet resSet = new ResourceSetImpl();
		
		Resource resource = resSet.createResource(URI.createURI("file:/Users/rafaeldurelli/Documents/runtime-EclipseApplication/Teste/models/My2.sqlmodel"));
		
		// Get the first model element and cast it to the right type, in my
	    // example everything is hierarchical included in this first node
	    resource.getContents().add(dataBaseModel);

	    // Now save the content.
	    try {
	      
	    	resource.save(Collections.EMPTY_MAP);
	    	
	      
	    } catch (IOException e) {
	    	MessageDialog.openError(null, "It was not possible to create the sqlmodel.", "Please vefiry what happened.");
	    	e.printStackTrace();
	    }
	    
	    MessageDialog.openInformation(null, "The sqlmodel was created in the folder models.", "If the folder named models is not visible, please refresh your project in order to see the sqlmodel.");
Exemplo n.º 14
0
 private boolean openSaveDialog() {
   if (getModel() != null && !getModel().exists()) {
     return true;
   }
   MessageDialog dialog =
       new MessageDialog(
           getShell(),
           Messages.ControlPanelWindow_SaveDialogTitle,
           null,
           Messages.ControlPanelWindow_SaveDialogMsg,
           MessageDialog.QUESTION_WITH_CANCEL,
           new String[] {
             IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL
           },
           0);
   int returnCode = dialog.open(); // Number of pressed button
   if (returnCode == 0) {
     if (getModel() != null) {
       save();
     } else {
       if (!saveAs()) {
         return false;
       }
     }
   }
   switch (returnCode) {
     case 2:
       return false; // User clicked Cancel button
     default:
       return true;
   }
 }
 @Override
 protected void saveData() throws Exception {
   int index = indexSpinner.getSelection();
   EditorImageSet editorImage = (EditorImageSet) editObject;
   if (index < editorImage.getImageCount()) {
     EditorImageDictionary imageDictionary = (EditorImageDictionary) editorImage.select(index);
     try {
       imageDictionary.setGlobalId(Integer.parseInt(globalId.getText()));
       imageDictionary.setMark(
           isObstacle.getSelection() ? MapCell.MARK_OBSTACLE : MapCell.MARK_NOMARL);
       imageDictionary.setOffsetX(Integer.parseInt(offsetX.getText()));
       imageDictionary.setOffsetY(Integer.parseInt(offsetY.getText()));
       imageDictionary.setUseEast(Byte.parseByte(useEast.getText()));
       imageDictionary.setUseSouth(Byte.parseByte(useSouth.getText()));
       MessageDialog.openInformation(
           PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
           "完成",
           "保存成功:" + imageDictionary);
     } catch (Exception e) {
       CrossGateEditor.getLog().error(getClass().getName(), e);
       MessageDialog.openError(
           PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
           "错误",
           "输入有误:" + e.getMessage());
     }
   }
 }
Exemplo n.º 16
0
 public static boolean saveDirtyFiles(String mask) {
   boolean result = true;
   // TODO (cs) add support for save automatically
   Shell shell = Display.getCurrent().getActiveShell();
   IEditorPart[] dirtyEditors = getDirtyEditors(mask);
   if (dirtyEditors.length > 0) {
     result = false;
     SaveDirtyFilesDialog saveDirtyFilesDialog = new SaveDirtyFilesDialog(shell);
     saveDirtyFilesDialog.setInput(Arrays.asList(dirtyEditors));
     // Save all open editors.
     if (saveDirtyFilesDialog.open() == Window.OK) {
       result = true;
       int numDirtyEditors = dirtyEditors.length;
       for (int i = 0; i < numDirtyEditors; i++) {
         dirtyEditors[i].doSave(null);
       }
     } else {
       MessageDialog dlg =
           new MessageDialog(
               shell,
               Messages.SaveDirtyFilesDialog_title_error,
               null,
               ALL_MODIFIED_RESOURCES_MUST_BE_SAVED_BEFORE_THIS_OPERATION,
               MessageDialog.ERROR,
               new String[] {IDialogConstants.OK_LABEL},
               0);
       dlg.open();
     }
   }
   return result;
 }
  private void onSelectDelete(final Object selectedPart) {

    if (selectedPart instanceof PartMP) {

      final MP selectedPartMp = ((PartMP) selectedPart).partMp;

      if (MessageDialog.openConfirm(
          _display.getActiveShell(),
          Messages.Dialog_OfflineArea_ConfirmDelete_Title,
          NLS.bind(
              Messages.Dialog_OfflineArea_ConfirmDeletePart_Message, selectedPartMp.getName()))) {

        deleteOfflineImages(selectedPartMp);
      }

    } else {

      if (MessageDialog.openConfirm(
          _display.getActiveShell(),
          Messages.Dialog_OfflineArea_ConfirmDelete_Title,
          Messages.Dialog_OfflineArea_ConfirmDeleteAll_Message)) {

        deleteOfflineImages(null);
      }
    }
  }
Exemplo n.º 18
0
  public void cmdIedeaExportsSelected() {
    DirectoryDialog dlg = new DirectoryDialog(getShell());
    dlg.setText("Select a folder to save the export files in");
    dlg.setMessage("Select a directory");
    final String dir = dlg.open();
    if (dir == null) {
      return;
    }

    final IedeaExporter iedeaExporter = new IedeaExporter();
    try {
      new ProgressMonitorDialog(null)
          .run(
              true,
              true,
              new IRunnableWithProgress() {
                @Override
                public void run(IProgressMonitor monitor)
                    throws InvocationTargetException, InterruptedException {
                  try {
                    iedeaExporter.setMonitor(monitor);
                    iedeaExporter.generate(dir);
                  } catch (TaskException e) {
                    throw new InvocationTargetException(e);
                  }
                }
              });
      MessageDialog.openInformation(null, "Completed", "Tier.net export successful");
    } catch (InvocationTargetException e) {
      MessageUtil.showError(e, "Error running export", e.getMessage());
    } catch (InterruptedException e) {
      MessageDialog.openInformation(null, "Cancelled", e.getMessage());
    }
  }
Exemplo n.º 19
0
  /**
   * ************************************************************************* The command has been
   * executed, so extract extract the needed information from the application context.
   * ************************************************************************
   */
  public CommandResult execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

    IServerProxy proxy = (IServerProxy) ServiceManager.get(IServerProxy.class);
    ServerRole role = proxy.getCurrentServer().getRole();
    if (role != ServerRole.COMMANDING) {
      MessageDialog.openError(
          window.getShell(),
          "Cannot open",
          "Cannot schedule procedures on the current server,\n" + "the role is monitoring");
      return CommandResult.NO_EFFECT;
    }

    IRuntimeSettings runtime = (IRuntimeSettings) ServiceManager.get(IRuntimeSettings.class);
    String procId =
        (String) runtime.getRuntimeProperty(RuntimeProperty.ID_NAVIGATION_VIEW_SELECTION);
    if (procId != null) {
      ConditionDialog dlg = new ConditionDialog(window.getShell());
      dlg.open();
      String condition = dlg.getCondition();
      if (condition != null) {
        ScheduleProcedureJob job = new ScheduleProcedureJob(procId, condition);
        CommandHelper.executeInProgress(job, true, true);
        if (job.result != CommandResult.SUCCESS) {
          MessageDialog.openError(window.getShell(), "Schedule error", job.message);
        }
        return job.result;
      } else {
        return CommandResult.NO_EFFECT;
      }
    } else {
      return CommandResult.NO_EFFECT;
    }
  }
  public boolean downloadModel(String folderName, String modelName) {
    logger.debug("IN");
    boolean toReturn = true;

    SpagoBIServerObjectsFactory proxyServerObjects = null;

    try {
      proxyServerObjects = new SpagoBIServerObjectsFactory(projectName);

      Template template =
          proxyServerObjects.getServerDocuments().downloadDatamartFile(folderName, modelName);

      if (template == null) {
        logger.error("The download operation has returned a null object!");
        return false;
      }
      overwriteTemplate(template);
    } catch (NullPointerException e) {
      logger.error(
          "No comunication with server, check SpagoBi Server definition in preferences page", e);
      MessageDialog.openError(
          getShell(),
          "Error",
          "No comunication with server, check SpagoBi Server definition in preferences page");
      return false;
    } catch (Exception e) {
      logger.error("No comunication with SpagoBI server, could not retrieve template", e);
      MessageDialog.openError(
          getShell(), "Error", "Could not get the template from server for document");
      return false;
    }

    logger.debug("OUT");
    return toReturn;
  }
  /** @return true if commit info is ok */
  public boolean checkCommitInfo() {
    updateStateFromUI();

    if (commitMessage.trim().length() == 0) {
      MessageDialog.openWarning(
          getShell(),
          UIText.CommitDialog_ErrorNoMessage,
          UIText.CommitDialog_ErrorMustEnterCommitMessage);
      return false;
    }

    boolean authorValid = false;
    if (author.length() > 0) authorValid = RawParseUtils.parsePersonIdent(author) != null;
    if (!authorValid) {
      MessageDialog.openWarning(
          getShell(),
          UIText.CommitDialog_ErrorInvalidAuthor,
          UIText.CommitDialog_ErrorInvalidAuthorSpecified);
      return false;
    }

    boolean committerValid = false;
    if (committer.length() > 0) committerValid = RawParseUtils.parsePersonIdent(committer) != null;
    if (!committerValid) {
      MessageDialog.openWarning(
          getShell(),
          UIText.CommitDialog_ErrorInvalidAuthor,
          UIText.CommitDialog_ErrorInvalidCommitterSpecified);
      return false;
    }

    authorHandler.updateProposals();
    committerHandler.updateProposals();
    return true;
  }
Exemplo n.º 22
0
  private void populateTableWithTupleTemplate() {
    Table table = m_fieldsView.table;

    Set<String> existingRowAliases = new HashSet<String>();
    for (int i = 0; i < table.getItemCount(); i++) {
      TableItem tableItem = table.getItem(i);
      String alias = tableItem.getText(1);
      if (!Const.isEmpty(alias)) {
        existingRowAliases.add(alias);
      }
    }

    int choice = 0;
    if (existingRowAliases.size() > 0) {
      // Ask what we should do with existing mapping data
      MessageDialog md =
          new MessageDialog(
              m_shell,
              Messages.getString("MappingDialog.GetFieldsChoice.Title"),
              null,
              Messages.getString(
                  "MappingDialog.GetFieldsChoice.Message", "" + existingRowAliases.size(), "" + 5),
              MessageDialog.WARNING,
              new String[] {
                Messages.getString("MappingOutputDialog.ClearAndAdd"),
                Messages.getString("MappingOutputDialog.Cancel"),
              },
              0);
      MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
      int idx = md.open();
      choice = idx & 0xFF;
    }

    if (choice == 1 || choice == 255 /* 255 = escape pressed */) {
      return; // Cancel
    }

    m_fieldsView.clearAll();
    TableItem item = new TableItem(table, SWT.NONE);
    item.setText(1, "KEY");
    item.setText(2, "Y");
    item = new TableItem(table, SWT.NONE);
    item.setText(1, "Family");
    item.setText(2, "N");
    item.setText(5, "String");
    item = new TableItem(table, SWT.NONE);
    item.setText(1, "Column");
    item.setText(2, "N");
    item = new TableItem(table, SWT.NONE);
    item.setText(1, "Value");
    item.setText(2, "N");
    item = new TableItem(table, SWT.NONE);
    item.setText(1, "Timestamp");
    item.setText(2, "N");
    item.setText(5, "Long");

    m_fieldsView.removeEmptyRows();
    m_fieldsView.setRowNums();
    m_fieldsView.optWidth(true);
  }
 @Override
 public void run(TableLoadOption... tableLoadOptions) throws OseeCoreException {
   if (AtsUtil.isProductionDb()) {
     AWorkbench.popup("ERROR", "This should not to be run on production DB");
     return;
   }
   MessageDialog dialog =
       new MessageDialog(
           Displays.getActiveShell(),
           getName(),
           null,
           getName() + "\n\nSelect Source or Destination Client",
           MessageDialog.QUESTION,
           new String[] {
             "Source Client", "Destination Client - Start", "Destination Client - End", "Cancel"
           },
           2);
   int result = dialog.open();
   resultData = new XResultData();
   if (result == 0) {
     runClientTest();
   } else if (result == 1) {
     EntryDialog diag =
         new EntryDialog(getName(), "Enter tt number of Source Client created Action");
     if (diag.open() == 0) {
       runDestinationTestStart(diag.getEntry());
     }
   } else if (result == 2) {
     EntryDialog diag =
         new EntryDialog(getName(), "Enter tt number of Source Client created Action");
     if (diag.open() == 0) {
       runDestinationTestEnd(diag.getEntry());
     }
   }
 }
Exemplo n.º 24
0
  @Override
  public boolean performFinish() {
    IFile resultFile = page.getResultFile();
    if (resultFile != null) {
      ABSEditor editor =
          UtilityFunctions.openABSEditorForFile(resultFile.getLocation(), resultFile.getProject());
      IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());

      // modules are always added the the end of the document
      final int off = document.getLength();

      try {
        document.replace(off, 0, insertType.getInsertionString(page.getResult()));
        final int insertOffset = insertType.getInsertOffset(page.getResult());

        WizardUtil.saveEditorAndGotoOffset(editor, insertOffset);

        return true;
      } catch (BadLocationException e) {
        MessageDialog.openError(
            getShell(),
            "Error",
            "Fatal error: The insertion position for the new module does not longer exist. Please save the target file and try again.");
        e.printStackTrace();
        return false;
      }
    } else {
      MessageDialog.openError(
          getShell(),
          "Error",
          "Fatal error: No file reference was passed by the wizard. Please try again to use the wizard and select a valid file.");
      return false;
    }
  }
  public void doReload(ContentNode node, ContentVersion updated) throws Exception {
    if (updated
        .getMod()
        .equals(getInfoglueEditorInput().getContent().getContentVersion().getMod())) {
      System.out.println("This version seem to be up to date.");
      return;
    }

    if (!isDirty()
        || MessageDialog.openQuestion(
            PlatformUI.getWorkbench().getDisplay().getActiveShell(),
            "CMS Message",
            "The content "
                + getInfoglueEditorInput().getContent().getName()
                + " was changed remotely by user: "******". Do you want to reload the changed content?")) {
      // Only save the editors to remove dirty flag, not the editorinput (sent to cms)
      // TODO: ??????
      for (int i = 0; i < getPageCount(); i++) {
        getEditor(i).doSave(null);
      }

      IFolder tmp = ProjectHelper.getProject(node).getFolder("WebContent");
      setInput(InfoglueCMS.openContentVersion(node));

    } else if (isDirty()) {
      MessageDialog.openInformation(
          this.getActiveEditor().getSite().getShell(),
          "Unhandled situation",
          "The content was updated on the server, the local version is not the latest and synchronization/update feature is still not implemented. Your changes might not get saved to CMS");
    }
  }
Exemplo n.º 26
0
 public final void unloadSelectedCustoms() {
   final IStructuredSelection selection =
       (IStructuredSelection)
           LoadCustomizationsDialog.this.selectedCustomizationsTreeViewer.getSelection();
   final List<Customization> toBeRemoved = new ArrayList<Customization>();
   boolean lockedCustomFound = false;
   for (Object object : selection.toList()) {
     if (this.lockedCustoms.contains(object)) {
       lockedCustomFound = true;
     } else if (object instanceof Customization) {
       final Customization element = (Customization) object;
       toBeRemoved.add(element);
     }
   }
   if (lockedCustomFound) {
     final MessageDialog dialog =
         new MessageDialog(
             null,
             Messages.LoadCustomizationsDialog_LoadCustomizationWarning,
             null,
             Messages.LoadCustomizationsDialog_Can_not_be_unload + this.lockMsg,
             MessageDialog.WARNING,
             new String[] {Messages.LoadCustomizationsDialog_OK},
             1);
     dialog.open();
   }
   removeFromSelection(toBeRemoved);
   refresh();
 }
Exemplo n.º 27
0
  protected void testQuery() {
    try {
      // ClassArrayShell whether model is null
      if (sqlPredicate == null) {
        MessageDialog.openWarning(top.getShell(), "Warning!", "The predicate is null");
        //		return;
      }
      // ClassArrayShell whether there is a name
      if (textName.getText() == null || textName.getText().trim().length() == 0) {
        MessageDialog.openWarning(top.getShell(), "Warning!", "The predicate should have a name");
        //		return;
      }
      // ClassArrayShell whether there is a data source
      if (sqlPredicate.getDataSource() == null) {
        MessageDialog.openWarning(top.getShell(), "Warning!", "There is no datasource set");
        //		return;
      }

      // ClassArrayShell SQL
      DataSource ds = sqlPredicate.getDataSource();
      Connection con = ds.getConnection();
      java.sql.Statement stmt = con.createStatement();
      final ResultSet rs = stmt.executeQuery(sqlPredicate.getQuery());

      QueryResultsDialog dialog = new QueryResultsDialog(getSite().getShell(), sqlPredicate, rs);
      dialog.create();
      if (dialog.open() != InputDialog.OK) return;
    } catch (Exception x) {
      MessageDialog.openError(top.getShell(), "Error!", "Test has failed");
    }
  }
 private void handleNewIntro() {
   boolean needNewProduct = false;
   if (!productDefined()) {
     needNewProduct = true;
     MessageDialog mdiag =
         new MessageDialog(
             PDEPlugin.getActiveWorkbenchShell(),
             PDEUIMessages.IntroSection_undefinedProductId,
             null,
             PDEUIMessages.IntroSection_undefinedProductIdMessage,
             MessageDialog.QUESTION,
             new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL},
             0);
     if (mdiag.open() != Window.OK) return;
   }
   ProductIntroWizard wizard = new ProductIntroWizard(getProduct(), needNewProduct);
   WizardDialog dialog = new WizardDialog(PDEPlugin.getActiveWorkbenchShell(), wizard);
   dialog.create();
   if (dialog.open() == Window.OK) {
     String id = wizard.getIntroId();
     fIntroCombo.add(id, 0);
     fIntroCombo.setText(id);
     getIntroInfo().setId(id);
     addDependenciesAndPlugins();
   }
 }
Exemplo n.º 29
0
 /**
  * This method is called when 'Finish' button is pressed in the wizard. We will create an
  * operation and run it using wizard as execution context.
  */
 public boolean performFinish() {
   final String fileName = page.getProjectName();
   IRunnableWithProgress op =
       new IRunnableWithProgress() {
         public void run(IProgressMonitor monitor) throws InvocationTargetException {
           try {
             doFinish(fileName, monitor);
           } catch (CoreException e) {
             throw new InvocationTargetException(e);
           } finally {
             monitor.done();
           }
         }
       };
   try {
     getContainer().run(true, false, op);
     workbench.showPerspective(
         "edu.rosehulman.soar.perspective.SoarPerspectiveFactory",
         workbench.getWorkbenchWindows()[0]);
   } catch (InterruptedException e) {
     return false;
   } catch (InvocationTargetException e) {
     Throwable realException = e.getTargetException();
     MessageDialog.openError(getShell(), "Error", realException.getMessage());
     return false;
   } catch (WorkbenchException e) {
     MessageDialog.openError(getShell(), "Error", e.getMessage());
     return false;
   }
   return true;
 }
  @Inject
  public void setSelection(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Contact contact) {
    if (contact != null) {
      if (dirtyable.isDirty()) {
        MessageDialog dialog =
            new MessageDialog(
                detailComposite.getShell(),
                "Save vCard",
                null,
                "The current vCard has been modified. Save changes?",
                MessageDialog.CONFIRM,
                new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL},
                0);
        dialog.create();
        ThemeUtil.applyDialogStyles(engine, dialog.getShell());
        if (dialog.open() == Window.OK) {
          ParameterizedCommand saveCommand =
              commandService.createCommand("contacts.save", Collections.EMPTY_MAP);
          handlerService.executeHandler(saveCommand);
        }
      }

      updatePartTitle(contact);
    } else {
      uiItem.setLabel("Details");
    }
    dirtyable.setDirty(false);
    if (!detailComposite.isDisposed()) {
      detailComposite.update(contact);
    }
  }